webstaff: add printing to transit list page
authorGalen Charlton <gmc@esilibrary.com>
Tue, 29 Nov 2016 21:34:14 +0000 (16:34 -0500)
committerKathy Lussier <klussier@masslnc.org>
Mon, 9 Jan 2017 15:58:59 +0000 (10:58 -0500)
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 <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2
Open-ILS/src/templates/staff/circ/transits/t_list.tt2
Open-ILS/src/templates/staff/share/print_templates/t_transit_list.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js
Open-ILS/web/js/ui/default/staff/circ/transits/list.js

index 48a7249..4beafb6 100644 (file)
@@ -30,6 +30,7 @@
           <option value="patron_address">[% l('Patron Address') %]</option>
           <option value="patron_note">[% l('Patron Note') %]</option>
           <option value="renew">[% l('Renew') %]</option>
+          <option value="transit_list">[% l('Transit List') %]</option>
           <option value="transit_slip">[% l('Transit Slip') %]</option>
         </select>
         <label for="print_context">[% l('Force Printer Context') %]</label>
index 6d598f0..8654c31 100644 (file)
@@ -40,6 +40,8 @@
 
   <eg-grid-menu-item handler="abort_transit" 
     label="[% l('Abort Transit') %]"></eg-grid-menu-item>
+  <eg-grid-menu-item handler="print_full_list"
+    label="[% l('Print Transits') %]"></eg-grid-menu-item>
 
   <eg-grid-field path='id' hidden required></eg-grid-field>
   <eg-grid-field path='target_copy.id' hidden required></eg-grid-field>
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 (file)
index 0000000..09e8333
--- /dev/null
@@ -0,0 +1,30 @@
+<!--
+Template for printing transits. Data specific to this template
+includes:
+
+transits - list; each entry contains:
+
+  * copy_status
+  * dest (library, keys include shortname)
+  * source_send_time
+  * id
+  * source (library, keys include shortname)
+  * target_copy (copy, keys include barcode)
+  * target_copy.call_number.record.simple_record.title
+-->
+<div>
+  <div>[% l('Transits:') %]</div>
+  <hr/>
+  <ol>
+    <li ng-repeat="transit in transits">
+      <div>[% l('From: [_1] To: [_2] <br> When: [_3] <br> 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}}') %]</div>
+    </li>
+  </ol>
+  <hr/>
+  <div>{{current_location.shortname}} {{today | date:'short'}}</div>
+<br/>
index da2b348..0ebc960 100644 (file)
@@ -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,
index 5e6550a..4ae321f 100644 (file)
@@ -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
+            });
+        });
+
+    }
 }])