sub get_barcodes {
my( $self, $client, $auth, $org_id, $context, $barcode ) = @_;
my $e = new_editor(authtoken => $auth);
+
return $e->event unless $e->checkauth;
return $e->event unless $e->allowed('STAFF_LOGIN', $org_id);
}
}
+# Handles stored messages for patrons
+
+__PACKAGE__->register_method(
+ method => "patron_message_list",
+ api_name => "open-ils.actor.patron_message_list",
+ signature => q/
+ Grabs a list of all pre-defined messages that can be sent to a patron.
+ /
+);
+
+# Gets the list of default messages
+sub patron_message_list {
+
+ my $message_ref = $U->storagereq('open-ils.storage.direct.action.patron_message_list');
+ my @message = @$message_ref;
+ my $stringtoSend;
+
+ foreach (@message) {
+
+ my @sub_message = @$_;
+
+ foreach (@sub_message) {
+
+ $stringtoSend .= $_ . "&SPLIT&";
+ }
+ }
+
+ return $stringtoSend;
+}
+
1;
);
+sub patron_message_list {
+
+ # Grab self, client
+ my $self = shift;
+ my $client = shift;
+
+ $logger->debug("PATRONPROBLEM");
+
+ # Build SQL statement
+ my $select = <<" SQL";
+ SELECT message, weight FROM config.patron_message;
+ SQL
+
+ # Load and execute statement
+ my $sth = action::survey->db_Main->prepare_cached($select);
+
+ $sth->execute();
+
+ return $sth->fetchall_arrayref;
+}
+
+__PACKAGE__->register_method(
+ api_name => 'open-ils.storage.direct.action.patron_message_list',
+ method => 'patron_message_list',
+ api_level => 1,
+ stream => 1,
+);
+
1;
'USER_ORG_UNIT_OPT_IN_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.check' },
'USER_ORG_UNIT_OPT_IN_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.create' },
'GET_BARCODES' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.get_barcodes' },
- 'ADJUST_BILLS_TO_ZERO' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billable_xact.adjust_to_zero' }
+ 'ADJUST_BILLS_TO_ZERO' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billable_xact.adjust_to_zero' },
+ 'PATRON_MESSAGE_LIST' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron_message_list' }
}
var urls = {
window.new_standing_penalty_event_listeners.add(document.getElementById('cancel_btn'),
'command', function() { window.close(); }, false
);
+
window.new_standing_penalty_event_listeners.add(document.getElementById('apply_btn'),
'command',
function() {
if (error) error.standard_unexpected_error_alert(err_prefix,E); else alert(err_prefix + E);
}
+ build_message_menu();
}
function new_penalty_cleanup() {
}
}
+function loadMessage(text){
+
+ var messageBox = document.getElementById("note_tb");
+ messageBox.value = text;
+}
+
+function build_message_menu(){
+
+ // Load the dropdown
+ var messageString = fieldmapper.standardRequest(
+ [ api.PATRON_MESSAGE_LIST.app, api.PATRON_MESSAGE_LIST.method ],
+ { async: false,
+ timeout: 10
+ }
+ );
+
+
+
+ var messageList = messageString.split(/&SPLIT&/);
+
+ // Array of arrays
+ var weightArray = [];
+
+ // Message, weight pairs
+ for (var i = 0; i < messageList.length; i+=2){
+
+ if (i < messageList.length -1){
+
+ var message = messageList[i];
+ var weight = messageList[i + 1];
+
+ // In case I didn't end up with a real weight for some reason
+ if (!isInteger(weight)){
+
+ weight = 1000;
+ }
+
+ // Ensure weight array is long enough, and there is already an array at index messageList[i + 2]
+ if ( !(weightArray[weight] instanceof Array) ){
+
+ weightArray[weight] = [];
+ }
+
+ weightArray[ weight ].push( message );
+ }
+ }
+
+ // Order by weight, then alphabetically
+ for(var i in weightArray){
+
+ weightArray[i].sort();
+
+ for (var n in weightArray[i]){
+
+ var message = weightArray[i][n];
+
+ var dropdown = document.getElementById("csp_messagelist");
+ dropdown.appendItem( message, message, "" );
+ }
+ }
+}
+
+function isInteger(possibleInteger) {
+ return !isNaN(parseFloat(n)) && isFinite(n);
+}
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="">
+ <menulist id="csp_menulist" label="Labels" style="width:90px;">
<menupopup id="csp_menupopup" value="21"/> <!-- default SILENT_NOTE -->
</menulist>
</toolbaritem>
+ <toolbaritem>
+ <menulist id="csp_messagelist" label="Messages" oncommand="loadMessage(event.target.value)" style="width:180px;">
+
+ </menulist>
+ </toolbaritem>
</toolbar>
</toolbox>
<textbox id="note_tb" multiline="true" />