Lines 118-123
Link Here
|
118 |
<th> </th> |
118 |
<th> </th> |
119 |
<th> </th> |
119 |
<th> </th> |
120 |
</tr> |
120 |
</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> |
121 |
</thead> |
139 |
</thead> |
122 |
</table> |
140 |
</table> |
123 |
</div> |
141 |
</div> |
Lines 371-396
Link Here
|
371 |
<script> |
389 |
<script> |
372 |
dt_overwrite_html_sorting_localeCompare(); |
390 |
dt_overwrite_html_sorting_localeCompare(); |
373 |
var sticky_filters = [% sticky_filters | html %]; |
391 |
var sticky_filters = [% sticky_filters | html %]; |
|
|
392 |
var columns_filter = {}; |
374 |
|
393 |
|
375 |
function query_from_filters( base_query, params ) { |
394 |
function query_from_filters( base_query ) { |
376 |
|
395 |
|
377 |
var query_and = []; |
396 |
var query_and = []; |
378 |
|
397 |
|
379 |
if ( params.basket_name != "" ) { |
398 |
var summary = $("#summaryfilter").val(); |
380 |
query_and.push( { "basket.name": { "like": '%'+params.basket_name+'%' } } ); |
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 doens't have it |
405 |
ean = (ean === undefined) ? '' : ean; |
406 |
|
407 |
if ( basket_name != "" ) { |
408 |
query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } ); |
381 |
} |
409 |
} |
382 |
if (params.basket_group != "") { |
410 |
if (basket_group != "") { |
383 |
query_and.push( { "basket.basket_group.name": { "like": '%'+params.basket_group+'%' } } ); |
411 |
query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } ); |
384 |
} |
412 |
} |
385 |
if (params.summary != "") { |
413 |
if (summary != "") { |
386 |
query_and.push( { "-or": [{"biblio.title": { "like": '%'+params.summary+'%' } }, |
414 |
query_and.push( { "-or": [{"biblio.title": { "like": '%'+summary+'%' } }, |
387 |
{"biblio.author": { "like": '%'+params.summary+'%' } }, |
415 |
{"biblio.author": { "like": '%'+summary+'%' } }, |
388 |
{"biblio.isbn": { "like": '%'+params.summary+'%' } } ] } ); |
416 |
{"biblio.isbn": { "like": '%'+summary+'%' } } ] } ); |
389 |
} |
417 |
} |
390 |
if (params.ean != "") { |
418 |
if (ean != "") { |
391 |
query_and.push( { "biblio.ean": params.ean } ); |
419 |
query_and.push( { "biblio.ean": ean } ); |
392 |
} |
420 |
} |
393 |
|
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 |
|
394 |
var query_params = []; |
457 |
var query_params = []; |
395 |
|
458 |
|
396 |
if ( query_and.length > 0 ) { |
459 |
if ( query_and.length > 0 ) { |
Lines 398-405
Link Here
|
398 |
query_params.push('q=' + encodeURIComponent(JSON.stringify({ "-and": query_and }))); |
461 |
query_params.push('q=' + encodeURIComponent(JSON.stringify({ "-and": query_and }))); |
399 |
} |
462 |
} |
400 |
|
463 |
|
401 |
if ( params.order_id != "" ) { |
464 |
if ( order_id != "" ) { |
402 |
query_params.push("order_id="+params.order_id); |
465 |
query_params.push("order_id="+order_id); |
403 |
} |
466 |
} |
404 |
|
467 |
|
405 |
return query_params; |
468 |
return query_params; |
Lines 435-458
Link Here
|
435 |
})); |
498 |
})); |
436 |
} |
499 |
} |
437 |
|
500 |
|
438 |
var base_query = { "basket.vendor_id": [% booksellerid | html %] }; |
501 |
var base_query = { "basket.vendor_id": [% booksellerid | html %] }; |
439 |
|
502 |
var query_params = query_from_filters( base_query ); |
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 |
|
503 |
|
457 |
var THE_query = query_params.join("&"); |
504 |
var THE_query = query_params.join("&"); |
458 |
|
505 |
|
Lines 473-478
Link Here
|
473 |
"items" |
520 |
"items" |
474 |
], |
521 |
], |
475 |
"stateSave": true, // remember state on page reload |
522 |
"stateSave": true, // remember state on page reload |
|
|
523 |
"orderCellsTop": true, // tell the datatable sorting is done on the top row |
524 |
"fixedHeader": true, |
476 |
'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', |
525 |
'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', |
477 |
"drawCallback": function (settings) { |
526 |
"drawCallback": function (settings) { |
478 |
$(".previewData").on("click", function(e){ |
527 |
$(".previewData").on("click", function(e){ |
Lines 740-771
Link Here
|
740 |
] |
789 |
] |
741 |
}); |
790 |
}); |
742 |
|
791 |
|
|
|
792 |
// column filter events handling |
793 |
$(".column-filter").each(function () { |
794 |
$(this).on( 'keyup change', function () { |
795 |
// recalculate the query |
796 |
var query_params = query_from_filters( base_query ); |
797 |
// refresh the datatable as appropriate |
798 |
if ( query_params.length > 0 ) { |
799 |
pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); |
800 |
} |
801 |
else { |
802 |
pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) ); |
803 |
} |
804 |
pending_orders_table.api().ajax.reload( null, false ); |
805 |
}); |
806 |
}); |
807 |
|
743 |
$("#filterform").on("submit", function(e) { |
808 |
$("#filterform").on("submit", function(e) { |
744 |
e.preventDefault(); |
809 |
e.preventDefault(); |
745 |
|
810 |
|
746 |
var summary = $("#summaryfilter").val(); |
|
|
747 |
var basket_name = $("#basketfilter").val(); |
748 |
var basket_group = $("#basketgroupnamefilter").val(); |
749 |
var order_id = $("#orderfilter").val(); |
750 |
var ean = $("#eanfilter").val(); |
751 |
|
752 |
// Save the filters in the cookie |
811 |
// Save the filters in the cookie |
753 |
$.cookie("filter_parcel_summary", summary); |
812 |
$.cookie("filter_parcel_summary", $("#summaryfilter").val()); |
754 |
$.cookie("filter_parcel_basketname", basket_name); |
813 |
$.cookie("filter_parcel_basketname", $("#basketfilter").val()); |
755 |
$.cookie("filter_parcel_orderno", basket_group); |
814 |
$.cookie("filter_parcel_orderno", $("#orderfilter").val()); |
756 |
$.cookie("filter_parcel_basketgroupname", order_id); |
815 |
$.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val()); |
757 |
$.cookie("filter_parcel_ean", ean); |
816 |
$.cookie("filter_parcel_ean", $("#eanfilter").val()); |
758 |
|
817 |
|
759 |
var query_params = query_from_filters( |
818 |
var query_params = query_from_filters( base_query ); |
760 |
base_query, |
|
|
761 |
{ |
762 |
"summary": summary, |
763 |
"basket_name": basket_name, |
764 |
"basket_group": basket_group, |
765 |
"order_id": order_id, |
766 |
"ean": (ean === undefined) ? '' : ean // ean == undefined if the HTML doens't have it |
767 |
} |
768 |
); |
769 |
|
819 |
|
770 |
if ( query_params.length > 0 ) { |
820 |
if ( query_params.length > 0 ) { |
771 |
pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); |
821 |
pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); |
772 |
- |
|
|