4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
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.
49 use C4
::Serials
; # GetExpirationDate
52 use C4
::Dates qw
/format_date format_date_in_iso/;
53 use Date
::Calc qw
/Today Date_to_Days/;
57 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
59 template_name
=> "serials/checkexpiration.tt",
63 flagsrequired
=> { serials
=> 'check_expiration' },
68 my $title = $query->param('title');
69 my $issn = $query->param('issn');
70 my $date = format_date_in_iso
($query->param('date'));
73 my @subscriptions = SearchSubscriptions
({ title
=> $title, issn
=> $issn, orderby
=> 'title' });
74 my @subscriptions_loop;
76 foreach my $subscription ( @subscriptions ) {
77 my $subscriptionid = $subscription->{'subscriptionid'};
78 my $expirationdate = GetExpirationDate
($subscriptionid);
80 $subscription->{expirationdate
} = $expirationdate;
81 next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in ISO format.
82 next if $subscription->{closed
};
83 if ( Date_to_Days
(split "-",$expirationdate) < Date_to_Days
(split "-",$date) &&
84 Date_to_Days
(split "-",$expirationdate) > Date_to_Days
(&Today
) ) {
85 $subscription->{expirationdate
}=format_date
($subscription->{expirationdate
});
86 push @subscriptions_loop,$subscription;
93 numsubscription
=> scalar @subscriptions_loop,
94 date
=> format_date
($date),
95 subscriptions_loop
=> \
@subscriptions_loop,
96 "BiblioDefaultView".C4
::Context
->preference("BiblioDefaultView") => 1,
100 (uc(C4
::Context
->preference("marcflavour"))) => 1
102 output_html_with_http_headers
$query, $cookie, $template->output;