@@ -, +, @@
---
.../prog/en/modules/acqui/parcel.tt | 622 +++++++++++-------
1 file changed, 390 insertions(+), 232 deletions(-)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt
@@ -34,16 +34,16 @@
Invoice is closed, so you can't receive orders anymore.
@@ -367,12 +273,12 @@
[% END %]
- [% END %]
-
+ [% END %]
+
- [% ELSE %]There are no received orders.[% END %]
+ [% ELSE %]There are no received orders.[% END %]
@@ -433,7 +339,7 @@
[% IF (UNIMARC) %]
- EAN :
+ EAN:
[% END %]
@@ -442,7 +348,7 @@
-
Clear
+
Clear
@@ -462,93 +368,345 @@
var sticky_filters = [% sticky_filters | html %];
$(document).ready(function(){
- if ( $("#pendingt").length ) {
- var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, {
- "bStateSave": true,
- "iCookieDuration": 60*60*24*1000, // 1000 days
- "iDisplayLength": 10,
- "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
- "aoColumnDefs": [
- { "aTargets": [ 4, 9, 10 ], "bSortable": false, "bSearchable": false },
- ],
- "aoColumns": [
- { "sType": "html" },
- { "sType": "html" },
- { "sType": "num-html" },
- { "sType": "anti-the" },
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
+
+ if ( $("#receivedt").length ) {
+ var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
+ "bStateSave": true,
+ "iCookieDuration": 60*60*24*1000, // 1000 days
+ "iDisplayLength": 10,
+ "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
+ "aoColumnDefs": [
+ { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false },
+ ],
+ "aoColumns": [
+ { "sType": "html" },
+ { "sType": "html" },
+ { "sType": "html" },
+ { "sType": "num-html" },
+ { "sType": "anti-the" },
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ],
+ "sPaginationType": "full"
+ }));
+ }
+
+ var base_query = { "basket.vendor_id": [% booksellerid | html %] };
+ var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1';
+ var pending_orders_table = $("#pending_orders").api({
+ "ajax": {
+ "url": pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))
+ },
+ "header_filter": true,
+ "embed": [
+ "basket.basket_group",
+ "biblio.active_orders+count",
+ "biblio.holds+count",
+ "biblio.items+count",
+ "biblio.suggestions.suggester",
+ "fund",
+ "current_item_level_holds+count",
+ "items"
],
- 'bAutoWidth': false,
- "sPaginationType": "full"
- } )
- ).columnFilter({
- sPlaceHolder: "head:after",
- aoColumns: [
- { type: "text" },
- { type: "text" },
- { type: "text" },
- { type: "text" },
- null,
- { type: "text" },
- { type: "text" },
- { type: "text" },
- { type: "text" },
- { type: "text" },
- null,
- null
+ 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
+ "columns": [
+ { "data": "basket.name",
+ "orderable": true,
+ "render": function(data, type, row, meta) {
+ if (type != 'display') return data;
+ return "
" + data + " (" + row.basket.basket_id + ") ";
+ }
+ },
+ { "data": "basket.basket_group.name",
+ "orderable": true,
+ "render": function(data, type, row, meta) {
+ if ( type != 'display' ) return data;
+ if ( row.basket.basket_group_id == null ) {
+ return _("No basket group");
+ }
+ else {
+ return "
"
+ + row.basket.basket_group.name + " (" + row.basket.basket_group_id + ") ";
+ }
+ }
+ },
+ { "data": "order_id",
+ "render": function(data, type, row, meta) {
+ if (type != 'display') return data;
+ return "
"+data+" ";
+ }
+ },
+ {
+ "data": "biblio.author",
+ "visible": false,
+ "searchable": true,
+ "orderable": false
+ },
+ {
+ "data": "biblio.title",
+ "visible": false,
+ "searchable": true,
+ "orderable": false
+ },
+ {
+ "data": "biblio.isbn",
+ "visible": false,
+ "searchable": true,
+ "orderable": false
+ },
+ { "data": function(row, type, val, meta) {
+ if ( row.biblio_id == null ) {
+ window.alert(row);
+ }
+ var result = "
"+row.biblio.title+" ";
+ if ( row.biblio.author != null )
+ result += _(" by ") + row.biblio.author;
+ if ( row.biblio.isbn != null )
+ result += " – " + row.biblio.isbn;
+ if ( row.biblio.publisher != null ) {
+ result += " " + _("Publisher: ") + row.biblio.publisher;
+ if ( row.biblio.publication_year != null ) {
+ result += ", " + row.biblio.publication_year;
+ }
+ else if ( row.biblio.copyright_date != null ) {
+ result += row.biblio.copyright_date;
+ }
+ }
+ var suggestions = row.biblio.suggestions;
+ if ( suggestions != null && suggestions.length > 0 ) {
+ var suggestion = suggestions[0];
+ if ( suggestion.suggester != null ) {
+ var suggester = suggestion.suggester;
+ var suggested_by = [];
+ if ( suggester.surname != null ) {
+ suggested_by.push(suggester.surname);
+ }
+ if ( suggester.firstname != null ) {
+ suggested_by.push(suggester.firstname);
+ }
+
+ result += " " + _("Suggested by: ") +
+ ''
+ + suggested_by.join(", ")
+ + " (#" + suggestions[0].suggestionid + ") ";
+ }
+ }
+ result += '
';
+
+ var internal_note = row.internal_note;
+ if ( internal_note != '' ) {
+ result += '
'
+ + _("Internal note: ")
+ + ' ' + internal_note
+ + ' [' + _("Change internal note") + ' ]
';
+ }
+ else {
+ result += ' [
' + _("Add internal note") + ' ]';
+ }
+
+ var vendor_note = row.vendor_note;
+ if ( vendor_note != '' ) {
+ result += '
'
+ + _("Vendor note: ")
+ + ' ' + vendor_note + '
';
+ }
+ else {
+ result += ' [
' + _("Add vendor note") + ' ]';
+ }
+
+ return result;
+ },
+ "orderable": false // FIXME
+ },
+ { "data": function( row, type, val, meta) {
+ var result = '
' + _("Order") + ' '
+ + '
' + _("MARC") + ' '
+ + '
' + _("Card") + ' ';
+ return result;
+ },
+ "orderable": false
+ },
+ { "data": "replacement_price",
+ "render": function(data, type, val, meta) {
+ if (type != 'display') return data;
+ return data.format_price();
+ }
+ },
+ { "data": "quantity",
+ "orderable": true
+ },
+ { "data": "ecost",
+ "render": function(data, type, val, meta) {
+ if (type != 'display') return data;
+ return data.format_price();
+ },
+ "orderable": true
+ },
+ { "data": function ( row, type, val, meta ) {
+ return (row.quantity * row.ecost).format_price();
+ },
+ "orderable": false // FIXME: How can we do it in DBIC?
+ },
+ { "data": "fund_id",
+ "render": function(data, type, row, meta) {
+ if (type != 'display') return data;
+ return row.fund.name;
+ }
+ },
+ { "data": function( row, type, val, meta ) {
+ return '
'
+ + _("Receive") + ' '
+ + '
'
+ + _("Transfer") + ' ';
+ },
+ "orderable": false
+ },
+ { "data": function( row, type, val, meta ) {
+ var result = "";
+
+ if ( row.current_holds_count > 0 ) {
+ result += '
'
+ + _("Can't cancel order") + ' ';
+ }
+ else {
+ result += '
'
+ + _("Cancel order") + ' ';
+ }
+
+ if ( row.items.length > 0 ||
+ row.biblio.active_orders_count > 1 ||
+ row.biblio.subscriptions_count > 0 ||
+ row.biblio.holds_count > 0 ) { // biblio can be deleted
+ result += '
'
+ + _("Can't cancel order and delete catalog record") + ' ';
+ }
+ else {
+ result += '
'
+ + _("Cancel order and catalog record") + ' ';
+ }
+
+ if ( row.biblio.items_count - row.items.length > 0 ) {
+ result += '
' + (row.biblio.items_count - row.items.length) + _(" item(s) left") + ' ';
+ }
+
+ if ( row.biblio.active_orders_count > 1 ) {
+ result += '
'
+ + (row.biblio.active_orders_count - 1) + _(" order(s) left") + ' ';
+ }
+
+ if ( row.biblio.subscriptions_count > 0 ) {
+ result += '
'
+ + _("%s subscription(s) left").format(row.biblio.subscriptions_count)
+ + ' ';
+ }
+
+ if ( row.biblio.holds_count > 0 ) {
+ result += '
'
+ + _("%s hold(s) left").format(row.biblio.holds_count) + ' ';
+ }
+
+ return result;
+ },
+ "orderable": false
+ }
]
});
- }
-
- if ( $("#receivedt").length ) {
- var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
- "bStateSave": true,
- "iCookieDuration": 60*60*24*1000, // 1000 days
- "iDisplayLength": 10,
- "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]],
- "aoColumnDefs": [
- { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false },
- ],
- "aoColumns": [
- { "sType": "html" },
- { "sType": "html" },
- { "sType": "html" },
- { "sType": "num-html" },
- { "sType": "anti-the" },
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null
- ],
- "sPaginationType": "full"
- }));
- }
-
- // Keep filters from finishreceive.pl to parcel.pl
- $.cookie("filter_parcel_summary", $("#summaryfilter").val());
- $.cookie("filter_parcel_basketname", $("#basketfilter").val());
- $.cookie("filter_parcel_orderno", $("#orderfilter").val());
- $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
- $.cookie("filter_parcel_ean", $("#eanfilter").val());
-
- $("#filterform").on('submit', function(){
+
+ $("#filterform").on("submit", function(e) {
+ e.preventDefault();
+ // Update the datatable URL
+ var summary = $("#summaryfilter").val();
+ var basket_name = $("#basketfilter").val();
+ var basket_group = $("#basketgroupnamefilter").val();
+ var order_id = $("#orderfilter").val();
+ var ean = $("#eanfilter").val();
+
+ var query_and = [];
+
+ if (basket_name != "") {
+ query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } );
+ }
+ if (basket_group != "") {
+ query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } );
+ }
+ if (summary != "") {
+ query_and.push( { "-or": [{"biblio.title": { "like": '%'+summary+'%' } },
+ {"biblio.author": { "like": '%'+summary+'%' } },
+ {"biblio.isbn": { "like": '%'+summary+'%' } } ] } );
+ }
+ [% IF (UNIMARC) %]
+ if (ean != "") {
+ query_and.push( { "biblio.ean": ean } );
+ }
+ [% END %]
+
+ if ( !jQuery.isEmptyObject(query_and) || order_id != "" ) {
+
+ var query_params = [];
+
+ if ( order_id != "" ) {
+ query_params.push("order_id="+order_id);
+ }
+
+ if ( !jQuery.isEmptyObject(query_and) ) {
+ query_and.push(base_query);
+ query_params.push('q=' + encodeURI(JSON.stringify({ "-and": query_and })));
+ }
+
+ pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") );
+ }
+ else {
+ pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) );
+ }
+ pending_orders_table.api().ajax.reload( null, false );
+ });
+
+ $('#clear_form_filters').on("click", function(){
+ $(this).closest('form').find("input[type=text], textarea").val("");
+ pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw();
+ });
+
+ // Keep filters from finishreceive.pl to parcel.pl
$.cookie("filter_parcel_summary", $("#summaryfilter").val());
$.cookie("filter_parcel_basketname", $("#basketfilter").val());
$.cookie("filter_parcel_orderno", $("#orderfilter").val());
$.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
$.cookie("filter_parcel_ean", $("#eanfilter").val());
- });
+
+ $("#filterform").on('submit', function(){
+ $.cookie("filter_parcel_summary", $("#summaryfilter").val());
+ $.cookie("filter_parcel_basketname", $("#basketfilter").val());
+ $.cookie("filter_parcel_orderno", $("#orderfilter").val());
+ $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val());
+ $.cookie("filter_parcel_ean", $("#eanfilter").val());
+ });
$(".previewData").on("click", function(e){
e.preventDefault();
@@ -558,28 +716,28 @@
$("#dataPreview .modal-body").load(page + " div");
$('#dataPreview').modal({show:true});
});
+
$("#dataPreview").on("hidden.bs.modal", function(){
$("#dataPreviewLabel").html("");
$("#dataPreview .modal-body").html("
"+_("Loading")+"
");
});
+ });
+
+ // Case-insensitive version of jquery's contains function
+ jQuery.extend(jQuery.expr[':'], {
+ icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
+ });
+ // Contains exactly function
+ jQuery.extend(jQuery.expr[':'], {
+ containsExactly: "$(a).text() == m[3]"
});
- // Case-insensitive version of jquery's contains function
- jQuery.extend(jQuery.expr[':'], {
- icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
- });
-
- // Contains exactly function
- jQuery.extend(jQuery.expr[':'], {
- containsExactly: "$(a).text() == m[3]"
- });
-
- function transfer_order_popup(ordernumber) {
- var url = "/cgi-bin/koha/acqui/transferorder.pl?"
- + "ordernumber=" + ordernumber
- window.open(url, 'TransferOrder');
- }
+ function transfer_order_popup(ordernumber) {
+ var url = "/cgi-bin/koha/acqui/transferorder.pl?"
+ + "ordernumber=" + ordernumber
+ window.open(url, 'TransferOrder');
+ }
[% END %]
--