Lines 27-32
use C4::Koha;
Link Here
|
27 |
use C4::Debug; |
27 |
use C4::Debug; |
28 |
use C4::Branch; # GetBranches |
28 |
use C4::Branch; # GetBranches |
29 |
use C4::Dates qw/format_date format_date_in_iso/; |
29 |
use C4::Dates qw/format_date format_date_in_iso/; |
|
|
30 |
use Koha::Database; |
30 |
|
31 |
|
31 |
my $input = CGI->new; |
32 |
my $input = CGI->new; |
32 |
my $dbh = C4::Context->dbh; |
33 |
my $dbh = C4::Context->dbh; |
Lines 100-109
elsif ($op eq 'delete-branch-item') {
Link Here
|
100 |
} |
101 |
} |
101 |
# save the values entered |
102 |
# save the values entered |
102 |
elsif ($op eq 'add') { |
103 |
elsif ($op eq 'add') { |
103 |
my $sth_search = $dbh->prepare('SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?'); |
|
|
104 |
my $sth_insert = $dbh->prepare('INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, reservesallowed, norenewalbefore, auto_renew, reservesallowed, issuelength, lengthunit, hardduedate, hardduedatecompare, fine, finedays, maxsuspensiondays, firstremind, chargeperiod,rentaldiscount, onshelfholds, opacitemholds, overduefinescap) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'); |
105 |
my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, maxsuspensiondays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, renewalperiod=?, norenewalbefore=?, auto_renew=?, reservesallowed=?, issuelength=?, lengthunit=?, hardduedate=?, hardduedatecompare=?, rentaldiscount=?, onshelfholds=?, opacitemholds=?, overduefinescap=? WHERE branchcode=? AND categorycode=? AND itemtype=?"); |
106 |
|
107 |
my $br = $branch; # branch |
104 |
my $br = $branch; # branch |
108 |
my $bor = $input->param('categorycode'); # borrower category |
105 |
my $bor = $input->param('categorycode'); # borrower category |
109 |
my $itemtype = $input->param('itemtype'); # item type |
106 |
my $itemtype = $input->param('itemtype'); # item type |
Lines 133-146
elsif ($op eq 'add') {
Link Here
|
133 |
my $overduefinescap = $input->param('overduefinescap') || undef; |
130 |
my $overduefinescap = $input->param('overduefinescap') || undef; |
134 |
$debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty"; |
131 |
$debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty"; |
135 |
|
132 |
|
136 |
$sth_search->execute($br,$bor,$itemtype); |
133 |
my $schema = Koha::Database->new()->schema(); |
137 |
my $res = $sth_search->fetchrow_hashref(); |
134 |
my $rs = $schema->resultset('Issuingrule'); |
138 |
if ($res->{total}) { |
135 |
|
139 |
$sth_update->execute($fine, $finedays, $maxsuspensiondays, $firstremind, $chargeperiod, $maxissueqty, $renewalsallowed, $renewalperiod, $norenewalbefore, $auto_renew, $reservesallowed, $issuelength,$lengthunit, $hardduedate,$hardduedatecompare,$rentaldiscount, $onshelfholds, $opacitemholds, $overduefinescap, $br,$bor,$itemtype); |
136 |
my $params = { |
140 |
} else { |
137 |
branchcode => $br, |
141 |
$sth_insert->execute($br,$bor,$itemtype,$maxissueqty,$renewalsallowed, $renewalperiod, $norenewalbefore, $auto_renew, $reservesallowed,$issuelength,$lengthunit,$hardduedate,$hardduedatecompare,$fine,$finedays, $maxsuspensiondays, $firstremind,$chargeperiod,$rentaldiscount,$onshelfholds,$opacitemholds,$overduefinescap); |
138 |
categorycode => $bor, |
142 |
} |
139 |
itemtype => $itemtype, |
143 |
} |
140 |
fine => $fine, |
|
|
141 |
finedays => $finedays, |
142 |
maxsuspensiondays => $maxsuspensiondays, |
143 |
firstremind => $firstremind, |
144 |
chargeperiod => $chargeperiod, |
145 |
maxissueqty => $maxissueqty, |
146 |
renewalsallowed => $renewalsallowed, |
147 |
renewalperiod => $renewalperiod, |
148 |
norenewalbefore => $norenewalbefore, |
149 |
auto_renew => $auto_renew, |
150 |
reservesallowed => $reservesallowed, |
151 |
issuelength => $issuelength, |
152 |
lengthunit => $lengthunit, |
153 |
hardduedate => $hardduedate, |
154 |
hardduedatecompare => $hardduedatecompare, |
155 |
rentaldiscount => $rentaldiscount, |
156 |
onshelfholds => $onshelfholds, |
157 |
opacitemholds => $opacitemholds, |
158 |
overduefinescap => $overduefinescap, |
159 |
}; |
160 |
|
161 |
$rs->update_or_create($params); |
162 |
|
163 |
} |
144 |
elsif ($op eq "set-branch-defaults") { |
164 |
elsif ($op eq "set-branch-defaults") { |
145 |
my $categorycode = $input->param('categorycode'); |
165 |
my $categorycode = $input->param('categorycode'); |
146 |
my $maxissueqty = $input->param('maxissueqty'); |
166 |
my $maxissueqty = $input->param('maxissueqty'); |
Lines 413-419
if ($branch eq "*") {
Link Here
|
413 |
SELECT default_borrower_circ_rules.*, categories.description AS humancategorycode |
433 |
SELECT default_borrower_circ_rules.*, categories.description AS humancategorycode |
414 |
FROM default_borrower_circ_rules |
434 |
FROM default_borrower_circ_rules |
415 |
JOIN categories USING (categorycode) |
435 |
JOIN categories USING (categorycode) |
416 |
|
436 |
|
417 |
"); |
437 |
"); |
418 |
$sth_branch_cat->execute(); |
438 |
$sth_branch_cat->execute(); |
419 |
} else { |
439 |
} else { |
Lines 507-513
$template->param(categoryloop => \@category_loop,
Link Here
|
507 |
branchloop => \@branchloop, |
527 |
branchloop => \@branchloop, |
508 |
humanbranch => ($branch ne '*' ? $branches->{$branch}->{branchname} : ''), |
528 |
humanbranch => ($branch ne '*' ? $branches->{$branch}->{branchname} : ''), |
509 |
current_branch => $branch, |
529 |
current_branch => $branch, |
510 |
definedbranch => scalar(@sorted_row_loop)>0 |
530 |
definedbranch => scalar(@sorted_row_loop)>0 |
511 |
); |
531 |
); |
512 |
output_html_with_http_headers $input, $cookie, $template->output; |
532 |
output_html_with_http_headers $input, $cookie, $template->output; |
513 |
|
533 |
|