From 2152ca68f785f38c781123f625199cb7a5972048 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 22 Jun 2012 17:25:54 +0200 Subject: [PATCH] Bug 8296: Add descriptive (text) published date field for serials Add a new field serial.publisheddatetext for displaying published date in another format that dateformat syspref permit. Signed-off-by: Cedric Vita --- C4/Serials.pm | 40 +++++++++++++------- installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 13 +++++++ .../prog/en/modules/serials/serials-collection.tt | 6 +++ .../prog/en/modules/serials/serials-edit.tt | 7 ++++ .../prog/en/modules/serials/subscription-detail.tt | 4 ++ .../prog/en/modules/opac-full-serial-issues.tt | 2 + misc/cronjobs/serialsUpdate.pl | 2 +- serials/serials-collection.pl | 10 +++-- serials/serials-edit.pl | 4 ++ 10 files changed, 72 insertions(+), 17 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index a1ce054..0cb256c 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -363,6 +363,7 @@ sub GetFullSubscription { serial.serialseq, serial.planneddate, serial.publisheddate, + serial.publisheddatetext, serial.status, serial.notes as notes, year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year, @@ -521,6 +522,7 @@ sub GetFullSubscriptionsFromBiblionumber { serial.serialseq, serial.planneddate, serial.publisheddate, + serial.publisheddatetext, serial.status, serial.notes as notes, year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year, @@ -736,7 +738,8 @@ sub GetSerials { my $counter = 0; $count = 5 unless ($count); my @serials; - my $query = "SELECT serialid,serialseq, status, publisheddate, planneddate,notes, routingnotes + my $query = "SELECT serialid,serialseq, status, publisheddate, + publisheddatetext, planneddate,notes, routingnotes FROM serial WHERE subscriptionid = ? AND status NOT IN (2,4,5) ORDER BY IF(publisheddate<>'0000-00-00',publisheddate,planneddate) DESC"; @@ -756,7 +759,8 @@ sub GetSerials { } # OK, now add the last 5 issues arrives/missing - $query = "SELECT serialid,serialseq, status, planneddate, publisheddate,notes, routingnotes + $query = "SELECT serialid,serialseq, status, planneddate, publisheddate, + publisheddatetext, notes, routingnotes FROM serial WHERE subscriptionid = ? AND (status in (2,4,5)) @@ -798,7 +802,8 @@ sub GetSerials2 { my ( $subscription, $status ) = @_; my $dbh = C4::Context->dbh; my $query = qq| - SELECT serialid,serialseq, status, planneddate, publisheddate,notes, routingnotes + SELECT serialid,serialseq, status, planneddate, publisheddate, + publisheddatetext, notes, routingnotes FROM serial WHERE subscriptionid=$subscription AND status IN ($status) ORDER BY publisheddate,serialid DESC @@ -1094,7 +1099,8 @@ sub ModSubscriptionHistory { =head2 ModSerialStatus -ModSerialStatus($serialid,$serialseq, $planneddate,$publisheddate,$status,$notes) + ModSerialStatus($serialid, $serialseq, $planneddate, $publisheddate, + $publisheddatetext, $status, $notes); This function modify the serial status. Serial status is a number.(eg 2 is "arrived") Note : if we change from "waited" to something else,then we will have to create a new "waited" entry @@ -1102,7 +1108,8 @@ Note : if we change from "waited" to something else,then we will have to create =cut sub ModSerialStatus { - my ( $serialid, $serialseq, $planneddate, $publisheddate, $status, $notes ) = @_; + my ($serialid, $serialseq, $planneddate, $publisheddate, $publisheddatetext, + $status, $notes) = @_; #It is a usual serial # 1st, get previous status : @@ -1118,10 +1125,15 @@ sub ModSerialStatus { DelIssue( {'serialid'=>$serialid, 'subscriptionid'=>$subscriptionid,'serialseq'=>$serialseq} ); } else { - my $query = -'UPDATE serial SET serialseq=?,publisheddate=?,planneddate=?,status=?,notes=? WHERE serialid = ?'; + my $query = ' + UPDATE serial + SET serialseq = ?, publisheddate = ?, publisheddatetext = ?, + planneddate = ?, status = ?, notes = ? + WHERE serialid = ? + '; $sth = $dbh->prepare($query); - $sth->execute( $serialseq, $publisheddate, $planneddate, $status, $notes, $serialid ); + $sth->execute( $serialseq, $publisheddate, $publisheddatetext, + $planneddate, $status, $notes, $serialid ); $query = "SELECT * FROM subscription WHERE subscriptionid = ?"; $sth = $dbh->prepare($query); $sth->execute($subscriptionid); @@ -1477,17 +1489,19 @@ returns the serial id =cut sub NewIssue { - my ( $serialseq, $subscriptionid, $biblionumber, $status, $planneddate, $publisheddate, $notes ) = @_; + my ( $serialseq, $subscriptionid, $biblionumber, $status, $planneddate, + $publisheddate, $publisheddatetext, $notes ) = @_; ### FIXME biblionumber CAN be provided by subscriptionid. So Do we STILL NEED IT ? my $dbh = C4::Context->dbh; my $query = qq| - INSERT INTO serial - (serialseq,subscriptionid,biblionumber,status,publisheddate,planneddate,notes) - VALUES (?,?,?,?,?,?,?) + INSERT INTO serial (serialseq, subscriptionid, biblionumber, status, + publisheddate, publisheddatetext, planneddate, notes) + VALUES (?,?,?,?,?,?,?,?) |; my $sth = $dbh->prepare($query); - $sth->execute( $serialseq, $subscriptionid, $biblionumber, $status, $publisheddate, $planneddate, $notes ); + $sth->execute( $serialseq, $subscriptionid, $biblionumber, $status, + $publisheddate, $publisheddatetext, $planneddate, $notes ); my $serialid = $dbh->{'mysql_insertid'}; $query = qq| SELECT missinglist,recievedlist diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index fdab879..4cde92e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1902,6 +1902,7 @@ CREATE TABLE `serial` ( `planneddate` date default NULL, `notes` text, `publisheddate` date default NULL, + publisheddatetext varchar(100) default NULL, `claimdate` date default NULL, `routingnotes` text, PRIMARY KEY (`serialid`) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 31f494a..9fa4f17 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7139,6 +7139,19 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do(" + ALTER TABLE serial + ADD COLUMN publisheddatetext VARCHAR(100) DEFAULT NULL + AFTER publisheddate + "); + + print "Upgrade to $DBversion done (Add serial.publisheddatetext)\n"; + SetVersion($DBversion); +} + + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt index 668fa38..243d39c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt @@ -256,6 +256,8 @@ $(document).ready(function() { [% END %] Date published + Date published (text) + Date received Number @@ -296,6 +298,10 @@ $(document).ready(function() { [% serial.publisheddate | $KohaDates %] + [% publisheddatetext = serial.publisheddatetext || serial.publisheddate %] + [% publisheddatetext | $KohaDates %] + + [% serial.planneddate | $KohaDates %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt index 8f9ea5f..5fad438 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt @@ -142,6 +142,7 @@ $(document).ready(function() { Numbered Published on + Published on (text) Expected on Status Notes @@ -163,6 +164,9 @@ $(document).ready(function() { + + + @@ -282,6 +286,9 @@ $(document).ready(function() { + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt index 959f14f..e9c649b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt @@ -332,6 +332,7 @@ $(document).ready(function() { Issue number Planned date Published date + Published date (text) Status [% FOREACH serialslis IN serialslist %] @@ -346,6 +347,9 @@ $(document).ready(function() { [% serialslis.publisheddate %] + [% serialslis.publisheddatetext || serialslis.publisheddate %] + + [% IF ( serialslis.status1 ) %]Expected[% END %] [% IF ( serialslis.status2 ) %]Arrived[% END %] [% IF ( serialslis.status3 ) %]Late[% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-full-serial-issues.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-full-serial-issues.tt index e0fb803..884bfb2 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-full-serial-issues.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-full-serial-issues.tt @@ -188,6 +188,7 @@ function showlayer(numlayer){ Date + Date (text) Library Notes Date received @@ -206,6 +207,7 @@ function showlayer(numlayer){   [% END %] + [% serial.publisheddatetext || serial.publisheddate %] [% serial.branchcode %] [% serial.notes %] diff --git a/misc/cronjobs/serialsUpdate.pl b/misc/cronjobs/serialsUpdate.pl index a5a376f..22ecf7d 100755 --- a/misc/cronjobs/serialsUpdate.pl +++ b/misc/cronjobs/serialsUpdate.pl @@ -83,7 +83,7 @@ while ( my $issue = $sth->fetchrow_hashref ) { { ModSerialStatus( $issue->{serialid}, $issue->{serialseq}, - $issue->{planneddate}, $issue->{publisheddate}, + $issue->{planneddate}, $issue->{publisheddate}, $issue->{publisheddatetext}, 3, "Automatically set to late" ); print $issue->{serialid}." update\n"; } diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index 7428494..c919535 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -56,8 +56,12 @@ my $subscriptions; if($op eq 'gennext' && @subscriptionid){ my $subscriptionid = $subscriptionid[0]; - my $sth = $dbh->prepare("SELECT publisheddate, serialid, serialseq, planneddate - FROM serial WHERE status = 1 AND subscriptionid = ?"); + my $sth = $dbh->prepare(" + SELECT publisheddate, publisheddatetext, serialid, serialseq, + planneddate + FROM serial + WHERE status = 1 AND subscriptionid = ? + "); my $status = defined( $nbissues ) ? 2 : 3; $nbissues ||= 1; for ( my $i = 0; $i < $nbissues; $i++ ){ @@ -66,7 +70,7 @@ if($op eq 'gennext' && @subscriptionid){ if ( my $issue = $sth->fetchrow_hashref ) { ModSerialStatus( $issue->{serialid}, $issue->{serialseq}, $issue->{planneddate}, $issue->{publisheddate}, - $status, "" ); + $issue->{publisheddatetext}, $status, "" ); }else{ my $subscription = GetSubscription($subscriptionid); my $expected = GetNextExpected($subscriptionid); diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 34f1031..407d0d2 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -81,6 +81,8 @@ my @serialids = $query->param('serialid'); my @serialseqs = $query->param('serialseq'); my @planneddates = $query->param('planneddate'); my @publisheddates = $query->param('publisheddate'); +my @publisheddates = $query->param('publisheddate'); +my @publisheddatetexts = $query->param('publisheddatetext'); my @status = $query->param('status'); my @notes = $query->param('notes'); my @subscriptionids = $query->param('subscriptionid'); @@ -227,6 +229,7 @@ if ( $op and $op eq 'serialchangestatus' ) { $status[$i], $plan_date, $pub_date, + $publisheddatetexts[$i], $notes[$i] ); } @@ -237,6 +240,7 @@ if ( $op and $op eq 'serialchangestatus' ) { $serialseqs[$i], $plan_date, $pub_date, + $publisheddatetexts[$i], $status[$i], $notes[$i] ); -- 1.7.10.4