Lines 31-43
use C4::Overdues;
Link Here
|
31 |
|
31 |
|
32 |
our $input = new CGI; |
32 |
our $input = new CGI; |
33 |
my $dbh = C4::Context->dbh; |
33 |
my $dbh = C4::Context->dbh; |
34 |
|
34 |
warn "INLIBRO"; |
35 |
my @categories = @{$dbh->selectall_arrayref( |
35 |
my @categories = @{$dbh->selectall_arrayref( |
36 |
'SELECT description, categorycode FROM categories WHERE overduenoticerequired > 0', |
36 |
'SELECT description, categorycode FROM categories WHERE overduenoticerequired > 0', |
37 |
{ Slice => {} } |
37 |
{ Slice => {} } |
38 |
)}; |
38 |
)}; |
39 |
my @category_codes = map { $_->{categorycode} } @categories; |
39 |
my @category_codes = map { $_->{categorycode} } @categories; |
40 |
our @rule_params = qw(delay letter debarred); |
40 |
our @rule_params = qw(delay letter debarred invoice); |
41 |
|
41 |
|
42 |
# blank_row($category_code) - return true if the entire row is blank. |
42 |
# blank_row($category_code) - return true if the entire row is blank. |
43 |
sub blank_row { |
43 |
sub blank_row { |
Lines 74-89
my ($template, $loggedinuser, $cookie)
Link Here
|
74 |
debug => 1, |
74 |
debug => 1, |
75 |
}); |
75 |
}); |
76 |
my $err=0; |
76 |
my $err=0; |
77 |
|
77 |
use Data::Dumper; |
78 |
# save the values entered into tables |
78 |
# save the values entered into tables |
79 |
my %temphash; |
79 |
my %temphash; |
80 |
my $input_saved = 0; |
80 |
my $input_saved = 0; |
81 |
if ($op eq 'save') { |
81 |
if ($op eq 'save') { |
82 |
my @names=$input->param(); |
82 |
my @names=$input->param(); |
|
|
83 |
warn "INLIBRO" . join(',', @names); |
83 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total FROM overduerules WHERE branchcode=? AND categorycode=?"); |
84 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total FROM overduerules WHERE branchcode=? AND categorycode=?"); |
84 |
|
85 |
|
85 |
my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); |
86 |
my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay1,letter1,debarred1,invoice1, delay2,letter2,debarred2,invoice2, delay3,letter3,debarred3,invoice3) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); |
86 |
my $sth_update=$dbh->prepare("UPDATE overduerules SET delay1=?, letter1=?, debarred1=?, delay2=?, letter2=?, debarred2=?, delay3=?, letter3=?, debarred3=? WHERE branchcode=? AND categorycode=?"); |
87 |
my $sth_update=$dbh->prepare("UPDATE overduerules SET delay1=?, letter1=?, debarred1=?, invoice1=?, delay2=?, letter2=?, debarred2=?, invoice2=?, delay3=?, letter3=?, debarred3=?, invoice3=? WHERE branchcode=? AND categorycode=?"); |
87 |
my $sth_delete=$dbh->prepare("DELETE FROM overduerules WHERE branchcode=? AND categorycode=?"); |
88 |
my $sth_delete=$dbh->prepare("DELETE FROM overduerules WHERE branchcode=? AND categorycode=?"); |
88 |
my $sth_insert_mtt = $dbh->prepare(" |
89 |
my $sth_insert_mtt = $dbh->prepare(" |
89 |
INSERT INTO overduerules_transport_types( |
90 |
INSERT INTO overduerules_transport_types( |
Lines 99-105
if ($op eq 'save') {
Link Here
|
99 |
|
100 |
|
100 |
foreach my $key (@names){ |
101 |
foreach my $key (@names){ |
101 |
# ISSUES |
102 |
# ISSUES |
102 |
if ($key =~ /(delay|letter|debarred)([1-3])-(.*)/) { |
103 |
if ($key =~ /(delay|letter|debarred|invoice)([1-3])-(.*)/) { |
103 |
my $type = $1; # data type |
104 |
my $type = $1; # data type |
104 |
my $num = $2; # From 1 to 3 |
105 |
my $num = $2; # From 1 to 3 |
105 |
my $bor = $3; # borrower category |
106 |
my $bor = $3; # borrower category |
Lines 115-121
if ($op eq 'save') {
Link Here
|
115 |
|
116 |
|
116 |
# figure out which rows need to be deleted |
117 |
# figure out which rows need to be deleted |
117 |
my @rows_to_delete = grep { blank_row($_) } @category_codes; |
118 |
my @rows_to_delete = grep { blank_row($_) } @category_codes; |
118 |
|
119 |
warn Dumper(%temphash); |
119 |
foreach my $bor (keys %temphash){ |
120 |
foreach my $bor (keys %temphash){ |
120 |
# get category name if we need it for an error message |
121 |
# get category name if we need it for an error message |
121 |
my $bor_category = GetBorrowercategory($bor); |
122 |
my $bor_category = GetBorrowercategory($bor); |
Lines 148-156
if ($op eq 'save') {
Link Here
|
148 |
$err=1; |
149 |
$err=1; |
149 |
} |
150 |
} |
150 |
unless ($err){ |
151 |
unless ($err){ |
151 |
if (($temphash{$bor}->{delay1} and ($temphash{$bor}->{"letter1"} or $temphash{$bor}->{"debarred1"})) |
152 |
if (($temphash{$bor}->{delay1} and ($temphash{$bor}->{"letter1"} or $temphash{$bor}->{"debarred1"} or $temphash{$bor}->{"invoice1"})) |
152 |
or ($temphash{$bor}->{delay2} and ($temphash{$bor}->{"letter2"} or $temphash{$bor}->{"debarred2"})) |
153 |
or ($temphash{$bor}->{delay2} and ($temphash{$bor}->{"letter2"} or $temphash{$bor}->{"debarred2"} or $temphash{$bor}->{"invoice2"})) |
153 |
or ($temphash{$bor}->{delay3} and ($temphash{$bor}->{"letter3"} or $temphash{$bor}->{"debarred3"}))) { |
154 |
or ($temphash{$bor}->{delay3} and ($temphash{$bor}->{"letter3"} or $temphash{$bor}->{"debarred3"} or $temphash{$bor}->{"invoice3"}))) { |
154 |
$sth_search->execute($branch,$bor); |
155 |
$sth_search->execute($branch,$bor); |
155 |
my $res = $sth_search->fetchrow_hashref(); |
156 |
my $res = $sth_search->fetchrow_hashref(); |
156 |
if ($res->{'total'}>0) { |
157 |
if ($res->{'total'}>0) { |
Lines 158-169
if ($op eq 'save') {
Link Here
|
158 |
($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:undef), |
159 |
($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:undef), |
159 |
($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), |
160 |
($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), |
160 |
($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), |
161 |
($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), |
|
|
162 |
($temphash{$bor}->{"invoice1"}?$temphash{$bor}->{"invoice1"}:0), |
161 |
($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:undef), |
163 |
($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:undef), |
162 |
($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), |
164 |
($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), |
163 |
($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), |
165 |
($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), |
|
|
166 |
($temphash{$bor}->{"invoice2"}?$temphash{$bor}->{"invoice2"}:0), |
164 |
($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:undef), |
167 |
($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:undef), |
165 |
($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), |
168 |
($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), |
166 |
($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0), |
169 |
($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0), |
|
|
170 |
($temphash{$bor}->{"invoice3"}?$temphash{$bor}->{"invoice3"}:0), |
167 |
$branch ,$bor |
171 |
$branch ,$bor |
168 |
); |
172 |
); |
169 |
} else { |
173 |
} else { |
Lines 171-182
if ($op eq 'save') {
Link Here
|
171 |
($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:0), |
175 |
($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:0), |
172 |
($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), |
176 |
($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), |
173 |
($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), |
177 |
($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), |
|
|
178 |
($temphash{$bor}->{"invoice1"}?$temphash{$bor}->{"invoice1"}:0), |
174 |
($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:0), |
179 |
($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:0), |
175 |
($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), |
180 |
($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), |
176 |
($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), |
181 |
($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), |
|
|
182 |
($temphash{$bor}->{"invoice2"}?$temphash{$bor}->{"invoice2"}:0), |
177 |
($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:0), |
183 |
($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:0), |
178 |
($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), |
184 |
($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), |
179 |
($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0) |
185 |
($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0), |
|
|
186 |
($temphash{$bor}->{"invoice3"}?$temphash{$bor}->{"invoice3"}:0), |
180 |
); |
187 |
); |
181 |
} |
188 |
} |
182 |
|
189 |
|
Lines 288-293
for my $data (@categories) {
Link Here
|
288 |
} |
295 |
} |
289 |
if ($dat->{"delay$i"}){$row{delay}=$dat->{"delay$i"};} |
296 |
if ($dat->{"delay$i"}){$row{delay}=$dat->{"delay$i"};} |
290 |
if ($dat->{"debarred$i"}){$row{debarred}=$dat->{"debarred$i"};} |
297 |
if ($dat->{"debarred$i"}){$row{debarred}=$dat->{"debarred$i"};} |
|
|
298 |
if ($dat->{"invoice$i"}){$row{invoice}=$dat->{"invoice$i"};} |
291 |
my @selected_mtts = @{ GetOverdueMessageTransportTypes( $branch, $data->{'categorycode'}, $i) }; |
299 |
my @selected_mtts = @{ GetOverdueMessageTransportTypes( $branch, $data->{'categorycode'}, $i) }; |
292 |
my @mtts; |
300 |
my @mtts; |
293 |
for my $mtt ( @$message_transport_types ) { |
301 |
for my $mtt ( @$message_transport_types ) { |
294 |
- |
|
|