Lines 27-33
use C4::Letters;
Link Here
|
27 |
use C4::Members; |
27 |
use C4::Members; |
28 |
use C4::Overdues; |
28 |
use C4::Overdues; |
29 |
use Koha::Libraries; |
29 |
use Koha::Libraries; |
30 |
|
30 |
use Koha::OverdueRules; |
31 |
use Koha::Patron::Categories; |
31 |
use Koha::Patron::Categories; |
32 |
|
32 |
|
33 |
our $input = new CGI; |
33 |
our $input = new CGI; |
Lines 76-82
$branch =
Link Here
|
76 |
: C4::Context->preference('DefaultToLoggedInLibraryOverdueTriggers') ? C4::Context::mybranch() |
76 |
: C4::Context->preference('DefaultToLoggedInLibraryOverdueTriggers') ? C4::Context::mybranch() |
77 |
: Koha::Libraries->search->count() == 1 ? undef |
77 |
: Koha::Libraries->search->count() == 1 ? undef |
78 |
: undef; |
78 |
: undef; |
79 |
$branch ||= q{}; |
79 |
$branch ||= undef; |
80 |
|
80 |
|
81 |
my $op = $input->param('op'); |
81 |
my $op = $input->param('op'); |
82 |
$op ||= q{}; |
82 |
$op ||= q{}; |
Lines 88-98
my %temphash;
Link Here
|
88 |
my $input_saved = 0; |
88 |
my $input_saved = 0; |
89 |
if ($op eq 'save') { |
89 |
if ($op eq 'save') { |
90 |
my @names=$input->multi_param(); |
90 |
my @names=$input->multi_param(); |
91 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total FROM overduerules WHERE branchcode=? AND categorycode=?"); |
|
|
92 |
|
93 |
my $sth_insert = $dbh->prepare("INSERT INTO overduerules (branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); |
94 |
my $sth_update=$dbh->prepare("UPDATE overduerules SET delay1=?, letter1=?, debarred1=?, delay2=?, letter2=?, debarred2=?, delay3=?, letter3=?, debarred3=? WHERE branchcode=? AND categorycode=?"); |
95 |
my $sth_delete=$dbh->prepare("DELETE FROM overduerules WHERE branchcode=? AND categorycode=?"); |
96 |
my $sth_insert_mtt = $dbh->prepare(" |
91 |
my $sth_insert_mtt = $dbh->prepare(" |
97 |
INSERT INTO overduerules_transport_types( |
92 |
INSERT INTO overduerules_transport_types( |
98 |
overduerules_id, letternumber, message_transport_type |
93 |
overduerules_id, letternumber, message_transport_type |
Lines 159-191
if ($op eq 'save') {
Link Here
|
159 |
if (($temphash{$bor}->{delay1} and ($temphash{$bor}->{"letter1"} or $temphash{$bor}->{"debarred1"})) |
154 |
if (($temphash{$bor}->{delay1} and ($temphash{$bor}->{"letter1"} or $temphash{$bor}->{"debarred1"})) |
160 |
or ($temphash{$bor}->{delay2} and ($temphash{$bor}->{"letter2"} or $temphash{$bor}->{"debarred2"})) |
155 |
or ($temphash{$bor}->{delay2} and ($temphash{$bor}->{"letter2"} or $temphash{$bor}->{"debarred2"})) |
161 |
or ($temphash{$bor}->{delay3} and ($temphash{$bor}->{"letter3"} or $temphash{$bor}->{"debarred3"}))) { |
156 |
or ($temphash{$bor}->{delay3} and ($temphash{$bor}->{"letter3"} or $temphash{$bor}->{"debarred3"}))) { |
162 |
$sth_search->execute($branch,$bor); |
157 |
my $overdue_rule = Koha::OverdueRules->find({ branchcode => $branch, categorycode => $bor }); |
163 |
my $res = $sth_search->fetchrow_hashref(); |
158 |
if ( $overdue_rule ) { |
164 |
if ($res->{'total'}>0) { |
159 |
$overdue_rule->update( { |
165 |
$sth_update->execute( |
160 |
delay1 => $temphash{$bor}->{"delay1"} ? $temphash{$bor}->{"delay1"} : undef, |
166 |
($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:undef), |
161 |
letter1 => $temphash{$bor}->{"letter1"} ? $temphash{$bor}->{"letter1"} : "", |
167 |
($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), |
162 |
debarred1 => $temphash{$bor}->{"debarred1"} ? $temphash{$bor}->{"debarred1"} : 0, |
168 |
($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), |
163 |
delay2 => $temphash{$bor}->{"delay2"} ? $temphash{$bor}->{"delay2"} : undef, |
169 |
($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:undef), |
164 |
letter2 => $temphash{$bor}->{"letter2"} ? $temphash{$bor}->{"letter2"} : "", |
170 |
($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), |
165 |
debarred2 => $temphash{$bor}->{"debarred2"} ? $temphash{$bor}->{"debarred2"} : 0, |
171 |
($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), |
166 |
delay3 => $temphash{$bor}->{"delay3"} ? $temphash{$bor}->{"delay3"} : undef, |
172 |
($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:undef), |
167 |
letter3 => $temphash{$bor}->{"letter3"} ? $temphash{$bor}->{"letter3"} : "", |
173 |
($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), |
168 |
debarred3 => $temphash{$bor}->{"debarred3"} ? $temphash{$bor}->{"debarred3"} : 0, |
174 |
($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0), |
169 |
}; |
175 |
$branch ,$bor |
|
|
176 |
); |
177 |
} else { |
170 |
} else { |
178 |
$sth_insert->execute($branch,$bor, |
171 |
$overdue_rule = Koha::OverdueRule->new({ |
179 |
($temphash{$bor}->{"delay1"}?$temphash{$bor}->{"delay1"}:0), |
172 |
branchcode => $branch, |
180 |
($temphash{$bor}->{"letter1"}?$temphash{$bor}->{"letter1"}:""), |
173 |
categorycode => $bor, |
181 |
($temphash{$bor}->{"debarred1"}?$temphash{$bor}->{"debarred1"}:0), |
174 |
delay1 => $temphash{$bor}->{"delay1"} ? $temphash{$bor}->{"delay1"} : undef , |
182 |
($temphash{$bor}->{"delay2"}?$temphash{$bor}->{"delay2"}:0), |
175 |
letter1 => $temphash{$bor}->{"letter1"} ? $temphash{$bor}->{"letter1"} : "" , |
183 |
($temphash{$bor}->{"letter2"}?$temphash{$bor}->{"letter2"}:""), |
176 |
debarred1 => $temphash{$bor}->{"debarred1"} ? $temphash{$bor}->{"debarred1"} : 0 , |
184 |
($temphash{$bor}->{"debarred2"}?$temphash{$bor}->{"debarred2"}:0), |
177 |
delay2 => $temphash{$bor}->{"delay2"} ? $temphash{$bor}->{"delay2"} : undef , |
185 |
($temphash{$bor}->{"delay3"}?$temphash{$bor}->{"delay3"}:0), |
178 |
letter2 => $temphash{$bor}->{"letter2"} ? $temphash{$bor}->{"letter2"} : "" , |
186 |
($temphash{$bor}->{"letter3"}?$temphash{$bor}->{"letter3"}:""), |
179 |
debarred2 => $temphash{$bor}->{"debarred2"} ? $temphash{$bor}->{"debarred2"} : 0 , |
187 |
($temphash{$bor}->{"debarred3"}?$temphash{$bor}->{"debarred3"}:0) |
180 |
delay3 => $temphash{$bor}->{"delay3"} ? $temphash{$bor}->{"delay3"} : undef , |
188 |
); |
181 |
letter3 => $temphash{$bor}->{"letter3"} ? $temphash{$bor}->{"letter3"} : "" , |
|
|
182 |
debarred3 => $temphash{$bor}->{"debarred3"} ? $temphash{$bor}->{"debarred3"} : 0 , |
183 |
})->store(); |
189 |
} |
184 |
} |
190 |
|
185 |
|
191 |
$sth_delete_mtt->execute( $branch, $bor ); |
186 |
$sth_delete_mtt->execute( $branch, $bor ); |
Lines 201-207
if ($op eq 'save') {
Link Here
|
201 |
} |
196 |
} |
202 |
unless ($err) { |
197 |
unless ($err) { |
203 |
for my $category_code (@rows_to_delete) { |
198 |
for my $category_code (@rows_to_delete) { |
204 |
$sth_delete->execute($branch, $category_code); |
199 |
my $overdue_rule = Koha::OverdueRules->find({ branchcode => $branch, categorycode => $category_code }); |
|
|
200 |
$overdue_rule->delete if $overdue_rule; |
205 |
} |
201 |
} |
206 |
$template->param(datasaved => 1); |
202 |
$template->param(datasaved => 1); |
207 |
$input_saved = 1; |
203 |
$input_saved = 1; |
Lines 252-260
for my $patron_category (@patron_categories) {
Link Here
|
252 |
} |
248 |
} |
253 |
} else { |
249 |
} else { |
254 |
#getting values from table |
250 |
#getting values from table |
255 |
my $sth2=$dbh->prepare("SELECT * from overduerules WHERE branchcode=? AND categorycode=?"); |
251 |
my $overdue_rule = Koha::OverdueRules->find({ branchcode => $branch, categorycode => $patron_category->categorycode }); |
256 |
$sth2->execute($branch,$patron_category->categorycode); |
252 |
my $dat = $overdue_rule ? $overdue_rule->unblessed : {}; |
257 |
my $dat=$sth2->fetchrow_hashref; |
|
|
258 |
for my $i ( 1..3 ){ |
253 |
for my $i ( 1..3 ){ |
259 |
my %row = ( |
254 |
my %row = ( |
260 |
overduename => $patron_category->categorycode, |
255 |
overduename => $patron_category->categorycode, |
261 |
- |
|
|