From 90f60d70bbefde0c6f53bcc819e238c91d981875 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 29 Nov 2016 16:34:14 -0500 Subject: [PATCH] webstaff: add printing to transit list page Adds a 'Print Transits' button and a transit_list print template. Using the button prints _all_ transits that match the filter criteria, not just the ones that happen to be displayed on the table. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../admin/workstation/t_print_templates.tt2 | 1 + .../templates/staff/circ/transits/t_list.tt2 | 2 + .../share/print_templates/t_transit_list.tt2 | 30 +++++++++++++ .../ui/default/staff/admin/workstation/app.js | 31 ++++++++++---- .../js/ui/default/staff/circ/transits/list.js | 42 +++++++++++++++++++ 5 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 Open-ILS/src/templates/staff/share/print_templates/t_transit_list.tt2 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 48a7249936..4beafb68f2 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 @@ -30,6 +30,7 @@ + diff --git a/Open-ILS/src/templates/staff/circ/transits/t_list.tt2 b/Open-ILS/src/templates/staff/circ/transits/t_list.tt2 index 6d598f08f3..8654c31187 100644 --- a/Open-ILS/src/templates/staff/circ/transits/t_list.tt2 +++ b/Open-ILS/src/templates/staff/circ/transits/t_list.tt2 @@ -40,6 +40,8 @@ + diff --git a/Open-ILS/src/templates/staff/share/print_templates/t_transit_list.tt2 b/Open-ILS/src/templates/staff/share/print_templates/t_transit_list.tt2 new file mode 100644 index 0000000000..09e8333553 --- /dev/null +++ b/Open-ILS/src/templates/staff/share/print_templates/t_transit_list.tt2 @@ -0,0 +1,30 @@ + +
+
[% l('Transits:') %]
+
+
    +
  1. +
    [% l('From: [_1] To: [_2]
    When: [_3]
    Barcode: [_4] Title: [_5]', + '{{transit.source.shortname}}', + '{{transit.dest.shortname}}', + "{{transit.source_send_time | date:'short'}}", + '{{transit.target_copy.barcode}}', + '{{transit.target_copy.call_number.record.simple_record.title}}') %]
    +
  2. +
+
+
{{current_location.shortname}} {{today | date:'short'}}
+
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 da2b348653..0ebc960ad0 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 @@ -403,7 +403,12 @@ function($scope , $q , egCore , ngToast) { var seed_copy = { barcode : '33434322323', call_number : { - label : '636.8 JON' + label : '636.8 JON', + record : { + simple_record : { + 'title' : 'Test Title' + } + } }, location : { name : 'General Collection' @@ -419,6 +424,20 @@ function($scope , $q , egCore , ngToast) { hold_type : 'T' } + var seed_transit = { + source : { + name : 'Library Y', + shortname : 'LY', + holds_address : seed_addr + }, + dest : { + name : 'Library X', + shortname : 'LX', + holds_address : seed_addr + }, + source_send_time : new Date().toISOString(), + target_copy : seed_copy + } $scope.preview_scope = { //bills @@ -496,14 +515,8 @@ function($scope , $q , egCore , ngToast) { value : 'This patron is super nice!' }, - transit : { - dest : { - name : 'Library X', - shortname : 'LX', - holds_address : seed_addr - }, - target_copy : seed_copy - }, + transit : seed_transit, + transits : [ seed_transit ], title : seed_record.title, author : seed_record.author, patron : seed_user, diff --git a/Open-ILS/web/js/ui/default/staff/circ/transits/list.js b/Open-ILS/web/js/ui/default/staff/circ/transits/list.js index 5e6550ab35..4ae321fbf2 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/transits/list.js +++ b/Open-ILS/web/js/ui/default/staff/circ/transits/list.js @@ -242,5 +242,47 @@ function($scope , $q , $routeParams , $window , egCore , egTransits , egGridData $scope.$watch('dates.end_date', function(newVal, oldVal) { if (newVal && newVal != oldVal) refresh_page(); }); + + function fetch_all_matching_transits(transits) { + var deferred = $q.defer(); + var filter = current_query(); + egCore.pcrud.search('atc', + filter, { + 'flesh' : 5, + // atc -> target_copy -> call_number -> record -> simple_record + // atc -> hold_transit_copy -> hold -> usr -> card + 'flesh_fields' : { + 'atc' : ['target_copy','dest','source','hold_transit_copy'], + 'acp' : ['call_number','location','circ_lib'], + 'acn' : ['record'], + 'bre' : ['simple_record'], + 'ahtc' : ['hold'], + 'ahr' : ['usr'], + 'au' : ['card'] + }, + 'select' : { 'bre' : ['id'] }, + order_by : { atc : 'source_send_time' }, + } + ).then( + deferred.resolve, null, + function(transit) { + transits.push(egCore.idl.toHash(transit)); + } + ); + return deferred.promise; + } + + $scope.print_full_list = function() { + var print_data = { transits : [] }; + + return fetch_all_matching_transits(print_data.transits).then(function() { + if (print_data.transits.length == 0) return $q.when(); + return egCore.print.print({ + template : 'transit_list', + scope : print_data + }); + }); + + } }]) -- 2.43.2