LP#1759343 Fix annotate payment setting name
[evergreen-equinox.git] / Open-ILS / web / js / ui / default / staff / circ / patron / bills.js
index a84ab2c..308fb30 100644 (file)
@@ -76,6 +76,10 @@ function($q , egCore , egWorkLog , patronSvc) {
             // payment API returns the update xact id so we can track it
             // for future payments without having to refresh the user.
             patronSvc.current.last_xact_id(resp.last_xact_id);
+
+            // reload patron data if credit balance has changed:
+            if(type === 'credit_payment' || patron_credit){ patronSvc.refreshPrimary(); }
+
             return resp.payments;
         });
     }
@@ -190,12 +194,17 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
     $scope.amount_verified = false;
     $scope.disable_auto_print = false;
 
-    // check receipt_on_pay setting default persisted
+    // Load persistant settings
     egCore.hatch.getItem('circ.bills.receiptonpay')
                 .then(function(rcptOnPay){
                     if (rcptOnPay) $scope.receipt_on_pay.isChecked = rcptOnPay;
                 });
 
+    egCore.hatch.getItem('eg.circ.bills.annotatepayment')
+                .then(function(annoPay){
+                    if (annoPay) $scope.annotate_payment = annoPay;
+                });
+
     // pre-define list-returning funcs in case we access them
     // before the grid instantiates
     $scope.gridControls = {
@@ -222,15 +231,14 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
     // -------------
     // Apply coloring to rows based on fines stop reason
     $scope.colorizeBillsList = {
-        rowClass: function(item) {
-            if (!item['circulation.checkin_time']) {
+        apply: function(item) {
+            if (item['circulation.due_date'] && !item['circulation.checkin_time']) {
                 if (item['circulation.stop_fines'] == 'LOST') {
-                    return 'dark-red-row-highlight';
+                    return 'lost-row';
                 } else if (item['circulation.stop_fines'] == 'LONGOVERDUE') {
-                    return 'red-row-highlight';
-                } else if (item['circulation.due_date'] &&  // Still checked out - need feedback on this approach, feel like there's a better way
-                          !item['circulation.stop_fines']) {
-                    return 'orange-row-highlight';
+                    return 'longoverdue-row';
+                } else {
+                    return 'overdue-row';
                 }
             }
         }
@@ -240,29 +248,17 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
     $scope.statusIconColumn = {
         isEnabled: true,
         template: function(item) {
-            var template = "";
-            var icons = [];
-            var now = new Date();
-
-            if (item['circulation.due_date'] &&
-                !item['circulation.checkin_time']) {
-                var due_date = new Date(item['circulation.due_date']);
-
-                if (item['circulation.stop_fines'] &&
-                    item['circulation.stop_fines'] == "LOST") {
-                    icons.push('glyphicon-question-sign');
-                } else if (item['circulation.stop_fines'] &&
-                    item['circulation.stop_fines'] == "LONGOVERDUE") {
-                    icons.push('glyphicon-exclamation-sign');
-                } else if (now >= due_date) {
-                    icons.push('glyphicon-time');
+            var icon = '';
+            if (item['circulation.due_date'] && !item['circulation.checkin_time']) {
+                if (item['circulation.stop_fines'] == "LOST") {
+                    icon = 'glyphicon-question-sign';
+                } else if (item['circulation.stop_fines'] == "LONGOVERDUE") {
+                    icon = 'glyphicon-exclamation-sign';
+                } else {
+                    icon = 'glyphicon-time';
                 }
             }
-
-            angular.forEach(icons, function(icon) {
-                template = template + "<i class='glyphicon " + icon + "'></i>"
-            });
-            return template;
+            return "<i class='glyphicon " + icon + "'></i>"
         }
     }
 
@@ -415,6 +411,10 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
         egCore.hatch.setItem('circ.bills.receiptonpay', $scope.receipt_on_pay.isChecked);
     }
 
+    $scope.onAnnotatePaymentChanged = function(){
+        egCore.hatch.setItem('eg.circ.bills.annotatepayment', $scope.annotate_payment);
+    }
+
     function printReceipt(type, payment_ids, payments_made, note) {
         var payment_blobs = [];
         var cusr = patronSvc.current;
@@ -455,10 +455,15 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
             second_given_name : cusr.second_given_name(),
             family_name : cusr.family_name(),
             suffix : cusr.suffix(),
+            pref_prefix : cusr.pref_prefix(),
+            pref_first_given_name : cusr.pref_first_given_name(),
+            pref_second_given_name : cusr.pref_second_given_name(),
+            pref_family_name : cusr.pref_family_name(),
+            pref_suffix : cusr.pref_suffix(),
             card : { barcode : cusr.card().barcode() },
             expire_date : cusr.expire_date(),
             alias : cusr.alias(),
-            has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/).length),
+            has_email : Boolean(patronSvc.current.email() && patronSvc.current.email().match(/.*@.*/)),
             has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
         };
 
@@ -587,10 +592,15 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
                             second_given_name : cusr.second_given_name(),
                             family_name : cusr.family_name(),
                             suffix : cusr.suffix(),
+                            pref_prefix : cusr.pref_prefix(),
+                            pref_first_given_name : cusr.pref_first_given_name(),
+                            pref_second_given_name : cusr.pref_second_given_name(),
+                            pref_family_name : cusr.pref_family_name(),
+                            pref_suffix : cusr.pref_suffix(),
                             card : { barcode : cusr.card().barcode() },
                             expire_date : cusr.expire_date(),
                             alias : cusr.alias(),
-                            has_email : Boolean(cusr.email() && cusr.email().match(/.*@.*/).length),
+                            has_email : Boolean(cusr.email() && cusr.email().match(/.*@.*/)),
                             has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
                         }
                     }
@@ -1077,6 +1087,11 @@ function($scope,  $q , egCore , patronSvc , billSvc , egPromptDialog , $location
                             egCore.org.get(egCore.auth.user().ws_ou())),
                         patron : {
                             prefix : cusr.prefix(),
+                            pref_prefix : cusr.pref_prefix(),
+                            pref_first_given_name : cusr.pref_first_given_name(),
+                            pref_second_given_name : cusr.pref_second_given_name(),
+                            pref_family_name : cusr.pref_family_name(),
+                            pref_suffix : cusr.pref_suffix(),
                             first_given_name : cusr.first_given_name(),
                             second_given_name : cusr.second_given_name(),
                             family_name : cusr.family_name(),
@@ -1084,7 +1099,7 @@ function($scope,  $q , egCore , patronSvc , billSvc , egPromptDialog , $location
                             card : { barcode : cusr.card().barcode() },
                             expire_date : cusr.expire_date(),
                             alias : cusr.alias(),
-                            has_email : Boolean(cusr.email() && cusr.email().match(/.*@.*/).length),
+                            has_email : Boolean(cusr.email() && cusr.email().match(/.*@.*/)),
                             has_phone : Boolean(cusr.day_phone() || cusr.evening_phone() || cusr.other_phone())
                         }
                     }