From 3561b6ab01e865b40ae739c79b22d1626b127d63 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 8 Dec 2009 16:47:07 +0000 Subject: [PATCH] plugged in items-out receipt template and printing for selfcheck git-svn-id: svn://svn.open-ils.org/ILS/trunk@15101 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 98 ++++++++++++++++++ ...08.data.selfcheck-itemsout-receipt-template.sql | 100 ++++++++++++++++++ Open-ILS/web/css/skin/default/selfcheck.css | 8 ++ .../web/js/ui/default/circ/selfcheck/selfcheck.js | 115 ++++++++++++++++++--- .../web/templates/default/circ/selfcheck/main.tt2 | 3 + 6 files changed, 308 insertions(+), 18 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0108.data.selfcheck-itemsout-receipt-template.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index c4e614f06..e29b0ba6f 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0107'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0108'); -- berick CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index d4d45d9c6..5d949431a 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -2731,3 +2731,101 @@ INSERT INTO action_trigger.environment ( event_def, path) VALUES ( 10, 'circ_lib.hours_of_operation'), ( 10, 'usr'); + +-- items out selfcheck receipt + +INSERT INTO action_trigger.hook (key, core_type, description, passive) + VALUES ( + 'format.selfcheck.items_out', + 'circ', + 'Formats items out for self-checkout receipt', + TRUE + ); + +INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, group_field, granularity, template ) + VALUES ( + 11, + TRUE, + 1, + 'Self-Checkout Items Out Receipt', + 'format.selfcheck.items_out', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +[%- SET lib = target.0.circ_lib -%] +[%- SET lib_addr = target.0.circ_lib.billing_address -%] +[%- SET hours = lib.hours_of_operation -%] +
+ +
[% date.format %]
+
[% lib.name %]
+
[% lib_addr.street1 %] [% lib_addr.street2 %]
+
[% lib_addr.city %], [% lib_addr.state %] [% lb_addr.post_code %]
+
[% lib.phone %]
+
+ + [% user.family_name %], [% user.first_given_name %] +
    + [% FOR circ IN target %] +
  1. +
    [% helpers.get_copy_bib_basics(circ.target_copy.id).title %]
    +
    Barcode: [% circ.target_copy.barcode %]
    +
    Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
    +
  2. + [% END %] +
+ +
+ Library Hours + [%- BLOCK format_time; date.format(time _ ' 1/1/1000', format='%I:%M %p'); END -%] +
+ Monday + [% PROCESS format_time time = hours.dow_0_open %] + [% PROCESS format_time time = hours.dow_0_close %] +
+
+ Tuesday + [% PROCESS format_time time = hours.dow_1_open %] + [% PROCESS format_time time = hours.dow_1_close %] +
+
+ Wednesday + [% PROCESS format_time time = hours.dow_2_open %] + [% PROCESS format_time time = hours.dow_2_close %] +
+
+ Thursday + [% PROCESS format_time time = hours.dow_3_open %] + [% PROCESS format_time time = hours.dow_3_close %] +
+
+ Friday + [% PROCESS format_time time = hours.dow_4_open %] + [% PROCESS format_time time = hours.dow_4_close %] +
+
+ Saturday + [% PROCESS format_time time = hours.dow_5_open %] + [% PROCESS format_time time = hours.dow_5_close %] +
+
+ Sunday + [% PROCESS format_time time = hours.dow_6_open %] + [% PROCESS format_time time = hours.dow_6_close %] +
+
+
+$$ +); + + +INSERT INTO action_trigger.environment ( event_def, path) VALUES + ( 11, 'target_copy'), + ( 11, 'circ_lib.billing_address'), + ( 11, 'circ_lib.hours_of_operation'), + ( 11, 'usr'); + diff --git a/Open-ILS/src/sql/Pg/upgrade/0108.data.selfcheck-itemsout-receipt-template.sql b/Open-ILS/src/sql/Pg/upgrade/0108.data.selfcheck-itemsout-receipt-template.sql new file mode 100644 index 000000000..5707a9911 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0108.data.selfcheck-itemsout-receipt-template.sql @@ -0,0 +1,100 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0108'); + +INSERT INTO action_trigger.hook (key, core_type, description, passive) + VALUES ( + 'format.selfcheck.items_out', + 'circ', + 'Formats items out for self-checkout receipt', + TRUE + ); + +INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, group_field, granularity, template ) + VALUES ( + 11, + TRUE, + 1, + 'Self-Checkout Items Out Receipt', + 'format.selfcheck.items_out', + 'NOOP_True', + 'ProcessTemplate', + 'usr', + 'print-on-demand', +$$ +[%- USE date -%] +[%- SET user = target.0.usr -%] +[%- SET lib = target.0.circ_lib -%] +[%- SET lib_addr = target.0.circ_lib.billing_address -%] +[%- SET hours = lib.hours_of_operation -%] +
+ +
[% date.format %]
+
[% lib.name %]
+
[% lib_addr.street1 %] [% lib_addr.street2 %]
+
[% lib_addr.city %], [% lib_addr.state %] [% lb_addr.post_code %]
+
[% lib.phone %]
+
+ + [% user.family_name %], [% user.first_given_name %] +
    + [% FOR circ IN target %] +
  1. +
    [% helpers.get_copy_bib_basics(circ.target_copy.id).title %]
    +
    Barcode: [% circ.target_copy.barcode %]
    +
    Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
    +
  2. + [% END %] +
+ +
+ Library Hours + [%- BLOCK format_time; date.format(time _ ' 1/1/1000', format='%I:%M %p'); END -%] +
+ Monday + [% PROCESS format_time time = hours.dow_0_open %] + [% PROCESS format_time time = hours.dow_0_close %] +
+
+ Tuesday + [% PROCESS format_time time = hours.dow_1_open %] + [% PROCESS format_time time = hours.dow_1_close %] +
+
+ Wednesday + [% PROCESS format_time time = hours.dow_2_open %] + [% PROCESS format_time time = hours.dow_2_close %] +
+
+ Thursday + [% PROCESS format_time time = hours.dow_3_open %] + [% PROCESS format_time time = hours.dow_3_close %] +
+
+ Friday + [% PROCESS format_time time = hours.dow_4_open %] + [% PROCESS format_time time = hours.dow_4_close %] +
+
+ Saturday + [% PROCESS format_time time = hours.dow_5_open %] + [% PROCESS format_time time = hours.dow_5_close %] +
+
+ Sunday + [% PROCESS format_time time = hours.dow_6_open %] + [% PROCESS format_time time = hours.dow_6_close %] +
+
+
+$$ +); + + +INSERT INTO action_trigger.environment ( event_def, path) VALUES + ( 11, 'target_copy'), + ( 11, 'circ_lib.billing_address'), + ( 11, 'circ_lib.hours_of_operation'), + ( 11, 'usr'); + +COMMIT; diff --git a/Open-ILS/web/css/skin/default/selfcheck.css b/Open-ILS/web/css/skin/default/selfcheck.css index d8dd7b52a..d17cf3ae5 100644 --- a/Open-ILS/web/css/skin/default/selfcheck.css +++ b/Open-ILS/web/css/skin/default/selfcheck.css @@ -72,6 +72,14 @@ body { border-left: 1px solid #888; } +#oils-selfck-content-header { + margin: 8px 10px 15px 10px; + padding: 8px; + border-bottom: 1px dashed #888; + text-align: right; + width: 100%; +} + #oils-selfck-info-nav { margin: 15px 10px 15px 10px; padding: 8px; diff --git a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js index 173499b4f..f6b91a5f1 100644 --- a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js +++ b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js @@ -30,6 +30,7 @@ function SelfCheckManager() { this.patronBarcodeRegex = null; this.checkouts = []; + this.itemsOut = []; // During renewals, keep track of the ID of the previous circulation. // Previous circ is used for tracking failed renewals (for receipts). @@ -90,13 +91,12 @@ SelfCheckManager.prototype.init = function() { // connect onclick handlers to the various navigation links var linkHandlers = { 'oils-selfck-hold-details-link' : function() { self.drawHoldsPage(); }, - //'oils-selfck-nav-holds' : function() { self.drawHoldsPage(); }, 'oils-selfck-pay-fines-link' : function() { self.drawFinesPage(); }, - //'oils-selfck-nav-fines' : function() { self.drawFinesPage(); }, 'oils-selfck-nav-home' : function() { self.drawCircPage(); }, 'oils-selfck-nav-logout' : function() { self.logoutPatron(); }, 'oils-selfck-nav-logout-print' : function() { self.logoutPatron(true); }, - 'oils-selfck-items-out-details-link' : function() { self.drawItemsOutPage(); } + 'oils-selfck-items-out-details-link' : function() { self.drawItemsOutPage(); }, + 'oils-selfck-print-list-link' : function() { self.printList(); } } for(var id in linkHandlers) @@ -120,7 +120,7 @@ SelfCheckManager.prototype.init = function() { var testPrint = this.cgi.param('testprint'); if(testPrint) { this.checkouts = JSON2js(testPrint); - this.printReceipt(); + this.printSessionReceipt(); this.checkouts = []; } } @@ -299,6 +299,7 @@ SelfCheckManager.prototype.updateScanBox = function(args) { SelfCheckManager.prototype.drawCircPage = function() { openils.Util.show('oils-selfck-circ-tbody'); + this.goToTab('checkout'); while(this.itemsOutTbody.childNodes[0]) this.itemsOutTbody.removeChild(this.itemsOutTbody.childNodes[0]); @@ -309,10 +310,6 @@ SelfCheckManager.prototype.drawCircPage = function() { handler : function(barcode) { self.checkout(barcode); } }); - openils.Util.hide('oils-selfck-payment-page'); - openils.Util.hide('oils-selfck-holds-page'); - openils.Util.show('oils-selfck-circ-page'); - if(!this.circTemplate) this.circTemplate = this.circTbody.removeChild(dojo.byId('oils-selfck-circ-row')); @@ -347,11 +344,11 @@ SelfCheckManager.prototype.drawCircPage = function() { } } + SelfCheckManager.prototype.drawItemsOutPage = function() { openils.Util.hide('oils-selfck-circ-tbody'); - openils.Util.hide('oils-selfck-payment-page'); - openils.Util.hide('oils-selfck-holds-page'); - openils.Util.show('oils-selfck-circ-page'); + + this.goToTab('items_out'); while(this.itemsOutTbody.childNodes[0]) this.itemsOutTbody.removeChild(this.itemsOutTbody.childNodes[0]); @@ -378,8 +375,10 @@ SelfCheckManager.prototype.drawItemsOutPage = function() { progressDialog.hide(); + self.itemsOut = []; dojo.forEach(circs, function(circ) { + self.itemsOut.push(circ.circ.id()); self.displayCheckout( {payload : circ}, (circ.circ.parent_circ()) ? 'renew' : 'checkout', @@ -392,6 +391,48 @@ SelfCheckManager.prototype.drawItemsOutPage = function() { ); } + +SelfCheckManager.prototype.goToTab = function(name) { + this.tabName = name; + + openils.Util.hide('oils-selfck-payment-page'); + openils.Util.hide('oils-selfck-holds-page'); + openils.Util.show('oils-selfck-circ-page'); + + switch(name) { + case 'checkout': + openils.Util.show('oils-selfck-circ-page'); + break; + case 'items_out': + openils.Util.show('oils-selfck-circ-page'); + break; + case 'holds': + openils.Util.show('oils-selfck-holds-page'); + break; + case 'fines': + openils.Util.show('oils-selfck-payment-page'); + break; + } +} + + +SelfCheckManager.prototype.printList = function() { + switch(this.tabName) { + case 'checkout': + this.printSessionReceipt(); + break; + case 'items_out': + this.printItemsOutReceipt(); + break; + case 'holds': + this.printHoldsReceipt(); + break; + case 'fines': + this.printFinesReceipt(); + break; + } +} + SelfCheckManager.prototype.updateHoldsSummary = function() { if(!this.holdsSummary) { @@ -463,9 +504,7 @@ SelfCheckManager.prototype.drawHoldsPage = function() { // TODO add option to hid scanBox // this.updateScanBox(...) - openils.Util.hide('oils-selfck-circ-page'); - openils.Util.hide('oils-selfck-payment-page'); - openils.Util.show('oils-selfck-holds-page'); + this.goToTab('holds'); this.holdTbody = dojo.byId('oils-selfck-hold-tbody'); if(!this.holdTemplate) @@ -840,9 +879,9 @@ SelfCheckManager.prototype.initPrinter = function() { } /** - * Print a receipt + * Print a receipt for this session's checkouts */ -SelfCheckManager.prototype.printReceipt = function(callback) { +SelfCheckManager.prototype.printSessionReceipt = function(callback) { var circIds = []; var circCtx = []; // circ context data. in this case, renewal_failure info @@ -917,13 +956,55 @@ SelfCheckManager.prototype.printData = function(data, numItems, callback) { } +/** + * Print a receipt for this user's items out + */ +SelfCheckManager.prototype.printItemsOutReceipt = function(callback) { + + if(!this.itemsOut.length) return; + + var params = [ + this.authtoken, + this.staff.ws_ou(), + null, + 'format.selfcheck.items_out', + 'print-on-demand', + this.itemsOut + ]; + + var self = this; + fieldmapper.standardRequest( + ['open-ils.circ', 'open-ils.circ.fire_circ_trigger_events'], + { + async : true, + params : params, + oncomplete : function(r) { + var resp = openils.Util.readResponse(r); + var output = resp.template_output(); + if(output) { + self.printData(output.data(), self.itemsOut.length, callback); + } else { + var error = resp.error_output(); + if(error) { + throw new Error("Error creating receipt: " + error.data()); + } else { + throw new Error("No receipt data returned from server"); + } + } + } + } + ); +} + + + /** * Logout the patron and return to the login page */ SelfCheckManager.prototype.logoutPatron = function(print) { if(print && this.checkouts.length) { - this.printReceipt( + this.printSessionReceipt( function() { location.href = location.href; } diff --git a/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 b/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 index 98751c0ee..81c02d8fd 100644 --- a/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 +++ b/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 @@ -17,6 +17,9 @@
+