From 344bab6b615c11dcb8d6b165267f52a3ce6d3b4e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 20 May 2014 12:47:10 -0400 Subject: [PATCH] initial bills UI Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/circ/patron/index.tt2 | 1 + .../src/templates/staff/circ/patron/t_bills.tt2 | 75 +++++++++++++++++++++- .../templates/staff/circ/patron/t_bills_list.tt2 | 21 ++++++ .../staff/circ/patron/t_search_results.tt2 | 1 + Open-ILS/src/templates/staff/css/style.css.tt2 | 25 ++++++++ Open-ILS/src/templates/staff/share/t_autogrid.tt2 | 2 +- .../web/js/ui/default/staff/circ/patron/app.js | 20 ++---- .../web/js/ui/default/staff/circ/patron/bills.js | 57 ++++++++++++++++ Open-ILS/web/js/ui/default/staff/services/grid.js | 49 +++++++++----- 9 files changed, 215 insertions(+), 36 deletions(-) create mode 100644 Open-ILS/src/templates/staff/circ/patron/t_bills_list.tt2 create mode 100644 Open-ILS/web/js/ui/default/staff/circ/patron/bills.js diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2 index ee09fa1274..c17bce0a91 100644 --- a/Open-ILS/src/templates/staff/circ/patron/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2 @@ -19,6 +19,7 @@ + diff --git a/Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 index d4e10aeed2..bc4750f195 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_bills.tt2 @@ -1,6 +1,75 @@ -
-
-
[% l('BILLS Development Pending') %]
+ +
+
+ +
+
+
+ [% l('Total Owed: [_1]', '{{summary.balance_owed() | currency}}') %] +
+
+
+ +
+ [% l('Refunds Available: [_1]', '{{0 | currency}}') %] +
+
+
+
+
+
+ [% l('Total Selected: [_1]', '{{total_selected | currency}}') %] +
+
+
+ +
+ [% l('Credit Available: [_1]', '{{patron().credit_forward_balance() | currency}}') %] +
+
+
+
+ +
+
+
+ [% l('Pay Bill') %] + +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + +
+
+ +
+
+ +
+ + +
+[% INCLUDE 'staff/circ/patron/t_bills_list.tt2' %]
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 new file mode 100644 index 0000000000..192585cfa7 --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/patron/t_bills_list.tt2 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + diff --git a/Open-ILS/src/templates/staff/circ/patron/t_search_results.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_search_results.tt2 index 1b2f2131b0..84e879244c 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_search_results.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_search_results.tt2 @@ -4,6 +4,7 @@ main-label="[% l('Patron Search Results') %]" items-provider="patronSearchGridProvider" activate-item="activatePatron" + on-item-selected="gridItemSelected" persist-key="circ.patron.search"> diff --git a/Open-ILS/src/templates/staff/css/style.css.tt2 b/Open-ILS/src/templates/staff/css/style.css.tt2 index 3fd7cc692c..0a4f7946f7 100644 --- a/Open-ILS/src/templates/staff/css/style.css.tt2 +++ b/Open-ILS/src/templates/staff/css/style.css.tt2 @@ -133,6 +133,31 @@ table.list tr.selected td { margin-left: 10px; } + +.strong-text { + font-weight: bold; +} +.strong-text-1 { + font-size: 110%; + font-weight: bold; +} +.strong-text-2 { + font-size: 120%; + font-weight: bold; +} +.strong-text-3 { + font-size: 130%; + font-weight: bold; +} +.strong-text-4 { + font-size: 140%; + font-weight: bold; +} + +.currency-input { + width: 8em; +} + /* ---------------------------------------------------------------------- * Grid * ---------------------------------------------------------------------- */ diff --git a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 index b48d61dcf1..7960624176 100644 --- a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 @@ -271,7 +271,7 @@ - {{itemFieldValue(item, col)}} + {{itemFieldValue(item, col) | egGridValueFilter:col}}
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index f40b1893c8..75a4874f59 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -465,12 +465,10 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, return {offset : 0}; } - // show the user summary for the first selected user - provider.select = function(items) { - if (items[0]) { - var user = items[0]; - patronSvc.setDefault(null, user); - } + // FIXME: use onItemSelect instead + $scope.gridItemSelected = function(item) { + if (item) // null if de-selecting + patronSvc.setDefault(null, item); } provider.get = function(offset, count) { @@ -670,16 +668,6 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, }]) /** - * Manages edit - */ -.controller('PatronBillsCtrl', - ['$scope','$routeParams','egCore', -function($scope, $routeParams, egCore) { - $scope.initTab('bills', $routeParams.id); -}]) - - -/** * Manages messages */ .controller('PatronMessagesCtrl', 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 new file mode 100644 index 0000000000..fd55a6de69 --- /dev/null +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js @@ -0,0 +1,57 @@ + +/* Billing Service */ + +angular.module('egPatronApp') + +.factory('billSvc', + ['$q','egCore', +function($q , egCore) { + + var service = {}; + + // user billing summary + service.fetchSummary = function() { + return egCore.pcrud.retrieve( + 'mous', service.userId, {}, {authoritative : true}) + .then(function(summary) {return service.summary = summary}) + } + + return service; +}]) + + +/** + * Manages Bills + */ +.controller('PatronBillsCtrl', + ['$scope','$q','$routeParams','egCore','egGridDataProvider','billSvc', +function($scope, $q , $routeParams, egCore , egGridDataProvider , billSvc) { + $scope.initTab('bills', $routeParams.id); + billSvc.userId = $routeParams.id; + + $scope.total_selected = 0; + $scope.payment_type = 'cash'; + $scope.focus_payment = true; + $scope.annotate_payment = false; + + + var query = {usr : billSvc.userId, balance_owed : {'<>' : 0}}; + $scope.gridQuery = function() {return query}; + $scope.gridItemRetrieved = function(item) { + item.payment_pending = 0; + } + + $scope.gridItemSelected = function(selected, deSelected) { + if (selected) { + $scope.total_selected += Number(selected.balance_owed); + } else { + $scope.total_selected += Number(deSelected.balance_owed); + } + } + + billSvc.fetchSummary().then(function(s) {$scope.summary = s}); + +}]) + + + diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index 0ca633be80..1d9baea1c3 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -67,6 +67,9 @@ angular.module('egGridMod', // are absorbed by the grid. onItemRetrieved : '=', + // function called with (selectedItem, deSelectedItem, allSelectedItems) + onItemSelected : '=', + // function; if set, row index values will be hyperlinked and // the onclick for an item will call activateItem with the item // as the argument. @@ -119,7 +122,7 @@ angular.module('egGridMod', // items needed only by the grid; remove from scope angular.forEach( - ['idlClass', 'onItemRetrieved','persistKey'], + ['idlClass','onItemRetrieved','onItemSelected','persistKey'], function(field) { grid[field] = $scope[field]; delete $scope[field]; @@ -152,8 +155,10 @@ angular.module('egGridMod', grid.columnsProvider.hideAllColumns(); } - if ($scope.autoFields) { + if (!grid.indexField && grid.idlClass) grid.indexField = egCore.idl.classes[grid.idlClass].pkey; + + if ($scope.autoFields) { if (grid.autoLabel) $scope.mainLabel = egCore.idl.classes[grid.idlClass].label; grid.columnsProvider.compileAutoColumns(); @@ -169,6 +174,12 @@ angular.module('egGridMod', query : $scope.query }); + if (!grid.dataProvider.query) { + console.error( + "Grid query is required when no data provider is supplied"); + return; + } + $scope.$watch( function() { return grid.dataProvider.query() }, function(newVal, oldVal) { @@ -214,6 +225,7 @@ angular.module('egGridMod', // link columns to scope after loadConfig(), since it // replaces the columns array. $scope.columns = grid.columnsProvider.columns; + //if (grid.selfManagedData) grid.collect(); }); } @@ -415,17 +427,6 @@ angular.module('egGridMod', } } - grid.informSelection = function() { - var items = []; - angular.forEach(Object.keys($scope.selected), - function(index) { - items.push($scope.items[grid.indexOf(index)]); - } - ); - grid.dataProvider.select(items); - } - - // returns true if item1 appears in the list before item2; // false otherwise. this is slightly more efficient that // finding the position of each then comparing them. @@ -508,7 +509,14 @@ angular.module('egGridMod', grid.lastSelectedItemIndex = index; } - grid.informSelection(); + var selected = grid.getSelectedItems(); + if (grid.onItemSelected) { + if ($scope.selected[index]) { + grid.onItemSelected(item, null, selected); + } else { + grid.onItemSelected(null, item, selected); + } + } } // Builds a sort expression from column sort priorities. @@ -734,7 +742,12 @@ angular.module('egGridMod', scope[field] = true; } ); - scope.template = element.html(); + + // any HTML content within the field is its custom template + var tmpl = element.html(); + if (tmpl && !tmpl.match(/^\s*$/)) + scope.template = tmpl + egGridCtrl.columnsProvider.add(scope); scope.$destroy(); } @@ -1056,6 +1069,7 @@ angular.module('egGridMod', return $q.when(); var query = provider.query(); + console.log(JSON.stringify(query)); if (!query || angular.equals(query, {})) return $q.when(); @@ -1063,7 +1077,8 @@ angular.module('egGridMod', var queryFields = {} angular.forEach(provider.columnsProvider.columns, function(col) { - if (col.required || col.visible) + // only query IDL-tracked columns + if (col.datatype && (col.required || col.visible)) queryFields[col.name] = col.path; } ); @@ -1242,6 +1257,8 @@ angular.module('egGridMod', case 'timestamp': // canned angular date filter FTW return $filter('date')(value, 'shortDate'); + case 'money': + return $filter('currency')(value); default: return value; } -- 2.11.0