View | Details | Raw Unified | Return to bug 7806
Collapse All | Expand All

(-)a/C4/Letters.pm (-1 lines)
Lines 860-866 sub _parseletter { Link Here
860
        # Dates replacement
860
        # Dates replacement
861
        my $replacedby   = defined ($val) ? $val : '';
861
        my $replacedby   = defined ($val) ? $val : '';
862
        if (    $replacedby
862
        if (    $replacedby
863
            and not $replacedby =~ m|0000-00-00|
864
            and not $replacedby =~ m|9999-12-31|
863
            and not $replacedby =~ m|9999-12-31|
865
            and $replacedby =~ m|^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$| )
864
            and $replacedby =~ m|^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$| )
866
        {
865
        {
(-)a/C4/Serials.pm (-13 / +2 lines)
Lines 354-365 sub PrepareSerialsData { Link Here
354
    my $previousnote = "";
354
    my $previousnote = "";
355
355
356
    foreach my $subs (@{$lines}) {
356
    foreach my $subs (@{$lines}) {
357
        for my $datefield ( qw(publisheddate planneddate) ) {
358
            # handle 0000-00-00 dates
359
            if (defined $subs->{$datefield} and $subs->{$datefield} =~ m/^00/) {
360
                $subs->{$datefield} = undef;
361
            }
362
        }
363
        $subs->{ "status" . $subs->{'status'} } = 1;
357
        $subs->{ "status" . $subs->{'status'} } = 1;
364
        if ( grep { $_ == $subs->{status} } ( EXPECTED, LATE, MISSING_STATUSES, CLAIMED ) ) {
358
        if ( grep { $_ == $subs->{status} } ( EXPECTED, LATE, MISSING_STATUSES, CLAIMED ) ) {
365
            $subs->{"checked"} = 1;
359
            $subs->{"checked"} = 1;
Lines 1236-1248 sub GetNextExpected { Link Here
1236
        $nextissue = $sth->fetchrow_hashref;
1230
        $nextissue = $sth->fetchrow_hashref;
1237
    }
1231
    }
1238
    foreach(qw/planneddate publisheddate/) {
1232
    foreach(qw/planneddate publisheddate/) {
1239
        if ( !defined $nextissue->{$_} ) {
1233
        # or should this default to 1st Jan ???
1240
            # or should this default to 1st Jan ???
1234
        $nextissue->{$_} //= strftime( '%Y-%m-%d', localtime );
1241
            $nextissue->{$_} = strftime( '%Y-%m-%d', localtime );
1242
        }
1243
        $nextissue->{$_} = ($nextissue->{$_} ne '0000-00-00')
1244
                         ? $nextissue->{$_}
1245
                         : undef;
1246
    }
1235
    }
1247
1236
1248
    return $nextissue;
1237
    return $nextissue;
(-)a/C4/Suggestions.pm (-9 / +10 lines)
Lines 187-206 sub SearchSuggestion { Link Here
187
    }
187
    }
188
188
189
    # filter on date fields
189
    # filter on date fields
190
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
190
    foreach my $field (qw( suggesteddate manageddate accepteddate )) {
191
    foreach my $field (qw( suggesteddate manageddate accepteddate )) {
191
        my $from = $field . "_from";
192
        my $from = $field . "_from";
192
        my $to   = $field . "_to";
193
        my $to   = $field . "_to";
193
        my $from_dt;
194
        my $from_dt;
194
        $from_dt = eval { dt_from_string( $suggestion->{$from} ) } if ( $suggestion->{$from} );
195
        $from_dt = eval { dt_from_string( $suggestion->{$from} ) } if ( $suggestion->{$from} );
195
        my $from_sql = '0000-00-00';
196
        my $to_dt;
196
        $from_sql = output_pref({ dt => $from_dt, dateformat => 'iso', dateonly => 1 })
197
        $to_dt = eval { dt_from_string( $suggestion->{$to} ) } if ( $suggestion->{$to} );
197
            if ($from_dt);
198
        if ( $from_dt ) {
198
        $debug && warn "SQL for start date ($field): $from_sql";
199
            push @query, qq{ AND suggestions.$field >= ?};
199
        if ( $suggestion->{$from} || $suggestion->{$to} ) {
200
            push @sql_params, $dtf->format_date($from_dt);
200
            push @query, qq{ AND suggestions.$field BETWEEN ? AND ? };
201
        }
201
            push @sql_params, $from_sql;
202
        if ( $to_dt ) {
202
            push @sql_params,
203
            push @query, qq{ AND suggestions.$field <= ?};
203
              output_pref({ dt => dt_from_string( $suggestion->{$to} ), dateformat => 'iso', dateonly => 1 }) || output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
204
            push @sql_params, $dtf->format_date($to_dt);
204
        }
205
        }
205
    }
206
    }
206
207
(-)a/cataloguing/value_builder/dateaccessioned.pl (-1 / +1 lines)
Lines 53-59 function Click$function_name(event) { Link Here
53
function set_to_today( id, force ) {
53
function set_to_today( id, force ) {
54
    /* The force parameter is used in Click but not in Focus ! */
54
    /* The force parameter is used in Click but not in Focus ! */
55
    if (! id) { alert(_("Bad id ") + id + _(" sent to set_to_today()")); return 0; }
55
    if (! id) { alert(_("Bad id ") + id + _(" sent to set_to_today()")); return 0; }
56
    if (\$("#" + id).val() == '' || \$("#" + id).val() == '0000-00-00' || force ) {
56
    if (\$("#" + id).val() == '' || force ) {
57
        \$("#" + id).val("$date");
57
        \$("#" + id).val("$date");
58
    }
58
    }
59
}
59
}
(-)a/circ/waitingreserves.pl (-1 / +1 lines)
Lines 89-95 my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : Link Here
89
my $today = Date_to_Days(&Today);
89
my $today = Date_to_Days(&Today);
90
90
91
while ( my $hold = $holds->next ) {
91
while ( my $hold = $holds->next ) {
92
    next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00');
92
    next unless $hold->waitingdate;
93
93
94
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate);
94
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate);
95
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
95
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
(-)a/installer/data/mysql/atomicupdate/bug_7806.perl (+19 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    eval {
5
        local $dbh->{PrintError} = 0;
6
        $dbh->do(q|
7
            UPDATE aqorders
8
            SET datecancellationprinted = NULL
9
            WHERE datecancellationprinted = '0000-00-00'
10
        |);
11
        $dbh->do(q|
12
            UPDATE old_issues
13
            SET returndate = NULL
14
            WHERE returndate = '0000-00-00'
15
        |);
16
17
    };
18
    NewVersion( $DBversion, 7806, "Remove remaining possible 0000-00-00 values");
19
}
(-)a/members/memberentry.pl (-1 lines)
Lines 210-216 if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) Link Here
210
        if ( $formatteddate ) {
210
        if ( $formatteddate ) {
211
            $newdata{$_} = $formatteddate;
211
            $newdata{$_} = $formatteddate;
212
        } else {
212
        } else {
213
            ($userdate eq '0000-00-00') and warn "Data error: $_ is '0000-00-00'";
214
            $template->param( "ERROR_$_" => 1 );
213
            $template->param( "ERROR_$_" => 1 );
215
            push(@errors,"ERROR_$_");
214
            push(@errors,"ERROR_$_");
216
        }
215
        }
(-)a/misc/cronjobs/serialsUpdate.pl (-1 / +1 lines)
Lines 119-125 while ( my $issue = $sth->fetchrow_hashref ) { Link Here
119
    my $subscription = &GetSubscription( $issue->{subscriptionid} );
119
    my $subscription = &GetSubscription( $issue->{subscriptionid} );
120
    my $publisheddate  = $issue->{publisheddate};
120
    my $publisheddate  = $issue->{publisheddate};
121
121
122
    if ( $subscription && $publisheddate && $publisheddate ne "0000-00-00" ) {
122
    if ( $subscription && $publisheddate ) {
123
        my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
123
        my $freqdata = GetSubscriptionFrequency($subscription->{'periodicity'});
124
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata );
124
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate, $freqdata );
125
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
125
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
(-)a/reports/issues_avg_stats.pl (-2 lines)
Lines 449-456 sub calculate { Link Here
449
        $emptycol=1 if (!defined($col));
449
        $emptycol=1 if (!defined($col));
450
        $col = "zzEMPTY" if (!defined($col));
450
        $col = "zzEMPTY" if (!defined($col));
451
        $row = "zzEMPTY" if (!defined($row));
451
        $row = "zzEMPTY" if (!defined($row));
452
        # fill returndate to avoid an error with date calc (needed for all non returned issues)
453
        $returndate= join '-',Date::Calc::Today if $returndate eq '0000-00-00';
454
    #  DateCalc returns => 0:0:WK:DD:HH:MM:SS   the weeks, days, hours, minutes,
452
    #  DateCalc returns => 0:0:WK:DD:HH:MM:SS   the weeks, days, hours, minutes,
455
    #  and seconds between the two
453
    #  and seconds between the two
456
        $loanlength = Delta_Days(split(/-/,$issuedate),split (/-/,$returndate)) ;
454
        $loanlength = Delta_Days(split(/-/,$issuedate),split (/-/,$returndate)) ;
(-)a/reserve/request.pl (-2 / +2 lines)
Lines 205-211 if ($borrowernumber_hold && !$action) { Link Here
205
    # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
205
    # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
206
    my $expiry_date = $patron->dateexpiry;
206
    my $expiry_date = $patron->dateexpiry;
207
    my $expiry = 0; # flag set if patron account has expired
207
    my $expiry = 0; # flag set if patron account has expired
208
    if ($expiry_date and $expiry_date ne '0000-00-00' and
208
    if ($expiry_date and
209
        Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
209
        Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
210
        $expiry = 1;
210
        $expiry = 1;
211
    }
211
    }
Lines 250-256 if ($club_hold && !$borrowernumber_hold && !$action) { Link Here
250
        }
250
        }
251
        my $expiry_date = $enrollment->patron->dateexpiry;
251
        my $expiry_date = $enrollment->patron->dateexpiry;
252
        $member->{expiry} = 0; # flag set if patron account has expired
252
        $member->{expiry} = 0; # flag set if patron account has expired
253
        if ($expiry_date and $expiry_date ne '0000-00-00' and
253
        if ($expiry_date and
254
            Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
254
            Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
255
            $member->{expiry} = 1;
255
            $member->{expiry} = 1;
256
        }
256
        }
(-)a/serials/subscription-add.pl (-12 / +3 lines)
Lines 84-101 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { Link Here
84
      print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
84
      print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
85
    }
85
    }
86
    $firstissuedate = $subs->{firstacquidate} || '';  # in iso format.
86
    $firstissuedate = $subs->{firstacquidate} || '';  # in iso format.
87
    for (qw(startdate firstacquidate histstartdate enddate histenddate)) {
87
    if (!defined $subs->{letter}) {
88
        next unless defined $subs->{$_};
88
        $subs->{letter}= q{};
89
	# TODO : Handle date formats properly.
89
    }
90
         if ($subs->{$_} eq '0000-00-00') {
91
            $subs->{$_} = ''
92
    	} else {
93
            $subs->{$_} = $subs->{$_};
94
        }
95
	  }
96
      if (!defined $subs->{letter}) {
97
          $subs->{letter}= q{};
98
      }
99
    my $nextexpected = GetNextExpected($subscriptionid);
90
    my $nextexpected = GetNextExpected($subscriptionid);
100
    $nextexpected->{'isfirstissue'} = $nextexpected->{planneddate} eq $firstissuedate ;
91
    $nextexpected->{'isfirstissue'} = $nextexpected->{planneddate} eq $firstissuedate ;
101
    $subs->{nextacquidate} = $nextexpected->{planneddate}  if($op eq 'modify');
92
    $subs->{nextacquidate} = $nextexpected->{planneddate}  if($op eq 'modify');
(-)a/suggestion/suggestion.pl (-1 / +1 lines)
Lines 39-45 use URI::Escape; Link Here
39
sub Init{
39
sub Init{
40
    my $suggestion= shift @_;
40
    my $suggestion= shift @_;
41
    # "Managed by" is used only when a suggestion is being edited (not when created)
41
    # "Managed by" is used only when a suggestion is being edited (not when created)
42
    if ($suggestion->{'suggesteddate'} eq "0000-00-00" ||$suggestion->{'suggesteddate'} eq "") {
42
    if ($suggestion->{'suggesteddate'} eq "") {
43
        # new suggestion
43
        # new suggestion
44
        $suggestion->{suggesteddate} = dt_from_string;
44
        $suggestion->{suggesteddate} = dt_from_string;
45
        $suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'suggestedby'});
45
        $suggestion->{'suggestedby'} = C4::Context->userenv->{"number"} unless ($suggestion->{'suggestedby'});
(-)a/t/db_dependent/Circulation/dateexpiry.t (-3 / +2 lines)
Lines 105-113 sub calc_date_due { Link Here
105
105
106
    # first test with empty expiry date
106
    # first test with empty expiry date
107
    # note that this expiry date will never lead to an issue btw !!
107
    # note that this expiry date will never lead to an issue btw !!
108
    $patron->{dateexpiry} = '0000-00-00';
108
    $patron->{dateexpiry} = undef;
109
    my $d = C4::Circulation::CalcDateDue( $today, $item->effective_itemtype, $branch->{branchcode}, $patron );
109
    my $d = C4::Circulation::CalcDateDue( $today, $item->effective_itemtype, $branch->{branchcode}, $patron );
110
    is( ref $d eq "DateTime" && $d->mdy() =~ /^\d+/, 1, "CalcDateDue with expiry 0000-00-00" );
110
    is( ref $d eq "DateTime" && $d->mdy() =~ /^\d+/, 1, "CalcDateDue with expiry undef" );
111
111
112
    # second test expiry date==today
112
    # second test expiry date==today
113
    my $d2 = output_pref( { dt => $today, dateonly => 1, dateformat => 'sql' } );
113
    my $d2 = output_pref( { dt => $today, dateonly => 1, dateformat => 'sql' } );
114
- 

Return to bug 7806