Lines 135-140
elsif ($op eq "set-branch-defaults") {
Link Here
|
135 |
my $categorycode = $input->param('categorycode'); |
135 |
my $categorycode = $input->param('categorycode'); |
136 |
my $maxissueqty = $input->param('maxissueqty'); |
136 |
my $maxissueqty = $input->param('maxissueqty'); |
137 |
my $holdallowed = $input->param('holdallowed'); |
137 |
my $holdallowed = $input->param('holdallowed'); |
|
|
138 |
my $returnbranch = $input->param('returnbranch'); |
138 |
$maxissueqty =~ s/\s//g; |
139 |
$maxissueqty =~ s/\s//g; |
139 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
140 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
140 |
$holdallowed =~ s/\s//g; |
141 |
$holdallowed =~ s/\s//g; |
Lines 144-177
elsif ($op eq "set-branch-defaults") {
Link Here
|
144 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
145 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
145 |
FROM default_circ_rules"); |
146 |
FROM default_circ_rules"); |
146 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
147 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
147 |
(maxissueqty, holdallowed) |
148 |
(maxissueqty, holdallowed, returnbranch) |
148 |
VALUES (?, ?)"); |
149 |
VALUES (?, ?, ?)"); |
149 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
150 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
150 |
SET maxissueqty = ?, holdallowed = ?"); |
151 |
SET maxissueqty = ?, holdallowed = ?, returnbranch = ?"); |
151 |
|
152 |
|
152 |
$sth_search->execute(); |
153 |
$sth_search->execute(); |
153 |
my $res = $sth_search->fetchrow_hashref(); |
154 |
my $res = $sth_search->fetchrow_hashref(); |
154 |
if ($res->{total}) { |
155 |
if ($res->{total}) { |
155 |
$sth_update->execute($maxissueqty, $holdallowed); |
156 |
$sth_update->execute($maxissueqty, $holdallowed, $returnbranch); |
156 |
} else { |
157 |
} else { |
157 |
$sth_insert->execute($maxissueqty, $holdallowed); |
158 |
$sth_insert->execute($maxissueqty, $holdallowed, $returnbranch); |
158 |
} |
159 |
} |
159 |
} else { |
160 |
} else { |
160 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
161 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
161 |
FROM default_branch_circ_rules |
162 |
FROM default_branch_circ_rules |
162 |
WHERE branchcode = ?"); |
163 |
WHERE branchcode = ?"); |
163 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
164 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
164 |
(branchcode, maxissueqty, holdallowed) |
165 |
(branchcode, maxissueqty, holdallowed, returnbranch) |
165 |
VALUES (?, ?, ?)"); |
166 |
VALUES (?, ?, ?, ?)"); |
166 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
167 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
167 |
SET maxissueqty = ?, holdallowed = ? |
168 |
SET maxissueqty = ?, holdallowed = ?, returnbranch = ? |
168 |
WHERE branchcode = ?"); |
169 |
WHERE branchcode = ?"); |
169 |
$sth_search->execute($branch); |
170 |
$sth_search->execute($branch); |
170 |
my $res = $sth_search->fetchrow_hashref(); |
171 |
my $res = $sth_search->fetchrow_hashref(); |
171 |
if ($res->{total}) { |
172 |
if ($res->{total}) { |
172 |
$sth_update->execute($maxissueqty, $holdallowed, $branch); |
173 |
$sth_update->execute($maxissueqty, $holdallowed, $returnbranch, $branch); |
173 |
} else { |
174 |
} else { |
174 |
$sth_insert->execute($branch, $maxissueqty, $holdallowed); |
175 |
$sth_insert->execute($branch, $maxissueqty, $holdallowed, $returnbranch); |
175 |
} |
176 |
} |
176 |
} |
177 |
} |
177 |
} |
178 |
} |
Lines 258-263
elsif ($op eq "add-branch-cat") {
Link Here
|
258 |
elsif ($op eq "add-branch-item") { |
259 |
elsif ($op eq "add-branch-item") { |
259 |
my $itemtype = $input->param('itemtype'); |
260 |
my $itemtype = $input->param('itemtype'); |
260 |
my $holdallowed = $input->param('holdallowed'); |
261 |
my $holdallowed = $input->param('holdallowed'); |
|
|
262 |
my $returnbranch = $input->param('returnbranch'); |
261 |
$holdallowed =~ s/\s//g; |
263 |
$holdallowed =~ s/\s//g; |
262 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
264 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
263 |
|
265 |
|
Lines 266-299
elsif ($op eq "add-branch-item") {
Link Here
|
266 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
268 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
267 |
FROM default_circ_rules"); |
269 |
FROM default_circ_rules"); |
268 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
270 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
269 |
(holdallowed) |
271 |
(holdallowed, returnbranch) |
270 |
VALUES (?)"); |
272 |
VALUES (?, ?)"); |
271 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
273 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
272 |
SET holdallowed = ?"); |
274 |
SET holdallowed = ?, returnbranch = ?"); |
273 |
|
275 |
|
274 |
$sth_search->execute(); |
276 |
$sth_search->execute(); |
275 |
my $res = $sth_search->fetchrow_hashref(); |
277 |
my $res = $sth_search->fetchrow_hashref(); |
276 |
if ($res->{total}) { |
278 |
if ($res->{total}) { |
277 |
$sth_update->execute($holdallowed); |
279 |
$sth_update->execute($holdallowed, $returnbranch); |
278 |
} else { |
280 |
} else { |
279 |
$sth_insert->execute($holdallowed); |
281 |
$sth_insert->execute($holdallowed, $returnbranch); |
280 |
} |
282 |
} |
281 |
} else { |
283 |
} else { |
282 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
284 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
283 |
FROM default_branch_item_rules |
285 |
FROM default_branch_item_rules |
284 |
WHERE itemtype = ?"); |
286 |
WHERE itemtype = ?"); |
285 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules |
287 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules |
286 |
(itemtype, holdallowed) |
288 |
(itemtype, holdallowed, returnbranch) |
287 |
VALUES (?, ?)"); |
289 |
VALUES (?, ?, ?)"); |
288 |
my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules |
290 |
my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules |
289 |
SET holdallowed = ? |
291 |
SET holdallowed = ?, returnbranch = ? |
290 |
WHERE itemtype = ?"); |
292 |
WHERE itemtype = ?"); |
291 |
$sth_search->execute($itemtype); |
293 |
$sth_search->execute($itemtype); |
292 |
my $res = $sth_search->fetchrow_hashref(); |
294 |
my $res = $sth_search->fetchrow_hashref(); |
293 |
if ($res->{total}) { |
295 |
if ($res->{total}) { |
294 |
$sth_update->execute($holdallowed, $itemtype); |
296 |
$sth_update->execute($holdallowed, $returnbranch, $itemtype); |
295 |
} else { |
297 |
} else { |
296 |
$sth_insert->execute($itemtype, $holdallowed); |
298 |
$sth_insert->execute($itemtype, $holdallowed, $returnbranch); |
297 |
} |
299 |
} |
298 |
} |
300 |
} |
299 |
} elsif ($itemtype eq "*") { |
301 |
} elsif ($itemtype eq "*") { |
Lines 301-317
elsif ($op eq "add-branch-item") {
Link Here
|
301 |
FROM default_branch_circ_rules |
303 |
FROM default_branch_circ_rules |
302 |
WHERE branchcode = ?"); |
304 |
WHERE branchcode = ?"); |
303 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
305 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
304 |
(branchcode, holdallowed) |
306 |
(branchcode, holdallowed, returnbranch) |
305 |
VALUES (?, ?)"); |
307 |
VALUES (?, ?, ?)"); |
306 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
308 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
307 |
SET holdallowed = ? |
309 |
SET holdallowed = ?, returnbranch = ? |
308 |
WHERE branchcode = ?"); |
310 |
WHERE branchcode = ?"); |
309 |
$sth_search->execute($branch); |
311 |
$sth_search->execute($branch); |
310 |
my $res = $sth_search->fetchrow_hashref(); |
312 |
my $res = $sth_search->fetchrow_hashref(); |
311 |
if ($res->{total}) { |
313 |
if ($res->{total}) { |
312 |
$sth_update->execute($holdallowed, $branch); |
314 |
$sth_update->execute($holdallowed, $returnbranch, $branch); |
313 |
} else { |
315 |
} else { |
314 |
$sth_insert->execute($branch, $holdallowed); |
316 |
$sth_insert->execute($branch, $holdallowed, $returnbranch); |
315 |
} |
317 |
} |
316 |
} else { |
318 |
} else { |
317 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
319 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
Lines 319-337
elsif ($op eq "add-branch-item") {
Link Here
|
319 |
WHERE branchcode = ? |
321 |
WHERE branchcode = ? |
320 |
AND itemtype = ?"); |
322 |
AND itemtype = ?"); |
321 |
my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules |
323 |
my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules |
322 |
(branchcode, itemtype, holdallowed) |
324 |
(branchcode, itemtype, holdallowed, returnbranch) |
323 |
VALUES (?, ?, ?)"); |
325 |
VALUES (?, ?, ?, ?)"); |
324 |
my $sth_update = $dbh->prepare("UPDATE branch_item_rules |
326 |
my $sth_update = $dbh->prepare("UPDATE branch_item_rules |
325 |
SET holdallowed = ? |
327 |
SET holdallowed = ?, returnbranch = ? |
326 |
WHERE branchcode = ? |
328 |
WHERE branchcode = ? |
327 |
AND itemtype = ?"); |
329 |
AND itemtype = ?"); |
328 |
|
330 |
|
329 |
$sth_search->execute($branch, $itemtype); |
331 |
$sth_search->execute($branch, $itemtype); |
330 |
my $res = $sth_search->fetchrow_hashref(); |
332 |
my $res = $sth_search->fetchrow_hashref(); |
331 |
if ($res->{total}) { |
333 |
if ($res->{total}) { |
332 |
$sth_update->execute($holdallowed, $branch, $itemtype); |
334 |
$sth_update->execute($holdallowed, $returnbranch, $branch, $itemtype); |
333 |
} else { |
335 |
} else { |
334 |
$sth_insert->execute($branch, $itemtype, $holdallowed); |
336 |
$sth_insert->execute($branch, $itemtype, $holdallowed, $returnbranch); |
335 |
} |
337 |
} |
336 |
} |
338 |
} |
337 |
} |
339 |
} |
Lines 484-489
if ($defaults) {
Link Here
|
484 |
$template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1); |
486 |
$template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1); |
485 |
$template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2); |
487 |
$template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2); |
486 |
$template->param(default_maxissueqty => $defaults->{maxissueqty}); |
488 |
$template->param(default_maxissueqty => $defaults->{maxissueqty}); |
|
|
489 |
$template->param(default_returnbranch => $defaults->{returnbranch}); |
487 |
} |
490 |
} |
488 |
|
491 |
|
489 |
$template->param(default_rules => ($defaults ? 1 : 0)); |
492 |
$template->param(default_rules => ($defaults ? 1 : 0)); |