Lines 40-45
use Koha::Patron::HouseboundRoles;
Link Here
|
40 |
use Koha::Token; |
40 |
use Koha::Token; |
41 |
use Email::Valid; |
41 |
use Email::Valid; |
42 |
use Module::Load; |
42 |
use Module::Load; |
|
|
43 |
use Koha::IssuingRule; |
44 |
use Koha::IssuingRules; |
45 |
|
46 |
|
47 |
|
48 |
|
43 |
|
49 |
|
44 |
#Setting variables |
50 |
#Setting variables |
45 |
my $input = new CGI; |
51 |
my $input = new CGI; |
Lines 187-237
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
187 |
|
193 |
|
188 |
#Once the user submits the page, this code validates the input and adds it |
194 |
#Once the user submits the page, this code validates the input and adds it |
189 |
#to the database as a new patron category |
195 |
#to the database as a new patron category |
190 |
#} elsif ( $op eq 'add_validate' ) { |
|
|
191 |
|
196 |
|
192 |
my $categorycode = $input->param('categorycode'); |
197 |
my $categorycode = $input->param('categorycode'); |
193 |
my $description = $input->param('description'); |
198 |
my $description = $input->param('description'); |
194 |
my $overduenoticerequired = $input->param('overduenoticerequired'); |
199 |
my $overduenoticerequired = $input->param('overduenoticerequired'); |
195 |
my $category_type = $input->param('category_type'); |
200 |
my $category_type = $input->param('category_type'); |
196 |
my $default_privacy = $input->param('default_privacy'); |
201 |
my $default_privacy = $input->param('default_privacy'); |
197 |
my $enrolmentperiod = $input->param('enrolmentperiod'); |
202 |
my $enrolmentperiod = $input->param('enrolmentperiod'); |
198 |
my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; |
203 |
my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; |
199 |
|
204 |
|
200 |
#Converts the string into a date format |
205 |
#Converts the string into a date format |
201 |
if ( $enrolmentperioddate) { |
206 |
if ( $enrolmentperioddate) { |
202 |
$enrolmentperioddate = output_pref( |
207 |
$enrolmentperioddate = output_pref( |
203 |
{ |
208 |
{ |
204 |
dt => dt_from_string($enrolmentperioddate), |
209 |
dt => dt_from_string($enrolmentperioddate), |
205 |
dateformat => 'iso', |
210 |
dateformat => 'iso', |
206 |
dateonly => 1, |
211 |
dateonly => 1, |
207 |
} |
212 |
} |
208 |
); |
213 |
); |
209 |
} |
214 |
} |
210 |
#Adds to the database |
|
|
211 |
$category = Koha::Patron::Category->new({ |
212 |
categorycode=> $categorycode, |
213 |
description => $description, |
214 |
overduenoticerequired => $overduenoticerequired, |
215 |
category_type=> $category_type, |
216 |
default_privacy => $default_privacy, |
217 |
enrolmentperiod => $enrolmentperiod, |
218 |
enrolmentperioddate => $enrolmentperioddate, |
219 |
}); |
220 |
eval { |
221 |
$category->store; |
222 |
}; |
223 |
|
215 |
|
224 |
#Error messages |
216 |
#Adds to the database |
225 |
if($category){ |
217 |
$category = Koha::Patron::Category->new({ |
226 |
$message = 'success_on_insert'; |
218 |
categorycode=> $categorycode, |
227 |
}else{ |
219 |
description => $description, |
228 |
$message = 'error_on_insert'; |
220 |
overduenoticerequired => $overduenoticerequired, |
229 |
} |
221 |
category_type=> $category_type, |
|
|
222 |
default_privacy => $default_privacy, |
223 |
enrolmentperiod => $enrolmentperiod, |
224 |
enrolmentperioddate => $enrolmentperioddate, |
225 |
}); |
226 |
eval { |
227 |
$category->store; |
228 |
}; |
229 |
|
230 |
#Error messages |
231 |
if($category){ |
232 |
$message = 'success_on_insert'; |
233 |
}else{ |
234 |
$message = 'error_on_insert'; |
235 |
} |
230 |
|
236 |
|
231 |
$template->param('message' => $message); |
237 |
$template->param('message' => $message); |
232 |
|
238 |
|
233 |
#Create a patron |
239 |
#Create a patron |
234 |
}elsif ( $step && $step == 3 ){ |
240 |
}elsif ( $step && $step == 3 ){ |
|
|
241 |
|
235 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
242 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
236 |
$template->param(libraries => $libraries, |
243 |
$template->param(libraries => $libraries, |
237 |
group_types => [ |
244 |
group_types => [ |
Lines 250-260
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
250 |
categories => $categories, |
257 |
categories => $categories, |
251 |
); |
258 |
); |
252 |
|
259 |
|
|
|
260 |
|
253 |
my $input = new CGI; |
261 |
my $input = new CGI; |
254 |
my $op = $input->param('op') // 'list'; |
262 |
my $op = $input->param('op') // 'list'; |
255 |
|
263 |
|
256 |
my @messages; |
264 |
my @messages; |
257 |
my @errors; |
265 |
my @errors; |
|
|
266 |
my $nok = $input->param('nok'); |
258 |
|
267 |
|
259 |
my ($template, $loggedinuser, $cookie)= get_template_and_user({ |
268 |
my ($template, $loggedinuser, $cookie)= get_template_and_user({ |
260 |
template_name => "/onboarding/onboardingstep3.tt", |
269 |
template_name => "/onboarding/onboardingstep3.tt", |
Lines 266-272
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
266 |
}); |
275 |
}); |
267 |
|
276 |
|
268 |
if($op eq 'add_validate'){ |
277 |
if($op eq 'add_validate'){ |
269 |
my %newdata; |
278 |
my %newdata; |
270 |
|
279 |
|
271 |
#Store the template form values in the newdata hash |
280 |
#Store the template form values in the newdata hash |
272 |
$newdata{borrowernumber} = $input->param('borrowernumber'); |
281 |
$newdata{borrowernumber} = $input->param('borrowernumber'); |
Lines 281-294
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
281 |
$newdata{dateexpiry} = '12/10/2016'; |
290 |
$newdata{dateexpiry} = '12/10/2016'; |
282 |
$newdata{privacy} = "default"; |
291 |
$newdata{privacy} = "default"; |
283 |
|
292 |
|
284 |
if(my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ |
293 |
$newdata{'cardnumber'} = undef if $newdata{'cardnumber'} =~ /^\s*$/; |
|
|
294 |
if(my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ |
285 |
push @errors, $error_code == 1 |
295 |
push @errors, $error_code == 1 |
286 |
? 'ERROR_cardnumber_already_exists' |
296 |
? 'ERROR_cardnumber_already_exists' |
287 |
:$error_code == 2 |
297 |
:$error_code == 2 |
288 |
? 'ERROR_cardnumber_length' |
298 |
? 'ERROR_cardnumber_length' |
289 |
:() |
299 |
:() |
290 |
} |
300 |
} |
291 |
|
|
|
292 |
|
301 |
|
293 |
|
302 |
|
294 |
#Hand the newdata hash to the AddMember subroutine in the C4::Members module and it creates a patron and hands back a borrowernumber which is being stored |
303 |
#Hand the newdata hash to the AddMember subroutine in the C4::Members module and it creates a patron and hands back a borrowernumber which is being stored |
Lines 299-304
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
299 |
$member2{'borrowernumber'}=$borrowernumber; |
308 |
$member2{'borrowernumber'}=$borrowernumber; |
300 |
|
309 |
|
301 |
my $flag = $input->param('flag'); |
310 |
my $flag = $input->param('flag'); |
|
|
311 |
|
302 |
if ($input->param('newflags')) { |
312 |
if ($input->param('newflags')) { |
303 |
my $dbh=C4::Context->dbh(); |
313 |
my $dbh=C4::Context->dbh(); |
304 |
my @perms = $input->multi_param('flag'); |
314 |
my @perms = $input->multi_param('flag'); |
Lines 314-341
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
314 |
} |
324 |
} |
315 |
|
325 |
|
316 |
|
326 |
|
317 |
# construct flags |
327 |
# construct flags |
318 |
my $module_flags = 0; |
328 |
my $module_flags = 0; |
319 |
my $sth=$dbh->prepare("SELECT bit,flag FROM userflags ORDER BY bit"); |
329 |
my $sth=$dbh->prepare("SELECT bit,flag FROM userflags ORDER BY bit"); |
320 |
$sth->execute(); |
330 |
$sth->execute(); |
321 |
while (my ($bit, $flag) = $sth->fetchrow_array) { |
331 |
while (my ($bit, $flag) = $sth->fetchrow_array) { |
322 |
if (exists $all_module_perms{$flag}) { |
332 |
if (exists $all_module_perms{$flag}) { |
323 |
$module_flags += 2**$bit; |
333 |
$module_flags += 2**$bit; |
324 |
} |
334 |
} |
325 |
} |
335 |
} |
326 |
|
336 |
|
327 |
$sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?"); |
337 |
$sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?"); |
328 |
$sth->execute($module_flags, $borrowernumber); |
338 |
$sth->execute($module_flags, $borrowernumber); |
329 |
|
339 |
|
330 |
|
340 |
#Error handling checking if the patron was created successfully |
331 |
#Error handling checking if the patron was created successfully |
341 |
if(!$borrowernumber){ |
332 |
if(!$borrowernumber){ |
342 |
push @messages, {type=> 'error', code => 'error_on_insert'}; |
333 |
push @messages, {type=> 'error', code => 'error_on_insert'}; |
343 |
}else{ |
334 |
}else{ |
344 |
push @messages, {type=> 'message', code => 'success_on_insert'}; |
335 |
push @messages, {type=> 'message', code => 'success_on_insert'}; |
345 |
} |
336 |
} |
346 |
} |
337 |
} |
347 |
} |
338 |
} |
|
|
339 |
}elsif ( $step && $step == 4){ |
348 |
}elsif ( $step && $step == 4){ |
340 |
my $createitemtype = $input->param('createitemtype'); |
349 |
my $createitemtype = $input->param('createitemtype'); |
341 |
$template->param('createitemtype'=> $createitemtype ); |
350 |
$template->param('createitemtype'=> $createitemtype ); |
Lines 363-376
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
363 |
my $description = $input->param('description'); |
372 |
my $description = $input->param('description'); |
364 |
|
373 |
|
365 |
#store the input from the form - only 2 fields |
374 |
#store the input from the form - only 2 fields |
366 |
my $thisitemtype= Koha::ItemType->new( |
375 |
$itemtype= Koha::ItemType->new( |
367 |
{ itemtype => $itemtype_code, |
376 |
{ itemtype => $itemtype_code, |
368 |
description => $description, |
377 |
description => $description, |
369 |
} |
378 |
} |
370 |
); |
379 |
); |
371 |
eval{ $thisitemtype->store; }; |
380 |
eval{ $itemtype->store; }; |
372 |
#Error messages |
381 |
#Error messages |
373 |
if($thisitemtype){ |
382 |
if($itemtype){ |
374 |
$message = 'success_on_insert'; |
383 |
$message = 'success_on_insert'; |
375 |
}else{ |
384 |
}else{ |
376 |
$message = 'error_on_insert'; |
385 |
$message = 'error_on_insert'; |
Lines 378-387
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
378 |
|
387 |
|
379 |
$template->param('message' => $message); |
388 |
$template->param('message' => $message); |
380 |
} |
389 |
} |
381 |
}elsif ( $step && $step == 5){ |
|
|
382 |
my $test="a"; |
383 |
warn $test; |
384 |
|
390 |
|
|
|
391 |
|
392 |
|
393 |
|
394 |
}elsif ( $step && $step == 5){ |
385 |
#Fetching all the existing categories to display in a drop down box |
395 |
#Fetching all the existing categories to display in a drop down box |
386 |
my $categories; |
396 |
my $categories; |
387 |
$categories= Koha::Patron::Categories->search(); |
397 |
$categories= Koha::Patron::Categories->search(); |
Lines 395-442
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
395 |
itemtypes => $itemtypes, |
405 |
itemtypes => $itemtypes, |
396 |
); |
406 |
); |
397 |
|
407 |
|
|
|
408 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
409 |
$template->param(libraries => $libraries, |
410 |
group_types => [ |
411 |
{ categorytype => 'searchdomain', |
412 |
categories => [ Koha::LibraryCategories->search( { categorytype => 'searchdomain' } ) ], |
413 |
}, |
414 |
{ categorytype => 'properties', |
415 |
categories => [ Koha::LibraryCategories->search( { categorytype => 'properties' } ) ], |
416 |
}, |
417 |
] |
418 |
); |
419 |
|
398 |
my $input = CGI->new; |
420 |
my $input = CGI->new; |
399 |
my($template, $loggedinuser, $cookie) =get_template_and_user({ |
421 |
my $dbh = C4::Context->dbh; |
400 |
template_name => "/onboarding/onboardingstep5.tt", |
422 |
|
401 |
query => $input, |
423 |
my ($template, $loggedinuser, $cookie) |
402 |
type => "intranet", |
424 |
= get_template_and_user({template_name => "/onboarding/onboardingstep5.tt", |
403 |
authnotrequired=>0, |
425 |
query => $input, |
404 |
flagsrequired=> {parameters => 'manage_circ_rules'}, |
426 |
type => "intranet", |
405 |
debug =>1, |
427 |
authnotrequired => 0, |
406 |
}); |
428 |
flagsrequired => {parameters => 'manage_circ_rules'}, |
|
|
429 |
debug => 1, |
430 |
}); |
407 |
|
431 |
|
408 |
my $type = $input->param('type'); |
|
|
409 |
my $branch = $input->param('branch'); |
432 |
my $branch = $input->param('branch'); |
|
|
433 |
unless ( $branch ) { |
434 |
if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) { |
435 |
$branch = Koha::Libraries->search->count() == 1 ? undef : C4::Context::mybranch(); |
436 |
} |
437 |
else { |
438 |
$branch = C4::Context::only_my_library() ? ( C4::Context::mybranch() || '*' ) : '*'; |
439 |
} |
440 |
} |
441 |
$branch = '*' if $branch eq 'NO_LIBRARY_SET'; |
442 |
my $op = $input->param('op') || q{}; |
410 |
|
443 |
|
411 |
if($op eq 'add_validate'){ |
444 |
if($op eq 'add_validate'){ |
|
|
445 |
|
446 |
my $type = $input->param('type'); |
447 |
my $br = $branch; |
412 |
my $bor = $input->param('categorycode'); |
448 |
my $bor = $input->param('categorycode'); |
413 |
my $itemtype = $input->param('itemtype'); |
449 |
my $itemtype = $input->param('itemtype'); |
414 |
my $maxissueqty = $input->param('maxissueqty'); |
450 |
my $maxissueqty = $input->param('maxissueqty'); |
415 |
my $issuelength = $input->param('issuelength'); |
451 |
my $issuelength = $input->param('issuelength'); |
416 |
#$issuelength = $issuelength eq q{} ? undef : $issuelength; |
|
|
417 |
my $lengthunit = $input->param('lengthunit'); |
452 |
my $lengthunit = $input->param('lengthunit'); |
418 |
my $renewalsallowed = $input->param('renewalsallowed'); |
453 |
my $renewalsallowed = $input->param('renewalsallowed'); |
419 |
my $renewalperiod = $input->param('renewalperiod'); |
454 |
my $renewalperiod = $input->param('renewalperiod'); |
420 |
my $onshelfholds = $input->param('onshelfholds'); |
455 |
my $onshelfholds = $input->param('onshelfholds') || 0; |
|
|
456 |
$maxissueqty =~ s/\s//g; |
457 |
$maxissueqty = undef if $maxissueqty !~ /^\d+/; |
458 |
$issuelength = $issuelength eq q{} ? undef : $issuelength; |
421 |
|
459 |
|
422 |
my $params ={ |
460 |
my $params ={ |
|
|
461 |
branchcode => $br, |
423 |
categorycode => $bor, |
462 |
categorycode => $bor, |
424 |
itemtype => $itemtype, |
463 |
itemtype => $itemtype, |
425 |
maxissueqty => $maxissueqty, |
464 |
maxissueqty => $maxissueqty, |
426 |
renewalsallowed => $renewalsallowed, |
465 |
renewalsallowed => $renewalsallowed, |
427 |
renewalperiod => $renewalperiod, |
466 |
renewalperiod => $renewalperiod, |
|
|
467 |
issuelength => $issuelength, |
428 |
lengthunit => $lengthunit, |
468 |
lengthunit => $lengthunit, |
429 |
onshelfholds => $onshelfholds, |
469 |
onshelfholds => $onshelfholds, |
430 |
}; |
470 |
}; |
431 |
my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype}); |
471 |
|
|
|
472 |
my @messages; |
473 |
|
474 |
my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br }); |
432 |
if($issuingrule){ |
475 |
if($issuingrule){ |
433 |
$issuingrule->set($params)->store(); |
476 |
$issuingrule->set($params)->store(); |
|
|
477 |
push @messages, {type=> 'error', code => 'error_on_insert'};#Stops crash of the onboarding tool if someone makes a circulation rule with the same item type, library and patron categroy as an exisiting circulation rule. |
434 |
}else{ |
478 |
}else{ |
435 |
Koha::IssuingRule->new()->set($params)->store(); |
479 |
Koha::IssuingRule->new()->set($params)->store(); |
436 |
} |
480 |
} |
437 |
} |
481 |
} |
438 |
} |
482 |
} |
439 |
|
|
|
440 |
|
483 |
|
441 |
output_html_with_http_headers $input, $cookie, $template->output; |
484 |
output_html_with_http_headers $input, $cookie, $template->output; |
442 |
|
485 |
|