update functionality for notes on user standing penalties
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Jan 2009 00:37:24 +0000 (00:37 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 14 Jan 2009 00:37:24 +0000 (00:37 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11821 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/locale/en-US/patron.properties
Open-ILS/xul/staff_client/server/patron/standing_penalties.js

index 58ad587..96870cb 100644 (file)
@@ -2772,6 +2772,28 @@ sub remove_penalty {
 }
 
 __PACKAGE__->register_method(
+       method  => "update_penalty_note",
+       api_name        => "open-ils.actor.user.penalty.note.update");
+
+sub update_penalty_note {
+       my($self, $conn, $auth, $penalty_ids, $note) = @_;
+       my $e = new_editor(authtoken=>$auth, xact => 1);
+       return $e->die_event unless $e->checkauth;
+    for my $penalty_id (@$penalty_ids) {
+        my $penalty = $e->search_actor_user_standing_penalty( { id => $penalty_id } )->[0];
+        if (! $penalty ) { return $e->die_event; }
+        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);
+
+        $penalty->note( $note ); $penalty->ischanged( 1 );
+
+        $e->update_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",
     stream => 1
index dd5f3b2..b186d93 100644 (file)
@@ -136,6 +136,7 @@ const api = {
        '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_AUSP_UPDATE_NOTE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.note.update' },
        '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 },
index c14d8db..1810aa3 100644 (file)
@@ -246,6 +246,10 @@ 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.standing_penalty.update_error=Error updating block/standing penalty.
+staff.patron.standing_penalty.note_prompt.title=Edit Block/Standing Penalty Note
+staff.patron.standing_penalty.note_prompt.singular=Enter note for selected block/standing penalty:
+staff.patron.standing_penalty.note_prompt.plural=Enter note for selected blocks/standing penalties:
 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
index 0917058..437a370 100644 (file)
@@ -165,6 +165,45 @@ function penalty_init() {
             false
         );
 
+        document.getElementById('cmd_edit_penalty').addEventListener(
+            'command',
+            function() {
+                var sel = list.retrieve_selection();
+                var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } );
+                if (ids.length > 0) {
+                    var note = window.prompt(
+                        patronStrings.getString( 'staff.patron.standing_penalty.note_prompt.' + (ids.length == 1 ? 'singular' : 'plural') ),
+                        '',
+                        patronStrings.getString( 'staff.patron.standing_penalty.note_prompt.title' )
+                    );
+                    if (note == null) { return; } /* cancel */
+                    for (var i = 0; i < ids.length; i++) {
+                        var penalty = util.functional.find_list( xulG.patron.standing_penalties(), function(o) { return o.id() == ids[i]; } );
+                        penalty.note( note ); /* this is for rendering, and propogates by reference to the object associated with the row in the GUI */
+                    } 
+                    document.getElementById('progress').hidden = false;
+                    net.simple_request( 
+                        'FM_AUSP_UPDATE_NOTE', [ ses(), ids, note ],
+                        function(reqObj) {
+                            var req = reqObj.getResultObject();
+                            if (typeof req.ilsevent != 'undefined' || String(req) != '1') {
+                                error.standard_unexpected_error_alert(patronStrings.getString('staff.patron.standing_penalty.update_error'),req);
+                            } else {
+                                for (var i = 0; i < ids.length; i++) {
+                                    list.refresh_row( rows[ ids[i] ] );
+                                }
+                            }
+                            if (xulG && typeof xulG.refresh == 'function') {
+                                xulG.refresh();
+                            }
+                            document.getElementById('progress').hidden = true;
+                        }
+                    );
+                }
+            },
+            false
+        );
+
 
     } catch(E) {
         alert(E);