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 obj.session = params['session'];
24 JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
25 this.test_patron = new au();
26 this.test_patron.family_name('Doe');
27 this.test_patron.first_given_name('John');
28 this.test_card = new ac();
29 this.test_card.barcode('123456789');
30 this.test_patron.card( this.test_card );
34 'items' : { 'dump' : function() { return JSON2js('[["1858348","421","268297","31001000418112","AC KRENTZ","1","Stacks","Normal","ARL-ATH","Normal","Yes","Yes","Yes","No","No","0","18","","","2006-02-13 15:31:30.730986-05","","2006-02-27","Deep waters ","Krentz, Jayne Ann.","","0671575236 :","p1997","Simon & Schuster Audio","PIN01074166 ","1","Checked out","???","???"]]'); } },
35 'holds' : { 'dump' : function() { return; } },
36 'patrons' : { 'dump' : function() { return; } },
40 if (typeof obj.data.print_list_templates == 'undefined') {
41 obj.data.print_list_types = [ 'items', 'holds', 'patrons' ];
42 obj.data.print_list_templates = {
45 'header' : 'You following items were checked:<hr/><ol>',
46 'line_item' : '<li>%title%\r\nBarcode: %barcode%\r\n',
47 'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\n',
51 'header' : 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou have the following items:<hr/><ol>',
52 'line_item' : '<li>%title%\r\nBarcode: %barcode% Due: %due_date%\r\n',
53 'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%',
57 'header' : 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou checked out the following items:<hr/><ol>',
58 'line_item' : '<li>%title%\r\nBarcode: %barcode% Due: %due_date%\r\n',
59 'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%',
63 'header' : 'You checked in the following items:<hr/><ol>',
64 'line_item' : '<li>%title%\r\nBarcode: %barcode% Call Number: %call_number%\r\n',
65 'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\n',
69 'header' : 'Welcome %PATRON_FIRSTNAME%, to %LIBRARY%!\r\nYou have the following titles on hold:<hr/><ol>',
70 'line_item' : '<li>%title%\r\n',
71 'footer' : '</ol><hr />%PINES_CODE% %TODAY%\r\nYou were helped by %STAFF_FIRSTNAME% %STAFF_LASTNAME%',
75 obj.data.stash( 'print_list_templates', 'print_list_types' );
78 obj.controller_init();
79 obj.controller.render(); obj.controller.view.template_name_menu.focus();
83 this.error.sdump('D_ERROR','print_list.init: ' + E + '\n');
87 'controller_init' : function() {
90 JSAN.use('util.controller'); obj.controller = new util.controller();
94 'sample' : [ ['command'], function() { } ],
95 'header' : [ ['change'], function() { obj.preview(); } ],
96 'line_item' : [ ['change'], function() { obj.preview(); } ],
97 'footer' : [ ['change'], function() { obj.preview(); } ],
107 obj.save_template( obj.controller.view.template_name_menu.value );
113 alert( 'not yet implemented' );
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.columns( {} ),
147 return '%' + o.id + '%';
152 var macro_string = macros.join(', ');
153 JSAN.use('util.window');
154 var win = new util.window();
155 win.open('data:text/html,'
157 '<html style="width: 600; height: 400;">'
158 + '<head><title>Template Macros</title></head>'
159 + '<body onload="document.getElementById(\'btn\').focus()">'
160 + '<h1>General:</h1>'
161 + '<p>%PINES_CODE%, %TODAY%, %STAFF_FIRSTNAME%, %STAFF_LASTNAME%, '
162 + '%PATRON_FIRSTNAME%, %LIBRARY%</p>'
164 + template_type + '</h1>'
165 + '<p>' + macro_string + '</p>'
166 + '<button id="btn" onclick="window.close()">Close Window</button>'
168 ), 'title', 'chrome,resizable');
174 'template_name_menu_placeholder' : [
178 JSAN.use('util.widgets'); JSAN.use('util.functional');
179 util.widgets.remove_children(e);
180 var ml = util.widgets.make_menulist(
181 util.functional.map_object_to_list(
182 obj.data.print_list_templates,
183 function(o,i) { return [i,i]; }
186 ml.setAttribute('id','template_name_menu');
187 ml.setAttribute('editable','true');
188 ml.setAttribute('flex','1');
190 obj.controller.view.template_name_menu = ml;
194 var tmp = obj.data.print_list_templates[ ev.target.value ];
195 obj.controller.view.template_type_menu.value = tmp.type;
196 obj.controller.view.header.value = tmp.header;
197 obj.controller.view.line_item.value = tmp.line_item;
198 obj.controller.view.footer.value = tmp.footer;
204 var tmp = obj.data.print_list_templates[ ml.value ];
205 obj.controller.view.template_type_menu.value = tmp.type;
206 obj.controller.view.header.value = tmp.header;
207 obj.controller.view.line_item.value = tmp.line_item;
208 obj.controller.view.footer.value = tmp.footer;
214 'template_type_menu_placeholder' : [
218 JSAN.use('util.widgets'); JSAN.use('util.functional');
219 util.widgets.remove_children(e);
220 var ml = util.widgets.make_menulist(
221 util.functional.map_list(
222 obj.data.print_list_types,
223 function(o) { return [o,o]; }
226 ml.setAttribute('id','template_types_menu');
228 obj.controller.view.template_type_menu = ml;
237 alert('controller_init: ' + E );
241 'preview' : function () {
244 'patron' : this.test_patron,
245 'lib' : this.data.hash.aou[ this.data.list.au[0].ws_ou() ],
246 'staff' : this.data.list.au[0],
247 'header' : this.controller.view.header.value,
248 'line_item' : this.controller.view.line_item.value,
249 'footer' : this.controller.view.footer.value,
250 'type' : this.controller.view.template_type_menu.value,
251 'list' : this.test_list[ this.controller.view.template_type_menu.value ].dump(),
252 'sample_frame' : this.controller.view.sample,
254 JSAN.use('util.print'); var print = new util.print();
255 print.tree_list( params );
257 this.error.sdump('D_ERROR','preview: ' + E);
258 alert('preview: ' + E);
262 'save_template' : function(name) {
264 this.data.print_list_templates[name].header = this.controller.view.header.value;
265 this.data.print_list_templates[name].line_item = this.controller.view.line_item.value;
266 this.data.print_list_templates[name].footer = this.controller.view.footer.value;
267 this.data.print_list_templates[name].type = this.controller.view.template_type_menu.value;
268 this.data.stash( 'print_list_templates' );
269 alert('Template Saved\n' + js2JSON(obj.data.print_list_templates[name]));
274 dump('exiting print_list_template_editor.js\n');