Lines 10-17
use CGI qw ( -utf8 );
Link Here
|
10 |
use List::MoreUtils qw/uniq/; |
10 |
use List::MoreUtils qw/uniq/; |
11 |
use Digest::MD5 qw(md5_base64); |
11 |
use Digest::MD5 qw(md5_base64); |
12 |
use Encode qw( encode ); |
12 |
use Encode qw( encode ); |
13 |
|
|
|
14 |
#Internal modules |
15 |
use C4::Koha; |
13 |
use C4::Koha; |
16 |
use C4::Auth; |
14 |
use C4::Auth; |
17 |
use C4::Context; |
15 |
use C4::Context; |
Lines 46-52
my $input = new CGI;
Link Here
|
46 |
my $query = new CGI; |
44 |
my $query = new CGI; |
47 |
my $step = $query->param('step'); |
45 |
my $step = $query->param('step'); |
48 |
|
46 |
|
49 |
#Getting the appropriate template to display to the user--> |
47 |
#Getting the appropriate template to display to the user |
50 |
my ( $template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user( |
48 |
my ( $template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user( |
51 |
{ |
49 |
{ |
52 |
template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt", |
50 |
template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt", |
Lines 87-94
if ( $op && $op eq 'finish' ) { #If the value of $op equals 'finish' then redire
Link Here
|
87 |
|
85 |
|
88 |
#Store the value of the template input name='start' in the variable $start so we can check if the user has pressed this button and started the onboarding tool process |
86 |
#Store the value of the template input name='start' in the variable $start so we can check if the user has pressed this button and started the onboarding tool process |
89 |
my $start = $query->param('start'); |
87 |
my $start = $query->param('start'); |
90 |
$template->param('start'=>$start); #Hand the start variable back to the template |
88 |
$template->param('start'=>$start); |
91 |
if ( $start && $start eq 'Start setting up my Koha' ){ |
89 |
|
|
|
90 |
if ( $start && $start eq 'Start setting up my Koha' ){ |
92 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
91 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
93 |
$template->param(libraries => $libraries, |
92 |
$template->param(libraries => $libraries, |
94 |
group_types => [ |
93 |
group_types => [ |
Lines 101-120
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
101 |
] |
100 |
] |
102 |
); |
101 |
); |
103 |
|
102 |
|
104 |
}elsif ( $start && $start eq 'Add a patron category' ){ |
|
|
105 |
|
106 |
#Select all the patron category records in the categories database table and store them in the newly declared variable $categories |
107 |
my $categories = Koha::Patron::Categories->search(); |
108 |
$template->param( |
109 |
categories => $categories, |
110 |
); #Hand the variable categories back to the template |
111 |
|
112 |
}elsif ( $start && $start eq 'Add an item type' ){ |
113 |
my $itemtypes = Koha::ItemTypes->search(); |
114 |
$template->param( |
115 |
itemtypes => $itemtypes, |
116 |
);#Hand the variable itemtypes back to the template |
117 |
|
118 |
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 |
103 |
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 |
119 |
}elsif ( $step && $step == 1 ) { |
104 |
}elsif ( $step && $step == 1 ) { |
120 |
my $createlibrary = $query->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary variable |
105 |
my $createlibrary = $query->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary variable |
Lines 157-162
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
157 |
my $createcat = $query->param('createcat'); #Store the inputted category code and name in $createcat |
142 |
my $createcat = $query->param('createcat'); #Store the inputted category code and name in $createcat |
158 |
$template->param('createcat'=>$createcat); |
143 |
$template->param('createcat'=>$createcat); |
159 |
|
144 |
|
|
|
145 |
#Select all the patron category records in the categories database table and give them to the template |
146 |
my $categories = Koha::Patron::Categories->search(); |
147 |
$template->param( |
148 |
categories => $categories, |
149 |
); |
150 |
|
160 |
#Initialising values |
151 |
#Initialising values |
161 |
my $searchfield = $input->param('description') // q||; |
152 |
my $searchfield = $input->param('description') // q||; |
162 |
my $categorycode = $input->param('categorycode'); |
153 |
my $categorycode = $input->param('categorycode'); |
Lines 195-201
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
195 |
dateonly => 1, |
186 |
dateonly => 1, |
196 |
} |
187 |
} |
197 |
); |
188 |
); |
198 |
} |
189 |
} |
199 |
|
190 |
|
200 |
#Adds a new patron category to the database |
191 |
#Adds a new patron category to the database |
201 |
$category = Koha::Patron::Category->new({ |
192 |
$category = Koha::Patron::Category->new({ |
Lines 275-294
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
275 |
:() |
266 |
:() |
276 |
} |
267 |
} |
277 |
|
268 |
|
278 |
# unless(Check_Userid($userid, $borrowernumber)){ |
|
|
279 |
# push @errors, "ERROR_login_exist"; |
280 |
# } |
281 |
push @errors, "ERROR_password_mismatch" if $firstpassword ne $secondpassword; |
269 |
push @errors, "ERROR_password_mismatch" if $firstpassword ne $secondpassword; |
282 |
push @errors, "ERROR_short_password" if ($firstpassword && $minpw && $firstpassword ne '****' && (length($firstpassword) < $minpw)); |
270 |
push @errors, "ERROR_short_password" if ($firstpassword && $minpw && $firstpassword ne '****' && (length($firstpassword) < $minpw)); |
283 |
# |
271 |
|
|
|
272 |
|
284 |
#Passing errors to template |
273 |
#Passing errors to template |
285 |
$nok = $nok || scalar(@errors); |
274 |
$nok = $nok || scalar(@errors); |
286 |
|
275 |
|
287 |
if($nok){ |
276 |
if($nok){ |
288 |
|
277 |
|
289 |
foreach my $error (@errors){ |
278 |
foreach my $error (@errors){ |
290 |
if ($error eq 'ERROR_password_mismatch'){ |
279 |
if ($error eq 'ERROR_password_mismatch'){ |
291 |
$template->param(errorpasswordmismatch => 1); |
280 |
$template->param(errorpasswordmismatch => 1); |
292 |
} |
281 |
} |
293 |
if ($error eq 'ERROR_login_exist'){ |
282 |
if ($error eq 'ERROR_login_exist'){ |
294 |
$template->param(errorloginexists =>1); |
283 |
$template->param(errorloginexists =>1); |
Lines 368-383
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
368 |
$sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?"); |
357 |
$sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?"); |
369 |
$sth->execute($module_flags, $borrowernumber); |
358 |
$sth->execute($module_flags, $borrowernumber); |
370 |
|
359 |
|
371 |
#Error handling checking if the patron was created successfully |
360 |
#Error handling checking if the patron was created successfully |
372 |
if(!$borrowernumber){ |
361 |
if(!$borrowernumber){ |
373 |
push @messages, {type=> 'error', code => 'error_on_insert'}; |
362 |
push @messages, {type=> 'error', code => 'error_on_insert'}; |
374 |
}else{ |
363 |
}else{ |
375 |
push @messages, {type=> 'message', code => 'success_on_insert'}; |
364 |
push @messages, {type=> 'message', code => 'success_on_insert'}; |
376 |
} |
365 |
} |
377 |
} |
366 |
} |
378 |
} |
367 |
} |
379 |
} |
368 |
} |
380 |
}elsif ( $step && $step == 4){ |
369 |
}elsif ( $step && $step == 4){ |
381 |
my $createitemtype = $input->param('createitemtype'); |
370 |
my $createitemtype = $input->param('createitemtype'); |
382 |
$template->param('createitemtype'=> $createitemtype ); |
371 |
$template->param('createitemtype'=> $createitemtype ); |
383 |
|
372 |
|
Lines 554-561
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
554 |
} else { |
543 |
} else { |
555 |
$sth_insert->execute($branch, $onshelfholds); |
544 |
$sth_insert->execute($branch, $onshelfholds); |
556 |
} |
545 |
} |
557 |
} |
546 |
} |
558 |
#End new code |
|
|
559 |
|
547 |
|
560 |
my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br }); |
548 |
my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br }); |
561 |
if($issuingrule){ |
549 |
if($issuingrule){ |
Lines 566-582
if ( $start && $start eq 'Start setting up my Koha' ){
Link Here
|
566 |
Koha::IssuingRule->new()->set($params)->store(); |
554 |
Koha::IssuingRule->new()->set($params)->store(); |
567 |
} |
555 |
} |
568 |
} |
556 |
} |
569 |
|
|
|
570 |
my @messages; |
571 |
|
572 |
my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br }); |
573 |
if($issuingrule){ |
574 |
$issuingrule->set($params)->store(); |
575 |
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. |
576 |
}else{ |
577 |
Koha::IssuingRule->new()->set($params)->store(); |
578 |
} |
579 |
} |
580 |
} |
557 |
} |
581 |
|
558 |
|
582 |
output_html_with_http_headers $input, $cookie, $template->output; |
559 |
output_html_with_http_headers $input, $cookie, $template->output; |