|
Lines 42-49
To know on which branch this script have to display late order.
Link Here
|
| 42 |
|
42 |
|
| 43 |
=cut |
43 |
=cut |
| 44 |
|
44 |
|
| 45 |
use strict; |
45 |
use Modern::Perl; |
| 46 |
use warnings; |
|
|
| 47 |
use CGI; |
46 |
use CGI; |
| 48 |
use C4::Bookseller qw( GetBooksellersWithLateOrders ); |
47 |
use C4::Bookseller qw( GetBooksellersWithLateOrders ); |
| 49 |
use C4::Auth; |
48 |
use C4::Auth; |
|
Lines 55-69
use C4::Letters;
Link Here
|
| 55 |
use C4::Branch; # GetBranches |
54 |
use C4::Branch; # GetBranches |
| 56 |
|
55 |
|
| 57 |
my $input = new CGI; |
56 |
my $input = new CGI; |
| 58 |
my ($template, $loggedinuser, $cookie) = get_template_and_user({ |
57 |
my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({ |
| 59 |
template_name => "acqui/lateorders.tmpl", |
58 |
template_name => "acqui/lateorders.tt", |
| 60 |
query => $input, |
59 |
query => $input, |
| 61 |
type => "intranet", |
60 |
type => "intranet", |
| 62 |
authnotrequired => 0, |
61 |
authnotrequired => 0, |
| 63 |
flagsrequired => {acquisition => 'order_receive'}, |
62 |
flagsrequired => {acquisition => '*'}, |
| 64 |
debug => 1, |
63 |
debug => 1, |
| 65 |
}); |
64 |
}); |
| 66 |
|
65 |
|
|
|
66 |
# Check if user has rights to access this page |
| 67 |
my $can_claim_for_all = 0; |
| 68 |
if ($userflags->{superlibrarian} |
| 69 |
or (!ref $userflags->{acquisition} and $userflags->{acquisition}) |
| 70 |
or (ref $userflags->{acquisition} |
| 71 |
and $userflags->{acquisition}->{order_claim_for_all} |
| 72 |
) |
| 73 |
) { |
| 74 |
$can_claim_for_all = 1; |
| 75 |
} |
| 76 |
|
| 77 |
if ( !$can_claim_for_all |
| 78 |
and ( |
| 79 |
ref $userflags->{acquisition} |
| 80 |
and not $userflags->{acquisition}->{order_receive} |
| 81 |
) |
| 82 |
) { |
| 83 |
# Will fail to authenticate, so redirect to login screen |
| 84 |
checkauth($input, 0, { acquisition => 'order_receive' }, "intranet"); |
| 85 |
} |
| 86 |
|
| 67 |
my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0 |
87 |
my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0 |
| 68 |
my $delay = $input->param('delay'); |
88 |
my $delay = $input->param('delay'); |
| 69 |
my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom'); |
89 |
my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom'); |
|
Lines 77-97
if ( $delay and not $delay =~ /^\d{1,3}$/ ) {
Link Here
|
| 77 |
} |
97 |
} |
| 78 |
|
98 |
|
| 79 |
if ($op and $op eq "send_alert"){ |
99 |
if ($op and $op eq "send_alert"){ |
| 80 |
my @ordernums = $input->param("claim_for");# FIXME: Fallback values? |
100 |
my @claim_for = $input->param('claim_for'); # FIXME: Fallback values? |
| 81 |
my $err; |
101 |
my (@ordernums, @not_claimed); |
| 82 |
eval { |
102 |
if (not $can_claim_for_all) { |
| 83 |
$err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") ); # FIXME: Fallback value? |
103 |
foreach my $ordernumber (@claim_for) { |
| 84 |
if ( not ref $err or not exists $err->{error} ) { |
104 |
my $order = GetOrder($ordernumber); |
| 85 |
AddClaim ( $_ ) for @ordernums; |
105 |
if (CanUserManageBasket($loggedinuser, $order->{basketno}, $userflags)) { |
|
|
106 |
push @ordernums, $ordernumber; |
| 107 |
} else { |
| 108 |
push @not_claimed, $ordernumber; |
| 109 |
} |
| 86 |
} |
110 |
} |
| 87 |
}; |
|
|
| 88 |
if ( $@ ) { |
| 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"; |
| 92 |
} else { |
111 |
} else { |
| 93 |
$template->{VARS}->{'info_claim'} = 1; |
112 |
@ordernums = @claim_for; |
| 94 |
} |
113 |
} |
|
|
114 |
if (scalar @ordernums > 0) { |
| 115 |
my $err; |
| 116 |
eval { |
| 117 |
$err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") ); # FIXME: Fallback value? |
| 118 |
if ( not ref $err or not exists $err->{error} ) { |
| 119 |
foreach my $ordernumber (@ordernums) { |
| 120 |
AddClaim($ordernumber); |
| 121 |
} |
| 122 |
} |
| 123 |
}; |
| 124 |
if ( $@ ) { |
| 125 |
$template->param(error_claim => $@); |
| 126 |
} elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) { |
| 127 |
$template->param(error_claim => "no_email"); |
| 128 |
} else { |
| 129 |
$template->param(info_claim => 1); |
| 130 |
} |
| 131 |
} |
| 132 |
$template->param(not_claimed => \@not_claimed); |
| 95 |
} |
133 |
} |
| 96 |
|
134 |
|
| 97 |
my %supplierlist = GetBooksellersWithLateOrders( |
135 |
my %supplierlist = GetBooksellersWithLateOrders( |
|
Lines 121-128
my @lateorders = GetLateOrders(
Link Here
|
| 121 |
); |
159 |
); |
| 122 |
|
160 |
|
| 123 |
my $total; |
161 |
my $total; |
| 124 |
foreach (@lateorders){ |
162 |
foreach my $order (@lateorders){ |
| 125 |
$total += $_->{subtotal}; |
163 |
if ( (not $can_claim_for_all) |
|
|
164 |
and (not CanUserManageBasket($loggedinuser, $order->{basketno}, $userflags)) |
| 165 |
) { |
| 166 |
$order->{cannot_claim} = 1; |
| 167 |
} |
| 168 |
$total += $order->{subtotal}; |
| 126 |
} |
169 |
} |
| 127 |
|
170 |
|
| 128 |
my @letters; |
171 |
my @letters; |