|
Lines 189-194
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 189 |
my $maxissueqty = $input->param('maxissueqty'); |
189 |
my $maxissueqty = $input->param('maxissueqty'); |
| 190 |
my $maxonsiteissueqty = $input->param('maxonsiteissueqty'); |
190 |
my $maxonsiteissueqty = $input->param('maxonsiteissueqty'); |
| 191 |
my $holdallowed = $input->param('holdallowed'); |
191 |
my $holdallowed = $input->param('holdallowed'); |
|
|
192 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
| 192 |
my $returnbranch = $input->param('returnbranch'); |
193 |
my $returnbranch = $input->param('returnbranch'); |
| 193 |
$maxissueqty =~ s/\s//g; |
194 |
$maxissueqty =~ s/\s//g; |
| 194 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
195 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
|
Lines 201-234
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 201 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
202 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 202 |
FROM default_circ_rules"); |
203 |
FROM default_circ_rules"); |
| 203 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
204 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
| 204 |
(maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
205 |
(maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) |
| 205 |
VALUES (?, ?, ?, ?)"); |
206 |
VALUES (?, ?, ?, ?, ?)"); |
| 206 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
207 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
| 207 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ?"); |
208 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?"); |
| 208 |
|
209 |
|
| 209 |
$sth_search->execute(); |
210 |
$sth_search->execute(); |
| 210 |
my $res = $sth_search->fetchrow_hashref(); |
211 |
my $res = $sth_search->fetchrow_hashref(); |
| 211 |
if ($res->{total}) { |
212 |
if ($res->{total}) { |
| 212 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch); |
213 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 213 |
} else { |
214 |
} else { |
| 214 |
$sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch); |
215 |
$sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 215 |
} |
216 |
} |
| 216 |
} else { |
217 |
} else { |
| 217 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
218 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 218 |
FROM default_branch_circ_rules |
219 |
FROM default_branch_circ_rules |
| 219 |
WHERE branchcode = ?"); |
220 |
WHERE branchcode = ?"); |
| 220 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
221 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
| 221 |
(branchcode, maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
222 |
(branchcode, maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) |
| 222 |
VALUES (?, ?, ?, ?, ?)"); |
223 |
VALUES (?, ?, ?, ?, ?, ?)"); |
| 223 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
224 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
| 224 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ? |
225 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
| 225 |
WHERE branchcode = ?"); |
226 |
WHERE branchcode = ?"); |
| 226 |
$sth_search->execute($branch); |
227 |
$sth_search->execute($branch); |
| 227 |
my $res = $sth_search->fetchrow_hashref(); |
228 |
my $res = $sth_search->fetchrow_hashref(); |
| 228 |
if ($res->{total}) { |
229 |
if ($res->{total}) { |
| 229 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch, $branch); |
230 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch, $branch); |
| 230 |
} else { |
231 |
} else { |
| 231 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch); |
232 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 232 |
} |
233 |
} |
| 233 |
} |
234 |
} |
| 234 |
} |
235 |
} |
|
Lines 336-344
elsif ($op eq "add-branch-cat") {
Link Here
|
| 336 |
} |
337 |
} |
| 337 |
} |
338 |
} |
| 338 |
elsif ($op eq "add-branch-item") { |
339 |
elsif ($op eq "add-branch-item") { |
| 339 |
my $itemtype = $input->param('itemtype'); |
340 |
my $itemtype = $input->param('itemtype'); |
| 340 |
my $holdallowed = $input->param('holdallowed'); |
341 |
my $holdallowed = $input->param('holdallowed'); |
| 341 |
my $returnbranch = $input->param('returnbranch'); |
342 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
|
|
343 |
my $returnbranch = $input->param('returnbranch'); |
| 344 |
|
| 342 |
$holdallowed =~ s/\s//g; |
345 |
$holdallowed =~ s/\s//g; |
| 343 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
346 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
| 344 |
|
347 |
|
|
Lines 347-380
elsif ($op eq "add-branch-item") {
Link Here
|
| 347 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
350 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 348 |
FROM default_circ_rules"); |
351 |
FROM default_circ_rules"); |
| 349 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
352 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
| 350 |
(holdallowed, returnbranch) |
353 |
(holdallowed, hold_fulfillment_policy, returnbranch) |
| 351 |
VALUES (?, ?)"); |
354 |
VALUES (?, ?, ?)"); |
| 352 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
355 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
| 353 |
SET holdallowed = ?, returnbranch = ?"); |
356 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?"); |
| 354 |
|
357 |
|
| 355 |
$sth_search->execute(); |
358 |
$sth_search->execute(); |
| 356 |
my $res = $sth_search->fetchrow_hashref(); |
359 |
my $res = $sth_search->fetchrow_hashref(); |
| 357 |
if ($res->{total}) { |
360 |
if ($res->{total}) { |
| 358 |
$sth_update->execute($holdallowed, $returnbranch); |
361 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 359 |
} else { |
362 |
} else { |
| 360 |
$sth_insert->execute($holdallowed, $returnbranch); |
363 |
$sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 361 |
} |
364 |
} |
| 362 |
} else { |
365 |
} else { |
| 363 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
366 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 364 |
FROM default_branch_item_rules |
367 |
FROM default_branch_item_rules |
| 365 |
WHERE itemtype = ?"); |
368 |
WHERE itemtype = ?"); |
| 366 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules |
369 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules |
| 367 |
(itemtype, holdallowed, returnbranch) |
370 |
(itemtype, holdallowed, hold_fulfillment_policy, returnbranch) |
| 368 |
VALUES (?, ?, ?)"); |
371 |
VALUES (?, ?, ?, ?)"); |
| 369 |
my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules |
372 |
my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules |
| 370 |
SET holdallowed = ?, returnbranch = ? |
373 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
| 371 |
WHERE itemtype = ?"); |
374 |
WHERE itemtype = ?"); |
| 372 |
$sth_search->execute($itemtype); |
375 |
$sth_search->execute($itemtype); |
| 373 |
my $res = $sth_search->fetchrow_hashref(); |
376 |
my $res = $sth_search->fetchrow_hashref(); |
| 374 |
if ($res->{total}) { |
377 |
if ($res->{total}) { |
| 375 |
$sth_update->execute($holdallowed, $returnbranch, $itemtype); |
378 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $itemtype); |
| 376 |
} else { |
379 |
} else { |
| 377 |
$sth_insert->execute($itemtype, $holdallowed, $returnbranch); |
380 |
$sth_insert->execute($itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 378 |
} |
381 |
} |
| 379 |
} |
382 |
} |
| 380 |
} elsif ($itemtype eq "*") { |
383 |
} elsif ($itemtype eq "*") { |
|
Lines 382-398
elsif ($op eq "add-branch-item") {
Link Here
|
| 382 |
FROM default_branch_circ_rules |
385 |
FROM default_branch_circ_rules |
| 383 |
WHERE branchcode = ?"); |
386 |
WHERE branchcode = ?"); |
| 384 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
387 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
| 385 |
(branchcode, holdallowed, returnbranch) |
388 |
(branchcode, holdallowed, hold_fulfillment_policy, returnbranch) |
| 386 |
VALUES (?, ?, ?)"); |
389 |
VALUES (?, ?, ?, ?)"); |
| 387 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
390 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
| 388 |
SET holdallowed = ?, returnbranch = ? |
391 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
| 389 |
WHERE branchcode = ?"); |
392 |
WHERE branchcode = ?"); |
| 390 |
$sth_search->execute($branch); |
393 |
$sth_search->execute($branch); |
| 391 |
my $res = $sth_search->fetchrow_hashref(); |
394 |
my $res = $sth_search->fetchrow_hashref(); |
| 392 |
if ($res->{total}) { |
395 |
if ($res->{total}) { |
| 393 |
$sth_update->execute($holdallowed, $returnbranch, $branch); |
396 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch); |
| 394 |
} else { |
397 |
} else { |
| 395 |
$sth_insert->execute($branch, $holdallowed, $returnbranch); |
398 |
$sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 396 |
} |
399 |
} |
| 397 |
} else { |
400 |
} else { |
| 398 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
401 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
|
Lines 400-418
elsif ($op eq "add-branch-item") {
Link Here
|
| 400 |
WHERE branchcode = ? |
403 |
WHERE branchcode = ? |
| 401 |
AND itemtype = ?"); |
404 |
AND itemtype = ?"); |
| 402 |
my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules |
405 |
my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules |
| 403 |
(branchcode, itemtype, holdallowed, returnbranch) |
406 |
(branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch) |
| 404 |
VALUES (?, ?, ?, ?)"); |
407 |
VALUES (?, ?, ?, ?, ?)"); |
| 405 |
my $sth_update = $dbh->prepare("UPDATE branch_item_rules |
408 |
my $sth_update = $dbh->prepare("UPDATE branch_item_rules |
| 406 |
SET holdallowed = ?, returnbranch = ? |
409 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
| 407 |
WHERE branchcode = ? |
410 |
WHERE branchcode = ? |
| 408 |
AND itemtype = ?"); |
411 |
AND itemtype = ?"); |
| 409 |
|
412 |
|
| 410 |
$sth_search->execute($branch, $itemtype); |
413 |
$sth_search->execute($branch, $itemtype); |
| 411 |
my $res = $sth_search->fetchrow_hashref(); |
414 |
my $res = $sth_search->fetchrow_hashref(); |
| 412 |
if ($res->{total}) { |
415 |
if ($res->{total}) { |
| 413 |
$sth_update->execute($holdallowed, $returnbranch, $branch, $itemtype); |
416 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch, $itemtype); |
| 414 |
} else { |
417 |
} else { |
| 415 |
$sth_insert->execute($branch, $itemtype, $holdallowed, $returnbranch); |
418 |
$sth_insert->execute($branch, $itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
| 416 |
} |
419 |
} |
| 417 |
} |
420 |
} |
| 418 |
} |
421 |
} |
|
Lines 536-543
my @sorted_branch_item_rules = sort { $a->{'humanitemtype'} cmp $b->{'humanitemt
Link Here
|
| 536 |
|
539 |
|
| 537 |
# note undef holdallowed so that template can deal with them |
540 |
# note undef holdallowed so that template can deal with them |
| 538 |
foreach my $entry (@sorted_branch_item_rules) { |
541 |
foreach my $entry (@sorted_branch_item_rules) { |
| 539 |
$entry->{holdallowed_any} = 1 if($entry->{holdallowed} == 2); |
542 |
$entry->{holdallowed_any} = 1 if ( $entry->{holdallowed} == 2 ); |
| 540 |
$entry->{holdallowed_same} = 1 if($entry->{holdallowed} == 1); |
543 |
$entry->{holdallowed_same} = 1 if ( $entry->{holdallowed} == 1 ); |
| 541 |
} |
544 |
} |
| 542 |
|
545 |
|
| 543 |
$template->param(show_branch_cat_rule_form => 1); |
546 |
$template->param(show_branch_cat_rule_form => 1); |
|
Lines 563-574
if ($branch eq "*") {
Link Here
|
| 563 |
my $defaults = $sth_defaults->fetchrow_hashref; |
566 |
my $defaults = $sth_defaults->fetchrow_hashref; |
| 564 |
|
567 |
|
| 565 |
if ($defaults) { |
568 |
if ($defaults) { |
| 566 |
$template->param(default_holdallowed_none => 1) if($defaults->{holdallowed} == 0); |
569 |
$template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 ); |
| 567 |
$template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1); |
570 |
$template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 ); |
| 568 |
$template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2); |
571 |
$template->param( default_holdallowed_any => 1 ) if ( $defaults->{holdallowed} == 2 ); |
| 569 |
$template->param(default_maxissueqty => $defaults->{maxissueqty}); |
572 |
$template->param( default_hold_fulfillment_policy => $defaults->{hold_fulfillment_policy} ); |
| 570 |
$template->param(default_maxonsiteissueqty => $defaults->{maxonsiteissueqty}); |
573 |
$template->param( default_maxissueqty => $defaults->{maxissueqty} ); |
| 571 |
$template->param(default_returnbranch => $defaults->{returnbranch}); |
574 |
$template->param( default_maxonsiteissueqty => $defaults->{maxonsiteissueqty} ); |
|
|
575 |
$template->param( default_returnbranch => $defaults->{returnbranch} ); |
| 572 |
} |
576 |
} |
| 573 |
|
577 |
|
| 574 |
$template->param(default_rules => ($defaults ? 1 : 0)); |
578 |
$template->param(default_rules => ($defaults ? 1 : 0)); |