From: Bill Erickson Date: Wed, 21 May 2014 21:17:06 +0000 (-0400) Subject: bill patron dialog; starting X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=abe40f735f551501b95545a6c749acf382522c91;p=working%2FEvergreen.git bill patron dialog; starting Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/staff/circ/patron/t_bill_patron_dialog.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_bill_patron_dialog.tt2 new file mode 100644 index 0000000000..ab1cd05dce --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/patron/t_bill_patron_dialog.tt2 @@ -0,0 +1,60 @@ + +
+ +
+ + diff --git a/Open-ILS/src/templates/staff/circ/patron/t_bills_list.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_bills_list.tt2 index 68307dd5ca..89d6252646 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_bills_list.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_bills_list.tt2 @@ -8,7 +8,7 @@ persist-key="circ.patron.bills"> + handler="showBillDialog"> diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js b/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js index 6e44de7965..8fabfa85df 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js @@ -39,6 +39,23 @@ function($q , egCore , patronSvc) { }); } + service.fetchBillingTypes = function() { + if (egCore.env.cbt) + return $q.when(egCore.env.cbt.list); + + return egCore.pcrud.search('cbt', + { // first 100 are reserved for system-generated bills + id : {'>' : 100}, + owner : egCore.org.ancestors( + egCore.auth.user().ws_ou(), true) + }, + {}, {atomic : true} + ).then(function(list) { + egCore.env.absorbList(list, 'cbt'); + return list; + }); + } + return service; }]) @@ -47,8 +64,9 @@ function($q , egCore , patronSvc) { * Manages Bills */ .controller('PatronBillsCtrl', - ['$scope','$q','$routeParams','$locale','egCore','egGridDataProvider','billSvc','egPromptDialog', -function($scope, $q , $routeParams, $locale , egCore , egGridDataProvider , billSvc , egPromptDialog) { + ['$scope','$q','$routeParams','$locale','egCore','egGridDataProvider','billSvc','patronSvc','egPromptDialog','$modal', +function($scope, $q , $routeParams, $locale , egCore , egGridDataProvider , billSvc , patronSvc , egPromptDialog , $modal) { + $scope.initTab('bills', $routeParams.id); billSvc.userId = $routeParams.id; @@ -58,6 +76,8 @@ function($scope, $q , $routeParams, $locale , egCore , egGridDataProvider , bi $scope.focus_payment = true; $scope.annotate_payment = false; $scope.gridRevision = 0; + var allItems = []; // all grid items (flattened mobts) + var selectedItems = []; // selected grid items billSvc.fetchSummary().then(function(s) {$scope.summary = s}); @@ -112,13 +132,11 @@ function($scope, $q , $routeParams, $locale , egCore , egGridDataProvider , bi var query = {usr : billSvc.userId, balance_owed : {'<>' : 0}}; $scope.gridQuery = function() {return query}; - var allItems = []; $scope.gridItemRetrieved = function(item) { item.payment_pending = 0; allItems.push(item); } - var selectedItems = []; $scope.gridSelectionChanged = function(all) { // update the item.payment_pending value each time the user // selects different transactions to pay against. @@ -130,6 +148,10 @@ function($scope, $q , $routeParams, $locale , egCore , egGridDataProvider , bi // transaction any time the user-entered payment amount is modified $scope.$watch('payment_amount', updatePendingColumn); + // updates the value of the payment_pending column in the grid. + // This has to be managed manually since the display value in the grid + // is derived from the value on the stored item and not the contents + // of our local scope variables. function updatePendingColumn() { // reset all to zero.. angular.forEach(allItems, function(item) {item.payment_pending = 0}); @@ -144,6 +166,8 @@ function($scope, $q , $routeParams, $locale , egCore , egGridDataProvider , bi }); } + // builds payment arrays ([xact_id, ammount]) for all transactions + // which have a pending payment amount. function generatePayments() { var payments = []; var paymentAmount = $scope.pending_payment(); @@ -170,6 +194,8 @@ function($scope, $q , $routeParams, $locale , egCore , egGridDataProvider , bi return payments; } + // generates payments, collects user note if needed, and sends payment + // to server. function sendPayment(note) { billSvc.applyPayment( $scope.payment_type, generatePayments(), note) @@ -180,8 +206,34 @@ function($scope, $q , $routeParams, $locale , egCore , egGridDataProvider , bi }) } - $scope.billPatron = function() { - // launch billing dialog + $scope.showBillDialog = function() { + $modal.open({ + templateUrl: './circ/patron/t_bill_patron_dialog', + controller: + ['$scope','$modalInstance','billingTypes', + function($scope , $modalInstance , billingTypes) { + $scope.focus = true; + $scope.patron = patronSvc.current; + $scope.billingTypes = billingTypes; + $scope.location = egCore.org.get(egCore.auth.user().ws_ou()), + $scope.billArgs = { + billingType : 101 // default to stock Misc. billing type + } + $scope.ok = function(args) { $modalInstance.close(args) } + $scope.cancel = function () { $modalInstance.dismiss() } + }], + resolve : { + // if we don't already have them, fetch the billing types + billingTypes : function() { + return billSvc.fetchBillingTypes(); + } + } + }).result.then( + function(args) { + console.log('BILL: ' + JSON.stringify(args)); + //billSvc.billPatron(args); + } + ); } $scope.showHistory = function() {