spawn external text editor for Patron Letter during Mark Item Missing Pieces workflow...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 13 Aug 2010 08:18:42 +0000 (08:18 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 13 Aug 2010 08:18:42 +0000 (08:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17209 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties
Open-ILS/xul/staff_client/server/cat/util.js

index 0b12f89..80fe257 100644 (file)
 <!ENTITY staff.server.admin.index.transits "Transits">
 <!ENTITY staff.server.admin.index.transit_list "Transit List">
 <!ENTITY staff.server.admin.index.conify "Server Settings">
+<!ENTITY staff.server.admin.index.external_text_editor.label "External Text Editor Command">
+<!ENTITY staff.server.admin.index.external_text_editor.accesskey "x">
 
 <!ENTITY staff.server.admin.index.booking "Booking">
 <!ENTITY staff.server.admin.index.booking.reservation "Create/Cancel Reservations">
index 944f68a..91d5178 100644 (file)
@@ -617,6 +617,21 @@ main.menu.prototype = {
                 ['oncommand'],
                 function() { open_eg_web_page('conify/global/permission/grp_penalty_threshold'); }
             ],
+            'cmd_local_admin_external_text_editor' : [
+                ['oncommand'],
+                function() {
+                    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
+                    var key = 'oils.text_editor.external.cmd';
+                    var has_key = prefs.prefHasUserValue(key);
+                    var value = has_key ? prefs.getCharPref(key) : 'C:\\Windows\\notepad.exe %letter.txt%';
+                    var cmd = window.prompt(
+                        document.getElementById('offlineStrings').getString('text_editor.prompt_for_external_cmd'),
+                        value
+                    );
+                    if (!cmd) { return; }
+                    prefs.setCharPref(key,cmd);
+                }
+            ],
             'cmd_local_admin_idl_field_doc' : [
                 ['oncommand'],
                 function() { open_eg_web_page('conify/global/config/idl_field_doc'); }
index 1465635..5aeed9d 100644 (file)
     <command id="cmd_local_admin_standing_penalty"/>
     <command id="cmd_local_admin_grp_penalty_threshold"/>
     <command id="cmd_local_admin_copy_location_order"/>
+    <command id="cmd_local_admin_external_text_editor"
+        label="&staff.server.admin.index.external_text_editor.label;"
+        accesskey="&staff.server.admin.index.external_text_editor.accesskey;"/>
     <command id="cmd_local_admin_idl_field_doc"/>
     <command id="cmd_local_admin_action_trigger"/>
     <command id="cmd_local_admin_survey"/>
                 <menuitem label="&staff.server.admin.index.closed_dates;" command="cmd_local_admin_closed_dates"/>
                 <menuitem label="&staff.server.admin.index.copy_locations;" command="cmd_local_admin_copy_locations"/>
                 <menuitem label="&staff.main.menu.admin.local_admin.conify.copy_location_order.label;" command="cmd_local_admin_copy_location_order"/>
+                <menuitem command="cmd_local_admin_external_text_editor"/>
                 <menuitem label="&staff.main.menu.admin.local_admin.conify.idl_field_doc.label;" command="cmd_local_admin_idl_field_doc"/>
                 <menuitem label="&staff.server.admin.index.fonts_and_sounds;" command="cmd_local_admin_fonts_and_sounds"/>
                 <menuitem label="&staff.main.menu.admin.local_admin.conify.grp_penalty_threshold.label;" command="cmd_local_admin_grp_penalty_threshold"/>
index 19a60f0..eca1229 100644 (file)
@@ -263,3 +263,4 @@ staff.cat.create_or_rebarcode_items=Create or Re-barcode Items
 printing.nothing_to_reprint=Nothing to re-print
 printing.prompt_for_external_print_cmd=Enter external print command and parameters (use %receipt.txt% or %receipt.html% as the file containing the print data. Those values will be substituted with the proper path.):
 printing.print_strategy_saved=Print strategy (%1$s) saved to file system.
+text_editor.prompt_for_external_cmd=Enter external text editor command and parameters (use %letter.txt% as the file containing the text. This value will be substituted with the proper path.):
index 566f1b2..28531e5 100644 (file)
@@ -775,7 +775,7 @@ cat.util.mark_item_as_missing_pieces = function(copy_ids) {
                                 'chrome,resizable,modal',
                                 { 'copy_id' : copies[i].id() }
                             );
-                            // TODO: patron notes/messages
+                            // Patron Message
                             var my_xulG = win.open(
                                 urls.XUL_NEW_STANDING_PENALTY,
                                 'new_standing_penalty',
@@ -794,7 +794,35 @@ cat.util.mark_item_as_missing_pieces = function(copy_ids) {
                                     [ ses(), penalty ]
                                 );
                             }
-                            // TODO: Invoke 3rd party app with letter to patron
+                            // Patron Letter
+
+                            var txt_file = new util.file('letter.txt');
+                            txt_file.write_content('truncate',robj.payload.letter.template_output().data());
+                            var text_path = '"' + txt_file._file.path + '"';
+                            txt_file.close();
+
+                            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
+                            var key = 'oils.text_editor.external.cmd';
+                            var has_key = prefs.prefHasUserValue(key);
+                            var oils_external_letter_opener_cmd = has_key ? prefs.getCharPref(key) : 'C:\\Windows\\notepad.exe %letter.txt%';
+
+                            var cmd = oils_external_letter_opener_cmd.replace('%letter.txt%',text_path);
+
+                            var file = new util.file('letter.bat');
+                            file.write_content('truncate+exec',cmd);
+                            file.close();
+                            file = new util.file('letter.bat');
+
+                            dump('letter exec: ' + cmd + '\n');
+                            var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
+                            process.init(file._file);
+
+                            var args = [];
+
+                            dump('process.run = ' + process.run(false, args, args.length) + '\n');
+
+                            file.close();
+
                         } else if (robj.ilsevent == 1500 /* ACTION_CIRCULATION_NOT_FOUND */) {
                             alert( $("catStrings").getFormattedString('staff.cat.util.mark_item_missing_pieces.circ_not_found',[ copies[i].barcode() ]) );
                         } else {