[open-ils-commits] r15143 - in trunk/Open-ILS: src/perlmods/OpenILS/Application/Circ src/sql/Pg src/sql/Pg/upgrade web/opac/locale/en-US web/opac/skin/default/js web/opac/skin/default/xml/common (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Dec 11 12:20:59 EST 2009
Author: erickson
Date: 2009-12-11 12:20:56 -0500 (Fri, 11 Dec 2009)
New Revision: 15143
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0114.data.hold_item_checked_out_perm.sql
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
trunk/Open-ILS/web/opac/skin/default/js/holds.js
trunk/Open-ILS/web/opac/skin/default/xml/common/holds.xml
Log:
added support for alerting and optionally preventing users when they attempt to place a hold on an item that is already checked out to them. give the override perm to everyone by default for backwards compat
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm 2009-12-11 15:41:16 UTC (rev 15142)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm 2009-12-11 17:20:56 UTC (rev 15143)
@@ -111,6 +111,9 @@
my $existing = $e->search_action_hold_request($sargs);
push( @events, OpenILS::Event->new('HOLD_EXISTS')) if @$existing;
+ my $checked_out = hold_item_is_checked_out($e, $recipient->id, $hold->hold_type, $hold->target);
+ push( @events, OpenILS::Event->new('HOLD_ITEM_CHECKED_OUT')) if $checked_out;
+
if( $t eq OILS_HOLD_TYPE_METARECORD )
{ $pevt = $e->event unless $e->allowed('MR_HOLDS', $porg); }
@@ -2238,4 +2241,82 @@
}
+# returns true if the user already has an item checked out
+# that could be used to fulfill the requested hold.
+sub hold_item_is_checked_out {
+ my($e, $user_id, $hold_type, $hold_target) = @_;
+
+ my $query = {
+ select => {acp => ['id']},
+ from => {acp => {}},
+ where => {
+ '+acp' => {
+ id => {
+ in => { # copies for circs the user has checked out
+ select => {circ => ['target_copy']},
+ from => 'circ',
+ where => {
+ usr => $user_id,
+ checkin_time => undef,
+ '-or' => [
+ {stop_fines => ["MAXFINES","LONGOVERDUE"]},
+ {stop_fines => undef}
+ ],
+ }
+ }
+ }
+ }
+ },
+ limit => 1
+ };
+
+ if($hold_type eq 'C') {
+
+ $query->{where}->{'+acp'}->{id} = $hold_target;
+
+ } elsif($hold_type eq 'V') {
+
+ $query->{where}->{'+acp'}->{call_number} = $hold_target;
+
+ } elsif($hold_type eq 'T') {
+
+ $query->{from}->{acp}->{acn} = {
+ field => 'id',
+ fkey => 'call_number',
+ 'join' => {
+ bre => {
+ field => 'id',
+ filter => {id => $hold_target},
+ fkey => 'record'
+ }
+ }
+ };
+
+ } else {
+
+ $query->{from}->{acp}->{acn} = {
+ field => 'id',
+ fkey => 'call_number',
+ join => {
+ bre => {
+ field => 'id',
+ fkey => 'record',
+ join => {
+ mmrsm => {
+ field => 'source',
+ fkey => 'id',
+ filter => {metarecord => $hold_target},
+ }
+ }
+ }
+ }
+ };
+ }
+
+ return $e->json_query($query)->[0];
+}
+
+
+
+
1;
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-12-11 15:41:16 UTC (rev 15142)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-12-11 17:20:56 UTC (rev 15143)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0113'); -- berick
+INSERT INTO config.upgrade_log (version) VALUES ('0114'); -- berick
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2009-12-11 15:41:16 UTC (rev 15142)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2009-12-11 17:20:56 UTC (rev 15143)
@@ -1248,6 +1248,7 @@
(356, 'ADMIN_BOOKING_RESOURCE_ATTR_VALUE', oils_i18n_gettext(356, 'Enables the user to create/update/delete booking resource attribute values', 'ppl', 'description')),
(357, 'ADMIN_BOOKING_RESERVATION', oils_i18n_gettext(357, 'Enables the user to create/update/delete booking reservations', 'ppl', 'description')),
(358, 'ADMIN_BOOKING_RESERVATION_ATTR_VALUE_MAP', oils_i18n_gettext(358, 'Enables the user to create/update/delete booking reservation attribute value maps', 'ppl', 'description'))
+ (359, 'HOLD_ITEM_CHECKED_OUT.override', oils_i18n_gettext(359, 'Allows a user to place a hold on an item that they already have checked out', 'ppl', 'description'))
;
;
@@ -1433,6 +1434,8 @@
INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (7, (SELECT id FROM permission.perm_list WHERE code = 'ADMIN_FUND'), 1, false);
INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (7, (SELECT id FROM permission.perm_list WHERE code = 'ADMIN_CURRENCY_TYPE'), 1, false);
+INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (1, (SELECT id FROM permission.perm_list WHERE code = 'HOLD_ITEM_CHECKED_OUT.override'), 0, false);
+
-- Admin user account
INSERT INTO actor.usr ( profile, card, usrname, passwd, first_given_name, family_name, dob, master_account, super_user, ident_type, ident_value, home_ou ) VALUES ( 1, 1, 'admin', 'open-ils', 'Administrator', 'System Account', '1979-01-22', TRUE, TRUE, 1, 'identification', 1 );
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0114.data.hold_item_checked_out_perm.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0114.data.hold_item_checked_out_perm.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0114.data.hold_item_checked_out_perm.sql 2009-12-11 17:20:56 UTC (rev 15143)
@@ -0,0 +1,11 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0114');
+
+INSERT INTO permission.perm_list (id, code, description) VALUES
+ (359, 'HOLD_ITEM_CHECKED_OUT.override', oils_i18n_gettext(359, 'Allows a user to place a hold on an item that they already have checked out', 'ppl', 'description'));
+
+-- for backwards compat, give everyone the permission
+INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) VALUES (1, (SELECT id FROM permission.perm_list WHERE code = 'HOLD_ITEM_CHECKED_OUT.override'), 0, false);
+
+COMMIT;
Modified: trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/opac.dtd 2009-12-11 15:41:16 UTC (rev 15142)
+++ trunk/Open-ILS/web/opac/locale/en-US/opac.dtd 2009-12-11 17:20:56 UTC (rev 15143)
@@ -590,9 +590,10 @@
<!ENTITY common.hold.copy "Copy Hold">
<!ENTITY common.hold.advanced "Advanced Hold Options">
<!ENTITY common.hold.delivery "Please select a physical location where your hold can be delivered.">
+<!ENTITY common.hold.checked_out "This item is already checked out.">
+<!ENTITY common.hold.checked_out.override "This item is already checked out. Would you like to place the hold anyway?">
<!ENTITY common.hold.exists "A hold already exists on the requested item.">
-<!ENTITY common.hold.exists.override "A hold already exists on the requested
-item. Would you like to create the hold anyway?">
+<!ENTITY common.hold.exists.override "A hold already exists on the requested item. Would you like to create the hold anyway?">
<!ENTITY common.hold.barred 'PATRON BARRED. Please see any notes in the
"Staff Notes" section of your "My Account" page or contact your local library.'>
<!ENTITY common.hold.item.invalid "This hold is no longer valid. It's likely that the
Modified: trunk/Open-ILS/web/opac/skin/default/js/holds.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/holds.js 2009-12-11 15:41:16 UTC (rev 15142)
+++ trunk/Open-ILS/web/opac/skin/default/js/holds.js 2009-12-11 17:20:56 UTC (rev 15143)
@@ -843,12 +843,26 @@
if( confirm($('hold_dup_exists_override').innerHTML) ) {
return holdsPlaceHold(hold, true);
}
+ return;
} else {
return alert($('hold_dup_exists').innerHTML);
}
}
+ if( grep(res, function(e) { return (e.textcode == 'HOLD_ITEM_CHECKED_OUT'); }) ) {
+ if( fetchPermOrgs('HOLD_ITEM_CHECKED_OUT.override')[0] != -1 ) {
+ if( confirm($('hold_checked_out_override').innerHTML) ) {
+ return holdsPlaceHold(hold, true);
+ }
+ return;
+
+ } else {
+ return alert($('hold_checked_out').innerHTML);
+ }
+ }
+
+
alert($('holds_failure').innerHTML);
}
}
Modified: trunk/Open-ILS/web/opac/skin/default/xml/common/holds.xml
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/xml/common/holds.xml 2009-12-11 15:41:16 UTC (rev 15142)
+++ trunk/Open-ILS/web/opac/skin/default/xml/common/holds.xml 2009-12-11 17:20:56 UTC (rev 15143)
@@ -220,8 +220,10 @@
<span class='hide_me' id='holds_pick_good_org'>&common.hold.delivery;</span>
<span class='hide_me' id='hold_dup_exists'>&common.hold.exists;</span>
+ <span class='hide_me' id='hold_checked_out'>&common.hold.checked_out;</span>
<span class='hide_me' id='hold_dup_exists_override'>&common.hold.exists.override;</span>
+ <span class='hide_me' id='hold_checked_out_override'>&common.hold.checked_out.override;</span>
<span id='hold_failed_patron_barred' class='hide_me'>&common.hold.barred;</span>
More information about the open-ils-commits
mailing list