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