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

(-)a/C4/Serials.pm (-12 / +12 lines)
Lines 22-28 use Modern::Perl; Link Here
22
22
23
use C4::Auth qw(haspermission);
23
use C4::Auth qw(haspermission);
24
use C4::Context;
24
use C4::Context;
25
use C4::Dates qw(format_date format_date_in_iso);
26
use DateTime;
25
use DateTime;
27
use Date::Calc qw(:all);
26
use Date::Calc qw(:all);
28
use POSIX qw(strftime);
27
use POSIX qw(strftime);
Lines 32-37 use C4::Debug; Link Here
32
use C4::Serials::Frequency;
31
use C4::Serials::Frequency;
33
use C4::Serials::Numberpattern;
32
use C4::Serials::Numberpattern;
34
use Koha::AdditionalField;
33
use Koha::AdditionalField;
34
use Koha::DateUtils;
35
35
36
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
36
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
37
37
Lines 467-475 sub GetSubscriptionsFromBiblionumber { Link Here
467
    $sth->execute($biblionumber);
467
    $sth->execute($biblionumber);
468
    my @res;
468
    my @res;
469
    while ( my $subs = $sth->fetchrow_hashref ) {
469
    while ( my $subs = $sth->fetchrow_hashref ) {
470
        $subs->{startdate}     = format_date( $subs->{startdate} );
470
        $subs->{startdate}     = output_pref( { dt => dt_from_string( $subs->{startdate} ),     dateonly => 1 } );
471
        $subs->{histstartdate} = format_date( $subs->{histstartdate} );
471
        $subs->{histstartdate} = output_pref( { dt => dt_from_string( $subs->{histstartdate} ), dateonly => 1 } );
472
        $subs->{histenddate}   = format_date( $subs->{histenddate} );
472
        $subs->{histenddate}   = output_pref( { dt => dt_from_string( $subs->{histenddate} ),   dateonly => 1 } );
473
        $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
473
        $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
474
        $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
474
        $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
475
        $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
475
        $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
Lines 480-486 sub GetSubscriptionsFromBiblionumber { Link Here
480
        if ( $subs->{enddate} eq '0000-00-00' ) {
480
        if ( $subs->{enddate} eq '0000-00-00' ) {
481
            $subs->{enddate} = '';
481
            $subs->{enddate} = '';
482
        } else {
482
        } else {
483
            $subs->{enddate} = format_date( $subs->{enddate} );
483
            $subs->{enddate} = output_pref( { dt => dt_from_string( $subs->{enddate}), dateonly => 1 } );
484
        }
484
        }
485
        $subs->{'abouttoexpire'}       = abouttoexpire( $subs->{'subscriptionid'} );
485
        $subs->{'abouttoexpire'}       = abouttoexpire( $subs->{'subscriptionid'} );
486
        $subs->{'subscriptionexpired'} = HasSubscriptionExpired( $subs->{'subscriptionid'} );
486
        $subs->{'subscriptionexpired'} = HasSubscriptionExpired( $subs->{'subscriptionid'} );
Lines 710-716 sub GetSerials { Link Here
710
        $line->{ "status" . $line->{status} } = 1;                                         # fills a "statusX" value, used for template status select list
710
        $line->{ "status" . $line->{status} } = 1;                                         # fills a "statusX" value, used for template status select list
711
        for my $datefield ( qw( planneddate publisheddate) ) {
711
        for my $datefield ( qw( planneddate publisheddate) ) {
712
            if ($line->{$datefield} && $line->{$datefield}!~m/^00/) {
712
            if ($line->{$datefield} && $line->{$datefield}!~m/^00/) {
713
                $line->{$datefield} = format_date( $line->{$datefield});
713
                $line->{$datefield} =  output_pref( { dt => dt_from_string( $line->{$datefield} ), dateonly => 1 } );
714
            } else {
714
            } else {
715
                $line->{$datefield} = q{};
715
                $line->{$datefield} = q{};
716
            }
716
            }
Lines 733-739 sub GetSerials { Link Here
733
        $line->{ "status" . $line->{status} } = 1;                                         # fills a "statusX" value, used for template status select list
733
        $line->{ "status" . $line->{status} } = 1;                                         # fills a "statusX" value, used for template status select list
734
        for my $datefield ( qw( planneddate publisheddate) ) {
734
        for my $datefield ( qw( planneddate publisheddate) ) {
735
            if ($line->{$datefield} && $line->{$datefield}!~m/^00/) {
735
            if ($line->{$datefield} && $line->{$datefield}!~m/^00/) {
736
                $line->{$datefield} = format_date( $line->{$datefield});
736
                $line->{$datefield} = output_pref( { dt => dt_from_string( $line->{$datefield} ), dateonly => 1 } );
737
            } else {
737
            } else {
738
                $line->{$datefield} = q{};
738
                $line->{$datefield} = q{};
739
            }
739
            }
Lines 788-794 sub GetSerials2 { Link Here
788
                $line->{$datefield} = q{};
788
                $line->{$datefield} = q{};
789
            }
789
            }
790
            else {
790
            else {
791
                $line->{$datefield} = format_date( $line->{$datefield} );
791
                $line->{$datefield} = output_pref( { dt => dt_from_string( $line->{$datefield} ), dateonly => 1 } );
792
            }
792
            }
793
        }
793
        }
794
        push @serials, $line;
794
        push @serials, $line;
Lines 824-831 sub GetLatestSerials { Link Here
824
    my @serials;
824
    my @serials;
825
    while ( my $line = $sth->fetchrow_hashref ) {
825
    while ( my $line = $sth->fetchrow_hashref ) {
826
        $line->{ "status" . $line->{status} } = 1;                        # fills a "statusX" value, used for template status select list
826
        $line->{ "status" . $line->{status} } = 1;                        # fills a "statusX" value, used for template status select list
827
        $line->{"planneddate"} = format_date( $line->{"planneddate"} );
827
        $line->{planneddate}   = output_pref( { dt => dt_from_string( $line->{planneddate} ),   dateonly => 1 } );
828
        $line->{"publisheddate"} = format_date( $line->{"publisheddate"} );
828
        $line->{publisheddate} = output_pref( { dt => dt_from_string( $line->{publisheddate} ), dateonly => 1 } );
829
        push @serials, $line;
829
        push @serials, $line;
830
    }
830
    }
831
831
Lines 1983-1993 sub GetLateOrMissingIssues { Link Here
1983
1983
1984
        if ($line->{planneddate} && $line->{planneddate} !~/^0+\-/) {
1984
        if ($line->{planneddate} && $line->{planneddate} !~/^0+\-/) {
1985
            $line->{planneddateISO} = $line->{planneddate};
1985
            $line->{planneddateISO} = $line->{planneddate};
1986
            $line->{planneddate} = format_date( $line->{planneddate} );
1986
            $line->{planneddate} = output_pref( { dt => dt_from_string( $line->{"planneddate"} ), dateonly => 1 } );
1987
        }
1987
        }
1988
        if ($line->{claimdate} && $line->{claimdate} !~/^0+\-/) {
1988
        if ($line->{claimdate} && $line->{claimdate} !~/^0+\-/) {
1989
            $line->{claimdateISO} = $line->{claimdate};
1989
            $line->{claimdateISO} = $line->{claimdate};
1990
            $line->{claimdate}   = format_date( $line->{claimdate} );
1990
            $line->{claimdate}   = output_pref( { dt => dt_from_string( $line->{"claimdate"} ), dateonly => 1 } );
1991
        }
1991
        }
1992
        $line->{"status".$line->{status}}   = 1;
1992
        $line->{"status".$line->{status}}   = 1;
1993
1993
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt (-3 / +4 lines)
Lines 1-3 Link Here
1
[% USE KohaDates %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Serials &rsaquo; Check expiration</title>
3
<title>Koha &rsaquo; Serials &rsaquo; Check expiration</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
Lines 70-76 Link Here
70
        [% END %]
71
        [% END %]
71
72
72
        <li><label for="date" class="required" title="Required field">Expiring before:</label>
73
        <li><label for="date" class="required" title="Required field">Expiring before:</label>
73
        <input id="date" type="text" name="date" size="10" value="[% date %]" class="focus datepicker" />
74
        <input id="date" type="text" name="date" size="10" value="[% date | $KohaDates %]" class="focus datepicker" />
74
        <span class="required">Required</span>
75
        <span class="required">Required</span>
75
			<div class="hint">[% INCLUDE 'date-format.inc' %]</div></li>
76
			<div class="hint">[% INCLUDE 'date-format.inc' %]</div></li>
76
			</ol>
77
			</ol>
Lines 89-95 Link Here
89
    [% IF ( issn ) %]
90
    [% IF ( issn ) %]
90
        with ISSN matching <b>[% issn %]</b>
91
        with ISSN matching <b>[% issn %]</b>
91
    [% END %]
92
    [% END %]
92
        will expire before <b>[% date %]</b>
93
        will expire before <b>[% date | $KohaDates %]</b>
93
</p>
94
</p>
94
<table>
95
<table>
95
        <tr>
96
        <tr>
Lines 127-133 Link Here
127
                [% subscriptions_loo.internalnotes %]
128
                [% subscriptions_loo.internalnotes %]
128
            </td>
129
            </td>
129
            <td>
130
            <td>
130
                [% subscriptions_loo.expirationdate %]
131
                [% subscriptions_loo.expirationdate | $KohaDates %]
131
            </td>
132
            </td>
132
            <td><a href="/cgi-bin/koha/serials/subscription-add.pl?op=modify&amp;subscriptionid=[% subscriptions_loo.subscriptionid %]">Edit</a></td>
133
            <td><a href="/cgi-bin/koha/serials/subscription-add.pl?op=modify&amp;subscriptionid=[% subscriptions_loo.subscriptionid %]">Edit</a></td>
133
			<td><a href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscriptions_loo.subscriptionid %]" onclick="popup([% subscriptions_loo.subscriptionid %]); return false;">Renew</a></td>
134
			<td><a href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscriptions_loo.subscriptionid %]" onclick="popup([% subscriptions_loo.subscriptionid %]); return false;">Renew</a></td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt (-2 / +9 lines)
Lines 3-8 Link Here
3
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Serials &rsaquo; Subscription history</title>
4
<title>Koha &rsaquo; Serials &rsaquo; Subscription history</title>
5
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'calendar.inc' %]
6
</head>
7
</head>
7
8
8
<body id="ser_subscription_history" class="ser">
9
<body id="ser_subscription_history" class="ser">
Lines 25-35 Link Here
25
            <table>
26
            <table>
26
              <tr>
27
              <tr>
27
                <td>Subscription start date</td>
28
                <td>Subscription start date</td>
28
                <td><input type="text" name="histstartdate" value="[% histstartdate | $KohaDates %]" /> (start date of the 1st subscription)</td>
29
                <td>
30
                    <input type="text" size="10" name="histstartdate" value="[% histstartdate | $KohaDates %]" class="datepickerfrom" /> (start date of the 1st subscription)
31
                    <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
32
                </td>
29
              </tr>
33
              </tr>
30
              <tr>
34
              <tr>
31
                <td>Subscription end date</td>
35
                <td>Subscription end date</td>
32
                <td><input type="text" name="histenddate" value="[% histenddate | $KohaDates %]" />(if empty, subscription is still active)</td>
36
                <td>
37
                    <input type="text" size="10" name="histenddate" value="[% histenddate | $KohaDates %]" class="datepickerto" />(if empty, subscription is still active)
38
                    <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
39
                </td>
33
              </tr>
40
              </tr>
34
              <tr>
41
              <tr>
35
                <td>Received issues</td>
42
                <td>Received issues</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-renew.tt (-1 / +7 lines)
Lines 1-6 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Serials subscription renew #[% subscriptionid %]</title>
2
<title>Koha &rsaquo; Serials subscription renew #[% subscriptionid %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
4
<style type="text/css">
5
<style type="text/css">
5
   #custom-doc { width:39.85em;*width:38.86em;min-width:531px; margin:auto; text-align:left; }
6
   #custom-doc { width:39.85em;*width:38.86em;min-width:531px; margin:auto; text-align:left; }
6
   </style>
7
   </style>
Lines 23-29 Link Here
23
		<input type="hidden" name="op" value="renew" />
24
		<input type="hidden" name="op" value="renew" />
24
		<input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
25
		<input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
25
		<fieldset class="rows"><legend>Subscription renewal for [% bibliotitle %]</legend>
26
		<fieldset class="rows"><legend>Subscription renewal for [% bibliotitle %]</legend>
26
		<ol><li><label for="startdate">Start date: </label><input type="text" id="startdate" name="startdate" value="[% startdate %]" /></li>
27
        <ol>
28
            <li>
29
                <label for="startdate">Start date: </label>
30
                <input type="text" size="10" id="startdate" name="startdate" value="[% startdate %]" class="datepicker"/>
31
                <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
32
            </li>
27
		<li><fieldset>
33
		<li><fieldset>
28
		<legend>Subscription length:</legend>
34
		<legend>Subscription length:</legend>
29
		<ol><li><label for="numberlength">Number of num:</label><input type="text" id="numberlength" name="numberlength" value="[% numberlength %]" /></li>
35
		<ol><li><label for="numberlength">Number of num:</label><input type="text" id="numberlength" name="numberlength" value="[% numberlength %]" /></li>
(-)a/serials/checkexpiration.pl (-8 / +14 lines)
Lines 50-57 use C4::Serials; # GetExpirationDate Link Here
50
use C4::Branch;
50
use C4::Branch;
51
use C4::Output;
51
use C4::Output;
52
use C4::Context;
52
use C4::Context;
53
use C4::Dates qw/format_date format_date_in_iso/;
53
use Koha::DateUtils;
54
use Date::Calc qw/Date_to_Days/;
54
55
use DateTime;
55
56
56
my $query = new CGI;
57
my $query = new CGI;
57
58
Lines 69-75 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user ( Link Here
69
my $title = $query->param('title');
70
my $title = $query->param('title');
70
my $issn  = $query->param('issn');
71
my $issn  = $query->param('issn');
71
my $branch = $query->param('branch');
72
my $branch = $query->param('branch');
72
my $date  = format_date_in_iso($query->param('date'));
73
my $date = $query->param('date');
74
$date = eval { dt_from_string( $query->param('date') ) } if $date;
73
75
74
if ($date) {
76
if ($date) {
75
    my @subscriptions = SearchSubscriptions({ title => $title, issn => $issn, orderby => 'title' });
77
    my @subscriptions = SearchSubscriptions({ title => $title, issn => $issn, orderby => 'title' });
Lines 78-85 if ($date) { Link Here
78
    foreach my $subscription ( @subscriptions ) {
80
    foreach my $subscription ( @subscriptions ) {
79
        my $subscriptionid = $subscription->{'subscriptionid'};
81
        my $subscriptionid = $subscription->{'subscriptionid'};
80
        my $expirationdate = GetExpirationDate($subscriptionid);
82
        my $expirationdate = GetExpirationDate($subscriptionid);
83
81
        $subscription->{expirationdate} = $expirationdate;
84
        $subscription->{expirationdate} = $expirationdate;
85
82
        next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in ISO format.
86
        next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in ISO format.
87
83
        next if $subscription->{closed};
88
        next if $subscription->{closed};
84
        if (   !C4::Context->preference("IndependentBranches")
89
        if (   !C4::Context->preference("IndependentBranches")
85
            or C4::Context->IsSuperLibrarian()
90
            or C4::Context->IsSuperLibrarian()
Lines 89-98 if ($date) { Link Here
89
            $subscription->{cannotedit} = 0;
94
            $subscription->{cannotedit} = 0;
90
        }
95
        }
91
        next if $subscription->{cannotedit};
96
        next if $subscription->{cannotedit};
92
        if ( Date_to_Days(split "-",$expirationdate) < Date_to_Days(split "-",$date) &&
97
93
             ( !$branch || ($subscription->{'branchcode'} eq $branch) ) ) {
98
        my $expirationdate_dt = dt_from_string( $expirationdate, 'iso' );
94
            $subscription->{expirationdate}=format_date($subscription->{expirationdate});
99
        if (   DateTime->compare( $date, $expirationdate_dt ) == 1
95
            push @subscriptions_loop,$subscription;
100
            && ( !$branch || ( $subscription->{'branchcode'} eq $branch ) ) ) {
101
            push @subscriptions_loop, $subscription;
96
        }
102
        }
97
    }
103
    }
98
104
Lines 100-106 if ($date) { Link Here
100
        title           => $title,
106
        title           => $title,
101
        issn            => $issn,
107
        issn            => $issn,
102
        numsubscription => scalar @subscriptions_loop,
108
        numsubscription => scalar @subscriptions_loop,
103
        date => format_date($date),
109
        date => $date,
104
        subscriptions_loop => \@subscriptions_loop,
110
        subscriptions_loop => \@subscriptions_loop,
105
        "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
111
        "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
106
        searched => 1,
112
        searched => 1,
(-)a/serials/routing-preview.pl (-1 lines)
Lines 23-29 use warnings; Link Here
23
use CGI qw ( -utf8 );
23
use CGI qw ( -utf8 );
24
use C4::Koha;
24
use C4::Koha;
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Dates;
27
use C4::Output;
26
use C4::Output;
28
use C4::Acquisition;
27
use C4::Acquisition;
29
use C4::Reserves;
28
use C4::Reserves;
(-)a/serials/routing.pl (-1 lines)
Lines 30-36 use warnings; Link Here
30
use CGI qw ( -utf8 );
30
use CGI qw ( -utf8 );
31
use C4::Koha;
31
use C4::Koha;
32
use C4::Auth;
32
use C4::Auth;
33
use C4::Dates;
34
use C4::Output;
33
use C4::Output;
35
use C4::Acquisition;
34
use C4::Acquisition;
36
use C4::Output;
35
use C4::Output;
(-)a/serials/serial-issues.pl (-1 lines)
Lines 46-52 use warnings; Link Here
46
use CGI qw ( -utf8 );
46
use CGI qw ( -utf8 );
47
use C4::Auth;
47
use C4::Auth;
48
use C4::Koha;
48
use C4::Koha;
49
use C4::Dates;
50
use C4::Serials;
49
use C4::Serials;
51
use C4::Output;
50
use C4::Output;
52
use C4::Context;
51
use C4::Context;
(-)a/serials/serials-collection.pl (-9 / +2 lines)
Lines 24-34 use warnings; Link Here
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Koha;
26
use C4::Koha;
27
use C4::Dates qw/format_date/;
28
use C4::Serials;
27
use C4::Serials;
29
use C4::Letters;
28
use C4::Letters;
30
use C4::Output;
29
use C4::Output;
31
use C4::Context;
30
use C4::Context;
31
32
use List::MoreUtils qw/uniq/;
32
use List::MoreUtils qw/uniq/;
33
33
34
34
Lines 114-128 if (@subscriptionid){ Link Here
114
    $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
114
    $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
115
    $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
115
    $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
116
    $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
116
    $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
117
117
    ##these are display information
118
    ##these are display information
118
    $subs->{startdate}     = format_date( $subs->{startdate} );
119
    $subs->{histstartdate} = format_date( $subs->{histstartdate} );
120
    if ( !defined $subs->{enddate} || $subs->{enddate} eq '0000-00-00' ) {
121
        $subs->{enddate} = '';
122
    }
123
    else {
124
        $subs->{enddate} = format_date( $subs->{enddate} );
125
    }
126
    $subs->{'abouttoexpire'}=abouttoexpire($subs->{'subscriptionid'});
119
    $subs->{'abouttoexpire'}=abouttoexpire($subs->{'subscriptionid'});
127
    $subs->{'subscriptionexpired'}=HasSubscriptionExpired($subs->{'subscriptionid'});
120
    $subs->{'subscriptionexpired'}=HasSubscriptionExpired($subs->{'subscriptionid'});
128
    $subs->{'subscriptionid'} = $subscriptionid;  # FIXME - why was this lost ?
121
    $subs->{'subscriptionid'} = $subscriptionid;  # FIXME - why was this lost ?
(-)a/serials/serials-edit.pl (-7 / +8 lines)
Lines 66-72 use warnings; Link Here
66
use CGI qw ( -utf8 );
66
use CGI qw ( -utf8 );
67
use Encode qw( decode is_utf8 );
67
use Encode qw( decode is_utf8 );
68
use C4::Auth;
68
use C4::Auth;
69
use C4::Dates qw/format_date format_date_in_iso/;
70
use C4::Biblio;
69
use C4::Biblio;
71
use C4::Items;
70
use C4::Items;
72
use C4::Koha;
71
use C4::Koha;
Lines 74-79 use C4::Output; Link Here
74
use C4::Context;
73
use C4::Context;
75
use C4::Serials;
74
use C4::Serials;
76
use C4::Search qw/enabled_staff_search_views/;
75
use C4::Search qw/enabled_staff_search_views/;
76
use Koha::DateUtils;
77
77
use List::MoreUtils qw/uniq/;
78
use List::MoreUtils qw/uniq/;
78
79
79
my $query           = CGI->new();
80
my $query           = CGI->new();
Lines 127-133 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
127
my @serialdatalist;
128
my @serialdatalist;
128
my %processedserialid;
129
my %processedserialid;
129
130
130
my $today = C4::Dates->new();
131
my $today = output_pref( dt_from_string );
131
foreach my $serialid (@serialids) {
132
foreach my $serialid (@serialids) {
132
133
133
    #filtering serialid for duplication
134
    #filtering serialid for duplication
Lines 143-152 foreach my $serialid (@serialids) { Link Here
143
                $serinfo->{$d} = q{};
144
                $serinfo->{$d} = q{};
144
            }
145
            }
145
            else {
146
            else {
146
                $serinfo->{$d} = format_date( $serinfo->{$d} );
147
                $serinfo->{$d} = output_pref( { dt => dt_from_string( $serinfo->{$d} ), dateonly => 1 } );
147
            }
148
            }
148
        }
149
        }
149
        $serinfo->{arriveddate}=$today->output('syspref');
150
        $serinfo->{arriveddate} = $today;
150
151
151
        $serinfo->{'editdisable'} = (
152
        $serinfo->{'editdisable'} = (
152
            (
153
            (
Lines 187-193 foreach my $subscriptionid (@subscriptionids) { Link Here
187
        $cell->{'itemid'}         = 'NNEW';
188
        $cell->{'itemid'}         = 'NNEW';
188
        $cell->{'serialid'}       = 'NEW';
189
        $cell->{'serialid'}       = 'NEW';
189
        $cell->{'issuesatonce'}   = 1;
190
        $cell->{'issuesatonce'}   = 1;
190
        $cell->{arriveddate}=$today->output('syspref');
191
        $cell->{arriveddate}      = $today;
191
192
192
        push @newserialloop, $cell;
193
        push @newserialloop, $cell;
193
        push @subscriptionloop,
194
        push @subscriptionloop,
Lines 214-223 if ( $op and $op eq 'serialchangestatus' ) { Link Here
214
        my ($plan_date, $pub_date);
215
        my ($plan_date, $pub_date);
215
216
216
        if (defined $planneddates[$i] && $planneddates[$i] ne 'XXX') {
217
        if (defined $planneddates[$i] && $planneddates[$i] ne 'XXX') {
217
            $plan_date = format_date_in_iso( $planneddates[$i] );
218
            $plan_date = eval { output_pref( { dt => dt_from_string( $planneddates[$i] ), dateonly => 1, dateformat => 'iso' } ); };
218
        }
219
        }
219
        if (defined $publisheddates[$i] && $publisheddates[$i] ne 'XXX') {
220
        if (defined $publisheddates[$i] && $publisheddates[$i] ne 'XXX') {
220
            $pub_date = format_date_in_iso( $publisheddates[$i] );
221
            $pub_date = eval { output_pref( { dt => dt_from_string( $publisheddates[$i] ), dateonly => 1, dateformat => 'iso' } ); };
221
        }
222
        }
222
223
223
        if ( $serialids[$i] && $serialids[$i] eq 'NEW' ) {
224
        if ( $serialids[$i] && $serialids[$i] eq 'NEW' ) {
(-)a/serials/showpredictionpattern.pl (-10 / +5 lines)
Lines 36-41 use C4::Auth; Link Here
36
use C4::Output;
36
use C4::Output;
37
use C4::Serials;
37
use C4::Serials;
38
use C4::Serials::Frequency;
38
use C4::Serials::Frequency;
39
use Koha::DateUtils;
39
40
40
my $input = new CGI;
41
my $input = new CGI;
41
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
42
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
Lines 76-94 my %pattern = ( Link Here
76
    every3          => $input->param('every3') // '',
77
    every3          => $input->param('every3') // '',
77
);
78
);
78
79
79
if(!defined $firstacquidate || $firstacquidate eq ''){
80
$firstacquidate = eval { output_pref( { str => $firstacquidate, dateonly => 1, dateformat => 'iso' } ); }
80
    my ($year, $month, $day) = Today();
81
    or output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
81
    $firstacquidate = sprintf "%04d-%02d-%02d", $year, $month, $day;
82
} else {
83
    $firstacquidate = C4::Dates->new($firstacquidate)->output('iso');
84
}
85
82
86
if($enddate){
83
$enddate = eval { output_pref( { str => $enddate, dateonly => 1, dateformat => 'iso' } ); };
87
    $enddate = C4::Dates->new($enddate)->output('iso');
88
}
89
84
90
if($nextacquidate) {
85
if($nextacquidate) {
91
    $nextacquidate = C4::Dates->new($nextacquidate)->output('iso');
86
    $nextacquidate =  eval { output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } ); };
92
} else {
87
} else {
93
    $nextacquidate = $firstacquidate;
88
    $nextacquidate = $firstacquidate;
94
}
89
}
(-)a/serials/subscription-add.pl (-12 / +18 lines)
Lines 23-29 use Date::Calc qw(Today Day_of_Year Week_of_Year Add_Delta_Days Add_Delta_YM); Link Here
23
use C4::Koha;
23
use C4::Koha;
24
use C4::Biblio;
24
use C4::Biblio;
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Dates qw/format_date format_date_in_iso/;
27
use C4::Acquisition;
26
use C4::Acquisition;
28
use C4::Output;
27
use C4::Output;
29
use C4::Context;
28
use C4::Context;
Lines 33-38 use C4::Serials::Frequency; Link Here
33
use C4::Serials::Numberpattern;
32
use C4::Serials::Numberpattern;
34
use C4::Letters;
33
use C4::Letters;
35
use Koha::AdditionalField;
34
use Koha::AdditionalField;
35
use Koha::DateUtils;
36
use Carp;
36
use Carp;
37
37
38
#use Smart::Comments;
38
#use Smart::Comments;
Lines 322-335 sub redirect_add_subscription { Link Here
322
    my $opacdisplaycount  = $query->param('opacdisplaycount');
322
    my $opacdisplaycount  = $query->param('opacdisplaycount');
323
    my $location          = $query->param('location');
323
    my $location          = $query->param('location');
324
    my $skip_serialseq    = $query->param('skip_serialseq');
324
    my $skip_serialseq    = $query->param('skip_serialseq');
325
    my $startdate = format_date_in_iso( $query->param('startdate') );
325
326
    my $enddate = format_date_in_iso( $query->param('enddate') );
326
    my $startdate      = output_pref( { str => $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
327
    my $firstacquidate  = format_date_in_iso($query->param('firstacquidate'));
327
    my $enddate        = output_pref( { str => $query->param('enddate'),        dateonly => 1, dateformat => 'iso' } );
328
    my $firstacquidate = output_pref( { str => $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
329
328
    if(!defined $enddate || $enddate eq '') {
330
    if(!defined $enddate || $enddate eq '') {
329
        if($subtype eq "issues") {
331
        if($subtype eq "issues") {
330
            $enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength);
332
            $enddate = _guess_enddate($firstacquidate, $periodicity, $numberlength, $weeklength, $monthlength)
331
        } else {
333
        } else {
332
            $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength);
334
            $enddate = _guess_enddate($startdate, $periodicity, $numberlength, $weeklength, $monthlength)
333
        }
335
        }
334
    }
336
    }
335
337
Lines 361-372 sub redirect_mod_subscription { Link Here
361
    my $aqbooksellerid = $query->param('aqbooksellerid');
363
    my $aqbooksellerid = $query->param('aqbooksellerid');
362
    my $biblionumber = $query->param('biblionumber');
364
    my $biblionumber = $query->param('biblionumber');
363
    my $aqbudgetid = $query->param('aqbudgetid');
365
    my $aqbudgetid = $query->param('aqbudgetid');
364
    my $startdate = format_date_in_iso($query->param('startdate'));
366
365
    my $firstacquidate = format_date_in_iso( $query->param('firstacquidate') );
367
    my $startdate      = output_pref( { str => $query->param('startdate'),      dateonly => 1, dateformat => 'iso' } );
366
    my $nextacquidate = $query->param('nextacquidate') ?
368
    my $enddate        = output_pref( { str => $query->param('enddate'),        dateonly => 1, dateformat => 'iso' } );
367
                            format_date_in_iso($query->param('nextacquidate')):
369
    my $firstacquidate = output_pref( { str => $query->param('firstacquidate'), dateonly => 1, dateformat => 'iso' } );
368
                            $firstacquidate;
370
369
    my $enddate = format_date_in_iso($query->param('enddate'));
371
    my $nextacquidate  = $query->param('nextacquidate');
372
    $nextacquidate = $nextacquidate
373
        ? output_pref( { str => $nextacquidate, dateonly => 1, dateformat => 'iso' } )
374
        : $firstacquidate;
375
370
    my $periodicity = $query->param('frequency');
376
    my $periodicity = $query->param('frequency');
371
377
372
    my $subtype = $query->param('subtype');
378
    my $subtype = $query->param('subtype');
(-)a/serials/subscription-detail.pl (-2 / +3 lines)
Lines 21-31 use C4::Acquisition; Link Here
21
use C4::Auth;
21
use C4::Auth;
22
use C4::Budgets;
22
use C4::Budgets;
23
use C4::Koha;
23
use C4::Koha;
24
use C4::Dates qw/format_date/;
25
use C4::Serials;
24
use C4::Serials;
26
use C4::Output;
25
use C4::Output;
27
use C4::Context;
26
use C4::Context;
28
use C4::Search qw/enabled_staff_search_views/;
27
use C4::Search qw/enabled_staff_search_views/;
28
use Koha::DateUtils;
29
29
30
use Koha::Acquisition::Bookseller;
30
use Koha::Acquisition::Bookseller;
31
31
Lines 100-106 my $hasRouting = check_routing($subscriptionid); Link Here
100
# COMMENT hdl : IMHO, we should think about passing more and more data hash to template->param rather than duplicating code a new coding Guideline ?
100
# COMMENT hdl : IMHO, we should think about passing more and more data hash to template->param rather than duplicating code a new coding Guideline ?
101
101
102
for my $date ( qw(startdate enddate firstacquidate histstartdate histenddate) ) {
102
for my $date ( qw(startdate enddate firstacquidate histstartdate histenddate) ) {
103
    $$subs{$date}      = format_date($$subs{$date}) if $date && $$subs{$date};
103
    $subs->{$date} = output_pref( { str => $subs->{$date}, dateonly => 1 } )
104
        if $subs->{$date};
104
}
105
}
105
$subs->{location} = GetKohaAuthorisedValueLib("LOC",$subs->{location});
106
$subs->{location} = GetKohaAuthorisedValueLib("LOC",$subs->{location});
106
$subs->{abouttoexpire}  = abouttoexpire($subs->{subscriptionid});
107
$subs->{abouttoexpire}  = abouttoexpire($subs->{subscriptionid});
(-)a/serials/subscription-history.pl (-4 / +5 lines)
Lines 34-41 use C4::Auth; Link Here
34
use C4::Output;
34
use C4::Output;
35
35
36
use C4::Biblio;
36
use C4::Biblio;
37
use C4::Dates qw(format_date_in_iso);
38
use C4::Serials;
37
use C4::Serials;
38
use Koha::DateUtils;
39
39
40
my $input = new CGI;
40
my $input = new CGI;
41
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
41
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
Lines 63-71 if($op && $op eq 'mod') { Link Here
63
    my $opacnote        = $input->param('opacnote');
63
    my $opacnote        = $input->param('opacnote');
64
    my $librariannote   = $input->param('librariannote');
64
    my $librariannote   = $input->param('librariannote');
65
65
66
    ModSubscriptionHistory( $subscriptionid, format_date_in_iso($histstartdate),
66
    $histstartdate = output_pref( { str => $histstartdate, dateonly => 1, dateformat => 'iso' } );
67
        format_date_in_iso($histenddate), $receivedlist, $missinglist, $opacnote,
67
    $histenddate   = output_pref( { str => $histenddate,   dateonly => 1, dateformat => 'iso' } );
68
        $librariannote );
68
69
    ModSubscriptionHistory( $subscriptionid, $histstartdate, $histenddate, $receivedlist, $missinglist, $opacnote, $librariannote );
69
70
70
    print $input->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
71
    print $input->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
71
    exit;
72
    exit;
(-)a/serials/subscription-renew.pl (-8 / +8 lines)
Lines 50-60 use CGI qw ( -utf8 ); Link Here
50
use Carp;
50
use Carp;
51
use C4::Koha;
51
use C4::Koha;
52
use C4::Auth;
52
use C4::Auth;
53
use C4::Dates qw/format_date/;
54
use C4::Context;
53
use C4::Context;
55
use C4::Auth;
54
use C4::Auth;
56
use C4::Output;
55
use C4::Output;
57
use C4::Serials;
56
use C4::Serials;
57
use Koha::DateUtils;
58
58
59
my $query = new CGI;
59
my $query = new CGI;
60
my $dbh   = C4::Context->dbh;
60
my $dbh   = C4::Context->dbh;
Lines 74-82 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
74
    }
74
    }
75
);
75
);
76
if ( $op eq "renew" ) {
76
if ( $op eq "renew" ) {
77
    my $startdate = output_pref( { str => $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
77
    ReNewSubscription(
78
    ReNewSubscription(
78
        $subscriptionid,             $loggedinuser,
79
        $subscriptionid, $loggedinuser,
79
        C4::Dates->new($query->param('startdate'))->output('iso'),  $query->param('numberlength'),
80
        $startdate, $query->param('numberlength'),
80
        $query->param('weeklength'), $query->param('monthlength'),
81
        $query->param('weeklength'), $query->param('monthlength'),
81
        $query->param('note')
82
        $query->param('note')
82
    );
83
    );
Lines 88-98 if ($subscription->{'cannotedit'}){ Link Here
88
  print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
89
  print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
89
}
90
}
90
91
92
my $newstartdate = output_pref( { str => $subscription->{enddate}, dateonly => 1 } )
93
    or output_pref( { dt => dt_from_string, dateonly => 1 } );
94
91
$template->param(
95
$template->param(
92
    startdate => format_date(
96
    startdate      => $newstartdate,
93
             $subscription->{enddate}
94
          || POSIX::strftime( "%Y-%m-%d", localtime )
95
    ),
96
    numberlength   => $subscription->{numberlength},
97
    numberlength   => $subscription->{numberlength},
97
    weeklength     => $subscription->{weeklength},
98
    weeklength     => $subscription->{weeklength},
98
    monthlength    => $subscription->{monthlength},
99
    monthlength    => $subscription->{monthlength},
99
- 

Return to bug 14969