[Koha-patches] [PATCH] (bug #3020) add a grace period to subscriptions
Nahuel ANGELINETTI
nahuel.angelinetti at biblibre.com
Mon Mar 9 16:55:17 CET 2009
This patch modify the database to have a grace period which can be set. And is used to create automatically new waited issues with a
cronjob(which is in this patch), and set old issues to "late" status.
---
C4/Serials.pm | 13 ++++---
installer/data/mysql/kohastructure.sql | 1 +
installer/data/mysql/updatedatabase.pl | 6 +++
.../prog/en/modules/serials/subscription-add.tmpl | 3 ++
.../en/modules/serials/subscription-detail.tmpl | 1 +
kohaversion.pl | 2 +-
serials/subscription-add.pl | 36 ++++++++++---------
7 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/C4/Serials.pm b/C4/Serials.pm
index b78453e..00734b1 100644
--- a/C4/Serials.pm
+++ b/C4/Serials.pm
@@ -1347,7 +1347,7 @@ $subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbu
$add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
$add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
$add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
- $numberingmethod, $status, $notes, $serialsadditems)
+ $numberingmethod, $status, $notes, $serialsadditems, graceperiod)
Create a new subscription with value given on input args.
@@ -1370,7 +1370,7 @@ sub NewSubscription {
$lastvalue3, $innerloop3, $numberingmethod, $status,
$notes, $letter, $firstacquidate, $irregularity,
$numberpattern, $callnumber, $hemisphere, $manualhistory,
- $internalnotes, $serialsadditems,
+ $internalnotes, $serialsadditems, $graceperiod
) = @_;
my $dbh = C4::Context->dbh;
@@ -1383,8 +1383,8 @@ sub NewSubscription {
add2,every2,whenmorethan2,setto2,lastvalue2,innerloop2,
add3,every3,whenmorethan3,setto3,lastvalue3,innerloop3,
numberingmethod, status, notes, letter,firstacquidate,irregularity,
- numberpattern, callnumber, hemisphere,manualhistory,internalnotes,serialsadditems)
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
+ numberpattern, callnumber, hemisphere,manualhistory,internalnotes,serialsadditems,graceperiod)
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|;
my $sth = $dbh->prepare($query);
$sth->execute(
@@ -1409,6 +1409,7 @@ sub NewSubscription {
$numberpattern, $callnumber,
$hemisphere, $manualhistory,
$internalnotes, $serialsadditems,
+ $graceperiod,
);
#then create the 1st waited number
@@ -2364,9 +2365,9 @@ sub abouttoexpire {
$sth->execute($subscriptionid);
my ($res) = $sth->fetchrow ;
# warn "date expiration : ".$expirationdate." date courante ".$res;
- my @res=split /-/,$res;
+ my @res=split (/-/,$res);
@res=Date::Calc::Today if ($res[0]*$res[1]==0);
- my @endofsubscriptiondate=split/-/,$expirationdate;
+ my @endofsubscriptiondate=split(/-/,$expirationdate);
my $x;
if ( $per == 1 ) {$x=7;}
if ( $per == 2 ) {$x=7; }
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 7111499..54c3bfe 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1896,6 +1896,7 @@ CREATE TABLE `subscription` (
`hemisphere` tinyint(3) default 0,
`lastbranch` varchar(10),
`serialsadditems` tinyint(1) NOT NULL default '0',
+ `graceperiod` int(11) NOT NULL default '0',
PRIMARY KEY (`subscriptionid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 5de6909..bb35e69 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -2240,6 +2240,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
+$DBversion = "3.01.00.025";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("ALTER TABLE `subscription` ADD COLUMN `graceperiod` INT(11) NOT NULL default '0';");
+ print "Upgrade to $DBversion done (Adding a field in issuingrules table)\n";
+ SetVersion ($DBversion);
+}
=item DropAllForeignKeys($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl
index 60e09d7..2ad3ff1 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tmpl
@@ -1000,6 +1000,9 @@ $('#numberpattern').change( function() {
</li>
<li>
+ <label for="graceperiod">Grace period:</label> <input type="text" name="graceperiod" id="graceperiod" value="<!-- TMPL_VAR name="graceperiod" -->" /> day(s)
+ </li>
+ <li>
<label for="notes">Public note:</label>
<textarea name="notes" id="notes" cols="30" rows="2"><!-- TMPL_VAR name="notes" --></textarea>
</li>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl
index 8f78e73..9d9569b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tmpl
@@ -66,6 +66,7 @@ function popup(subscriptionid) {
<!-- TMPL_ELSE -->
<li>Serial receipt does not create an item record.</li>
<!-- /TMPL_IF -->
+ <li><span class="label">Grace period:</span> <!-- TMPL_VAR name="graceperiod" --> </li>
<!-- TMPL_IF name="callnumber" --><li><span class="label">Call Number:</span> <!-- TMPL_VAR name="callnumber" --> </li><!-- /TMPL_IF -->
<!-- TMPL_IF name="letter" --><li><span class="label">Patron alert with:</span> <!-- TMPL_VAR name="letter" --> </li><!-- /TMPL_IF -->
<!-- TMPL_IF name="notes" --><li><span class="label">Notes:</span> <!-- TMPL_VAR name="notes" --></li><!-- /TMPL_IF -->
diff --git a/kohaversion.pl b/kohaversion.pl
index 33963cd..6efd56b 100644
--- a/kohaversion.pl
+++ b/kohaversion.pl
@@ -10,7 +10,7 @@
use strict;
sub kohaversion {
- our $VERSION = '3.01.00.019';
+ our $VERSION = '3.01.00.025';
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install
diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl
index 39bd8ff..f5fe0fd 100755
--- a/serials/subscription-add.pl
+++ b/serials/subscription-add.pl
@@ -161,22 +161,24 @@ $template->param( 'dateformat_' . C4::Context->preference('dateformat') => 1 ,
);
if ($op eq 'addsubscription') {
- my $auser = $query->param('user');
- my $branchcode = $query->param('branchcode');
- my $aqbooksellerid = $query->param('aqbooksellerid');
- my $cost = $query->param('cost');
- my $aqbudgetid = $query->param('aqbudgetid');
- my $startdate = $query->param('startdate');
- my $firstacquidate = $query->param('firstacquidate');
- my $periodicity = $query->param('periodicity');
- my $dow = $query->param('dow');
- my @irregularity = $query->param('irregularity_select');
- my $numberlength = 0;
- my $weeklength = 0;
- my $monthlength = 0;
- my $numberpattern = $query->param('numbering_pattern');
- my $sublength = $query->param('sublength');
- my $subtype = $query->param('subtype');
+ my $auser = $query->param('user');
+ my $branchcode = $query->param('branchcode');
+ my $aqbooksellerid = $query->param('aqbooksellerid');
+ my $cost = $query->param('cost');
+ my $aqbudgetid = $query->param('aqbudgetid');
+ my $startdate = $query->param('startdate');
+ my $firstacquidate = $query->param('firstacquidate');
+ my $periodicity = $query->param('periodicity');
+ my $dow = $query->param('dow');
+ my @irregularity = $query->param('irregularity_select');
+ my $numberlength = 0;
+ my $weeklength = 0;
+ my $monthlength = 0;
+ my $numberpattern = $query->param('numbering_pattern');
+ my $sublength = $query->param('sublength');
+ my $subtype = $query->param('subtype');
+ my $graceperiod = $query->param('graceperiod') || 0;
+
if ($subtype eq 'months'){
$monthlength = $sublength;
} elsif ($subtype eq 'weeks'){
@@ -220,7 +222,7 @@ if ($op eq 'addsubscription') {
$add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
$numberingmethod, $status, $notes,$letter,$firstacquidate,join(",", at irregularity),
$numberpattern, $callnumber, $hemisphere,($manualhistory?$manualhistory:0),$internalnotes,
- $serialsadditems,
+ $serialsadditems,$graceperiod
);
print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
--
1.5.6.3
More information about the Koha-patches
mailing list