receipts
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 16 Feb 2006 13:33:16 +0000 (13:33 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 16 Feb 2006 13:33:16 +0000 (13:33 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3094 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/util/print.js
Open-ILS/xul/staff_client/server/circ/checkin.js
Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js
Open-ILS/xul/staff_client/server/patron/holds.js
Open-ILS/xul/staff_client/server/patron/items.js
Open-ILS/xul/staff_client/server/patron/search_result.js
Open-ILS/xul/staff_client/server/patron/search_result.xul
Open-ILS/xul/staff_client/server/patron/search_result_overlay.xul

index 3c218bf..78257e4 100644 (file)
@@ -41,6 +41,109 @@ util.print.prototype = {
                        }, 0
                );
        },
+       
+       'tree_list' : function (params) { 
+               var cols;
+               switch(params.type) {
+                       case 'items':
+                               JSAN.use('circ.util');
+                               cols = util.functional.map_list(
+                                       circ.util.columns( {} ),
+                                       function(o) {
+                                               return '%' + o.id + '%';
+                                       }
+                               );
+                       break;
+                       case 'holds':
+                               JSAN.use('circ.util');
+                               cols = util.functional.map_list(
+                                       circ.util.hold_columns( {} ),
+                                       function(o) {
+                                               return '%' + o.id + '%';
+                                       }
+                               );
+                       break;
+                       case 'patrons':
+                               JSAN.use('patron.util');
+                               cols = util.functional.map_list(
+                                       patron.util.columns( {} ),
+                                       function(o) {
+                                               return '%' + o.id + '%';
+                                       }
+                               );
+                       break;
+               }
+
+               var s = this.template_sub( params.header, cols, params );
+               for (var i = 0; i < params.list.length; i++) {
+                       params.row = params.list[i];
+                       s += this.template_sub( params.line_item, cols, params );
+               }
+               s += this.template_sub( params.footer, cols, params );
+
+               if (params.sample_frame) {
+                       params.sample_frame.setAttribute('src','data:text/html,<html>' + window.escape(s) + '</html>');
+               } else {
+                       this.simple(s);
+               }
+       },
+
+       'template_sub' : function( msg, cols, params ) {
+               if (!msg) { dump('template sub called with empty string\n'); return; }
+               JSAN.use('util.date');
+               var s = msg;
+
+               try{s = s.replace(/%LIBRARY%/,params.lib.name());}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s = s.replace(/%PINES_CODE%/,params.lib.shortname());}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s = s.replace(/%STAFF_FIRSTNAME%/,params.staff.first_given_name());}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s = s.replace(/%STAFF_LASTNAME%/,params.staff.family_name());}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s = s.replace(/%STAFF_BARCODE%/,'123abc'); } /* FIXME -- cheating */
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s = s.replace(/%PATRON_FIRSTNAME%/,params.patron.first_given_name());}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s = s.replace(/%PATRON_LASTNAME%/,params.patron.family_name());}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s = s.replace(/%PATRON_BARCODE%/,params.patron.card().barcode());}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+
+               try{s=s.replace(/%TODAY%/g,(new Date()));}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s=s.replace(/%TODAY_m%/g,(util.date.formatted_date(new Date(),'%m')));}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s=s.replace(/%TODAY_d%/g,(util.date.formatted_date(new Date(),'%d')));}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s=s.replace(/%TODAY_Y%/g,(util.date.formatted_date(new Date(),'%Y')));}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s=s.replace(/%TODAY_H%/g,(util.date.formatted_date(new Date(),'%H')));}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s=s.replace(/%TODAY_I%/g,(util.date.formatted_date(new Date(),'%I')));}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s=s.replace(/%TODAY_M%/g,(util.date.formatted_date(new Date(),'%M')));}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s=s.replace(/%TODAY_D%/g,(util.date.formatted_date(new Date(),'%D')));}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+               try{s=s.replace(/%TODAY_F%/g,(util.date.formatted_date(new Date(),'%F')));}
+                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+
+               if (params.row) {
+                       for (var i = 0; i < cols.length; i++) {
+                               dump('s is "' + s + '"\n');
+                               dump('params.row is ' + js2JSON(params.row) + '\n');
+                               dump('col is ' + cols[i] + '\n');
+                               var re = new RegExp(cols[i],"g");
+                               try{s=s.replace(re, params.row[i]);}
+                                       catch(E){this.error.sdump('D_ERROR','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+                               dump('new s is "' + s + '"\n\n');
+                       }
+               }
+
+               return s;
+       },
+
 
        'NSPrint' : function(w,silent,params) {
                if (!w) w = window;
index b4dccb5..ef713ac 100644 (file)
@@ -97,6 +97,8 @@ circ.checkin.prototype = {
                                        'cmd_checkin_print' : [
                                                ['command'],
                                                function() {
+                                                       dump( js2JSON( obj.list.dump() ) );
+                                                       alert( js2JSON( obj.list.dump() ) );
                                                }
                                        ],
                                        'cmd_checkin_reprint' : [
index c9f6d49..e26d46e 100644 (file)
@@ -22,6 +22,20 @@ circ.print_list_template_editor.prototype = {
                        obj.session = params['session'];
 
                        JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+                       this.test_patron = new au();
+                       this.test_patron.family_name('Doe');
+                       this.test_patron.first_given_name('John');
+                       this.test_card = new ac();
+                       this.test_card.barcode('123456789');
+                       this.test_patron.card( this.test_card );
+
+                       this.test_list = {
+                       
+                               'items' : { 'dump' : function() { return JSON2js('[["1858348","421","268297","31001000418112","AC KRENTZ","1","???","Normal","???","Normal","0","0","18","","","2006-02-13 15:31:30.730986-05","","2006-02-27","Deep waters","Krentz, Jayne Ann.","1","???","???","???"],["3524184","462","???","nc10","Not Cataloged","","???","Normal","???","Normal","0","0","0","","","2006-02-16 01:00:44.84216-05","","2006-03-01","temp title","temp author","2","???","???","???"],["3524178","487","???","nc1","Not Cataloged","","???","Normal","???","Normal","0","0","0","","","2006-02-16 11:52:51.065944-05","","2006-03-02","title1","author1","2","???","???","???"]]'); } },
+                               'holds' : { 'dump' : function() { return JSON2js('[["2005-11-18","","","T","Athens-Clarke County Library","ARL-ATH","???","demo@demoland.tv","","","","18","111-222-3344","2006-02-16 03:33:24.90493-05","3","0","183324","3","WATER GARDENS (FOR YOUR GARDEN) PB","Spier, Carol."],["2005-11-22","","","T","Athens-Clarke County Library","ARL-ATH","33207004527158","demo@demoland.tv","","","","25","111-222-3344","2006-02-16 03:33:27.754555-05","3","0","278434","3","Harry Potter and the sorcerer\'s stone","Rowling, J. K."],["2005-11-22","2006-02-09 21:29:09.575124-05","","T","Athens-Clarke County Library","ARL-ATH","33207000946790","demo@demoland.tv","","","","26","111-222-3344","2006-02-09 21:03:11.938293-05","3","0","352139","3","Shakespeare the man","Rowse, A. L. "],["2005-11-22","","","T","Athens-Clarke County Library","ARL-ATH","???","demo@demoland.tv","","","","27","111-222-3344","2006-02-16 03:33:39.35158-05","3","0","277202","3","Costa Rica","Morrison, Marion."],["2005-11-22","","","T","Bogart Branch Library","ARL-BOG","???","demo@demoland.tv","","","","29","111-222-3344","2006-02-16 03:33:41.297713-05","3","0","366540","3","On leaving Charleston","Ripley, Alexandra."],["2005-11-24","","","T","Athens-Clarke County Library","ARL-ATH","???","demo@demoland.tv","","","","30","111-222-3344","2006-02-16 03:33:41.697186-05","3","0","216351","3","Cats! Cats! Cats!","Wiseman, Bernard."],["2005-12-09","","","T","Athens-Clarke County Library","ARL-ATH","???","demo@demoland.tv","","","","32","111-222-3344","2006-02-16 03:33:41.970716-05","3","0","313569","3","Water","Cooper, Jason"],["2006-02-16","2006-02-16 06:23:19.602866-05","","T","Athens-Clarke County Library","ARL-ATH","a1115b1","demo@demoland.tv","","","","65","111-222-3345","2006-02-16 06:22:11.49379-05","14","0","200839","3","Water all around","Pine, Tillie S."]]'); } },
+                               'patrons' : { 'dump' : function() { return JSON2js('[["090909090","demo3","Good","Users","Yes","6","Airman","Demo3","Demo3","D","III","","0","2005-11-22","2008-11-22","ECGR-MIDVL","0","","","","demo2@open-ils.org","1980-04-03","Drivers Licence","9898888777","???","","1"],["123321123321123","miker2","Good","Patrons","Yes","21","mr","Rylander","Mike","E","IIX","","0","2006-02-16","2006-01-01","ARL-BOG","0","770-222-5555","","","miker@example.com","1979-01-22","State ID","0987654321","???","","1"],["123456789","demo","Good","Staff","Yes","3","Mr.","Joe","Demo","J","","test","0","2005-11-15","2008-11-15","ARL-ATH","978.38","111-222-3345","222-333-4455","","demo@demoland.tv","1976-10-24","Drivers Licence","888888","???","","1"],["user2","user2","Good","Patrons","Yes","17","","User","Jim","","","","0","2006-02-13","2009-02-13","ARL-BOG","0","404","","","","2005-12-12","Drivers Licence","1234","???","","1"],["18009999999","animalmother","Good","Patrons","Yes","12","","Mother","Animal","","","","0","2006-02-13","2008-02-15","ARL-BOG","0","444-333-2222","","","animalmother@fullmetaljacket.net","1969-01-02","SSN","123456789","???","","1"],["staff3","staff3","Good","Circulators","Yes","15","","staff","circ","","","","0","2006-02-13","2009-02-13","ARL-BKM","0","777","","","","2005-12-12","Drivers Licence","n/a","???","","1"],["staff2","staff2","Good","Circulators","Yes","14","","Staff","Circ","","","","0","2006-02-13","2009-02-13","ARL-BOG","0","777","","","","2005-12-12","Drivers Licence","n/a","???","","1"],["11223344","miker","Good","Patrons","Yes","8","Mr","rylander","mike","","","","0","2005-12-19","2008-12-19","ARL-EAST","0","12123412","","","mrylander@example.com","1979-01-22","Voter Card","123456","???","","1"],["987654321","erickson","Good","Operations Manager","Yes","4","","Erickson","Bill","S","","","1","2005-11-18","2008-11-18","ARL-ATH","5","111-444-7777","1-800-999-9998","","bill@mastashake.org","1976-10-24","Voter Card","999999999999","???","","1"],["user4","user4","Good","Patrons","Yes","34","","Nimble","Jack","B","","","0","2006-02-16","2009-02-16","ARL-ATH","0","404","","","","2000-10-10","Drivers Licence","123","???","","1"],["user3","user3","Good","Patrons","Yes","18","","User","Jane","","","","0","2006-02-13","2009-02-13","ARL-BKM","0","404","","","","2005-12-12","Drivers Licence","12345","???","","1"],["user1","user1","Good","Patrons","Yes","16","","User","Joe","","","","0","2006-02-13","2009-02-13","ARL-ATH","0","404","404","","","2005-12-12","Drivers Licence","123","???","","1"],["staff1","staff1","Good","Circulators","Yes","13","","Staff","Circ","","","","0","2006-02-13","2009-02-13","ARL-ATH","0","777","","","","2005-12-12","Drivers Licence","n/a","???","","1"],["1122332211","demo2","Good","Users","Yes","5","Advisor","Jones","Demo2","D","","","0","2005-11-22","2008-11-22","CPRL-R","0","111-222-3333","","","demo2@open-ils.org","1980-05-02","Drivers Licence","0009990000","???","","1"]]'); } },
+
+                       }
 
                        if (typeof obj.data.print_list_templates == 'undefined') {
                                obj.data.print_list_types = [ 'items', 'holds', 'patrons' ];
@@ -29,7 +43,7 @@ circ.print_list_template_editor.prototype = {
                                        'items_out' : {
                                                'type' : 'items',
                                                'header' : 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou have the following items:<hr/><ol>',
-                                               'line_item' : '<li>%title: 50%\r\nBarcode: %barcode% Due: %due_date%\r\n',
+                                               'line_item' : '<li>%title%\r\nBarcode: %barcode% Due: %due_date%\r\n',
                                                'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%',
                                        }, 
                                        'checkout' : {
@@ -78,6 +92,7 @@ circ.print_list_template_editor.prototype = {
                                                'preview' : [
                                                        ['command'],
                                                        function() {
+                                                               obj.preview();
                                                        }
                                                ],
                                                'save' : [
@@ -217,19 +232,25 @@ circ.print_list_template_editor.prototype = {
                }
        },
 
-       'preview' : function (name) { 
-               var params = { 
-                       'au' : new au(), 
-                       'lib' : this.data.list.au[0].home_ou(),
-                       'staff' : this.data.list.au[0],
-                       'header' : this.controller.view.header.value,
-                       'line_item' : this.controller.view.line_item.value,
-                       'footer' : this.controller.view.footer.value,
-                       'type' : this.controller.view.template_type_menu.value,
-                       'list' : this.test_list[ this.controller.view.template_type_menu.value ].dump(),
-                       'sample_view' : this.controller.view.sample,
-               };
-               this.print( params );
+       'preview' : function () { 
+               try {
+                       var params = { 
+                               'patron' : this.test_patron, 
+                               'lib' : this.data.hash.aou[ this.data.list.au[0].home_ou() ],
+                               'staff' : this.data.list.au[0],
+                               'header' : this.controller.view.header.value,
+                               'line_item' : this.controller.view.line_item.value,
+                               'footer' : this.controller.view.footer.value,
+                               'type' : this.controller.view.template_type_menu.value,
+                               'list' : this.test_list[ this.controller.view.template_type_menu.value ].dump(),
+                               'sample_frame' : this.controller.view.sample,
+                       };
+                       JSAN.use('util.print'); var print = new util.print();
+                       print.tree_list( params );
+               } catch(E) {
+                       this.error.sdump('D_ERROR','preview: ' + E);
+                       alert('preview: ' + E);
+               }
        },
 
        'save_template' : function(name) {
@@ -241,8 +262,6 @@ circ.print_list_template_editor.prototype = {
                alert('Template Saved');
        },
 
-       'print' : function(params) {
-       },
 }
 
 dump('exiting print_list_template_editor.js\n');
index d337ac9..682c8a3 100644 (file)
@@ -78,6 +78,8 @@ patron.holds.prototype = {
                                        'cmd_holds_print' : [
                                                ['command'],
                                                function() {
+                                                       dump( js2JSON( obj.list.dump() ) + '\n');
+                                                       alert( js2JSON( obj.list.dump() ) + '\n');
                                                }
                                        ],
                                        'cmd_holds_edit' : [
index 40ec7dc..c4ef3a9 100644 (file)
@@ -109,7 +109,7 @@ patron.items.prototype = {
                                        'cmd_items_print' : [
                                                ['command'],
                                                function() {
-                                                       alert('TODO: Print items out receipt');
+                                                       dump(js2JSON(obj.list.dump()) + '\n');
                                                }
                                        ],
                                        'cmd_items_claimed_returned' : [
index 97c1c1a..6170879 100644 (file)
@@ -77,6 +77,13 @@ patron.search_result.prototype = {
                                                ['command'],
                                                function() { alert('Not Yet Implemented'); }
                                        ],
+                                       'cmd_search_print' : [
+                                               ['command'],
+                                               function() {
+                                                       dump( js2JSON( obj.list.dump() ) );
+                                                       alert( js2JSON( obj.list.dump() ) );
+                                               }
+                                       ],
                                }
                        }
                );
index 8b0670f..8f33bf2 100644 (file)
@@ -69,6 +69,7 @@
                <command id="cmd_patron_bills" />
                <command id="cmd_patron_edit" />
                <command id="cmd_patron_info" />
+               <command id="cmd_search_print" />
        </commandset>
 
        <box id="patron_search_result_main" />
index f86d835..051162c 100644 (file)
@@ -8,7 +8,13 @@
 <commandset id="patron_search_result_cmds" />
 
        <box id="patron_search_result_main" flex="1">
-               <tree id="patron_list" flex="1" enableColumnDrag="true" seltype="multiple"/>
+               <vbox flex="1">
+                       <tree id="patron_list" flex="1" enableColumnDrag="true" seltype="multiple"/>
+                       <hbox>
+                               <spacer flex="1"/>
+                               <button label="Print" command="cmd_search_print" />
+                       </hbox>
+               </vbox>
        </box>
 
 </overlay>