View | Details | Raw Unified | Return to bug 20212
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-233 / +397 lines)
Lines 34-49 Link Here
34
        <div class="col-sm-10 col-sm-push-2">
34
        <div class="col-sm-10 col-sm-push-2">
35
            <main>
35
            <main>
36
36
37
	[% IF ( receive_error ) %]
37
    [% IF ( receive_error ) %]
38
	<div class="dialog alert">
38
    <div class="dialog alert">
39
	<h3>Error adding items:</h3>
39
    <h3>Error adding items:</h3>
40
	<ul>
40
    <ul>
41
	[% FOREACH error_loo IN error_loop %]
41
    [% FOREACH error_loo IN error_loop %]
42
		<li>[% error_loo.error_param | html %][% IF ( error_loo.error_duplicate_barcode ) %]Duplicate Barcode[% END %] <!-- todo: other error conditions come here. --></li>
42
        <li>[% error_loo.error_param | html %][% IF ( error_loo.error_duplicate_barcode ) %]Duplicate Barcode[% END %] <!-- todo: other error conditions come here. --></li>
43
	[% END %]
43
    [% END %]
44
	</ul>
44
    </ul>
45
	</div>
45
    </div>
46
	[% END %]
46
    [% END %]
47
    <h1>
47
    <h1>
48
        [% IF datereceived %]
48
        [% IF datereceived %]
49
            Receipt summary for <em>[% name | html %]</em> [% IF ( invoice ) %] <em> [ [% invoice | html %] ] </em>[% END %] on <em>[% datereceived | $KohaDates %]</em>
49
            Receipt summary for <em>[% name | html %]</em> [% IF ( invoice ) %] <em> [ [% invoice | html %] ] </em>[% END %] on <em>[% datereceived | $KohaDates %]</em>
Lines 55-66 Link Here
55
    [% IF ( success_delorder ) %]
55
    [% IF ( success_delorder ) %]
56
    <div class="dialog message">The order has been successfully canceled.</div>
56
    <div class="dialog message">The order has been successfully canceled.</div>
57
    [% ELSE %]
57
    [% ELSE %]
58
	[% IF ( error_delitem ) %]
58
    [% IF ( error_delitem ) %]
59
	    <div class="dialog alert">The order has been canceled, although one or more items could not have been deleted.</div>
59
        <div class="dialog alert">The order has been canceled, although one or more items could not have been deleted.</div>
60
	[% END %]
60
    [% END %]
61
	[% IF ( error_delbiblio ) %]
61
    [% IF ( error_delbiblio ) %]
62
	    <div class="dialog alert">The order has been canceled, although the record has not been deleted.</div>
62
        <div class="dialog alert">The order has been canceled, although the record has not been deleted.</div>
63
	[% END %]
63
    [% END %]
64
    [% END %]
64
    [% END %]
65
65
66
    [% IF (error_cancelling_receipt) %]
66
    [% IF (error_cancelling_receipt) %]
Lines 92-215 Link Here
92
<p><strong>Invoice number:</strong> [% invoice | html %] <strong>Received by:</strong> [% logged_in_user.userid | html %] <strong>On:</strong> [% datereceived | $KohaDates %]</p>
92
<p><strong>Invoice number:</strong> [% invoice | html %] <strong>Received by:</strong> [% logged_in_user.userid | html %] <strong>On:</strong> [% datereceived | $KohaDates %]</p>
93
</div>
93
</div>
94
[% UNLESS (invoiceclosedate) %]
94
[% UNLESS (invoiceclosedate) %]
95
  <div id="acqui_receive_search">
95
    <div id="acqui_receive_search">
96
    <h3>Pending orders</h3>
96
        <h3>Pending orders</h3>
97
97
        <table id="pending_orders" class="table table-bordered table-striped">
98
    [% IF ( loop_orders ) %]
98
            <thead>
99
      <table id="pendingt">
99
                <tr>
100
        <thead>
100
                    <th>Basket</th>
101
          <tr>
101
                    <th>Basket group</th>
102
            <th>Basket search</th>
102
                    <th>Order line</th>
103
            <th>Basket group search</th>
103
                    <th class="hidden">Title</th>
104
            <th>Order line search</th>
104
                    <th class="hidden">Author</th>
105
            <th>Summary search</th>
105
                    <th class="hidden">ISBN</th>
106
            <th>&nbsp;</th>
106
                    <th>Summary</th>
107
            <th>Replacement price search</th>
107
                    <th>More</th>
108
            <th>Quantity search</th>
108
                    <th>Replacement price</th>
109
            <th>Unit cost search</th>
109
                    <th>Quantity</th>
110
            <th>Order cost search</th>
110
                    <th>Unit cost</th>
111
            <th>Fund search</th>
111
                    <th>Order cost</th>
112
            <th>&nbsp;</th>
112
                    <th>Fund</th>
113
            <th>&nbsp;</th>
113
                    <th>&nbsp;</th>
114
          </tr>
114
                    <th>&nbsp;</th>
115
          <tr>
116
            <th>Basket</th>
117
            <th>Basket group</th>
118
            <th>Order line</th>
119
            <th>Summary</th>
120
            <th>More</th>
121
            <th>Replacement price</th>
122
            <th>Quantity</th>
123
            <th>Unit cost</th>
124
            <th>Order cost</th>
125
            <th>Fund</th>
126
            <th>&nbsp;</th>
127
            <th>&nbsp;</th>
128
          </tr>
129
        </thead>
130
        <tbody class="filterclass">
131
        [% FOREACH loop_order IN loop_orders %]
132
            <tr>
133
                <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno | uri %]">[% loop_order.basketname | html %] ([% loop_order.basketno | html %])</a></td>
134
                <td>
135
                  [% IF loop_order.basketgroupid %]
136
                  <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid=[% booksellerid | uri %]&amp;basketgroupid=[% loop_order.basketgroupid | uri %]">[% loop_order.basketgroupname | html %] ([% loop_order.basketgroupid | html %])</a>
137
                  [% ELSE %]
138
                    No basket group
139
                  [% END %]
140
                </td>
141
                <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber | uri %]&amp;booksellerid=[% loop_order.booksellerid | uri %]">[% loop_order.ordernumber | html %]</a></td>
142
                <td class="summaryfilterclass">
143
                  <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber | uri %]">[% loop_order.title | html %]</a>
144
                [% IF ( loop_order.author ) %] by [% loop_order.author | html %][% END %]
145
                [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn | html %][% END %]
146
                [% IF ( loop_order.publishercode ) %]
147
                    <br />Publisher: [% loop_order.publishercode | html %]
148
                    [%- IF    ( loop_order.publicationyear > 0) -%], [% loop_order.publicationyear | html %]
149
                    [%- ELSIF ( loop_order.copyrightdate   > 0) -%] [% loop_order.copyrightdate | html %]
150
                    [% END %]
151
                [% END %]
152
                [% IF ( loop_order.suggestionid ) %]
153
                    <br/>
154
                    Suggested by: <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid | uri %]&amp;op=show">[% loop_order.surnamesuggestedby | html %][% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby | html %] [% END %]( #[% loop_order.suggestionid | html %])</a>
155
                [% END %]
156
                <br />
157
                [% IF ( loop_order.order_internalnote ) %]
158
                    <p class="ordernote"><strong>Internal note: </strong>[% loop_order.order_internalnote | html %] [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber | uri %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]&type=internal">Change internal note</a>]</p>
159
                [% ELSE %]
160
                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber | uri %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]&type=internal">Add internal note</a>]
161
                [% END %]
162
                [% IF ( loop_order.order_vendornote ) %]
163
                    <p class="ordernote"><strong>Vendor note: </strong>[% loop_order.order_vendornote | html %]</p>
164
                [% ELSE %]
165
                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber | uri %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]&type=vendor">Add vendor note</a>]
166
                [% END %]
167
                </td>
168
                <td>
169
                  <a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=[% loop_order.ordernumber | uri %]" class="previewData">[% tp('noun', 'Order') | html %]</a><br>
170
                  <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber | uri %]" class="previewData">MARC</a><br>
171
                  <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber | uri %]" class="previewData">Card</a>
172
                </td>
173
                <td>[% loop_order.replacementprice | $Price %]</td>
174
                <td>[% loop_order.quantity | html %]</td>
175
                <td>[% loop_order.ecost | $Price %]</td>
176
                <td>[% loop_order.total | $Price %]</td>
177
                <td>[% loop_order.budget_name | html %]</td>
178
				<td>
179
                              <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber | uri %]&amp;invoiceid=[% invoiceid | uri %]">Receive</a>
180
                    <br />
181
                    <a href="#" onclick="transfer_order_popup([% loop_order.ordernumber | html %]); return false;">Transfer</a>
182
				</td>
183
				<td>
184
                        [% IF ( loop_order.left_holds_on_order ) %]
185
                        <span class="button" title="Can't cancel order, ([% loop_order.holds_on_order | html %]) holds are linked with this order. Cancel holds first">Can't cancel order</span><br>
186
                        [% ELSE %]
187
                        <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% loop_order.ordernumber | uri %]&biblionumber=[% loop_order.biblionumber | uri %]&referrer=[% "/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid" | uri %]">Cancel order</a><br />
188
                        [% END %]
189
                        [% IF ( loop_order.can_del_bib ) %]
190
                        <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% loop_order.ordernumber | uri %]&biblionumber=[% loop_order.biblionumber | uri %]&del_biblio=1&referrer=[% "/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid" | uri %]">Cancel order and catalog record</a><br />
191
                        [% ELSE %]
192
                        <span class="button" title="Can't delete catalog record, see constraints below">Can't cancel order and delete catalog record</span><br>
193
                        [% END %]
194
                        [% IF ( loop_order.left_item ) %]
195
                        <strong title="Can't delete catalog record, because of [% loop_order.items | html %] existing item(s)" >[% loop_order.items | html %] item(s) left</strong><br>
196
                        [% END %]
197
                        [% IF ( loop_order.left_biblio ) %]
198
                        <strong title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios | html %] order(s) left</strong><br>
199
                        [% END %]
200
                        [% IF ( loop_order.left_subscription ) %]
201
                        <strong title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions | html %] subscription(s) left</strong><br>
202
                        [% END %]
203
                        [% IF ( loop_order.left_holds ) %]
204
                        <strong title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds | html %] hold(s) left</strong>
205
                        [% END %]
206
                    </td>
207
                </tr>
115
                </tr>
208
        [% END %]
116
            </thead>
209
        </tbody>
117
        </table>
210
      </table>
118
    </div>
211
    [% ELSE %]There are no pending orders.[% END %]
212
  </div>
213
[% ELSE %]
119
[% ELSE %]
214
    <p>
120
    <p>
215
        Invoice is closed, so you can't receive orders anymore.
121
        Invoice is closed, so you can't receive orders anymore.
Lines 367-378 Link Here
367
                    [% END %]
273
                    [% END %]
368
                </td>
274
                </td>
369
            </tr>
275
            </tr>
370
	    [% END %]
276
        [% END %]
371
	</tbody>
277
    </tbody>
372
    </table>
278
    </table>
373
    </form>
279
    </form>
374
280
375
	[% ELSE %]There are no received orders.[% END %]
281
    [% ELSE %]There are no received orders.[% END %]
376
</div>
282
</div>
377
283
378
<div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
284
<div id="dataPreview" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
Lines 433-439 Link Here
433
      </li>
339
      </li>
434
      [% IF (UNIMARC) %]
340
      [% IF (UNIMARC) %]
435
        <li>
341
        <li>
436
          <label for="eanfilter">EAN :</label>
342
          <label for="eanfilter">EAN:</label>
437
          <input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter | html %]"/>
343
          <input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter | html %]"/>
438
        </li>
344
        </li>
439
      [% END %]
345
      [% END %]
Lines 442-448 Link Here
442
      <input type="hidden" value="search" name="op" />
348
      <input type="hidden" value="search" name="op" />
443
      <input type="hidden" value="[% invoiceid | html %]" name="invoiceid" />
349
      <input type="hidden" value="[% invoiceid | html %]" name="invoiceid" />
444
      <input type="submit" value="Filter" />
350
      <input type="submit" value="Filter" />
445
      <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">Clear</a>
351
      <a href="#" id="clear_form_filters">Clear</a>
446
    </fieldset>
352
    </fieldset>
447
  </fieldset>
353
  </fieldset>
448
</form>
354
</form>
Lines 462-554 Link Here
462
        var sticky_filters = [% sticky_filters | html %];
368
        var sticky_filters = [% sticky_filters | html %];
463
369
464
        $(document).ready(function(){
370
        $(document).ready(function(){
465
          if ( $("#pendingt").length ) {
371
466
            var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, {
372
            if ( $("#receivedt").length ) {
467
                "bStateSave": true,
373
                var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
468
                "iCookieDuration": 60*60*24*1000, // 1000 days
374
                    "bStateSave": true,
469
                "iDisplayLength": 10,
375
                    "iCookieDuration": 60*60*24*1000, // 1000 days
470
                "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
376
                    "iDisplayLength": 10,
471
                "aoColumnDefs": [
377
                    "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
472
                    { "aTargets": [ 4, 9, 10 ], "bSortable": false, "bSearchable": false },
378
                    "aoColumnDefs": [
473
                ],
379
                        { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false },
474
                "aoColumns": [
380
                    ],
475
                    { "sType": "html" },
381
                    "aoColumns": [
476
                    { "sType": "html" },
382
                        { "sType": "html" },
477
                    { "sType": "num-html" },
383
                        { "sType": "html" },
478
                    { "sType": "anti-the" },
384
                        { "sType": "html" },
479
                    null,
385
                        { "sType": "num-html" },
480
                    null,
386
                        { "sType": "anti-the" },
481
                    null,
387
                        null,
482
                    null,
388
                        null,
483
                    null,
389
                        null,
484
                    null,
390
                        null,
485
                    null,
391
                        null,
486
                    null,
392
                        null,
393
                        null,
394
                        null
395
                    ],
396
                    "sPaginationType": "full"
397
                }));
398
            }
399
400
            var base_query = { "basket.vendor_id": [% booksellerid | html %]  };
401
            var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1';
402
            var pending_orders_table = $("#pending_orders").api({
403
                "ajax": {
404
                    "url": pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))
405
                },
406
                "header_filter": true,
407
                "embed": [
408
                    "basket.basket_group",
409
                    "biblio.active_orders+count",
410
                    "biblio.holds+count",
411
                    "biblio.items+count",
412
                    "biblio.suggestions.suggester",
413
                    "fund",
414
                    "current_item_level_holds+count",
415
                    "items"
487
                ],
416
                ],
488
                'bAutoWidth': false,
417
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
489
                "sPaginationType": "full"
418
                "columns": [
490
            } )
419
                    { "data": "basket.name",
491
            ).columnFilter({
420
                      "orderable": true,
492
                sPlaceHolder: "head:after",
421
                      "render": function(data, type, row, meta) {
493
                aoColumns: [
422
                        if (type != 'display') return data;
494
                    { type: "text" },
423
                        return "<a href=\"/cgi-bin/koha/acqui/basket.pl?basketno=" + row.basket.basket_id + "\">" + data + " (" + row.basket.basket_id + ")</a>";
495
                    { type: "text" },
424
                      }
496
                    { type: "text" },
425
                    },
497
                    { type: "text" },
426
                    { "data": "basket.basket_group.name",
498
                    null,
427
                      "orderable": true,
499
                    { type: "text" },
428
                      "render": function(data, type, row, meta) {
500
                    { type: "text" },
429
                        if ( type != 'display' ) {
501
                    { type: "text" },
430
                            if ( data == null ) {
502
                    { type: "text" },
431
                                return "";
503
                    { type: "text" },
432
                            }
504
                    null,
433
                            else {
505
                    null
434
                                return data;
435
                            }
436
                        }
437
                        if ( row.basket.basket_group_id == null ) {
438
                            return _("No basket group");
439
                        }
440
                        else {
441
                            return "<a href=\"/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid="
442
                                    + row.basket.vendor_id + "&amp;basketgroupid="
443
                                    + row.basket.basket_group_id + "\">"
444
                                    + row.basket.basket_group.name + " (" + row.basket.basket_group_id + ")</a>";
445
                        }
446
                      }
447
                    },
448
                    { "data": "order_id",
449
                      "render": function(data, type, row, meta) {
450
                        if (type != 'display') return data;
451
                        return "<a href=\"neworderempty.pl?ordernumber="+data+"&amp;booksellerid="+row.basket.vendor_id+"\">"+data+"</a>";
452
                      }
453
                    },
454
                    {
455
                        "data": "biblio.author",
456
                        "visible": false,
457
                        "searchable": true,
458
                        "orderable": false
459
                    },
460
                    {
461
                        "data": "biblio.title",
462
                        "visible": false,
463
                        "searchable": true,
464
                        "orderable": false
465
                    },
466
                    {
467
                        "data": "biblio.isbn",
468
                        "visible": false,
469
                        "searchable": true,
470
                        "orderable": false
471
                    },
472
                    { "data": function(row, type, val, meta) {
473
                        if ( row.biblio_id == null ) {
474
                            window.alert(row);
475
                        }
476
                        var result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+row.biblio_id+"\">"+row.biblio.title+"</a>";
477
                        if ( row.biblio.author != null )
478
                            result += _(" by ") + row.biblio.author;
479
                        if ( row.biblio.isbn != null )
480
                            result += " &ndash; " + row.biblio.isbn;
481
                        if ( row.biblio.publisher != null ) {
482
                            result += "<br/>" + _("Publisher: ") + row.biblio.publisher;
483
                            if ( row.biblio.publication_year != null ) {
484
                                result += ", " + row.biblio.publication_year;
485
                            }
486
                            else if ( row.biblio.copyright_date != null ) {
487
                                result += row.biblio.copyright_date;
488
                            }
489
                        }
490
                        var suggestions = row.biblio.suggestions;
491
                        if ( suggestions != null && suggestions.length > 0 ) {
492
                            var suggestion = suggestions[0];
493
                            if ( suggestion.suggester != null ) {
494
                                var suggester = suggestion.suggester;
495
                                var suggested_by = [];
496
                                if ( suggester.surname != null ) {
497
                                    suggested_by.push(suggester.surname);
498
                                }
499
                                if ( suggester.firstname != null ) {
500
                                    suggested_by.push(suggester.firstname);
501
                                }
502
503
                                    result += "<br/>" + _("Suggested by: ") +
504
                                                '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
505
                                                    + suggestion.suggestionid
506
                                                    + '&amp;op=show">'
507
                                                    + suggested_by.join(", ")
508
                                                    + " (#" + suggestions[0].suggestionid + ")</a>";
509
                            }
510
                        }
511
                        result += '</p>';
512
513
                        var internal_note = row.internal_note;
514
                        if ( internal_note != '' ) {
515
                            result += '<p class="ordernote"><strong>'
516
                                        + _("Internal note: ")
517
                                        + '</strong>' + internal_note
518
                                        + ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
519
                                        + row.order_id + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
520
                                        + '&type=internal">' + _("Change internal note") + '</a>]</p>';
521
                        }
522
                        else {
523
                            result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
524
                                        + row.order_id + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
525
                                        + '&type=internal">' + _("Add internal note") + '</a>]';
526
                        }
527
528
                        var vendor_note = row.vendor_note;
529
                        if ( vendor_note != '' ) {
530
                            result += '<p class="ordernote"><strong>'
531
                                        + _("Vendor note: ")
532
                                        + '</strong>' + vendor_note + '</p>';
533
                        }
534
                        else {
535
                            result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
536
                                        + row.order_id + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
537
                                        + '&type=vendor">' + _("Add vendor note") + '</a>]';
538
                        }
539
540
                        return result;
541
                      },
542
                      "orderable": false // FIXME
543
                    },
544
                    { "data": function( row, type, val, meta) {
545
                            var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + row.order_id + '" class="previewData">' + _("Order") + '</a><br>'
546
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + row.biblio_id + '" class="previewData">' + _("MARC") + '</a><br>'
547
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + row.biblio_id + '" class="previewData">' + _("Card") + '</a>';
548
                            return result;
549
                      },
550
                      "orderable": false
551
                    },
552
                    { "data": "replacement_price",
553
                      "render": function(data, type, val, meta) {
554
                        if (type != 'display') return data;
555
                        return data.format_price();
556
                      }
557
                    },
558
                    { "data": "quantity",
559
                      "orderable": true
560
                    },
561
                    { "data": "ecost",
562
                      "render": function(data, type, val, meta) {
563
                        if (type != 'display') return data;
564
                        return data.format_price();
565
                      },
566
                      "orderable": true
567
                    },
568
                    { "data": function ( row, type, val, meta ) {
569
                            return (row.quantity * row.ecost).format_price();
570
                      },
571
                      "orderable": false // FIXME: How can we do it in DBIC?
572
                    },
573
                    { "data": "fund_id",
574
                      "render": function(data, type, row, meta) {
575
                        if (type != 'display') return data;
576
                        return row.fund.name;
577
                      }
578
                    },
579
                    { "data": function( row, type, val, meta ) {
580
                        return '<a href="orderreceive.pl?ordernumber='
581
                                + row.order_id + '&amp;invoiceid=[% invoiceid | uri %]' + '">'
582
                                + _("Receive") + '</a><br/>'
583
                                + '<a href="#" onclick="transfer_order_popup(' + row.order_id + '); return false;">'
584
                                + _("Transfer") + '</a>';
585
                      },
586
                      "orderable": false
587
                    },
588
                    { "data": function( row, type, val, meta ) {
589
                            var result = "";
590
591
                            if ( row.current_holds_count > 0 ) {
592
                                result += '<span class="button" title="'
593
                                        + _("Can't cancel order, (%s) holds are linked with this order. Cancel holds first").format( row.holds_count ) + '">'
594
                                        + _("Can't cancel order") + '</span><br/>';
595
                            }
596
                            else {
597
                                result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber='
598
                                            + row.order_id
599
                                            + '&biblionumber=' + row.biblio_id
600
                                            + '&referrer=/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">'
601
                                            + _("Cancel order") + '</a><br/>';
602
                            }
603
604
                            if ( row.items.length > 0 ||
605
                                row.biblio.active_orders_count > 1 ||
606
                                row.biblio.subscriptions_count > 0 ||
607
                                row.biblio.holds_count > 0 ) { // biblio can be deleted
608
                                result += '<span class="button" title="'
609
                                        + _("Can't delete catalog record, see constraints below") + '">'
610
                                        + _("Can't cancel order and delete catalog record") + '</span><br>';
611
                            }
612
                            else {
613
                                result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber='
614
                                        + row.order_id + '&biblionumber=' + row.biblio_id
615
                                        + '&del_biblio=1&referrer="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[$ invoiceid | uri ]">'
616
                                        + _("Cancel order and catalog record") + '</a><br/>';
617
                            }
618
619
                            if ( row.biblio.items_count - row.items.length > 0 ) {
620
                                result += '<strong title="'
621
                                        + _("Can't delete catalog record, because of %s existing item(s)").format(row.items.length)
622
                                        +'">' + (row.biblio.items_count - row.items.length) + _(" item(s) left") + '</strong><br/>';
623
                            }
624
625
                            if ( row.biblio.active_orders_count > 1 ) {
626
                                result += '<strong title="'
627
                                        + _("Can't delete catalog record, delete other orders linked to it first") + '">'
628
                                        + (row.biblio.active_orders_count - 1) + _(" order(s) left") + '</strong><br/>';
629
                            }
630
631
                            if ( row.biblio.subscriptions_count > 0 ) {
632
                                result += '<strong title="' + _("Can't delete catalog record, delete subscriptions first") + '">'
633
                                        + _("%s subscription(s) left").format(row.biblio.subscriptions_count)
634
                                        + '</strong><br>';
635
                            }
636
637
                            if ( row.biblio.holds_count > 0 ) {
638
                                result += '<strong title="' + _("Can't delete catalog record or order, cancel holds first") + '">'
639
                                        + _("%s hold(s) left").format(row.biblio.holds_count) + '</strong>';
640
                            }
641
642
                            return result;
643
                      },
644
                      "orderable": false
645
                    }
506
                ]
646
                ]
507
            });
647
            });
508
          }
648
509
649
            $("#filterform").on("submit", function(e) {
510
          if ( $("#receivedt").length ) {
650
                e.preventDefault();
511
            var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
651
                // Update the datatable URL
512
                "bStateSave": true,
652
                var summary      = $("#summaryfilter").val();
513
                "iCookieDuration": 60*60*24*1000, // 1000 days
653
                var basket_name  = $("#basketfilter").val();
514
                "iDisplayLength": 10,
654
                var basket_group = $("#basketgroupnamefilter").val();
515
                "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
655
                var order_id     = $("#orderfilter").val();
516
                "aoColumnDefs": [
656
                var ean          = $("#eanfilter").val();
517
                    { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false },
657
518
                ],
658
                var query_and = [];
519
                "aoColumns": [
659
520
                    { "sType": "html" },
660
                if (basket_name != "") {
521
                    { "sType": "html" },
661
                    query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } );
522
                    { "sType": "html" },
662
                }
523
                    { "sType": "num-html" },
663
                if (basket_group != "") {
524
                    { "sType": "anti-the" },
664
                    query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } );
525
                    null,
665
                }
526
                    null,
666
                if (summary != "") {
527
                    null,
667
                    query_and.push( { "-or": [{"biblio.title":  { "like": '%'+summary+'%' } },
528
                    null,
668
                                {"biblio.author": { "like": '%'+summary+'%' } },
529
                    null,
669
                                {"biblio.isbn":   { "like": '%'+summary+'%' } } ] } );
530
                    null,
670
                }
531
                    null,
671
            [% IF (UNIMARC) %]
532
                    null
672
                if (ean != "") {
533
                ],
673
                    query_and.push( { "biblio.ean": ean } );
534
                "sPaginationType": "full"
674
                }
535
            }));
675
            [% END %]
536
          }
676
537
677
                if ( !jQuery.isEmptyObject(query_and) || order_id != "" ) {
538
          // Keep filters from finishreceive.pl to parcel.pl
678
539
          $.cookie("filter_parcel_summary", $("#summaryfilter").val());
679
                    var query_params = [];
540
          $.cookie("filter_parcel_basketname", $("#basketfilter").val());
680
541
          $.cookie("filter_parcel_orderno", $("#orderfilter").val());
681
                    if ( order_id != "" ) {
542
          $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
682
                        query_params.push("order_id="+order_id);
543
          $.cookie("filter_parcel_ean", $("#eanfilter").val());
683
                    }
544
684
545
          $("#filterform").on('submit', function(){
685
                    if ( !jQuery.isEmptyObject(query_and) ) {
686
                        query_and.push(base_query);
687
                        query_params.push('q=' + encodeURI(JSON.stringify({ "-and": query_and })));
688
                    }
689
690
                    pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") );
691
                }
692
                else {
693
                    pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) );
694
                }
695
                pending_orders_table.api().ajax.reload( null, false );
696
            });
697
698
            $('#clear_form_filters').on("click", function(){
699
                $(this).closest('form').find("input[type=text], textarea").val("");
700
                pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw();
701
            });
702
703
            // Keep filters from finishreceive.pl to parcel.pl
546
            $.cookie("filter_parcel_summary", $("#summaryfilter").val());
704
            $.cookie("filter_parcel_summary", $("#summaryfilter").val());
547
            $.cookie("filter_parcel_basketname", $("#basketfilter").val());
705
            $.cookie("filter_parcel_basketname", $("#basketfilter").val());
548
            $.cookie("filter_parcel_orderno", $("#orderfilter").val());
706
            $.cookie("filter_parcel_orderno", $("#orderfilter").val());
549
            $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
707
            $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
550
            $.cookie("filter_parcel_ean", $("#eanfilter").val());
708
            $.cookie("filter_parcel_ean", $("#eanfilter").val());
551
          });
709
710
            $("#filterform").on('submit', function(){
711
                $.cookie("filter_parcel_summary", $("#summaryfilter").val());
712
                $.cookie("filter_parcel_basketname", $("#basketfilter").val());
713
                $.cookie("filter_parcel_orderno", $("#orderfilter").val());
714
                $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
715
                $.cookie("filter_parcel_ean", $("#eanfilter").val());
716
            });
552
717
553
            $(".previewData").on("click", function(e){
718
            $(".previewData").on("click", function(e){
554
                e.preventDefault();
719
                e.preventDefault();
Lines 558-585 Link Here
558
                $("#dataPreview .modal-body").load(page + " div");
723
                $("#dataPreview .modal-body").load(page + " div");
559
                $('#dataPreview').modal({show:true});
724
                $('#dataPreview').modal({show:true});
560
            });
725
            });
726
561
            $("#dataPreview").on("hidden.bs.modal", function(){
727
            $("#dataPreview").on("hidden.bs.modal", function(){
562
                $("#dataPreviewLabel").html("");
728
                $("#dataPreviewLabel").html("");
563
                $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
729
                $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
564
            });
730
            });
731
        });
732
733
        // Case-insensitive version of jquery's contains function
734
        jQuery.extend(jQuery.expr[':'], {
735
            icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
736
        });
565
737
738
        // Contains exactly function
739
        jQuery.extend(jQuery.expr[':'], {
740
            containsExactly: "$(a).text() == m[3]"
566
        });
741
        });
567
742
568
         // Case-insensitive version of jquery's contains function
743
        function transfer_order_popup(ordernumber) {
569
         jQuery.extend(jQuery.expr[':'], {
744
        var url = "/cgi-bin/koha/acqui/transferorder.pl?"
570
	    icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
745
            + "ordernumber=" + ordernumber
571
         });
746
            window.open(url, 'TransferOrder');
572
747
        }
573
         // Contains exactly function
574
         jQuery.extend(jQuery.expr[':'], {
575
              containsExactly: "$(a).text() == m[3]"
576
         });
577
578
         function transfer_order_popup(ordernumber) {
579
            var url = "/cgi-bin/koha/acqui/transferorder.pl?"
580
                + "ordernumber=" + ordernumber
581
                window.open(url, 'TransferOrder');
582
         }
583
    </script>
748
    </script>
584
[% END %]
749
[% END %]
585
750
586
- 

Return to bug 20212