add Print Bills to Bill History
authorJason Etheridge <jason@esilibrary.com>
Thu, 17 Nov 2016 20:38:17 +0000 (15:38 -0500)
committerKathy Lussier <klussier@masslnc.org>
Tue, 22 Nov 2016 19:10:05 +0000 (14:10 -0500)
FIXME: duplicated a code chunk, should probably refactor into a shared printBills
FIXME: disable actions or make otherwise obvious that they only work on selected rows

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>

Open-ILS/src/templates/staff/circ/patron/t_bill_history_xacts.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index 70f48b6..accbd36 100644 (file)
@@ -10,6 +10,8 @@
       label="[% l('Add Billing') %]" handler="addBilling"></eg-grid-action>
     <eg-grid-action 
       label="[% l('Full Details') %]" handler="showFullDetails"></eg-grid-action>
+    <eg-grid-action
+      label="[% l('Print Bills') %]" handler="printBills"></eg-grid-action>
 
     <eg-grid-field path="summary.balance_owed"></eg-grid-field>
     <eg-grid-field path="id" label="[% l('Bill #') %]"></eg-grid-field>
index 8d2801d..37c2a18 100644 (file)
@@ -775,6 +775,39 @@ function($scope,  $q , egCore , patronSvc , billSvc , egPromptDialog , $location
             })
         }
     }
+
+    $scope.printBills = function(selected) { // FIXME: refactor me
+        if (!selected.length) return;
+        // bills print receipt assumes nested hashes, but our grid
+        // stores flattener data.  Fetch the selected xacts as
+        // fleshed pcrud objects and hashify.  
+        // (Consider an alternate approach..)
+        var ids = selected.map(function(t){ return t.id });
+        var xacts = [];
+        egCore.pcrud.search('mbt', 
+            {id : ids},
+            {flesh : 1, flesh_fields : {'mbt' : ['summary']}},
+            {authoritative : true}
+        ).then(
+            function() {
+                egCore.print.print({
+                    context : 'receipt', 
+                    template : 'bills_historical', 
+                    scope : {   
+                        transactions : xacts,
+                        current_location : egCore.idl.toHash(
+                            egCore.org.get(egCore.auth.user().ws_ou()))
+                    }
+                });
+            }, 
+            null, 
+            function(xact) {
+                xacts.push(egCore.idl.toHash(xact));
+            }
+        );
+    }
+
+
 }])
 
 .controller('BillPaymentHistoryCtrl',