plugged in items-out receipt template and printing for selfcheck
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Dec 2009 16:47:07 +0000 (16:47 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Dec 2009 16:47:07 +0000 (16:47 +0000)
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
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0108.data.selfcheck-itemsout-receipt-template.sql [new file with mode: 0644]
Open-ILS/web/css/skin/default/selfcheck.css
Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
Open-ILS/web/templates/default/circ/selfcheck/main.tt2

index c4e614f..e29b0ba 100644 (file)
@@ -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,
index d4d45d9..5d94943 100644 (file)
@@ -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 -%]
+<div>
+    <style> li { padding: 8px; margin 5px; }</style>
+    <div>[% date.format %]</div>
+    <div>[% lib.name %]</div>
+    <div>[% lib_addr.street1 %] [% lib_addr.street2 %]</div>
+    <div>[% lib_addr.city %], [% lib_addr.state %] [% lb_addr.post_code %]</div>
+    <div>[% lib.phone %]</div>
+    <br/>
+
+    [% user.family_name %], [% user.first_given_name %]
+    <ol>
+    [% FOR circ IN target %]
+        <li>
+            <div>[% helpers.get_copy_bib_basics(circ.target_copy.id).title %]</div>
+            <div>Barcode: [% circ.target_copy.barcode %]</div>
+            <div>Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]</div>
+        </li>
+    [% END %]
+    </ol>
+    
+    <div>
+        Library Hours
+        [%- BLOCK format_time; date.format(time _ ' 1/1/1000', format='%I:%M %p'); END -%]
+        <div>
+            Monday 
+            [% PROCESS format_time time = hours.dow_0_open %] 
+            [% PROCESS format_time time = hours.dow_0_close %] 
+        </div>
+        <div>
+            Tuesday 
+            [% PROCESS format_time time = hours.dow_1_open %] 
+            [% PROCESS format_time time = hours.dow_1_close %] 
+        </div>
+        <div>
+            Wednesday 
+            [% PROCESS format_time time = hours.dow_2_open %] 
+            [% PROCESS format_time time = hours.dow_2_close %] 
+        </div>
+        <div>
+            Thursday
+            [% PROCESS format_time time = hours.dow_3_open %] 
+            [% PROCESS format_time time = hours.dow_3_close %] 
+        </div>
+        <div>
+            Friday
+            [% PROCESS format_time time = hours.dow_4_open %] 
+            [% PROCESS format_time time = hours.dow_4_close %] 
+        </div>
+        <div>
+            Saturday
+            [% PROCESS format_time time = hours.dow_5_open %] 
+            [% PROCESS format_time time = hours.dow_5_close %] 
+        </div>
+        <div>
+            Sunday 
+            [% PROCESS format_time time = hours.dow_6_open %] 
+            [% PROCESS format_time time = hours.dow_6_close %] 
+        </div>
+    </div>
+</div>
+$$
+);
+
+
+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 (file)
index 0000000..5707a99
--- /dev/null
@@ -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 -%]
+<div>
+    <style> li { padding: 8px; margin 5px; }</style>
+    <div>[% date.format %]</div>
+    <div>[% lib.name %]</div>
+    <div>[% lib_addr.street1 %] [% lib_addr.street2 %]</div>
+    <div>[% lib_addr.city %], [% lib_addr.state %] [% lb_addr.post_code %]</div>
+    <div>[% lib.phone %]</div>
+    <br/>
+
+    [% user.family_name %], [% user.first_given_name %]
+    <ol>
+    [% FOR circ IN target %]
+        <li>
+            <div>[% helpers.get_copy_bib_basics(circ.target_copy.id).title %]</div>
+            <div>Barcode: [% circ.target_copy.barcode %]</div>
+            <div>Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]</div>
+        </li>
+    [% END %]
+    </ol>
+    
+    <div>
+        Library Hours
+        [%- BLOCK format_time; date.format(time _ ' 1/1/1000', format='%I:%M %p'); END -%]
+        <div>
+            Monday 
+            [% PROCESS format_time time = hours.dow_0_open %] 
+            [% PROCESS format_time time = hours.dow_0_close %] 
+        </div>
+        <div>
+            Tuesday 
+            [% PROCESS format_time time = hours.dow_1_open %] 
+            [% PROCESS format_time time = hours.dow_1_close %] 
+        </div>
+        <div>
+            Wednesday 
+            [% PROCESS format_time time = hours.dow_2_open %] 
+            [% PROCESS format_time time = hours.dow_2_close %] 
+        </div>
+        <div>
+            Thursday
+            [% PROCESS format_time time = hours.dow_3_open %] 
+            [% PROCESS format_time time = hours.dow_3_close %] 
+        </div>
+        <div>
+            Friday
+            [% PROCESS format_time time = hours.dow_4_open %] 
+            [% PROCESS format_time time = hours.dow_4_close %] 
+        </div>
+        <div>
+            Saturday
+            [% PROCESS format_time time = hours.dow_5_open %] 
+            [% PROCESS format_time time = hours.dow_5_close %] 
+        </div>
+        <div>
+            Sunday 
+            [% PROCESS format_time time = hours.dow_6_open %] 
+            [% PROCESS format_time time = hours.dow_6_close %] 
+        </div>
+    </div>
+</div>
+$$
+);
+
+
+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;
index d8dd7b5..d17cf3a 100644 (file)
@@ -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;
index 173499b..f6b91a5 100644 (file)
@@ -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;
             }
index 98751c0..81c02d8 100644 (file)
@@ -17,6 +17,9 @@
 </div>
 <div id='oils-selfck-bottom-div'>
     <div id='oils-selfck-content-div'>
+        <div id='oils-selfck-content-header'>
+            <a id='oils-selfck-print-list-link' href='javascript:void(0);'>Print List</a>
+        </div>
         <div id='oils-selfck-circ-page' class='hidden'>
             <!-- Checkout / renewal interface -->
             [% INCLUDE 'default/circ/selfcheck/circ_page.tt2' %]