|
Lines 6-11
use diagnostics;
Link Here
|
| 6 |
|
6 |
|
| 7 |
|
7 |
|
| 8 |
use Modern::Perl; |
8 |
use Modern::Perl; |
|
|
9 |
use C4::InstallAuth; |
| 9 |
|
10 |
|
| 10 |
#External modules |
11 |
#External modules |
| 11 |
use CGI qw ( -utf8 ); |
12 |
use CGI qw ( -utf8 ); |
|
Lines 53-59
my $query = new CGI;
Link Here
|
| 53 |
my $step = $query->param('step'); |
54 |
my $step = $query->param('step'); |
| 54 |
|
55 |
|
| 55 |
#Getting the appropriate template to display to the user--> |
56 |
#Getting the appropriate template to display to the user--> |
| 56 |
my ( $template, $loggedinuser, $cookie) = get_template_and_user( |
57 |
my ( $template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user( |
| 57 |
{ |
58 |
{ |
| 58 |
template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt", |
59 |
template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt", |
| 59 |
query => $query, |
60 |
query => $query, |
|
Lines 180-186
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 180 |
my $message; |
181 |
my $message; |
| 181 |
my $category; |
182 |
my $category; |
| 182 |
|
183 |
|
| 183 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
184 |
my ( $template, $loggedinuser, $cookie ) = C4::InstallAuth::get_template_and_user( |
| 184 |
{ |
185 |
{ |
| 185 |
template_name => "/onboarding/onboardingstep2.tt", |
186 |
template_name => "/onboarding/onboardingstep2.tt", |
| 186 |
query => $input, |
187 |
query => $input, |
|
Lines 193-199
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 193 |
|
194 |
|
| 194 |
#Once the user submits the page, this code validates the input and adds it |
195 |
#Once the user submits the page, this code validates the input and adds it |
| 195 |
#to the database as a new patron category |
196 |
#to the database as a new patron category |
| 196 |
|
|
|
| 197 |
my $categorycode = $input->param('categorycode'); |
197 |
my $categorycode = $input->param('categorycode'); |
| 198 |
my $description = $input->param('description'); |
198 |
my $description = $input->param('description'); |
| 199 |
my $overduenoticerequired = $input->param('overduenoticerequired'); |
199 |
my $overduenoticerequired = $input->param('overduenoticerequired'); |
|
Lines 238-244
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 238 |
|
238 |
|
| 239 |
#Create a patron |
239 |
#Create a patron |
| 240 |
}elsif ( $step && $step == 3 ){ |
240 |
}elsif ( $step && $step == 3 ){ |
| 241 |
|
|
|
| 242 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
241 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
| 243 |
$template->param(libraries => $libraries, |
242 |
$template->param(libraries => $libraries, |
| 244 |
group_types => [ |
243 |
group_types => [ |
|
Lines 257-271
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 257 |
categories => $categories, |
256 |
categories => $categories, |
| 258 |
); |
257 |
); |
| 259 |
|
258 |
|
| 260 |
|
|
|
| 261 |
my $input = new CGI; |
259 |
my $input = new CGI; |
| 262 |
my $op = $input->param('op') // 'list'; |
260 |
my $op = $input->param('op') // 'list'; |
| 263 |
|
261 |
|
| 264 |
my @messages; |
262 |
my @messages; |
| 265 |
my @errors; |
263 |
my @errors; |
| 266 |
my $nok = $input->param('nok'); |
|
|
| 267 |
|
264 |
|
| 268 |
my ($template, $loggedinuser, $cookie)= get_template_and_user({ |
265 |
my ($template, $loggedinuser, $cookie)= C4::InstallAuth::get_template_and_user({ |
| 269 |
template_name => "/onboarding/onboardingstep3.tt", |
266 |
template_name => "/onboarding/onboardingstep3.tt", |
| 270 |
query => $input, |
267 |
query => $input, |
| 271 |
type => "intranet", |
268 |
type => "intranet", |
|
Lines 290-314
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 290 |
$newdata{dateexpiry} = '12/10/2016'; |
287 |
$newdata{dateexpiry} = '12/10/2016'; |
| 291 |
$newdata{privacy} = "default"; |
288 |
$newdata{privacy} = "default"; |
| 292 |
|
289 |
|
| 293 |
$newdata{'cardnumber'} = undef if $newdata{'cardnumber'} =~ /^\s*$/; |
290 |
if(my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ |
| 294 |
if(my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ |
|
|
| 295 |
push @errors, $error_code == 1 |
291 |
push @errors, $error_code == 1 |
| 296 |
? 'ERROR_cardnumber_already_exists' |
292 |
? 'ERROR_cardnumber_already_exists' |
| 297 |
:$error_code == 2 |
293 |
:$error_code == 2 |
| 298 |
? 'ERROR_cardnumber_length' |
294 |
? 'ERROR_cardnumber_length' |
| 299 |
:() |
295 |
:() |
| 300 |
} |
296 |
} |
| 301 |
|
297 |
|
| 302 |
|
298 |
|
| 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 |
299 |
#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 |
| 304 |
my $borrowernumber = &AddMember(%newdata); |
300 |
my $borrowernumber = &AddMember(%newdata); |
| 305 |
|
|
|
| 306 |
#Create a hash named member2 and fillit with the borrowernumber of the borrower that has just been created |
301 |
#Create a hash named member2 and fillit with the borrowernumber of the borrower that has just been created |
| 307 |
my %member2; |
302 |
my %member2; |
| 308 |
$member2{'borrowernumber'}=$borrowernumber; |
303 |
$member2{'borrowernumber'}=$borrowernumber; |
| 309 |
|
304 |
|
| 310 |
my $flag = $input->param('flag'); |
305 |
my $flag = $input->param('flag'); |
| 311 |
|
|
|
| 312 |
if ($input->param('newflags')) { |
306 |
if ($input->param('newflags')) { |
| 313 |
my $dbh=C4::Context->dbh(); |
307 |
my $dbh=C4::Context->dbh(); |
| 314 |
my @perms = $input->multi_param('flag'); |
308 |
my @perms = $input->multi_param('flag'); |
|
Lines 354-360
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 354 |
my $op = $input->param('op') // 'list'; |
348 |
my $op = $input->param('op') // 'list'; |
| 355 |
my $message; |
349 |
my $message; |
| 356 |
|
350 |
|
| 357 |
my( $template, $borrowernumber, $cookie) = get_template_and_user( |
351 |
my( $template, $borrowernumber, $cookie) = C4::InstallAuth::get_template_and_user( |
| 358 |
{ template_name => "/onboarding/onboardingstep4.tt", |
352 |
{ template_name => "/onboarding/onboardingstep4.tt", |
| 359 |
query => $input, |
353 |
query => $input, |
| 360 |
type => "intranet", |
354 |
type => "intranet", |
|
Lines 372-385
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 372 |
my $description = $input->param('description'); |
366 |
my $description = $input->param('description'); |
| 373 |
|
367 |
|
| 374 |
#store the input from the form - only 2 fields |
368 |
#store the input from the form - only 2 fields |
| 375 |
$itemtype= Koha::ItemType->new( |
369 |
my $thisitemtype= Koha::ItemType->new( |
| 376 |
{ itemtype => $itemtype_code, |
370 |
{ itemtype => $itemtype_code, |
| 377 |
description => $description, |
371 |
description => $description, |
| 378 |
} |
372 |
} |
| 379 |
); |
373 |
); |
| 380 |
eval{ $itemtype->store; }; |
374 |
eval{ $thisitemtype->store; }; |
| 381 |
#Error messages |
375 |
#Error messages |
| 382 |
if($itemtype){ |
376 |
if($thisitemtype){ |
| 383 |
$message = 'success_on_insert'; |
377 |
$message = 'success_on_insert'; |
| 384 |
}else{ |
378 |
}else{ |
| 385 |
$message = 'error_on_insert'; |
379 |
$message = 'error_on_insert'; |
|
Lines 387-397
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 387 |
|
381 |
|
| 388 |
$template->param('message' => $message); |
382 |
$template->param('message' => $message); |
| 389 |
} |
383 |
} |
| 390 |
|
|
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
}elsif ( $step && $step == 5){ |
384 |
}elsif ( $step && $step == 5){ |
|
|
385 |
|
| 395 |
#Fetching all the existing categories to display in a drop down box |
386 |
#Fetching all the existing categories to display in a drop down box |
| 396 |
my $categories; |
387 |
my $categories; |
| 397 |
$categories= Koha::Patron::Categories->search(); |
388 |
$categories= Koha::Patron::Categories->search(); |
|
Lines 420-427
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 420 |
my $input = CGI->new; |
411 |
my $input = CGI->new; |
| 421 |
my $dbh = C4::Context->dbh; |
412 |
my $dbh = C4::Context->dbh; |
| 422 |
|
413 |
|
| 423 |
my ($template, $loggedinuser, $cookie) |
414 |
my ($template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user({template_name => "/onboarding/onboardingstep5.tt", |
| 424 |
= get_template_and_user({template_name => "/onboarding/onboardingstep5.tt", |
|
|
| 425 |
query => $input, |
415 |
query => $input, |
| 426 |
type => "intranet", |
416 |
type => "intranet", |
| 427 |
authnotrequired => 0, |
417 |
authnotrequired => 0, |
|
Lines 442-448
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 442 |
my $op = $input->param('op') || q{}; |
432 |
my $op = $input->param('op') || q{}; |
| 443 |
|
433 |
|
| 444 |
if($op eq 'add_validate'){ |
434 |
if($op eq 'add_validate'){ |
| 445 |
|
|
|
| 446 |
my $type = $input->param('type'); |
435 |
my $type = $input->param('type'); |
| 447 |
my $br = $branch; |
436 |
my $br = $branch; |
| 448 |
my $bor = $input->param('categorycode'); |
437 |
my $bor = $input->param('categorycode'); |
|
Lines 468-473
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
| 468 |
lengthunit => $lengthunit, |
457 |
lengthunit => $lengthunit, |
| 469 |
onshelfholds => $onshelfholds, |
458 |
onshelfholds => $onshelfholds, |
| 470 |
}; |
459 |
}; |
|
|
460 |
my @messages; |
| 461 |
|
| 462 |
#New code from smart-rules.tt starts here. Needs to be added to library |
| 463 |
#Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to. |
| 464 |
if ($branch eq "*") { |
| 465 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 466 |
FROM default_circ_rules"); |
| 467 |
my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules |
| 468 |
(maxissueqty, onshelfholds) |
| 469 |
VALUES (?, ?)"); |
| 470 |
my $sth_update = $dbh->prepare("UPDATE default_circ_rules |
| 471 |
SET maxissueqty = ?, onshelfholds = ?"); |
| 472 |
|
| 473 |
$sth_search->execute(); |
| 474 |
my $res = $sth_search->fetchrow_hashref(); |
| 475 |
if ($res->{total}) { |
| 476 |
$sth_update->execute($maxissueqty, $onshelfholds); |
| 477 |
} else { |
| 478 |
$sth_insert->execute($maxissueqty, $onshelfholds); |
| 479 |
} |
| 480 |
} |
| 481 |
|
| 482 |
|
| 483 |
#Allows for the 'All' option to work when selecting all patron categories for a circulation rule to apply to. |
| 484 |
if ($bor eq "*") { |
| 485 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 486 |
FROM default_circ_rules"); |
| 487 |
my $sth_insert = $dbh->prepare(q| |
| 488 |
INSERT INTO default_circ_rules |
| 489 |
(maxissueqty) |
| 490 |
VALUES (?) |
| 491 |
|); |
| 492 |
my $sth_update = $dbh->prepare(q| |
| 493 |
UPDATE default_circ_rules |
| 494 |
SET maxissueqty = ? |
| 495 |
|); |
| 496 |
|
| 497 |
$sth_search->execute(); |
| 498 |
my $res = $sth_search->fetchrow_hashref(); |
| 499 |
if ($res->{total}) { |
| 500 |
$sth_update->execute($maxissueqty); |
| 501 |
} else { |
| 502 |
$sth_insert->execute($maxissueqty); |
| 503 |
} |
| 504 |
} |
| 505 |
#Allows for the 'All' option to work when selecting all itemtypes for a circulation rule to apply to |
| 506 |
if ($itemtype eq "*") { |
| 507 |
my $sth_search = $dbh->prepare("SELECT count(*) AS total |
| 508 |
FROM default_branch_circ_rules |
| 509 |
WHERE branchcode = ?"); |
| 510 |
my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules |
| 511 |
(branchcode, onshelfholds) |
| 512 |
VALUES (?, ?)"); |
| 513 |
my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules |
| 514 |
SET onshelfholds = ? |
| 515 |
WHERE branchcode = ?"); |
| 516 |
$sth_search->execute($branch); |
| 517 |
my $res = $sth_search->fetchrow_hashref(); |
| 518 |
if ($res->{total}) { |
| 519 |
$sth_update->execute($onshelfholds, $branch); |
| 520 |
} else { |
| 521 |
$sth_insert->execute($branch, $onshelfholds); |
| 522 |
} |
| 523 |
} |
| 524 |
#End new code |
| 525 |
|
| 526 |
my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br }); |
| 527 |
if($issuingrule){ |
| 528 |
$issuingrule->set($params)->store(); |
| 529 |
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. |
| 530 |
|
| 531 |
}else{ |
| 532 |
Koha::IssuingRule->new()->set($params)->store(); |
| 533 |
} |
| 534 |
} |
| 471 |
|
535 |
|
| 472 |
my @messages; |
536 |
my @messages; |
| 473 |
|
537 |
|