[open-ils-commits] [GIT] Evergreen ILS branch master updated. 663317194fcf77ef584634adc543d050457821ac

Evergreen Git git at git.evergreen-ils.org
Mon Jan 9 13:50:00 EST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  663317194fcf77ef584634adc543d050457821ac (commit)
       via  68e5f1e12d43f6cd58529a0f867bd37fafc3d61f (commit)
       via  d2f41ba6829aad91367cb5e47a5825ffcb7ee2df (commit)
       via  e94ca037bf2ce8a9923c28b53cdb0d8c1247a7de (commit)
       via  5992dd30fafda48d7226939332ddb029ac83bca1 (commit)
       via  f4c5013abfb8ce026fb21d4fdcd985e09c55aa67 (commit)
       via  bcef00bd27782fa730bf3b82c263c1e8c421245f (commit)
       via  85716b57f62b9de89327561f37cc3807d5fd6787 (commit)
       via  4aac5e8fb061fa3bdd9808e9519cc605c2b1725a (commit)
       via  fbf349a8bd1293cbb94f5cd74bac9a8a54ed48e5 (commit)
       via  da521bed5758a5ee7d6f15e25dc7d3c00546071a (commit)
       via  46a751a8a8ded31c2dd7cfe96d9385e9037c353f (commit)
       via  a9e670511c2953bcd16fce74a48cd8b7a7cb43e0 (commit)
      from  922c9def9f04aa8855f34e14d5fd5f93ee3b1a54 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 663317194fcf77ef584634adc543d050457821ac
Author: Mike Rylander <mrylander at gmail.com>
Date:   Mon Jan 9 13:49:40 2012 -0500

    Stamping upgrade script for current_shelf_lib
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index c08457d..87e7150 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0663', :eg_version); -- tsbere/dbs
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0664', :eg_version); -- berick/miker
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0664.schema.hold-current-shelf-lib.sql b/Open-ILS/src/sql/Pg/upgrade/0664.schema.hold-current-shelf-lib.sql
new file mode 100644
index 0000000..f46db93
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0664.schema.hold-current-shelf-lib.sql
@@ -0,0 +1,27 @@
+-- Evergreen DB patch 0664.schema.hold-current-shelf-lib.sql
+--
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0664', :eg_version);
+
+-- add the new column
+ALTER TABLE action.hold_request ADD COLUMN current_shelf_lib 
+    INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED;
+
+-- set the value for current_shelf_lib on existing shelved holds
+UPDATE action.hold_request
+    SET current_shelf_lib = pickup_lib
+    FROM asset.copy
+    WHERE 
+            action.hold_request.shelf_time IS NOT NULL 
+        AND action.hold_request.capture_time IS NOT NULL
+        AND action.hold_request.current_copy IS NOT NULL
+        AND action.hold_request.fulfillment_time IS NULL
+        AND action.hold_request.cancel_time IS NULL
+        AND asset.copy.id = action.hold_request.current_copy
+        AND asset.copy.status = 8; -- on holds shelf
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql
deleted file mode 100644
index cec449c..0000000
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql
+++ /dev/null
@@ -1,28 +0,0 @@
--- Evergreen DB patch XXXX.schema.hold-current-shelf-lib.sql
---
--- FIXME: insert description of change, if needed
---
-BEGIN;
-
-
--- check whether patch can be applied
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
--- add the new column
-ALTER TABLE action.hold_request ADD COLUMN current_shelf_lib 
-    INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED;
-
--- set the value for current_shelf_lib on existing shelved holds
-UPDATE action.hold_request ahr
-    SET current_shelf_lib = pickup_lib
-    FROM asset.copy acp
-    WHERE 
-            ahr.shelf_time IS NOT NULL 
-        AND ahr.capture_time IS NOT NULL
-        AND ahr.current_copy IS NOT NULL
-        AND ahr.fulfillment_time IS NULL
-        AND ahr.cancel_time IS NULL
-        AND acp.id = ahr.current_copy
-        AND acp.status = 8; -- on holds shelf
-
-COMMIT;

commit 68e5f1e12d43f6cd58529a0f867bd37fafc3d61f
Merge: 922c9de d2f41ba
Author: Mike Rylander <mrylander at gmail.com>
Date:   Mon Jan 9 13:44:16 2012 -0500

    Merge remote-tracking branch 'eg-working/user/berick/hold-current-shelf-lib'
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>


commit d2f41ba6829aad91367cb5e47a5825ffcb7ee2df
Author: Bill Erickson <berick at esilibrary.com>
Date:   Wed Dec 28 15:44:36 2011 -0500

    Use hold current shelf lib to determine availability : opac sorting
    
    The availability of a hold can now be determined by
    hold.current_shelf_lib == hold.pickup_lib.
    
    This change uses the new hold availability test to sort available
    holds to front/top of a patron's holds list (for the OPAC).
    
    Affects open-ils.circ.holds[.canceled|id_list].retrieve
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index a5b76f9..38f269f 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -530,7 +530,17 @@ sub retrieve_holds {
     } else {
 
         # order non-cancelled holds by ready-for-pickup, then active, followed by suspended
-        $holds_query->{order_by} = {ahr => ['shelf_time', 'frozen', 'request_time']};
+        # "compare" sorts false values to the front.  testing pickup_lib != current_shelf_lib
+        # will sort by pl = csl > pl != csl > followed by csl is null;
+        $holds_query->{order_by} = [
+            {   class => 'ahr', 
+                field => 'pickup_lib', 
+                compare => {'!='  => {'+ahr' => 'current_shelf_lib'}}},
+            {class => 'ahr', field => 'shelf_time'},
+            {class => 'ahr', field => 'frozen'},
+            {class => 'ahr', field => 'request_time'}
+
+        ];
         $holds_query->{where}->{cancel_time} = undef;
     }
 

commit e94ca037bf2ce8a9923c28b53cdb0d8c1247a7de
Author: Mike Rylander <mrylander at gmail.com>
Date:   Wed Jan 4 13:32:33 2012 -0500

    Teach cstore et al about predicate-style truth tests in ORDER BY clauses
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c
index e0b545c..99918d5 100644
--- a/Open-ILS/src/c-apps/oils_sql.c
+++ b/Open-ILS/src/c-apps/oils_sql.c
@@ -4950,6 +4950,8 @@ static char* buildOrderByFromArray( osrfMethodContext* ctx, const jsonObject* or
 		const char* field =
 			jsonObjectGetString( jsonObjectGetKeyConst( order_spec, "field" ));
 
+		jsonObject* compare_to = jsonObjectGetKeyConst( order_spec, "compare" );
+
 		if( !field || !class_alias ) {
 			osrfLogError( OSRF_LOG_MARK,
 				"%s: Missing class or field name in field specification of ORDER BY clause",
@@ -5028,6 +5030,24 @@ static char* buildOrderByFromArray( osrfMethodContext* ctx, const jsonObject* or
 
 			OSRF_BUFFER_ADD( order_buf, transform_str );
 			free( transform_str );
+		} else if( compare_to ) {
+			char* compare_str = searchPredicate( order_class_info, field_def, compare_to, ctx );
+			if( ! compare_str ) {
+				if( ctx )
+					osrfAppSessionStatus(
+						ctx->session,
+						OSRF_STATUS_INTERNALSERVERERROR,
+						"osrfMethodException",
+						ctx->request,
+						"Severe query error in ORDER BY clause -- "
+						"see error log for more details"
+					);
+				buffer_free( order_buf );
+				return NULL;
+			}
+
+			buffer_fadd( order_buf, "(%s)", compare_str );
+			free( compare_str );
 		}
 		else
 			buffer_fadd( order_buf, "\"%s\".%s", class_alias, field );

commit 5992dd30fafda48d7226939332ddb029ac83bca1
Author: Bill Erickson <berick at esilibrary.com>
Date:   Wed Dec 28 13:58:45 2011 -0500

    Use hold current shelf lib to determine availability : hold shelf browse
    
    The availability of a hold can now be determined by
    hold.current_shelf_lib == hold.pickup_lib.
    
    This change updates the staff client code to only display the "available
    on" value (i.e. shelf_time) in the holds list when the current_shelf_lib
    == pickup_lib and not just that it's captured and on a shelf.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js
index 95b91a7..3b16945 100644
--- a/Open-ILS/xul/staff_client/server/circ/util.js
+++ b/Open-ILS/xul/staff_client/server/circ/util.js
@@ -1884,11 +1884,8 @@ circ.util.hold_columns = function(modify,params) {
             'primary' : false,
             'hidden' : false,
             'editable' : false, 'render' : function(my) {
-                if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
-                    return util.date.formatted_date( my.ahr.transit().dest_recv_time(), '%{localized}' );
-                }
-                if (!my.ahr.transit() && my.ahr.capture_time()) {
-                    return util.date.formatted_date( my.ahr.capture_time(), '%{localized}' );
+                if (my.ahr.current_shelf_lib() == my.ahr.pickup_lib()) {
+                    return util.date.formatted_date( my.ahr.shelf_time(), '%{localized}' );
                 }
                 return "";
             }

commit f4c5013abfb8ce026fb21d4fdcd985e09c55aa67
Author: Bill Erickson <berick at esilibrary.com>
Date:   Wed Dec 28 09:54:32 2011 -0500

    Use hold current shelf lib to determine availability : SIP
    
    The availability of a hold can now be determined by
    hold.current_shelf_lib == hold.pickup_lib.
    
    This change updates the unavailable holds count function for the patron
    information SIP call(s).
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
index d2b2085..68d8c13 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm
@@ -624,16 +624,27 @@ sub recall_items {
 sub unavail_holds {
      my ($self, $start, $end) = @_;
      syslog('LOG_DEBUG', 'OILS: Patron->unavail_holds()');
+
+     my $ids = $self->{editor}->json_query({
+        select => {ahr => ['id']},
+        from => 'ahr',
+        where => {
+            usr => $self->{user}->id,
+            fulfillment_time => undef,
+            cancel_time => undef,
+            '-or' => [
+                {current_shelf_lib => undef},
+                {current_shelf_lib => {'!=' => {'+ahr' => 'pickup_lib'}}}
+            ]
+        }
+    });
  
      my @holds_sip_output = map {
         OpenILS::SIP::clean_text($self->__hold_to_title($_))
      } @{
-        $self->{editor}->search_action_hold_request({
-            usr              => $self->{user}->id,
-            fulfillment_time => undef,
-            cancel_time      => undef,
-            shelf_time       => undef
-        })
+        $self->{editor}->search_action_hold_request(
+            {id => [map {$_->{id}} @$ids]}
+        )
      };
  
      return (defined $start and defined $end) ?

commit bcef00bd27782fa730bf3b82c263c1e8c421245f
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Dec 27 16:34:46 2011 -0500

    Use hold current shelf lib to determine availability : A/T validator
    
    The availability of a hold can now be determined by
    hold.current_shelf_lib == hold.pickup_lib.
    
    This change updates the HoldIsAvailable action/trigger validator to use
    the new test.  I've left the original belt-and-suspenders checks in
    place and marked them as redundant within the code for reference.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm
index 54847b3..57563e0 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Validator.pm
@@ -75,11 +75,13 @@ sub HoldIsAvailable {
 
     return 1 if 
         !$hold->cancel_time and
-        $hold->capture_time and 
-        $hold->current_copy and
-        $hold->shelf_time and
         !$hold->fulfillment_time and
-        $hold->current_copy->status == OILS_COPY_STATUS_ON_HOLDS_SHELF;
+        $hold->current_shelf_lib and
+        $hold->current_shelf_lib eq $hold->pickup_lib and
+        $hold->capture_time and # redundant
+        $hold->current_copy and # redundant
+        $hold->shelf_time and   # redundant
+        $hold->current_copy->status == OILS_COPY_STATUS_ON_HOLDS_SHELF; # redundant
 
     return 0;
 }

commit 85716b57f62b9de89327561f37cc3807d5fd6787
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Dec 27 16:20:08 2011 -0500

    Use hold current shelf lib to determine availability : opac hold count
    
    The availability of a hold can now be determined by
    hold.current_shelf_lib == hold.pickup_lib.
    
    This change updates the API call for open hold counts for a patron.
    
    open-ils.actor.user.hold_requests.count
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
index c54debf..93f1a75 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
@@ -1840,7 +1840,7 @@ sub hold_request_count {
     }
 
     my $holds = $e->json_query({
-        select => {ahr => ['shelf_time']},
+        select => {ahr => ['pickup_lib', 'current_shelf_lib']},
         from => 'ahr',
         where => {
             usr => $user_id,
@@ -1851,7 +1851,12 @@ sub hold_request_count {
 
 	return { 
         total => scalar(@$holds), 
-        ready => scalar(grep { $_->{shelf_time} } @$holds) 
+        ready => scalar(
+            grep { 
+                $_->{current_shelf_lib} and # avoid undef warnings
+                $_->{pickup_lib} eq $_->{current_shelf_lib} 
+            } @$holds
+        ) 
     };
 }
 

commit 4aac5e8fb061fa3bdd9808e9519cc605c2b1725a
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Dec 27 15:47:00 2011 -0500

    Alter hold pickup lib from shelf avoids transit
    
    When the pickup library for a hold is changed while the hold is on the
    shelf, we no longer put the copy into transit to the new location.
    Instead, we clear the shelf_expire_time (to prevent premature
    expiration) and leave the hold and copy otherwise untouched.
    
    This makes it possible for staff to identify items that are sitting on
    the holds shelf that need to be put into transit to a new pickup
    library.  The transit will be created when the item is checked in at the
    originating library.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
index 406bd24..999ac68 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
@@ -3189,36 +3189,9 @@ sub process_received_transit {
 # ------------------------------------------------------------------
 sub put_hold_on_shelf {
     my($self, $hold) = @_;
-
     $hold->shelf_time('now');
     $hold->current_shelf_lib($self->circ_lib);
-
-    my $shelf_expire = $U->ou_ancestor_setting_value(
-        $self->circ_lib, 'circ.holds.default_shelf_expire_interval', $self->editor);
-
-    return undef unless $shelf_expire;
-
-    my $seconds = OpenSRF::Utils->interval_to_seconds($shelf_expire);
-    my $expire_time = DateTime->now->add(seconds => $seconds);
-
-    # if the shelf expire time overlaps with a pickup lib's 
-    # closed date, push it out to the first open date
-    my $dateinfo = $U->storagereq(
-        'open-ils.storage.actor.org_unit.closed_date.overlap', 
-        $hold->pickup_lib, $expire_time);
-
-    if($dateinfo) {
-        my $dt_parser = DateTime::Format::ISO8601->new;
-        $expire_time = $dt_parser->parse_datetime(cleanse_ISO8601($dateinfo->{end}));
-
-        # TODO: enable/disable time bump via setting?
-        $expire_time->set(hour => '23', minute => '59', second => '59');
-
-        $logger->info("circulator: shelf_expire_time overlaps".
-            " with closed date, pushing expire time to $expire_time");
-    }
-
-    $hold->shelf_expire_time($expire_time->strftime('%FT%T%z'));
+    $holdcode->set_hold_shelf_expire_time($hold, $self->editor);
     return undef;
 }
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index 26fffb8..a5b76f9 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -952,20 +952,23 @@ sub update_hold_impl {
             $transit->dest($hold->pickup_lib);
             $e->update_action_hold_transit_copy($transit) or return $e->die_event;
 
-        } elsif($hold_status == 4) { # on holds shelf
+        } elsif($hold_status == 4 or $hold_status == 8) { # on holds shelf
 
             return $e->die_event unless $e->allowed('UPDATE_PICKUP_LIB_FROM_HOLDS_SHELF', $orig_hold->pickup_lib);
             return $e->die_event unless $e->allowed('UPDATE_PICKUP_LIB_FROM_HOLDS_SHELF', $hold->pickup_lib);
 
             $logger->info("updating pickup lib for hold ".$hold->id." while on holds shelf");
 
-            # create the new transit
-            my $evt = transit_hold($e, $orig_hold, $hold, $e->retrieve_asset_copy($hold->current_copy));
-            return $evt if $evt;
+            if ($hold->pickup_lib eq $orig_hold->current_shelf_lib) {
+                # This can happen if the pickup lib is changed while the hold is 
+                # on the shelf, then changed back to the original pickup lib.
+                # Restore the original shelf_expire_time to prevent abuse.
+                set_hold_shelf_expire_time(undef, $hold, $e, $hold->shelf_time);
 
-            # hold is leaving the shelf  
-            $hold->clear_shelf_time;
-            $hold->clear_shelf_expire_time;
+            } else {
+                # clear to prevent premature shelf expiration
+                $hold->clear_shelf_expire_time;
+            }
         }
     } 
 
@@ -981,6 +984,49 @@ sub update_hold_impl {
     return $hold->id;
 }
 
+# this does not update the hold in the DB.  It only 
+# sets the shelf_expire_time field on the hold object.
+# start_time is optional and defaults to 'now'
+sub set_hold_shelf_expire_time {
+    my ($class, $hold, $editor, $start_time) = @_;
+
+    my $shelf_expire = $U->ou_ancestor_setting_value( 
+        $hold->pickup_lib,
+        'circ.holds.default_shelf_expire_interval', 
+        $editor
+    );
+
+    return undef unless $shelf_expire;
+
+    $start_time = ($start_time) ? 
+        DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($start_time)) :
+        DateTime->now;
+
+    my $seconds = OpenSRF::Utils->interval_to_seconds($shelf_expire);
+    my $expire_time = $start_time->add(seconds => $seconds);
+
+    # if the shelf expire time overlaps with a pickup lib's 
+    # closed date, push it out to the first open date
+    my $dateinfo = $U->storagereq(
+        'open-ils.storage.actor.org_unit.closed_date.overlap', 
+        $hold->pickup_lib, $expire_time);
+
+    if($dateinfo) {
+        my $dt_parser = DateTime::Format::ISO8601->new;
+        $expire_time = $dt_parser->parse_datetime(cleanse_ISO8601($dateinfo->{end}));
+
+        # TODO: enable/disable time bump via setting?
+        $expire_time->set(hour => '23', minute => '59', second => '59');
+
+        $logger->info("circulator: shelf_expire_time overlaps".
+            " with closed date, pushing expire time to $expire_time");
+    }
+
+    $hold->shelf_expire_time($expire_time->strftime('%FT%T%z'));
+    return undef;
+}
+
+
 sub transit_hold {
     my($e, $orig_hold, $hold, $copy) = @_;
     my $src  = $orig_hold->pickup_lib;

commit fbf349a8bd1293cbb94f5cd74bac9a8a54ed48e5
Author: Bill Erickson <berick at esilibrary.com>
Date:   Wed Dec 28 11:17:37 2011 -0500

    New hold status for "Wrong Shelf"
    
    Adds a new hold status code (8) to indicate when a hold is sitting on
    the wrong holds shelf.
    
    In the OPAC, a hold status of 8 is displayed as in-transit.  Neither
    waiting-for-copy or in-transit are entirely accurate.  In-transit makes
    slightly more sense, since the copy is captured and (slowly) making its
    way to the correct shelf.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index b69b7f5..26fffb8 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -1090,6 +1090,7 @@ Returns event on error or:
  5 for 'hold-shelf-delay'
  6 for 'canceled'
  7 for 'suspended'
+ 8 for 'captured, on wrong hold shelf'
 END_OF_DESC
         }
     }
@@ -1119,6 +1120,9 @@ sub _hold_status {
     if ($U->is_true($hold->frozen)) {
         return 7;
     }
+    if ($hold->current_shelf_lib and $hold->current_shelf_lib ne $hold->pickup_lib) {
+        return 8;
+    }
 	return 1 unless $hold->current_copy;
 	return 2 unless $hold->capture_time;
 
diff --git a/Open-ILS/src/templates/opac/parts/hold_status.tt2 b/Open-ILS/src/templates/opac/parts/hold_status.tt2
index 1480665..0cabbec 100644
--- a/Open-ILS/src/templates/opac/parts/hold_status.tt2
+++ b/Open-ILS/src/templates/opac/parts/hold_status.tt2
@@ -14,7 +14,7 @@
             SET hwait = POSIX.ceil(hold.hold.estimated_wait / 86400);
             l("Estimated wait: [quant,_1,day,days]", hwait) | html;
 
-        ELSIF hold.hold.status == 3;
+        ELSIF hold.hold.status == 3 OR hold.hold.status == 8;
             l("In Transit") | html;
 
         ELSIF hold.hold.status < 3;
diff --git a/Open-ILS/web/opac/skin/default/js/myopac.js b/Open-ILS/web/opac/skin/default/js/myopac.js
index 92e4b12..302f0ec 100644
--- a/Open-ILS/web/opac/skin/default/js/myopac.js
+++ b/Open-ILS/web/opac/skin/default/js/myopac.js
@@ -492,7 +492,7 @@ function myOShowHoldStatus(r) {
 	    if( qstats.status < 3 )
 		    unHideMe($n(row, 'hold_status_waiting'));
     
-	    if( qstats.status == 3 )
+	    if( qstats.status == 3 || qstats.status == 8 )
 		    unHideMe($n(row, 'hold_status_transit'));
     }
 }
diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js
index e8213d9..95b91a7 100644
--- a/Open-ILS/xul/staff_client/server/circ/util.js
+++ b/Open-ILS/xul/staff_client/server/circ/util.js
@@ -1944,6 +1944,9 @@ circ.util.hold_columns = function(modify,params) {
                     case 7:
                         return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.7');
                         break;
+                    case 8:
+                        return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.8');
+                        break;
                     default:
                         return my.status;
                         break;
diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
index af45237..a8d2ce3 100644
--- a/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
+++ b/Open-ILS/xul/staff_client/server/locale/en-US/circ.properties
@@ -324,6 +324,7 @@ staff.circ.utils.hold_status.4=Ready for pickup
 staff.circ.utils.hold_status.5=Reserved/Pending
 staff.circ.utils.hold_status.6=Canceled
 staff.circ.utils.hold_status.7=Suspended
+staff.circ.utils.hold_status.8=Wrong Shelf
 staff.circ.utils.hold_post_clear_shelf_action.label=Post-Clear
 staff.circ.utils.hold_post_clear_shelf_action.hold=Need for Hold
 staff.circ.utils.hold_post_clear_shelf_action.transit=Need for Transit

commit da521bed5758a5ee7d6f15e25dc7d3c00546071a
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Dec 27 15:55:33 2011 -0500

    Hold current_shelf_lib for shelf browse API
    
    Use the new current_shelf_lib column on hold requests to determine which
    copies are on a given shelf.  This also removes the shelf_time filter
    since shelf_time is guaranteed to be set if current_shelf_lib is set.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index d35e13d..b69b7f5 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -1945,14 +1945,11 @@ sub fetch_captured_holds {
                 capture_time     => { "!=" => undef },
                 current_copy     => { "!=" => undef },
                 fulfillment_time => undef,
-                pickup_lib       => $org,
-#                cancel_time      => undef,
-              }
+                current_shelf_lib => $org
+            }
         }
     };
     if($self->api_name =~ /expired/) {
-#       $query->{'where'}->{'+ahr'}->{'shelf_expire_time'} = {'<' => 'now'};
-        $query->{'where'}->{'+alhr'}->{'shelf_time'} = {'!=' => undef};
         $query->{'where'}->{'+alhr'}->{'-or'} = {
                 shelf_expire_time => { '<' => 'now'},
                 cancel_time => { '!=' => undef },

commit 46a751a8a8ded31c2dd7cfe96d9385e9037c353f
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Dec 27 13:18:08 2011 -0500

    Hold current_shelf_lib API for setting/clearing.
    
    Sets and clears the hold.current_shelf_lib value as appropriate during
    hold capture, transit checkin, hold resetting, etc.
    
    Also, we now create hold transits (instead of regular transits) when a
    captured copy is (unexpectedly) found at the wrong branch and needs to
    transit to the pickup lib.  This can happen if the captured copy simply
    transits to the wrong place (existing behavior) or the pickup lib for
    the hold was changed while the copy was on the shelf (new behavior).
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
index 50ef6d6..406bd24 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm
@@ -1655,6 +1655,7 @@ sub handle_checkout_holds {
         $hold->clear_capture_time;
         $hold->clear_shelf_time;
         $hold->clear_shelf_expire_time;
+	    $hold->clear_current_shelf_lib;
 
         return $self->bail_on_event($e->event)
             unless $e->update_action_hold_request($hold);
@@ -2798,23 +2799,42 @@ sub checkin_build_copy_transit {
     my $self            = shift;
     my $dest            = shift;
     my $copy       = $self->copy;
-   my $transit    = Fieldmapper::action::transit_copy->new;
+    my $transit    = Fieldmapper::action::transit_copy->new;
+
+    # if we are transiting an item to the shelf shelf, it's a hold transit
+    if (my $hold = $self->remote_hold) {
+        $transit = Fieldmapper::action::hold_transit_copy->new;
+        $transit->hold($hold->id);
+
+        # the item is going into transit, remove any shelf-iness
+        if ($hold->current_shelf_lib or $hold->shelf_time) {
+            $hold->clear_current_shelf_lib;
+            $hold->clear_shelf_time;
+            return $self->bail_on_events($self->editor->event)
+                unless $self->editor->update_action_hold_request($hold);
+        }
+    }
 
     #$dest  ||= (ref($copy->circ_lib)) ? $copy->circ_lib->id : $copy->circ_lib;
     $logger->info("circulator: transiting copy to $dest");
 
-   $transit->source($self->circ_lib);
-   $transit->dest($dest);
-   $transit->target_copy($copy->id);
-   $transit->source_send_time('now');
-   $transit->copy_status( $U->copy_status($copy->status)->id );
+    $transit->source($self->circ_lib);
+    $transit->dest($dest);
+    $transit->target_copy($copy->id);
+    $transit->source_send_time('now');
+    $transit->copy_status( $U->copy_status($copy->status)->id );
 
     $logger->debug("circulator: setting copy status on transit: ".$transit->copy_status);
 
-    return $self->bail_on_events($self->editor->event)
-        unless $self->editor->create_action_transit_copy($transit);
+    if ($self->remote_hold) {
+        return $self->bail_on_events($self->editor->event)
+            unless $self->editor->create_action_hold_transit_copy($transit);
+    } else {
+        return $self->bail_on_events($self->editor->event)
+            unless $self->editor->create_action_transit_copy($transit);
+    }
 
-   $copy->status(OILS_COPY_STATUS_IN_TRANSIT);
+    $copy->status(OILS_COPY_STATUS_IN_TRANSIT);
     $self->update_copy;
     $self->checkin_changed(1);
 }
@@ -3171,6 +3191,7 @@ sub put_hold_on_shelf {
     my($self, $hold) = @_;
 
     $hold->shelf_time('now');
+    $hold->current_shelf_lib($self->circ_lib);
 
     my $shelf_expire = $U->ou_ancestor_setting_value(
         $self->circ_lib, 'circ.holds.default_shelf_expire_interval', $self->editor);
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index 6705d61..d35e13d 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -672,6 +672,7 @@ sub uncancel_hold {
     $hold->clear_capture_time;
     $hold->clear_prev_check_time;
     $hold->clear_shelf_expire_time;
+	$hold->clear_current_shelf_lib;
 
     $e->update_action_hold_request($hold) or return $e->die_event;
     $e->commit;
@@ -1796,6 +1797,7 @@ sub _reset_hold {
 	$hold->clear_current_copy;
 	$hold->clear_shelf_time;
 	$hold->clear_shelf_expire_time;
+	$hold->clear_current_shelf_lib;
 
 	$e->update_action_hold_request($hold) or return $e->die_event;
 	$e->commit;

commit a9e670511c2953bcd16fce74a48cd8b7a7cb43e0
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Dec 27 12:19:05 2011 -0500

    Hold current_shelf_lib DB and IDL
    
    Schema, upgrade, and IDL pieces for a new
    action.hold_request.current_shelf_lib column.  The goal of the column is
    to track the location where a hold is currently sitting on a hold shelf.
    Typically, this will be the pickup library, however, if the pickup
    library has changed while the hold was on the shelf, the current shelf
    lib will be different.
    
    The upgrade script sets current_shelf_lib to match the pickup_lib for
    all holds that are currently active and on the shelf.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index 7e0b301..42807fd 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -4520,6 +4520,7 @@ SELECT  usr,
 			<field reporter:label="Is Mint Condition" name="mint_condition" reporter:datatype="bool" />
 			<field reporter:label="Shelf Expire Time" name="shelf_expire_time" reporter:datatype="timestamp"/>
 			<field reporter:label="Notes" name="notes" reporter:datatype="link" oils_persist:virtual="true"/>
+			<field reporter:label="Current Shelf Lib" name="current_shelf_lib" reporter:datatype="org_unit"/>
 		</fields>
 		<links>
 			<link field="fulfillment_lib" reltype="has_a" key="id" map="" class="aou"/>
@@ -4536,6 +4537,7 @@ SELECT  usr,
 			<link field="bib_rec" reltype="might_have" key="id" map="" class="rhrr"/>
 			<link field="cancel_cause" reltype="might_have" key="id" map="" class="ahrcc"/>
 			<link field="notes" reltype="has_many" key="hold" map="" class="ahrn"/>
+			<link field="current_shelf_lib" reltype="has_a" key="id" map="" class="aou"/>
 		</links>
 	</class>
 	<class id="alhr" controller="open-ils.cstore" oils_obj:fieldmapper="action::last_hold_request" reporter:label="Last Captured Hold Request" oils_persist:readonly="true">
@@ -4580,6 +4582,7 @@ SELECT  usr,
 			<field reporter:label="Is Mint Condition" name="mint_condition" reporter:datatype="bool" />
 			<field reporter:label="Shelf Expire Time" name="shelf_expire_time" reporter:datatype="timestamp"/>
 			<field reporter:label="Notes" name="notes" reporter:datatype="link" oils_persist:virtual="true"/>
+			<field reporter:label="Current Shelf Lib" name="current_shelf_lib" reporter:datatype="org_unit"/>
 		</fields>
 		<links>
 			<link field="fulfillment_lib" reltype="has_a" key="id" map="" class="aou"/>
@@ -4596,6 +4599,7 @@ SELECT  usr,
 			<link field="bib_rec" reltype="might_have" key="id" map="" class="rhrr"/>
 			<link field="cancel_cause" reltype="might_have" key="id" map="" class="ahrcc"/>
 			<link field="notes" reltype="has_many" key="hold" map="" class="ahrn"/>
+			<link field="current_shelf_lib" reltype="has_a" key="id" map="" class="aou"/>
 		</links>
 	</class>
 
diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql
index 05c45ad..111b53d 100644
--- a/Open-ILS/src/sql/Pg/090.schema.action.sql
+++ b/Open-ILS/src/sql/Pg/090.schema.action.sql
@@ -357,7 +357,8 @@ CREATE TABLE action.hold_request (
 	shelf_time		TIMESTAMP WITH TIME ZONE,
     cut_in_line     BOOL,
 	mint_condition  BOOL NOT NULL DEFAULT TRUE,
-	shelf_expire_time TIMESTAMPTZ
+	shelf_expire_time TIMESTAMPTZ,
+	current_shelf_lib INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED
 );
 
 CREATE INDEX hold_request_target_idx ON action.hold_request (target);
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql
new file mode 100644
index 0000000..cec449c
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.hold-current-shelf-lib.sql
@@ -0,0 +1,28 @@
+-- Evergreen DB patch XXXX.schema.hold-current-shelf-lib.sql
+--
+-- FIXME: insert description of change, if needed
+--
+BEGIN;
+
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+-- add the new column
+ALTER TABLE action.hold_request ADD COLUMN current_shelf_lib 
+    INT REFERENCES actor.org_unit DEFERRABLE INITIALLY DEFERRED;
+
+-- set the value for current_shelf_lib on existing shelved holds
+UPDATE action.hold_request ahr
+    SET current_shelf_lib = pickup_lib
+    FROM asset.copy acp
+    WHERE 
+            ahr.shelf_time IS NOT NULL 
+        AND ahr.capture_time IS NOT NULL
+        AND ahr.current_copy IS NOT NULL
+        AND ahr.fulfillment_time IS NULL
+        AND ahr.cancel_time IS NULL
+        AND acp.id = ahr.current_copy
+        AND acp.status = 8; -- on holds shelf
+
+COMMIT;

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/examples/fm_IDL.xml                       |    4 +
 Open-ILS/src/c-apps/oils_sql.c                     |   20 +++++
 .../src/perlmods/lib/OpenILS/Application/Actor.pm  |    9 ++-
 .../lib/OpenILS/Application/Circ/Circulate.pm      |   68 +++++++---------
 .../perlmods/lib/OpenILS/Application/Circ/Holds.pm |   85 +++++++++++++++++---
 .../lib/OpenILS/Application/Trigger/Validator.pm   |   10 ++-
 Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm    |   23 ++++--
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/090.schema.action.sql          |    3 +-
 .../upgrade/0664.schema.hold-current-shelf-lib.sql |   27 ++++++
 Open-ILS/src/templates/opac/parts/hold_status.tt2  |    2 +-
 Open-ILS/web/opac/skin/default/js/myopac.js        |    2 +-
 Open-ILS/xul/staff_client/server/circ/util.js      |   10 +-
 .../server/locale/en-US/circ.properties            |    1 +
 14 files changed, 195 insertions(+), 71 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0664.schema.hold-current-shelf-lib.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list