|
Lines 33-38
use Koha::Logger;
Link Here
|
| 33 |
use Koha::RefundLostItemFeeRule; |
33 |
use Koha::RefundLostItemFeeRule; |
| 34 |
use Koha::RefundLostItemFeeRules; |
34 |
use Koha::RefundLostItemFeeRules; |
| 35 |
use Koha::Libraries; |
35 |
use Koha::Libraries; |
|
|
36 |
use Koha::CirculationRules; |
| 36 |
use Koha::Patron::Categories; |
37 |
use Koha::Patron::Categories; |
| 37 |
use Koha::Patrons; |
38 |
use Koha::Patrons; |
| 38 |
|
39 |
|
|
Lines 101-106
elsif ($op eq 'delete-branch-cat') {
Link Here
|
| 101 |
AND categorycode = ?"); |
102 |
AND categorycode = ?"); |
| 102 |
$sth_delete->execute($branch, $categorycode); |
103 |
$sth_delete->execute($branch, $categorycode); |
| 103 |
} |
104 |
} |
|
|
105 |
Koha::CirculationRules->set_rule( |
| 106 |
{ |
| 107 |
branchcode => $branch, |
| 108 |
categorycode => $categorycode, |
| 109 |
itemtype => undef, |
| 110 |
rule_name => 'max_holds', |
| 111 |
rule_value => undef, |
| 112 |
} |
| 113 |
); |
| 104 |
} |
114 |
} |
| 105 |
elsif ($op eq 'delete-branch-item') { |
115 |
elsif ($op eq 'delete-branch-item') { |
| 106 |
my $itemtype = $input->param('itemtype'); |
116 |
my $itemtype = $input->param('itemtype'); |
|
Lines 276-321
elsif ($op eq "add-branch-cat") {
Link Here
|
| 276 |
FROM default_circ_rules"); |
286 |
FROM default_circ_rules"); |
| 277 |
my $sth_insert = $dbh->prepare(q| |
287 |
my $sth_insert = $dbh->prepare(q| |
| 278 |
INSERT INTO default_circ_rules |
288 |
INSERT INTO default_circ_rules |
| 279 |
(maxissueqty, maxonsiteissueqty, max_holds) |
289 |
(maxissueqty, maxonsiteissueqty) |
| 280 |
VALUES (?, ?, ?) |
290 |
VALUES (?, ?, ) |
| 281 |
|); |
291 |
|); |
| 282 |
my $sth_update = $dbh->prepare(q| |
292 |
my $sth_update = $dbh->prepare(q| |
| 283 |
UPDATE default_circ_rules |
293 |
UPDATE default_circ_rules |
| 284 |
SET maxissueqty = ?, |
294 |
SET maxissueqty = ?, |
| 285 |
maxonsiteissueqty = ?, |
295 |
maxonsiteissueqty = ? |
| 286 |
max_holds = ? |
|
|
| 287 |
|); |
296 |
|); |
| 288 |
|
297 |
|
| 289 |
$sth_search->execute(); |
298 |
$sth_search->execute(); |
| 290 |
my $res = $sth_search->fetchrow_hashref(); |
299 |
my $res = $sth_search->fetchrow_hashref(); |
| 291 |
if ($res->{total}) { |
300 |
if ($res->{total}) { |
| 292 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty, $max_holds ); |
301 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty ); |
| 293 |
} else { |
302 |
} else { |
| 294 |
$sth_insert->execute( $maxissueqty, $maxonsiteissueqty, $max_holds ); |
303 |
$sth_insert->execute( $maxissueqty, $maxonsiteissueqty ); |
| 295 |
} |
304 |
} |
|
|
305 |
|
| 306 |
Koha::CirculationRules->set_rule( |
| 307 |
{ |
| 308 |
branchcode => undef, |
| 309 |
categorycode => undef, |
| 310 |
itemtype => undef, |
| 311 |
rule_name => 'max_holds', |
| 312 |
rule_value => $max_holds, |
| 313 |
} |
| 314 |
); |
| 296 |
} else { |
315 |
} else { |
| 297 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
316 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 298 |
FROM default_borrower_circ_rules |
317 |
FROM default_borrower_circ_rules |
| 299 |
WHERE categorycode = ?"); |
318 |
WHERE categorycode = ?"); |
| 300 |
my $sth_insert = $dbh->prepare(q| |
319 |
my $sth_insert = $dbh->prepare(q| |
| 301 |
INSERT INTO default_borrower_circ_rules |
320 |
INSERT INTO default_borrower_circ_rules |
| 302 |
(categorycode, maxissueqty, maxonsiteissueqty, max_holds) |
321 |
(categorycode, maxissueqty, maxonsiteissueqty) |
| 303 |
VALUES (?, ?, ?, ?) |
322 |
VALUES (?, ?, ?, ?) |
| 304 |
|); |
323 |
|); |
| 305 |
my $sth_update = $dbh->prepare(q| |
324 |
my $sth_update = $dbh->prepare(q| |
| 306 |
UPDATE default_borrower_circ_rules |
325 |
UPDATE default_borrower_circ_rules |
| 307 |
SET maxissueqty = ?, |
326 |
SET maxissueqty = ?, |
| 308 |
maxonsiteissueqty = ?, |
327 |
maxonsiteissueqty = ? |
| 309 |
max_holds = ? |
|
|
| 310 |
WHERE categorycode = ? |
328 |
WHERE categorycode = ? |
| 311 |
|); |
329 |
|); |
| 312 |
$sth_search->execute($branch); |
330 |
$sth_search->execute($branch); |
| 313 |
my $res = $sth_search->fetchrow_hashref(); |
331 |
my $res = $sth_search->fetchrow_hashref(); |
| 314 |
if ($res->{total}) { |
332 |
if ($res->{total}) { |
| 315 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty, $categorycode, $max_holds ); |
333 |
$sth_update->execute( $maxissueqty, $maxonsiteissueqty, $categorycode ); |
| 316 |
} else { |
334 |
} else { |
| 317 |
$sth_insert->execute( $categorycode, $maxissueqty, $maxonsiteissueqty, $max_holds ); |
335 |
$sth_insert->execute( $categorycode, $maxissueqty, $maxonsiteissueqty ); |
| 318 |
} |
336 |
} |
|
|
337 |
|
| 338 |
Koha::CirculationRules->set_rule( |
| 339 |
{ |
| 340 |
branchcode => undef, |
| 341 |
categorycode => $categorycode, |
| 342 |
itemtype => undef, |
| 343 |
rule_name => 'max_holds', |
| 344 |
rule_value => $max_holds, |
| 345 |
} |
| 346 |
); |
| 319 |
} |
347 |
} |
| 320 |
} elsif ($categorycode eq "*") { |
348 |
} elsif ($categorycode eq "*") { |
| 321 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
349 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
|
Lines 346-359
elsif ($op eq "add-branch-cat") {
Link Here
|
| 346 |
AND categorycode = ?"); |
374 |
AND categorycode = ?"); |
| 347 |
my $sth_insert = $dbh->prepare(q| |
375 |
my $sth_insert = $dbh->prepare(q| |
| 348 |
INSERT INTO branch_borrower_circ_rules |
376 |
INSERT INTO branch_borrower_circ_rules |
| 349 |
(branchcode, categorycode, maxissueqty, maxonsiteissueqty, max_holds) |
377 |
(branchcode, categorycode, maxissueqty, maxonsiteissueqty) |
| 350 |
VALUES (?, ?, ?, ?, ?) |
378 |
VALUES (?, ?, ?, ?) |
| 351 |
|); |
379 |
|); |
| 352 |
my $sth_update = $dbh->prepare(q| |
380 |
my $sth_update = $dbh->prepare(q| |
| 353 |
UPDATE branch_borrower_circ_rules |
381 |
UPDATE branch_borrower_circ_rules |
| 354 |
SET maxissueqty = ?, |
382 |
SET maxissueqty = ?, |
| 355 |
maxonsiteissueqty = ? |
383 |
maxonsiteissueqty = ? |
| 356 |
max_holds = ? |
|
|
| 357 |
WHERE branchcode = ? |
384 |
WHERE branchcode = ? |
| 358 |
AND categorycode = ? |
385 |
AND categorycode = ? |
| 359 |
|); |
386 |
|); |
|
Lines 361-370
elsif ($op eq "add-branch-cat") {
Link Here
|
| 361 |
$sth_search->execute($branch, $categorycode); |
388 |
$sth_search->execute($branch, $categorycode); |
| 362 |
my $res = $sth_search->fetchrow_hashref(); |
389 |
my $res = $sth_search->fetchrow_hashref(); |
| 363 |
if ($res->{total}) { |
390 |
if ($res->{total}) { |
| 364 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $max_holds, $branch, $categorycode); |
391 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $branch, $categorycode); |
| 365 |
} else { |
392 |
} else { |
| 366 |
$sth_insert->execute($branch, $categorycode, $maxissueqty, $maxonsiteissueqty, $max_holds); |
393 |
$sth_insert->execute($branch, $categorycode, $maxissueqty, $maxonsiteissueqty); |
| 367 |
} |
394 |
} |
|
|
395 |
|
| 396 |
Koha::CirculationRules->set_rule( |
| 397 |
{ |
| 398 |
branchcode => $branch, |
| 399 |
categorycode => $categorycode, |
| 400 |
itemtype => undef, |
| 401 |
rule_name => 'max_holds', |
| 402 |
rule_value => $max_holds, |
| 403 |
} |
| 404 |
); |
| 368 |
} |
405 |
} |
| 369 |
} |
406 |
} |
| 370 |
elsif ($op eq "add-branch-item") { |
407 |
elsif ($op eq "add-branch-item") { |
|
Lines 559-565
my @sorted_branch_cat_rules = sort { $a->{'humancategorycode'} cmp $b->{'humanca
Link Here
|
| 559 |
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { |
596 |
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { |
| 560 |
$entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty}); |
597 |
$entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty}); |
| 561 |
$entry->{unlimited_maxonsiteissueqty} = 1 unless defined($entry->{maxonsiteissueqty}); |
598 |
$entry->{unlimited_maxonsiteissueqty} = 1 unless defined($entry->{maxonsiteissueqty}); |
| 562 |
$entry->{unlimited_max_holds} = 1 unless defined($entry->{max_holds}); |
|
|
| 563 |
} |
599 |
} |
| 564 |
|
600 |
|
| 565 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |
601 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |