From 8149fe7a68d64daf32da7f6a0fea7f4315e0afd0 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Fri, 27 Jan 2017 18:17:41 +0000 Subject: [PATCH] Bug 17855 - Implemented a retrieval of patron category enrolmentdate/enrolementdateperiod to set an appropriate dateexpiry for patron accounts created with the onboarding tool. Set address and city variables to "" in onboarding.pl Fixed the creation/filling of the $firstpassword, $secondpassword and $op variables in the onboarding.pl so they don't cause uninitialised variable errors. --- installer/onboarding.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/installer/onboarding.pl b/installer/onboarding.pl index d7c2f75..1239ac8 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -45,6 +45,7 @@ use Koha::LibraryCategories; use Koha::Database; use Koha::DateUtils; use Koha::Patron::Categories; +use Koha::Patron::Category; use Koha::Patron::HouseboundRole; use Koha::Patron::HouseboundRoles; use Koha::Token; @@ -91,7 +92,7 @@ my $dbh = DBI->connect( ); #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. -my $op = $input->param('op'); +my $op = $input->param('op') || ""; $template->param( 'op' => $op ); if ( $op && $op eq 'finish' ) @@ -241,8 +242,8 @@ elsif ( $step && $step == 2 ) { #Create a patron } elsif ( $step && $step == 3 ) { - my $firstpassword = $input->param('password'); - my $secondpassword = $input->param('password2'); + my $firstpassword = $input->param('password') || ""; + my $secondpassword = $input->param('password2') || ""; #Find all patron records in the database and hand them to the template @@ -280,6 +281,9 @@ elsif ( $step && $step == 3 ) { my $categories = Koha::Patron::Categories->search(); $template->param( 'categories' => $categories, ); + + + #Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry my $exisiting_cardnumber = my $sth_search = $dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); @@ -378,8 +382,13 @@ elsif ( $step && $step == 3 ) { $newdata{userid} = $input->param('userid'); $newdata{password} = $input->param('password'); $newdata{password2} = $input->param('password2'); - $newdata{dateexpiry} = '12/10/2016'; $newdata{privacy} = "default"; + $newdata{address} = ""; + $newdata{city} = ""; + +#Determine the dateexpiry of the patron based on the patron category it is created from + my $patron_category = Koha::Patron::Categories->find( $newdata{categorycode} ); + $newdata{dateexpiry} = $patron_category->get_expiry_date( $newdata{dateenrolled} ); #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 my $borrowernumber = &AddMember(%newdata); -- 2.1.4