From 5fe8f0216c8e5d8a145604f958466932529367d3 Mon Sep 17 00:00:00 2001
From: Jonathan Druart
Date: Wed, 11 Nov 2015 10:48:36 +0000
Subject: [PATCH] Bug 14969: Remove C4::Dates from serials/*.pl files
Warning: This area is a mess, especially with date management.
For the same reasons as other "Remove C4::Dates from*" patches, this one
will deal with the serials module.
Note that this patch add the datepicker on 3 input fields (on
serials/subscription-detail.tt and serials/subscription-renew.tt).
There was also weird behavior when the dates were invalid. Now default
to undefined. But with the datepicker it will reduce the number of
cases even if the user is still allowed to fill invalid dates.
Test plan:
1/ Create a subscription, fill the first issue pub date and the
subscription start date.
You can fill or not the end date.
Play with the numbering pattern and confirm that there are generated as
before this patch.
2/ On the check expiration page, confirm that the dates are correctly
displayed.
3/ Renew the subscription and confirm that the behavior is correct.
4/ Go on the subscription history page and confirm you have now the
datepicker plugin set on the 2 date fields.
QA notes: The startdate, histstartdate and enddate are not used in
the serials-collection template, this patch removes them from the pl
script.
---
C4/Serials.pm | 24 ++++++++---------
.../prog/en/modules/serials/checkexpiration.tt | 7 ++---
.../en/modules/serials/subscription-history.tt | 11 ++++++--
.../prog/en/modules/serials/subscription-renew.tt | 8 +++++-
serials/checkexpiration.pl | 22 ++++++++++------
serials/routing-preview.pl | 1 -
serials/routing.pl | 1 -
serials/serial-issues.pl | 1 -
serials/serials-collection.pl | 11 ++------
serials/serials-edit.pl | 15 ++++++-----
serials/showpredictionpattern.pl | 15 ++++-------
serials/subscription-add.pl | 30 +++++++++++++---------
serials/subscription-detail.pl | 5 ++--
serials/subscription-history.pl | 9 ++++---
serials/subscription-renew.pl | 15 ++++++-----
15 files changed, 95 insertions(+), 80 deletions(-)
diff --git a/C4/Serials.pm b/C4/Serials.pm
index 5f348ce..37e7c16 100644
--- a/C4/Serials.pm
+++ b/C4/Serials.pm
@@ -22,7 +22,6 @@ use Modern::Perl;
use C4::Auth qw(haspermission);
use C4::Context;
-use C4::Dates qw(format_date format_date_in_iso);
use DateTime;
use Date::Calc qw(:all);
use POSIX qw(strftime);
@@ -32,6 +31,7 @@ use C4::Debug;
use C4::Serials::Frequency;
use C4::Serials::Numberpattern;
use Koha::AdditionalField;
+use Koha::DateUtils;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@@ -467,9 +467,9 @@ sub GetSubscriptionsFromBiblionumber {
$sth->execute($biblionumber);
my @res;
while ( my $subs = $sth->fetchrow_hashref ) {
- $subs->{startdate} = format_date( $subs->{startdate} );
- $subs->{histstartdate} = format_date( $subs->{histstartdate} );
- $subs->{histenddate} = format_date( $subs->{histenddate} );
+ $subs->{startdate} = output_pref( { dt => dt_from_string( $subs->{startdate} ), dateonly => 1 } );
+ $subs->{histstartdate} = output_pref( { dt => dt_from_string( $subs->{histstartdate} ), dateonly => 1 } );
+ $subs->{histenddate} = output_pref( { dt => dt_from_string( $subs->{histenddate} ), dateonly => 1 } );
$subs->{opacnote} =~ s/\n/\ /g;
$subs->{missinglist} =~ s/\n/\ /g;
$subs->{recievedlist} =~ s/\n/\ /g;
@@ -480,7 +480,7 @@ sub GetSubscriptionsFromBiblionumber {
if ( $subs->{enddate} eq '0000-00-00' ) {
$subs->{enddate} = '';
} else {
- $subs->{enddate} = format_date( $subs->{enddate} );
+ $subs->{enddate} = output_pref( { dt => dt_from_string( $subs->{enddate}), dateonly => 1 } );
}
$subs->{'abouttoexpire'} = abouttoexpire( $subs->{'subscriptionid'} );
$subs->{'subscriptionexpired'} = HasSubscriptionExpired( $subs->{'subscriptionid'} );
@@ -710,7 +710,7 @@ sub GetSerials {
$line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list
for my $datefield ( qw( planneddate publisheddate) ) {
if ($line->{$datefield} && $line->{$datefield}!~m/^00/) {
- $line->{$datefield} = format_date( $line->{$datefield});
+ $line->{$datefield} = output_pref( { dt => dt_from_string( $line->{$datefield} ), dateonly => 1 } );
} else {
$line->{$datefield} = q{};
}
@@ -733,7 +733,7 @@ sub GetSerials {
$line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list
for my $datefield ( qw( planneddate publisheddate) ) {
if ($line->{$datefield} && $line->{$datefield}!~m/^00/) {
- $line->{$datefield} = format_date( $line->{$datefield});
+ $line->{$datefield} = output_pref( { dt => dt_from_string( $line->{$datefield} ), dateonly => 1 } );
} else {
$line->{$datefield} = q{};
}
@@ -788,7 +788,7 @@ sub GetSerials2 {
$line->{$datefield} = q{};
}
else {
- $line->{$datefield} = format_date( $line->{$datefield} );
+ $line->{$datefield} = output_pref( { dt => dt_from_string( $line->{$datefield} ), dateonly => 1 } );
}
}
push @serials, $line;
@@ -824,8 +824,8 @@ sub GetLatestSerials {
my @serials;
while ( my $line = $sth->fetchrow_hashref ) {
$line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list
- $line->{"planneddate"} = format_date( $line->{"planneddate"} );
- $line->{"publisheddate"} = format_date( $line->{"publisheddate"} );
+ $line->{planneddate} = output_pref( { dt => dt_from_string( $line->{planneddate} ), dateonly => 1 } );
+ $line->{publisheddate} = output_pref( { dt => dt_from_string( $line->{publisheddate} ), dateonly => 1 } );
push @serials, $line;
}
@@ -1848,11 +1848,11 @@ sub GetLateOrMissingIssues {
if ($line->{planneddate} && $line->{planneddate} !~/^0+\-/) {
$line->{planneddateISO} = $line->{planneddate};
- $line->{planneddate} = format_date( $line->{planneddate} );
+ $line->{planneddate} = output_pref( { dt => dt_from_string( $line->{"planneddate"} ), dateonly => 1 } );
}
if ($line->{claimdate} && $line->{claimdate} !~/^0+\-/) {
$line->{claimdateISO} = $line->{claimdate};
- $line->{claimdate} = format_date( $line->{claimdate} );
+ $line->{claimdate} = output_pref( { dt => dt_from_string( $line->{"claimdate"} ), dateonly => 1 } );
}
$line->{"status".$line->{status}} = 1;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt
index e41d5c3..657f91d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt
@@ -1,3 +1,4 @@
+[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
Koha › Serials › Check expiration
[% INCLUDE 'doc-head-close.inc' %]
@@ -70,7 +71,7 @@
[% END %]
-
+
Required
[% INCLUDE 'date-format.inc' %]
@@ -89,7 +90,7 @@
[% IF ( issn ) %]
with ISSN matching [% issn %]
[% END %]
- will expire before [% date %]
+ will expire before [% date | $KohaDates %]