|
Lines 91-118
elsif ($op eq 'delete-branch-cat') {
Link Here
|
| 91 |
if ($categorycode eq "*") { |
91 |
if ($categorycode eq "*") { |
| 92 |
my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules"); |
92 |
my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules"); |
| 93 |
$sth_delete->execute(); |
93 |
$sth_delete->execute(); |
| 94 |
} else { |
|
|
| 95 |
my $sth_delete = $dbh->prepare("DELETE FROM default_borrower_circ_rules |
| 96 |
WHERE categorycode = ?"); |
| 97 |
$sth_delete->execute($categorycode); |
| 98 |
} |
94 |
} |
| 99 |
} elsif ($categorycode eq "*") { |
95 |
} elsif ($categorycode eq "*") { |
| 100 |
my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules |
96 |
my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules |
| 101 |
WHERE branchcode = ?"); |
97 |
WHERE branchcode = ?"); |
| 102 |
$sth_delete->execute($branch); |
98 |
$sth_delete->execute($branch); |
| 103 |
} else { |
|
|
| 104 |
my $sth_delete = $dbh->prepare("DELETE FROM branch_borrower_circ_rules |
| 105 |
WHERE branchcode = ? |
| 106 |
AND categorycode = ?"); |
| 107 |
$sth_delete->execute($branch, $categorycode); |
| 108 |
} |
99 |
} |
| 109 |
Koha::CirculationRules->set_rule( |
100 |
Koha::CirculationRules->set_rules( |
| 110 |
{ |
101 |
{ |
| 111 |
branchcode => $branch, |
102 |
categorycode => $categorycode eq '*' ? undef : $categorycode, |
| 112 |
categorycode => $categorycode, |
103 |
branchcode => $branch eq '*' ? undef : $branch, |
| 113 |
itemtype => undef, |
104 |
itemtype => undef, |
| 114 |
rule_name => 'max_holds', |
105 |
rules => { |
| 115 |
rule_value => undef, |
106 |
max_holds => undef, |
|
|
107 |
maxissueqty => undef, |
| 108 |
maxonsiteissueqty => undef, |
| 109 |
} |
| 116 |
} |
110 |
} |
| 117 |
); |
111 |
); |
| 118 |
} |
112 |
} |
|
Lines 199-206
elsif ($op eq 'add') {
Link Here
|
| 199 |
firstremind => $firstremind, |
193 |
firstremind => $firstremind, |
| 200 |
chargeperiod => $chargeperiod, |
194 |
chargeperiod => $chargeperiod, |
| 201 |
chargeperiod_charge_at => $chargeperiod_charge_at, |
195 |
chargeperiod_charge_at => $chargeperiod_charge_at, |
| 202 |
maxissueqty => $maxissueqty, |
|
|
| 203 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 204 |
renewalsallowed => $renewalsallowed, |
196 |
renewalsallowed => $renewalsallowed, |
| 205 |
renewalperiod => $renewalperiod, |
197 |
renewalperiod => $renewalperiod, |
| 206 |
norenewalbefore => $norenewalbefore, |
198 |
norenewalbefore => $norenewalbefore, |
|
Lines 230-235
elsif ($op eq 'add') {
Link Here
|
| 230 |
Koha::IssuingRule->new()->set($params)->store(); |
222 |
Koha::IssuingRule->new()->set($params)->store(); |
| 231 |
} |
223 |
} |
| 232 |
|
224 |
|
|
|
225 |
Koha::CirculationRules->set_rules( |
| 226 |
{ |
| 227 |
categorycode => $bor, |
| 228 |
itemtype => $itemtype, |
| 229 |
branchcode => $br, |
| 230 |
rules => { |
| 231 |
maxissueqty => $maxissueqty, |
| 232 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 233 |
} |
| 234 |
} |
| 235 |
); |
| 236 |
|
| 233 |
} |
237 |
} |
| 234 |
elsif ($op eq "set-branch-defaults") { |
238 |
elsif ($op eq "set-branch-defaults") { |
| 235 |
my $categorycode = $input->param('categorycode'); |
239 |
my $categorycode = $input->param('categorycode'); |
|
Lines 252-286
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 252 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
256 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 253 |
FROM default_circ_rules"); |
257 |
FROM default_circ_rules"); |
| 254 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
258 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
| 255 |
(maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) |
259 |
(holdallowed, hold_fulfillment_policy, returnbranch) |
| 256 |
VALUES (?, ?, ?, ?, ?)"); |
260 |
VALUES (?, ?, ?)"); |
| 257 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
261 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
| 258 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?"); |
262 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?"); |
| 259 |
|
263 |
|
| 260 |
$sth_search->execute(); |
264 |
$sth_search->execute(); |
| 261 |
my $res = $sth_search->fetchrow_hashref(); |
265 |
my $res = $sth_search->fetchrow_hashref(); |
| 262 |
if ($res->{total}) { |
266 |
if ($res->{total}) { |
| 263 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
267 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 264 |
} else { |
268 |
} else { |
| 265 |
$sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
269 |
$sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 266 |
} |
270 |
} |
|
|
271 |
|
| 272 |
Koha::CirculationRules->set_rules( |
| 273 |
{ |
| 274 |
categorycode => undef, |
| 275 |
itemtype => undef, |
| 276 |
branchcode => undef, |
| 277 |
rules => { |
| 278 |
maxissueqty => $maxissueqty, |
| 279 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 280 |
} |
| 281 |
} |
| 282 |
); |
| 267 |
} else { |
283 |
} else { |
| 268 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
284 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 269 |
FROM default_branch_circ_rules |
285 |
FROM default_branch_circ_rules |
| 270 |
WHERE branchcode = ?"); |
286 |
WHERE branchcode = ?"); |
| 271 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
287 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
| 272 |
(branchcode, maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) |
288 |
(branchcode, holdallowed, hold_fulfillment_policy, returnbranch) |
| 273 |
VALUES (?, ?, ?, ?, ?, ?)"); |
289 |
VALUES (?, ?, ?, ?)"); |
| 274 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
290 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
| 275 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
291 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
| 276 |
WHERE branchcode = ?"); |
292 |
WHERE branchcode = ?"); |
| 277 |
$sth_search->execute($branch); |
293 |
$sth_search->execute($branch); |
| 278 |
my $res = $sth_search->fetchrow_hashref(); |
294 |
my $res = $sth_search->fetchrow_hashref(); |
| 279 |
if ($res->{total}) { |
295 |
if ($res->{total}) { |
| 280 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch, $branch); |
296 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch); |
| 281 |
} else { |
297 |
} else { |
| 282 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
298 |
$sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 283 |
} |
299 |
} |
|
|
300 |
|
| 301 |
Koha::CirculationRules->set_rules( |
| 302 |
{ |
| 303 |
categorycode => undef, |
| 304 |
itemtype => undef, |
| 305 |
branchcode => $branch, |
| 306 |
rules => { |
| 307 |
maxissueqty => $maxissueqty, |
| 308 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 309 |
} |
| 310 |
} |
| 311 |
); |
| 284 |
} |
312 |
} |
| 285 |
Koha::CirculationRules->set_rule( |
313 |
Koha::CirculationRules->set_rule( |
| 286 |
{ |
314 |
{ |
|
Lines 306-430
elsif ($op eq "add-branch-cat") {
Link Here
|
| 306 |
|
334 |
|
| 307 |
if ($branch eq "*") { |
335 |
if ($branch eq "*") { |
| 308 |
if ($categorycode eq "*") { |
336 |
if ($categorycode eq "*") { |
| 309 |
#FIXME This block is will probably be never used |
337 |
Koha::CirculationRules->set_rules( |
| 310 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
|
|
| 311 |
FROM default_circ_rules"); |
| 312 |
my $sth_insert = $dbh->prepare(q| |
| 313 |
INSERT INTO default_circ_rules |
| 314 |
(maxissueqty, maxonsiteissueqty) |
| 315 |
VALUES (?, ?) |
| 316 |
|); |
| 317 |
my $sth_update = $dbh->prepare(q| |
| 318 |
UPDATE default_circ_rules |
| 319 |
SET maxissueqty = ?, |
| 320 |
maxonsiteissueqty = ?, |
| 321 |
|); |
| 322 |
|
| 323 |
$sth_search->execute(); |
| 324 |
my $res = $sth_search->fetchrow_hashref(); |
| 325 |
if ($res->{total}) { |
| 326 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty ); |
| 327 |
} else { |
| 328 |
$sth_insert->execute( $maxissueqty, $maxonsiteissueqty ); |
| 329 |
} |
| 330 |
|
| 331 |
Koha::CirculationRules->set_rule( |
| 332 |
{ |
338 |
{ |
| 333 |
branchcode => undef, |
|
|
| 334 |
categorycode => undef, |
339 |
categorycode => undef, |
| 335 |
itemtype => undef, |
340 |
itemtype => undef, |
| 336 |
rule_name => 'max_holds', |
341 |
branchcode => undef, |
| 337 |
rule_value => $max_holds, |
342 |
rules => { |
|
|
343 |
max_holds => $max_holds, |
| 344 |
maxissueqty => $maxissueqty, |
| 345 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 346 |
} |
| 338 |
} |
347 |
} |
| 339 |
); |
348 |
); |
| 340 |
} else { |
349 |
} else { |
| 341 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
350 |
Koha::CirculationRules->set_rules( |
| 342 |
FROM default_borrower_circ_rules |
|
|
| 343 |
WHERE categorycode = ?"); |
| 344 |
my $sth_insert = $dbh->prepare(q| |
| 345 |
INSERT INTO default_borrower_circ_rules |
| 346 |
(categorycode, maxissueqty, maxonsiteissueqty) |
| 347 |
VALUES ( ?, ?, ?) |
| 348 |
|); |
| 349 |
my $sth_update = $dbh->prepare(q| |
| 350 |
UPDATE default_borrower_circ_rules |
| 351 |
SET maxissueqty = ?, |
| 352 |
maxonsiteissueqty = ?, |
| 353 |
WHERE categorycode = ? |
| 354 |
|); |
| 355 |
$sth_search->execute($categorycode); |
| 356 |
my $res = $sth_search->fetchrow_hashref(); |
| 357 |
if ($res->{total}) { |
| 358 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty, $categorycode ); |
| 359 |
} else { |
| 360 |
$sth_insert->execute( $categorycode, $maxissueqty, $maxonsiteissueqty ); |
| 361 |
} |
| 362 |
|
| 363 |
Koha::CirculationRules->set_rule( |
| 364 |
{ |
351 |
{ |
| 365 |
branchcode => undef, |
352 |
branchcode => undef, |
| 366 |
categorycode => $categorycode, |
353 |
categorycode => $categorycode, |
| 367 |
itemtype => undef, |
354 |
itemtype => undef, |
| 368 |
rule_name => 'max_holds', |
355 |
rules => { |
| 369 |
rule_value => $max_holds, |
356 |
max_holds => $max_holds, |
|
|
357 |
maxissueqty => $maxissueqty, |
| 358 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 359 |
} |
| 370 |
} |
360 |
} |
| 371 |
); |
361 |
); |
| 372 |
} |
362 |
} |
| 373 |
} elsif ($categorycode eq "*") { |
363 |
} elsif ($categorycode eq "*") { |
| 374 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
364 |
Koha::CirculationRules->set_rules( |
| 375 |
FROM default_branch_circ_rules |
|
|
| 376 |
WHERE branchcode = ?"); |
| 377 |
my $sth_insert = $dbh->prepare(q| |
| 378 |
INSERT INTO default_branch_circ_rules |
| 379 |
(branchcode, maxissueqty, maxonsiteissueqty) |
| 380 |
VALUES (?, ?, ?) |
| 381 |
|); |
| 382 |
my $sth_update = $dbh->prepare(q| |
| 383 |
UPDATE default_branch_circ_rules |
| 384 |
SET maxissueqty = ?, |
| 385 |
maxonsiteissueqty = ? |
| 386 |
WHERE branchcode = ? |
| 387 |
|); |
| 388 |
$sth_search->execute($branch); |
| 389 |
my $res = $sth_search->fetchrow_hashref(); |
| 390 |
if ($res->{total}) { |
| 391 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $branch); |
| 392 |
} else { |
| 393 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty); |
| 394 |
} |
| 395 |
} else { |
| 396 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 397 |
FROM branch_borrower_circ_rules |
| 398 |
WHERE branchcode = ? |
| 399 |
AND categorycode = ?"); |
| 400 |
my $sth_insert = $dbh->prepare(q| |
| 401 |
INSERT INTO branch_borrower_circ_rules |
| 402 |
(branchcode, categorycode, maxissueqty, maxonsiteissueqty) |
| 403 |
VALUES (?, ?, ?, ?) |
| 404 |
|); |
| 405 |
my $sth_update = $dbh->prepare(q| |
| 406 |
UPDATE branch_borrower_circ_rules |
| 407 |
SET maxissueqty = ?, |
| 408 |
maxonsiteissueqty = ? |
| 409 |
WHERE branchcode = ? |
| 410 |
AND categorycode = ? |
| 411 |
|); |
| 412 |
|
| 413 |
$sth_search->execute($branch, $categorycode); |
| 414 |
my $res = $sth_search->fetchrow_hashref(); |
| 415 |
if ($res->{total}) { |
| 416 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $branch, $categorycode); |
| 417 |
} else { |
| 418 |
$sth_insert->execute($branch, $categorycode, $maxissueqty, $maxonsiteissueqty); |
| 419 |
} |
| 420 |
|
| 421 |
Koha::CirculationRules->set_rule( |
| 422 |
{ |
365 |
{ |
|
|
366 |
categorycode => undef, |
| 367 |
itemtype => undef, |
| 423 |
branchcode => $branch, |
368 |
branchcode => $branch, |
|
|
369 |
rules => { |
| 370 |
max_holds => $max_holds, |
| 371 |
maxissueqty => $maxissueqty, |
| 372 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 373 |
} |
| 374 |
} |
| 375 |
); |
| 376 |
} else { |
| 377 |
Koha::CirculationRules->set_rules( |
| 378 |
{ |
| 424 |
categorycode => $categorycode, |
379 |
categorycode => $categorycode, |
| 425 |
itemtype => undef, |
380 |
itemtype => undef, |
| 426 |
rule_name => 'max_holds', |
381 |
branchcode => $branch, |
| 427 |
rule_value => $max_holds, |
382 |
rules => { |
|
|
383 |
max_holds => $max_holds, |
| 384 |
maxissueqty => $maxissueqty, |
| 385 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 386 |
} |
| 428 |
} |
387 |
} |
| 429 |
); |
388 |
); |
| 430 |
} |
389 |
} |
|
Lines 592-632
while (my $row = $sth2->fetchrow_hashref) {
Link Here
|
| 592 |
|
551 |
|
| 593 |
my @sorted_row_loop = sort by_category_and_itemtype @row_loop; |
552 |
my @sorted_row_loop = sort by_category_and_itemtype @row_loop; |
| 594 |
|
553 |
|
| 595 |
my $sth_branch_cat; |
|
|
| 596 |
if ($branch eq "*") { |
| 597 |
$sth_branch_cat = $dbh->prepare(" |
| 598 |
SELECT default_borrower_circ_rules.*, categories.description AS humancategorycode |
| 599 |
FROM default_borrower_circ_rules |
| 600 |
JOIN categories USING (categorycode) |
| 601 |
|
| 602 |
"); |
| 603 |
$sth_branch_cat->execute(); |
| 604 |
} else { |
| 605 |
$sth_branch_cat = $dbh->prepare(" |
| 606 |
SELECT branch_borrower_circ_rules.*, categories.description AS humancategorycode |
| 607 |
FROM branch_borrower_circ_rules |
| 608 |
JOIN categories USING (categorycode) |
| 609 |
WHERE branch_borrower_circ_rules.branchcode = ? |
| 610 |
"); |
| 611 |
$sth_branch_cat->execute($branch); |
| 612 |
} |
| 613 |
|
| 614 |
my @branch_cat_rules = (); |
| 615 |
while (my $row = $sth_branch_cat->fetchrow_hashref) { |
| 616 |
push @branch_cat_rules, $row; |
| 617 |
} |
| 618 |
my @sorted_branch_cat_rules = sort { $a->{'humancategorycode'} cmp $b->{'humancategorycode'} } @branch_cat_rules; |
| 619 |
|
| 620 |
# note undef maxissueqty so that template can deal with them |
| 621 |
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { |
| 622 |
$entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty}); |
| 623 |
$entry->{unlimited_maxonsiteissueqty} = 1 unless defined($entry->{maxonsiteissueqty}); |
| 624 |
$entry->{unlimited_max_holds} = 1 unless defined($entry->{max_holds}); |
| 625 |
$entry->{unlimited_holds_per_day} = 1 unless defined($entry->{holds_per_day}); |
| 626 |
} |
| 627 |
|
| 628 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |
| 629 |
|
| 630 |
my $sth_branch_item; |
554 |
my $sth_branch_item; |
| 631 |
if ($branch eq "*") { |
555 |
if ($branch eq "*") { |
| 632 |
$sth_branch_item = $dbh->prepare(" |
556 |
$sth_branch_item = $dbh->prepare(" |
|
Lines 667-673
foreach my $entry (@sorted_branch_item_rules) {
Link Here
|
| 667 |
|
591 |
|
| 668 |
$template->param(show_branch_cat_rule_form => 1); |
592 |
$template->param(show_branch_cat_rule_form => 1); |
| 669 |
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules); |
593 |
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules); |
| 670 |
$template->param(branch_cat_rule_loop => \@sorted_branch_cat_rules); |
|
|
| 671 |
|
594 |
|
| 672 |
my $sth_defaults; |
595 |
my $sth_defaults; |
| 673 |
if ($branch eq "*") { |
596 |
if ($branch eq "*") { |