From 46fc29f87d8eb34d58cd44f6c9e589191bd7925a Mon Sep 17 00:00:00 2001 From: Chris Hall Date: Mon, 20 Feb 2012 10:07:13 +1300 Subject: [PATCH] bug 6739 : added the ability to configure whether an expired patron can perform opac actions such as renew and reserve on both a syspref and patron-category level --- C4/Members.pm | 4 +- admin/categorie.pl | 18 +++-- installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 8 ++ .../prog/en/modules/admin/categorie.tt | 10 ++- .../prog/en/modules/admin/preferences/opac.pref | 7 ++ .../prog/en/modules/admin/preferences/patrons.pref | 2 +- koha-tmpl/opac-tmpl/prog/en/css/print.css | 9 ++- .../opac-tmpl/prog/en/modules/opac-reserve.tt | 3 + koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt | 11 +++ opac/opac-renew.pl | 78 +++++++++++--------- opac/opac-reserve.pl | 11 +++ opac/opac-user.pl | 24 ++++-- 14 files changed, 130 insertions(+), 57 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index b81872c..1bd3b8c 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -313,11 +313,11 @@ sub GetMemberDetails { my $query; my $sth; if ($borrowernumber) { - $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE borrowernumber=?"); + $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,categories.BlockExpiredOpacActions,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE borrowernumber=?"); $sth->execute($borrowernumber); } elsif ($cardnumber) { - $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE cardnumber=?"); + $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,categories.BlockExpiredOpacActions,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE cardnumber=?"); $sth->execute($cardnumber); } else { diff --git a/admin/categorie.pl b/admin/categorie.pl index 521346b..e26237c 100755 --- a/admin/categorie.pl +++ b/admin/categorie.pl @@ -67,6 +67,7 @@ my $searchfield=$input->param('description'); my $script_name="/cgi-bin/koha/admin/categorie.pl"; my $categorycode=$input->param('categorycode'); my $op = $input->param('op'); +my $block_expired = $input->param("block_expired"); my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "admin/categorie.tmpl", @@ -92,7 +93,7 @@ if ($op eq 'add_form') { my $data; if ($categorycode) { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); + my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type,BlockExpiredOpacActions from categories where categorycode=?"); $sth->execute($categorycode); $data=$sth->fetchrow_hashref; $sth->finish; @@ -113,6 +114,7 @@ if ($op eq 'add_form') { category_type => $data->{'category_type'}, DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), "type_".$data->{'category_type'} => 1, + "block_" . ($data->{'BlockExpiredOpacActions'} == -1 ? 'syspref' : $data->{'BlockExpiredOpacActions'} ? 'block' : 'dontblock') => 1, SMSSendDriver => C4::Context->preference("SMSSendDriver") ); if (C4::Context->preference('EnhancedMessagingPreferences')) { @@ -128,14 +130,14 @@ if ($op eq 'add_form') { if($input->param('enrolmentperioddate')){ $input->param('enrolmentperioddate' => C4::Dates::format_date_in_iso($input->param('enrolmentperioddate')) ); } - + if ($is_a_modif) { - my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?"); - $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode')); + my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=?,BlockExpiredOpacActions=? WHERE categorycode=?"); + $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','block_expired','categorycode')); $sth->finish; } else { - my $sth=$dbh->prepare("INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)"); - $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type')); + my $sth=$dbh->prepare("INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type,BlockExpiredOpacActions) values (?,?,?,?,?,?,?,?,?,?,?,?)"); + $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','block_expired')); $sth->finish; } if (C4::Context->preference('EnhancedMessagingPreferences')) { @@ -158,7 +160,7 @@ if ($op eq 'add_form') { $sth->finish; $template->param(total => $total->{'total'}); - my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); + my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type,BlockExpiredOpacActions from categories where categorycode=?"); $sth2->execute($categorycode); my $data=$sth2->fetchrow_hashref; $sth2->finish; @@ -177,6 +179,7 @@ if ($op eq 'add_form') { reservefee => sprintf("%.2f",$data->{'reservefee'}), hidelostitems => $data->{'hidelostitems'}, category_type => $data->{'category_type'}, + "block_" . $data->{'BlockExpiredOpacActions'} == -1 ? 'syspref' : $data->{'BlockExpiredOpacActions'} ? 'block' : 'dontblock', ); # END $OP eq DELETE_CONFIRM ################## DELETE_CONFIRMED ################################## @@ -210,6 +213,7 @@ if ($op eq 'add_form') { reservefee => sprintf("%.2f",$results->[$i]{'reservefee'}), hidelostitems => $results->[$i]{'hidelostitems'}, category_type => $results->[$i]{'category_type'}, + block_syspref => 1, "type_".$results->[$i]{'category_type'} => 1); if (C4::Context->preference('EnhancedMessagingPreferences')) { my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'}); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 67149c9d..49f86c1 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -432,6 +432,7 @@ CREATE TABLE `categories` ( -- this table shows information related to Koha patr `reservefee` decimal(28,6) default NULL, -- cost to place holds `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no) `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff) + `BlockExpiredOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this categori can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BLockExpiredPAtronOpacACtions PRIMARY KEY (`categorycode`), UNIQUE KEY `categorycode` (`categorycode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 0cc79b2..9caecdd 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -336,3 +336,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('BorrowerRenewalPeriodBase', 'now', 'Set whether the borrower renewal date should be counted from the dateexpiry or from the current date ','dateexpiry|now','Choice'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('AllowItemsOnHoldCheckout',0,'Do not generate RESERVE_WAITING and RESERVED warning when checking out items reserved to someone else. This allows self checkouts for those items.','','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacExportOptions','bibtex|dc|marcxml|marc8|utf8|marcstd|mods|ris','Define export options available on OPAC detail page.','','free'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('BlockExpiredPatronOpacActions', 'yes', 'Set whether an expired patron can perform opac actions such as placing a hold or reserve, can be overridden on a per patron-type basis',NULL,'YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d2d9d97..f43b5a8 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4712,6 +4712,14 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } + +$DBversion = "3.07.00.017"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('BlockExpiredPatronOpacActions', 'yes', 'Set whether an expired patron can perform opac actions such as placing a hold or reserve, can be overridden on a per patron-type basis',NULL,'YesNo')"); + $dbh->do("ALTER TABLE `categories` ADD COLUMN `BlockExpiredOpacActions` TINYINT(1) DEFAULT 0 NOT NULL"); + print "Upgraded to $DBversion done (Added syspref BlockExpiredPartonOpacActions, When this preference is turned on opac actions such as placing a hold or reserve are blocked for expired patrons (can be overridden on a per patron-type basis) \n"; + SetVersion ($DBversion); +} =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt index 62322fa..d54ec36 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt @@ -179,7 +179,15 @@ [% IF ( type_P ) %][% ELSE %][% END %] [% IF ( type_X ) %][% ELSE %][% END %] - + +
  • + + Should patrons of this category be blocked from opac actions such as renew and reserve when their cards have expired. +
  • [% IF ( EnhancedMessagingPreferences ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index be86733..74874a7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -371,6 +371,13 @@ OPAC: class: code - Allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations. + - + - pref: BlockExpiredPatronOpacActions + choices: + yes: "Block" + no: "Don't Block" + - expired patrons from opac actions such as placing a hold or renew, the setting for a patron category takes priority over this + Privacy: - - pref: AnonSuggestions diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 3d88883..b4c9fd6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -89,7 +89,7 @@ Patrons: class: integer - characters long. - - - Show a notice that a patron is about to expire + - Show a notice if the patron is about to expire or has expired - pref: NotifyBorrowerDeparture class: integer - days beforehand. diff --git a/koha-tmpl/opac-tmpl/prog/en/css/print.css b/koha-tmpl/opac-tmpl/prog/en/css/print.css index 85df351..b5a904a 100644 --- a/koha-tmpl/opac-tmpl/prog/en/css/print.css +++ b/koha-tmpl/opac-tmpl/prog/en/css/print.css @@ -19,6 +19,7 @@ body { font-family : arial, geneva, sans-serif; font-size : 14px; margin : 0px 0px 0px 0px; + word-wrap : break-word; } caption { @@ -199,10 +200,14 @@ body#basket p { padding:0pt; } -#members,#opac-main-search,#opac-user-views .ui-tabs-nav,input,div.yui-b,h2 span.hint,td.resultscontrol,.pages,.suggestion,.views,#action,#export,#bibliodescriptions .ui-tabs-nav,#addshelf,fieldset.action, .list-actions, .ft { +#members,#opac-main-search,#opac-user-views .ui-tabs-nav,input,h2 span.hint,td.resultscontrol,.pages,.suggestion,.views,#action,#export,#bibliodescriptions .ui-tabs-nav,#addshelf,fieldset.action, .list-actions, .ft, #facetcontainer { display : none; } -div#yui-main div.yui-b { + +#userresults { + position : absolute; + right : 0px; + word-wrap : break-word; display : block; } diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt index 64ed80c..258c276 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt @@ -210,6 +210,9 @@ [% IF ( bad_data ) %]
    ERROR: Internal error: incomplete hold request.
    [% END %] + [% IF ( expired_patron ) %] +

    Sorry, you cannot place holds because your library card has expired.

    Please contact your librarian if you wish to renew your card

    + [% END %] [% ELSE %] [% IF ( none_available ) %]
    Sorry, none of these items can be placed on hold. diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt index 9174fa1..f5d5f78 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt @@ -83,8 +83,19 @@ $.tablesorter.addParser({ Please note: Your card will expire on [% BORROWER_INF.warndeparture %]. Please contact the library if you wish to renew your subscription. [% IF ( BORROWER_INF.returnbeforeexpiry ) %] Also note that you must return all checked out items before your card expires.[% END %]
    + [% ELSIF ( BORROWER_INF.warnexpired ) %] +
    + Please note: You card has expired as of [% BORROWER_INF.warnexpired %]. Please contact the library if you wish to renew your subscription. +
    [% END %] + [% IF ( RENEW_ERROR ) %] +
    + Please note: You're renew failed with the following error: [% RENEW_ERROR %] +
    + [% END %] + + [% IF ( patron_flagged ) %]