Lines 27-32
use C4::Koha;
Link Here
|
27 |
use C4::Branch; |
27 |
use C4::Branch; |
28 |
use C4::Letters; |
28 |
use C4::Letters; |
29 |
use C4::Members; |
29 |
use C4::Members; |
|
|
30 |
use C4::Overdues; |
30 |
|
31 |
|
31 |
our $input = new CGI; |
32 |
our $input = new CGI; |
32 |
my $dbh = C4::Context->dbh; |
33 |
my $dbh = C4::Context->dbh; |
Lines 44-54
sub blank_row {
Link Here
|
44 |
for my $rp (@rule_params) { |
45 |
for my $rp (@rule_params) { |
45 |
for my $n (1 .. 3) { |
46 |
for my $n (1 .. 3) { |
46 |
my $key = "${rp}${n}-$category_code"; |
47 |
my $key = "${rp}${n}-$category_code"; |
47 |
|
48 |
|
48 |
if (utf8::is_utf8($key)) { |
49 |
if (utf8::is_utf8($key)) { |
49 |
utf8::encode($key); |
50 |
utf8::encode($key); |
50 |
} |
51 |
} |
51 |
|
52 |
|
52 |
my $value = $input->param($key); |
53 |
my $value = $input->param($key); |
53 |
if ($value) { |
54 |
if ($value) { |
54 |
return 0; |
55 |
return 0; |
Lines 84-89
if ($op eq 'save') {
Link Here
|
84 |
my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); |
85 |
my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); |
85 |
my $sth_update=$dbh->prepare("UPDATE overduerules SET delay1=?, letter1=?, debarred1=?, delay2=?, letter2=?, debarred2=?, delay3=?, letter3=?, debarred3=? WHERE branchcode=? AND categorycode=?"); |
86 |
my $sth_update=$dbh->prepare("UPDATE overduerules SET delay1=?, letter1=?, debarred1=?, delay2=?, letter2=?, debarred2=?, delay3=?, letter3=?, debarred3=? WHERE branchcode=? AND categorycode=?"); |
86 |
my $sth_delete=$dbh->prepare("DELETE FROM overduerules WHERE branchcode=? AND categorycode=?"); |
87 |
my $sth_delete=$dbh->prepare("DELETE FROM overduerules WHERE branchcode=? AND categorycode=?"); |
|
|
88 |
my $sth_insert_mtt = $dbh->prepare(" |
89 |
INSERT INTO overduerules_transport_types( |
90 |
branchcode, categorycode, letternumber, message_transport_type |
91 |
) VALUES ( |
92 |
?, ?, ?, ? |
93 |
) |
94 |
"); |
95 |
my $sth_delete_mtt = $dbh->prepare(" |
96 |
DELETE FROM overduerules_transport_types |
97 |
WHERE branchcode = ? AND categorycode = ? |
98 |
"); |
99 |
|
87 |
foreach my $key (@names){ |
100 |
foreach my $key (@names){ |
88 |
# ISSUES |
101 |
# ISSUES |
89 |
if ($key =~ /(delay|letter|debarred)([1-3])-(.*)/) { |
102 |
if ($key =~ /(delay|letter|debarred)([1-3])-(.*)/) { |
Lines 166-171
if ($op eq 'save') {
Link Here
|
166 |
($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0) |
179 |
($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0) |
167 |
); |
180 |
); |
168 |
} |
181 |
} |
|
|
182 |
|
183 |
$sth_delete_mtt->execute( $branch, $bor ); |
184 |
for my $letternumber ( 1..3 ) { |
185 |
my @mtt = $input->param( "mtt${letternumber}-$bor" ); |
186 |
next unless @mtt; |
187 |
for my $mtt ( @mtt ) { |
188 |
$sth_insert_mtt->execute( $branch, $bor, $letternumber, $mtt); |
189 |
} |
190 |
} |
169 |
} |
191 |
} |
170 |
} |
192 |
} |
171 |
} |
193 |
} |
Lines 185-203
my $countletters = keys %{$letters};
Link Here
|
185 |
|
207 |
|
186 |
my @line_loop; |
208 |
my @line_loop; |
187 |
|
209 |
|
|
|
210 |
my $message_transport_types = C4::Letters::GetMessageTransportTypes(); |
211 |
my ( @first, @second, @third ); |
188 |
for my $data (@categories) { |
212 |
for my $data (@categories) { |
189 |
my %row = ( |
|
|
190 |
overduename => $data->{'categorycode'}, |
191 |
line => $data->{'description'} |
192 |
); |
193 |
if (%temphash and not $input_saved){ |
213 |
if (%temphash and not $input_saved){ |
194 |
# if we managed to save the form submission, don't |
214 |
# if we managed to save the form submission, don't |
195 |
# reuse %temphash, but take the values from the |
215 |
# reuse %temphash, but take the values from the |
196 |
# database - this makes it easier to identify |
216 |
# database - this makes it easier to identify |
197 |
# bugs where the form submission was not correctly saved |
217 |
# bugs where the form submission was not correctly saved |
198 |
for (my $i=1;$i<=3;$i++){ |
218 |
for my $i ( 1..3 ){ |
199 |
$row{"delay$i"}=$temphash{$data->{'categorycode'}}->{"delay$i"}; |
219 |
my %row = ( |
200 |
$row{"debarred$i"}=$temphash{$data->{'categorycode'}}->{"debarred$i"}; |
220 |
overduename => $data->{'categorycode'}, |
|
|
221 |
line => $data->{'description'} |
222 |
); |
223 |
$row{delay}=$temphash{$data->{'categorycode'}}->{"delay$i"}; |
224 |
$row{debarred}=$temphash{$data->{'categorycode'}}->{"debarred$i"}; |
201 |
if ($countletters){ |
225 |
if ($countletters){ |
202 |
my @letterloop; |
226 |
my @letterloop; |
203 |
foreach my $thisletter (sort { $letters->{$a} cmp $letters->{$b} } keys %$letters) { |
227 |
foreach my $thisletter (sort { $letters->{$a} cmp $letters->{$b} } keys %$letters) { |
Lines 212-221
for my $data (@categories) {
Link Here
|
212 |
); |
236 |
); |
213 |
push @letterloop, \%letterrow; |
237 |
push @letterloop, \%letterrow; |
214 |
} |
238 |
} |
215 |
$row{"letterloop$i"}=\@letterloop; |
239 |
$row{letterloop}=\@letterloop; |
216 |
} else { |
240 |
} else { |
217 |
$row{"noletter"}=1; |
241 |
$row{noletter}=1; |
218 |
$row{"letter$i"}=$temphash{$data->{'categorycode'}}->{"letter$i"}; |
242 |
$row{letter}=$temphash{$data->{'categorycode'}}->{"letter$i"}; |
|
|
243 |
} |
244 |
my @selected_mtts = @{ GetOverdueMessageTransportTypes( $branch, $data->{'categorycode'}, $i) }; |
245 |
my @mtts; |
246 |
for my $mtt ( @$message_transport_types ) { |
247 |
push @mtts, { |
248 |
value => $mtt, |
249 |
selected => ( grep {/$mtt/} @selected_mtts ) ? 1 : 0 , |
250 |
} |
251 |
} |
252 |
$row{message_transport_types} = \@mtts; |
253 |
if ( $i == 1 ) { |
254 |
push @first, \%row; |
255 |
} elsif ( $i == 2 ) { |
256 |
push @second, \%row; |
257 |
} else { |
258 |
push @third, \%row; |
219 |
} |
259 |
} |
220 |
} |
260 |
} |
221 |
} else { |
261 |
} else { |
Lines 223-229
for my $data (@categories) {
Link Here
|
223 |
my $sth2=$dbh->prepare("SELECT * from overduerules WHERE branchcode=? AND categorycode=?"); |
263 |
my $sth2=$dbh->prepare("SELECT * from overduerules WHERE branchcode=? AND categorycode=?"); |
224 |
$sth2->execute($branch,$data->{'categorycode'}); |
264 |
$sth2->execute($branch,$data->{'categorycode'}); |
225 |
my $dat=$sth2->fetchrow_hashref; |
265 |
my $dat=$sth2->fetchrow_hashref; |
226 |
for (my $i=1;$i<=3;$i++){ |
266 |
for my $i ( 1..3 ){ |
|
|
267 |
my %row = ( |
268 |
overduename => $data->{'categorycode'}, |
269 |
line => $data->{'description'} |
270 |
); |
227 |
if ($countletters){ |
271 |
if ($countletters){ |
228 |
my @letterloop; |
272 |
my @letterloop; |
229 |
foreach my $thisletter (sort { $letters->{$a} cmp $letters->{$b} } keys %$letters) { |
273 |
foreach my $thisletter (sort { $letters->{$a} cmp $letters->{$b} } keys %$letters) { |
Lines 237-255
for my $data (@categories) {
Link Here
|
237 |
); |
281 |
); |
238 |
push @letterloop, \%letterrow; |
282 |
push @letterloop, \%letterrow; |
239 |
} |
283 |
} |
240 |
$row{"letterloop$i"}=\@letterloop; |
284 |
$row{letterloop}=\@letterloop; |
241 |
} else { |
285 |
} else { |
242 |
$row{"noletter"}=1; |
286 |
$row{noletter}=1; |
243 |
if ($dat->{"letter$i"}){$row{"letter$i"}=$dat->{"letter$i"};} |
287 |
if ($dat->{"letter$i"}){$row{letter}=$dat->{"letter$i"};} |
|
|
288 |
} |
289 |
if ($dat->{"delay$i"}){$row{delay}=$dat->{"delay$i"};} |
290 |
if ($dat->{"debarred$i"}){$row{debarred}=$dat->{"debarred$i"};} |
291 |
my @selected_mtts = @{ GetOverdueMessageTransportTypes( $branch, $data->{'categorycode'}, $i) }; |
292 |
my @mtts; |
293 |
for my $mtt ( @$message_transport_types ) { |
294 |
push @mtts, { |
295 |
value => $mtt, |
296 |
selected => ( grep {/$mtt/} @selected_mtts ) ? 1 : 0 , |
297 |
} |
244 |
} |
298 |
} |
245 |
if ($dat->{"delay$i"}){$row{"delay$i"}=$dat->{"delay$i"};} |
299 |
$row{message_transport_types} = \@mtts; |
246 |
if ($dat->{"debarred$i"}){$row{"debarred$i"}=$dat->{"debarred$i"};} |
300 |
if ( $i == 1 ) { |
|
|
301 |
push @first, \%row; |
302 |
} elsif ( $i == 2 ) { |
303 |
push @second, \%row; |
304 |
} else { |
305 |
push @third, \%row; |
306 |
} |
307 |
|
247 |
} |
308 |
} |
248 |
} |
309 |
} |
249 |
push @line_loop,\%row; |
|
|
250 |
} |
310 |
} |
251 |
|
311 |
|
252 |
$template->param(table=> \@line_loop, |
312 |
my @tabs = ( |
253 |
branchloop => $branchloop, |
313 |
{ |
254 |
branch => $branch); |
314 |
id => 'first', |
|
|
315 |
number => 1, |
316 |
values => \@first, |
317 |
}, |
318 |
{ |
319 |
id => 'second', |
320 |
number => 2, |
321 |
values => \@second, |
322 |
}, |
323 |
{ |
324 |
id => 'third', |
325 |
number => 3, |
326 |
values => \@third, |
327 |
}, |
328 |
); |
329 |
|
330 |
$template->param( |
331 |
table => ( @first or @second or @third ? 1 : 0 ), |
332 |
branchloop => $branchloop, |
333 |
branch => $branch, |
334 |
tabs => \@tabs, |
335 |
message_transport_types => $message_transport_types, |
336 |
); |
255 |
output_html_with_http_headers $input, $cookie, $template->output; |
337 |
output_html_with_http_headers $input, $cookie, $template->output; |
256 |
- |
|
|