Lines 31-36
use Koha::Patrons;
Link Here
|
31 |
use Koha::Patron::Categories; |
31 |
use Koha::Patron::Categories; |
32 |
use Koha::ItemTypes; |
32 |
use Koha::ItemTypes; |
33 |
use Koha::IssuingRules; |
33 |
use Koha::IssuingRules; |
|
|
34 |
use Koha::CirculationRules; |
35 |
use Switch; |
34 |
|
36 |
|
35 |
#Setting variables |
37 |
#Setting variables |
36 |
my $input = new CGI; |
38 |
my $input = new CGI; |
Lines 240-267
if ( $step == 5 ) {
Link Here
|
240 |
my $maxissueqty = $input->param('maxissueqty'); |
242 |
my $maxissueqty = $input->param('maxissueqty'); |
241 |
my $issuelength = $input->param('issuelength'); |
243 |
my $issuelength = $input->param('issuelength'); |
242 |
my $lengthunit = $input->param('lengthunit'); |
244 |
my $lengthunit = $input->param('lengthunit'); |
243 |
my $renewalsallowed = $input->param('renewalsallowed'); |
245 |
my $renewalsallowed = $input->param('renewalsallowed'); |
244 |
my $renewalperiod = $input->param('renewalperiod'); |
246 |
my $renewalperiod = $input->param('renewalperiod'); |
245 |
my $onshelfholds = $input->param('onshelfholds') || 0; |
247 |
my $onshelfholds = $input->param('onshelfholds') || 0; |
246 |
$maxissueqty =~ s/\s//g; |
248 |
$maxissueqty =~ s/\s//g; |
247 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
249 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
248 |
$issuelength = $issuelength eq q{} ? undef : $issuelength; |
250 |
$issuelength = $issuelength eq q{} ? undef : $issuelength; |
249 |
|
251 |
|
250 |
my $params = { |
252 |
my $issuingruleparams = { |
251 |
branchcode => $branchcode, |
253 |
branchcode => $branchcode, |
252 |
categorycode => $categorycode, |
254 |
categorycode => $categorycode, |
253 |
itemtype => $itemtype, |
255 |
itemtype => $itemtype, |
254 |
maxissueqty => $maxissueqty, |
|
|
255 |
renewalsallowed => $renewalsallowed, |
256 |
renewalsallowed => $renewalsallowed, |
256 |
renewalperiod => $renewalperiod, |
257 |
renewalperiod => $renewalperiod, |
257 |
issuelength => $issuelength, |
258 |
issuelength => $issuelength, |
258 |
lengthunit => $lengthunit, |
259 |
lengthunit => $lengthunit, |
259 |
onshelfholds => $onshelfholds, |
260 |
onshelfholds => $onshelfholds, |
260 |
}; |
261 |
}; |
|
|
262 |
$branchcode = $branchcode if $branchcode ne '*'; |
263 |
$branchcode = undef if $branchcode eq '*'; |
264 |
$categorycode = $categorycode if $categorycode ne '*'; |
265 |
$categorycode = undef if $categorycode eq '*'; |
266 |
$itemtype = $itemtype if $itemtype ne '*'; |
267 |
$itemtype = undef if $itemtype eq '*'; |
268 |
|
269 |
my $circulationruleparams = { |
270 |
branchcode => $branchcode, |
271 |
categorycode => $categorycode, |
272 |
itemtype => $itemtype, |
273 |
rule_name => 'patron_maxissueqty', |
274 |
rule_value => $maxissueqty, |
275 |
}; |
261 |
|
276 |
|
262 |
my $issuingrule = Koha::IssuingRule->new($params); |
277 |
my $issuingrule = Koha::IssuingRule->new($issuingruleparams); |
263 |
eval { $issuingrule->store; }; |
278 |
eval { $issuingrule->store; }; |
264 |
|
279 |
|
|
|
280 |
my $circulationrule = Koha::CirculationRule->new($circulationruleparams); |
281 |
eval { $circulationrule->store; }; |
282 |
|
265 |
unless ($@) { |
283 |
unless ($@) { |
266 |
push @messages, { code => 'success_on_insert_circ_rule' }; |
284 |
push @messages, { code => 'success_on_insert_circ_rule' }; |
267 |
} |
285 |
} |
Lines 269-276
if ( $step == 5 ) {
Link Here
|
269 |
push @messages, { code => 'error_on_insert_circ_rule' }; |
287 |
push @messages, { code => 'error_on_insert_circ_rule' }; |
270 |
} |
288 |
} |
271 |
} |
289 |
} |
272 |
|
290 |
warn Koha::CirculationRules->count; |
273 |
$step++ if Koha::IssuingRules->count; |
291 |
$step++ if (Koha::IssuingRules->count && Koha::CirculationRules->count); |
274 |
} |
292 |
} |
275 |
|
293 |
|
276 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
294 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |