4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along with
16 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
17 # Suite 330, Boston, MA 02111-1307 USA
26 This script check what subscription will expire before C<$datenumber $datelimit>
33 To filter subscription on title
36 To filter subscription on issn
39 The date to filter on.
48 use C4::Serials; # GetExpirationDate
51 use C4::Dates qw/format_date format_date_in_iso/;
52 use Date::Calc qw/Today Date_to_Days/;
56 my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
58 template_name => "serials/checkexpiration.tmpl",
62 flagsrequired => { serials => 1 },
67 my $title = $query->param('title');
68 my $issn = $query->param('issn');
69 my $date = format_date_in_iso($query->param('date'));
72 my @subscriptions = GetSubscriptions( $title, $issn );
73 my @subscriptions_loop;
75 foreach my $subscription ( @subscriptions ) {
76 my $subscriptionid = $subscription->{'subscriptionid'};
77 my $expirationdate = GetExpirationDate($subscriptionid);
79 $subscription->{expirationdate} = $expirationdate;
80 next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in ISO format.
81 if ( Date_to_Days(split "-",$expirationdate) < Date_to_Days(split "-",$date) &&
82 Date_to_Days(split "-",$expirationdate) > Date_to_Days(&Today) ) {
83 $subscription->{expirationdate}=format_date($subscription->{expirationdate});
84 push @subscriptions_loop,$subscription;
91 numsubscription => scalar @subscriptions_loop,
92 date => format_date($date),
93 subscriptions_loop => \@subscriptions_loop,
94 "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
98 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
100 output_html_with_http_headers $query, $cookie, $template->output;