blind first cut of angular bits
authorMike Rylander <miker@esilibrary.com>
Wed, 3 Aug 2016 20:51:54 +0000 (16:51 -0400)
committerMike Rylander <miker@esilibrary.com>
Wed, 3 Aug 2016 20:51:54 +0000 (16:51 -0400)
Signed-off-by: Mike Rylander <miker@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/services/user.js

index 29974aa..2b891b0 100644 (file)
     </label>
   </div>
   <div class="pad-horiz">
-    <button class="btn btn-default" 
-      ng-click="print_receipt()">[% l('Print Receipt') %]</button>
+    <span ng-show="email_receipt()" class="glyphicon glyphicon-envelope" aria-label="[% l('Send Email Receipt') %]"></span>
+    <div class="btn-group" uib-dropdown>
+      <button ng-click="print_or_email_receipt()" id="quick-button" type="button" class="btn btn-danger">[% l('Quick Receipt') %]</button>
+      <button ng-show="email_receipt()" type="button" class="btn btn-danger" uib-dropdown-toggle>
+        <span class="caret"></span>
+        <span class="sr-only">[% l('print option') %]</span>
+      </button>
+      <ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="quick-button">
+        <li role="menuitem"><a ng-click="print_receipt()" href="#">[% l('Print Receipt') %]</a></li>
+      </ul>
+    </div>
   </div>
   <div>
     <button class="btn btn-default" 
index 3d6e9c6..d336d70 100644 (file)
@@ -34,6 +34,14 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         );
     }
 
+    $scope.email_receipt = function() {
+        return  (
+            patronSvc.current &&
+            patronSvc.current.settings()['circ.send_email_checkout_receipts'] &&
+            patronSvc.current.settings()['circ.send_email_checkout_receipts'] == 'true'
+        );
+    }
+
     $scope.using_hatch = egCore.hatch.usingHatch();
 
     egCore.hatch.getItem('circ.checkout.strict_barcode')
@@ -191,18 +199,38 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         });
     }
 
+    $scope.send_email_receipt = function () {
+        if ($scope.email_receipt() && $scope.checkouts.length) {
+            return egCore.net.request(
+                'open-ils.circ',
+                'open-ils.circ.checkout.batch_notify.session.atomic',
+                egCore.auth.token(),
+                patronSvc.current.id(),
+                $scope.checkouts.map(function (c) { return c.circ.id() })
+            ); // fire and forget?
+        }
+        return $q.when();
+    }
+
+    $scope.print_or_email_receipt = function () {
+        if ($scope.email_receipt()) return $scope.send_email_receipt;
+        $scope.print_receipt();
+    }
+
     // Redirect the user to the barcode entry page to load a new patron.
     // If configured to do so, print the receipt first
     $scope.done = function() {
-        if (printOnComplete) {
+        $scope.send_email_receipt().then( function () {
+            if (printOnComplete) {
 
-            $scope.print_receipt().then(function() {
-                $location.path('/circ/patron/bcsearch');
-            });
+                $scope.print_receipt().then(function() {
+                    $location.path('/circ/patron/bcsearch');
+                });
 
-        } else {
-            $location.path('/circ/patron/bcsearch');
-        }
+            } else {
+                $location.path('/circ/patron/bcsearch');
+            }
+        });
     }
 }])
 
index f2a70c1..9fd32a8 100644 (file)
@@ -11,6 +11,7 @@ function($q,  $timeout,  egNet,  egAuth,  egOrg) {
     var service = {
         defaultFleshFields : [
             'card',                                                                
+            'settings',
             'standing_penalties',                                                  
             'addresses',                                                           
             'billing_address',