From 09e4d286d6c7d84d3995dd704b2a2e7f5db650c4 Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 15 Dec 2005 16:28:35 +0000 Subject: [PATCH] first go at moving staff client 2 trap hold logic to staff client 3 git-svn-id: svn://svn.open-ils.org/ILS/trunk@2403 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/server/circ/hold_capture.js | 166 ++++++++++++++++++ .../staff_client/server/circ/hold_capture.xul | 72 ++++++++ .../server/circ/hold_capture_overlay.xul | 54 ++++++ Open-ILS/xul/staff_client/server/circ/util.js | 6 +- 4 files changed, 295 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/xul/staff_client/server/circ/hold_capture.js create mode 100644 Open-ILS/xul/staff_client/server/circ/hold_capture.xul create mode 100644 Open-ILS/xul/staff_client/server/circ/hold_capture_overlay.xul diff --git a/Open-ILS/xul/staff_client/server/circ/hold_capture.js b/Open-ILS/xul/staff_client/server/circ/hold_capture.js new file mode 100644 index 0000000000..cd77ff1e7e --- /dev/null +++ b/Open-ILS/xul/staff_client/server/circ/hold_capture.js @@ -0,0 +1,166 @@ +dump('entering circ.hold_capture.js\n'); + +if (typeof circ == 'undefined') circ = {}; +circ.hold_capture = function (params) { + + JSAN.use('util.error'); this.error = new util.error(); + JSAN.use('util.network'); this.network = new util.network(); + this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'}); +} + +circ.hold_capture.prototype = { + + 'init' : function( params ) { + + var obj = this; + + obj.session = params['session']; + + JSAN.use('circ.util'); + var columns = circ.util.columns( + { + 'barcode' : { 'hidden' : false }, + 'title' : { 'hidden' : false }, + 'status' : { 'hidden' : false }, + //'hold_capture_status' : { 'hidden' : false }, + 'hold_capture_route_to' : { 'hidden' : false }, + 'hold_capture_text' : { 'hidden' : false, 'flex' : 3 }, + } + ); + dump('columns = ' + js2JSON(columns) + '\n'); + + JSAN.use('util.list'); obj.list = new util.list('hold_capture_list'); + obj.list.init( + { + 'columns' : columns, + 'map_row_to_column' : circ.util.std_map_row_to_column(), + } + ); + + JSAN.use('util.controller'); obj.controller = new util.controller(); + obj.controller.init( + { + 'control_map' : { + 'hold_capture_barcode_entry_textbox' : [ + ['keypress'], + function(ev) { + if (ev.keyCode && ev.keyCode == 13) { + obj.hold_capture(); + } + } + ], + 'cmd_broken' : [ + ['command'], + function() { alert('Not Yet Implemented'); } + ], + 'cmd_hold_capture_submit_barcode' : [ + ['command'], + function() { + obj.hold_capture(); + } + ], + 'cmd_hold_capture_print' : [ + ['command'], + function() { + } + ], + 'cmd_hold_capture_reprint' : [ + ['command'], + function() { + } + ], + 'cmd_hold_capture_done' : [ + ['command'], + function() { + } + ], + } + } + ); + this.controller.view.hold_capture_barcode_entry_textbox.focus(); + + }, + + 'hold_capture' : function() { + var obj = this; + try { + var barcode = obj.controller.view.hold_capture_barcode_entry_textbox.value; + JSAN.use('circ.util'); + var hold_capture = circ.util.hold_capture_via_barcode( + obj.session, barcode, true + ); + if (hold_capture) { + JSAN.use('patron.util'); + var au_obj = patron.util.retrieve_via_id( hold_capture.hold.usr() ); + obj.list.append( + { + 'row' : { + 'my' : { + 'patron' : au_obj, + 'circ' : hold_capture.circ, + 'mvr' : hold_capture.record, + 'acp' : hold_capture.copy, + 'status' : hold_capture.status, + 'route_to' : hold_capture.route_to, + 'text' : hold_capture.text, + } + } + //I could override map_row_to_column here + } + ); + + alert('To Printer\n' + check.text + '\r\n' + 'Barcode: ' + barcode + ' Title: ' + check.record.title() + + ' Author: ' + check.record.author() + '\r\n' + + 'Route To: ' + check.route_to + + ' Patron: ' + au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + + '\r\n'); //FIXME + /* + sPrint(check.text + '
\r\n' + 'Barcode: ' + barcode + ' Title: ' + check.record.title() + + ' Author: ' + check.record.author() + '
\r\n' + + 'Route To: ' + check.route_to + + ' Patron: ' + au_obj.card().barcode() + ' ' + au_obj.family_name() + ', ' + au_obj.first_given_name() + + '
\r\n' + ); + */ + + if (typeof obj.on_hold_capture == 'function') { + obj.on_hold_capture(hold_capture); + } + if (typeof window.xulG == 'object' && typeof window.xulG.on_hold_capture == 'function') { + obj.error.sdump('D_CIRC','circ.hold_capture: Calling external .on_hold_capture()\n'); + window.xulG.on_hold_capture(hold_capture); + } else { + obj.error.sdump('D_CIRC','circ.hold_capture: No external .on_hold_capture()\n'); + } + } else { + throw("Could not capture hold."); + } + + } catch(E) { + alert('FIXME: need special alert and error handling\n' + + js2JSON(E)); + if (typeof obj.on_failure == 'function') { + obj.on_failure(E); + } + if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') { + obj.error.sdump('D_CIRC','circ.hold_capture: Calling external .on_failure()\n'); + window.xulG.on_failure(E); + } else { + obj.error.sdump('D_CIRC','circ.hold_capture: No external .on_failure()\n'); + } + } + + }, + + 'on_hold_capture' : function() { + this.controller.view.hold_capture_barcode_entry_textbox.value = ''; + this.controller.view.hold_capture_barcode_entry_textbox.focus(); + }, + + 'on_failure' : function() { + this.controller.view.hold_capture_barcode_entry_textbox.select(); + this.controller.view.hold_capture_barcode_entry_textbox.focus(); + } +} + +dump('exiting circ.hold_capture.js\n'); diff --git a/Open-ILS/xul/staff_client/server/circ/hold_capture.xul b/Open-ILS/xul/staff_client/server/circ/hold_capture.xul new file mode 100644 index 0000000000..0beb608f01 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/circ/hold_capture.xul @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/xul/staff_client/server/circ/hold_capture_overlay.xul b/Open-ILS/xul/staff_client/server/circ/hold_capture_overlay.xul new file mode 100644 index 0000000000..a69b5f7975 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/circ/hold_capture_overlay.xul @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + +