@@ -, +, @@
dates in the future.
- Create and edit subscriptions with valid dates, verify that subscriptions are
correctly defined
- Bypass datepickers by manually entering dates like 00/00/0000 or 33/33/2999, verify
that subscriptions are saved, but a warning appears on the subscription's detail
page.
---
.../prog/en/modules/serials/subscription-detail.tt | 3 ++
serials/subscription-add.pl | 45 +++++++++++++++-----
2 files changed, 38 insertions(+), 10 deletions(-)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
@@ -43,6 +43,9 @@ $(document).ready(function() {
[% INCLUDE 'serials-toolbar.inc' %]
Subscription for [% bibliotitle%] [% IF closed %](closed)[% END %]
+ [% IF ! (startdate && enddate) %]
+ Startdate and/or enddate not properly defined. Please edit subscription to define them.
+ [% END %]
[% IF ( abouttoexpire ) %]
[% UNLESS closed %]
--- a/serials/subscription-add.pl
+++ a/serials/subscription-add.pl
@@ -15,6 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see .
+# FIXME: Processing of invalid dates (00/00/0000 or 33/33/2999) needs
+# some more attention. At the moment subscription will be saved with
+# empty dates, subscription detail page will display a warning if
+# startdate and/or enddate are empty.
+
use strict;
use warnings;
@@ -324,22 +329,40 @@ sub redirect_add_subscription {
my $skip_serialseq = $query->param('skip_serialseq');
my $startdate = $query->param('startdate');
- $startdate = eval { dt_from_string( $startdate ); } if ( $startdate );
- $startdate = output_pref( { dt => $startdate, dateonly => 1, dateformat => 'iso' } ) if ( $startdate );
+ my $startdate_dt = eval { dt_from_string( $startdate ); } if ( $startdate );
+ if ( $startdate_dt ) {
+ $startdate = output_pref( { dt => $startdate_dt, dateonly => 1, dateformat => 'iso' } );
+ }
+ else {
+ $startdate = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
+ }
my $enddate = $query->param('enddate');
- $enddate = eval { dt_from_string( $enddate ); } if ( $enddate );
- $enddate = output_pref( { dt => $enddate, dateonly => 1, dateformat => 'iso' } ) if ( $enddate );
+ my $enddate_dt = eval { dt_from_string( $enddate ); } if ( $enddate );
+ if ( $enddate_dt ) {
+ $enddate = output_pref( { dt => $enddate_dt, dateonly => 1, dateformat => 'iso' } );
+ }
+ else {
+ $enddate = undef;
+ }
+
my $firstacquidate = $query->param('firstacquidate');
- $firstacquidate = eval { dt_from_string( $firstacquidate ); } if ( $firstacquidate );
- $firstacquidate = output_pref( { dt => $enddate, dateonly => 1, dateformat => 'iso' } ) if ( $firstacquidate );
+ my $firstacquidate_dt = eval { dt_from_string( $firstacquidate ); } if ( $firstacquidate );
+ if ($firstacquidate_dt ) {
+ $firstacquidate = output_pref( { dt => $firstacquidate_dt, dateonly => 1, dateformat => 'iso' } );
+ }
+ else {
+ $firstacquidate = undef;
+ }
if(!defined $enddate || $enddate eq '') {
if($subtype eq "issues") {
- $enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
+ $enddate = eval { _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength); };
} else {
- $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
+ $enddate = eval { _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength); };
}
+ #FIXME We set $enddate to empty string if there was a problem with guessing;
+ $enddate = '';
}
my $subscriptionid = NewSubscription(
@@ -418,10 +441,12 @@ sub redirect_mod_subscription {
# Guess end date
if(!defined $enddate || $enddate eq '') {
if($subtype eq "issues") {
- $enddate = _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
+ $enddate = eval { _guess_enddate($nextacquidate, $periodicity, $numberlength, $weeklength, $monthlength); };
} else {
- $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
+ $enddate = eval {_guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength); };
}
+ #FIXME We set $enddate totoday if it is empty;
+ $enddate = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) unless ( $enddate );
}
my $nextexpected = GetNextExpected($subscriptionid);
--