Renew membership from expiry date or from current date based on a syspref
authorKoustubha Kale <kmkale@anantcorp.com>
Wed, 14 Dec 2011 10:18:16 +0000 (15:48 +0530)
committerPaul Poulain <paul.poulain@biblibre.com>
Wed, 1 Feb 2012 21:53:40 +0000 (22:53 +0100)
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
installer/data/mysql/atomicupdate/bug_6843_Renew_membership_from_expiry_or_current_date.pl [new file with mode: 0755]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref

index 1d7bc42..b81872c 100644 (file)
@@ -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 (executable)
index 0000000..bffd857
--- /dev/null
@@ -0,0 +1,9 @@
+#! /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";
index 2a59b47..5e3d79d 100755 (executable)
@@ -333,3 +333,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES (
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACLocalCoverImages','0','Display local cover images on OPAC search and details pages.','1','YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('LocalCoverImages','0','Display local cover images on intranet details pages.','1','YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowMultipleCovers','0','Allow multiple cover images to be attached to each bibliographic record.','1','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');
index 0e2f73b..1277ac4 100644 (file)
@@ -114,3 +114,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.