|
Lines 17-24
Link Here
|
| 17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
| 18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
|
19 |
|
| 20 |
use strict; |
20 |
use Modern::Perl; |
| 21 |
use warnings; |
|
|
| 22 |
use CGI; |
21 |
use CGI; |
| 23 |
use C4::Context; |
22 |
use C4::Context; |
| 24 |
use C4::Output; |
23 |
use C4::Output; |
|
Lines 44-50
my ($template, $loggedinuser, $cookie)
Link Here
|
| 44 |
|
43 |
|
| 45 |
my $type=$input->param('type'); |
44 |
my $type=$input->param('type'); |
| 46 |
my $branch = $input->param('branch') || ( C4::Branch::onlymine() ? ( C4::Branch::mybranch() || '*' ) : '*' ); |
45 |
my $branch = $input->param('branch') || ( C4::Branch::onlymine() ? ( C4::Branch::mybranch() || '*' ) : '*' ); |
| 47 |
my $op = $input->param('op'); |
46 |
my $op = $input->param('op') || ''; |
| 48 |
|
47 |
|
| 49 |
if ($op eq 'delete') { |
48 |
if ($op eq 'delete') { |
| 50 |
my $itemtype = $input->param('itemtype'); |
49 |
my $itemtype = $input->param('itemtype'); |
|
Lines 56-101
if ($op eq 'delete') {
Link Here
|
| 56 |
} |
55 |
} |
| 57 |
elsif ($op eq 'delete-branch-cat') { |
56 |
elsif ($op eq 'delete-branch-cat') { |
| 58 |
my $categorycode = $input->param('categorycode'); |
57 |
my $categorycode = $input->param('categorycode'); |
| 59 |
if ($branch eq "*") { |
58 |
if ($categorycode eq "*") { |
| 60 |
if ($categorycode eq "*") { |
59 |
my $sth_delete = $dbh->prepare("DELETE FROM circ_rules WHERE branchcode = ?"); |
| 61 |
my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules"); |
60 |
$sth_delete->execute( $branch ); |
| 62 |
$sth_delete->execute(); |
|
|
| 63 |
} else { |
| 64 |
my $sth_delete = $dbh->prepare("DELETE FROM default_borrower_circ_rules |
| 65 |
WHERE categorycode = ?"); |
| 66 |
$sth_delete->execute($categorycode); |
| 67 |
} |
| 68 |
} elsif ($categorycode eq "*") { |
| 69 |
my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules |
| 70 |
WHERE branchcode = ?"); |
| 71 |
$sth_delete->execute($branch); |
| 72 |
} else { |
61 |
} else { |
| 73 |
my $sth_delete = $dbh->prepare("DELETE FROM branch_borrower_circ_rules |
62 |
my $sth_delete = $dbh->prepare("DELETE FROM borrower_circ_rules |
| 74 |
WHERE branchcode = ? |
63 |
WHERE branchcode = ? |
| 75 |
AND categorycode = ?"); |
64 |
AND categorycode = ?"); |
| 76 |
$sth_delete->execute($branch, $categorycode); |
65 |
$sth_delete->execute( $branch, $categorycode ); |
| 77 |
} |
66 |
} |
| 78 |
} |
67 |
} |
| 79 |
elsif ($op eq 'delete-branch-item') { |
68 |
elsif ($op eq 'delete-branch-item') { |
| 80 |
my $itemtype = $input->param('itemtype'); |
69 |
my $itemtype = $input->param('itemtype'); |
| 81 |
if ($branch eq "*") { |
70 |
if ($itemtype eq "*") { |
| 82 |
if ($itemtype eq "*") { |
71 |
my $sth_delete = $dbh->prepare("DELETE FROM circ_rules WHERE branchcode = ?"); |
| 83 |
my $sth_delete = $dbh->prepare("DELETE FROM default_circ_rules"); |
72 |
$sth_delete->execute( $branch); |
| 84 |
$sth_delete->execute(); |
|
|
| 85 |
} else { |
| 86 |
my $sth_delete = $dbh->prepare("DELETE FROM default_branch_item_rules |
| 87 |
WHERE itemtype = ?"); |
| 88 |
$sth_delete->execute($itemtype); |
| 89 |
} |
| 90 |
} elsif ($itemtype eq "*") { |
| 91 |
my $sth_delete = $dbh->prepare("DELETE FROM default_branch_circ_rules |
| 92 |
WHERE branchcode = ?"); |
| 93 |
$sth_delete->execute($branch); |
| 94 |
} else { |
73 |
} else { |
| 95 |
my $sth_delete = $dbh->prepare("DELETE FROM branch_item_rules |
74 |
my $sth_delete = $dbh->prepare("DELETE FROM item_circ_rules |
| 96 |
WHERE branchcode = ? |
75 |
WHERE branchcode = ? |
| 97 |
AND itemtype = ?"); |
76 |
AND itemtype = ?"); |
| 98 |
$sth_delete->execute($branch, $itemtype); |
77 |
$sth_delete->execute( $branch, $itemtype ); |
| 99 |
} |
78 |
} |
| 100 |
} |
79 |
} |
| 101 |
# save the values entered |
80 |
# save the values entered |
|
Lines 142-181
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 142 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
121 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
| 143 |
$holdallowed =~ s/\s//g; |
122 |
$holdallowed =~ s/\s//g; |
| 144 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
123 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
| 145 |
|
124 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 146 |
if ($branch eq "*") { |
125 |
FROM circ_rules |
| 147 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
126 |
WHERE branchcode = ?"); |
| 148 |
FROM default_circ_rules"); |
127 |
my $sth_insert = $dbh->prepare("INSERT INTO circ_rules |
| 149 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
128 |
(branchcode, maxissueqty, holdallowed, returnbranch) |
| 150 |
(maxissueqty, holdallowed, returnbranch) |
129 |
VALUES (?, ?, ?, ?)"); |
| 151 |
VALUES (?, ?, ?)"); |
130 |
my $sth_update = $dbh->prepare("UPDATE circ_rules |
| 152 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
131 |
SET maxissueqty = ?, holdallowed = ?, returnbranch = ? |
| 153 |
SET maxissueqty = ?, holdallowed = ?, returnbranch = ?"); |
132 |
WHERE branchcode = ?"); |
| 154 |
|
133 |
|
| 155 |
$sth_search->execute(); |
134 |
$sth_search->execute( $branch ); |
| 156 |
my $res = $sth_search->fetchrow_hashref(); |
135 |
my $res = $sth_search->fetchrow_hashref(); |
| 157 |
if ($res->{total}) { |
136 |
if ($res->{total}) { |
| 158 |
$sth_update->execute($maxissueqty, $holdallowed, $returnbranch); |
137 |
$sth_update->execute($maxissueqty, $holdallowed, $returnbranch, $branch); |
| 159 |
} else { |
|
|
| 160 |
$sth_insert->execute($maxissueqty, $holdallowed, $returnbranch); |
| 161 |
} |
| 162 |
} else { |
138 |
} else { |
| 163 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
139 |
$sth_insert->execute($branch, $maxissueqty, $holdallowed, $returnbranch); |
| 164 |
FROM default_branch_circ_rules |
|
|
| 165 |
WHERE branchcode = ?"); |
| 166 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
| 167 |
(branchcode, maxissueqty, holdallowed, returnbranch) |
| 168 |
VALUES (?, ?, ?, ?)"); |
| 169 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
| 170 |
SET maxissueqty = ?, holdallowed = ?, returnbranch = ? |
| 171 |
WHERE branchcode = ?"); |
| 172 |
$sth_search->execute($branch); |
| 173 |
my $res = $sth_search->fetchrow_hashref(); |
| 174 |
if ($res->{total}) { |
| 175 |
$sth_update->execute($maxissueqty, $holdallowed, $returnbranch, $branch); |
| 176 |
} else { |
| 177 |
$sth_insert->execute($branch, $maxissueqty, $holdallowed, $returnbranch); |
| 178 |
} |
| 179 |
} |
140 |
} |
| 180 |
} |
141 |
} |
| 181 |
elsif ($op eq "add-branch-cat") { |
142 |
elsif ($op eq "add-branch-cat") { |
|
Lines 184-255
elsif ($op eq "add-branch-cat") {
Link Here
|
| 184 |
$maxissueqty =~ s/\s//g; |
145 |
$maxissueqty =~ s/\s//g; |
| 185 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
146 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
| 186 |
|
147 |
|
| 187 |
if ($branch eq "*") { |
148 |
if ($categorycode eq "*") { |
| 188 |
if ($categorycode eq "*") { |
|
|
| 189 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 190 |
FROM default_circ_rules"); |
| 191 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
| 192 |
(maxissueqty) |
| 193 |
VALUES (?)"); |
| 194 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
| 195 |
SET maxissueqty = ?"); |
| 196 |
|
| 197 |
$sth_search->execute(); |
| 198 |
my $res = $sth_search->fetchrow_hashref(); |
| 199 |
if ($res->{total}) { |
| 200 |
$sth_update->execute($maxissueqty); |
| 201 |
} else { |
| 202 |
$sth_insert->execute($maxissueqty); |
| 203 |
} |
| 204 |
} else { |
| 205 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 206 |
FROM default_borrower_circ_rules |
| 207 |
WHERE categorycode = ?"); |
| 208 |
my $sth_insert = $dbh->prepare("INSERT INTO default_borrower_circ_rules |
| 209 |
(categorycode, maxissueqty) |
| 210 |
VALUES (?, ?)"); |
| 211 |
my $sth_update = $dbh->prepare("UPDATE default_borrower_circ_rules |
| 212 |
SET maxissueqty = ? |
| 213 |
WHERE categorycode = ?"); |
| 214 |
$sth_search->execute($branch); |
| 215 |
my $res = $sth_search->fetchrow_hashref(); |
| 216 |
if ($res->{total}) { |
| 217 |
$sth_update->execute($maxissueqty, $categorycode); |
| 218 |
} else { |
| 219 |
$sth_insert->execute($categorycode, $maxissueqty); |
| 220 |
} |
| 221 |
} |
| 222 |
} elsif ($categorycode eq "*") { |
| 223 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
149 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 224 |
FROM default_branch_circ_rules |
150 |
FROM circ_rules |
| 225 |
WHERE branchcode = ?"); |
151 |
WHERE branchcode = ?"); |
| 226 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
152 |
my $sth_insert = $dbh->prepare("INSERT INTO circ_rules |
| 227 |
(branchcode, maxissueqty) |
153 |
(branchcode, maxissueqty) |
| 228 |
VALUES (?, ?)"); |
154 |
VALUES (?, ?)"); |
| 229 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
155 |
my $sth_update = $dbh->prepare("UPDATE circ_rules |
| 230 |
SET maxissueqty = ? |
156 |
SET maxissueqty = ? |
| 231 |
WHERE branchcode = ?"); |
157 |
WHERE branchcode = ?"); |
| 232 |
$sth_search->execute($branch); |
158 |
|
|
|
159 |
$sth_search->execute( $branch ); |
| 233 |
my $res = $sth_search->fetchrow_hashref(); |
160 |
my $res = $sth_search->fetchrow_hashref(); |
| 234 |
if ($res->{total}) { |
161 |
if ($res->{total}) { |
| 235 |
$sth_update->execute($maxissueqty, $branch); |
162 |
$sth_update->execute( $branch, $maxissueqty ); |
| 236 |
} else { |
163 |
} else { |
| 237 |
$sth_insert->execute($branch, $maxissueqty); |
164 |
$sth_insert->execute( $maxissueqty, $branch ); |
| 238 |
} |
165 |
} |
| 239 |
} else { |
166 |
} else { |
| 240 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
167 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 241 |
FROM branch_borrower_circ_rules |
168 |
FROM borrower_circ_rules |
| 242 |
WHERE branchcode = ? |
169 |
WHERE branchcode = ? |
| 243 |
AND categorycode = ?"); |
170 |
AND categorycode = ?"); |
| 244 |
my $sth_insert = $dbh->prepare("INSERT INTO branch_borrower_circ_rules |
171 |
my $sth_insert = $dbh->prepare("INSERT INTO borrower_circ_rules |
| 245 |
(branchcode, categorycode, maxissueqty) |
172 |
(branchcode, categorycode, maxissueqty) |
| 246 |
VALUES (?, ?, ?)"); |
173 |
VALUES (?, ?, ?)"); |
| 247 |
my $sth_update = $dbh->prepare("UPDATE branch_borrower_circ_rules |
174 |
my $sth_update = $dbh->prepare("UPDATE borrower_circ_rules |
| 248 |
SET maxissueqty = ? |
175 |
SET maxissueqty = ? |
| 249 |
WHERE branchcode = ? |
176 |
WHERE branchcode = ? |
| 250 |
AND categorycode = ?"); |
177 |
AND categorycode = ?"); |
| 251 |
|
178 |
$sth_search->execute( $branch, $categorycode ); |
| 252 |
$sth_search->execute($branch, $categorycode); |
|
|
| 253 |
my $res = $sth_search->fetchrow_hashref(); |
179 |
my $res = $sth_search->fetchrow_hashref(); |
| 254 |
if ($res->{total}) { |
180 |
if ($res->{total}) { |
| 255 |
$sth_update->execute($maxissueqty, $branch, $categorycode); |
181 |
$sth_update->execute($maxissueqty, $branch, $categorycode); |
|
Lines 265-316
elsif ($op eq "add-branch-item") {
Link Here
|
| 265 |
$holdallowed =~ s/\s//g; |
191 |
$holdallowed =~ s/\s//g; |
| 266 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
192 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
| 267 |
|
193 |
|
| 268 |
if ($branch eq "*") { |
194 |
if ($itemtype eq "*") { |
| 269 |
if ($itemtype eq "*") { |
|
|
| 270 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 271 |
FROM default_circ_rules"); |
| 272 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
| 273 |
(holdallowed, returnbranch) |
| 274 |
VALUES (?, ?)"); |
| 275 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
| 276 |
SET holdallowed = ?, returnbranch = ?"); |
| 277 |
|
| 278 |
$sth_search->execute(); |
| 279 |
my $res = $sth_search->fetchrow_hashref(); |
| 280 |
if ($res->{total}) { |
| 281 |
$sth_update->execute($holdallowed, $returnbranch); |
| 282 |
} else { |
| 283 |
$sth_insert->execute($holdallowed, $returnbranch); |
| 284 |
} |
| 285 |
} else { |
| 286 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 287 |
FROM default_branch_item_rules |
| 288 |
WHERE itemtype = ?"); |
| 289 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_item_rules |
| 290 |
(itemtype, holdallowed, returnbranch) |
| 291 |
VALUES (?, ?, ?)"); |
| 292 |
my $sth_update = $dbh->prepare("UPDATE default_branch_item_rules |
| 293 |
SET holdallowed = ?, returnbranch = ? |
| 294 |
WHERE itemtype = ?"); |
| 295 |
$sth_search->execute($itemtype); |
| 296 |
my $res = $sth_search->fetchrow_hashref(); |
| 297 |
if ($res->{total}) { |
| 298 |
$sth_update->execute($holdallowed, $returnbranch, $itemtype); |
| 299 |
} else { |
| 300 |
$sth_insert->execute($itemtype, $holdallowed, $returnbranch); |
| 301 |
} |
| 302 |
} |
| 303 |
} elsif ($itemtype eq "*") { |
| 304 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
195 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 305 |
FROM default_branch_circ_rules |
196 |
FROM circ_rules |
| 306 |
WHERE branchcode = ?"); |
197 |
WHERE branchcode = ?"); |
| 307 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
198 |
my $sth_insert = $dbh->prepare("INSERT INTO circ_rules |
| 308 |
(branchcode, holdallowed, returnbranch) |
199 |
(branchcode, holdallowed, returnbranch) |
| 309 |
VALUES (?, ?, ?)"); |
200 |
VALUES (?, ?, ?)"); |
| 310 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
201 |
my $sth_update = $dbh->prepare("UPDATE circ_rules |
| 311 |
SET holdallowed = ?, returnbranch = ? |
202 |
SET holdallowed = ?, returnbranch = ? |
| 312 |
WHERE branchcode = ?"); |
203 |
WHERE branchcode = ?"); |
| 313 |
$sth_search->execute($branch); |
204 |
|
|
|
205 |
$sth_search->execute( $branch ); |
| 314 |
my $res = $sth_search->fetchrow_hashref(); |
206 |
my $res = $sth_search->fetchrow_hashref(); |
| 315 |
if ($res->{total}) { |
207 |
if ($res->{total}) { |
| 316 |
$sth_update->execute($holdallowed, $returnbranch, $branch); |
208 |
$sth_update->execute($holdallowed, $returnbranch, $branch); |
|
Lines 319-336
elsif ($op eq "add-branch-item") {
Link Here
|
| 319 |
} |
211 |
} |
| 320 |
} else { |
212 |
} else { |
| 321 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
213 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 322 |
FROM branch_item_rules |
214 |
FROM item_circ_rules |
| 323 |
WHERE branchcode = ? |
215 |
WHERE itemtype = ?"); |
| 324 |
AND itemtype = ?"); |
216 |
my $sth_insert = $dbh->prepare("INSERT INTO item_circ_rules |
| 325 |
my $sth_insert = $dbh->prepare("INSERT INTO branch_item_rules |
|
|
| 326 |
(branchcode, itemtype, holdallowed, returnbranch) |
217 |
(branchcode, itemtype, holdallowed, returnbranch) |
| 327 |
VALUES (?, ?, ?, ?)"); |
218 |
VALUES (?, ?, ?, ?)"); |
| 328 |
my $sth_update = $dbh->prepare("UPDATE branch_item_rules |
219 |
my $sth_update = $dbh->prepare("UPDATE item_circ_rules |
| 329 |
SET holdallowed = ?, returnbranch = ? |
220 |
SET holdallowed = ?, returnbranch = ? |
| 330 |
WHERE branchcode = ? |
221 |
WHERE branchcode = ? |
| 331 |
AND itemtype = ?"); |
222 |
AND itemtype = ?"); |
| 332 |
|
223 |
$sth_search->execute($itemtype); |
| 333 |
$sth_search->execute($branch, $itemtype); |
|
|
| 334 |
my $res = $sth_search->fetchrow_hashref(); |
224 |
my $res = $sth_search->fetchrow_hashref(); |
| 335 |
if ($res->{total}) { |
225 |
if ($res->{total}) { |
| 336 |
$sth_update->execute($holdallowed, $returnbranch, $branch, $itemtype); |
226 |
$sth_update->execute($holdallowed, $returnbranch, $branch, $itemtype); |
|
Lines 385-391
while (my $row = $sth2->fetchrow_hashref) {
Link Here
|
| 385 |
$row->{'humancategorycode'} ||= $row->{'categorycode'}; |
275 |
$row->{'humancategorycode'} ||= $row->{'categorycode'}; |
| 386 |
$row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*'; |
276 |
$row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*'; |
| 387 |
$row->{'fine'} = sprintf('%.2f', $row->{'fine'}); |
277 |
$row->{'fine'} = sprintf('%.2f', $row->{'fine'}); |
| 388 |
if ($row->{'hardduedate'} ne '0000-00-00') { |
278 |
if ($row->{hardduedate} and $row->{'hardduedate'} ne '0000-00-00') { |
| 389 |
$row->{'hardduedate'} = format_date( $row->{'hardduedate'}); |
279 |
$row->{'hardduedate'} = format_date( $row->{'hardduedate'}); |
| 390 |
$row->{'hardduedatebefore'} = 1 if ($row->{'hardduedatecompare'} == -1); |
280 |
$row->{'hardduedatebefore'} = 1 if ($row->{'hardduedatecompare'} == -1); |
| 391 |
$row->{'hardduedateexact'} = 1 if ($row->{'hardduedatecompare'} == 0); |
281 |
$row->{'hardduedateexact'} = 1 if ($row->{'hardduedatecompare'} == 0); |
|
Lines 400-422
$sth->finish;
Link Here
|
| 400 |
my @sorted_row_loop = sort by_category_and_itemtype @row_loop; |
290 |
my @sorted_row_loop = sort by_category_and_itemtype @row_loop; |
| 401 |
|
291 |
|
| 402 |
my $sth_branch_cat; |
292 |
my $sth_branch_cat; |
| 403 |
if ($branch eq "*") { |
293 |
$sth_branch_cat = $dbh->prepare(" |
| 404 |
$sth_branch_cat = $dbh->prepare(" |
294 |
SELECT borrower_circ_rules.*, categories.description AS humancategorycode |
| 405 |
SELECT default_borrower_circ_rules.*, categories.description AS humancategorycode |
295 |
FROM borrower_circ_rules |
| 406 |
FROM default_borrower_circ_rules |
296 |
JOIN categories USING (categorycode) |
| 407 |
JOIN categories USING (categorycode) |
297 |
WHERE borrower_circ_rules.branchcode = ? |
| 408 |
|
298 |
"); |
| 409 |
"); |
299 |
$sth_branch_cat->execute($branch); |
| 410 |
$sth_branch_cat->execute(); |
|
|
| 411 |
} else { |
| 412 |
$sth_branch_cat = $dbh->prepare(" |
| 413 |
SELECT branch_borrower_circ_rules.*, categories.description AS humancategorycode |
| 414 |
FROM branch_borrower_circ_rules |
| 415 |
JOIN categories USING (categorycode) |
| 416 |
WHERE branch_borrower_circ_rules.branchcode = ? |
| 417 |
"); |
| 418 |
$sth_branch_cat->execute($branch); |
| 419 |
} |
| 420 |
|
300 |
|
| 421 |
my @branch_cat_rules = (); |
301 |
my @branch_cat_rules = (); |
| 422 |
while (my $row = $sth_branch_cat->fetchrow_hashref) { |
302 |
while (my $row = $sth_branch_cat->fetchrow_hashref) { |
|
Lines 432-453
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) {
Link Here
|
| 432 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |
312 |
@sorted_row_loop = sort by_category_and_itemtype @row_loop; |
| 433 |
|
313 |
|
| 434 |
my $sth_branch_item; |
314 |
my $sth_branch_item; |
| 435 |
if ($branch eq "*") { |
315 |
$sth_branch_item = $dbh->prepare(" |
| 436 |
$sth_branch_item = $dbh->prepare(" |
316 |
SELECT item_circ_rules.*, itemtypes.description AS humanitemtype |
| 437 |
SELECT default_branch_item_rules.*, itemtypes.description AS humanitemtype |
317 |
FROM item_circ_rules |
| 438 |
FROM default_branch_item_rules |
318 |
JOIN itemtypes USING (itemtype) |
| 439 |
JOIN itemtypes USING (itemtype) |
319 |
WHERE item_circ_rules.branchcode = ? |
| 440 |
"); |
320 |
"); |
| 441 |
$sth_branch_item->execute(); |
321 |
$sth_branch_item->execute($branch); |
| 442 |
} else { |
|
|
| 443 |
$sth_branch_item = $dbh->prepare(" |
| 444 |
SELECT branch_item_rules.*, itemtypes.description AS humanitemtype |
| 445 |
FROM branch_item_rules |
| 446 |
JOIN itemtypes USING (itemtype) |
| 447 |
WHERE branch_item_rules.branchcode = ? |
| 448 |
"); |
| 449 |
$sth_branch_item->execute($branch); |
| 450 |
} |
| 451 |
|
322 |
|
| 452 |
my @branch_item_rules = (); |
323 |
my @branch_item_rules = (); |
| 453 |
while (my $row = $sth_branch_item->fetchrow_hashref) { |
324 |
while (my $row = $sth_branch_item->fetchrow_hashref) { |
|
Lines 466-485
$template->param(branch_item_rule_loop => \@sorted_branch_item_rules);
Link Here
|
| 466 |
$template->param(branch_cat_rule_loop => \@sorted_branch_cat_rules); |
337 |
$template->param(branch_cat_rule_loop => \@sorted_branch_cat_rules); |
| 467 |
|
338 |
|
| 468 |
my $sth_defaults; |
339 |
my $sth_defaults; |
| 469 |
if ($branch eq "*") { |
340 |
$sth_defaults = $dbh->prepare(" |
| 470 |
$sth_defaults = $dbh->prepare(" |
341 |
SELECT * |
| 471 |
SELECT * |
342 |
FROM circ_rules |
| 472 |
FROM default_circ_rules |
343 |
WHERE branchcode = ? |
| 473 |
"); |
344 |
"); |
| 474 |
$sth_defaults->execute(); |
345 |
$sth_defaults->execute($branch); |
| 475 |
} else { |
|
|
| 476 |
$sth_defaults = $dbh->prepare(" |
| 477 |
SELECT * |
| 478 |
FROM default_branch_circ_rules |
| 479 |
WHERE branchcode = ? |
| 480 |
"); |
| 481 |
$sth_defaults->execute($branch); |
| 482 |
} |
| 483 |
|
346 |
|
| 484 |
my $defaults = $sth_defaults->fetchrow_hashref; |
347 |
my $defaults = $sth_defaults->fetchrow_hashref; |
| 485 |
|
348 |
|
|
Lines 493-506
if ($defaults) {
Link Here
|
| 493 |
|
356 |
|
| 494 |
$template->param(default_rules => ($defaults ? 1 : 0)); |
357 |
$template->param(default_rules => ($defaults ? 1 : 0)); |
| 495 |
|
358 |
|
| 496 |
$template->param(categoryloop => \@category_loop, |
359 |
$template->param( |
| 497 |
itemtypeloop => \@itemtypes, |
360 |
categoryloop => \@category_loop, |
| 498 |
rules => \@sorted_row_loop, |
361 |
itemtypeloop => \@itemtypes, |
| 499 |
branchloop => \@branchloop, |
362 |
rules => \@sorted_row_loop, |
| 500 |
humanbranch => ($branch ne '*' ? $branches->{$branch}->{branchname} : ''), |
363 |
branchloop => \@branchloop, |
| 501 |
current_branch => $branch, |
364 |
humanbranch => ($branch ne '*' ? $branches->{$branch}->{branchname} : ''), |
| 502 |
definedbranch => scalar(@sorted_row_loop)>0 |
365 |
current_branch => $branch, |
| 503 |
); |
366 |
definedbranch => scalar(@sorted_row_loop)>0, |
|
|
367 |
); |
| 504 |
output_html_with_http_headers $input, $cookie, $template->output; |
368 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 505 |
|
369 |
|
| 506 |
exit 0; |
370 |
exit 0; |