patron display refresh tweaks and offer to cancel transits on hold retargeting
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 22 Oct 2007 05:39:11 +0000 (05:39 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 22 Oct 2007 05:39:11 +0000 (05:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@7903 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 8a1294b..463b393 100644 (file)
@@ -76,6 +76,7 @@ patron.holds.prototype = {
                                                                        params.row_node.setAttribute('retrieve_id', 
                                                                                js2JSON({
                                                                                        'copy_id':copy_id,
+                                            'barcode':row.my.acp ? row.my.acp.barcode() : null,
                                                                                        'id':row.my.ahr.id(),
                                                                                        'type':row.my.ahr.hold_type(),
                                                                                        'target':row.my.ahr.target(),
@@ -431,7 +432,7 @@ patron.holds.prototype = {
                                                                                var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
                                                                                if (typeof robj.ilsevent != 'undefined') throw(robj);
                                                                        }
-                                                                       obj.retrieve();
+                                                                       obj.retrieve(true);
                                                                }
                                                        } catch(E) {
                                                                obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
@@ -489,7 +490,7 @@ patron.holds.prototype = {
                                                                                var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
                                                                                if (typeof robj.ilsevent != 'undefined') throw(robj);
                                                                        }
-                                                                       obj.retrieve();
+                                                                       obj.retrieve(true);
                                                                }
                                                        } catch(E) {
                                                                obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
@@ -531,7 +532,7 @@ patron.holds.prototype = {
                                                                                var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
                                                                                if (typeof robj.ilsevent != 'undefined') throw(robj);
                                                                        }
-                                                                       obj.retrieve();
+                                                                       obj.retrieve(true);
                                                                }
                                                        } catch(E) {
                                                                obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
@@ -543,7 +544,7 @@ patron.holds.prototype = {
                                                function() {
                                                        try {
                                                                var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
-                                                               xml += '<description>Send email notifications (when appropriate)?  The email address used is found in the hold recepient account.</description>';
+                                                               xml += '<description>Send email notifications (when appropriate)?  The email address used is found in the hold recipient account.</description>';
                                                                xml += '<hbox><button value="email" label="Email" accesskey="E" name="fancy_submit"/>';
                                                                xml += '<button value="noemail" label="No Email" accesskey="N" name="fancy_submit"/></hbox>';
                                                                xml += '</vbox>';
@@ -572,15 +573,13 @@ patron.holds.prototype = {
                                                                                var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
                                                                                if (typeof robj.ilsevent != 'undefined') throw(robj);
                                                                        }
-                                                                       obj.retrieve();
+                                                                       obj.retrieve(true);
                                                                }
                                                        } catch(E) {
                                                                obj.error.standard_unexpected_error_alert('Holds not likely modified.',E);
                                                        }
                                                }
                                        ],
-
-
                                        'cmd_holds_retarget' : [
                                                ['command'],
                                                function() {
@@ -610,10 +609,39 @@ patron.holds.prototype = {
                                                                var msg = 'Are you sure you would like to cancel 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,'Cancelling Holds','Yes','No',null,'Check here to confirm this message');
                                                                if (r == 0) {
+                                    var transits = [];
                                                                        for (var i = 0; i < obj.retrieve_ids.length; i++) {
+                                        if (obj.holds_map[ obj.retrieve_ids[i].id ].transit()) {
+                                            transits.push( obj.retrieve_ids[i].barcode );
+                                        }
                                                                                var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id]);
                                                                                if (typeof robj.ilsevent != 'undefined') throw(robj);
                                                                        }
+                                    if (transits.length > 0) {
+                                        var msg2 = 'For barcodes ' + transits.join(', ') + ' cancel the transits as well?';
+                                        var r2 = obj.error.yns_alert(msg2,'Cancelling Transits','Yes','No',null,'Check here to confirm this message');
+                                        if (r2 == 0) {
+                                            try {
+                                                for (var i = 0; i < transits.length; i++) {
+                                                    var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : transits[i] } ]);
+                                                    if (typeof robj.ilsevent != 'undefined') {
+                                                        switch(robj.ilsevent) {
+                                                            case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
+                                                                alert(robj.desc);
+                                                            break;
+                                                            case 5000 /* PERM_FAILURE */ :
+                                                            break;
+                                                            default:
+                                                                throw(robj);
+                                                            break;
+                                                        }
+                                                                                           }
+                                                }
+                                            } catch(E) {
+                                                                           obj.error.standard_unexpected_error_alert('Hold-transits not likely cancelled.',E);
+                                            }
+                                        }
+                                    }
                                                                        obj.retrieve();
                                                                }
                                                        } catch(E) {