From 07cfdabf4310f5d957edc9d50c2eda52f9676c66 Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 14 Jan 2009 00:37:24 +0000 Subject: [PATCH] update functionality for notes on user standing penalties git-svn-id: svn://svn.open-ils.org/ILS/trunk@11821 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Actor.pm | 22 +++++++++++ .../chrome/content/main/constants.js | 1 + .../server/locale/en-US/patron.properties | 4 ++ .../server/patron/standing_penalties.js | 39 +++++++++++++++++++ 4 files changed, 66 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm index 58ad5875e8..96870cbea8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm @@ -2771,6 +2771,28 @@ sub remove_penalty { return 1; } +__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", diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index dd5f3b2872..b186d93b13 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -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 }, diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties index c14d8dbe16..1810aa3acd 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/patron.properties @@ -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 diff --git a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js index 09170582f6..437a370ce3 100644 --- a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js +++ b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js @@ -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); -- 2.43.2