open circ exists handler for checkout
authorBill Erickson <berick@esilibrary.com>
Fri, 9 May 2014 20:39:48 +0000 (16:39 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 9 May 2014 20:39:48 +0000 (16:39 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_circ_exists_dialog.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js

diff --git a/Open-ILS/src/templates/staff/circ/patron/t_circ_exists_dialog.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_circ_exists_dialog.tt2
new file mode 100644 (file)
index 0000000..b687325
--- /dev/null
@@ -0,0 +1,23 @@
+<form class="form-validated" novalidate ng-submit="ok()" name="form">
+  <div>
+    <div class="modal-content">
+      <div class="modal-header">
+        <button type="button" class="close" 
+          ng-click="cancel()" aria-hidden="true">&times;</button>
+        <h4 class="modal-title">[% l('Open Circulation') %]</h4>
+      </div>
+      <div class="modal-body">
+[% |l("{{circDate | date:'shortDate'}}") %]
+There is an open circulation on the requested item.  
+This copy was checked out by another patron on [_1].
+[% END %]
+      </div>
+      <div class="modal-footer">
+        <button class="btn btn-warning" 
+            ng-click="cancel()">[% l('Cancel') %]</button>
+        <input type="submit" class="btn btn-primary" 
+            value="[% l('Normal Checkin then Checkout') %]"/>
+      </div>
+    </div> <!-- modal-content -->
+  </div> <!-- modal-dialog -->
+</form>
index c5194da..5828706 100644 (file)
@@ -147,6 +147,10 @@ function($scope,  $q,  $modal,  $routeParams,  egCore, egUser,  patronSvc ,
                 }
                 break;
 
+            case 'OPEN_CIRCULATION_EXISTS':
+                openCircExistsDialog(args, evt);
+                break;
+
             /* stuff to consider 
             PERM_FAILURE
             PATRON_EXCEEDS_OVERDUE_COUNT
@@ -206,6 +210,47 @@ function($scope,  $q,  $modal,  $routeParams,  egCore, egUser,  patronSvc ,
         );
     }
 
+    function openCircExistsDialog(coArgs, evt) {
+        $modal.open({
+            templateUrl: './circ/patron/t_circ_exists_dialog',
+            controller: 
+                       ['$scope','$modalInstance','openCirc',
+                function($scope , $modalInstance , openCirc) {
+                $scope.circDate = openCirc.xact_start();
+                $scope.ok = function() { $modalInstance.close() }
+                $scope.cancel = function () { $modalInstance.dismiss() }
+            }],
+            resolve : {
+                openCirc : function() {
+                    return egCore.pcrud.search('circ', 
+                        {target_copy : evt.payload.copy.id()},
+                        {order_by : {circ : 'xact_start desc' }, limit : 1}
+                    );
+                }
+            }
+        }).result.then(
+            function() {
+                egCore.net.request(
+                    'open-ils.circ', 
+                    'open-ils.circ.checkin',
+                    egCore.auth.token(), 
+                    {barcode :coArgs.copy_barcode, noop : true}
+
+                ).then(function(resp) {
+
+                    if (evt = egCore.evt.parse(resp)) {
+                        if (evt.textcode == 'SUCCESS') {
+                            performCheckout(coArgs);
+                        } else {
+                           alert(evt); // FIXME 
+                        }
+                    }
+                })
+            }
+        );
+    }
+
+
     function openPrecatDialog(copy_barcode) {
         $modal.open({
             templateUrl: './circ/patron/t_precat_dialog',