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",
'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 },
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
{
'barcode' : obj.barcode,
'id' : obj.id,
+ 'refresh' : function() { obj.refresh_all(); },
'on_finished' : function(patron) {
obj.patron = patron; obj.controller.render();
{
'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');
- document.getElementById('cmd_remove_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_remove_penalty').setAttribute('disabled','true');
}
}
'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(); } )
}
}
}
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);
}
dump('entering patron.summary.js\n');
function $(id) { return document.getElementById(id); }
+var patronStrings = $('patronStrings');
if (typeof patron == 'undefined') patron = {};
patron.summary = function (params) {
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()
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()) {
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() )]));
}
);
/*
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>'
[ ses(), obj.id ]
);
} else {
- throw($("patronStrings").getString('staff.patron.summary.retrieve.no_barcode'));
+ throw(patronStrings.getString('staff.patron.summary.retrieve.no_barcode'));
}
if (robj) {