Lines 193-198
elsif ($op eq "set-branch-defaults") {
Link Here
|
193 |
my $maxissueqty = $input->param('maxissueqty'); |
193 |
my $maxissueqty = $input->param('maxissueqty'); |
194 |
my $maxonsiteissueqty = $input->param('maxonsiteissueqty'); |
194 |
my $maxonsiteissueqty = $input->param('maxonsiteissueqty'); |
195 |
my $holdallowed = $input->param('holdallowed'); |
195 |
my $holdallowed = $input->param('holdallowed'); |
|
|
196 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
196 |
my $returnbranch = $input->param('returnbranch'); |
197 |
my $returnbranch = $input->param('returnbranch'); |
197 |
$maxissueqty =~ s/\s//g; |
198 |
$maxissueqty =~ s/\s//g; |
198 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
199 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
Lines 205-238
elsif ($op eq "set-branch-defaults") {
Link Here
|
205 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
206 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
206 |
FROM default_circ_rules"); |
207 |
FROM default_circ_rules"); |
207 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
208 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
208 |
(maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
209 |
(maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) |
209 |
VALUES (?, ?, ?, ?)"); |
210 |
VALUES (?, ?, ?, ?, ?)"); |
210 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
211 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
211 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ?"); |
212 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?"); |
212 |
|
213 |
|
213 |
$sth_search->execute(); |
214 |
$sth_search->execute(); |
214 |
my $res = $sth_search->fetchrow_hashref(); |
215 |
my $res = $sth_search->fetchrow_hashref(); |
215 |
if ($res->{total}) { |
216 |
if ($res->{total}) { |
216 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch); |
217 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
217 |
} else { |
218 |
} else { |
218 |
$sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch); |
219 |
$sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
219 |
} |
220 |
} |
220 |
} else { |
221 |
} else { |
221 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
222 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
222 |
FROM default_branch_circ_rules |
223 |
FROM default_branch_circ_rules |
223 |
WHERE branchcode = ?"); |
224 |
WHERE branchcode = ?"); |
224 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
225 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
225 |
(branchcode, maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
226 |
(branchcode, maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) |
226 |
VALUES (?, ?, ?, ?, ?)"); |
227 |
VALUES (?, ?, ?, ?, ?, ?)"); |
227 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
228 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
228 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ? |
229 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
229 |
WHERE branchcode = ?"); |
230 |
WHERE branchcode = ?"); |
230 |
$sth_search->execute($branch); |
231 |
$sth_search->execute($branch); |
231 |
my $res = $sth_search->fetchrow_hashref(); |
232 |
my $res = $sth_search->fetchrow_hashref(); |
232 |
if ($res->{total}) { |
233 |
if ($res->{total}) { |
233 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch, $branch); |
234 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch, $branch); |
234 |
} else { |
235 |
} else { |
235 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch); |
236 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
236 |
} |
237 |
} |
237 |
} |
238 |
} |
238 |
} |
239 |
} |
Lines 340-348
elsif ($op eq "add-branch-cat") {
Link Here
|
340 |
} |
341 |
} |
341 |
} |
342 |
} |
342 |
elsif ($op eq "add-branch-item") { |
343 |
elsif ($op eq "add-branch-item") { |
343 |
my $itemtype = $input->param('itemtype'); |
344 |
my $itemtype = $input->param('itemtype'); |
344 |
my $holdallowed = $input->param('holdallowed'); |
345 |
my $holdallowed = $input->param('holdallowed'); |
345 |
my $returnbranch = $input->param('returnbranch'); |
346 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
|
|
347 |
my $returnbranch = $input->param('returnbranch'); |
348 |
|
346 |
$holdallowed =~ s/\s//g; |
349 |
$holdallowed =~ s/\s//g; |
347 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
350 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
348 |
|
351 |
|
Lines 351-384
elsif ($op eq "add-branch-item") {
Link Here
|
351 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
354 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
352 |
FROM default_circ_rules"); |
355 |
FROM default_circ_rules"); |
353 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
356 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
354 |
(holdallowed, returnbranch) |
357 |
(holdallowed, hold_fulfillment_policy, returnbranch) |
355 |
VALUES (?, ?)"); |
358 |
VALUES (?, ?, ?)"); |
356 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
359 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
357 |
SET holdallowed = ?, returnbranch = ?"); |
360 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ?"); |
358 |
|
361 |
|
359 |
$sth_search->execute(); |
362 |
$sth_search->execute(); |
360 |
my $res = $sth_search->fetchrow_hashref(); |
363 |
my $res = $sth_search->fetchrow_hashref(); |
361 |
if ($res->{total}) { |
364 |
if ($res->{total}) { |
362 |
$sth_update->execute($holdallowed, $returnbranch); |
365 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch); |
363 |
} else { |
366 |
} else { |
364 |
$sth_insert->execute($holdallowed, $returnbranch); |
367 |
$sth_insert->execute($holdallowed, $hold_fulfillment_policy, $returnbranch); |
365 |
} |
368 |
} |
366 |
} else { |
369 |
} else { |
367 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
370 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
368 |
FROM default_branch_item_rules |
371 |
FROM default_branch_item_rules |
369 |
WHERE itemtype = ?"); |
372 |
WHERE itemtype = ?"); |
370 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules |
373 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules |
371 |
(itemtype, holdallowed, returnbranch) |
374 |
(itemtype, holdallowed, hold_fulfillment_policy, returnbranch) |
372 |
VALUES (?, ?, ?)"); |
375 |
VALUES (?, ?, ?, ?)"); |
373 |
my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules |
376 |
my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules |
374 |
SET holdallowed = ?, returnbranch = ? |
377 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
375 |
WHERE itemtype = ?"); |
378 |
WHERE itemtype = ?"); |
376 |
$sth_search->execute($itemtype); |
379 |
$sth_search->execute($itemtype); |
377 |
my $res = $sth_search->fetchrow_hashref(); |
380 |
my $res = $sth_search->fetchrow_hashref(); |
378 |
if ($res->{total}) { |
381 |
if ($res->{total}) { |
379 |
$sth_update->execute($holdallowed, $returnbranch, $itemtype); |
382 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $itemtype); |
380 |
} else { |
383 |
} else { |
381 |
$sth_insert->execute($itemtype, $holdallowed, $returnbranch); |
384 |
$sth_insert->execute($itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
382 |
} |
385 |
} |
383 |
} |
386 |
} |
384 |
} elsif ($itemtype eq "*") { |
387 |
} elsif ($itemtype eq "*") { |
Lines 386-402
elsif ($op eq "add-branch-item") {
Link Here
|
386 |
FROM default_branch_circ_rules |
389 |
FROM default_branch_circ_rules |
387 |
WHERE branchcode = ?"); |
390 |
WHERE branchcode = ?"); |
388 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
391 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
389 |
(branchcode, holdallowed, returnbranch) |
392 |
(branchcode, holdallowed, hold_fulfillment_policy, returnbranch) |
390 |
VALUES (?, ?, ?)"); |
393 |
VALUES (?, ?, ?, ?)"); |
391 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
394 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
392 |
SET holdallowed = ?, returnbranch = ? |
395 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
393 |
WHERE branchcode = ?"); |
396 |
WHERE branchcode = ?"); |
394 |
$sth_search->execute($branch); |
397 |
$sth_search->execute($branch); |
395 |
my $res = $sth_search->fetchrow_hashref(); |
398 |
my $res = $sth_search->fetchrow_hashref(); |
396 |
if ($res->{total}) { |
399 |
if ($res->{total}) { |
397 |
$sth_update->execute($holdallowed, $returnbranch, $branch); |
400 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch); |
398 |
} else { |
401 |
} else { |
399 |
$sth_insert->execute($branch, $holdallowed, $returnbranch); |
402 |
$sth_insert->execute($branch, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
400 |
} |
403 |
} |
401 |
} else { |
404 |
} else { |
402 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
405 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
Lines 404-422
elsif ($op eq "add-branch-item") {
Link Here
|
404 |
WHERE branchcode = ? |
407 |
WHERE branchcode = ? |
405 |
AND itemtype = ?"); |
408 |
AND itemtype = ?"); |
406 |
my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules |
409 |
my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules |
407 |
(branchcode, itemtype, holdallowed, returnbranch) |
410 |
(branchcode, itemtype, holdallowed, hold_fulfillment_policy, returnbranch) |
408 |
VALUES (?, ?, ?, ?)"); |
411 |
VALUES (?, ?, ?, ?, ?)"); |
409 |
my $sth_update = $dbh->prepare("UPDATE branch_item_rules |
412 |
my $sth_update = $dbh->prepare("UPDATE branch_item_rules |
410 |
SET holdallowed = ?, returnbranch = ? |
413 |
SET holdallowed = ?, hold_fulfillment_policy = ?, returnbranch = ? |
411 |
WHERE branchcode = ? |
414 |
WHERE branchcode = ? |
412 |
AND itemtype = ?"); |
415 |
AND itemtype = ?"); |
413 |
|
416 |
|
414 |
$sth_search->execute($branch, $itemtype); |
417 |
$sth_search->execute($branch, $itemtype); |
415 |
my $res = $sth_search->fetchrow_hashref(); |
418 |
my $res = $sth_search->fetchrow_hashref(); |
416 |
if ($res->{total}) { |
419 |
if ($res->{total}) { |
417 |
$sth_update->execute($holdallowed, $returnbranch, $branch, $itemtype); |
420 |
$sth_update->execute($holdallowed, $hold_fulfillment_policy, $returnbranch, $branch, $itemtype); |
418 |
} else { |
421 |
} else { |
419 |
$sth_insert->execute($branch, $itemtype, $holdallowed, $returnbranch); |
422 |
$sth_insert->execute($branch, $itemtype, $holdallowed, $hold_fulfillment_policy, $returnbranch); |
420 |
} |
423 |
} |
421 |
} |
424 |
} |
422 |
} |
425 |
} |
Lines 549-556
my @sorted_branch_item_rules = sort { lc $a->{translated_description} cmp lc $b-
Link Here
|
549 |
|
552 |
|
550 |
# note undef holdallowed so that template can deal with them |
553 |
# note undef holdallowed so that template can deal with them |
551 |
foreach my $entry (@sorted_branch_item_rules) { |
554 |
foreach my $entry (@sorted_branch_item_rules) { |
552 |
$entry->{holdallowed_any} = 1 if($entry->{holdallowed} == 2); |
555 |
$entry->{holdallowed_any} = 1 if ( $entry->{holdallowed} == 2 ); |
553 |
$entry->{holdallowed_same} = 1 if($entry->{holdallowed} == 1); |
556 |
$entry->{holdallowed_same} = 1 if ( $entry->{holdallowed} == 1 ); |
554 |
} |
557 |
} |
555 |
|
558 |
|
556 |
$template->param(show_branch_cat_rule_form => 1); |
559 |
$template->param(show_branch_cat_rule_form => 1); |
Lines 576-587
if ($branch eq "*") {
Link Here
|
576 |
my $defaults = $sth_defaults->fetchrow_hashref; |
579 |
my $defaults = $sth_defaults->fetchrow_hashref; |
577 |
|
580 |
|
578 |
if ($defaults) { |
581 |
if ($defaults) { |
579 |
$template->param(default_holdallowed_none => 1) if($defaults->{holdallowed} == 0); |
582 |
$template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 ); |
580 |
$template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1); |
583 |
$template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 ); |
581 |
$template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2); |
584 |
$template->param( default_holdallowed_any => 1 ) if ( $defaults->{holdallowed} == 2 ); |
582 |
$template->param(default_maxissueqty => $defaults->{maxissueqty}); |
585 |
$template->param( default_hold_fulfillment_policy => $defaults->{hold_fulfillment_policy} ); |
583 |
$template->param(default_maxonsiteissueqty => $defaults->{maxonsiteissueqty}); |
586 |
$template->param( default_maxissueqty => $defaults->{maxissueqty} ); |
584 |
$template->param(default_returnbranch => $defaults->{returnbranch}); |
587 |
$template->param( default_maxonsiteissueqty => $defaults->{maxonsiteissueqty} ); |
|
|
588 |
$template->param( default_returnbranch => $defaults->{returnbranch} ); |
585 |
} |
589 |
} |
586 |
|
590 |
|
587 |
$template->param(default_rules => ($defaults ? 1 : 0)); |
591 |
$template->param(default_rules => ($defaults ? 1 : 0)); |