Bug 8801: Add menu entry to delete items in batch
[koha.git] / serials / checkexpiration.pl
blobbf4b6e933b5ae505c538adb038c001b0f1eb7cf8
1 #!/usr/bin/perl
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
9 # version.
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
16 # with Koha; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 =head1 NAME
22 checkexpiration.pl
24 =head1 DESCRIPTION
26 This script check what subscription will expire before C<$datenumber $datelimit>
28 =head1 PARAMETERS
30 =over 4
32 =item title
33 To filter subscription on title
35 =item issn
36 To filter subscription on issn
38 =item date
39 The date to filter on.
41 =back
43 =cut
45 use strict;
46 use warnings;
47 use CGI;
48 use C4::Auth;
49 use C4::Serials; # GetExpirationDate
50 use C4::Output;
51 use C4::Context;
52 use C4::Dates qw/format_date format_date_in_iso/;
53 use Date::Calc qw/Today Date_to_Days/;
55 my $query = new CGI;
57 my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
59 template_name => "serials/checkexpiration.tmpl",
60 query => $query,
61 type => "intranet",
62 authnotrequired => 0,
63 flagsrequired => { serials => 'check_expiration' },
64 debug => 1,
68 my $title = $query->param('title');
69 my $issn = $query->param('issn');
70 my $date = format_date_in_iso($query->param('date'));
72 if ($date) {
73 my @subscriptions = GetSubscriptions( $title, $issn );
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 if ( Date_to_Days(split "-",$expirationdate) < Date_to_Days(split "-",$date) &&
83 Date_to_Days(split "-",$expirationdate) > Date_to_Days(&Today) ) {
84 $subscription->{expirationdate}=format_date($subscription->{expirationdate});
85 push @subscriptions_loop,$subscription;
89 $template->param (
90 title => $title,
91 issn => $issn,
92 numsubscription => scalar @subscriptions_loop,
93 date => format_date($date),
94 subscriptions_loop => \@subscriptions_loop,
95 "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
98 $template->param (
99 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
100 (uc(C4::Context->preference("marcflavour"))) => 1
102 output_html_with_http_headers $query, $cookie, $template->output;