--- /dev/null
+<!-- edit bucket dialog -->
+<form ng-submit="ok(billArgs)" role="form" class="form-horizontal">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close"
+ ng-click="cancel()" aria-hidden="true">×</button>
+ <h4 class="modal-title">
+ [% l('Bill Patron: [_1], [_2] [_3] : [_4]',
+ '{{patron.family_name()}}',
+ '{{patron.first_given_name()}}',
+ '{{patron.second_given_name()}}',
+ '{{patron.card().barcode()}}') %]
+ </h4>
+ </div>
+ <div class="modal-body">
+ <div class="form-group">
+ <label for="bill-dialog-location" class="control-label col-md-4">
+ [% l('Location:') %]
+ </label>
+ <div class="col-md-8">
+ <p class="form-control-static">{{location.shortname()}}</p>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label for="bill-dialog-type" class="control-label col-md-4">
+ [% l('Billing Type:') %]
+ </label>
+ <div class="col-md-8">
+ <select ng-model="billArgs.billingType" class="form-control">
+ <option ng-repeat="type in billingTypes" value="{{type.id()}}">
+ {{type.name()}}
+ </option>
+ </select>
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="bill-dialog-amount" class="control-label col-md-4">[% l('Amount:') %]</label>
+ <div class="col-md-8">
+ <input type="number" min="0" step="any" class="form-control"
+ focus-me='focus' required id="bill-dialog-amount"
+ ng-model="billArgs.amount"/>
+ </div>
+ </div>
+ <div class="form-group">
+ <label for="bill-dialog-note" class="control-label col-md-4">[% l('Note:') %]</label>
+ <div class="col-md-8">
+ <textarea rows="3" class="form-control" placeholder="[% l('Note...') %]"
+ id="bill-dialog-note" ng-model="billArgs.note"></textarea>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <input type="submit" class="btn btn-success" value="[% l('Submit Bill') %]"/>
+ <button class="btn btn-warning" ng-click="cancel($event)">[% l('Cancel') %]</button>
+ </div>
+ </div>
+</form>
+
+
});
}
+ 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;
}])
* 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;
$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});
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.
// 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});
});
}
+ // builds payment arrays ([xact_id, ammount]) for all transactions
+ // which have a pending payment amount.
function generatePayments() {
var payments = [];
var paymentAmount = $scope.pending_payment();
return payments;
}
+ // generates payments, collects user note if needed, and sends payment
+ // to server.
function sendPayment(note) {
billSvc.applyPayment(
$scope.payment_type, generatePayments(), note)
})
}
- $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() {