<!ENTITY staff.patron_display.standing.label 'Standing:'>
<!ENTITY staff.patron_display.status.caption 'Status'>
<!ENTITY staff.patron_display_interface_label "Patron">
-<!ENTITY staff.patron_display.penalty.caption "Staff-Generated Blocks / Standing Penalties">
-<!ENTITY staff.patron_display.penalty.menu.actions.label "Actions for these Penalties">
+<!ENTITY staff.patron_display.penalty.caption "Staff-Generated Penalties/Messages">
+<!ENTITY staff.patron_display.penalty.menu.actions.label "Actions for these Penalties/Messages">
<!ENTITY staff.patron_display.penalty.menu.actions.accesskey "P">
-<!ENTITY staff.patron_display.penalty.menu.apply.label "Apply New Penalty">
-<!ENTITY staff.patron_display.penalty.menu.apply.accesskey "N">
-<!ENTITY staff.patron_display.penalty.menu.actions.remove.label "Remove from Patron">
+<!ENTITY staff.patron_display.penalty.menu.apply.label "Apply Standing Penalty/Message">
+<!ENTITY staff.patron_display.penalty.menu.apply.accesskey "S">
+<!ENTITY staff.patron_display.penalty.menu.actions.remove.label "Remove Penalty/Message">
<!ENTITY staff.patron_display.penalty.menu.actions.remove.accesskey "R">
-<!ENTITY staff.patron_display.penalty.menu.actions.edit.label "Edit Note">
-<!ENTITY staff.patron_display.penalty.menu.actions.edit.accesskey "E">
+<!ENTITY staff.patron_display.penalty.menu.actions.edit.label "Modify Penalty/Message">
+<!ENTITY staff.patron_display.penalty.menu.actions.edit.accesskey "M">
+<!ENTITY staff.patron_display.apply_penalty_dialog.title "Apply Standing Penalty/Message">
+<!ENTITY staff.patron_display.apply_penalty_dialog.header "Apply Standing Penalty/Message">
+<!ENTITY staff.patron_display.apply_penalty_dialog.description "Notes, Alerts, Blocks">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.note.label "Note">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.note.accesskey "N">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.alert.label "Alert">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.alert.accesskey "t">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.block.label "Block">
+<!ENTITY staff.patron_display.apply_penalty_dialog.radio_btn.block.accesskey "k">
+<!ENTITY staff.patron_display.apply_penalty_dialog.cancel_btn.label "Cancel">
+<!ENTITY staff.patron_display.apply_penalty_dialog.cancel_btn.accesskey "C">
+<!ENTITY staff.patron_display.apply_penalty_dialog.apply_btn.label "Apply">
+<!ENTITY staff.patron_display.apply_penalty_dialog.apply_btn.accesskey "A">
+<!ENTITY staff.patron_display.edit_penalty_dialog.title "Modify Standing Penalty/Message">
+<!ENTITY staff.patron_display.edit_penalty_dialog.header "Modify Standing Penalty/Message">
+<!ENTITY staff.patron_display.edit_penalty_dialog.description "Notes, Alerts, Blocks">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.note.label "Note">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.note.accesskey "N">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.alert.label "Alert">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.alert.accesskey "t">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.block.label "Block">
+<!ENTITY staff.patron_display.edit_penalty_dialog.radio_btn.block.accesskey "k">
+<!ENTITY staff.patron_display.edit_penalty_dialog.cancel_btn.label "Cancel">
+<!ENTITY staff.patron_display.edit_penalty_dialog.cancel_btn.accesskey "C">
+<!ENTITY staff.patron_display.edit_penalty_dialog.apply_btn.label "Modify">
+<!ENTITY staff.patron_display.edit_penalty_dialog.apply_btn.accesskey "M">
<!ENTITY staff.patron_editor_interface_label "Patron Edit">
<!ENTITY staff.patron_interface_label "Patron ">
<!ENTITY staff.patron_navbar.bills 'Bills'>
}
const api = {
+ 'PCRUD_XACT_BEGIN' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.transaction.begin' },
+ 'PCRUD_XACT_COMMIT' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.transaction.commit' },
+ 'PCRUD_XACT_ROLLBACK' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.transaction.rollback' },
'TEST_SECURE' : { 'app' : 'open-ils.actor', 'method' : 'opensrf.system.time' },
'TEST_UNSECURE' : { 'app' : 'open-ils.actor', 'method' : 'opensrf.system.time', 'secure' : false },
'AUTH_INIT' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.init' },
'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_PCRUD_UPDATE' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.update.ausp', 'secure' : false },
'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 },
'XUL_SPINE_LABEL' : '/xul/server/cat/spine_labels.xul',
'XUL_STANDALONE' : 'chrome://open_ils_staff_client/content/circ/offline.xul',
'XUL_STANDING_PENALTIES' : '/xul/server/patron/standing_penalties.xul',
+ 'XUL_NEW_STANDING_PENALTY' : '/xul/server/patron/new_standing_penalty.xul',
+ 'XUL_EDIT_STANDING_PENALTY' : '/xul/server/patron/edit_standing_penalty.xul',
'XUL_STAT_CAT_EDIT' : '/xul/server/admin/stat_cat_editor.xhtml',
'XUL_SURVEY_WIZARD' : 'chrome://open_ils_staff_client/content/admin/survey_wizard.xul',
'XUL_USER_BUCKETS' : '/xul/server/patron/user_buckets.xul',
staff.patron.summary.expires_on=Expires on
staff.patron.summary.standing_penalty.remove=Remove
staff.patron.summary.standing_penalty.none=No Blocks/Penalties
-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
--- /dev/null
+var data; var error;
+
+function default_focus() { document.getElementById('note_tb').focus(); } // parent interfaces often call this
+
+function edit_penalty_init() {
+ try {
+
+ commonStrings = document.getElementById('commonStrings');
+ patronStrings = document.getElementById('patronStrings');
+
+ if (typeof JSAN == 'undefined') {
+ throw(
+ commonStrings.getString('common.jsan.missing')
+ );
+ }
+
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+
+ JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+
+ JSAN.use('util.error'); error = new util.error();
+ JSAN.use('util.widgets');
+
+ build_penalty_menu();
+
+ /* set widget values */
+ document.getElementById('csp_menupopup').setAttribute('value',xul_param('id',{'modal_xulG':true}));
+ if (xul_param('id',{'modal_xulG':true})==21) { // SILENT_NOTE
+ document.getElementById('note_btn').checked = true;
+ } else if (xul_param('id',{'modal_xulG':true})==20) { // ALERT_NOTE
+ document.getElementById('alert_btn').checked = true;
+ } else if (xul_param('id',{'modal_xulG':true})==25) { // STAFF_CHR
+ document.getElementById('block_btn').checked = true;
+ } else {
+ var nl = document.getElementById('csp_menupopup').getElementsByAttribute('value',xul_param('id',{'modal_xulG':true}));
+ if (nl.length > 0) {
+ document.getElementById('csp_menulist').setAttribute('label', nl[0].getAttribute('label'));
+ } else {
+ document.getElementById('csp_menulist').setAttribute('label', '???');
+ }
+ }
+
+ /* set widget behavior */
+ document.getElementById('csp_menulist').addEventListener(
+ 'command',
+ function() {
+ document.getElementById('note_btn').checked = false;
+ document.getElementById('alert_btn').checked = false;
+ document.getElementById('block_btn').checked = false;
+ },
+ false
+ );
+ document.getElementById('note_btn').addEventListener(
+ 'command',
+ function() {
+ document.getElementById('csp_menulist').setAttribute('label','');
+ document.getElementById('csp_menupopup').setAttribute('value','21'); // SILENT_NOTE
+ },
+ false
+ );
+ document.getElementById('alert_btn').addEventListener(
+ 'command',
+ function() {
+ document.getElementById('csp_menulist').setAttribute('label','');
+ document.getElementById('csp_menupopup').setAttribute('value','20'); // ALERT_NOTE
+ },
+ false
+ );
+ document.getElementById('block_btn').addEventListener(
+ 'command',
+ function() {
+ document.getElementById('csp_menulist').setAttribute('label','');
+ document.getElementById('csp_menupopup').setAttribute('value','25'); // STAFF_CHR
+ },
+ false
+ );
+ document.getElementById('cancel_btn').addEventListener(
+ 'command', function() { window.close(); }, false
+ );
+ document.getElementById('apply_btn').addEventListener(
+ 'command',
+ function() {
+ update_modal_xulG(
+ {
+ 'id' : document.getElementById('csp_menupopup').getAttribute('value'),
+ 'note' : document.getElementById('note_tb').value,
+ 'modify' : 1
+ }
+ )
+ window.close();
+ },
+ false
+ );
+ default_focus();
+
+ } catch(E) {
+ var err_prefix = 'standing_penalties.js -> penalty_init() : ';
+ if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+ }
+
+}
+
+function build_penalty_menu() {
+ try {
+
+ var csp_menupopup = document.getElementById('csp_menupopup');
+ util.widgets.remove_children(csp_menupopup);
+ for (var i = 0; i < data.list.csp.length; i++) {
+ if (data.list.csp[i].id() > 100) {
+ var menuitem = document.createElement('menuitem'); csp_menupopup.appendChild(menuitem);
+ menuitem.setAttribute('label',data.list.csp[i].label());
+ menuitem.setAttribute('value',data.list.csp[i].id());
+ menuitem.setAttribute('id','csp_'+data.list.csp[i].id());
+ menuitem.setAttribute('oncommand',"var p = this.parentNode; p.parentNode.setAttribute('label',this.getAttribute('label')); p.setAttribute('value'," + data.list.csp[i].id() + ")");
+ }
+ }
+
+ } catch(E) {
+ var err_prefix = 'edit_standing_penalty.js -> build_penalty_menu() : ';
+ if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+ }
+}
+
--- /dev/null
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Dialog: Edit Standing Penalty to Patron -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- PRESENTATION -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window PUBLIC "" ""[
+ <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="edit_penalty_win"
+ onload="try { edit_penalty_init(); font_helper(); } catch(E) { alert(E); }"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ title="&staff.patron_display.edit_penalty_dialog.title;">
+
+ <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+ <!-- BEHAVIOR -->
+ <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true;</script>
+ <scripts id="openils_util_scripts"/>
+
+ <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+ <script type="text/javascript" src="edit_standing_penalty.js"/>
+
+ <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties" />
+
+ <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+ <!-- CONTENT -->
+ <dialogheader title="&staff.patron_display.edit_penalty_dialog.header;" description="&staff.patron_display.edit_penalty_dialog.description;" />
+ <toolbox flex="1">
+ <toolbar>
+ <toolbarbutton id="note_btn"
+ type="radio" group="radio" style="-moz-user-focus: normal"
+ label="&staff.patron_display.edit_penalty_dialog.radio_btn.note.label;" accesskey="&staff.patron_display.edit_penalty_dialog.radio_btn.note.accesskey;"
+ checked="true"/>
+ <toolbarbutton id="alert_btn"
+ type="radio" group="radio" style="-moz-user-focus: normal"
+ label="&staff.patron_display.edit_penalty_dialog.radio_btn.alert.label;" accesskey="&staff.patron_display.edit_penalty_dialog.radio_btn.alert.accesskey;" />
+ <toolbarbutton id="block_btn"
+ type="radio" group="radio" style="-moz-user-focus: normal"
+ label="&staff.patron_display.edit_penalty_dialog.radio_btn.block.label;" accesskey="&staff.patron_display.edit_penalty_dialog.radio_btn.block.accesskey;" />
+ <toolbarspring/>
+ <toolbaritem>
+ <menulist id="csp_menulist" label="">
+ <menupopup id="csp_menupopup" />
+ </menulist>
+ </toolbaritem>
+ </toolbar>
+ </toolbox>
+ <textbox id="note_tb" multiline="true" />
+ <hbox>
+ <spacer flex="1"/>
+ <button id="cancel_btn" label="&staff.patron_display.edit_penalty_dialog.cancel_btn.label;" accesskey="&staff.patron_display.edit_penalty_dialog.cancel_btn.accesskey;" />
+ <button id="apply_btn" label="&staff.patron_display.edit_penalty_dialog.apply_btn.label;" accesskey="&staff.patron_display.edit_penalty_dialog.apply_btn.label;" />
+ </hbox>
+</window>
+
--- /dev/null
+var data; var error;
+
+function default_focus() { document.getElementById('note_tb').focus(); } // parent interfaces often call this
+
+function new_penalty_init() {
+ try {
+
+ commonStrings = document.getElementById('commonStrings');
+ patronStrings = document.getElementById('patronStrings');
+
+ if (typeof JSAN == 'undefined') {
+ throw(
+ commonStrings.getString('common.jsan.missing')
+ );
+ }
+
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+
+ JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+
+ JSAN.use('util.error'); error = new util.error();
+ JSAN.use('util.widgets');
+
+ build_penalty_menu();
+
+ /* set widget behavior */
+ document.getElementById('csp_menulist').addEventListener(
+ 'command',
+ function() {
+ document.getElementById('note_btn').checked = false;
+ document.getElementById('alert_btn').checked = false;
+ document.getElementById('block_btn').checked = false;
+ },
+ false
+ );
+ document.getElementById('note_btn').addEventListener(
+ 'command',
+ function() {
+ document.getElementById('csp_menulist').setAttribute('label','');
+ document.getElementById('csp_menupopup').setAttribute('value','21'); // SILENT_NOTE
+ },
+ false
+ );
+ document.getElementById('alert_btn').addEventListener(
+ 'command',
+ function() {
+ document.getElementById('csp_menulist').setAttribute('label','');
+ document.getElementById('csp_menupopup').setAttribute('value','20'); // ALERT_NOTE
+ },
+ false
+ );
+ document.getElementById('block_btn').addEventListener(
+ 'command',
+ function() {
+ document.getElementById('csp_menulist').setAttribute('label','');
+ document.getElementById('csp_menupopup').setAttribute('value','25'); // STAFF_CHR
+ },
+ false
+ );
+ document.getElementById('cancel_btn').addEventListener(
+ 'command', function() { window.close(); }, false
+ );
+ document.getElementById('apply_btn').addEventListener(
+ 'command',
+ function() {
+ update_modal_xulG(
+ {
+ 'id' : document.getElementById('csp_menupopup').getAttribute('value'),
+ 'note' : document.getElementById('note_tb').value,
+ 'modify' : 1
+ }
+ )
+ window.close();
+ },
+ false
+ );
+
+ default_focus();
+
+ } catch(E) {
+ var err_prefix = 'standing_penalties.js -> penalty_init() : ';
+ if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+ }
+
+}
+
+function build_penalty_menu() {
+ try {
+
+ var csp_menupopup = document.getElementById('csp_menupopup');
+ util.widgets.remove_children(csp_menupopup);
+ for (var i = 0; i < data.list.csp.length; i++) {
+ if (data.list.csp[i].id() > 100) {
+ var menuitem = document.createElement('menuitem'); csp_menupopup.appendChild(menuitem);
+ menuitem.setAttribute('label',data.list.csp[i].label());
+ menuitem.setAttribute('value',data.list.csp[i].id());
+ menuitem.setAttribute('id','csp_'+data.list.csp[i].id());
+ menuitem.setAttribute('oncommand',"var p = this.parentNode; p.parentNode.setAttribute('label',this.getAttribute('label')); p.setAttribute('value'," + data.list.csp[i].id() + ")");
+ }
+ }
+
+ } catch(E) {
+ var err_prefix = 'new_standing_penalty.js -> build_penalty_menu() : ';
+ if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
+ }
+}
+
--- /dev/null
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Dialog: Apply Standing Penalty to Patron -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- PRESENTATION -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window PUBLIC "" ""[
+ <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="new_penalty_win"
+ onload="try { new_penalty_init(); font_helper(); } catch(E) { alert(E); }"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ title="&staff.patron_display.apply_penalty_dialog.title;">
+
+ <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+ <!-- BEHAVIOR -->
+ <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true;</script>
+ <scripts id="openils_util_scripts"/>
+
+ <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+ <script type="text/javascript" src="new_standing_penalty.js"/>
+
+ <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties" />
+
+ <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+ <!-- CONTENT -->
+ <dialogheader title="&staff.patron_display.apply_penalty_dialog.header;" description="&staff.patron_display.apply_penalty_dialog.description;" />
+ <toolbox flex="1">
+ <toolbar>
+ <toolbarbutton id="note_btn"
+ type="radio" group="radio" style="-moz-user-focus: normal"
+ label="&staff.patron_display.apply_penalty_dialog.radio_btn.note.label;" accesskey="&staff.patron_display.apply_penalty_dialog.radio_btn.note.accesskey;"
+ checked="true"/>
+ <toolbarbutton id="alert_btn"
+ type="radio" group="radio" style="-moz-user-focus: normal"
+ label="&staff.patron_display.apply_penalty_dialog.radio_btn.alert.label;" accesskey="&staff.patron_display.apply_penalty_dialog.radio_btn.alert.accesskey;" />
+ <toolbarbutton id="block_btn"
+ type="radio" group="radio" style="-moz-user-focus: normal"
+ label="&staff.patron_display.apply_penalty_dialog.radio_btn.block.label;" accesskey="&staff.patron_display.apply_penalty_dialog.radio_btn.block.accesskey;" />
+ <toolbarspring/>
+ <toolbaritem>
+ <menulist id="csp_menulist" label="">
+ <menupopup id="csp_menupopup" value="21"/> <!-- default SILENT_NOTE -->
+ </menulist>
+ </toolbaritem>
+ </toolbar>
+ </toolbox>
+ <textbox id="note_tb" multiline="true" />
+ <hbox>
+ <spacer flex="1"/>
+ <button id="cancel_btn" label="&staff.patron_display.apply_penalty_dialog.cancel_btn.label;" accesskey="&staff.patron_display.apply_penalty_dialog.cancel_btn.accesskey;" />
+ <button id="apply_btn" label="&staff.patron_display.apply_penalty_dialog.apply_btn.label;" accesskey="&staff.patron_display.apply_penalty_dialog.apply_btn.label;" />
+ </hbox>
+</window>
+
var list; var data; var error; var net; var rows;
+function default_focus() { document.getElementById('apply_btn').focus(); } // parent interfaces often call this
+
function penalty_init() {
try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
commonStrings = document.getElementById('commonStrings');
patronStrings = document.getElementById('patronStrings');
JSAN.use('util.widgets');
init_list();
- build_penalty_menu();
+ document.getElementById('cmd_apply_penalty').addEventListener('command', handle_apply_penalty, false);
document.getElementById('cmd_remove_penalty').addEventListener('command', handle_remove_penalty, false);
document.getElementById('cmd_edit_penalty').addEventListener('command', handle_edit_penalty, false);
populate_list();
+ default_focus();
} catch(E) {
var err_prefix = 'standing_penalties.js -> penalty_init() : ';
var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } );
if (ids.length > 0) {
document.getElementById('cmd_remove_penalty').setAttribute('disabled','false');
+ document.getElementById('cmd_edit_penalty').setAttribute('disabled','false');
} else {
document.getElementById('cmd_remove_penalty').setAttribute('disabled','true');
+ document.getElementById('cmd_edit_penalty').setAttribute('disabled','true');
}
}
}
}
-function build_penalty_menu() {
- try {
-
- var csp_list = document.getElementById('csp_list');
- util.widgets.remove_children(csp_list);
- for (var i = 0; i < data.list.csp.length; i++) {
- if (data.list.csp[i].id() > 100) {
- var menuitem = document.createElement('menuitem'); csp_list.appendChild(menuitem);
- menuitem.setAttribute('label',data.list.csp[i].label());
- menuitem.setAttribute('value',data.list.csp[i].id());
- menuitem.setAttribute('id','csp_'+data.list.csp[i].id());
- menuitem.addEventListener(
- 'command',
- handle_menuitem,
- false
- );
- }
- }
-
- } catch(E) {
- var err_prefix = 'standing_penalties.js -> build_penalty_menu() : ';
- if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
- }
-}
-
-function handle_menuitem(ev) {
+function handle_apply_penalty(ev) {
try {
-
- var id = ev.target.getAttribute('value');
-
- var note = window.prompt(
- patronStrings.getString('staff.patron.standing_penalty.note_prompt'),
- '',
- patronStrings.getString('staff.patron.standing_penalty.note_title')
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.window');
+ var win = new util.window();
+ var my_xulG = win.open(
+ urls.XUL_NEW_STANDING_PENALTY,
+ 'new_standing_penalty',
+ 'chrome,resizable,modal',
+ {}
);
+ if (!my_xulG.id) { alert('cancelled'); return 0; }
+
var penalty = new ausp();
penalty.usr( xulG.patron.id() );
penalty.isnew( 1 );
- penalty.standing_penalty( id );
+ penalty.standing_penalty( my_xulG.id );
penalty.org_unit( ses('ws_ou') );
- penalty.note( note );
+ penalty.note( my_xulG.note );
net.simple_request(
'FM_AUSP_APPLY',
[ ses(), penalty ],
- generate_request_handler_for_penalty_apply( penalty, id )
+ generate_request_handler_for_penalty_apply( penalty, my_xulG.id )
);
document.getElementById('progress').hidden = false;
} catch(E) {
- var err_prefix = 'standing_penalties.js -> handle_menuitem() : ';
+ alert('error: ' + E);
+ var err_prefix = 'standing_penalties.js -> handle_apply_penalty() : ';
if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
}
}
}
};
}
-
+
function handle_remove_penalty(ev) {
try {
function handle_edit_penalty(ev) {
try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.window');
+ var win = new util.window();
+
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();
+ alert('penalty = ' + js2JSON(penalty));
+ var my_xulG = win.open(
+ urls.XUL_EDIT_STANDING_PENALTY,
+ 'new_standing_penalty',
+ 'chrome,resizable,modal',
+ {
+ 'id' : typeof penalty.standing_penalty() == 'object' ? penalty.standing_penalty().id() : penalty.standing_penalty(),
+ 'note' : penalty.note()
}
- document.getElementById('progress').hidden = true;
+ );
+ if (my_xulG.modify) {
+ document.getElementById('progress').hidden = false;
+ penalty.note( my_xulG.note ); /* this is for rendering, and propogates by reference to the object associated with the row in the GUI */
+ penalty.standing_penalty( my_xulG.id );
+ penalty.ischanged( 1 );
+ dojo.require('openils.PermaCrud');
+ var pcrud = new openils.PermaCrud( { authtoken :ses() });
+ pcrud.apply( penalty, {
+ timeout : 10, // makes it synchronous
+ onerror : function(r) {
+ try {
+ document.getElementById('progress').hidden = true;
+ var res = openils.Util.readResponse(r,true);
+ error.standard_unexpected_error_alert(patronStrings.getString('staff.patron.standing_penalty.update_error'),res);
+ } catch(E) {
+ alert(E);
+ }
+ },
+ oncomplete : function(r) {
+ try {
+ var res = openils.Util.readResponse(r,true);
+ list.refresh_row( rows[ ids[i] ] );
+ document.getElementById('progress').hidden = true;
+ } catch(E) {
+ alert(E);
+ }
+ }
+ });
}
- );
+ }
+ /*
+ if (xulG && typeof xulG.refresh == 'function') {
+ xulG.refresh();
+ }
+ */
}
} catch(E) {
<commandset id="penalty_cmds">
<command id="cmd_apply_penalty" />
- <command id="cmd_remove_penalty" />
- <command id="cmd_edit_penalty" />
+ <command id="cmd_remove_penalty" disabled="true"/>
+ <command id="cmd_edit_penalty" disabled="true"/>
+ <command id="cmd_show_all" />
+ <command id="cmd_show_note" />
+ <command id="cmd_show_alert" />
+ <command id="cmd_show_block" />
</commandset>
<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<caption id="penalty_caption" label="&staff.patron_display.penalty.caption;"/>
<vbox flex="0">
<hbox flex="1">
- <menubar>
- <menu label="&staff.patron_display.penalty.menu.apply.label;" accesskey="&staff.patron_display.penalty.menu.apply.accesskey;">
- <menupopup id="csp_list">
- </menupopup>
- </menu>
- </menubar>
- <spacer flex="1"/>
- <progressmeter id="progress" flex="1" hidden="true" mode="undetermined"/>
- <spacer flex="1"/>
- <menubar>
- <menu label="&staff.patron_display.penalty.menu.actions.label;" accesskey="&staff.patron_display.penalty.menu.actions.accesskey;">
- <menupopup>
- <menuitem command="cmd_remove_penalty" label="&staff.patron_display.penalty.menu.actions.remove.label;" accesskey="&staff.patron-display.menu.actions.remove.accesskey;"/>
- <menuitem command="cmd_edit_penalty" label="&staff.patron_display.penalty.menu.actions.edit.label;" accesskey="&staff.patron-display.menu.actions.edit.accesskey;"/>
- </menupopup>
- </menu>
- </menubar>
+ <toolbox flex="1">
+ <toolbar>
+ <toolbaritem> <!-- why not a toolbarbutton? I like the way this looks better -->
+ <button id="apply_btn"
+ command="cmd_apply_penalty"
+ label="&staff.patron_display.penalty.menu.apply.label;"
+ accesskey="&staff.patron_display.penalty.menu.apply.accesskey;"
+ style="-moz-user-focus: normal" />
+ </toolbaritem>
+ <toolbarseparator />
+ <!--
+ <toolbarbutton command="cmd_show_all" label="All" accesskey="A" type="radio" group="radio" style="-moz-user-focus: normal" checked="true"/>
+ <toolbarbutton command="cmd_show_note" label="Note" accesskey="N" type="radio" group="radio" style="-moz-user-focus: normal"/>
+ <toolbarbutton command="cmd_show_alert" label="Alert" accesskey="t" type="radio" group="radio" style="-moz-user-focus: normal"/>
+ <toolbarbutton command="cmd_show_block" label="Block" accesskey="k" type="radio" group="radio" style="-moz-user-focus: normal"/>
+ <toolbarseparator />
+ -->
+ <toolbarspring />
+ <toolbaritem>
+ <progressmeter id="progress" flex="1" hidden="true" mode="undetermined"/>
+ </toolbaritem>
+ <toolbarbutton
+ label="&staff.patron_display.penalty.menu.actions.label;"
+ accesskey="&staff.patron_display.penalty.menu.actions.accesskey;"
+ type="menu" style="-moz-user-focus: normal"
+ oncommand="this.focus(); this.firstChild.showPopup()">
+ <menupopup>
+ <menuitem command="cmd_remove_penalty" label="&staff.patron_display.penalty.menu.actions.remove.label;" accesskey="&staff.patron-display.menu.actions.remove.accesskey;"/>
+ <menuitem command="cmd_edit_penalty" label="&staff.patron_display.penalty.menu.actions.edit.label;" accesskey="&staff.patron-display.menu.actions.edit.accesskey;"/>
+ </menupopup>
+ </toolbarbutton>
+ </toolbar>
+ </toolbox>
</hbox>
</vbox>
<tree id="ausp_list" flex="1" enableColumnDrag="true" context="ausp_actions"/>
},
{
'persist' : 'hidden width ordinal', 'id' : 'csp_name', 'label' : commonStrings.getString('staff.csp_name_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.csp.name(); }
+ 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.csp.name(); }
},
{
'persist' : 'hidden width ordinal', 'id' : 'csp_label', 'label' : commonStrings.getString('staff.csp_label_label'), 'flex' : 1,