|
Lines 111-116
elsif ($op eq 'add') {
Link Here
|
| 111 |
my $firstremind = $input->param('firstremind'); |
111 |
my $firstremind = $input->param('firstremind'); |
| 112 |
my $chargeperiod = $input->param('chargeperiod'); |
112 |
my $chargeperiod = $input->param('chargeperiod'); |
| 113 |
my $maxissueqty = $input->param('maxissueqty'); |
113 |
my $maxissueqty = $input->param('maxissueqty'); |
|
|
114 |
my $maxonsiteissueqty = $input->param('maxonsiteissueqty'); |
| 114 |
my $renewalsallowed = $input->param('renewalsallowed'); |
115 |
my $renewalsallowed = $input->param('renewalsallowed'); |
| 115 |
my $renewalperiod = $input->param('renewalperiod'); |
116 |
my $renewalperiod = $input->param('renewalperiod'); |
| 116 |
my $norenewalbefore = $input->param('norenewalbefore'); |
117 |
my $norenewalbefore = $input->param('norenewalbefore'); |
|
Lines 120-125
elsif ($op eq 'add') {
Link Here
|
| 120 |
my $onshelfholds = $input->param('onshelfholds') || 0; |
121 |
my $onshelfholds = $input->param('onshelfholds') || 0; |
| 121 |
$maxissueqty =~ s/\s//g; |
122 |
$maxissueqty =~ s/\s//g; |
| 122 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
123 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
|
|
124 |
$maxonsiteissueqty =~ s/\s//g; |
| 125 |
$maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/; |
| 123 |
my $issuelength = $input->param('issuelength'); |
126 |
my $issuelength = $input->param('issuelength'); |
| 124 |
my $lengthunit = $input->param('lengthunit'); |
127 |
my $lengthunit = $input->param('lengthunit'); |
| 125 |
my $hardduedate = $input->param('hardduedate'); |
128 |
my $hardduedate = $input->param('hardduedate'); |
|
Lines 128-134
elsif ($op eq 'add') {
Link Here
|
| 128 |
my $rentaldiscount = $input->param('rentaldiscount'); |
131 |
my $rentaldiscount = $input->param('rentaldiscount'); |
| 129 |
my $opacitemholds = $input->param('opacitemholds') || 0; |
132 |
my $opacitemholds = $input->param('opacitemholds') || 0; |
| 130 |
my $overduefinescap = $input->param('overduefinescap') || undef; |
133 |
my $overduefinescap = $input->param('overduefinescap') || undef; |
| 131 |
$debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty"; |
134 |
$debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty"; |
| 132 |
|
135 |
|
| 133 |
my $schema = Koha::Database->new()->schema(); |
136 |
my $schema = Koha::Database->new()->schema(); |
| 134 |
my $rs = $schema->resultset('Issuingrule'); |
137 |
my $rs = $schema->resultset('Issuingrule'); |
|
Lines 143-148
elsif ($op eq 'add') {
Link Here
|
| 143 |
firstremind => $firstremind, |
146 |
firstremind => $firstremind, |
| 144 |
chargeperiod => $chargeperiod, |
147 |
chargeperiod => $chargeperiod, |
| 145 |
maxissueqty => $maxissueqty, |
148 |
maxissueqty => $maxissueqty, |
|
|
149 |
maxonsiteissueqty => $maxonsiteissueqty, |
| 146 |
renewalsallowed => $renewalsallowed, |
150 |
renewalsallowed => $renewalsallowed, |
| 147 |
renewalperiod => $renewalperiod, |
151 |
renewalperiod => $renewalperiod, |
| 148 |
norenewalbefore => $norenewalbefore, |
152 |
norenewalbefore => $norenewalbefore, |
|
Lines 164-173
elsif ($op eq 'add') {
Link Here
|
| 164 |
elsif ($op eq "set-branch-defaults") { |
168 |
elsif ($op eq "set-branch-defaults") { |
| 165 |
my $categorycode = $input->param('categorycode'); |
169 |
my $categorycode = $input->param('categorycode'); |
| 166 |
my $maxissueqty = $input->param('maxissueqty'); |
170 |
my $maxissueqty = $input->param('maxissueqty'); |
|
|
171 |
my $maxonsiteissueqty = $input->param('maxonsiteissueqty'); |
| 167 |
my $holdallowed = $input->param('holdallowed'); |
172 |
my $holdallowed = $input->param('holdallowed'); |
| 168 |
my $returnbranch = $input->param('returnbranch'); |
173 |
my $returnbranch = $input->param('returnbranch'); |
| 169 |
$maxissueqty =~ s/\s//g; |
174 |
$maxissueqty =~ s/\s//g; |
| 170 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
175 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
|
|
176 |
$maxonsiteissueqty =~ s/\s//g; |
| 177 |
$maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/; |
| 171 |
$holdallowed =~ s/\s//g; |
178 |
$holdallowed =~ s/\s//g; |
| 172 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
179 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
| 173 |
|
180 |
|
|
Lines 175-288
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 175 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
182 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 176 |
FROM default_circ_rules"); |
183 |
FROM default_circ_rules"); |
| 177 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
184 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
| 178 |
(maxissueqty, holdallowed, returnbranch) |
185 |
(maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
| 179 |
VALUES (?, ?, ?)"); |
186 |
VALUES (?, ?, ?, ?)"); |
| 180 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
187 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
| 181 |
SET maxissueqty = ?, holdallowed = ?, returnbranch = ?"); |
188 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ?"); |
| 182 |
|
189 |
|
| 183 |
$sth_search->execute(); |
190 |
$sth_search->execute(); |
| 184 |
my $res = $sth_search->fetchrow_hashref(); |
191 |
my $res = $sth_search->fetchrow_hashref(); |
| 185 |
if ($res->{total}) { |
192 |
if ($res->{total}) { |
| 186 |
$sth_update->execute($maxissueqty, $holdallowed, $returnbranch); |
193 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch); |
| 187 |
} else { |
194 |
} else { |
| 188 |
$sth_insert->execute($maxissueqty, $holdallowed, $returnbranch); |
195 |
$sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch); |
| 189 |
} |
196 |
} |
| 190 |
} else { |
197 |
} else { |
| 191 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
198 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 192 |
FROM default_branch_circ_rules |
199 |
FROM default_branch_circ_rules |
| 193 |
WHERE branchcode = ?"); |
200 |
WHERE branchcode = ?"); |
| 194 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
201 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
| 195 |
(branchcode, maxissueqty, holdallowed, returnbranch) |
202 |
(branchcode, maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
| 196 |
VALUES (?, ?, ?, ?)"); |
203 |
VALUES (?, ?, ?, ?, ?)"); |
| 197 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
204 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
| 198 |
SET maxissueqty = ?, holdallowed = ?, returnbranch = ? |
205 |
SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ? |
| 199 |
WHERE branchcode = ?"); |
206 |
WHERE branchcode = ?"); |
| 200 |
$sth_search->execute($branch); |
207 |
$sth_search->execute($branch); |
| 201 |
my $res = $sth_search->fetchrow_hashref(); |
208 |
my $res = $sth_search->fetchrow_hashref(); |
| 202 |
if ($res->{total}) { |
209 |
if ($res->{total}) { |
| 203 |
$sth_update->execute($maxissueqty, $holdallowed, $returnbranch, $branch); |
210 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch, $branch); |
| 204 |
} else { |
211 |
} else { |
| 205 |
$sth_insert->execute($branch, $maxissueqty, $holdallowed, $returnbranch); |
212 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch); |
| 206 |
} |
213 |
} |
| 207 |
} |
214 |
} |
| 208 |
} |
215 |
} |
| 209 |
elsif ($op eq "add-branch-cat") { |
216 |
elsif ($op eq "add-branch-cat") { |
| 210 |
my $categorycode = $input->param('categorycode'); |
217 |
my $categorycode = $input->param('categorycode'); |
| 211 |
my $maxissueqty = $input->param('maxissueqty'); |
218 |
my $maxissueqty = $input->param('maxissueqty'); |
|
|
219 |
my $maxonsiteissueqty = $input->param('maxonsiteissueqty'); |
| 212 |
$maxissueqty =~ s/\s//g; |
220 |
$maxissueqty =~ s/\s//g; |
| 213 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
221 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
|
|
222 |
$maxonsiteissueqty =~ s/\s//g; |
| 223 |
$maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/; |
| 214 |
|
224 |
|
| 215 |
if ($branch eq "*") { |
225 |
if ($branch eq "*") { |
| 216 |
if ($categorycode eq "*") { |
226 |
if ($categorycode eq "*") { |
| 217 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
227 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 218 |
FROM default_circ_rules"); |
228 |
FROM default_circ_rules"); |
| 219 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
229 |
my $sth_insert = $dbh->prepare(q| |
| 220 |
(maxissueqty) |
230 |
INSERT INTO default_circ_rules |
| 221 |
VALUES (?)"); |
231 |
(maxissueqty, maxonsiteissueqty) |
| 222 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
232 |
VALUES (?, ?) |
| 223 |
SET maxissueqty = ?"); |
233 |
|); |
|
|
234 |
my $sth_update = $dbh->prepare(q| |
| 235 |
UPDATE default_circ_rules |
| 236 |
SET maxissueqty = ?, |
| 237 |
maxonsiteissueqty = ? |
| 238 |
|); |
| 224 |
|
239 |
|
| 225 |
$sth_search->execute(); |
240 |
$sth_search->execute(); |
| 226 |
my $res = $sth_search->fetchrow_hashref(); |
241 |
my $res = $sth_search->fetchrow_hashref(); |
| 227 |
if ($res->{total}) { |
242 |
if ($res->{total}) { |
| 228 |
$sth_update->execute($maxissueqty); |
243 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty); |
| 229 |
} else { |
244 |
} else { |
| 230 |
$sth_insert->execute($maxissueqty); |
245 |
$sth_insert->execute($maxissueqty, $maxonsiteissueqty); |
| 231 |
} |
246 |
} |
| 232 |
} else { |
247 |
} else { |
| 233 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
248 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 234 |
FROM default_borrower_circ_rules |
249 |
FROM default_borrower_circ_rules |
| 235 |
WHERE categorycode = ?"); |
250 |
WHERE categorycode = ?"); |
| 236 |
my $sth_insert = $dbh->prepare("INSERT INTO default_borrower_circ_rules |
251 |
my $sth_insert = $dbh->prepare(q| |
| 237 |
(categorycode, maxissueqty) |
252 |
INSERT INTO default_borrower_circ_rules |
| 238 |
VALUES (?, ?)"); |
253 |
(categorycode, maxissueqty, maxonsiteissueqty) |
| 239 |
my $sth_update = $dbh->prepare("UPDATE default_borrower_circ_rules |
254 |
VALUES (?, ?, ?) |
| 240 |
SET maxissueqty = ? |
255 |
|); |
| 241 |
WHERE categorycode = ?"); |
256 |
my $sth_update = $dbh->prepare(q| |
|
|
257 |
UPDATE default_borrower_circ_rules |
| 258 |
SET maxissueqty = ?, |
| 259 |
maxonsiteissueqty = ? |
| 260 |
WHERE categorycode = ? |
| 261 |
|); |
| 242 |
$sth_search->execute($branch); |
262 |
$sth_search->execute($branch); |
| 243 |
my $res = $sth_search->fetchrow_hashref(); |
263 |
my $res = $sth_search->fetchrow_hashref(); |
| 244 |
if ($res->{total}) { |
264 |
if ($res->{total}) { |
| 245 |
$sth_update->execute($maxissueqty, $categorycode); |
265 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $categorycode); |
| 246 |
} else { |
266 |
} else { |
| 247 |
$sth_insert->execute($categorycode, $maxissueqty); |
267 |
$sth_insert->execute($categorycode, $maxissueqty, $maxonsiteissueqty); |
| 248 |
} |
268 |
} |
| 249 |
} |
269 |
} |
| 250 |
} elsif ($categorycode eq "*") { |
270 |
} elsif ($categorycode eq "*") { |
| 251 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
271 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 252 |
FROM default_branch_circ_rules |
272 |
FROM default_branch_circ_rules |
| 253 |
WHERE branchcode = ?"); |
273 |
WHERE branchcode = ?"); |
| 254 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
274 |
my $sth_insert = $dbh->prepare(q| |
| 255 |
(branchcode, maxissueqty) |
275 |
INSERT INTO default_branch_circ_rules |
| 256 |
VALUES (?, ?)"); |
276 |
(branchcode, maxissueqty, maxonsiteissueqty) |
| 257 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
277 |
VALUES (?, ?, ?) |
| 258 |
SET maxissueqty = ? |
278 |
|); |
| 259 |
WHERE branchcode = ?"); |
279 |
my $sth_update = $dbh->prepare(q| |
|
|
280 |
UPDATE default_branch_circ_rules |
| 281 |
SET maxissueqty = ?, |
| 282 |
maxonsiteissueqty = ? |
| 283 |
WHERE branchcode = ? |
| 284 |
|); |
| 260 |
$sth_search->execute($branch); |
285 |
$sth_search->execute($branch); |
| 261 |
my $res = $sth_search->fetchrow_hashref(); |
286 |
my $res = $sth_search->fetchrow_hashref(); |
| 262 |
if ($res->{total}) { |
287 |
if ($res->{total}) { |
| 263 |
$sth_update->execute($maxissueqty, $branch); |
288 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $branch); |
| 264 |
} else { |
289 |
} else { |
| 265 |
$sth_insert->execute($branch, $maxissueqty); |
290 |
$sth_insert->execute($branch, $maxissueqty, $maxonsiteissueqty); |
| 266 |
} |
291 |
} |
| 267 |
} else { |
292 |
} else { |
| 268 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
293 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 269 |
FROM branch_borrower_circ_rules |
294 |
FROM branch_borrower_circ_rules |
| 270 |
WHERE branchcode = ? |
295 |
WHERE branchcode = ? |
| 271 |
AND categorycode = ?"); |
296 |
AND categorycode = ?"); |
| 272 |
my $sth_insert = $dbh->prepare("INSERT INTO branch_borrower_circ_rules |
297 |
my $sth_insert = $dbh->prepare(q| |
| 273 |
(branchcode, categorycode, maxissueqty) |
298 |
INSERT INTO branch_borrower_circ_rules |
| 274 |
VALUES (?, ?, ?)"); |
299 |
(branchcode, categorycode, maxissueqty, maxonsiteissueqty) |
| 275 |
my $sth_update = $dbh->prepare("UPDATE branch_borrower_circ_rules |
300 |
VALUES (?, ?, ?, ?) |
| 276 |
SET maxissueqty = ? |
301 |
|); |
| 277 |
WHERE branchcode = ? |
302 |
my $sth_update = $dbh->prepare(q| |
| 278 |
AND categorycode = ?"); |
303 |
UPDATE branch_borrower_circ_rules |
|
|
304 |
SET maxissueqty = ?, |
| 305 |
maxonsiteissueqty = ? |
| 306 |
WHERE branchcode = ? |
| 307 |
AND categorycode = ? |
| 308 |
|); |
| 279 |
|
309 |
|
| 280 |
$sth_search->execute($branch, $categorycode); |
310 |
$sth_search->execute($branch, $categorycode); |
| 281 |
my $res = $sth_search->fetchrow_hashref(); |
311 |
my $res = $sth_search->fetchrow_hashref(); |
| 282 |
if ($res->{total}) { |
312 |
if ($res->{total}) { |
| 283 |
$sth_update->execute($maxissueqty, $branch, $categorycode); |
313 |
$sth_update->execute($maxissueqty, $maxonsiteissueqty, $branch, $categorycode); |
| 284 |
} else { |
314 |
} else { |
| 285 |
$sth_insert->execute($branch, $categorycode, $maxissueqty); |
315 |
$sth_insert->execute($branch, $categorycode, $maxissueqty, $maxonsiteissueqty); |
| 286 |
} |
316 |
} |
| 287 |
} |
317 |
} |
| 288 |
} |
318 |
} |
|
Lines 455-460
my @sorted_branch_cat_rules = sort { $a->{'humancategorycode'} cmp $b->{'humanca
Link Here
|
| 455 |
# note undef maxissueqty so that template can deal with them |
485 |
# note undef maxissueqty so that template can deal with them |
| 456 |
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { |
486 |
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { |
| 457 |
$entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty}); |
487 |
$entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty}); |
|
|
488 |
$entry->{unlimited_maxonsiteissueqty} = 1 unless defined($entry->{maxonsiteissueqty}); |
| 458 |
} |
489 |
} |
| 459 |
|
490 |
|
| 460 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |
491 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |
|
Lines 516-521
if ($defaults) {
Link Here
|
| 516 |
$template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1); |
547 |
$template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1); |
| 517 |
$template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2); |
548 |
$template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2); |
| 518 |
$template->param(default_maxissueqty => $defaults->{maxissueqty}); |
549 |
$template->param(default_maxissueqty => $defaults->{maxissueqty}); |
|
|
550 |
$template->param(default_maxonsiteissueqty => $defaults->{maxonsiteissueqty}); |
| 519 |
$template->param(default_returnbranch => $defaults->{returnbranch}); |
551 |
$template->param(default_returnbranch => $defaults->{returnbranch}); |
| 520 |
} |
552 |
} |
| 521 |
|
553 |
|