added dup-holds override perm and ability to opac
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 29 Jul 2006 22:50:40 +0000 (22:50 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 29 Jul 2006 22:50:40 +0000 (22:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5170 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/skin/default/js/holds.js
Open-ILS/web/opac/skin/default/xml/common/holds.xml

index a52de21..670e0a2 100644 (file)
@@ -67,11 +67,14 @@ sub create_hold {
        my $e = new_editor(authtoken=>$auth);
        return $e->event unless $e->checkauth;
 
+       my $override = 1 if $self->api_name =~ /override/;
+
        my $holds = (ref($holds[0] eq 'ARRAY')) ? $holds[0] : [@holds];
 
        for my $hold (@$holds) {
 
                next unless $hold;
+               my @events;
 
                my $requestor = $e->requestor;
                my $recipient = $requestor;
@@ -101,37 +104,36 @@ sub create_hold {
 
                $sargs->{holdable_formats} = $hold->holdable_formats if $t eq 'M';
                        
-               # XXX Put multi-hold-per-title perm here for staff
                my $existing = $e->search_action_hold_request($sargs); 
-               my $eevt = OpenILS::Event->new('HOLD_EXISTS') if @$existing;
+               push( @events, OpenILS::Event->new('HOLD_EXISTS')) if @$existing;
 
                if( $t eq 'M' ) { $pevt = $e->event unless $e->checkperm($rid, $porg, 'MR_HOLDS'); }
                if( $t eq 'T' ) { $pevt = $e->event unless $e->checkperm($rid, $porg, 'TITLE_HOLDS');  }
                if( $t eq 'V' ) { $pevt = $e->event unless $e->checkperm($rid, $porg, 'VOLUME_HOLDS'); }
                if( $t eq 'C' ) { $pevt = $e->event unless $e->checkperm($rid, $porg, 'COPY_HOLDS'); }
 
+               return $pevt if $pevt;
 
-               # COPY/VOLUME holds are allowed for staff, not overridable 
-               # XXX We need overridable events for staff XXX
-
-               if( $pevt ) {
-                       if( $self->api_name =~ /override/ ) {
-                               # The recipient is not allowed to receive the requested hold 
-                               # and the requestor has elected to override - 
-                               # let's see if the requestor is allowed
-                               return $e->event unless $e->allowed('REQUEST_HOLDS_OVERRIDE', $porg);
+               if( @events ) {
+                       if( $override ) {
+                               for my $evt (@events) {
+                                       next unless $evt;
+                                       my $name = $evt->{textcode};
+                                       return $e->event unless $e->allowed("$name.override", $porg);
+                               }
                        } else {
-                               return $pevt;
+                               return \@events;
                        }
                }
 
-               if( $eevt ) {
-                       if( $self->api_name =~ /override/ ) {
-                               return $e->event unless $e->allowed('CREATE_DUPLICATE_HOLDS', $porg);
-                       } else {
-                               return $eevt;
-                       }
-               }
+
+#              if( $eevt ) {
+#                      if( $override ) {
+#                              return $e->event unless $e->allowed('CREATE_DUPLICATE_HOLDS', $porg);
+#                      } else {
+#                              return $eevt;
+#                      }
+#              }
 
 
                $hold->requestor($e->requestor->id); 
@@ -139,6 +141,7 @@ sub create_hold {
                $e->create_action_hold_request($hold) or return $e->event;
        }
 
+       $e->commit;
        return 1;
 }
 
index 431b3a5..57781b3 100644 (file)
@@ -280,6 +280,7 @@ var FETCH_MONEY_BILLING                     = 'open-ils.circ:open-ils.circ.money.billing.retrieve.
 var FETCH_CROSSREF                             = "open-ils.search:open-ils.search.authority.crossref";
 var FETCH_CROSSREF_BATCH               = "open-ils.search:open-ils.search.authority.crossref.batch";
 var CREATE_HOLD                                        = "open-ils.circ:open-ils.circ.holds.create";
+var CREATE_HOLD_OVERRIDE               = "open-ils.circ:open-ils.circ.holds.create.override";
 var CANCEL_HOLD                                        = "open-ils.circ:open-ils.circ.hold.cancel";
 var UPDATE_USERNAME                            = "open-ils.actor:open-ils.actor.user.username.update";
 var UPDATE_PASSWORD                            = "open-ils.actor:open-ils.actor.user.password.update";
@@ -325,6 +326,7 @@ var FETCH_BRE                                               = 'open-ils.search:open-ils.search.biblio.record_entry.slim.r
 var CHECK_USERNAME                             = 'open-ils.actor:open-ils.actor.username.exists';
 var FETCH_CIRC_BY_ID                           = 'open-ils.circ:open-ils.circ.retrieve';
 var FETCH_MR_DESCRIPTORS               = 'open-ils.search:open-ils.search.metabib.record_to_descriptors';
+var FETCH_HIGHEST_PERM_ORG             = 'open-ils.actor:open-ils.actor.user.perm.highest_org.batch';
 
 /* ---------------------------------------------------------------------------- */
 
index 0385ff0..d6c3567 100644 (file)
@@ -392,6 +392,9 @@ function __holdsDrawWindow() {
                }
        }
 
+       if(!$('holds_phone').value) 
+               $('holds_enable_phone').checked = false;        
+
        appendClear($('holds_physical_desc'), text(rec.physical_description()));
 
        if(holdArgs.type == 'M') hideMe($('hold_physical_desc_row'));
@@ -631,7 +634,7 @@ function holdsBuildHoldFromWindow() {
        return hold;
 }
        
-function holdsPlaceHold(hold) {
+function holdsPlaceHold(hold, recurse) {
 
        if(!hold) return;
 
@@ -645,12 +648,14 @@ function holdsPlaceHold(hold) {
                }
        }
 
-       var req = new Request( CREATE_HOLD, holdArgs.requestor.session, hold );
+       var method = CREATE_HOLD;
+       if(recurse) method = CREATE_HOLD_OVERRIDE;
+
+       var req = new Request( method, holdArgs.requestor.session, hold );
+       req.request.alertEvent = false;
        req.send(true);
        var res = req.result();
-
-       if( res == '1' ) alert($('holds_success').innerHTML);
-       else alert($('holds_failure').innerHTML);
+       holdProcessResult(hold, res, recurse);
        
        showCanvas();
 
@@ -658,6 +663,40 @@ function holdsPlaceHold(hold) {
        runEvt('common', 'holdUpdated');
 }
 
+function holdProcessResult( hold, res, recurse ) {
+
+       if( res == '1' ) {
+               alert($('holds_success').innerHTML);
+
+       } else {
+
+               if( recurse ) {
+                       alert($('holds_failure').innerHTML);
+                       return;
+               }
+
+               if( grep(res, function(e) { return (e.textcode == 'HOLD_EXISTS'); }) ) {
+
+                       /* see if the requestor has the ability to create duplicate holds */
+                       var preq = new Request(FETCH_HIGHEST_PERM_ORG, 
+                               G.user.session, G.user.id(), ['CREATE_DUPLICATE_HOLDS']);
+                       preq.send(true);
+                       var org = preq.result()[0];
+
+                       if( org ) {
+                               if( confirm($('hold_dup_exists_override').innerHTML) ) {
+                                       holdsPlaceHold(hold, true);
+                               }
+
+                       } else {
+                               alert($('hold_dup_exists').innerHTML);
+                               return;
+                       }
+               }
+       }
+}
+
+
 function holdsCancel(holdid, user) {
        if(!user) user = G.user;
        var req = new Request(CANCEL_HOLD, user.session, holdid);
index b7bed14..2108d47 100644 (file)
                Please select a physical location where your hold can be delivered.
        </span>
 
+       <span class='hide_me' id='hold_dup_exists'>
+               A hold already exists on the requested item
+       </span>
+
+       <span class='hide_me' id='hold_dup_exists_override'>
+               A hold already exists on the requested item.  Would you like to create the hold anyway?
+       </span>
+
+
 </div>