hold thaw/freeze staff UI
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 19 Nov 2007 15:41:12 +0000 (15:41 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 19 Nov 2007 15:41:12 +0000 (15:41 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@8084 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/holds.js
Open-ILS/xul/staff_client/server/patron/holds.xul
Open-ILS/xul/staff_client/server/patron/holds_overlay.xul

index 463b393..ada1d77 100644 (file)
@@ -236,6 +236,8 @@ patron.holds.prototype = {
                                                obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
                                                obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
                                                obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
+                                               obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
+                                               obj.controller.view.cmd_holds_edit_freeze.setAttribute('disabled','false');
                                                obj.controller.view.cmd_show_notifications.setAttribute('disabled','false');
                                                obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
                                                obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
@@ -250,6 +252,8 @@ patron.holds.prototype = {
                                                obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
                                                obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
                                                obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
+                                               obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
+                                               obj.controller.view.cmd_holds_edit_freeze.setAttribute('disabled','true');
                                                obj.controller.view.cmd_show_notifications.setAttribute('disabled','true');
                                                obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
                                                obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
@@ -429,6 +433,7 @@ patron.holds.prototype = {
                                                                        for (var i = 0; i < obj.retrieve_ids.length; i++) {
                                                                                var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
                                                                                hold.selection_depth( obj.data.hash.aout[selection].depth() ); hold.ischanged('1');
+                                        try { if ( typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('IFXME: Error flattening hold before hold update: ' + E); }
                                                                                var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
                                                                                if (typeof robj.ilsevent != 'undefined') throw(robj);
                                                                        }
@@ -487,6 +492,7 @@ patron.holds.prototype = {
                                                                        for (var i = 0; i < obj.retrieve_ids.length; i++) {
                                                                                var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
                                                                                hold.pickup_lib(  pickup_lib ); hold.ischanged('1');
+                                        try { if ( typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('IFXME: Error flattening hold before hold update: ' + E); }
                                                                                var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
                                                                                if (typeof robj.ilsevent != 'undefined') throw(robj);
                                                                        }
@@ -529,6 +535,7 @@ patron.holds.prototype = {
                                                                        for (var i = 0; i < obj.retrieve_ids.length; i++) {
                                                                                var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
                                                                                hold.phone_notify(  phone ); hold.ischanged('1');
+                                        try { if ( typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('IFXME: Error flattening hold before hold update: ' + E); }
                                                                                var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
                                                                                if (typeof robj.ilsevent != 'undefined') throw(robj);
                                                                        }
@@ -580,6 +587,99 @@ patron.holds.prototype = {
                                                        }
                                                }
                                        ],
+                                       'cmd_holds_edit_freeze' : [
+                                               ['command'],
+                                               function() {
+                                                       try {
+                                                               var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+                                                               xml += '<description>Freeze or un-freeze these holds?</description>';
+                                                               xml += '<hbox><button value="freeze" label="Freeze" accesskey="F" name="fancy_submit"/>';
+                                                               xml += '<button value="unfreeze" label="Un-Freeze" accesskey="U" name="fancy_submit"/></hbox>';
+                                                               xml += '</vbox>';
+                                                               var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+                                                               bot_xml += '<spacer flex="1"/><button label="Cancel" accesskey="C" name="fancy_cancel"/></hbox>';
+                                                               netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+                                                               //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
+                                                               //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
+                                                               JSAN.use('util.window'); var win = new util.window();
+                                                               var fancy_prompt_data = win.open(
+                                                                       urls.XUL_FANCY_PROMPT,
+                                                                       //+ '?xml_in_stash=temp_mid'
+                                                                       //+ '&bottom_xml_in_stash=temp_bot'
+                                                                       //+ '&title=' + window.escape('Set Email Notification for Holds'),
+                                                                       'fancy_prompt', 'chrome,resizable,modal',
+                                                                       { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : 'Set Email Notification for Holds' }
+                                                               );
+                                                               if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
+                                                               var freeze = fancy_prompt_data.fancy_submit == 'freeze' ? get_db_true() : get_db_false();
+                                                               var msg = 'Are you sure you would like to ' + ( get_bool( freeze ) ? 'freeze' : 'un-freeze' ) + ' hold' + ( obj.retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ') + '?';
+                                                               var r = obj.error.yns_alert(msg,'Modifying Holds','Yes','No',null,'Check here to confirm this message');
+                                                               if (r == 0) {
+                                                                       for (var i = 0; i < obj.retrieve_ids.length; i++) {
+                                                                               var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
+                                                                               hold.frozen(  freeze ); 
+                                                                               if ( ! get_bool( freeze ) ) {
+                                                                                       hold.thaw_date( null );
+                                                                               }
+                                                                               hold.ischanged('1');
+                                        try { if ( typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('IFXME: Error flattening hold before hold update: ' + E); }
+                                                                               var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
+                                                                               if (typeof robj.ilsevent != 'undefined') throw(robj);
+                                                                       }
+                                                                       obj.retrieve(true);
+                                                               }
+                                                       } catch(E) {
+                                                               obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
+                                                       }
+                                               }
+                                       ],
+
+                    'cmd_holds_edit_thaw_date' : [
+                                               ['command'],
+                                               function() {
+                                                       try {
+                                JSAN.use('util.date');
+                                function check_date(value) {
+                                    try {
+                                        if (! util.date.check('YYYY-MM-DD',value) ) { throw('Invalid Date'); }
+                                        if (util.date.check_past('YYYY-MM-DD',value) ) { 
+                                            throw('Thaw date for frozen holds needs to be after today.'); 
+                                        }
+                                        return true;
+                                    } catch(E) {
+                                        alert(E);
+                                        return false;
+                                    }
+                                }
+
+                                                               var msg = 'Please enter a thaw date for hold' + ( obj.retrieve_ids.length > 1 ? 's ' : ' ') + util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ') + '\nOr set to blank to unset the thaw date for these holds.  Frozen holds without a thaw date will remain frozen until manually unfrozen, otherwise they unfreeze on the thaw date.';
+                                var value = 'YYYY-MM-DD';
+                                var title = 'Modifying Holds';
+                                                               var thaw_date; var invalid = true;
+                                while(invalid) {
+                                    thaw_date = window.prompt(msg,value,title);
+                                    if (thaw_date) {
+                                        invalid = ! check_date(thaw_date);
+                                    } else { 
+                                        invalid = false;
+                                    }
+                                }
+                                if (thaw_date || thaw_date == '') {
+                                    for (var i = 0; i < obj.retrieve_ids.length; i++) {
+                                        var hold = obj.holds_map[ obj.retrieve_ids[i].id ];
+                                        hold.thaw_date(  thaw_date == '' ? null : util.date.formatted_date(thaw_date + ' 00:00:00','%{iso8601}') ); hold.ischanged('1');
+                                        try { if ( typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('IFXME: Error flattening hold before hold update: ' + E); }
+                                        var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
+                                        if (typeof robj.ilsevent != 'undefined') throw(robj);
+                                    }
+                                                                       obj.retrieve(true);
+                                }
+                                                       } catch(E) {
+                                                               obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
+                                                       }
+                                               }
+                                       ],
+
                                        'cmd_holds_retarget' : [
                                                ['command'],
                                                function() {
@@ -731,6 +831,8 @@ patron.holds.prototype = {
                obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
                obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
                obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
+               obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
+               obj.controller.view.cmd_holds_edit_freeze.setAttribute('disabled','true');
                obj.controller.view.cmd_show_notifications.setAttribute('disabled','true');
                obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
                obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
index f5e82c9..bf561dd 100644 (file)
@@ -81,6 +81,8 @@
                <command id="cmd_holds_edit_pickup_lib" />
                <command id="cmd_holds_edit_phone_notify" />
                <command id="cmd_holds_edit_email_notify" />
+               <command id="cmd_holds_edit_thaw_date" />
+               <command id="cmd_holds_edit_freeze" />
                <command id="cmd_holds_edit_selection_depth" disabled="true" hidden="true"/>
                <command id="cmd_broken" disabled="true" hidden="true"/>
                <command id="cmd_holds_retarget"/>
index fb248d2..cee26ce 100644 (file)
@@ -21,7 +21,9 @@
                <menuseparator />
                <menuitem label="Edit Pickup Library" command="cmd_holds_edit_pickup_lib" accesskey="L"/>
                <menuitem label="Edit Phone Notification" command="cmd_holds_edit_phone_notify" accesskey="P"/>
-               <menuitem label="Toggle Email Notification" command="cmd_holds_edit_email_notify" accesskey="E"/>
+               <menuitem label="Set Email Notification" command="cmd_holds_edit_email_notify" accesskey="E"/>
+               <menuitem label="Edit Thaw Date" command="cmd_holds_edit_thaw_date" accesskey="T"/>
+               <menuitem label="Set Freeze" command="cmd_holds_edit_freeze" accesskey="F"/>
                <!--
                <menuitem label="Edit Hold Range" command="cmd_holds_edit_selection_depth" accesskey="R"/>
                <menuitem label="Edit Hold Focus" command="cmd_broken" accesskey="F"/>
@@ -70,7 +72,9 @@
                                <menuseparator />
                                <menuitem label="Edit Pickup Library" command="cmd_holds_edit_pickup_lib" accesskey="L"/>
                                <menuitem label="Edit Phone Notification" command="cmd_holds_edit_phone_notify" accesskey="P"/>
-                               <menuitem label="Toggle Email Notification" command="cmd_holds_edit_email_notify" accesskey="E" />
+                               <menuitem label="Set Email Notification" command="cmd_holds_edit_email_notify" accesskey="E" />
+                <menuitem label="Edit Thaw Date" command="cmd_holds_edit_thaw_date" accesskey="T"/>
+                <menuitem label="Set Freeze" command="cmd_holds_edit_freeze" accesskey="F"/>
                                <!--
                                <menuitem label="Edit Hold Range" command="cmd_holds_edit_selection_depth" accesskey="R" />
                                <menuitem label="Edit Hold Focus" command="cmd_broken" accesskey="F" />