# Dates replacement
my $replacedby = defined ($val) ? $val : '';
if ( $replacedby
- and not $replacedby =~ m|0000-00-00|
and not $replacedby =~ m|9999-12-31|
and $replacedby =~ m|^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$| )
{
my $previousnote = "";
foreach my $subs (@{$lines}) {
- for my $datefield ( qw(publisheddate planneddate) ) {
- # handle 0000-00-00 dates
- if (defined $subs->{$datefield} and $subs->{$datefield} =~ m/^00/) {
- $subs->{$datefield} = undef;
- }
- }
$subs->{ "status" . $subs->{'status'} } = 1;
if ( grep { $_ == $subs->{status} } ( EXPECTED, LATE, MISSING_STATUSES, CLAIMED ) ) {
$subs->{"checked"} = 1;
$nextissue = $sth->fetchrow_hashref;
}
foreach(qw/planneddate publisheddate/) {
- if ( !defined $nextissue->{$_} ) {
- # or should this default to 1st Jan ???
- $nextissue->{$_} = strftime( '%Y-%m-%d', localtime );
- }
- $nextissue->{$_} = ($nextissue->{$_} ne '0000-00-00')
- ? $nextissue->{$_}
- : undef;
+ # or should this default to 1st Jan ???
+ $nextissue->{$_} //= strftime( '%Y-%m-%d', localtime );
}
return $nextissue;
}
# filter on date fields
+ my $dtf = Koha::Database->new->schema->storage->datetime_parser;
foreach my $field (qw( suggesteddate manageddate accepteddate )) {
my $from = $field . "_from";
my $to = $field . "_to";
my $from_dt;
$from_dt = eval { dt_from_string( $suggestion->{$from} ) } if ( $suggestion->{$from} );
- my $from_sql = '0000-00-00';
- $from_sql = output_pref({ dt => $from_dt, dateformat => 'iso', dateonly => 1 })
- if ($from_dt);
- $debug && warn "SQL for start date ($field): $from_sql";
- if ( $suggestion->{$from} || $suggestion->{$to} ) {
- push @query, qq{ AND suggestions.$field BETWEEN ? AND ? };
- push @sql_params, $from_sql;
- push @sql_params,
- output_pref({ dt => dt_from_string( $suggestion->{$to} ), dateformat => 'iso', dateonly => 1 }) || output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
+ my $to_dt;
+ $to_dt = eval { dt_from_string( $suggestion->{$to} ) } if ( $suggestion->{$to} );
+ if ( $from_dt ) {
+ push @query, qq{ AND suggestions.$field >= ?};
+ push @sql_params, $dtf->format_date($from_dt);
+ }
+ if ( $to_dt ) {
+ push @query, qq{ AND suggestions.$field <= ?};
+ push @sql_params, $dtf->format_date($to_dt);
}
}
function set_to_today( id, force ) {
/* The force parameter is used in Click but not in Focus ! */
if (! id) { alert(_("Bad id ") + id + _(" sent to set_to_today()")); return 0; }
- if (\$("#" + id).val() == '' || \$("#" + id).val() == '0000-00-00' || force ) {
+ if (\$("#" + id).val() == '' || force ) {
\$("#" + id).val("$date");
}
}
my $today = Date_to_Days(&Today);
while ( my $hold = $holds->next ) {
- next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00');
+ next unless $hold->waitingdate;
my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate);
my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
--- /dev/null
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+
+ eval {
+ local $dbh->{PrintError} = 0;
+ $dbh->do(q|
+ UPDATE aqorders
+ SET datecancellationprinted = NULL
+ WHERE datecancellationprinted = '0000-00-00'
+ |);
+ $dbh->do(q|
+ UPDATE old_issues
+ SET returndate = NULL
+ WHERE returndate = '0000-00-00'
+ |);
+
+ };
+ NewVersion( $DBversion, 7806, "Remove remaining possible 0000-00-00 values");
+}
if ( $formatteddate ) {
$newdata{$_} = $formatteddate;
} else {
- ($userdate eq '0000-00-00') and warn "Data error: $_ is '0000-00-00'";
$template->param( "ERROR_$_" => 1 );
push(@errors,"ERROR_$_");
}
my $subscription = &GetSubscription( $issue->{subscriptionid} );
my $publisheddate = $issue->{publisheddate};
- if ( $subscription && $publisheddate && $publisheddate ne "0000-00-00" ) {
+ if ( $subscription && $publisheddate ) {
my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata );
my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
$emptycol=1 if (!defined($col));
$col = "zzEMPTY" if (!defined($col));
$row = "zzEMPTY" if (!defined($row));
- # fill returndate to avoid an error with date calc (needed for all non returned issues)
- $returndate= join '-',Date::Calc::Today if $returndate eq '0000-00-00';
# DateCalc returns => 0:0:WK:DD:HH:MM:SS the weeks, days, hours, minutes,
# and seconds between the two
$loanlength = Delta_Days(split(/-/,$issuedate),split (/-/,$returndate)) ;
# we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
my $expiry_date = $patron->dateexpiry;
my $expiry = 0; # flag set if patron account has expired
- if ($expiry_date and $expiry_date ne '0000-00-00' and
+ if ($expiry_date and
Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
$expiry = 1;
}
}
my $expiry_date = $enrollment->patron->dateexpiry;
$member->{expiry} = 0; # flag set if patron account has expired
- if ($expiry_date and $expiry_date ne '0000-00-00' and
+ if ($expiry_date and
Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
$member->{expiry} = 1;
}
print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
}
$firstissuedate = $subs->{firstacquidate} || ''; # in iso format.
- for (qw(startdate firstacquidate histstartdate enddate histenddate)) {
- next unless defined $subs->{$_};
- # TODO : Handle date formats properly.
- if ($subs->{$_} eq '0000-00-00') {
- $subs->{$_} = ''
- } else {
- $subs->{$_} = $subs->{$_};
- }
- }
- if (!defined $subs->{letter}) {
- $subs->{letter}= q{};
- }
+ if (!defined $subs->{letter}) {
+ $subs->{letter}= q{};
+ }
my $nextexpected = GetNextExpected($subscriptionid);
$nextexpected->{'isfirstissue'} = $nextexpected->{planneddate} eq $firstissuedate ;
$subs->{nextacquidate} = $nextexpected->{planneddate} if($op eq 'modify');
sub Init{
my $suggestion= shift @_;
# "Managed by" is used only when a suggestion is being edited (not when created)
- if ($suggestion->{'suggesteddate'} eq "0000-00-00" ||$suggestion->{'suggesteddate'} eq "") {
+ if ($suggestion->{'suggesteddate'} eq "") {
# new suggestion
$suggestion->{suggesteddate} = dt_from_string;
$suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'suggestedby'});
# first test with empty expiry date
# note that this expiry date will never lead to an issue btw !!
- $patron->{dateexpiry} = '0000-00-00';
+ $patron->{dateexpiry} = undef;
my $d = C4::Circulation::CalcDateDue( $today, $item->effective_itemtype, $branch->{branchcode}, $patron );
- is( ref $d eq "DateTime" && $d->mdy() =~ /^\d+/, 1, "CalcDateDue with expiry 0000-00-00" );
+ is( ref $d eq "DateTime" && $d->mdy() =~ /^\d+/, 1, "CalcDateDue with expiry undef" );
# second test expiry date==today
my $d2 = output_pref( { dt => $today, dateonly => 1, dateformat => 'sql' } );