From 3b1d91d04f98fcb1bc213de5a14e252cb9d0994d Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Mon, 9 Mar 2009 16:55:17 +0100 Subject: [PATCH] (bug #3020) add a grace period to subscriptions 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. Signed-off-by: Galen Charlton --- C4/Serials.pm | 17 +++++---- installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 ++++ .../en/modules/serials/subscription-add.tmpl | 3 ++ .../modules/serials/subscription-detail.tmpl | 1 + kohaversion.pl | 2 +- serials/subscription-add.pl | 36 ++++++++++--------- 7 files changed, 42 insertions(+), 25 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index aedc9c536a..135743212e 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1345,7 +1345,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. @@ -1368,7 +1368,8 @@ sub NewSubscription { $lastvalue3, $innerloop3, $numberingmethod, $status, $notes, $letter, $firstacquidate, $irregularity, $numberpattern, $callnumber, $hemisphere, $manualhistory, - $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount + $internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, + $graceperiod ) = @_; my $dbh = C4::Context->dbh; @@ -1381,8 +1382,9 @@ 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,staffdisplaycount,opacdisplaycount) - VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + numberpattern, callnumber, hemisphere,manualhistory,internalnotes,serialsadditems, + staffdisplaycount,opacdisplaycount,graceperiod) + VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |; my $sth = $dbh->prepare($query); $sth->execute( @@ -1407,7 +1409,8 @@ sub NewSubscription { $numberpattern, $callnumber, $hemisphere, $manualhistory, $internalnotes, $serialsadditems, - $staffdisplaycount, $opacdisplaycount + $staffdisplaycount, $opacdisplaycount, + $graceperiod, ); #then create the 1st waited number @@ -2368,9 +2371,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 72ff5e3666..c17c4ba715 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1898,6 +1898,7 @@ CREATE TABLE `subscription` ( `serialsadditems` tinyint(1) NOT NULL default '0', `staffdisplaycount` VARCHAR(10) NULL, `opacdisplaycount` VARCHAR(10) NULL, + `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 8225b8651e..71340c15d0 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -2430,6 +2430,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.01.00.034"; +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) Drop all foreign keys of the table $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 b3b6395d95..c2c440077f 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 @@ -1001,6 +1001,9 @@ $(document).ready(function() { (select a library) +
  • + " /> day(s) +
  • 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 0e6b4c1b31..93e92cc39c 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) {
  • Serial receipt does not create an item record.
  • +
  • Grace period:  
  • Call Number:  
  • Number of issues to display to staff 
  • Number of issues to display to the public 
  • diff --git a/kohaversion.pl b/kohaversion.pl index a0248eaf8e..6d838d34fd 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = '3.01.00.033'; + our $VERSION = '3.01.00.034'; # 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 aeac6840d7..dba37ad637 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'){ @@ -222,7 +224,7 @@ if ($op eq 'addsubscription') { $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, $numberingmethod, $status, $notes,$letter,$firstacquidate,join(",",@irregularity), $numberpattern, $callnumber, $hemisphere,($manualhistory?$manualhistory:0),$internalnotes, - $serialsadditems,$staffdisplaycount,$opacdisplaycount + $serialsadditems,$staffdisplaycount,$opacdisplaycount,$graceperiod ); print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); -- 2.20.1