1 dump('entering print_list_template_editor.js\n');
3 if (typeof circ == 'undefined') circ = {};
4 circ.print_list_template_editor = function (params) {
6 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7 JSAN.use('util.error'); this.error = new util.error();
9 dump('print_list: ' + E + '\n');
13 circ.print_list_template_editor.prototype = {
15 'init' : function( params ) {
18 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
22 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
23 this.test_patron = new au();
24 this.test_patron.family_name('Doe');
25 this.test_patron.first_given_name('John');
26 this.test_card = new ac();
27 this.test_card.barcode('123456789');
28 this.test_patron.card( this.test_card );
32 'original_balance' : '7.40',
33 'payment_type' : 'Cash',
34 'payment_received' : '10.00',
35 'payment_applied' : '7.40',
36 'voided_balance' : '0.00',
37 'change_given' : '2.60',
38 'credit_given' : '0.00',
39 'note' : "The patron's child paid this",
40 'new_balance' : '0.00',
46 'items' : [["7608453","???","1497190","31033007616786","J 551.48 ARATO R","MGRL-RC","1","Stacks","Short","MGRL-RC","Low","Yes","Yes","Yes","No","No","0","19.95","","","???","???","???","???","World of water ","Arato, Rona.","","0778714160 (rlb : alk. paper)","c2005","Crabtree Pub. Co.","ocm55600795 ","???","???","Available","???","???","3",""],["7136201","???","1424085","31001000224056","YA ROWLING","ARL-ATH","3","Stacks","Short","ARL-ATH","Low","Yes","Yes","Yes","No","No","0","7.99","","","???","???","???","???","Harry Potter and the prisoner of Azkaban ","Rowling, J. K.","","0439136350 (hc)","1999","Arthur A. Levine Books","ocm41266045 ","???","???","Available","???","???","2","alert message here"],["6577928","???","1301532","31041005919235","975.8784 HAG","OHOOP-LADS","1","Stacks","Short","OHOOP-LADS","Low","Yes","Yes","Yes","No","No","0","10","","","???","???","???","???","Georgia genealogical sources series marriages 1869-1879, Appling County Georgia","Hageness, MariLee Beatty.","","","c1998","MLH Research","ocm49507123 ","???","???","Available","???","???","15","high use item"]],
47 'holds' : [["2006-05-13","2006-05-18 16:37:47.062916-04","","T","Athens-Clarke County Library","ARL-ATH","33207004749414","No","","","","7","999-999-9999","2006-05-15 00:37:28.269456-04","3","0","818781","3","Harry Potter and the goblet of fire ","Rowling, J. K.","Large print ed.","0786229276 (lg. print : hc : alk. paper)","2000","Thorndike Press","i0786229276"],["2006-05-16","2006-05-18 20:07:04.474747-04","","T","Athens-Clarke County Library","ARL-ATH","33207004347359","Yes","","","","8","777-777-7777","2006-05-18 16:52:23.866001-04","1000000","0","551071","1000524","Cats ","Arnold, Caroline.","","0822530325 (alk. paper)","1999","Lerner Publications","i0822530325"],["2006-05-17","2006-05-18 20:08:32.882203-04","","T","Athens-Clarke County Library","ARL-ATH","33207002398776","Yes","","","","28","999-999-9999","2006-05-18 16:52:58.020117-04","1000000","0","1274439","3","Tortilla Flat ","Steinbeck, John","","0140042407 (pbk.) :","1986, c1935","Penguin Books","a2095783"],["2006-05-10","2006-05-20 21:02:57.318012-04","","T","Athens-Clarke County Library","ARL-ATH","33207003330208","No","","","","4","222-333-4444","2006-05-18 16:52:23.362607-04","3","0","315900","3","Spreadin\' rhythm around Black popular songwriters, 1880-1930","Jasen, David A.","","0028647424","c1998","Schirmer Books","i0028647424"],["2006-05-20","2006-05-20 21:11:42.124176-04","","T","Athens-Clarke County Library","ARL-ATH","33207001049453","Yes","","","","54","218-233-3757","2006-05-20 19:48:12.101796-04","1000000","0","323269","1000567","Foundation and empire ","Asimov, Isaac","","0893402109","1979","J. Curley","i0893402109"],["2006-05-20","2006-05-20 21:19:15.209143-04","","T","Athens-Clarke County Library","ARL-ATH","33207001502782","Yes","","","","63","218-233-3757","2006-05-20 19:48:37.645795-04","1000567","0","427831","1000567","The Caine mutiny : a novel of World War II","Wouk, Herman","","","1952 [c1951]","Doubleday","PIN24075557"],["2006-06-03","2006-06-07 17:03:32.676709-04","","V","Athens-Clarke County Library","ARL-ATH","No Copy","No","","","","135","999-999-9999","2006-06-05 23:45:18.078505-04","3","0","6592393","3","No Title?","No Author?","???","???","???","???","???"]],
48 'bills' : [["248","Id = 3","grocery","-2.00","0.00","2.00","","Fee for copies","2006-05-27 22:56","","cash_payment","2006-06-10 17:01","2006-05-27",""],["239","Id = 3","circulation","17.00","17.00","0.00","SYSTEM GENERATED","Lost Materials Processing Fee","2006-05-27 22:07","",""," ","2006-05-26",""],["173","Id = 3","grocery","1.00","17.25","16.25","","Lost materials","2006-05-20 16:36","","cash_payment","2006-05-27 01:31","2006-05-20",""]],
49 'payment' : [ { 'bill_id' : 333, 'payment' : '2.23', 'title' : 'Harry Potter', 'last_billing_type' : 'Overdue materials', 'last_billing_note' : 'System Generated Overdue Fine', 'barcode' : 'barcode123' }, { 'bill_id' : 367, 'payment' : '5.17', 'last_billing_type' : 'Damaged material', 'last_billing_note' : 'Tracked up the carpet', 'title' : '', 'barcode' : '' } ],
52 { 'transit_source' : 'ARL-ATH', 'transit_source_send_time' : '2006-05-01 12:15', 'transit_dest_lib' : 'DCPL-CEN', 'transit_item_title' : 'Scooby Doo', 'transit_item_barcode' : 'barcode123' },
53 { 'transit_source' : 'ARL-ATH', 'transit_source_send_time' : '2006-05-02 12:19', 'transit_dest_lib' : 'DCPL-CEN', 'transit_item_title' : 'Scooby Doo', 'transit_item_barcode' : 'barcode456' }
55 'offline_checkout' : [],
56 'offline_checkin' : [],
58 'offline_inhouse_use' : [],
61 obj.controller_init();
62 obj.controller.render(); obj.controller.view.template_name_menu.focus();
68 this.error.sdump('D_ERROR','print_list.init: ' + E + '\n');
72 'post_init' : function() {
76 var tmp = obj.data.print_list_templates[ obj.controller.view.template_name_menu.value ];
77 obj.controller.view.template_type_menu.value = tmp.type;
78 obj.controller.view.header.value = tmp.header;
79 obj.controller.view.line_item.value = tmp.line_item;
80 obj.controller.view.footer.value = tmp.footer;
86 'controller_init' : function() {
89 JSAN.use('util.controller'); obj.controller = new util.controller();
93 'sample' : [ ['command'], function() { } ],
94 'header' : [ ['change'], function() { obj.preview(); } ],
95 'line_item' : [ ['change'], function() { obj.preview(); } ],
96 'footer' : [ ['change'], function() { obj.preview(); } ],
106 obj.save_template( obj.controller.view.template_name_menu.value );
112 obj.data.print_list_defaults();
120 JSAN.use('util.functional');
121 var template_type = obj.controller.view.template_type_menu.value;
123 switch(template_type) {
125 JSAN.use('circ.util');
126 macros = util.functional.map_list(
127 circ.util.columns( {} ),
129 return '%' + o.id + '%';
134 JSAN.use('circ.util');
135 macros = util.functional.map_list(
136 circ.util.hold_columns( {} ),
138 return '%' + o.id + '%';
143 JSAN.use('patron.util');
144 macros = util.functional.map_list(
145 patron.util.mbts_columns( {} ),
147 return '%' + o.id + '%';
152 JSAN.use('patron.util');
153 macros = util.functional.map_list(
154 patron.util.columns( {} ),
156 return '%' + o.id + '%';
161 macros = [ '%original_balance%', '%payment_received%', '%payment_applied%', '%payment_type%', '%voided_balance%', '%change_given%', '%new_balance%', '%note%', '%bill_id%', '%payment%', '%title%' ];
164 var macro_string = macros.join(', ');
165 JSAN.use('util.window');
166 var win = new util.window();
167 win.open('data:text/html,'
169 '<html style="width: 600; height: 400;">'
170 + '<head><title>Template Macros</title></head>'
171 + '<body onload="document.getElementById(\'btn\').focus()">'
172 + '<h1>General:</h1>'
173 + '<p>%PINES_CODE%, %TODAY%, %STAFF_FIRSTNAME%, %STAFF_LASTNAME%, '
174 + '%PATRON_FIRSTNAME%, %LIBRARY%</p>'
176 + template_type + '</h1>'
177 + '<p>' + macro_string + '</p>'
178 + '<button id="btn" onclick="window.close()">Close Window</button>'
180 ), 'title', 'chrome,resizable');
186 'template_name_menu_placeholder' : [
190 JSAN.use('util.widgets'); JSAN.use('util.functional');
191 util.widgets.remove_children(e);
192 var ml = util.widgets.make_menulist(
193 util.functional.map_object_to_list(
194 obj.data.print_list_templates,
195 function(o,i) { return [i,i]; }
198 ml.setAttribute('id','template_name_menu');
199 //ml.setAttribute('editable','true');
200 ml.setAttribute('flex','1');
202 obj.controller.view.template_name_menu = ml;
206 var tmp = obj.data.print_list_templates[ ev.target.value ];
207 obj.controller.view.template_type_menu.value = tmp.type;
208 obj.controller.view.header.value = tmp.header;
209 obj.controller.view.line_item.value = tmp.line_item;
210 obj.controller.view.footer.value = tmp.footer;
218 'template_type_menu_placeholder' : [
222 JSAN.use('util.widgets'); JSAN.use('util.functional');
223 util.widgets.remove_children(e);
224 var ml = util.widgets.make_menulist(
225 util.functional.map_list(
226 obj.data.print_list_types,
227 function(o) { return [o,o]; }
230 ml.setAttribute('id','template_types_menu');
231 ml.setAttribute('disabled','true');
233 obj.controller.view.template_type_menu = ml;
242 alert('controller_init: ' + E );
246 'preview' : function () {
248 var list = this.test_list[ this.controller.view.template_type_menu.value ];
249 if (typeof list == 'undefined') list = [];
250 var data = this.test_data[ this.controller.view.template_type_menu.value ];
251 if (typeof data == 'undefined') data = {};
254 'patron' : this.test_patron,
255 'lib' : this.data.hash.aou[ this.data.list.au[0].ws_ou() ],
256 'staff' : this.data.list.au[0],
257 'header' : this.controller.view.header.value,
258 'line_item' : this.controller.view.line_item.value,
259 'footer' : this.controller.view.footer.value,
260 'type' : this.controller.view.template_type_menu.value,
263 'sample_frame' : this.controller.view.sample,
265 JSAN.use('util.print'); var print = new util.print();
266 print.tree_list( params );
268 this.error.sdump('D_ERROR','preview: ' + E);
269 alert('preview: ' + E);
273 'save_template' : function(name) {
275 obj.data.print_list_templates[name].header = obj.controller.view.header.value;
276 obj.data.print_list_templates[name].line_item = obj.controller.view.line_item.value;
277 obj.data.print_list_templates[name].footer = obj.controller.view.footer.value;
278 obj.data.print_list_templates[name].type = obj.controller.view.template_type_menu.value;
279 obj.data.stash( 'print_list_templates' );
280 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
281 JSAN.use('util.file'); var file = new util.file('print_list_templates');
282 file.set_object(obj.data.print_list_templates); file.close();
283 alert('Template Saved\n' + js2JSON(obj.data.print_list_templates[name]));
288 dump('exiting print_list_template_editor.js\n');