Lines 372-377
Link Here
|
372 |
dt_overwrite_html_sorting_localeCompare(); |
372 |
dt_overwrite_html_sorting_localeCompare(); |
373 |
var sticky_filters = [% sticky_filters | html %]; |
373 |
var sticky_filters = [% sticky_filters | html %]; |
374 |
|
374 |
|
|
|
375 |
function query_from_filters( base_query, params ) { |
376 |
|
377 |
var query_and = []; |
378 |
|
379 |
if ( params.basket_name != "" ) { |
380 |
query_and.push( { "basket.name": { "like": '%'+params.basket_name+'%' } } ); |
381 |
} |
382 |
if (params.basket_group != "") { |
383 |
query_and.push( { "basket.basket_group.name": { "like": '%'+params.basket_group+'%' } } ); |
384 |
} |
385 |
if (params.summary != "") { |
386 |
query_and.push( { "-or": [{"biblio.title": { "like": '%'+params.summary+'%' } }, |
387 |
{"biblio.author": { "like": '%'+params.summary+'%' } }, |
388 |
{"biblio.isbn": { "like": '%'+params.summary+'%' } } ] } ); |
389 |
} |
390 |
if (params.ean != "") { |
391 |
query_and.push( { "biblio.ean": params.ean } ); |
392 |
} |
393 |
|
394 |
var query_params = []; |
395 |
|
396 |
if ( query_and.length > 0 ) { |
397 |
query_and.push(base_query); |
398 |
query_params.push('q=' + encodeURIComponent(JSON.stringify({ "-and": query_and }))); |
399 |
} |
400 |
|
401 |
if ( params.order_id != "" ) { |
402 |
query_params.push("order_id="+params.order_id); |
403 |
} |
404 |
|
405 |
return query_params; |
406 |
} |
407 |
|
375 |
$(document).ready(function(){ |
408 |
$(document).ready(function(){ |
376 |
|
409 |
|
377 |
if ( $("#receivedt").length ) { |
410 |
if ( $("#receivedt").length ) { |
Lines 403-412
Link Here
|
403 |
} |
436 |
} |
404 |
|
437 |
|
405 |
var base_query = { "basket.vendor_id": [% booksellerid | html %] }; |
438 |
var base_query = { "basket.vendor_id": [% booksellerid | html %] }; |
|
|
439 |
|
440 |
var summary = $("#summaryfilter").val(); |
441 |
var basket_name = $("#basketfilter").val(); |
442 |
var basket_group = $("#basketgroupnamefilter").val(); |
443 |
var order_id = $("#orderfilter").val(); |
444 |
var ean = $("#eanfilter").val(); |
445 |
|
446 |
var query_params = query_from_filters( |
447 |
base_query, |
448 |
{ |
449 |
"summary": summary, |
450 |
"basket_name": basket_name, |
451 |
"basket_group": basket_group, |
452 |
"order_id": order_id, |
453 |
"ean": (ean === undefined) ? '' : ean // ean == undefined if the DOM doens't have it |
454 |
} |
455 |
); |
456 |
|
457 |
var THE_query = query_params.join("&"); |
458 |
|
406 |
var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1'; |
459 |
var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1'; |
407 |
var pending_orders_table = $("#pending_orders").api({ |
460 |
var pending_orders_table = $("#pending_orders").api({ |
408 |
"ajax": { |
461 |
"ajax": { |
409 |
"url": pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) |
462 |
"url": pending_orders_url + '&' + THE_query |
410 |
}, |
463 |
}, |
411 |
"header_filter": true, |
464 |
"header_filter": true, |
412 |
"embed": [ |
465 |
"embed": [ |
Lines 688-732
Link Here
|
688 |
|
741 |
|
689 |
$("#filterform").on("submit", function(e) { |
742 |
$("#filterform").on("submit", function(e) { |
690 |
e.preventDefault(); |
743 |
e.preventDefault(); |
691 |
// Update the datatable URL |
744 |
|
692 |
var summary = $("#summaryfilter").val(); |
745 |
var summary = $("#summaryfilter").val(); |
693 |
var basket_name = $("#basketfilter").val(); |
746 |
var basket_name = $("#basketfilter").val(); |
694 |
var basket_group = $("#basketgroupnamefilter").val(); |
747 |
var basket_group = $("#basketgroupnamefilter").val(); |
695 |
var order_id = $("#orderfilter").val(); |
748 |
var order_id = $("#orderfilter").val(); |
696 |
var ean = $("#eanfilter").val(); |
749 |
var ean = $("#eanfilter").val(); |
697 |
|
750 |
|
698 |
var query_and = []; |
751 |
// Save the filters in the cookie |
699 |
|
752 |
$.cookie("filter_parcel_summary", summary); |
700 |
if (basket_name != "") { |
753 |
$.cookie("filter_parcel_basketname", basket_name); |
701 |
query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } ); |
754 |
$.cookie("filter_parcel_orderno", basket_group); |
702 |
} |
755 |
$.cookie("filter_parcel_basketgroupname", order_id); |
703 |
if (basket_group != "") { |
756 |
$.cookie("filter_parcel_ean", ean); |
704 |
query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } ); |
|
|
705 |
} |
706 |
if (summary != "") { |
707 |
query_and.push( { "-or": [{"biblio.title": { "like": '%'+summary+'%' } }, |
708 |
{"biblio.author": { "like": '%'+summary+'%' } }, |
709 |
{"biblio.isbn": { "like": '%'+summary+'%' } } ] } ); |
710 |
} |
711 |
[% IF (UNIMARC) %] |
712 |
if (ean != "") { |
713 |
query_and.push( { "biblio.ean": ean } ); |
714 |
} |
715 |
[% END %] |
716 |
|
717 |
if ( !jQuery.isEmptyObject(query_and) || order_id != "" ) { |
718 |
|
719 |
var query_params = []; |
720 |
|
721 |
if ( order_id != "" ) { |
722 |
query_params.push("order_id="+order_id); |
723 |
} |
724 |
|
757 |
|
725 |
if ( !jQuery.isEmptyObject(query_and) ) { |
758 |
var query_params = query_from_filters( |
726 |
query_and.push(base_query); |
759 |
base_query, |
727 |
query_params.push('q=' + encodeURI(JSON.stringify({ "-and": query_and }))); |
760 |
{ |
|
|
761 |
"summary": summary, |
762 |
"basket_name": basket_name, |
763 |
"basket_group": basket_group, |
764 |
"order_id": order_id, |
765 |
"ean": (ean === undefined) ? '' : ean // ean == undefined if the HTML doens't have it |
728 |
} |
766 |
} |
|
|
767 |
); |
729 |
|
768 |
|
|
|
769 |
if ( query_params.length > 0 ) { |
730 |
pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); |
770 |
pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); |
731 |
} |
771 |
} |
732 |
else { |
772 |
else { |
Lines 740-760
Link Here
|
740 |
pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw(); |
780 |
pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw(); |
741 |
}); |
781 |
}); |
742 |
|
782 |
|
743 |
// Keep filters from finishreceive.pl to parcel.pl |
|
|
744 |
$.cookie("filter_parcel_summary", $("#summaryfilter").val()); |
745 |
$.cookie("filter_parcel_basketname", $("#basketfilter").val()); |
746 |
$.cookie("filter_parcel_orderno", $("#orderfilter").val()); |
747 |
$.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val()); |
748 |
$.cookie("filter_parcel_ean", $("#eanfilter").val()); |
749 |
|
750 |
$("#filterform").on('submit', function(){ |
751 |
$.cookie("filter_parcel_summary", $("#summaryfilter").val()); |
752 |
$.cookie("filter_parcel_basketname", $("#basketfilter").val()); |
753 |
$.cookie("filter_parcel_orderno", $("#orderfilter").val()); |
754 |
$.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val()); |
755 |
$.cookie("filter_parcel_ean", $("#eanfilter").val()); |
756 |
}); |
757 |
|
758 |
$(".previewData").on("click", function(e){ |
783 |
$(".previewData").on("click", function(e){ |
759 |
e.preventDefault(); |
784 |
e.preventDefault(); |
760 |
var ltitle = $(this).text(); |
785 |
var ltitle = $(this).text(); |
761 |
- |
|
|