Lines 2-8
Link Here
|
2 |
|
2 |
|
3 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
4 |
# |
4 |
# |
5 |
# Copyright (C) YEAR YOURNAME-OR-YOUREMPLOYER |
5 |
# Copyright (C) YEAR Alex Buckley CatalystIT |
6 |
# |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it |
7 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
# under the terms of the GNU General Public License as published by |
8 |
# under the terms of the GNU General Public License as published by |
Lines 22-56
use Modern::Perl;
Link Here
|
22 |
use diagnostics; |
22 |
use diagnostics; |
23 |
use C4::InstallAuth; |
23 |
use C4::InstallAuth; |
24 |
use CGI qw ( -utf8 ); |
24 |
use CGI qw ( -utf8 ); |
25 |
use List::MoreUtils qw/uniq/; |
|
|
26 |
use Digest::MD5 qw(md5_base64); |
25 |
use Digest::MD5 qw(md5_base64); |
27 |
use Encode qw( encode ); |
26 |
use Encode qw( encode ); |
28 |
use C4::Koha; |
27 |
use C4::Koha; |
29 |
use C4::Context; |
|
|
30 |
use C4::Output; |
28 |
use C4::Output; |
31 |
use C4::Form::MessagingPreferences; |
|
|
32 |
use C4::Members; |
29 |
use C4::Members; |
33 |
use C4::Members::Attributes; |
30 |
use C4::Members::Attributes; |
34 |
use C4::Members::AttributeTypes; |
31 |
use C4::Members::AttributeTypes; |
35 |
use C4::Log; |
32 |
use C4::Log; |
36 |
use C4::Letters; |
|
|
37 |
use C4::Form::MessagingPreferences; |
38 |
use Koha::AuthorisedValues; |
33 |
use Koha::AuthorisedValues; |
39 |
use Koha::Patron::Debarments; |
34 |
use Koha::Patron::Debarments; |
40 |
use Koha::Cities; |
|
|
41 |
use Koha::Patrons; |
35 |
use Koha::Patrons; |
42 |
use Koha::Items; |
36 |
use Koha::Items; |
43 |
use Koha::Libraries; |
37 |
use Koha::Libraries; |
44 |
use Koha::LibraryCategories; |
|
|
45 |
use Koha::Database; |
38 |
use Koha::Database; |
46 |
use Koha::DateUtils; |
39 |
use Koha::DateUtils; |
47 |
use Koha::Patron::Categories; |
40 |
use Koha::Patron::Categories; |
48 |
use Koha::Patron::Category; |
|
|
49 |
use Koha::Patron::HouseboundRole; |
41 |
use Koha::Patron::HouseboundRole; |
50 |
use Koha::Patron::HouseboundRoles; |
42 |
use Koha::Patron::HouseboundRoles; |
51 |
use Koha::Token; |
|
|
52 |
use Email::Valid; |
53 |
use Module::Load; |
54 |
use Koha::ItemTypes; |
43 |
use Koha::ItemTypes; |
55 |
use Koha::IssuingRule; |
44 |
use Koha::IssuingRule; |
56 |
use Koha::IssuingRules; |
45 |
use Koha::IssuingRules; |
Lines 92-100
my $dbh = DBI->connect(
Link Here
|
92 |
); |
81 |
); |
93 |
|
82 |
|
94 |
#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. |
83 |
#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. |
95 |
my $op = $input->param('op') || ""; |
84 |
my $op = $input->param('op'); |
96 |
$template->param( 'op' => $op ); |
85 |
$template->param( 'op' => $op ); |
97 |
|
86 |
|
|
|
87 |
my $schema = Koha::Database->new()->schema(); |
88 |
|
98 |
if ( $op && $op eq 'Finish' ) |
89 |
if ( $op && $op eq 'Finish' ) |
99 |
{ #If the value of $op equals 'finish' then redirect user to /cgi-bin/koha/mainpage.pl |
90 |
{ #If the value of $op equals 'finish' then redirect user to /cgi-bin/koha/mainpage.pl |
100 |
print $input->redirect("/cgi-bin/koha/mainpage.pl"); |
91 |
print $input->redirect("/cgi-bin/koha/mainpage.pl"); |
Lines 129-143
$template->param(
Link Here
|
129 |
my $categories = Koha::Patron::Categories->search(); |
120 |
my $categories = Koha::Patron::Categories->search(); |
130 |
$template->param( 'categories' => $categories, ); |
121 |
$template->param( 'categories' => $categories, ); |
131 |
|
122 |
|
132 |
#Select all the itemtype records in the itemtypes database table and give them to the template |
123 |
#Select all ItemType records in the itemtype table and give them to the template |
133 |
my $itemtypes = Koha::ItemTypes->search(); |
124 |
my $itemtypes = Koha::ItemTypes->search(); |
134 |
$template->param( 'itemtypes' => $itemtypes, ); |
125 |
$template->param( 'itemtypes' => $itemtypes, ); |
135 |
|
126 |
|
|
|
127 |
|
136 |
#Select all the ztarget records in the z3950server table and give them to the template |
128 |
#Select all the ztarget records in the z3950server table and give them to the template |
137 |
my $existingztargets = $schema->Resultset('Z3950server')->count; |
129 |
my $existingztargets = $schema->resultset('Z3950server')->count; |
138 |
$template->param(existingztargets => $existingztargets); |
130 |
$template->param(existingztargets => $existingztargets); |
139 |
|
131 |
|
140 |
|
|
|
141 |
if ( $step && $step == 1 ) { |
132 |
if ( $step && $step == 1 ) { |
142 |
#store inputted parameters in variables |
133 |
#store inputted parameters in variables |
143 |
my $branchcode = $input->param('branchcode'); |
134 |
my $branchcode = $input->param('branchcode'); |
Lines 247-254
elsif ( $step && $step == 2 ) {
Link Here
|
247 |
#Create a patron |
238 |
#Create a patron |
248 |
} |
239 |
} |
249 |
elsif ( $step && $step == 3 ) { |
240 |
elsif ( $step && $step == 3 ) { |
250 |
my $firstpassword = $input->param('password') || ''; |
241 |
my $firstpassword = $input->param('password'); |
251 |
my $secondpassword = $input->param('password2') || ''; |
242 |
my $secondpassword = $input->param('password2'); |
252 |
|
243 |
|
253 |
|
244 |
|
254 |
#Find all patron records in the database and hand them to the template |
245 |
#Find all patron records in the database and hand them to the template |
Lines 286-294
elsif ( $step && $step == 3 ) {
Link Here
|
286 |
my $categories = Koha::Patron::Categories->search(); |
277 |
my $categories = Koha::Patron::Categories->search(); |
287 |
$template->param( 'categories' => $categories, ); |
278 |
$template->param( 'categories' => $categories, ); |
288 |
|
279 |
|
289 |
|
|
|
290 |
|
291 |
|
292 |
#Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry |
280 |
#Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry |
293 |
my $exisiting_cardnumber = my $sth_search = |
281 |
my $exisiting_cardnumber = my $sth_search = |
294 |
$dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); |
282 |
$dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); |
Lines 387-399
elsif ( $step && $step == 3 ) {
Link Here
|
387 |
$newdata{userid} = $input->param('userid'); |
375 |
$newdata{userid} = $input->param('userid'); |
388 |
$newdata{password} = $input->param('password'); |
376 |
$newdata{password} = $input->param('password'); |
389 |
$newdata{password2} = $input->param('password2'); |
377 |
$newdata{password2} = $input->param('password2'); |
|
|
378 |
$newdata{dateexpiry} = '12/10/2016'; |
390 |
$newdata{privacy} = "default"; |
379 |
$newdata{privacy} = "default"; |
391 |
$newdata{address} = ""; |
|
|
392 |
$newdata{city} = ""; |
393 |
|
394 |
#Determine the dateexpiry of the patron based on the patron category it is created from |
395 |
my $patron_category = Koha::Patron::Categories->find( $newdata{categorycode} ); |
396 |
$newdata{dateexpiry} = $patron_category->get_expiry_date( $newdata{dateenrolled} ); |
397 |
|
380 |
|
398 |
#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 |
381 |
#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 |
399 |
my $borrowernumber = &AddMember(%newdata); |
382 |
my $borrowernumber = &AddMember(%newdata); |
Lines 420-439
elsif ( $step && $step == 3 ) {
Link Here
|
420 |
} |
403 |
} |
421 |
|
404 |
|
422 |
# construct flags |
405 |
# construct flags |
423 |
my $module_flags = 0; |
406 |
my @userflags = $schema->resultset('Userflag')->search({}, { |
424 |
my $sth = |
407 |
order_by => { -asc => 'bit'}, |
425 |
$dbh->prepare("SELECT bit,flag FROM userflags ORDER BY bit"); |
408 |
} |
426 |
$sth->execute(); |
409 |
); |
427 |
while ( my ( $bit, $flag ) = $sth->fetchrow_array ) { |
|
|
428 |
if ( exists $all_module_perms{$flag} ) { |
429 |
$module_flags += 2**$bit; |
430 |
} |
431 |
} |
432 |
|
410 |
|
433 |
#Set the superlibrarian permission of the newly created patron to superlibrarian |
411 |
#Setting superlibrarian permissions for new patron |
434 |
$sth = $dbh->prepare( |
412 |
my $flags = Koha::Patrons->find($borrowernumber)->set({flags=>01})->store; |
435 |
"UPDATE borrowers SET flags=? WHERE borrowernumber=?"); |
|
|
436 |
$sth->execute( $module_flags, $borrowernumber ); |
437 |
|
413 |
|
438 |
#Error handling checking if the patron was created successfully |
414 |
#Error handling checking if the patron was created successfully |
439 |
if ( !$borrowernumber ) { |
415 |
if ( !$borrowernumber ) { |
Lines 586-592
elsif ( $step && $step == 5 ) {
Link Here
|
586 |
|
562 |
|
587 |
my @messages; |
563 |
my @messages; |
588 |
|
564 |
|
589 |
#New code from smart-rules.tt starts here. Needs to be added to library |
|
|
590 |
#Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to. |
565 |
#Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to. |
591 |
if ( $branch eq "*" ) { |
566 |
if ( $branch eq "*" ) { |
592 |
my $sth_search = $dbh->prepare( |
567 |
my $sth_search = $dbh->prepare( |
Lines 689-712
elsif ( $step && $step == 5 ) {
Link Here
|
689 |
} |
664 |
} |
690 |
} |
665 |
} |
691 |
elsif ( $step && $step == 6 ){ |
666 |
elsif ( $step && $step == 6 ){ |
692 |
my ( $template, $loggedinuser, $cookie ) = |
667 |
my $service = $input->param('service'); |
693 |
C4::InstallAuth::get_template_and_user( |
668 |
$template->param( service => $service ); |
694 |
{ |
|
|
695 |
template_name => "/onboarding/onboardingstep6.tt", |
696 |
query => $input, |
697 |
type => "intranet", |
698 |
authnotrequired => 0, |
699 |
flagsrequired => { parameters => 'manage_circ_rules' }, |
700 |
debug => 1, |
701 |
} |
702 |
); |
703 |
|
669 |
|
704 |
my $existingztargets = $schema->Resultset('Z3950server')->count; |
670 |
my ( $template, $loggedinuser, $cookie ) = |
705 |
$template->param(existingztargets => $existingztargets); |
671 |
C4::InstallAuth::get_template_and_user( |
706 |
|
672 |
{ |
707 |
my $service = $input->param('service'); |
673 |
template_name => "/onboarding/onboardingstep6.tt", |
708 |
$template->param( service => $service ); |
674 |
query => $input, |
|
|
675 |
type => "intranet", |
676 |
authnotrequired => 0, |
677 |
flagsrequired => { parameters => 'manage_circ_rules' }, |
678 |
debug => 1, |
679 |
} |
680 |
); |
709 |
} |
681 |
} |
710 |
|
682 |
|
711 |
|
|
|
712 |
output_html_with_http_headers $input, $cookie, $template->output; |
683 |
output_html_with_http_headers $input, $cookie, $template->output; |