|
Lines 80-107
elsif ($op eq 'delete-branch-cat') {
Link Here
|
| 80 |
if ($categorycode eq "*") { |
80 |
if ($categorycode eq "*") { |
| 81 |
my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules"); |
81 |
my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules"); |
| 82 |
$sth_delete->execute(); |
82 |
$sth_delete->execute(); |
| 83 |
} else { |
|
|
| 84 |
my $sth_delete = $dbh->prepare("DELETE FROM default_borrower_circ_rules |
| 85 |
WHERE categorycode = ?"); |
| 86 |
$sth_delete->execute($categorycode); |
| 87 |
} |
83 |
} |
| 88 |
} elsif ($categorycode eq "*") { |
84 |
} elsif ($categorycode eq "*") { |
| 89 |
my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules |
85 |
my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules |
| 90 |
WHERE branchcode = ?"); |
86 |
WHERE branchcode = ?"); |
| 91 |
$sth_delete->execute($branch); |
87 |
$sth_delete->execute($branch); |
| 92 |
} else { |
|
|
| 93 |
my $sth_delete = $dbh->prepare("DELETE FROM branch_borrower_circ_rules |
| 94 |
WHERE branchcode = ? |
| 95 |
AND categorycode = ?"); |
| 96 |
$sth_delete->execute($branch, $categorycode); |
| 97 |
} |
88 |
} |
| 98 |
Koha::CirculationRules->set_rule( |
89 |
Koha::CirculationRules->set_rules( |
| 99 |
{ |
90 |
{ |
| 100 |
branchcode => $branch, |
91 |
categorycode => $categorycode eq '*' ? undef : $categorycode, |
| 101 |
categorycode => $categorycode, |
92 |
branchcode => $branch eq '*' ? undef : $branch, |
| 102 |
itemtype => undef, |
93 |
itemtype => undef, |
| 103 |
rule_name => 'max_holds', |
94 |
rules => { |
| 104 |
rule_value => undef, |
95 |
max_holds => undef, |
|
|
96 |
maxissueqty => undef, |
| 97 |
maxonsiteissueqty => undef, |
| 98 |
} |
| 105 |
} |
99 |
} |
| 106 |
); |
100 |
); |
| 107 |
} |
101 |
} |
|
Lines 182-189
elsif ($op eq 'add') {
Link Here
|
| 182 |
firstremind => $firstremind, |
176 |
firstremind => $firstremind, |
| 183 |
chargeperiod => $chargeperiod, |
177 |
chargeperiod => $chargeperiod, |
| 184 |
chargeperiod_charge_at => $chargeperiod_charge_at, |
178 |
chargeperiod_charge_at => $chargeperiod_charge_at, |
| 185 |
maxissueqty => $maxissueqty, |
|
|
| 186 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 187 |
renewalsallowed => $renewalsallowed, |
179 |
renewalsallowed => $renewalsallowed, |
| 188 |
renewalperiod => $renewalperiod, |
180 |
renewalperiod => $renewalperiod, |
| 189 |
norenewalbefore => $norenewalbefore, |
181 |
norenewalbefore => $norenewalbefore, |
|
Lines 211-216
elsif ($op eq 'add') {
Link Here
|
| 211 |
Koha::IssuingRule->new()->set($params)->store(); |
203 |
Koha::IssuingRule->new()->set($params)->store(); |
| 212 |
} |
204 |
} |
| 213 |
|
205 |
|
|
|
206 |
Koha::CirculationRules->set_rules( |
| 207 |
{ |
| 208 |
categorycode => $bor, |
| 209 |
itemtype => $itemtype, |
| 210 |
branchcode => $br, |
| 211 |
rules => { |
| 212 |
maxissueqty => $maxissueqty, |
| 213 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 214 |
} |
| 215 |
} |
| 216 |
); |
| 217 |
|
| 214 |
} |
218 |
} |
| 215 |
elsif ($op eq "set-branch-defaults") { |
219 |
elsif ($op eq "set-branch-defaults") { |
| 216 |
my $categorycode = $input->param('categorycode'); |
220 |
my $categorycode = $input->param('categorycode'); |
|
Lines 230-264
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 230 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
234 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 231 |
FROM default_circ_rules"); |
235 |
FROM default_circ_rules"); |
| 232 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
236 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
| 233 |
(maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) |
237 |
(holdallowed, hold_fulfillment_policy, returnbranch) |
| 234 |
VALUES (?, ?, ?, ?, ?)"); |
238 |
VALUES (?, ?, ?)"); |
| 235 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
239 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
| 236 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?"); |
240 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?"); |
| 237 |
|
241 |
|
| 238 |
$sth_search->execute(); |
242 |
$sth_search->execute(); |
| 239 |
my $res = $sth_search->fetchrow_hashref(); |
243 |
my $res = $sth_search->fetchrow_hashref(); |
| 240 |
if ($res->{total}) { |
244 |
if ($res->{total}) { |
| 241 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
245 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 242 |
} else { |
246 |
} else { |
| 243 |
$sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
247 |
$sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 244 |
} |
248 |
} |
|
|
249 |
|
| 250 |
Koha::CirculationRules->set_rules( |
| 251 |
{ |
| 252 |
categorycode => undef, |
| 253 |
itemtype => undef, |
| 254 |
branchcode => undef, |
| 255 |
rules => { |
| 256 |
maxissueqty => $maxissueqty, |
| 257 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 258 |
} |
| 259 |
} |
| 260 |
); |
| 245 |
} else { |
261 |
} else { |
| 246 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
262 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 247 |
FROM default_branch_circ_rules |
263 |
FROM default_branch_circ_rules |
| 248 |
WHERE branchcode = ?"); |
264 |
WHERE branchcode = ?"); |
| 249 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
265 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
| 250 |
(branchcode, maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) |
266 |
(branchcode, holdallowed, hold_fulfillment_policy, returnbranch) |
| 251 |
VALUES (?, ?, ?, ?, ?, ?)"); |
267 |
VALUES (?, ?, ?, ?)"); |
| 252 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
268 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
| 253 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
269 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
| 254 |
WHERE branchcode = ?"); |
270 |
WHERE branchcode = ?"); |
| 255 |
$sth_search->execute($branch); |
271 |
$sth_search->execute($branch); |
| 256 |
my $res = $sth_search->fetchrow_hashref(); |
272 |
my $res = $sth_search->fetchrow_hashref(); |
| 257 |
if ($res->{total}) { |
273 |
if ($res->{total}) { |
| 258 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch, $branch); |
274 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch); |
| 259 |
} else { |
275 |
} else { |
| 260 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
276 |
$sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 261 |
} |
277 |
} |
|
|
278 |
|
| 279 |
Koha::CirculationRules->set_rules( |
| 280 |
{ |
| 281 |
categorycode => undef, |
| 282 |
itemtype => undef, |
| 283 |
branchcode => $branch, |
| 284 |
rules => { |
| 285 |
maxissueqty => $maxissueqty, |
| 286 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 287 |
} |
| 288 |
} |
| 289 |
); |
| 262 |
} |
290 |
} |
| 263 |
} |
291 |
} |
| 264 |
elsif ($op eq "add-branch-cat") { |
292 |
elsif ($op eq "add-branch-cat") { |
|
Lines 275-398
elsif ($op eq "add-branch-cat") {
Link Here
|
| 275 |
|
303 |
|
| 276 |
if ($branch eq "*") { |
304 |
if ($branch eq "*") { |
| 277 |
if ($categorycode eq "*") { |
305 |
if ($categorycode eq "*") { |
| 278 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
306 |
Koha::CirculationRules->set_rules( |
| 279 |
FROM default_circ_rules"); |
|
|
| 280 |
my $sth_insert = $dbh->prepare(q| |
| 281 |
INSERT INTO default_circ_rules |
| 282 |
(maxissueqty, maxonsiteissueqty) |
| 283 |
VALUES (?, ?, ) |
| 284 |
|); |
| 285 |
my $sth_update = $dbh->prepare(q| |
| 286 |
UPDATE default_circ_rules |
| 287 |
SET maxissueqty = ?, |
| 288 |
maxonsiteissueqty = ? |
| 289 |
|); |
| 290 |
|
| 291 |
$sth_search->execute(); |
| 292 |
my $res = $sth_search->fetchrow_hashref(); |
| 293 |
if ($res->{total}) { |
| 294 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty ); |
| 295 |
} else { |
| 296 |
$sth_insert->execute( $maxissueqty, $maxonsiteissueqty ); |
| 297 |
} |
| 298 |
|
| 299 |
Koha::CirculationRules->set_rule( |
| 300 |
{ |
307 |
{ |
| 301 |
branchcode => undef, |
|
|
| 302 |
categorycode => undef, |
308 |
categorycode => undef, |
| 303 |
itemtype => undef, |
309 |
itemtype => undef, |
| 304 |
rule_name => 'max_holds', |
310 |
branchcode => undef, |
| 305 |
rule_value => $max_holds, |
311 |
rules => { |
|
|
312 |
max_holds => $max_holds, |
| 313 |
maxissueqty => $maxissueqty, |
| 314 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 315 |
} |
| 306 |
} |
316 |
} |
| 307 |
); |
317 |
); |
| 308 |
} else { |
318 |
} else { |
| 309 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
319 |
Koha::CirculationRules->set_rules( |
| 310 |
FROM default_borrower_circ_rules |
|
|
| 311 |
WHERE categorycode = ?"); |
| 312 |
my $sth_insert = $dbh->prepare(q| |
| 313 |
INSERT INTO default_borrower_circ_rules |
| 314 |
(categorycode, maxissueqty, maxonsiteissueqty) |
| 315 |
VALUES (?, ?, ?, ?) |
| 316 |
|); |
| 317 |
my $sth_update = $dbh->prepare(q| |
| 318 |
UPDATE default_borrower_circ_rules |
| 319 |
SET maxissueqty = ?, |
| 320 |
maxonsiteissueqty = ? |
| 321 |
WHERE categorycode = ? |
| 322 |
|); |
| 323 |
$sth_search->execute($branch); |
| 324 |
my $res = $sth_search->fetchrow_hashref(); |
| 325 |
if ($res->{total}) { |
| 326 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty, $categorycode ); |
| 327 |
} else { |
| 328 |
$sth_insert->execute( $categorycode, $maxissueqty, $maxonsiteissueqty ); |
| 329 |
} |
| 330 |
|
| 331 |
Koha::CirculationRules->set_rule( |
| 332 |
{ |
320 |
{ |
| 333 |
branchcode => undef, |
|
|
| 334 |
categorycode => $categorycode, |
321 |
categorycode => $categorycode, |
| 335 |
itemtype => undef, |
322 |
itemtype => undef, |
| 336 |
rule_name => 'max_holds', |
323 |
branchcode => undef, |
| 337 |
rule_value => $max_holds, |
324 |
rules => { |
|
|
325 |
max_holds => $max_holds, |
| 326 |
maxissueqty => $maxissueqty, |
| 327 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 328 |
} |
| 338 |
} |
329 |
} |
| 339 |
); |
330 |
); |
| 340 |
} |
331 |
} |
| 341 |
} elsif ($categorycode eq "*") { |
332 |
} elsif ($categorycode eq "*") { |
| 342 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
333 |
Koha::CirculationRules->set_rules( |
| 343 |
FROM default_branch_circ_rules |
|
|
| 344 |
WHERE branchcode = ?"); |
| 345 |
my $sth_insert = $dbh->prepare(q| |
| 346 |
INSERT INTO default_branch_circ_rules |
| 347 |
(branchcode, maxissueqty, maxonsiteissueqty) |
| 348 |
VALUES (?, ?, ?) |
| 349 |
|); |
| 350 |
my $sth_update = $dbh->prepare(q| |
| 351 |
UPDATE default_branch_circ_rules |
| 352 |
SET maxissueqty = ?, |
| 353 |
maxonsiteissueqty = ? |
| 354 |
WHERE branchcode = ? |
| 355 |
|); |
| 356 |
$sth_search->execute($branch); |
| 357 |
my $res = $sth_search->fetchrow_hashref(); |
| 358 |
if ($res->{total}) { |
| 359 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $branch); |
| 360 |
} else { |
| 361 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty); |
| 362 |
} |
| 363 |
} else { |
| 364 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 365 |
FROM branch_borrower_circ_rules |
| 366 |
WHERE branchcode = ? |
| 367 |
AND categorycode = ?"); |
| 368 |
my $sth_insert = $dbh->prepare(q| |
| 369 |
INSERT INTO branch_borrower_circ_rules |
| 370 |
(branchcode, categorycode, maxissueqty, maxonsiteissueqty) |
| 371 |
VALUES (?, ?, ?, ?) |
| 372 |
|); |
| 373 |
my $sth_update = $dbh->prepare(q| |
| 374 |
UPDATE branch_borrower_circ_rules |
| 375 |
SET maxissueqty = ?, |
| 376 |
maxonsiteissueqty = ? |
| 377 |
WHERE branchcode = ? |
| 378 |
AND categorycode = ? |
| 379 |
|); |
| 380 |
|
| 381 |
$sth_search->execute($branch, $categorycode); |
| 382 |
my $res = $sth_search->fetchrow_hashref(); |
| 383 |
if ($res->{total}) { |
| 384 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $branch, $categorycode); |
| 385 |
} else { |
| 386 |
$sth_insert->execute($branch, $categorycode, $maxissueqty, $maxonsiteissueqty); |
| 387 |
} |
| 388 |
|
| 389 |
Koha::CirculationRules->set_rule( |
| 390 |
{ |
334 |
{ |
|
|
335 |
categorycode => undef, |
| 336 |
itemtype => undef, |
| 391 |
branchcode => $branch, |
337 |
branchcode => $branch, |
|
|
338 |
rules => { |
| 339 |
max_holds => $max_holds, |
| 340 |
maxissueqty => $maxissueqty, |
| 341 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 342 |
} |
| 343 |
} |
| 344 |
); |
| 345 |
} else { |
| 346 |
Koha::CirculationRules->set_rules( |
| 347 |
{ |
| 392 |
categorycode => $categorycode, |
348 |
categorycode => $categorycode, |
| 393 |
itemtype => undef, |
349 |
itemtype => undef, |
| 394 |
rule_name => 'max_holds', |
350 |
branchcode => $branch, |
| 395 |
rule_value => $max_holds, |
351 |
rules => { |
|
|
352 |
max_holds => $max_holds, |
| 353 |
maxissueqty => $maxissueqty, |
| 354 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 355 |
} |
| 396 |
} |
356 |
} |
| 397 |
); |
357 |
); |
| 398 |
} |
358 |
} |
|
Lines 560-598
while (my $row = $sth2->fetchrow_hashref) {
Link Here
|
| 560 |
|
520 |
|
| 561 |
my @sorted_row_loop = sort by_category_and_itemtype @row_loop; |
521 |
my @sorted_row_loop = sort by_category_and_itemtype @row_loop; |
| 562 |
|
522 |
|
| 563 |
my $sth_branch_cat; |
|
|
| 564 |
if ($branch eq "*") { |
| 565 |
$sth_branch_cat = $dbh->prepare(" |
| 566 |
SELECT default_borrower_circ_rules.*, categories.description AS humancategorycode |
| 567 |
FROM default_borrower_circ_rules |
| 568 |
JOIN categories USING (categorycode) |
| 569 |
|
| 570 |
"); |
| 571 |
$sth_branch_cat->execute(); |
| 572 |
} else { |
| 573 |
$sth_branch_cat = $dbh->prepare(" |
| 574 |
SELECT branch_borrower_circ_rules.*, categories.description AS humancategorycode |
| 575 |
FROM branch_borrower_circ_rules |
| 576 |
JOIN categories USING (categorycode) |
| 577 |
WHERE branch_borrower_circ_rules.branchcode = ? |
| 578 |
"); |
| 579 |
$sth_branch_cat->execute($branch); |
| 580 |
} |
| 581 |
|
| 582 |
my @branch_cat_rules = (); |
| 583 |
while (my $row = $sth_branch_cat->fetchrow_hashref) { |
| 584 |
push @branch_cat_rules, $row; |
| 585 |
} |
| 586 |
my @sorted_branch_cat_rules = sort { $a->{'humancategorycode'} cmp $b->{'humancategorycode'} } @branch_cat_rules; |
| 587 |
|
| 588 |
# note undef maxissueqty so that template can deal with them |
| 589 |
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { |
| 590 |
$entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty}); |
| 591 |
$entry->{unlimited_maxonsiteissueqty} = 1 unless defined($entry->{maxonsiteissueqty}); |
| 592 |
} |
| 593 |
|
| 594 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |
| 595 |
|
| 596 |
my $sth_branch_item; |
523 |
my $sth_branch_item; |
| 597 |
if ($branch eq "*") { |
524 |
if ($branch eq "*") { |
| 598 |
$sth_branch_item = $dbh->prepare(" |
525 |
$sth_branch_item = $dbh->prepare(" |
|
Lines 633-639
foreach my $entry (@sorted_branch_item_rules) {
Link Here
|
| 633 |
|
560 |
|
| 634 |
$template->param(show_branch_cat_rule_form => 1); |
561 |
$template->param(show_branch_cat_rule_form => 1); |
| 635 |
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules); |
562 |
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules); |
| 636 |
$template->param(branch_cat_rule_loop => \@sorted_branch_cat_rules); |
|
|
| 637 |
|
563 |
|
| 638 |
my $sth_defaults; |
564 |
my $sth_defaults; |
| 639 |
if ($branch eq "*") { |
565 |
if ($branch eq "*") { |