[Patches] [PATCH] [Bug 6843] Renew membership from expiry date or from current

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Wed Dec 21 03:11:01 NZDT 2011


From: Koustubha Kale <kmkale at anantcorp.com>
Date: Wed, 14 Dec 2011 15:48:16 +0530
Subject: [PATCH] [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 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 +++-
 ...Renew_membership_from_expiry_or_current_date.pl |   10 ++++++++++
 installer/data/mysql/sysprefs.sql                  |    1 +
 .../prog/en/modules/admin/preferences/patrons.pref |    6 ++++++
 4 files changed, 20 insertions(+), 1 deletions(-)
 create mode 100755 installer/data/mysql/atomicupdate/bug_6843_Renew_membership_from_expiry_or_current_date.pl

diff --git a/C4/Members.pm b/C4/Members.pm
index 1d7bc42..b81872c 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -1687,7 +1687,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/atomicupdate/bug_6843_Renew_membership_from_expiry_or_current_date.pl b/installer/data/mysql/atomicupdate/bug_6843_Renew_membership_from_expiry_or_current_date.pl
new file mode 100755
index 0000000..6007129
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_6843_Renew_membership_from_expiry_or_current_date.pl
@@ -0,0 +1,10 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use C4::Context;
+my $dbh=C4::Context->dbh;
+$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 done (Added a system preference to allow renewal of Patron account either from todays date or from existing expiry date in the patrons account.)\n";
+
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index 128c9b2..9be4b79 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/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




More information about the Patches mailing list