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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-233 / +390 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 <i>[% name | html %]</i> [% IF ( invoice ) %] <i> [ [% invoice | html %] ] </i>[% END %] on <i>[% datereceived | $KohaDates %]</i>
49
            Receipt summary for <i>[% name | html %]</i> [% IF ( invoice ) %] <i> [ [% invoice | html %] ] </i>[% END %] on <i>[% datereceived | $KohaDates %]</i>
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
                        <b title="Can't delete catalog record, because of [% loop_order.items | html %] existing item(s)" >[% loop_order.items | html %] item(s) left</b><br>
196
                        [% END %]
197
                        [% IF ( loop_order.left_biblio ) %]
198
                        <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios | html %] order(s) left</b><br>
199
                        [% END %]
200
                        [% IF ( loop_order.left_subscription ) %]
201
                        <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions | html %] subscription(s) left</b><br>
202
                        [% END %]
203
                        [% IF ( loop_order.left_holds ) %]
204
                        <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds | html %] hold(s) left</b>
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' ) return data;
501
                    { type: "text" },
430
                        if ( row.basket.basket_group_id == null ) {
502
                    { type: "text" },
431
                            return _("No basket group");
503
                    { type: "text" },
432
                        }
504
                    null,
433
                        else {
505
                    null
434
                            return "<a href=\"/cgi-bin/koha/acqui/basketgroup.pl?op=add&amp;booksellerid="
435
                                    + row.basket.vendor_id + "&amp;basketgroupid="
436
                                    + row.basket.basket_group_id + "\">"
437
                                    + row.basket.basket_group.name + " (" + row.basket.basket_group_id + ")</a>";
438
                        }
439
                      }
440
                    },
441
                    { "data": "order_id",
442
                      "render": function(data, type, row, meta) {
443
                        if (type != 'display') return data;
444
                        return "<a href=\"neworderempty.pl?ordernumber="+data+"&amp;booksellerid="+row.basket.vendor_id+"\">"+data+"</a>";
445
                      }
446
                    },
447
                    {
448
                        "data": "biblio.author",
449
                        "visible": false,
450
                        "searchable": true,
451
                        "orderable": false
452
                    },
453
                    {
454
                        "data": "biblio.title",
455
                        "visible": false,
456
                        "searchable": true,
457
                        "orderable": false
458
                    },
459
                    {
460
                        "data": "biblio.isbn",
461
                        "visible": false,
462
                        "searchable": true,
463
                        "orderable": false
464
                    },
465
                    { "data": function(row, type, val, meta) {
466
                        if ( row.biblio_id == null ) {
467
                            window.alert(row);
468
                        }
469
                        var result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+row.biblio_id+"\">"+row.biblio.title+"</a>";
470
                        if ( row.biblio.author != null )
471
                            result += _(" by ") + row.biblio.author;
472
                        if ( row.biblio.isbn != null )
473
                            result += " &ndash; " + row.biblio.isbn;
474
                        if ( row.biblio.publisher != null ) {
475
                            result += "<br/>" + _("Publisher: ") + row.biblio.publisher;
476
                            if ( row.biblio.publication_year != null ) {
477
                                result += ", " + row.biblio.publication_year;
478
                            }
479
                            else if ( row.biblio.copyright_date != null ) {
480
                                result += row.biblio.copyright_date;
481
                            }
482
                        }
483
                        var suggestions = row.biblio.suggestions;
484
                        if ( suggestions != null && suggestions.length > 0 ) {
485
                            var suggestion = suggestions[0];
486
                            if ( suggestion.suggester != null ) {
487
                                var suggester = suggestion.suggester;
488
                                var suggested_by = [];
489
                                if ( suggester.surname != null ) {
490
                                    suggested_by.push(suggester.surname);
491
                                }
492
                                if ( suggester.firstname != null ) {
493
                                    suggested_by.push(suggester.firstname);
494
                                }
495
496
                                    result += "<br/>" + _("Suggested by: ") +
497
                                                '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
498
                                                    + suggestion.suggestionid
499
                                                    + '&amp;op=show">'
500
                                                    + suggested_by.join(", ")
501
                                                    + " (#" + suggestions[0].suggestionid + ")</a>";
502
                            }
503
                        }
504
                        result += '</p>';
505
506
                        var internal_note = row.internal_note;
507
                        if ( internal_note != '' ) {
508
                            result += '<p class="ordernote"><strong>'
509
                                        + _("Internal note: ")
510
                                        + '</strong>' + internal_note
511
                                        + ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
512
                                        + row.order_id + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
513
                                        + '&type=internal">' + _("Change internal note") + '</a>]</p>';
514
                        }
515
                        else {
516
                            result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
517
                                        + row.order_id + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
518
                                        + '&type=internal">' + _("Add internal note") + '</a>]';
519
                        }
520
521
                        var vendor_note = row.vendor_note;
522
                        if ( vendor_note != '' ) {
523
                            result += '<p class="ordernote"><strong>'
524
                                        + _("Vendor note: ")
525
                                        + '</strong>' + vendor_note + '</p>';
526
                        }
527
                        else {
528
                            result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
529
                                        + row.order_id + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
530
                                        + '&type=vendor">' + _("Add vendor note") + '</a>]';
531
                        }
532
533
                        return result;
534
                      },
535
                      "orderable": false // FIXME
536
                    },
537
                    { "data": function( row, type, val, meta) {
538
                            var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + row.order_id + '" class="previewData">' + _("Order") + '</a><br>'
539
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + row.biblio_id + '" class="previewData">' + _("MARC") + '</a><br>'
540
                                + '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + row.biblio_id + '" class="previewData">' + _("Card") + '</a>';
541
                            return result;
542
                      },
543
                      "orderable": false
544
                    },
545
                    { "data": "replacement_price",
546
                      "render": function(data, type, val, meta) {
547
                        if (type != 'display') return data;
548
                        return data.format_price();
549
                      }
550
                    },
551
                    { "data": "quantity",
552
                      "orderable": true
553
                    },
554
                    { "data": "ecost",
555
                      "render": function(data, type, val, meta) {
556
                        if (type != 'display') return data;
557
                        return data.format_price();
558
                      },
559
                      "orderable": true
560
                    },
561
                    { "data": function ( row, type, val, meta ) {
562
                            return (row.quantity * row.ecost).format_price();
563
                      },
564
                      "orderable": false // FIXME: How can we do it in DBIC?
565
                    },
566
                    { "data": "fund_id",
567
                      "render": function(data, type, row, meta) {
568
                        if (type != 'display') return data;
569
                        return row.fund.name;
570
                      }
571
                    },
572
                    { "data": function( row, type, val, meta ) {
573
                        return '<a href="orderreceive.pl?ordernumber='
574
                                + row.order_id + '&amp;invoiceid=[% invoiceid | uri %]' + '">'
575
                                + _("Receive") + '</a><br/>'
576
                                + '<a href="#" onclick="transfer_order_popup(' + row.order_id + '); return false;">'
577
                                + _("Transfer") + '</a>';
578
                      },
579
                      "orderable": false
580
                    },
581
                    { "data": function( row, type, val, meta ) {
582
                            var result = "";
583
584
                            if ( row.current_holds_count > 0 ) {
585
                                result += '<span class="button" title="'
586
                                        + _("Can't cancel order, (%s) holds are linked with this order. Cancel holds first").format( row.holds_count ) + '">'
587
                                        + _("Can't cancel order") + '</span><br/>';
588
                            }
589
                            else {
590
                                result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber='
591
                                            + row.order_id
592
                                            + '&biblionumber=' + row.biblio_id
593
                                            + '&referrer=/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">'
594
                                            + _("Cancel order") + '</a><br/>';
595
                            }
596
597
                            if ( row.items.length > 0 ||
598
                                row.biblio.active_orders_count > 1 ||
599
                                row.biblio.subscriptions_count > 0 ||
600
                                row.biblio.holds_count > 0 ) { // biblio can be deleted
601
                                result += '<span class="button" title="'
602
                                        + _("Can't delete catalog record, see constraints below") + '">'
603
                                        + _("Can't cancel order and delete catalog record") + '</span><br>';
604
                            }
605
                            else {
606
                                result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber='
607
                                        + row.order_id + '&biblionumber=' + row.biblio_id
608
                                        + '&del_biblio=1&referrer="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[$ invoiceid | uri ]">'
609
                                        + _("Cancel order and catalog record") + '</a><br/>';
610
                            }
611
612
                            if ( row.biblio.items_count - row.items.length > 0 ) {
613
                                result += '<b title="'
614
                                        + _("Can't delete catalog record, because of %s existing item(s)").format(row.items.length)
615
                                        +'">' + (row.biblio.items_count - row.items.length) + _(" item(s) left") + '</b><br/>';
616
                            }
617
618
                            if ( row.biblio.active_orders_count > 1 ) {
619
                                result += '<b title="'
620
                                        + _("Can't delete catalog record, delete other orders linked to it first") + '">'
621
                                        + (row.biblio.active_orders_count - 1) + _(" order(s) left") + '</b><br/>';
622
                            }
623
624
                            if ( row.biblio.subscriptions_count > 0 ) {
625
                                result += '<b title="' + _("Can't delete catalog record, delete subscriptions first") + '">'
626
                                        + _("%s subscription(s) left").format(row.biblio.subscriptions_count)
627
                                        + '</b><br>';
628
                            }
629
630
                            if ( row.biblio.holds_count > 0 ) {
631
                                result += '<b title="' + _("Can't delete catalog record or order, cancel holds first") + '">'
632
                                        + _("%s hold(s) left").format(row.biblio.holds_count) + '</b>';
633
                            }
634
635
                            return result;
636
                      },
637
                      "orderable": false
638
                    }
506
                ]
639
                ]
507
            });
640
            });
508
          }
641
509
642
            $("#filterform").on("submit", function(e) {
510
          if ( $("#receivedt").length ) {
643
                e.preventDefault();
511
            var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
644
                // Update the datatable URL
512
                "bStateSave": true,
645
                var summary      = $("#summaryfilter").val();
513
                "iCookieDuration": 60*60*24*1000, // 1000 days
646
                var basket_name  = $("#basketfilter").val();
514
                "iDisplayLength": 10,
647
                var basket_group = $("#basketgroupnamefilter").val();
515
                "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
648
                var order_id     = $("#orderfilter").val();
516
                "aoColumnDefs": [
649
                var ean          = $("#eanfilter").val();
517
                    { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false },
650
518
                ],
651
                var query_and = [];
519
                "aoColumns": [
652
520
                    { "sType": "html" },
653
                if (basket_name != "") {
521
                    { "sType": "html" },
654
                    query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } );
522
                    { "sType": "html" },
655
                }
523
                    { "sType": "num-html" },
656
                if (basket_group != "") {
524
                    { "sType": "anti-the" },
657
                    query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } );
525
                    null,
658
                }
526
                    null,
659
                if (summary != "") {
527
                    null,
660
                    query_and.push( { "-or": [{"biblio.title":  { "like": '%'+summary+'%' } },
528
                    null,
661
                                {"biblio.author": { "like": '%'+summary+'%' } },
529
                    null,
662
                                {"biblio.isbn":   { "like": '%'+summary+'%' } } ] } );
530
                    null,
663
                }
531
                    null,
664
            [% IF (UNIMARC) %]
532
                    null
665
                if (ean != "") {
533
                ],
666
                    query_and.push( { "biblio.ean": ean } );
534
                "sPaginationType": "full"
667
                }
535
            }));
668
            [% END %]
536
          }
669
537
670
                if ( !jQuery.isEmptyObject(query_and) || order_id != "" ) {
538
          // Keep filters from finishreceive.pl to parcel.pl
671
539
          $.cookie("filter_parcel_summary", $("#summaryfilter").val());
672
                    var query_params = [];
540
          $.cookie("filter_parcel_basketname", $("#basketfilter").val());
673
541
          $.cookie("filter_parcel_orderno", $("#orderfilter").val());
674
                    if ( order_id != "" ) {
542
          $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
675
                        query_params.push("order_id="+order_id);
543
          $.cookie("filter_parcel_ean", $("#eanfilter").val());
676
                    }
544
677
545
          $("#filterform").on('submit', function(){
678
                    if ( !jQuery.isEmptyObject(query_and) ) {
679
                        query_and.push(base_query);
680
                        query_params.push('q=' + encodeURI(JSON.stringify({ "-and": query_and })));
681
                    }
682
683
                    pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") );
684
                }
685
                else {
686
                    pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) );
687
                }
688
                pending_orders_table.api().ajax.reload( null, false );
689
            });
690
691
            $('#clear_form_filters').on("click", function(){
692
                $(this).closest('form').find("input[type=text], textarea").val("");
693
                pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw();
694
            });
695
696
            // Keep filters from finishreceive.pl to parcel.pl
546
            $.cookie("filter_parcel_summary", $("#summaryfilter").val());
697
            $.cookie("filter_parcel_summary", $("#summaryfilter").val());
547
            $.cookie("filter_parcel_basketname", $("#basketfilter").val());
698
            $.cookie("filter_parcel_basketname", $("#basketfilter").val());
548
            $.cookie("filter_parcel_orderno", $("#orderfilter").val());
699
            $.cookie("filter_parcel_orderno", $("#orderfilter").val());
549
            $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
700
            $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
550
            $.cookie("filter_parcel_ean", $("#eanfilter").val());
701
            $.cookie("filter_parcel_ean", $("#eanfilter").val());
551
          });
702
703
            $("#filterform").on('submit', function(){
704
                $.cookie("filter_parcel_summary", $("#summaryfilter").val());
705
                $.cookie("filter_parcel_basketname", $("#basketfilter").val());
706
                $.cookie("filter_parcel_orderno", $("#orderfilter").val());
707
                $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
708
                $.cookie("filter_parcel_ean", $("#eanfilter").val());
709
            });
552
710
553
            $(".previewData").on("click", function(e){
711
            $(".previewData").on("click", function(e){
554
                e.preventDefault();
712
                e.preventDefault();
Lines 558-585 Link Here
558
                $("#dataPreview .modal-body").load(page + " div");
716
                $("#dataPreview .modal-body").load(page + " div");
559
                $('#dataPreview').modal({show:true});
717
                $('#dataPreview').modal({show:true});
560
            });
718
            });
719
561
            $("#dataPreview").on("hidden.bs.modal", function(){
720
            $("#dataPreview").on("hidden.bs.modal", function(){
562
                $("#dataPreviewLabel").html("");
721
                $("#dataPreviewLabel").html("");
563
                $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
722
                $("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
564
            });
723
            });
724
        });
725
726
        // Case-insensitive version of jquery's contains function
727
        jQuery.extend(jQuery.expr[':'], {
728
            icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
729
        });
565
730
731
        // Contains exactly function
732
        jQuery.extend(jQuery.expr[':'], {
733
            containsExactly: "$(a).text() == m[3]"
566
        });
734
        });
567
735
568
         // Case-insensitive version of jquery's contains function
736
        function transfer_order_popup(ordernumber) {
569
         jQuery.extend(jQuery.expr[':'], {
737
        var url = "/cgi-bin/koha/acqui/transferorder.pl?"
570
	    icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
738
            + "ordernumber=" + ordernumber
571
         });
739
            window.open(url, 'TransferOrder');
572
740
        }
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>
741
    </script>
584
[% END %]
742
[% END %]
585
743
586
- 

Return to bug 20212