|
Lines 56-70
use C4::Branch; # GetBranches
Link Here
|
| 56 |
use Koha::DateUtils; |
56 |
use Koha::DateUtils; |
| 57 |
|
57 |
|
| 58 |
my $input = new CGI; |
58 |
my $input = new CGI; |
| 59 |
my ($template, $loggedinuser, $cookie) = get_template_and_user({ |
59 |
my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({ |
| 60 |
template_name => "acqui/lateorders.tmpl", |
60 |
template_name => "acqui/lateorders.tmpl", |
| 61 |
query => $input, |
61 |
query => $input, |
| 62 |
type => "intranet", |
62 |
type => "intranet", |
| 63 |
authnotrequired => 0, |
63 |
authnotrequired => 0, |
| 64 |
flagsrequired => {acquisition => 'order_receive'}, |
64 |
flagsrequired => {acquisition => 'order_receive'}, |
| 65 |
debug => 1, |
65 |
debug => 1, |
| 66 |
}); |
66 |
}); |
| 67 |
|
67 |
|
|
|
68 |
# Check if user has rights to access this page |
| 69 |
my $can_claim_for_all = 0; |
| 70 |
if ($userflags->{superlibrarian} |
| 71 |
or (!ref $userflags->{acquisition} and $userflags->{acquisition}) |
| 72 |
or (ref $userflags->{acquisition} |
| 73 |
and $userflags->{acquisition}->{order_claim_for_all} |
| 74 |
) |
| 75 |
) { |
| 76 |
$can_claim_for_all = 1; |
| 77 |
} |
| 78 |
|
| 79 |
if ( !$can_claim_for_all |
| 80 |
and ( |
| 81 |
ref $userflags->{acquisition} |
| 82 |
and not $userflags->{acquisition}->{order_receive} |
| 83 |
) |
| 84 |
) { |
| 85 |
# Will fail to authenticate, so redirect to login screen |
| 86 |
checkauth($input, 0, { acquisition => 'order_receive' }, "intranet"); |
| 87 |
} |
| 88 |
|
| 68 |
my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0 |
89 |
my $booksellerid = $input->param('booksellerid') || undef; # we don't want "" or 0 |
| 69 |
my $delay = $input->param('delay') // 0; |
90 |
my $delay = $input->param('delay') // 0; |
| 70 |
|
91 |
|
|
Lines 101-122
if ( $delay and not $delay =~ /^\d{1,3}$/ ) {
Link Here
|
| 101 |
} |
122 |
} |
| 102 |
|
123 |
|
| 103 |
if ($op and $op eq "send_alert"){ |
124 |
if ($op and $op eq "send_alert"){ |
| 104 |
my @ordernums = $input->param("ordernumber");# FIXME: Fallback values? |
125 |
my @claim_for = $input->param('claim_for'); # FIXME: Fallback values? |
| 105 |
my $err; |
126 |
my (@ordernums, @not_claimed); |
| 106 |
eval { |
127 |
if (not $can_claim_for_all) { |
| 107 |
$err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") ); # FIXME: Fallback value? |
128 |
foreach my $ordernumber (@claim_for) { |
| 108 |
if ( not ref $err or not exists $err->{error} ) { |
129 |
my $order = GetOrder($ordernumber); |
| 109 |
AddClaim ( $_ ) for @ordernums; |
130 |
if (CanUserManageBasket($loggedinuser, $order->{basketno}, $userflags)) { |
|
|
131 |
push @ordernums, $ordernumber; |
| 132 |
} else { |
| 133 |
push @not_claimed, $ordernumber; |
| 134 |
} |
| 110 |
} |
135 |
} |
| 111 |
}; |
|
|
| 112 |
|
| 113 |
if ( $@ ) { |
| 114 |
$template->param(error_claim => $@); |
| 115 |
} elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) { |
| 116 |
$template->{VARS}->{'error_claim'} = "no_email"; |
| 117 |
} else { |
136 |
} else { |
| 118 |
$template->{VARS}->{'info_claim'} = 1; |
137 |
@ordernums = @claim_for; |
|
|
138 |
} |
| 139 |
if (scalar @ordernums > 0) { |
| 140 |
my $err; |
| 141 |
eval { |
| 142 |
$err = SendAlerts( 'claimacquisition', \@ordernums, $input->param("letter_code") ); # FIXME: Fallback value? |
| 143 |
if ( not ref $err or not exists $err->{error} ) { |
| 144 |
foreach my $ordernumber (@ordernums) { |
| 145 |
AddClaim($ordernumber); |
| 146 |
} |
| 147 |
} |
| 148 |
}; |
| 149 |
if ( $@ ) { |
| 150 |
$template->param(error_claim => $@); |
| 151 |
} elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) { |
| 152 |
$template->param(error_claim => "no_email"); |
| 153 |
} else { |
| 154 |
$template->param(info_claim => 1); |
| 155 |
} |
| 119 |
} |
156 |
} |
|
|
157 |
$template->param(not_claimed => \@not_claimed); |
| 120 |
} |
158 |
} |
| 121 |
|
159 |
|
| 122 |
my @parameters = ( $delay ); |
160 |
my @parameters = ( $delay ); |
|
Lines 155-162
if ($estimateddeliverydateto_dt) {
Link Here
|
| 155 |
my @lateorders = GetLateOrders( @parameters ); |
193 |
my @lateorders = GetLateOrders( @parameters ); |
| 156 |
|
194 |
|
| 157 |
my $total; |
195 |
my $total; |
| 158 |
foreach (@lateorders){ |
196 |
foreach my $order (@lateorders){ |
| 159 |
$total += $_->{subtotal}; |
197 |
if ( (not $can_claim_for_all) |
|
|
198 |
and (not CanUserManageBasket($loggedinuser, $order->{basketno}, $userflags)) |
| 199 |
) { |
| 200 |
$order->{cannot_claim} = 1; |
| 201 |
} |
| 202 |
$total += $order->{subtotal}; |
| 160 |
} |
203 |
} |
| 161 |
|
204 |
|
| 162 |
my @letters; |
205 |
my @letters; |