[open-ils-commits] r11736 - in trunk/Open-ILS: src/perlmods/OpenILS/Application xul/staff_client/chrome/content/main xul/staff_client/server/locale/en-US xul/staff_client/server/patron

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jan 5 01:48:09 EST 2009


Author: phasefx
Date: 2009-01-05 01:48:06 -0500 (Mon, 05 Jan 2009)
New Revision: 11736

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
   trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
   trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
   trunk/Open-ILS/xul/staff_client/server/patron/display.js
   trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js
   trunk/Open-ILS/xul/staff_client/server/patron/summary.js
Log:
remove standing penalties

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2009-01-02 21:34:45 UTC (rev 11735)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm	2009-01-05 06:48:06 UTC (rev 11736)
@@ -2754,7 +2754,22 @@
     return 1;
 }
 
+__PACKAGE__->register_method(
+	method	=> "remove_penalty",
+	api_name	=> "open-ils.actor.user.penalty.remove");
 
+sub remove_penalty {
+	my($self, $conn, $auth, $penalty) = @_;
+	my $e = new_editor(authtoken=>$auth, xact => 1);
+	return $e->die_event unless $e->checkauth;
+    my $user = $e->retrieve_actor_user($penalty->usr) or return $e->die_event;
+    return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
+
+    $e->delete_actor_user_standing_penalty($penalty) or return $e->die_event;
+    $e->commit;
+    return 1;
+}
+
 __PACKAGE__->register_method(
 	method => "ranged_penalty_thresholds",
 	api_name => "open-ils.actor.grp_penalty_threshold.ranged.retrieve",

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js	2009-01-02 21:34:45 UTC (rev 11735)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js	2009-01-05 06:48:06 UTC (rev 11736)
@@ -133,6 +133,7 @@
 	'FM_AUS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.settings.retrieve' },
 	'FM_AUS_UPDATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.settings.update' },
 	'FM_AUSP_APPLY' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.apply' },
+	'FM_AUSP_REMOVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.remove' },
 	'FM_BRE_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve', 'secure' : false },
 	'FM_BRE_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve.authoritative', 'secure' : false },
 	'FM_BRE_ID_SEARCH_VIA_BARCODE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.find_by_barcode', 'secure' : false },

Modified: trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties	2009-01-02 21:34:45 UTC (rev 11735)
+++ trunk/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties	2009-01-05 06:48:06 UTC (rev 11736)
@@ -245,6 +245,7 @@
 staff.patron.standing_penalty.note_prompt=Enter note to go with penalties:
 staff.patron.standing_penalty.note_title=Apply Penalty
 staff.patron.standing_penalty.apply_error=Error applying %1$s block/standing penalty.
+staff.patron.standing_penalty.remove_error=Error removing %1$s block/standing penalty.
 staff.patron.ue.uEditInit.session_no_defined=User session is not defined
 staff.patron.ue.uEditSaveuser.error_creating_note=Error creating patron guardian or parent note
 staff.patron.ue.uEditShowSearch.search=Search would be:\n%1$s

Modified: trunk/Open-ILS/xul/staff_client/server/patron/display.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/display.js	2009-01-02 21:34:45 UTC (rev 11735)
+++ trunk/Open-ILS/xul/staff_client/server/patron/display.js	2009-01-05 06:48:06 UTC (rev 11736)
@@ -410,6 +410,7 @@
 				{
 					'barcode' : obj.barcode,
 					'id' : obj.id,
+                    'refresh' : function() { obj.refresh_all(); },
 					'on_finished' : function(patron) {
 
 						obj.patron = patron; obj.controller.render();

Modified: trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js	2009-01-02 21:34:45 UTC (rev 11735)
+++ trunk/Open-ILS/xul/staff_client/server/patron/standing_penalties.js	2009-01-05 06:48:06 UTC (rev 11736)
@@ -24,15 +24,27 @@
             {
                 'columns' : patron.util.csp_columns({}),
                 'map_row_to_columns' : patron.util.std_map_row_to_columns(),
-                'retrieve_row' : function(params) { params.row_node.setAttribute('retrieve_id',params.row.my.csp.id()); params.on_retrieve(params.row); return params.row; },
+                'retrieve_row' : function(params) { 
+                    params.row_node.setAttribute('retrieve_id',params.row.my.csp.id()); 
+                    if (params.row.my.ausp) { params.row_node.setAttribute('retrieve_ausp_id',params.row.my.ausp.id()); }
+                    params.on_retrieve(params.row); 
+                    return params.row; 
+                },
                 'on_select' : function(ev) {
                     var sel = list.retrieve_selection();
                     var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } );
+                    var ausp_ids = util.functional.filter_list(
+                        util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_ausp_id') || 'null' ); } ),
+                        function(o) { return o != null; }
+                    );
                     if (ids.length > 0) {
                         document.getElementById('cmd_apply_penalty').setAttribute('disabled','false');
+                    } else {
+                        document.getElementById('cmd_apply_penalty').setAttribute('disabled','true');
+                    }
+                    if (ausp_ids.length > 0) {
                         document.getElementById('cmd_remove_penalty').setAttribute('disabled','false');
                     } else {
-                        document.getElementById('cmd_apply_penalty').setAttribute('disabled','true');
                         document.getElementById('cmd_remove_penalty').setAttribute('disabled','true');
                     }
                 }
@@ -48,7 +60,7 @@
                             'my' : {
                                 'csp' : data.list.csp[i],
                                 'au' : xulG.patron,
-                                'ausp' : util.functional.find_list( xulG.patron.standing_penalties(), function(o) { dump(js2JSON(o) + '\n'); return o.standing_penalty().id() == data.list.csp[i].id(); } )
+                                'ausp' : util.functional.find_list( xulG.patron.standing_penalties(), function(o) { return o.standing_penalty().id() == data.list.csp[i].id(); } )
                             }
                         }
                     }
@@ -100,6 +112,48 @@
             false
         );
 
+        document.getElementById('cmd_remove_penalty').addEventListener(
+            'command',
+            function() {
+                var sel = list.retrieve_selection();
+                var ids = util.functional.filter_list(
+                    util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_ausp_id') || 'null' ); } ),
+                    function(o) { return o != null; }
+                );
+                if (ids.length > 0) {
+                    function gen_func(id) {
+                        return function() {
+                            var penalty = util.functional.find_list( xulG.patron.standing_penalties(), function(o) { return o.id() == id; } );
+                            penalty.isdeleted(1);
+
+                            var req = net.simple_request( 'FM_AUSP_REMOVE', [ ses(), penalty ] );
+                            if (typeof req.ilsevent != 'undefined' || String(req) != '1') {
+                                error.standard_unexpected_error_alert(patronStrings.getFormattedString('staff.patron.standing_penalty.remove_error',[data.hash.csp[id].name()]),req);
+                            }
+                        }; 
+                    }
+
+                    var funcs = [];
+                    for (var i = 0; i < ids.length; i++) {
+                        funcs.push( gen_func(ids[i]) );
+                    } 
+                    funcs.push(
+                        function() {
+                            if (xulG && typeof xulG.refresh == 'function') {
+                                xulG.refresh();
+                            }
+                            document.getElementById('progress').hidden = true;
+                        }
+                    );
+                    document.getElementById('progress').hidden = false;
+                    JSAN.use('util.exec'); var exec = new util.exec();
+                    exec.chain(funcs);
+                }
+            },
+            false
+        );
+
+
     } catch(E) {
         alert(E);
     }

Modified: trunk/Open-ILS/xul/staff_client/server/patron/summary.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/summary.js	2009-01-02 21:34:45 UTC (rev 11735)
+++ trunk/Open-ILS/xul/staff_client/server/patron/summary.js	2009-01-05 06:48:06 UTC (rev 11736)
@@ -1,6 +1,7 @@
 dump('entering patron.summary.js\n');
 
 function $(id) { return document.getElementById(id); }
+var patronStrings = $('patronStrings');
 
 if (typeof patron == 'undefined') patron = {};
 patron.summary = function (params) {
@@ -79,7 +80,7 @@
 						function(e) {
 							return function() { 
 								e.setAttribute('value',
-									$("patronStrings").getString('staff.patron.summary.patron_net_access') + 
+									patronStrings.getString('staff.patron.summary.patron_net_access') + 
 									' ' + obj.OpenILS.data.hash.cnal[
 										obj.patron.net_access_level()
 									].name()
@@ -104,14 +105,49 @@
 									row.appendChild(label);
 
     								var button = document.createElement('button');
-	    							button.setAttribute('label', $("patronStrings").getString('staff.patron.summary.standing_penalty.remove'));
+	    							button.setAttribute('label', patronStrings.getString('staff.patron.summary.standing_penalty.remove'));
                                     button.setAttribute('image','/xul/server/skin/media/images/icon_delete.gif');
 	    							button.setAttribute('disabled','true');
+	    							button.setAttribute('hidden','true');
+                                    button.setAttribute('retrieve_ausp_id',penalties[i].id());
 		    						row.appendChild(button);
 
                                     // XXX check a permission here? How to fire the remove action ??? XXX
                                     if (penalties[i].standing_penalty().id() > 100) {
 	    							    button.setAttribute('disabled','false');
+	    							    button.setAttribute('hidden','false');
+                                        button.addEventListener(
+                                            'command',
+                                            function(ev) {
+                                                try {
+                                                    JSAN.use('util.functional');
+                                                    var id = ev.target.getAttribute('retrieve_ausp_id');
+                                                    var penalty = util.functional.find_list( obj.patron.standing_penalties(), function(o) { return o.id() == id; } );
+                                                    penalty.isdeleted(1);
+
+                                                    var req = obj.network.simple_request( 'FM_AUSP_REMOVE', [ ses(), penalty ] );
+                                                    if (typeof req.ilsevent != 'undefined' || String(req) != '1') {
+                                                        obj.error.standard_unexpected_error_alert(
+                                                            patronStrings.getFormattedString(
+                                                                'staff.patron.standing_penalty.remove_error',
+                                                                [obj.data.hash.csp[id].name()]
+                                                            ),
+                                                            req
+                                                        );
+                                                    }
+                                                    if (typeof xulG.refresh == 'function') { xulG.refresh(); }
+                                                } catch(F) {
+                                                    obj.error.standard_unexpected_error_alert(
+                                                        patronStrings.getFormattedString(
+                                                            'staff.patron.standing_penalty.remove_error',
+                                                            [ev.target.getAttribute('retrieve_ausp_id')]
+                                                        ),
+                                                        F
+                                                    );
+                                                }
+                                            },
+                                            false
+                                        );
                                     }
 
                                     if (penalties[i].standing_penalty().block_list()) {
@@ -151,7 +187,7 @@
 									function(req) {
 										JSAN.use('util.money');
 										var robj = req.getResultObject();
-										e.setAttribute('value', $("patronStrings").getFormattedString('staff.patron.summary.patron_bill.money', [util.money.sanitize( robj.balance_owed() )]));
+										e.setAttribute('value', patronStrings.getFormattedString('staff.patron.summary.patron_bill.money', [util.money.sanitize( robj.balance_owed() )]));
 									}
 								);
 								/*
@@ -319,7 +355,7 @@
 						function(e) {
 							return function() { 
 								e.setAttribute('value',
-									$("patronStrings").getString('staff.patron.summary.expires_on') + ' ' + (
+									patronStrings.getString('staff.patron.summary.expires_on') + ' ' + (
 										obj.patron.expire_date() ?
 										obj.patron.expire_date().substr(0,10) :
 										'<Unset>'
@@ -609,7 +645,7 @@
 								[ ses(), obj.id ]
 							);
 						} else {
-							throw($("patronStrings").getString('staff.patron.summary.retrieve.no_barcode'));
+							throw(patronStrings.getString('staff.patron.summary.retrieve.no_barcode'));
 						}
 						if (robj) {
 



More information about the open-ils-commits mailing list