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-473
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 |
function _escape_str(s){ |
337 |
function _escape_str(s){ |
472 |
return s != null ? s.escapeHtml() : ""; |
338 |
return s != null ? s.escapeHtml() : ""; |
473 |
} |
339 |
} |
Lines 480-486
Link Here
|
480 |
if ( $("#receivedt").length ) { |
346 |
if ( $("#receivedt").length ) { |
481 |
var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, { |
347 |
var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, { |
482 |
"bStateSave": true, |
348 |
"bStateSave": true, |
483 |
"iCookieDuration": 60*60*24*1000, // 1000 days |
|
|
484 |
"iDisplayLength": 10, |
349 |
"iDisplayLength": 10, |
485 |
"aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]], |
350 |
"aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]], |
486 |
"aoColumnDefs": [ |
351 |
"aoColumnDefs": [ |
Lines 505-519
Link Here
|
505 |
})); |
370 |
})); |
506 |
} |
371 |
} |
507 |
|
372 |
|
508 |
var base_query = { "basket.vendor_id": [% booksellerid | html %] }; |
|
|
509 |
var query_params = query_from_filters( base_query ); |
510 |
|
511 |
var THE_query = query_params.join("&"); |
512 |
|
513 |
var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1'; |
514 |
var pending_orders_table = $("#pending_orders").api({ |
373 |
var pending_orders_table = $("#pending_orders").api({ |
515 |
"ajax": { |
374 |
"ajax": { |
516 |
"url": pending_orders_url + '&' + THE_query |
375 |
"url": '/api/v1/acquisitions/orders?only_active=1' |
517 |
}, |
376 |
}, |
518 |
"header_filter": true, |
377 |
"header_filter": true, |
519 |
"embed": [ |
378 |
"embed": [ |
Lines 527-534
Link Here
|
527 |
"items" |
386 |
"items" |
528 |
], |
387 |
], |
529 |
"stateSave": true, // remember state on page reload |
388 |
"stateSave": true, // remember state on page reload |
530 |
"orderCellsTop": true, // tell the datatable sorting is done on the top row |
|
|
531 |
'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', |
532 |
"drawCallback": function (settings) { |
389 |
"drawCallback": function (settings) { |
533 |
$(".previewData").on("click", function(e){ |
390 |
$(".previewData").on("click", function(e){ |
534 |
e.preventDefault(); |
391 |
e.preventDefault(); |
Lines 539-558
Link Here
|
539 |
$('#dataPreview').modal({show:true}); |
396 |
$('#dataPreview').modal({show:true}); |
540 |
}); |
397 |
}); |
541 |
}, |
398 |
}, |
542 |
"columnDefs": [ { |
|
|
543 |
"targets": [3,4,5,9], |
544 |
"render": function (data, type, row, meta) { |
545 |
return _escape_str(data); |
546 |
} |
547 |
}, |
548 |
{ |
549 |
"targets": [8,10], |
550 |
"render": function (data, type, row, meta) { |
551 |
return _escape_price(data); |
552 |
} |
553 |
} ], |
554 |
"columns": [ |
399 |
"columns": [ |
555 |
{ "data": "basket.name", |
400 |
{ "data": "basket.name", |
|
|
401 |
"searchable": true, |
556 |
"orderable": true, |
402 |
"orderable": true, |
557 |
"render": function(data, type, row, meta) { |
403 |
"render": function(data, type, row, meta) { |
558 |
if (type != 'display') return _escape_str(data); |
404 |
if (type != 'display') return _escape_str(data); |
Lines 584-610
Link Here
|
584 |
} |
430 |
} |
585 |
}, |
431 |
}, |
586 |
{ |
432 |
{ |
587 |
"data": "biblio.author", |
433 |
"data": "biblio.author:biblio.title:biblio.isbn", |
588 |
"visible": false, |
434 |
"render": function(data, type, row, meta) { |
589 |
"searchable": true, |
|
|
590 |
"orderable": false |
591 |
}, |
592 |
{ |
593 |
"data": "biblio.title", |
594 |
"visible": false, |
595 |
"searchable": true, |
596 |
"orderable": false |
597 |
}, |
598 |
{ |
599 |
"data": "biblio.isbn", |
600 |
"visible": false, |
601 |
"searchable": true, |
602 |
"orderable": false |
603 |
}, |
604 |
{ |
605 |
"data": function(row, type, val, meta) { |
606 |
var result = ''; |
435 |
var result = ''; |
607 |
if ( row.biblio_id != null ) { |
436 |
if ( row && row.biblio_id != null ) { |
608 |
result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+row.biblio.title.escapeHtml()+"</a>"; |
437 |
result = "<p><a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber="+encodeURIComponent(row.biblio_id)+"\">"+row.biblio.title.escapeHtml()+"</a>"; |
609 |
if ( row.biblio.author != null ) |
438 |
if ( row.biblio.author != null ) |
610 |
result += _(" by ") + row.biblio.author.escapeHtml(); |
439 |
result += _(" by ") + row.biblio.author.escapeHtml(); |
Lines 672-687
Link Here
|
672 |
|
501 |
|
673 |
return result; |
502 |
return result; |
674 |
}, |
503 |
}, |
675 |
"orderable": false |
504 |
"orderable": false, |
676 |
}, |
505 |
}, |
677 |
{ |
506 |
{ |
678 |
"data": function( row, type, val, meta) { |
507 |
"data": "", |
|
|
508 |
"render": function(data, type, row, meta) { |
679 |
var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a><br>' |
509 |
var result = '<a href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '" class="previewData">' + _("Order") + '</a><br>' |
680 |
+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a><br>' |
510 |
+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("MARC") + '</a><br>' |
681 |
+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a>'; |
511 |
+ '<a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&id=' + encodeURIComponent(row.biblio_id) + '" class="previewData">' + _("Card") + '</a>'; |
682 |
return result; |
512 |
return result; |
683 |
}, |
513 |
}, |
684 |
"orderable": false |
514 |
"orderable": false, |
|
|
515 |
"searchable": false |
685 |
}, |
516 |
}, |
686 |
{ |
517 |
{ |
687 |
"data": "replacement_price" |
518 |
"data": "replacement_price" |
Lines 694-703
Link Here
|
694 |
"data": "ecost" |
525 |
"data": "ecost" |
695 |
}, |
526 |
}, |
696 |
{ |
527 |
{ |
697 |
"data": function ( row, type, val, meta ) { |
528 |
"data": "", |
|
|
529 |
"render": function(data, type, row, meta) { |
698 |
return (row.quantity * row.ecost).format_price(); |
530 |
return (row.quantity * row.ecost).format_price(); |
699 |
}, |
531 |
}, |
700 |
"orderable": false // FIXME: How can we do it in DBIC? |
532 |
"orderable": false, // FIXME: How can we do it in DBIC? |
|
|
533 |
"searchable": false |
701 |
}, |
534 |
}, |
702 |
{ |
535 |
{ |
703 |
"data": "fund.name", |
536 |
"data": "fund.name", |
Lines 707-723
Link Here
|
707 |
} |
540 |
} |
708 |
}, |
541 |
}, |
709 |
{ |
542 |
{ |
710 |
"data": function( row, type, val, meta ) { |
543 |
"data": "", |
|
|
544 |
"render": function(data, type, row, meta) { |
711 |
return '<a href="orderreceive.pl?ordernumber=' |
545 |
return '<a href="orderreceive.pl?ordernumber=' |
712 |
+ encodeURIComponent(row.order_id) + '&invoiceid=[% invoiceid | uri %]' + '">' |
546 |
+ encodeURIComponent(row.order_id) + '&invoiceid=[% invoiceid | uri %]' + '">' |
713 |
+ _("Receive") + '</a><br/>' |
547 |
+ _("Receive") + '</a><br/>' |
714 |
+ '<a href="#" onclick="transfer_order_popup(' + row.order_id.escapeHtml() + '); return false;">' |
548 |
+ '<a href="#" onclick="transfer_order_popup(' + row.order_id.escapeHtml() + '); return false;">' |
715 |
+ _("Transfer") + '</a>'; |
549 |
+ _("Transfer") + '</a>'; |
716 |
}, |
550 |
}, |
717 |
"orderable": false |
551 |
"orderable": false, |
|
|
552 |
"searchable": false |
718 |
}, |
553 |
}, |
719 |
{ |
554 |
{ |
720 |
"data": function( row, type, val, meta ) { |
555 |
"data": "", |
|
|
556 |
"render": function(data, type, row, meta) { |
721 |
var result = ""; |
557 |
var result = ""; |
722 |
|
558 |
|
723 |
if ( row.current_holds_count > 0 ) { |
559 |
if ( row.current_holds_count > 0 ) { |
Lines 775-826
Link Here
|
775 |
|
611 |
|
776 |
return result; |
612 |
return result; |
777 |
}, |
613 |
}, |
778 |
"orderable": false |
614 |
"orderable": false, |
|
|
615 |
"searchable": false |
779 |
} |
616 |
} |
780 |
] |
617 |
] |
781 |
}); |
618 |
}, {}, 1, {"basket.vendor_id": [% booksellerid | html %]}); |
782 |
|
|
|
783 |
// column filter events handling |
784 |
$(".column-filter").each(function () { |
785 |
$(this).on( 'keyup change', function () { |
786 |
// recalculate the query |
787 |
var query_params = query_from_filters( base_query ); |
788 |
// refresh the datatable as appropriate |
789 |
if ( query_params.length > 0 ) { |
790 |
pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); |
791 |
} |
792 |
else { |
793 |
pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) ); |
794 |
} |
795 |
pending_orders_table.api().ajax.reload( null, false ); |
796 |
}); |
797 |
}); |
798 |
|
799 |
$("#filterform").on("submit", function(e) { |
800 |
e.preventDefault(); |
801 |
|
802 |
// Save the filters in the cookie |
803 |
$.cookie("filter_parcel_summary", $("#summaryfilter").val()); |
804 |
$.cookie("filter_parcel_basketname", $("#basketfilter").val()); |
805 |
$.cookie("filter_parcel_orderno", $("#orderfilter").val()); |
806 |
$.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val()); |
807 |
$.cookie("filter_parcel_ean", $("#eanfilter").val()); |
808 |
|
809 |
var query_params = query_from_filters( base_query ); |
810 |
|
811 |
if ( query_params.length > 0 ) { |
812 |
pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); |
813 |
} |
814 |
else { |
815 |
pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) ); |
816 |
} |
817 |
pending_orders_table.api().ajax.reload( null, false ); |
818 |
}); |
819 |
|
820 |
$('#clear_form_filters').on("click", function(){ |
821 |
$(this).closest('form').find("input[type=text], textarea").val(""); |
822 |
pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw(); |
823 |
}); |
824 |
|
619 |
|
825 |
$(".previewData").on("click", function(e){ |
620 |
$(".previewData").on("click", function(e){ |
826 |
e.preventDefault(); |
621 |
e.preventDefault(); |