Add Context to Receipt Templates
authorThomas Berezansky <tsbere@mvlc.org>
Tue, 20 Dec 2011 16:49:16 +0000 (11:49 -0500)
committerJason Etheridge <jason@esilibrary.com>
Wed, 11 Jan 2012 04:53:02 +0000 (23:53 -0500)
By default the print context is used, but this enabled each template to be
assigned a specific printer context that it is intended for.

This means that things that normally use "Default" can be forced to, say,
"Receipt" and such easily.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
Open-ILS/xul/staff_client/chrome/content/util/print.js
Open-ILS/xul/staff_client/server/cat/copy_buckets.js
Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js
Open-ILS/xul/staff_client/server/circ/print_list_template_editor.xul
Open-ILS/xul/staff_client/server/circ/util.js
Open-ILS/xul/staff_client/server/patron/bill2.js

index e2bc1bb..4a96bb1 100644 (file)
 <!ENTITY staff.circ.print_list.top_ui.name.label "Name">
 <!ENTITY staff.circ.print_list.top_ui.name.accesskey "N">
 <!ENTITY staff.circ.print_list.top_ui.type.label "Type">
+<!ENTITY staff.circ.print_list.top_ui.context.label "Force Context">
 <!ENTITY staff.circ.print_list.top_ui.actions.label "Actions">
 <!ENTITY staff.circ.print_list.top_ui.preview.label "Preview">
 <!ENTITY staff.circ.print_list.top_ui.preview.accesskey "P">
index 0dda428..d6e79a7 100644 (file)
@@ -343,6 +343,16 @@ OpenILS.data.prototype = {
                 'holds', 
                 /* 'patrons' */
             ];
+            // We define this for the benefit of the editor.
+            // We don't assign them here, leaving that to the user.
+            // Without one assigned per template the context the util.print was created with will be used instead.
+            obj.print_list_contexts = [
+                'default',
+                'receipt',
+                'label',
+                'mail',
+                'offline',
+            ]; 
             obj.print_list_templates = { 
                 'item_status' : {
                     'type' : 'items',
index 399e61b..414c8d7 100644 (file)
@@ -227,6 +227,7 @@ util.print.prototype = {
         }
         var cols = [];
         var s = '';
+        if (params.context) this.set_context(params.context);
         if (params.header) s += this.template_sub( params.header, cols, params );
         if (params.list) {
             // Pre-templating sort
@@ -303,6 +304,7 @@ util.print.prototype = {
         } else {
             this.simple(s,params);
         }
+        if(this.context != this.default_context) this.set_context(this.default_context);
     },
 
     'template_sub' : function( msg, cols, params ) {
index 9dc89df..a9e3137 100644 (file)
@@ -626,6 +626,7 @@ cat.copy_buckets.prototype = {
                                         'footer' : data.print_list_templates.item_status.footer,
                                         'type' : data.print_list_templates.item_status.type,
                                         'list' : obj.list2.dump_with_keys(),
+                                        'context' : data.print_list_templates.item_status.context,
                                     };
                                     JSAN.use('util.print'); var print = new util.print();
                                     print.tree_list( p );
index f7b3916..c4d461f 100644 (file)
@@ -109,6 +109,7 @@ circ.print_list_template_editor.prototype = {
                 obj.controller.view.header.value = tmp.header;
                 obj.controller.view.line_item.value = tmp.line_item;
                 obj.controller.view.footer.value = tmp.footer;
+                obj.controller.view.template_context_menu.value = tmp.context;
                 obj.preview();
             }, 0
         );
@@ -310,6 +311,7 @@ circ.print_list_template_editor.prototype = {
                                             obj.controller.view.header.value = tmp.header;
                                             obj.controller.view.line_item.value = tmp.line_item;
                                             obj.controller.view.footer.value = tmp.footer;
+                                            obj.controller.view.template_context_menu.value = tmp.context;
                                             obj.preview();
                                         },
                                         false
@@ -335,8 +337,29 @@ circ.print_list_template_editor.prototype = {
                                     obj.controller.view.template_type_menu = ml;
                                 }
                             }
+                        ],
+                        'template_context_menu_placeholder' : [
+                            ['render'],
+                            function(e) {
+                                return function() {
+                                    JSAN.use('util.widgets'); JSAN.use('util.functional');
+                                    util.widgets.remove_children(e);
+                                    var ml = util.widgets.make_menulist(
+                                        [['',null]].concat(
+                                            util.functional.map_list(
+                                                obj.data.print_list_contexts,
+                                                function(o) { return [o,o]; }
+                                            )
+                                        )
+                                    );
+                                    ml.setAttribute('id','template_context_menu');
+                                    e.appendChild(ml);
+                                    obj.controller.view.template_context_menu = ml;
+                                }
+                            }
                         ]
 
+
                     }
                 }
             );
@@ -378,6 +401,7 @@ circ.print_list_template_editor.prototype = {
         obj.data.print_list_templates[name].line_item = obj.controller.view.line_item.value;
         obj.data.print_list_templates[name].footer = obj.controller.view.footer.value;
         obj.data.print_list_templates[name].type = obj.controller.view.template_type_menu.value;
+        obj.data.print_list_templates[name].context = obj.controller.view.template_context_menu.value;
         obj.data.stash( 'print_list_templates' );
         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
         JSAN.use('util.file'); var file = new util.file('print_list_templates');
index 534b16c..0450cfa 100644 (file)
@@ -82,6 +82,8 @@
                 <hbox>
                     <label value="&staff.circ.print_list.top_ui.type.label;" />
                     <hbox id="template_type_menu_placeholder" />
+                    <label value="&staff.circ.print_list.top_ui.context.label;" />
+                    <hbox id="template_context_menu_placeholder" />
                 </hbox>
             </groupbox>
             <groupbox orient="horizontal">
index de7f0e3..c692edd 100644 (file)
@@ -3043,7 +3043,8 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che
                                     'footer' : data.print_list_templates[ template ].footer,
                                     'type' : data.print_list_templates[ template ].type,
                                     'list' : print_list,
-                                    'data' : print_data
+                                    'data' : print_data,
+                                    'context' : data.print_list_templates[ template ].context,
                                 };
                                 if ($('printer_prompt')) {
                                     if (! $('printer_prompt').checked) { parms.no_prompt = true; }
@@ -3448,7 +3449,8 @@ circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,che
                             'footer' : data.print_list_templates[ template ].footer,
                             'type' : data.print_list_templates[ template ].type,
                             'list' : print_list,
-                            'data' : print_data 
+                            'data' : print_data,
+                            'context' : data.print_list_templates[ template ].context,
                         };
                         if ($('printer_prompt')) {
                             if (! $('printer_prompt').checked) { parms.no_prompt = true; }
index 6ee86cf..567dffb 100644 (file)
@@ -866,7 +866,8 @@ function apply_payment() {
                             };
                         }
                     ),
-                    'data' : g.previous_summary
+                    'data' : g.previous_summary,
+                    'context' : g.data.print_list_templates[template].context,
                 };
                 g.error.sdump('D_DEBUG',js2JSON(params));
                 if ($('printer_prompt').hasAttribute('checked')) {