3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
25 this script shows late orders for a specific supplier, branch and delay
33 To know on which supplier this script have to display late order.
36 To know the time boundary. Default value is 30 days.
39 To know on which branch this script have to display late order.
48 use C4::Bookseller qw( GetBooksellersWithLateOrders );
55 use C4::Branch; # GetBranches
58 my ($template, $loggedinuser, $cookie) = get_template_and_user({
59 template_name => "acqui/lateorders.tmpl",
63 flagsrequired => {acquisition => 'order_receive'},
67 my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0
68 my $delay = $input->param('delay');
69 my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom');
70 my $estimateddeliverydateto = $input->param('estimateddeliverydateto');
71 my $branch = $input->param('branch');
72 my $op = $input->param('op');
75 if ( defined $delay and not $delay =~ /^\d{1,3}$/ ) {
76 push @errors, {delay_digits => 1, bad_delay => $delay};
79 if ($op and $op eq "send_alert"){
80 my @ordernums = $input->param("claim_for");# FIXME: Fallback values?
83 $err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") ); # FIXME: Fallback value?
84 if ( not ref $err or not exists $err->{error} ) {
85 AddClaim ( $_ ) for @ordernums;
89 $template->param(error_claim => $@);
90 } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) {
91 $template->{VARS}->{'error_claim'} = "no_email";
93 $template->{VARS}->{'info_claim'} = 1;
97 my %supplierlist = GetBooksellersWithLateOrders(
100 C4::Dates->new($estimateddeliverydatefrom)->output("iso"),
101 C4::Dates->new($estimateddeliverydateto)->output("iso")
104 my (@sloopy); # supplier loop
105 foreach (keys %supplierlist){
106 push @sloopy, (($booksellerid and $booksellerid eq $_ ) ?
107 {id=>$_, name=>$supplierlist{$_}, selected=>1} :
108 {id=>$_, name=>$supplierlist{$_}} ) ;
110 $template->param(SUPPLIER_LOOP => \@sloopy);
112 $template->param(Supplier=>$supplierlist{$booksellerid}) if ($booksellerid);
113 $template->param(booksellerid=>$booksellerid) if ($booksellerid);
115 my @lateorders = GetLateOrders(
119 C4::Dates->new($estimateddeliverydatefrom)->output("iso"),
120 C4::Dates->new($estimateddeliverydateto)->output("iso")
124 foreach (@lateorders){
125 $total += $_->{subtotal};
129 my $letters=GetLetters("claimacquisition");
130 foreach (keys %$letters){
131 push @letters, {code=>$_,name=>$letters->{$_}};
133 $template->param(letters=>\@letters) if (@letters);
135 $template->param(ERROR_LOOP => \@errors) if (@errors);
137 lateorders => \@lateorders,
139 estimateddeliverydatefrom => $estimateddeliverydatefrom,
140 estimateddeliverydateto => $estimateddeliverydateto,
142 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
143 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
145 output_html_with_http_headers $input, $cookie, $template->output;