From 018de8802d1aa8af9e309187c210f2036957e10a 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
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
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.
Tested on top of 15166 15168 15171, full browser reload for date pickers.
Note for 4/: It is the link in tab planning on subscription
detail page, near "Manual history" (if manual history is enabled).
Works as advertised.
Signed-off-by: Marc Véron
Signed-off-by: Katrin Fischer
Signed-off-by: Tomas Cohen Arazi
---
C4/Serials.pm | 24 +++++++--------
.../en/modules/serials/checkexpiration.tt | 7 +++--
.../modules/serials/subscription-history.tt | 11 +++++--
.../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 5f348ce0a4..37e7c1602e 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 e41d5c3793..657f91d232 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 %]
Expiring before:
-
+
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 %]
@@ -127,7 +128,7 @@
[% subscriptions_loo.internalnotes %]
- [% subscriptions_loo.expirationdate %]
+ [% subscriptions_loo.expirationdate | $KohaDates %]
Edit
Renew
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt
index 5213b3d43e..cbfb0a5044 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt
@@ -3,6 +3,7 @@
[% INCLUDE 'doc-head-open.inc' %]
Koha › Serials › Subscription history
[% INCLUDE 'doc-head-close.inc' %]
+[% INCLUDE 'calendar.inc' %]
@@ -25,11 +26,17 @@
Subscription start date
- (start date of the 1st subscription)
+
+ (start date of the 1st subscription)
+ [% INCLUDE 'date-format.inc' %]
+
Subscription end date
- (if empty, subscription is still active)
+
+ (if empty, subscription is still active)
+ [% INCLUDE 'date-format.inc' %]
+
Received issues
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt
index a38f791740..e7eb83def4 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt
@@ -1,6 +1,7 @@
[% INCLUDE 'doc-head-open.inc' %]
Koha › Serials subscription renew #[% subscriptionid %]
[% INCLUDE 'doc-head-close.inc' %]
+[% INCLUDE 'calendar.inc' %]
@@ -23,7 +24,12 @@
Subscription renewal for [% bibliotitle %]
- Start date:
+
+
+ Start date:
+
+ [% INCLUDE 'date-format.inc' %]
+
Subscription length:
Number of num:
diff --git a/serials/checkexpiration.pl b/serials/checkexpiration.pl
index 11d1714fbf..3222e22c9f 100755
--- a/serials/checkexpiration.pl
+++ b/serials/checkexpiration.pl
@@ -50,8 +50,9 @@ use C4::Serials; # GetExpirationDate
use C4::Branch;
use C4::Output;
use C4::Context;
-use C4::Dates qw/format_date format_date_in_iso/;
-use Date::Calc qw/Date_to_Days/;
+use Koha::DateUtils;
+
+use DateTime;
my $query = new CGI;
@@ -69,7 +70,8 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user (
my $title = $query->param('title');
my $issn = $query->param('issn');
my $branch = $query->param('branch');
-my $date = format_date_in_iso($query->param('date'));
+my $date = $query->param('date');
+$date = eval { dt_from_string( $query->param('date') ) } if $date;
if ($date) {
my @subscriptions = SearchSubscriptions({ title => $title, issn => $issn, orderby => 'title' });
@@ -78,8 +80,11 @@ if ($date) {
foreach my $subscription ( @subscriptions ) {
my $subscriptionid = $subscription->{'subscriptionid'};
my $expirationdate = GetExpirationDate($subscriptionid);
+
$subscription->{expirationdate} = $expirationdate;
+
next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in ISO format.
+
next if $subscription->{closed};
if ( !C4::Context->preference("IndependentBranches")
or C4::Context->IsSuperLibrarian()
@@ -89,10 +94,11 @@ if ($date) {
$subscription->{cannotedit} = 0;
}
next if $subscription->{cannotedit};
- if ( Date_to_Days(split "-",$expirationdate) < Date_to_Days(split "-",$date) &&
- ( !$branch || ($subscription->{'branchcode'} eq $branch) ) ) {
- $subscription->{expirationdate}=format_date($subscription->{expirationdate});
- push @subscriptions_loop,$subscription;
+
+ my $expirationdate_dt = dt_from_string( $expirationdate, 'iso' );
+ if ( DateTime->compare( $date, $expirationdate_dt ) == 1
+ && ( !$branch || ( $subscription->{'branchcode'} eq $branch ) ) ) {
+ push @subscriptions_loop, $subscription;
}
}
@@ -100,7 +106,7 @@ if ($date) {
title => $title,
issn => $issn,
numsubscription => scalar @subscriptions_loop,
- date => format_date($date),
+ date => $date,
subscriptions_loop => \@subscriptions_loop,
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
searched => 1,
diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl
index 13bca6c2a5..bed5091458 100755
--- a/serials/routing-preview.pl
+++ b/serials/routing-preview.pl
@@ -23,7 +23,6 @@ use warnings;
use CGI qw ( -utf8 );
use C4::Koha;
use C4::Auth;
-use C4::Dates;
use C4::Output;
use C4::Acquisition;
use C4::Reserves;
diff --git a/serials/routing.pl b/serials/routing.pl
index 8f9cb6baff..32f42e52ab 100755
--- a/serials/routing.pl
+++ b/serials/routing.pl
@@ -30,7 +30,6 @@ use warnings;
use CGI qw ( -utf8 );
use C4::Koha;
use C4::Auth;
-use C4::Dates;
use C4::Output;
use C4::Acquisition;
use C4::Output;
diff --git a/serials/serial-issues.pl b/serials/serial-issues.pl
index 12d7f90dce..c5bfbca686 100755
--- a/serials/serial-issues.pl
+++ b/serials/serial-issues.pl
@@ -46,7 +46,6 @@ use warnings;
use CGI qw ( -utf8 );
use C4::Auth;
use C4::Koha;
-use C4::Dates;
use C4::Serials;
use C4::Output;
use C4::Context;
diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl
index aef46045a1..0ee32defbd 100755
--- a/serials/serials-collection.pl
+++ b/serials/serials-collection.pl
@@ -24,11 +24,11 @@ use warnings;
use CGI qw ( -utf8 );
use C4::Auth;
use C4::Koha;
-use C4::Dates qw/format_date/;
use C4::Serials;
use C4::Letters;
use C4::Output;
use C4::Context;
+
use List::MoreUtils qw/uniq/;
@@ -114,15 +114,8 @@ if (@subscriptionid){
$subs->{opacnote} =~ s/\n/\ /g;
$subs->{missinglist} =~ s/\n/\ /g;
$subs->{recievedlist} =~ s/\n/\ /g;
+
##these are display information
- $subs->{startdate} = format_date( $subs->{startdate} );
- $subs->{histstartdate} = format_date( $subs->{histstartdate} );
- if ( !defined $subs->{enddate} || $subs->{enddate} eq '0000-00-00' ) {
- $subs->{enddate} = '';
- }
- else {
- $subs->{enddate} = format_date( $subs->{enddate} );
- }
$subs->{'abouttoexpire'}=abouttoexpire($subs->{'subscriptionid'});
$subs->{'subscriptionexpired'}=HasSubscriptionExpired($subs->{'subscriptionid'});
$subs->{'subscriptionid'} = $subscriptionid; # FIXME - why was this lost ?
diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl
index 9b6f5d08d1..efd9c78295 100755
--- a/serials/serials-edit.pl
+++ b/serials/serials-edit.pl
@@ -66,7 +66,6 @@ use warnings;
use CGI qw ( -utf8 );
use Encode qw( decode is_utf8 );
use C4::Auth;
-use C4::Dates qw/format_date format_date_in_iso/;
use C4::Biblio;
use C4::Items;
use C4::Koha;
@@ -74,6 +73,8 @@ use C4::Output;
use C4::Context;
use C4::Serials;
use C4::Search qw/enabled_staff_search_views/;
+use Koha::DateUtils;
+
use List::MoreUtils qw/uniq/;
my $query = CGI->new();
@@ -127,7 +128,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my @serialdatalist;
my %processedserialid;
-my $today = C4::Dates->new();
+my $today = output_pref( dt_from_string );
foreach my $serialid (@serialids) {
#filtering serialid for duplication
@@ -143,10 +144,10 @@ foreach my $serialid (@serialids) {
$serinfo->{$d} = q{};
}
else {
- $serinfo->{$d} = format_date( $serinfo->{$d} );
+ $serinfo->{$d} = output_pref( { dt => dt_from_string( $serinfo->{$d} ), dateonly => 1 } );
}
}
- $serinfo->{arriveddate}=$today->output('syspref');
+ $serinfo->{arriveddate} = $today;
$serinfo->{'editdisable'} = (
(
@@ -187,7 +188,7 @@ foreach my $subscriptionid (@subscriptionids) {
$cell->{'itemid'} = 'NNEW';
$cell->{'serialid'} = 'NEW';
$cell->{'issuesatonce'} = 1;
- $cell->{arriveddate}=$today->output('syspref');
+ $cell->{arriveddate} = $today;
push @newserialloop, $cell;
push @subscriptionloop,
@@ -214,10 +215,10 @@ if ( $op and $op eq 'serialchangestatus' ) {
my ($plan_date, $pub_date);
if (defined $planneddates[$i] && $planneddates[$i] ne 'XXX') {
- $plan_date = format_date_in_iso( $planneddates[$i] );
+ $plan_date = eval { output_pref( { dt => dt_from_string( $planneddates[$i] ), dateonly => 1, dateformat => 'iso' } ); };
}
if (defined $publisheddates[$i] && $publisheddates[$i] ne 'XXX') {
- $pub_date = format_date_in_iso( $publisheddates[$i] );
+ $pub_date = eval { output_pref( { dt => dt_from_string( $publisheddates[$i] ), dateonly => 1, dateformat => 'iso' } ); };
}
if ( $serialids[$i] && $serialids[$i] eq 'NEW' ) {
diff --git a/serials/showpredictionpattern.pl b/serials/showpredictionpattern.pl
index 6945a36e83..add9f06b36 100755
--- a/serials/showpredictionpattern.pl
+++ b/serials/showpredictionpattern.pl
@@ -36,6 +36,7 @@ use C4::Auth;
use C4::Output;
use C4::Serials;
use C4::Serials::Frequency;
+use Koha::DateUtils;
my $input = new CGI;
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
@@ -76,19 +77,13 @@ my %pattern = (
every3 => $input->param('every3') // '',
);
-if(!defined $firstacquidate || $firstacquidate eq ''){
- my ($year, $month, $day) = Today();
- $firstacquidate = sprintf "%04d-%02d-%02d", $year, $month, $day;
-} else {
- $firstacquidate = C4::Dates->new($firstacquidate)->output('iso');
-}
+$firstacquidate = eval { output_pref( { str => $firstacquidate, dateonly => 1, dateformat => 'iso' } ); }
+ or output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
-if($enddate){
- $enddate = C4::Dates->new($enddate)->output('iso');
-}
+$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); };
if($nextacquidate) {
- $nextacquidate = C4::Dates->new($nextacquidate)->output('iso');
+ $nextacquidate = eval { output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } ); };
} else {
$nextacquidate = $firstacquidate;
}
diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl
index fedb7dafd0..1790866856 100755
--- a/serials/subscription-add.pl
+++ b/serials/subscription-add.pl
@@ -23,7 +23,6 @@ use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days Add_Delta_YM);
use C4::Koha;
use C4::Biblio;
use C4::Auth;
-use C4::Dates qw/format_date format_date_in_iso/;
use C4::Acquisition;
use C4::Output;
use C4::Context;
@@ -33,6 +32,7 @@ use C4::Serials::Frequency;
use C4::Serials::Numberpattern;
use C4::Letters;
use Koha::AdditionalField;
+use Koha::DateUtils;
use Carp;
#use Smart::Comments;
@@ -322,14 +322,16 @@ sub redirect_add_subscription {
my $opacdisplaycount = $query->param('opacdisplaycount');
my $location = $query->param('location');
my $skip_serialseq = $query->param('skip_serialseq');
- my $startdate = format_date_in_iso( $query->param('startdate') );
- my $enddate = format_date_in_iso( $query->param('enddate') );
- my $firstacquidate = format_date_in_iso($query->param('firstacquidate'));
+
+ my $startdate = output_pref( { str => $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
+ my $enddate = output_pref( { str => $query->param('enddate'), dateonly => 1, dateformat => 'iso' } );
+ my $firstacquidate = output_pref( { str => $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
+
if(!defined $enddate || $enddate eq '') {
if($subtype eq "issues") {
- $enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
+ $enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength)
} else {
- $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
+ $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength)
}
}
@@ -361,12 +363,16 @@ sub redirect_mod_subscription {
my $aqbooksellerid = $query->param('aqbooksellerid');
my $biblionumber = $query->param('biblionumber');
my $aqbudgetid = $query->param('aqbudgetid');
- my $startdate = format_date_in_iso($query->param('startdate'));
- my $firstacquidate = format_date_in_iso( $query->param('firstacquidate') );
- my $nextacquidate = $query->param('nextacquidate') ?
- format_date_in_iso($query->param('nextacquidate')):
- $firstacquidate;
- my $enddate = format_date_in_iso($query->param('enddate'));
+
+ my $startdate = output_pref( { str => $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
+ my $enddate = output_pref( { str => $query->param('enddate'), dateonly => 1, dateformat => 'iso' } );
+ my $firstacquidate = output_pref( { str => $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
+
+ my $nextacquidate = $query->param('nextacquidate');
+ $nextacquidate = $nextacquidate
+ ? output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } )
+ : $firstacquidate;
+
my $periodicity = $query->param('frequency');
my $subtype = $query->param('subtype');
diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl
index 45ce5b07a6..824ffc2473 100755
--- a/serials/subscription-detail.pl
+++ b/serials/subscription-detail.pl
@@ -21,11 +21,11 @@ use C4::Acquisition;
use C4::Auth;
use C4::Budgets;
use C4::Koha;
-use C4::Dates qw/format_date/;
use C4::Serials;
use C4::Output;
use C4::Context;
use C4::Search qw/enabled_staff_search_views/;
+use Koha::DateUtils;
use Koha::Acquisition::Bookseller;
@@ -100,7 +100,8 @@ my $hasRouting = check_routing($subscriptionid);
# COMMENT hdl : IMHO, we should think about passing more and more data hash to template->param rather than duplicating code a new coding Guideline ?
for my $date ( qw(startdate enddate firstacquidate histstartdate histenddate) ) {
- $$subs{$date} = format_date($$subs{$date}) if $date && $$subs{$date};
+ $subs->{$date} = output_pref( { str => $subs->{$date}, dateonly => 1 } )
+ if $subs->{$date};
}
$subs->{location} = GetKohaAuthorisedValueLib("LOC",$subs->{location});
$subs->{abouttoexpire} = abouttoexpire($subs->{subscriptionid});
diff --git a/serials/subscription-history.pl b/serials/subscription-history.pl
index 267afcb500..8b7dd3dada 100755
--- a/serials/subscription-history.pl
+++ b/serials/subscription-history.pl
@@ -34,8 +34,8 @@ use C4::Auth;
use C4::Output;
use C4::Biblio;
-use C4::Dates qw(format_date_in_iso);
use C4::Serials;
+use Koha::DateUtils;
my $input = new CGI;
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
@@ -63,9 +63,10 @@ if($op && $op eq 'mod') {
my $opacnote = $input->param('opacnote');
my $librariannote = $input->param('librariannote');
- ModSubscriptionHistory( $subscriptionid, format_date_in_iso($histstartdate),
- format_date_in_iso($histenddate), $receivedlist, $missinglist, $opacnote,
- $librariannote );
+ $histstartdate = output_pref( { str => $histstartdate, dateonly => 1, dateformat => 'iso' } );
+ $histenddate = output_pref( { str => $histenddate, dateonly => 1, dateformat => 'iso' } );
+
+ ModSubscriptionHistory( $subscriptionid, $histstartdate, $histenddate, $receivedlist, $missinglist, $opacnote, $librariannote );
print $input->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
exit;
diff --git a/serials/subscription-renew.pl b/serials/subscription-renew.pl
index 9f3b934d6e..226a3878fa 100755
--- a/serials/subscription-renew.pl
+++ b/serials/subscription-renew.pl
@@ -50,11 +50,11 @@ use CGI qw ( -utf8 );
use Carp;
use C4::Koha;
use C4::Auth;
-use C4::Dates qw/format_date/;
use C4::Context;
use C4::Auth;
use C4::Output;
use C4::Serials;
+use Koha::DateUtils;
my $query = new CGI;
my $dbh = C4::Context->dbh;
@@ -74,9 +74,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
if ( $op eq "renew" ) {
+ my $startdate = output_pref( { str => $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
ReNewSubscription(
- $subscriptionid, $loggedinuser,
- C4::Dates->new($query->param('startdate'))->output('iso'), $query->param('numberlength'),
+ $subscriptionid, $loggedinuser,
+ $startdate, $query->param('numberlength'),
$query->param('weeklength'), $query->param('monthlength'),
$query->param('note')
);
@@ -88,11 +89,11 @@ if ($subscription->{'cannotedit'}){
print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
}
+my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } )
+ or output_pref( { dt => dt_from_string, dateonly => 1 } );
+
$template->param(
- startdate => format_date(
- $subscription->{enddate}
- || POSIX::strftime( "%Y-%m-%d", localtime )
- ),
+ startdate => $newstartdate,
numberlength => $subscription->{numberlength},
weeklength => $subscription->{weeklength},
monthlength => $subscription->{monthlength},
--
2.39.5