From 2a52c9bdfa5ff5d935170ba35041fbd08a63e20d Mon Sep 17 00:00:00 2001 From: Koustubha Kale <kmkale@anantcorp.com> Date: Wed, 9 Nov 2011 12:02:21 +0530 Subject: [PATCH 1/3] [Bug 6843] Renew membership from expiry date or from current date based on a syspref Content-Type: text/plain; charset="utf-8" This patch adds a system preference under Patron -> BorrowerRenewalPeriodBase Using this preference the patch allows to renewal of Patron account either from todays date or from existing expiry date in the patrons account. To test : Apply patch; Set System Preference BorrowerRenewalPeriodBase ( under Patron ) to "current membership expiry date"; Renew a patron; You will observe that patrons account expiry date has been calculated from previuos expiry date instead of today's date ( as is the default in Koha prior to this patch ). --- C4/Members.pm | 4 +++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 9 +++++++++ .../prog/en/modules/admin/preferences/patrons.pref | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 56718f0..6524b9f 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1710,7 +1710,9 @@ sub ExtendMemberSubscriptionTo { my $dbh = C4::Context->dbh; my $borrower = GetMember('borrowernumber'=>$borrowerid); unless ($date){ - $date=POSIX::strftime("%Y-%m-%d",localtime()); + $date = (C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry') ? + C4::Dates->new($borrower->{'dateexpiry'}, 'iso')->output("iso") : + C4::Dates->new()->output("iso"); $date = GetExpiryDate( $borrower->{'categorycode'}, $date ); } my $sth = $dbh->do(<<EOF); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ae2c1cb..25eb781 100755 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -328,4 +328,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OpacKohaUrl','1',"Show 'Powered by Koha' text on OPAC footer.",NULL,NULL); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('EasyAnalyticalRecords','0','If on, display in the catalogue screens tools to easily setup analytical record relationships','','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowRecentComments',0,'If ON a link to recent comments will appear in the OPAC masthead',NULL,'YesNo'); +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'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 815a71d..c4377c5 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4550,6 +4550,15 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.06.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do(<<ENDOFRENEWAL); +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'); +ENDOFRENEWAL + print "Upgrade to $DBversion done (Change the field)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) 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 ac3e1d2..3d6a705 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 @@ -107,3 +107,9 @@ Patrons: yes: Do no: "Don't" - store and display surnames in upper case. + - + - When renewing borrowers, base the new expiry date on + - pref: BorrowerRenewalPeriodBase + choices: + now: current date. + dateexpiry: current membership expiry date. -- 1.7.5.4