Lines 105-113
Link Here
|
105 |
<th>Basket</th> |
105 |
<th>Basket</th> |
106 |
<th>Basket group</th> |
106 |
<th>Basket group</th> |
107 |
<th>Order line</th> |
107 |
<th>Order line</th> |
108 |
<th class="hidden">Title</th> |
|
|
109 |
<th class="hidden">Author</th> |
110 |
<th class="hidden">ISBN</th> |
111 |
<th>Summary</th> |
108 |
<th>Summary</th> |
112 |
<th>More</th> |
109 |
<th>More</th> |
113 |
<th>Replacement price</th> |
110 |
<th>Replacement price</th> |
Lines 118-141
Link Here
|
118 |
<th> </th> |
115 |
<th> </th> |
119 |
<th> </th> |
116 |
<th> </th> |
120 |
</tr> |
117 |
</tr> |
121 |
<tr> |
|
|
122 |
<th><div class="input-group input-group-sm"><input id="basket_name_column_search" type="text" class="form-control column-filter" data-search-fields='["basket.name"]'></div></th> |
123 |
<th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["basket.basket_group.name"]'></div></th> |
124 |
<th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.order_id"]'></div></th> |
125 |
<th class="hidden"> </th> |
126 |
<th class="hidden"> </th> |
127 |
<th class="hidden"> </th> |
128 |
<th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.internal_note","me.vendor_note","biblio.title","biblio.author","biblio.isbn","biblio.publisher","biblio.publication_year","biblio.copyright_date","biblio.suggestions.suggester.surname","biblio.suggestions.suggester.firstname"]'></div></th> |
129 |
<th> </th> |
130 |
<th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.replacement_price"]'></div></th> |
131 |
<th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.quantity"]'></div></th> |
132 |
<th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.ecost"]'></div></th> |
133 |
<th> </th> |
134 |
<!--th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["order_cost"]'></div></th--> |
135 |
<th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["fund.name"]'></div></th> |
136 |
<th> </th> |
137 |
<th> </th> |
138 |
</tr> |
139 |
</thead> |
118 |
</thead> |
140 |
</table> |
119 |
</table> |
141 |
</div> |
120 |
</div> |
Lines 340-380
Link Here
|
340 |
<div class="col-sm-2 col-sm-pull-10"> |
319 |
<div class="col-sm-2 col-sm-pull-10"> |
341 |
<aside> |
320 |
<aside> |
342 |
|
321 |
|
343 |
<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" method="post"> |
|
|
344 |
<fieldset class="brief"> |
345 |
<h4>Filter</h4> |
346 |
<ol> |
347 |
<li> |
348 |
<label for="summaryfilter">ISBN, author or title:</label> |
349 |
<input type="text" name="summaryfilter" id="summaryfilter" value="[% summaryfilter | html %]"/> |
350 |
</li> |
351 |
<li> |
352 |
<label for="basketfilter">Basket name:</label> |
353 |
<input type="text" name="basketfilter" id="basketfilter" value="[% basketfilter | html %]"/> |
354 |
</li> |
355 |
<li> |
356 |
<label for="basketgroupnamefilter">Basket group name:</label> |
357 |
<input type="text" name="basketgroupnamefilter" id="basketgroupnamefilter" value="[% basketgroupnamefilter | html %]" /> |
358 |
</li> |
359 |
<li> |
360 |
<label for="orderfilter">Order line:</label> |
361 |
<input type="text" name="orderfilter" id="orderfilter" value="[% orderfilter | html %]"/> |
362 |
</li> |
363 |
[% IF (UNIMARC) %] |
364 |
<li> |
365 |
<label for="eanfilter">EAN:</label> |
366 |
<input type="text" name="eanfilter" id="eanfilter" value="[% eanfilter | html %]"/> |
367 |
</li> |
368 |
[% END %] |
369 |
</ol> |
370 |
<fieldset class="action"> |
371 |
<input type="hidden" value="search" name="op" /> |
372 |
<input type="hidden" value="[% invoiceid | html %]" name="invoiceid" /> |
373 |
<input type="submit" value="Filter" /> |
374 |
<a href="#" id="clear_form_filters">Clear</a> |
375 |
</fieldset> |
376 |
</fieldset> |
377 |
</form> |
378 |
[% INCLUDE 'acquisitions-menu.inc' %] |
322 |
[% INCLUDE 'acquisitions-menu.inc' %] |
379 |
</aside> |
323 |
</aside> |
380 |
</div> <!-- /.col-sm-2.col-sm-pull-10 --> |
324 |
</div> <!-- /.col-sm-2.col-sm-pull-10 --> |
Lines 388-479
Link Here
|
388 |
<style>#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }</style> |
332 |
<style>#dataPreview { width : 80%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }</style> |
389 |
<script> |
333 |
<script> |
390 |
dt_overwrite_html_sorting_localeCompare(); |
334 |
dt_overwrite_html_sorting_localeCompare(); |
391 |
var sticky_filters = [% sticky_filters | html %]; |
|
|
392 |
var columns_filter = {}; |
335 |
var columns_filter = {}; |
393 |
|
336 |
|
394 |
function query_from_filters( base_query ) { |
|
|
395 |
|
396 |
var query_and = []; |
397 |
|
398 |
var summary = $("#summaryfilter").val(); |
399 |
var basket_group = $("#basketgroupnamefilter").val(); |
400 |
var basket_name = $("#basketfilter").val(); |
401 |
var order_id = $("#orderfilter").val(); |
402 |
var ean = $("#eanfilter").val(); |
403 |
|
404 |
// ean == undefined if the HTML doesn't have it |
405 |
ean = (ean === undefined) ? '' : ean; |
406 |
|
407 |
if ( basket_name != "" ) { |
408 |
query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } ); |
409 |
} |
410 |
if (basket_group != "") { |
411 |
query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } ); |
412 |
} |
413 |
if (summary != "") { |
414 |
query_and.push( { "-or": [{"biblio.title": { "like": '%'+summary+'%' } }, |
415 |
{"biblio.author": { "like": '%'+summary+'%' } }, |
416 |
{"biblio.isbn": { "like": '%'+summary+'%' } } ] } ); |
417 |
} |
418 |
if (ean != "") { |
419 |
query_and.push( { "biblio.ean": ean } ); |
420 |
} |
421 |
|
422 |
$(".column-filter").each(function () { |
423 |
var search_fields = $(this).data('search-fields'); |
424 |
var value = this.value; |
425 |
|
426 |
if ( value != '' && |
427 |
value != undefined ) { // skip if empty |
428 |
|
429 |
var columns_filters = []; |
430 |
|
431 |
search_fields.forEach( function (item) { |
432 |
if ( item === "me.order_id" || |
433 |
item === "me.replacement_price" || |
434 |
item === "me.quantity" || |
435 |
item === "me.ecost" ) { |
436 |
// For numbers, we do 'starts with' |
437 |
var object = {}; |
438 |
object[item] = { "like": value+'%' }; |
439 |
columns_filters.push( object ); |
440 |
} |
441 |
else { |
442 |
var object = {}; |
443 |
object[item] = { "like": '%'+value+'%' }; |
444 |
columns_filters.push( object ); |
445 |
} |
446 |
}); |
447 |
|
448 |
if ( columns_filters.length > 1 ) { |
449 |
query_and.push( { "-or": columns_filters } ); |
450 |
} |
451 |
else if ( columns_filters.length > 0 ) { |
452 |
query_and.push( columns_filters[0] ); |
453 |
} |
454 |
} |
455 |
}); |
456 |
|
457 |
var query_params = []; |
458 |
|
459 |
if ( query_and.length > 0 ) { |
460 |
query_and.push(base_query); |
461 |
query_params.push('q=' + encodeURIComponent(JSON.stringify({ "-and": query_and }))); |
462 |
} |
463 |
|
464 |
if ( order_id != "" ) { |
465 |
query_params.push("order_id="+order_id); |
466 |
} |
467 |
|
468 |
return query_params; |
469 |
} |
470 |
|
471 |
$(document).ready(function(){ |
337 |
$(document).ready(function(){ |
472 |
|
338 |
|
473 |
if ( $("#receivedt").length ) { |
339 |
if ( $("#receivedt").length ) { |
474 |
var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, { |
340 |
var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, { |
475 |
"bStateSave": true, |
341 |
"bStateSave": true, |
476 |
"iCookieDuration": 60*60*24*1000, // 1000 days |
|
|
477 |
"iDisplayLength": 10, |
342 |
"iDisplayLength": 10, |
478 |
"aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]], |
343 |
"aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]], |
479 |
"aoColumnDefs": [ |
344 |
"aoColumnDefs": [ |
Lines 498-512
Link Here
|
498 |
})); |
363 |
})); |
499 |
} |
364 |
} |
500 |
|
365 |
|
501 |
var base_query = { "basket.vendor_id": [% booksellerid | html %] }; |
|
|
502 |
var query_params = query_from_filters( base_query ); |
503 |
|
504 |
var THE_query = query_params.join("&"); |
505 |
|
506 |
var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1'; |
507 |
var pending_orders_table = $("#pending_orders").api({ |
366 |
var pending_orders_table = $("#pending_orders").api({ |
508 |
"ajax": { |
367 |
"ajax": { |
509 |
"url": pending_orders_url + '&' + THE_query |
368 |
"url": '/api/v1/acquisitions/orders?only_active=1' |
510 |
}, |
369 |
}, |
511 |
"header_filter": true, |
370 |
"header_filter": true, |
512 |
"embed": [ |
371 |
"embed": [ |
Lines 520-527
Link Here
|
520 |
"items" |
379 |
"items" |
521 |
], |
380 |
], |
522 |
"stateSave": true, // remember state on page reload |
381 |
"stateSave": true, // remember state on page reload |
523 |
"orderCellsTop": true, // tell the datatable sorting is done on the top row |
|
|
524 |
'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', |
525 |
"drawCallback": function (settings) { |
382 |
"drawCallback": function (settings) { |
526 |
$(".previewData").on("click", function(e){ |
383 |
$(".previewData").on("click", function(e){ |
527 |
e.preventDefault(); |
384 |
e.preventDefault(); |
Lines 532-561
Link Here
|
532 |
$('#dataPreview').modal({show:true}); |
389 |
$('#dataPreview').modal({show:true}); |
533 |
}); |
390 |
}); |
534 |
}, |
391 |
}, |
535 |
"columnDefs": [ { |
|
|
536 |
"targets": [3,4,5,9], |
537 |
"render": function (data, type, row, meta) { |
538 |
if ( data != null ) { |
539 |
return data.escapeHtml(); |
540 |
} |
541 |
else { |
542 |
return ""; |
543 |
} |
544 |
} |
545 |
}, |
546 |
{ |
547 |
"targets": [8,10], |
548 |
"render": function (data, type, row, meta) { |
549 |
if ( data != null ) { |
550 |
return data.escapeHtml().format_price(); |
551 |
} |
552 |
else { |
553 |
return ""; |
554 |
} |
555 |
} |
556 |
} ], |
557 |
"columns": [ |
392 |
"columns": [ |
558 |
{ "data": "basket.name", |
393 |
{ "data": "basket.name", |
|
|
394 |
"searchable": true, |
559 |
"orderable": true, |
395 |
"orderable": true, |
560 |
"render": function(data, type, row, meta) { |
396 |
"render": function(data, type, row, meta) { |
561 |
if (type != 'display') return data; |
397 |
if (type != 'display') return data; |
Lines 592-618
Link Here
|
592 |
} |
428 |
} |
593 |
}, |
429 |
}, |
594 |
{ |
430 |
{ |
595 |
"data": "biblio.author", |
431 |
"data": "biblio.author:biblio.title:biblio.isbn", |
596 |
"visible": false, |
432 |
"render": function(data, type, row, meta) { |
597 |
"searchable": true, |
|
|
598 |
"orderable": false |
599 |
}, |
600 |
{ |
601 |
"data": "biblio.title", |
602 |
"visible": false, |
603 |
"searchable": true, |
604 |
"orderable": false |
605 |
}, |
606 |
{ |
607 |
"data": "biblio.isbn", |
608 |
"visible": false, |
609 |
"searchable": true, |
610 |
"orderable": false |
611 |
}, |
612 |
{ |
613 |
"data": function(row, type, val, meta) { |
614 |
var result = ''; |
433 |
var result = ''; |
615 |
if ( row.biblio_id != null ) { |
434 |
if ( row && row.biblio_id != null ) { |
616 |
result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+row.biblio.title.escapeHtml()+"</a>"; |
435 |
result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+row.biblio.title.escapeHtml()+"</a>"; |
617 |
if ( row.biblio.author != null ) |
436 |
if ( row.biblio.author != null ) |
618 |
result += _(" by ") + row.biblio.author.escapeHtml(); |
437 |
result += _(" by ") + row.biblio.author.escapeHtml(); |
Lines 680-695
Link Here
|
680 |
|
499 |
|
681 |
return result; |
500 |
return result; |
682 |
}, |
501 |
}, |
683 |
"orderable": false |
502 |
"orderable": false, |
684 |
}, |
503 |
}, |
685 |
{ |
504 |
{ |
686 |
"data": function( row, type, val, meta) { |
505 |
"data": "", |
|
|
506 |
"render": function(data, type, row, meta) { |
687 |
var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a><br>' |
507 |
var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a><br>' |
688 |
+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a><br>' |
508 |
+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a><br>' |
689 |
+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a>'; |
509 |
+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a>'; |
690 |
return result; |
510 |
return result; |
691 |
}, |
511 |
}, |
692 |
"orderable": false |
512 |
"orderable": false, |
|
|
513 |
"searchable": false |
693 |
}, |
514 |
}, |
694 |
{ |
515 |
{ |
695 |
"data": "replacement_price" |
516 |
"data": "replacement_price" |
Lines 702-711
Link Here
|
702 |
"data": "ecost" |
523 |
"data": "ecost" |
703 |
}, |
524 |
}, |
704 |
{ |
525 |
{ |
705 |
"data": function ( row, type, val, meta ) { |
526 |
"data": "", |
|
|
527 |
"render": function(data, type, row, meta) { |
706 |
return (row.quantity * row.ecost).format_price(); |
528 |
return (row.quantity * row.ecost).format_price(); |
707 |
}, |
529 |
}, |
708 |
"orderable": false // FIXME: How can we do it in DBIC? |
530 |
"orderable": false, // FIXME: How can we do it in DBIC? |
|
|
531 |
"searchable": false |
709 |
}, |
532 |
}, |
710 |
{ |
533 |
{ |
711 |
"data": "fund_id", |
534 |
"data": "fund_id", |
Lines 715-731
Link Here
|
715 |
} |
538 |
} |
716 |
}, |
539 |
}, |
717 |
{ |
540 |
{ |
718 |
"data": function( row, type, val, meta ) { |
541 |
"data": "", |
|
|
542 |
"render": function(data, type, row, meta) { |
719 |
return '<a href="orderreceive.pl?ordernumber=' |
543 |
return '<a href="orderreceive.pl?ordernumber=' |
720 |
+ encodeURIComponent(row.order_id) + '&invoiceid=[% invoiceid | uri %]' + '">' |
544 |
+ encodeURIComponent(row.order_id) + '&invoiceid=[% invoiceid | uri %]' + '">' |
721 |
+ _("Receive") + '</a><br/>' |
545 |
+ _("Receive") + '</a><br/>' |
722 |
+ '<a href="#" onclick="transfer_order_popup(' + row.order_id.escapeHtml() + '); return false;">' |
546 |
+ '<a href="#" onclick="transfer_order_popup(' + row.order_id.escapeHtml() + '); return false;">' |
723 |
+ _("Transfer") + '</a>'; |
547 |
+ _("Transfer") + '</a>'; |
724 |
}, |
548 |
}, |
725 |
"orderable": false |
549 |
"orderable": false, |
|
|
550 |
"searchable": false |
726 |
}, |
551 |
}, |
727 |
{ |
552 |
{ |
728 |
"data": function( row, type, val, meta ) { |
553 |
"data": "", |
|
|
554 |
"render": function(data, type, row, meta) { |
729 |
var result = ""; |
555 |
var result = ""; |
730 |
|
556 |
|
731 |
if ( row.current_holds_count > 0 ) { |
557 |
if ( row.current_holds_count > 0 ) { |
Lines 783-834
Link Here
|
783 |
|
609 |
|
784 |
return result; |
610 |
return result; |
785 |
}, |
611 |
}, |
786 |
"orderable": false |
612 |
"orderable": false, |
|
|
613 |
"searchable": false |
787 |
} |
614 |
} |
788 |
] |
615 |
] |
789 |
}); |
616 |
}, {}, 1, {"basket.vendor_id": [% booksellerid | html %]}); |
790 |
|
|
|
791 |
// column filter events handling |
792 |
$(".column-filter").each(function () { |
793 |
$(this).on( 'keyup change', function () { |
794 |
// recalculate the query |
795 |
var query_params = query_from_filters( base_query ); |
796 |
// refresh the datatable as appropriate |
797 |
if ( query_params.length > 0 ) { |
798 |
pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); |
799 |
} |
800 |
else { |
801 |
pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) ); |
802 |
} |
803 |
pending_orders_table.api().ajax.reload( null, false ); |
804 |
}); |
805 |
}); |
806 |
|
807 |
$("#filterform").on("submit", function(e) { |
808 |
e.preventDefault(); |
809 |
|
810 |
// Save the filters in the cookie |
811 |
$.cookie("filter_parcel_summary", $("#summaryfilter").val()); |
812 |
$.cookie("filter_parcel_basketname", $("#basketfilter").val()); |
813 |
$.cookie("filter_parcel_orderno", $("#orderfilter").val()); |
814 |
$.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val()); |
815 |
$.cookie("filter_parcel_ean", $("#eanfilter").val()); |
816 |
|
817 |
var query_params = query_from_filters( base_query ); |
818 |
|
819 |
if ( query_params.length > 0 ) { |
820 |
pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); |
821 |
} |
822 |
else { |
823 |
pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) ); |
824 |
} |
825 |
pending_orders_table.api().ajax.reload( null, false ); |
826 |
}); |
827 |
|
828 |
$('#clear_form_filters').on("click", function(){ |
829 |
$(this).closest('form').find("input[type=text], textarea").val(""); |
830 |
pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw(); |
831 |
}); |
832 |
|
617 |
|
833 |
$(".previewData").on("click", function(e){ |
618 |
$(".previewData").on("click", function(e){ |
834 |
e.preventDefault(); |
619 |
e.preventDefault(); |