JBAS-2118 Lost payments auth for webstaff WIP
authorBill Erickson <berickxx@gmail.com>
Thu, 8 Nov 2018 16:37:30 +0000 (11:37 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/circ/patron/t_lost_payment_auth.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

diff --git a/Open-ILS/src/templates/staff/circ/patron/t_lost_payment_auth.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_lost_payment_auth.tt2
new file mode 100644 (file)
index 0000000..8036a16
--- /dev/null
@@ -0,0 +1,34 @@
+<form ng-submit="ok(args)" role="form">
+  <div class="modal-header">
+    <button type="button" class="close" ng-click="cancel()" 
+      aria-hidden="true">&times;</button>
+    <h4 class="modal-title">
+      [% l('Please enter your KCLS login credentials.') %]
+    </h4>
+  </div>
+  <div class="modal-body">
+    <div>
+      <i>(hint: your username is the first part of your KCLS email address)</i>
+    </div>
+    <div class="form-group row pad-vert">
+      <div class="col-md-4">
+        [% l('Username: ') %]
+      </div>
+      <div class="col-md-8">
+        <input type="text" class="form-control" ng-model="context.username"/>
+      </div>
+    </div>
+    <div class="form-group row pad-vert">
+      <div class="col-md-4">
+        [% l('Password: ') %]
+      </div>
+      <div class="col-md-8">
+        <input type="password" class="form-control" ng-model="context.password"/>
+      </div>
+    </div>
+  </div>
+  <div class="modal-footer">
+    <input type="submit" class="btn btn-primary" value="[% l('Submit') %]"/>
+    <button class="btn btn-warning" ng-click="cancel($event)">[% l('Cancel') %]</button>
+  </div>
+</form>
index ceda5c8..e62cd3e 100644 (file)
@@ -372,6 +372,53 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
         $scope.gridControls.refresh();
     }
 
+    // Returns a promise resolved to the list of payments altered as
+    // necessary to include lost payment authorization data, rejected
+    // if the payment is canceled.
+    function handleLostPayAuth(payments) {
+
+        var lostXacts = [];
+        payments.forEach(function(payment) {
+            var xactId = payment[0];
+            var gridItem = $scope.gridControls.allItems().filter(
+                function(item) {return item.id == xactId})[0];
+
+            var stopFines = gridItem['circulation.stop_fines'];
+            if (stopFines === 'LOST') {
+                console.debug("Processing lost payment transaction ", xactId);
+                lostXacts.push(xactId);
+            }
+        });
+
+        if (lostXacts.length === 0) {
+            return $q.when(payments);
+        }
+
+        return $uibModal.open({
+            templateUrl : './circ/patron/t_lost_payment_auth',
+            backdrop: 'static',
+            controller : [
+                        '$scope','$uibModalInstance',
+                function($scope , $uibModalInstance) {
+                    $scope.context = {
+                        username: '',
+                        password: ''
+                    };
+
+                    $scope.ok = function() {
+                        console.log($scope.context.username);
+                        console.log($scope.context.password);
+                        $uibModalInstance.close(payments);
+                    }
+
+                    $scope.cancel = function() {
+                        $uibModalInstance.dismiss();
+                    }
+                }
+            ]
+        }).result;
+    }
+
     // generates payments, collects user note if needed, and sends payment
     // to server.
     function sendPayment(note, cc_args) {
@@ -379,6 +426,12 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
         var make_payments = generatePayments();
         var patron_credit = $scope.convert_to_credit.isChecked ?
             $scope.pending_change() : 0; 
+
+        // KCLS prompt for lost payment authorization.
+        handleLostPayAuth(make_payments)
+        .then(function(make_payments) {
+        // NOTE: avoiding indentation to reduce variation with stock.
+
         billSvc.applyPayment($scope.payment_type, 
             make_payments, note, $scope.check_number, cc_args, patron_credit)
         .then(
@@ -395,6 +448,7 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
                 console.error('Payment was rejected: ' + msg);
             }
         )
+        })
         .finally(function() { $scope.applyingPayment = false; })
     }