Lines 63-69
my ( $template, $loggedinuser, $cookie ) =
Link Here
|
63 |
C4::InstallAuth::get_template_and_user( |
63 |
C4::InstallAuth::get_template_and_user( |
64 |
{ |
64 |
{ |
65 |
template_name => "/onboarding/onboardingstep" |
65 |
template_name => "/onboarding/onboardingstep" |
66 |
. ( $step ? $step : 0 ) . ".tt", |
66 |
. ( $step ? $step : 1 ) . ".tt", |
67 |
query => $input, |
67 |
query => $input, |
68 |
type => "intranet", |
68 |
type => "intranet", |
69 |
authnotrequired => 0, |
69 |
authnotrequired => 0, |
Lines 93-152
my $dbh = DBI->connect(
Link Here
|
93 |
#Store the value of the template input name='op' in the variable $op so we can check if the user has pressed the button with the name="op" and value="finish" meaning the user has finished the onboarding tool. |
93 |
#Store the value of the template input name='op' in the variable $op so we can check if the user has pressed the button with the name="op" and value="finish" meaning the user has finished the onboarding tool. |
94 |
my $op = $input->param('op'); |
94 |
my $op = $input->param('op'); |
95 |
$template->param( 'op' => $op ); |
95 |
$template->param( 'op' => $op ); |
|
|
96 |
|
96 |
if ( $op && $op eq 'finish' ) |
97 |
if ( $op && $op eq 'finish' ) |
97 |
{ #If the value of $op equals 'finish' then redirect user to /cgi-bin/koha/mainpage.pl |
98 |
{ #If the value of $op equals 'finish' then redirect user to /cgi-bin/koha/mainpage.pl |
98 |
print $input->redirect("/cgi-bin/koha/mainpage.pl"); |
99 |
print $input->redirect("/cgi-bin/koha/mainpage.pl"); |
99 |
exit; |
100 |
exit; |
100 |
} |
101 |
} |
101 |
|
102 |
|
102 |
#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 |
103 |
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
103 |
my $start = $input->param('start'); |
104 |
$template->param( |
104 |
$template->param( 'start' => $start ); |
105 |
libraries => $libraries, |
|
|
106 |
group_types => [ |
107 |
{ |
108 |
categorytype => 'searchdomain', |
109 |
categories => [ |
110 |
Koha::LibraryCategories->search( |
111 |
{ categorytype => 'searchdomain' } |
112 |
) |
113 |
], |
114 |
}, |
115 |
{ |
116 |
categorytype => 'properties', |
117 |
categories => [ |
118 |
Koha::LibraryCategories->search( |
119 |
{ categorytype => 'properties' } |
120 |
) |
121 |
], |
122 |
}, |
123 |
] |
124 |
); |
105 |
|
125 |
|
106 |
if ( $start && $start eq 'Start setting up my Koha' ) { |
|
|
107 |
my $libraries = |
108 |
Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
109 |
$template->param( |
110 |
libraries => $libraries, |
111 |
group_types => [ |
112 |
{ |
113 |
categorytype => 'searchdomain', |
114 |
categories => [ |
115 |
Koha::LibraryCategories->search( |
116 |
{ categorytype => 'searchdomain' } |
117 |
) |
118 |
], |
119 |
}, |
120 |
{ |
121 |
categorytype => 'properties', |
122 |
categories => [ |
123 |
Koha::LibraryCategories->search( |
124 |
{ categorytype => 'properties' } |
125 |
) |
126 |
], |
127 |
}, |
128 |
] |
129 |
); |
130 |
} |
131 |
elsif ( $start && $start eq 'Minimal patron category setup' ) { |
132 |
|
126 |
|
133 |
#Select all the patron category records in the categories database table and give them to the template |
127 |
#Select all the patron category records in the categories database table and give them to the template |
134 |
my $categories = Koha::Patron::Categories->search(); |
128 |
my $categories = Koha::Patron::Categories->search(); |
135 |
$template->param( categories => $categories, ); |
129 |
$template->param( 'categories' => $categories, ); |
136 |
|
130 |
|
137 |
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 |
131 |
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 |
138 |
} |
|
|
139 |
elsif ( $start && $start eq 'Minimal item type setup' ) { |
140 |
|
141 |
my $itemtypes = Koha::ItemTypes->search(); |
132 |
my $itemtypes = Koha::ItemTypes->search(); |
142 |
$template->param( itemtypes => $itemtypes, ); |
133 |
$template->param( 'itemtypes' => $itemtypes, ); |
143 |
} |
|
|
144 |
elsif ( $step && $step == 1 ) { |
145 |
my $createlibrary = $input->param('createlibrary') |
146 |
; #Store the inputted library branch code and name in $createlibrary variable |
147 |
$template->param( 'createlibrary' => $createlibrary ) |
148 |
; # Hand the library values back to the template in the createlibrary variable |
149 |
|
134 |
|
|
|
135 |
if ( $step && $step == 1 ) { |
150 |
#store inputted parameters in variables |
136 |
#store inputted parameters in variables |
151 |
my $branchcode = $input->param('branchcode'); |
137 |
my $branchcode = $input->param('branchcode'); |
152 |
$branchcode = uc($branchcode); |
138 |
$branchcode = uc($branchcode); |
Lines 179-266
elsif ( $step && $step == 1 ) {
Link Here
|
179 |
else { |
165 |
else { |
180 |
$message = 'error_on_insert'; |
166 |
$message = 'error_on_insert'; |
181 |
} |
167 |
} |
|
|
168 |
warn $message; |
182 |
$template->param( 'message' => $message ); |
169 |
$template->param( 'message' => $message ); |
183 |
|
170 |
|
184 |
#Check if the $step variable equals 2 i.e. the user has clicked to create a patron category in the create patron category screen 1 |
171 |
#Check if the $step variable equals 2 i.e. the user has clicked to create a patron category in the create patron category screen 1 |
185 |
} |
172 |
} |
186 |
elsif ( $step && $step == 2 ) { |
173 |
elsif ( $step && $step == 2 ) { |
187 |
my $createcat = $input->param('createcat') |
174 |
if ($op eq "add_validate_category"){ |
188 |
; #Store the inputted category code and name in $createcat |
175 |
#Initialising values |
189 |
$template->param( 'createcat' => $createcat ); |
176 |
my $searchfield = $input->param('description') // q||; |
|
|
177 |
my $categorycode = $input->param('categorycode'); |
178 |
my $op = $input->param('op') // 'list'; |
179 |
my $message; |
180 |
my $category; |
181 |
$template->param( 'categorycode' => $categorycode ); |
190 |
|
182 |
|
191 |
#Initialising values |
183 |
my ( $template, $loggedinuser, $cookie ) = |
192 |
my $searchfield = $input->param('description') // q||; |
184 |
C4::InstallAuth::get_template_and_user( |
193 |
my $categorycode = $input->param('categorycode'); |
185 |
{ |
194 |
my $op = $input->param('op') // 'list'; |
186 |
template_name => "/onboarding/onboardingstep2.tt", |
195 |
my $message; |
187 |
query => $input, |
196 |
my $category; |
188 |
type => "intranet", |
197 |
$template->param( 'categorycode' => $categorycode ); |
189 |
authnotrequired => 0, |
|
|
190 |
flagsrequired => |
191 |
{ parameters => 'parameters_remaining_permissions' }, |
192 |
debug => 1, |
193 |
} |
194 |
); |
198 |
|
195 |
|
199 |
my ( $template, $loggedinuser, $cookie ) = |
196 |
#Once the user submits the page, this code validates the input and adds it |
200 |
C4::InstallAuth::get_template_and_user( |
197 |
#to the database as a new patron category |
201 |
{ |
198 |
$categorycode = $input->param('categorycode'); |
202 |
template_name => "/onboarding/onboardingstep2.tt", |
199 |
my $description = $input->param('description'); |
203 |
query => $input, |
200 |
my $overduenoticerequired = $input->param('overduenoticerequired'); |
204 |
type => "intranet", |
201 |
my $category_type = $input->param('category_type'); |
205 |
authnotrequired => 0, |
202 |
my $default_privacy = $input->param('default_privacy'); |
206 |
flagsrequired => |
203 |
my $enrolmentperiod = $input->param('enrolmentperiod'); |
207 |
{ parameters => 'parameters_remaining_permissions' }, |
204 |
my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; |
208 |
debug => 1, |
205 |
|
|
|
206 |
#Converts the string into a date format |
207 |
if ($enrolmentperioddate) { |
208 |
$enrolmentperioddate = output_pref( |
209 |
{ |
210 |
dt => dt_from_string($enrolmentperioddate), |
211 |
dateformat => 'iso', |
212 |
dateonly => 1, |
213 |
} |
214 |
); |
209 |
} |
215 |
} |
210 |
); |
|
|
211 |
|
216 |
|
212 |
#Once the user submits the page, this code validates the input and adds it |
217 |
#Adds a new patron category to the database |
213 |
#to the database as a new patron category |
218 |
$category = Koha::Patron::Category->new( |
214 |
$categorycode = $input->param('categorycode'); |
|
|
215 |
my $description = $input->param('description'); |
216 |
my $overduenoticerequired = $input->param('overduenoticerequired'); |
217 |
my $category_type = $input->param('category_type'); |
218 |
my $default_privacy = $input->param('default_privacy'); |
219 |
my $enrolmentperiod = $input->param('enrolmentperiod'); |
220 |
my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; |
221 |
|
222 |
#Converts the string into a date format |
223 |
if ($enrolmentperioddate) { |
224 |
$enrolmentperioddate = output_pref( |
225 |
{ |
219 |
{ |
226 |
dt => dt_from_string($enrolmentperioddate), |
220 |
categorycode => $categorycode, |
227 |
dateformat => 'iso', |
221 |
description => $description, |
228 |
dateonly => 1, |
222 |
overduenoticerequired => $overduenoticerequired, |
|
|
223 |
category_type => $category_type, |
224 |
default_privacy => $default_privacy, |
225 |
enrolmentperiod => $enrolmentperiod, |
226 |
enrolmentperioddate => $enrolmentperioddate, |
229 |
} |
227 |
} |
230 |
); |
228 |
); |
231 |
} |
|
|
232 |
|
229 |
|
233 |
#Adds a new patron category to the database |
230 |
eval { $category->store; }; |
234 |
$category = Koha::Patron::Category->new( |
|
|
235 |
{ |
236 |
categorycode => $categorycode, |
237 |
description => $description, |
238 |
overduenoticerequired => $overduenoticerequired, |
239 |
category_type => $category_type, |
240 |
default_privacy => $default_privacy, |
241 |
enrolmentperiod => $enrolmentperiod, |
242 |
enrolmentperioddate => $enrolmentperioddate, |
243 |
} |
244 |
); |
245 |
|
231 |
|
246 |
eval { $category->store; }; |
232 |
#Error messages |
|
|
233 |
if ($category) { |
234 |
$message = 'success_on_insert'; |
235 |
} |
236 |
else { |
237 |
$message = 'error_on_insert'; |
238 |
} |
247 |
|
239 |
|
248 |
#Error messages |
240 |
$template->param( 'message' => $message ); |
249 |
if ($category) { |
|
|
250 |
$message = 'success_on_insert'; |
251 |
} |
252 |
else { |
253 |
$message = 'error_on_insert'; |
254 |
} |
241 |
} |
255 |
|
|
|
256 |
$template->param( 'message' => $message ); |
257 |
|
258 |
#Create a patron |
242 |
#Create a patron |
259 |
} |
243 |
} |
260 |
elsif ( $step && $step == 3 ) { |
244 |
elsif ( $step && $step == 3 ) { |
261 |
my $firstpassword = $input->param('password'); |
245 |
my $firstpassword = $input->param('password'); |
262 |
my $secondpassword = $input->param('password2'); |
246 |
my $secondpassword = $input->param('password2'); |
263 |
|
247 |
|
|
|
248 |
|
249 |
#Find all patron records in the database and hand them to the template |
250 |
my %currentpatrons = Koha::Patrons->search(); |
251 |
my $currentpatrons = values %currentpatrons; |
252 |
warn $currentpatrons; |
253 |
$template->param( 'patrons' =>$currentpatrons); |
254 |
|
255 |
|
264 |
#Find all library records in the database and hand them to the template to display in the library dropdown box |
256 |
#Find all library records in the database and hand them to the template to display in the library dropdown box |
265 |
my $libraries = |
257 |
my $libraries = |
266 |
Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
258 |
Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); |
Lines 288-298
elsif ( $step && $step == 3 ) {
Link Here
|
288 |
|
280 |
|
289 |
#Find all patron categories in the database and hand them to the template to display in the patron category dropdown box |
281 |
#Find all patron categories in the database and hand them to the template to display in the patron category dropdown box |
290 |
my $categories = Koha::Patron::Categories->search(); |
282 |
my $categories = Koha::Patron::Categories->search(); |
291 |
$template->param( categories => $categories, ); |
283 |
$template->param( 'categories' => $categories, ); |
292 |
|
284 |
|
293 |
#Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry |
285 |
#Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry |
294 |
my $exisiting_cardnumber = my $sth_search = |
286 |
my $exisiting_cardnumber = my $sth_search = |
295 |
$dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); |
287 |
$dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); |
|
|
288 |
warn $exisiting_cardnumber; |
296 |
my $new_cardnumber = $exisiting_cardnumber + 1; |
289 |
my $new_cardnumber = $exisiting_cardnumber + 1; |
297 |
warn $new_cardnumber; |
290 |
warn $new_cardnumber; |
298 |
$template->param( "newcardnumber" => $new_cardnumber ); |
291 |
$template->param( "newcardnumber" => $new_cardnumber ); |
Lines 446-454
elsif ( $step && $step == 3 ) {
Link Here
|
446 |
} |
439 |
} |
447 |
} |
440 |
} |
448 |
elsif ( $step && $step == 4 ) { |
441 |
elsif ( $step && $step == 4 ) { |
449 |
my $createitemtype = $input->param('createitemtype'); |
|
|
450 |
$template->param( 'createitemtype' => $createitemtype ); |
451 |
|
452 |
my ( $template, $borrowernumber, $cookie ) = |
442 |
my ( $template, $borrowernumber, $cookie ) = |
453 |
C4::InstallAuth::get_template_and_user( |
443 |
C4::InstallAuth::get_template_and_user( |
454 |
{ |
444 |
{ |
Lines 460-470
elsif ( $step && $step == 4 ) {
Link Here
|
460 |
{ parameters => 'parameters_remaining_permissions' }, |
450 |
{ parameters => 'parameters_remaining_permissions' }, |
461 |
debug => 1, |
451 |
debug => 1, |
462 |
} |
452 |
} |
463 |
); |
453 |
); |
464 |
|
454 |
if ($op eq "add_validate"){ |
465 |
if ( $op eq 'add_validate' ) { |
|
|
466 |
my $description = $input->param('description'); |
455 |
my $description = $input->param('description'); |
467 |
my $itemtype_code = $input->param('itemtype'); |
456 |
my $itemtype_code = $input->param('itemtype'); |
|
|
457 |
warn $description; |
468 |
$itemtype_code = uc($itemtype_code); |
458 |
$itemtype_code = uc($itemtype_code); |
469 |
|
459 |
|
470 |
#Create a new itemtype object using the user inputted itemtype and description |
460 |
#Create a new itemtype object using the user inputted itemtype and description |
Lines 672-679
elsif ( $step && $step == 5 ) {
Link Here
|
672 |
} |
662 |
} |
673 |
} |
663 |
} |
674 |
|
664 |
|
675 |
#End new code |
|
|
676 |
|
677 |
my $issuingrule = Koha::IssuingRules->find( |
665 |
my $issuingrule = Koha::IssuingRules->find( |
678 |
{ categorycode => $bor, itemtype => $itemtype, branchcode => $br } |
666 |
{ categorycode => $bor, itemtype => $itemtype, branchcode => $br } |
679 |
); |
667 |
); |