From 629836cf6a0543fac68e1c6fdb1b1c95e1aa8148 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 11 Jun 2014 15:46:39 -0400 Subject: [PATCH] circ checkin migration; transit slip Signed-off-by: Bill Erickson --- .../staff/admin/workstation/t_print_templates.tt2 | 1 + .../src/templates/staff/circ/checkin/index.tt2 | 1 + .../staff/circ/checkin/t_checkin_table.tt2 | 39 +++-- Open-ILS/src/templates/staff/circ/patron/index.tt2 | 1 + .../staff/circ/share/t_transit_dialog.tt2 | 4 +- .../staff/share/print_templates/t_transit_slip.tt2 | 15 ++ .../js/ui/default/staff/admin/workstation/app.js | 38 ++++- .../web/js/ui/default/staff/circ/checkin/app.js | 180 +++------------------ .../staff/circ/services/{circulate.js => circ.js} | 95 +++++++++-- Open-ILS/web/js/ui/default/staff/services/hatch.js | 2 + 10 files changed, 183 insertions(+), 193 deletions(-) create mode 100644 Open-ILS/src/templates/staff/share/print_templates/t_transit_slip.tt2 rename Open-ILS/web/js/ui/default/staff/circ/services/{circulate.js => circ.js} (77%) diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2 index c25c2bdeb4..5e30af2847 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2 @@ -16,6 +16,7 @@ +
diff --git a/Open-ILS/src/templates/staff/circ/checkin/index.tt2 b/Open-ILS/src/templates/staff/circ/checkin/index.tt2 index ea5d58c4ac..2432bd24e5 100644 --- a/Open-ILS/src/templates/staff/circ/checkin/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/checkin/index.tt2 @@ -9,6 +9,7 @@ + + diff --git a/Open-ILS/src/templates/staff/circ/share/t_transit_dialog.tt2 b/Open-ILS/src/templates/staff/circ/share/t_transit_dialog.tt2 index 7d53a8398e..fd09a2cb0e 100644 --- a/Open-ILS/src/templates/staff/circ/share/t_transit_dialog.tt2 +++ b/Open-ILS/src/templates/staff/circ/share/t_transit_dialog.tt2 @@ -54,10 +54,8 @@
diff --git a/Open-ILS/src/templates/staff/share/print_templates/t_transit_slip.tt2 b/Open-ILS/src/templates/staff/share/print_templates/t_transit_slip.tt2 new file mode 100644 index 0000000000..20d0095407 --- /dev/null +++ b/Open-ILS/src/templates/staff/share/print_templates/t_transit_slip.tt2 @@ -0,0 +1,15 @@ +
+
[% l('This item needs to be routed to [_1]', '{{transit.dest.shortname}}') %]
+ {{transit.dest.name}}
+ {{transit.dest.holds_address.street1}} + {{transit.dest.holds_address.street2}}
+ {{transit.dest.holds_address.city}}, + {{transit.dest.holds_address.state}} + {{transit.dest.holds_address.post_code}}

+ [% l('Barcode: [_1]', '{{transit.target_copy.barcode}}') %]
+ [% l('Title: [_1]', '{{title}}') %]
+ [% l('Author: [_1]', '{{author}}') %]
+ [% l('Slip Date: [_1]', '{{today | date:"short"}}') %]
+ [% l('Printed by [_1] at [_2]', + '{{staff.first_given_name}}', '{{current_location.shortname}}') %]
+
diff --git a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js index 2c52b429b5..11db1bdd17 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js @@ -313,6 +313,25 @@ function($scope , $q , egCore) { barcode : '30393830393' } } + var seed_addr = { + street1 : '123 Apple Rd', + street2 : 'Suite B', + city : 'Anywhere', + state : 'XX', + country : 'US', + post_code : '12345' + } + + var seed_record = { + title : 'Traveling Pants!!', + author : 'Jane Jones', + isbn : '1231312123' + }; + + var seed_copy = { + barcode : '33434322323' + } + $scope.preview_scope = { current_location : egCore.idl.toHash( egCore.org.get(egCore.auth.user().ws_ou())), @@ -358,16 +377,29 @@ function($scope , $q , egCore) { title : 'Test Note Title', usr : seed_user, value : 'This patron is super nice!' - } + }, + + transit : { + dest : { + name : 'Library X', + shortname : 'LX', + holds_address : seed_addr + }, + target_copy : seed_copy + }, + title : seed_record.title, + author : seed_record.author, + staff : egCore.idl.toHash(egCore.auth.user()) } + $scope.preview_scope.payments = [ {amount : 1.00, xact : $scope.preview_scope.transactions[0]}, {amount : 1.00, xact : $scope.preview_scope.transactions[1]} ] $scope.preview_scope.payments[0].xact.title = 'Hali Bote Azikaban de tao fan'; $scope.preview_scope.payments[0].xact.copy_barcode = '334343434'; - $scope.preview_scope.payments[1].xact.title = 'Traveling Pants!!'; - $scope.preview_scope.payments[1].xact.copy_barcode = '334343467'; + $scope.preview_scope.payments[1].xact.title = seed_record.title; + $scope.preview_scope.payments[1].xact.copy_barcode = seed_copy.barcode; $scope.template_changed = function() { egCore.hatch.getPrintTemplate($scope.print.template_name) diff --git a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js index 829a4c89f1..4568cf2583 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js @@ -6,49 +6,19 @@ angular.module('egCheckinApp', ['ngRoute', 'ui.bootstrap', $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export }) -/** - * checkin service - */ .factory('checkinSvc', [function() { - var service = {}; service.checkins = []; return service; }]) -/** - * locally cached org unit addresses -- needed for route slips, etc. - */ -.factory('orgAddrSvc', ['$q','egCore', function($q, egCore) { - var service = {cache : {}}; - service.getAddr = function(org_id, addr_type) { - if (service.cache[org_id]) { - if (service.cache[org_id][addr_type]) { - return $q.when(service.cache[org_id][addr_type]); - } - } else { - service.cache[org_id] = {}; - } - - var deferred = $q.defer(); - egCore.pcrud.retrieve('aoa', egCore.org.get(org_id).holds_address()) - .then(function(addr) { - service.cache[org_id][addr_type] = addr; - deferred.resolve(addr); - }); - return deferred.promise; - } - return service; -}]) /** * Manages checkin */ .controller('CheckinCtrl', - ['$scope','$q','$modal','egCore','checkinSvc','egGridDataProvider', - 'orgAddrSvc','egAlertDialog','egConfirmDialog', -function($scope, $q, $modal, egCore, checkinSvc, egGridDataProvider, - orgAddrSvc, egAlertDialog, egConfirmDialog) { + ['$scope','$q','egCore','checkinSvc','egGridDataProvider','egCirc', +function($scope , $q , egCore , checkinSvc , egGridDataProvider , egCirc) { // run egCore.startup here since it's not handled via resolver egCore.startup.go().then( @@ -59,142 +29,32 @@ function($scope, $q, $modal, egCore, checkinSvc, egGridDataProvider, $scope.focusMe = true; $scope.checkins = checkinSvc.checkins; + var checkinGrid = $scope.gridControls = {}; - var provider = egGridDataProvider.instance({}); - provider.get = function(offset, count) { - return provider.arrayNotifier( - $scope.checkins, offset, count - ); - } - $scope.gridDataProvider = provider; - - function addCheckin(evt) { - checkinSvc.checkins.push(evt); - provider.refresh(); - } - + $scope.gridDataProvider = egGridDataProvider.instance({ + get : function(offset, count) { + return this.arrayNotifier($scope.checkins, offset, count); + } + }); $scope.checkin = function(args) { - if (args && args.copy_barcode) { - performCheckin(angular.copy(args)); - args.copy_barcode = ''; // reset UI - } - - $scope.focusMe = true; - } - - function performCheckin(args, override) { - var method = 'open-ils.circ.checkin'; - if (override) method += '.override'; - egCore.net.request('open-ils.circ', method, egCore.auth.token(), args) - .then(function(evt) { + if (args && args.copy_barcode) { - if (!evt) { - console.error('no checkin response received'); - return; - } + egCirc.checkin(angular.copy(args)) + .then(function(final_resp) { + final_resp.evt.index = checkinSvc.checkins.length; + checkinSvc.checkins.unshift(final_resp.evt); + checkinGrid.refresh(); - if (angular.isArray(evt)) evt = evt[0]; - evt.id = checkinSvc.checkins.length; - evt.copy_barcode = args.copy_barcode; - handleCheckinResponse(evt, args, override); - }); - } + // in case we lost focus to a dialog + $scope.focusMe = true; + }); - function handleCheckinResponse(evt, args, override) { - var copy, hold, transit; - if (evt.payload) { - copy = evt.payload.copy; - hold = evt.payload.hold; - transit = evt.payload.transit; - } - - switch (evt.textcode) { - case 'SUCCESS': - case 'NO_CHANGE': - addCheckin(evt); - if (copy.status() == 8) { // on holds shelf - if (hold && - hold.pickup_lib() == egCore.auth.user().ws_ou()) { - // item should be on our holds shelf. - // display the holds slip - openRouteDialog( - './circ/checkin/t_hold_shelf_dialog', evt, args); - } - } - break; - - case 'ROUTE_ITEM': - addCheckin(evt); - openRouteDialog('./circ/checkin/t_transit_dialog', evt, args); - break; - case 'ASSET_COPY_NOT_FOUND': - $scope.blurMe = true; - egAlertDialog.open(egCore.strings.UNCAT_ALERT_DIALOG, args) - .result.then(function() {$scope.focusMe = true}); - break; - case 'COPY_ALERT_MESSAGE': - $scope.blurMe = true; - egConfirmDialog.open( - egCore.strings.COPY_ALERT_MSG_DIALOG_TITLE, - evt.payload, // payload == alert message text - { copy_barcode : args.copy_barcode, - ok : function() { - // on confirm, redo checkout w/ override - performCheckin(args, true) - }, - cancel : function() { - // on cancel, push the event on the list - // to show that it happened - addCheckin(evt); - } - } - ).result.then(function() {$scope.focusMe = true}) - break; - default: - console.warn('unhandled checkin response : ' + evt.textcode); - console.debug('checkin: ' + js2JSON(evt)); - // push it on the list so the user can at least see - // something happened. - addCheckin(evt); - } - } + args.copy_barcode = ''; // reset UI for next scan + } - function openRouteDialog(tmpl, evt, args) { - // avoid unintended checkins while the dialog is open - $scope.blurMe = true; - $modal.open({ - templateUrl: tmpl, - controller: [ - '$scope', '$modalInstance', 'destAddr', 'holdUser', - function($scope, $modalInstance, destAddr, holdUser) { - $scope.destAddr = destAddr; - $scope.holdUser = holdUser; - $scope.dest = egCore.org.get(evt.org); - $scope.evt = evt; - $scope.now = new Date(); - $scope.ok = function() {$modalInstance.close()} - }], - resolve : { - destAddr : function() { - if (!evt.org) return $q.when(); - // TODO SERVER: response payload should flesh dest addr - return orgAddrSvc.getAddr(evt.org, 'holds_address'); - }, - holdUser : function() { - // TODO SERVER: response payload should flesh hold recipient - if (!evt.payload.hold) return $q.when(); - return egCore.pcrud.retrieve('au', - evt.payload.hold.usr(), { - flesh : 1, - flesh_fields : {'au' : ['card']} - } - ); - } - } - }).result.then(function() {$scope.focusMe = true}); + $scope.focusMe = true; } - }]) diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/circulate.js b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js similarity index 77% rename from Open-ILS/web/js/ui/default/staff/circ/services/circulate.js rename to Open-ILS/web/js/ui/default/staff/circ/services/circ.js index e0d728da12..bab34b6bad 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/services/circulate.js +++ b/Open-ILS/web/js/ui/default/staff/circ/services/circ.js @@ -6,8 +6,8 @@ angular.module('egCoreMod') .factory('egCirc', - ['$modal','$q','egCore', -function($modal , $q , egCore) { + ['$modal','$q','egCore','egAlertDialog','egConfirmDialog', +function($modal , $q , egCore , egAlertDialog , egConfirmDialog) { var service = { // auto-override these events after the first override @@ -73,7 +73,7 @@ function($modal , $q , egCore) { var method = 'open-ils.circ.checkin'; if (options.override) method += '.override'; - egCore.net.request( + return egCore.net.request( 'open-ils.circ', method, egCore.auth.token(), params ).then(function(evt) { @@ -87,6 +87,9 @@ function($modal , $q , egCore) { var final_resp = {evt : evt, params : params, options : options}; + // track the barcode regardless of whether it refers to a copy + evt.copy_barcode = params.copy_barcode; + switch (evt.textcode) { case 'SUCCESS': return $q.when(final_resp); @@ -159,7 +162,7 @@ function($modal , $q , egCore) { }; // fetch/cache for org unit addresses - service.get_org_address = function(org_id, addr_type) { + service.get_org_addr = function(org_id, addr_type) { if (service.org_addr_cache[org_id]) { if (service.org_addr_cache[org_id][addr_type]) return $q.when(service.org_addr_cache[org_id][addr_type]); @@ -275,27 +278,30 @@ function($modal , $q , egCore) { transit = evt.payload.transit; } + // track the barcode regardless of whether it refers to a copy + evt.copy_barcode = params.copy_barcode; + switch (evt.textcode) { case 'SUCCESS': case 'NO_CHANGE': - if (copy.status() == 8) { // on holds shelf - if (hold && - hold.pickup_lib() == egCore.auth.user().ws_ou()) { - // show dialog telling user the item is on the - // local holds shelf - return service.route_dialog( - './circ/share/t_hold_shelf_dialog', - evt, params, options - ).then(function() { return final_resp }); - } else { - return $q.when(final_resp); - } + + // inform user if the item is on the local holds shelf + if (copy.status() == 8 // on holds shelf + && hold + && hold.pickup_lib() == egCore.auth.user().ws_ou()) { + return service.route_dialog( + './circ/share/t_hold_shelf_dialog', + evt, params, options + ).then(function() { return final_resp }); + + } else { + return $q.when(final_resp); } // show the route dialog case 'ROUTE_ITEM': return service.route_dialog( - './circ/share/t_hold_shelf_dialog', + './circ/share/t_transit_dialog', evt, params, options ).then(function() { return final_resp }); @@ -334,6 +340,61 @@ function($modal , $q , egCore) { } } + service.route_dialog = function(tmpl, evt, params, options) { + return $modal.open({ + templateUrl: tmpl, + controller: [ + '$scope', '$modalInstance', 'destAddr', 'holdUser', + function($scope, $modalInstance, destAddr, holdUser) { + $scope.destAddr = destAddr; + $scope.holdUser = holdUser; + $scope.dest = egCore.org.get(evt.org); + $scope.evt = evt; + $scope.now = new Date(); + $scope.ok = function() {$modalInstance.close()} + $scope.print = function() { + $modalInstance.close(); + + var transit = evt.payload.transit; + + // flesh data into the transit to match the print template + transit.target_copy(evt.payload.copy); + transit.dest(egCore.org.get(transit.dest())); + transit.dest().holds_address(destAddr); + + egCore.hatch.printFromTemplate('default', 'transit_slip', + { transit : egCore.idl.toHash(transit), + title : evt.payload.record.title(), + author : evt.payload.record.author(), + staff : egCore.idl.toHash(egCore.auth.user()), + current_location : egCore.idl.toHash( + egCore.org.get(egCore.auth.user().ws_ou())) + } + ); + + } + }], + resolve : { + destAddr : function() { + if (!evt.org) return $q.when(); + return service.get_org_addr(evt.org, 'holds_address'); + }, + holdUser : function() { + if (!evt.payload.hold) return $q.when(); + return egCore.pcrud.retrieve('au', + evt.payload.hold.usr(), { + flesh : 1, + flesh_fields : {'au' : ['card']} + } + ); + } + } + }).result; + } + + + return service; + }]); diff --git a/Open-ILS/web/js/ui/default/staff/services/hatch.js b/Open-ILS/web/js/ui/default/staff/services/hatch.js index e673b5be81..099aa0daa3 100644 --- a/Open-ILS/web/js/ui/default/staff/services/hatch.js +++ b/Open-ILS/web/js/ui/default/staff/services/hatch.js @@ -237,6 +237,8 @@ angular.module('egCoreMod') service.ingestPrintContent(contentType, content, {}) .then(function() { $window.print() }); } else { + // HTML content is already ingested and accessible + // within the page to the printer. $window.print(); } } -- 2.11.0