|
Lines 34-39
use Koha::RefundLostItemFeeRule;
Link Here
|
| 34 |
use Koha::RefundLostItemFeeRules; |
34 |
use Koha::RefundLostItemFeeRules; |
| 35 |
use Koha::Libraries; |
35 |
use Koha::Libraries; |
| 36 |
use Koha::Patron::Categories; |
36 |
use Koha::Patron::Categories; |
|
|
37 |
use Koha::CirculationRules; |
| 37 |
|
38 |
|
| 38 |
my $input = CGI->new; |
39 |
my $input = CGI->new; |
| 39 |
my $dbh = C4::Context->dbh; |
40 |
my $dbh = C4::Context->dbh; |
|
Lines 94-99
elsif ($op eq 'delete-branch-cat') {
Link Here
|
| 94 |
AND categorycode = ?"); |
95 |
AND categorycode = ?"); |
| 95 |
$sth_delete->execute($branch, $categorycode); |
96 |
$sth_delete->execute($branch, $categorycode); |
| 96 |
} |
97 |
} |
|
|
98 |
Koha::CirculationRules->set_rule( |
| 99 |
{ |
| 100 |
branchcode => $branch, |
| 101 |
categorycode => $categorycode, |
| 102 |
itemtype => undef, |
| 103 |
rule_name => 'max_holds', |
| 104 |
rule_value => undef, |
| 105 |
} |
| 106 |
); |
| 97 |
} |
107 |
} |
| 98 |
elsif ($op eq 'delete-branch-item') { |
108 |
elsif ($op eq 'delete-branch-item') { |
| 99 |
my $itemtype = $input->param('itemtype'); |
109 |
my $itemtype = $input->param('itemtype'); |
|
Lines 269-314
elsif ($op eq "add-branch-cat") {
Link Here
|
| 269 |
FROM default_circ_rules"); |
279 |
FROM default_circ_rules"); |
| 270 |
my $sth_insert = $dbh->prepare(q| |
280 |
my $sth_insert = $dbh->prepare(q| |
| 271 |
INSERT INTO default_circ_rules |
281 |
INSERT INTO default_circ_rules |
| 272 |
(maxissueqty, maxonsiteissueqty, max_holds) |
282 |
(maxissueqty, maxonsiteissueqty) |
| 273 |
VALUES (?, ?, ?) |
283 |
VALUES (?, ?, ) |
| 274 |
|); |
284 |
|); |
| 275 |
my $sth_update = $dbh->prepare(q| |
285 |
my $sth_update = $dbh->prepare(q| |
| 276 |
UPDATE default_circ_rules |
286 |
UPDATE default_circ_rules |
| 277 |
SET maxissueqty = ?, |
287 |
SET maxissueqty = ?, |
| 278 |
maxonsiteissueqty = ?, |
288 |
maxonsiteissueqty = ? |
| 279 |
max_holds = ? |
|
|
| 280 |
|); |
289 |
|); |
| 281 |
|
290 |
|
| 282 |
$sth_search->execute(); |
291 |
$sth_search->execute(); |
| 283 |
my $res = $sth_search->fetchrow_hashref(); |
292 |
my $res = $sth_search->fetchrow_hashref(); |
| 284 |
if ($res->{total}) { |
293 |
if ($res->{total}) { |
| 285 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty, $max_holds ); |
294 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty ); |
| 286 |
} else { |
295 |
} else { |
| 287 |
$sth_insert->execute( $maxissueqty, $maxonsiteissueqty, $max_holds ); |
296 |
$sth_insert->execute( $maxissueqty, $maxonsiteissueqty ); |
| 288 |
} |
297 |
} |
|
|
298 |
|
| 299 |
Koha::CirculationRules->set_rule( |
| 300 |
{ |
| 301 |
branchcode => undef, |
| 302 |
categorycode => undef, |
| 303 |
itemtype => undef, |
| 304 |
rule_name => 'max_holds', |
| 305 |
rule_value => $max_holds, |
| 306 |
} |
| 307 |
); |
| 289 |
} else { |
308 |
} else { |
| 290 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
309 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 291 |
FROM default_borrower_circ_rules |
310 |
FROM default_borrower_circ_rules |
| 292 |
WHERE categorycode = ?"); |
311 |
WHERE categorycode = ?"); |
| 293 |
my $sth_insert = $dbh->prepare(q| |
312 |
my $sth_insert = $dbh->prepare(q| |
| 294 |
INSERT INTO default_borrower_circ_rules |
313 |
INSERT INTO default_borrower_circ_rules |
| 295 |
(categorycode, maxissueqty, maxonsiteissueqty, max_holds) |
314 |
(categorycode, maxissueqty, maxonsiteissueqty) |
| 296 |
VALUES (?, ?, ?, ?) |
315 |
VALUES (?, ?, ?, ?) |
| 297 |
|); |
316 |
|); |
| 298 |
my $sth_update = $dbh->prepare(q| |
317 |
my $sth_update = $dbh->prepare(q| |
| 299 |
UPDATE default_borrower_circ_rules |
318 |
UPDATE default_borrower_circ_rules |
| 300 |
SET maxissueqty = ?, |
319 |
SET maxissueqty = ?, |
| 301 |
maxonsiteissueqty = ?, |
320 |
maxonsiteissueqty = ? |
| 302 |
max_holds = ? |
|
|
| 303 |
WHERE categorycode = ? |
321 |
WHERE categorycode = ? |
| 304 |
|); |
322 |
|); |
| 305 |
$sth_search->execute($branch); |
323 |
$sth_search->execute($branch); |
| 306 |
my $res = $sth_search->fetchrow_hashref(); |
324 |
my $res = $sth_search->fetchrow_hashref(); |
| 307 |
if ($res->{total}) { |
325 |
if ($res->{total}) { |
| 308 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty, $categorycode, $max_holds ); |
326 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty, $categorycode ); |
| 309 |
} else { |
327 |
} else { |
| 310 |
$sth_insert->execute( $categorycode, $maxissueqty, $maxonsiteissueqty, $max_holds ); |
328 |
$sth_insert->execute( $categorycode, $maxissueqty, $maxonsiteissueqty ); |
| 311 |
} |
329 |
} |
|
|
330 |
|
| 331 |
Koha::CirculationRules->set_rule( |
| 332 |
{ |
| 333 |
branchcode => undef, |
| 334 |
categorycode => $categorycode, |
| 335 |
itemtype => undef, |
| 336 |
rule_name => 'max_holds', |
| 337 |
rule_value => $max_holds, |
| 338 |
} |
| 339 |
); |
| 312 |
} |
340 |
} |
| 313 |
} elsif ($categorycode eq "*") { |
341 |
} elsif ($categorycode eq "*") { |
| 314 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
342 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
|
Lines 339-352
elsif ($op eq "add-branch-cat") {
Link Here
|
| 339 |
AND categorycode = ?"); |
367 |
AND categorycode = ?"); |
| 340 |
my $sth_insert = $dbh->prepare(q| |
368 |
my $sth_insert = $dbh->prepare(q| |
| 341 |
INSERT INTO branch_borrower_circ_rules |
369 |
INSERT INTO branch_borrower_circ_rules |
| 342 |
(branchcode, categorycode, maxissueqty, maxonsiteissueqty, max_holds) |
370 |
(branchcode, categorycode, maxissueqty, maxonsiteissueqty) |
| 343 |
VALUES (?, ?, ?, ?, ?) |
371 |
VALUES (?, ?, ?, ?) |
| 344 |
|); |
372 |
|); |
| 345 |
my $sth_update = $dbh->prepare(q| |
373 |
my $sth_update = $dbh->prepare(q| |
| 346 |
UPDATE branch_borrower_circ_rules |
374 |
UPDATE branch_borrower_circ_rules |
| 347 |
SET maxissueqty = ?, |
375 |
SET maxissueqty = ?, |
| 348 |
maxonsiteissueqty = ? |
376 |
maxonsiteissueqty = ? |
| 349 |
max_holds = ? |
|
|
| 350 |
WHERE branchcode = ? |
377 |
WHERE branchcode = ? |
| 351 |
AND categorycode = ? |
378 |
AND categorycode = ? |
| 352 |
|); |
379 |
|); |
|
Lines 354-363
elsif ($op eq "add-branch-cat") {
Link Here
|
| 354 |
$sth_search->execute($branch, $categorycode); |
381 |
$sth_search->execute($branch, $categorycode); |
| 355 |
my $res = $sth_search->fetchrow_hashref(); |
382 |
my $res = $sth_search->fetchrow_hashref(); |
| 356 |
if ($res->{total}) { |
383 |
if ($res->{total}) { |
| 357 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $max_holds, $branch, $categorycode); |
384 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $branch, $categorycode); |
| 358 |
} else { |
385 |
} else { |
| 359 |
$sth_insert->execute($branch, $categorycode, $maxissueqty, $maxonsiteissueqty, $max_holds); |
386 |
$sth_insert->execute($branch, $categorycode, $maxissueqty, $maxonsiteissueqty); |
| 360 |
} |
387 |
} |
|
|
388 |
|
| 389 |
Koha::CirculationRules->set_rule( |
| 390 |
{ |
| 391 |
branchcode => $branch, |
| 392 |
categorycode => $categorycode, |
| 393 |
itemtype => undef, |
| 394 |
rule_name => 'max_holds', |
| 395 |
rule_value => $max_holds, |
| 396 |
} |
| 397 |
); |
| 361 |
} |
398 |
} |
| 362 |
} |
399 |
} |
| 363 |
elsif ($op eq "add-branch-item") { |
400 |
elsif ($op eq "add-branch-item") { |
|
Lines 552-558
my @sorted_branch_cat_rules = sort { $a->{'humancategorycode'} cmp $b->{'humanca
Link Here
|
| 552 |
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { |
589 |
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { |
| 553 |
$entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty}); |
590 |
$entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty}); |
| 554 |
$entry->{unlimited_maxonsiteissueqty} = 1 unless defined($entry->{maxonsiteissueqty}); |
591 |
$entry->{unlimited_maxonsiteissueqty} = 1 unless defined($entry->{maxonsiteissueqty}); |
| 555 |
$entry->{unlimited_max_holds} = 1 unless defined($entry->{max_holds}); |
|
|
| 556 |
} |
592 |
} |
| 557 |
|
593 |
|
| 558 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |
594 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |