From 8560d873c2a96118e1bff0f6a8ae9ee69f27c522 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 19 Dec 2016 20:34:49 +0000 Subject: [PATCH] Bug 17855 - Similar to the previous patch Have fixed the incorrect insertion of patron into the database Test plan: 1. Go through the web installer and onboarding tool as outlined here: https://koha-community.org/manual/installation/html/ 2. Check the database to see that the library, patron category, patron, and item type are now being inserted successfully. bug 17855 - Similar to the previous patch, except perl code to prevent card number duplication is in the process of beign added to step 3 in the onboarding.pl script. Same test plan as previous patch Bug 17855 - Similar to the previous patch. Library, patron category, patron (with superlibrarian permissions) and item type are all being inserted from the onboarding.pl script into the database. Removed the error that was being displayed after the first of the two create circulation rule screens. Test plan 1. Run through the web installer and onboarding tool as outlined in: https://koha-community.org/manual/installation/html/ 2. Notice there is no error after the first of the two create circulation rule screens. 3. Check the database and you should see the library, patron category, patron, and item type have been inserted. Bug 17855 - Refined text inputs to numerical inputs in onboarding tool. Set minimum card number allowed to 1 for creating a patron screen. In addition to displaying patron category descriptions instead of codes in the dropdown boxes of the aforementioned screen. Implemented months and date check in the create patron category screen. Bug 17855 - Similar to the previous patch except for additional perl code for step 5 (create circulation rule) in the onboarding.pl script Months or dates check implemented in the create patron category screen 1 Changed patron category codes to descriptions in create a new patron Trying to fix default_privacy error Updated text input fields to transform text to capitalize or upper case as appropriate. Changed input fields to number rather than text where appropriate, minimum set to 0 Same as previous. Changed minimum to 1 for card number Working insertion of the item types with working dropdown boxes in the circulation rules screen Changed text to number input type Error no longer showing after the first create circulation rule screen. The patron is also being inserted to the database correctly with the superlibrarian privilages. Working on preventing card number duplication fixed minor error where i was incorrectly inserted --- C4/Members.pm | 2 +- installer/onboarding.pl | 96 +++++++-------- .../intranet-tmpl/prog/en/includes/calendar.inc | 2 +- .../prog/en/includes/installer-doc-head-close.inc | 15 +++ .../prog/en/modules/onboarding/onboardingstep1.tt | 4 +- .../prog/en/modules/onboarding/onboardingstep2.tt | 134 +++++++++++++-------- .../prog/en/modules/onboarding/onboardingstep3.tt | 21 +--- .../prog/en/modules/onboarding/onboardingstep4.tt | 6 +- .../prog/en/modules/onboarding/onboardingstep5.tt | 12 +- 9 files changed, 159 insertions(+), 133 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index dfe4cbd..a11cdb2 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -498,7 +498,7 @@ sub AddMember { } my $patron_category = $schema->resultset('Category')->find( $data{'categorycode'} ); - $data{'privacy'} = + $data{'privacy'} = $patron_category->default_privacy() eq 'default' ? 1 : $patron_category->default_privacy() eq 'never' ? 2 : $patron_category->default_privacy() eq 'forever' ? 0 diff --git a/installer/onboarding.pl b/installer/onboarding.pl index bea4e65..d5574d7 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -184,7 +184,6 @@ if ( $start && $start eq 'Start setting up my Koha' ){ debug => 1, } ); - #Once the user submits the page, this code validates the input and adds it #to the database as a new patron category @@ -233,7 +232,6 @@ if ( $start && $start eq 'Start setting up my Koha' ){ #Create a patron }elsif ( $step && $step == 3 ){ - my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); $template->param(libraries => $libraries, group_types => [ @@ -252,11 +250,11 @@ if ( $start && $start eq 'Start setting up my Koha' ){ categories => $categories, ); - my $input = new CGI; my $op = $input->param('op') // 'list'; - my @messages; + my @messages; + my @errors; my ($template, $loggedinuser, $cookie)= get_template_and_user({ template_name => "/onboarding/onboardingstep3.tt", @@ -267,16 +265,8 @@ if ( $start && $start eq 'Start setting up my Koha' ){ debug => 1, }); - if($op eq 'add_form'){ - my $member; - $template->param( - member => $member, - ); - } - - elsif($op eq 'add_validate'){ - - my %newdata; + if($op eq 'add_validate'){ + my %newdata; #Store the template form values in the newdata hash $newdata{borrowernumber} = $input->param('borrowernumber'); @@ -289,14 +279,26 @@ if ( $start && $start eq 'Start setting up my Koha' ){ $newdata{password} = $input->param('password'); $newdata{password2} = $input->param('password2'); $newdata{dateexpiry} = '12/10/2016'; + $newdata{privacy} = "default"; + + if(my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ + push @errors, $error_code == 1 + ? 'ERROR_cardnumber_already_exists' + :$error_code == 2 + ? 'ERROR_cardnumber_length' + :() + } + + #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); + +#Create a hash named member2 and fillit with the borrowernumber of the borrower that has just been created my %member2; $member2{'borrowernumber'}=$borrowernumber; my $flag = $input->param('flag'); - if ($input->param('newflags')) { my $dbh=C4::Context->dbh(); my @perms = $input->multi_param('flag'); @@ -312,27 +314,28 @@ if ( $start && $start eq 'Start setting up my Koha' ){ } - # construct flags - my $module_flags = 0; - my $sth=$dbh->prepare("SELECT bit,flag FROM userflags ORDER BY bit"); - $sth->execute(); - while (my ($bit, $flag) = $sth->fetchrow_array) { - if (exists $all_module_perms{$flag}) { - $module_flags += 2**$bit; - } - } + # construct flags + my $module_flags = 0; + my $sth=$dbh->prepare("SELECT bit,flag FROM userflags ORDER BY bit"); + $sth->execute(); + while (my ($bit, $flag) = $sth->fetchrow_array) { + if (exists $all_module_perms{$flag}) { + $module_flags += 2**$bit; + } + } - $sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?"); - $sth->execute($module_flags, $borrowernumber); + $sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?"); + $sth->execute($module_flags, $borrowernumber); -#Error handling checking if the patron was created successfully - if(!$borrowernumber){ - push @messages, {type=> 'error', code => 'error_on_insert'}; - }else{ - push @messages, {type=> 'message', code => 'success_on_insert'}; - } - } + #Error handling checking if the patron was created successfully + if(!$borrowernumber){ + push @messages, {type=> 'error', code => 'error_on_insert'}; + }else{ + push @messages, {type=> 'message', code => 'success_on_insert'}; + } + } + } }elsif ( $step && $step == 4){ my $createitemtype = $input->param('createitemtype'); $template->param('createitemtype'=> $createitemtype ); @@ -360,14 +363,14 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my $description = $input->param('description'); #store the input from the form - only 2 fields - my $itemtype= Koha::ItemType->new( + my $thisitemtype= Koha::ItemType->new( { itemtype => $itemtype_code, description => $description, } ); - eval{ $itemtype->store; }; + eval{ $thisitemtype->store; }; #Error messages - if($itemtype){ + if($thisitemtype){ $message = 'success_on_insert'; }else{ $message = 'error_on_insert'; @@ -375,8 +378,10 @@ if ( $start && $start eq 'Start setting up my Koha' ){ $template->param('message' => $message); } - }elsif ( $step && $step == 5){ + my $test="a"; + warn $test; + #Fetching all the existing categories to display in a drop down box my $categories; $categories= Koha::Patron::Categories->search(); @@ -403,14 +408,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my $type = $input->param('type'); my $branch = $input->param('branch'); - - - if($op eq 'add_form'){ - - - - } - elsif($op eq 'add_validate'){ + if($op eq 'add_validate'){ my $bor = $input->param('categorycode'); my $itemtype = $input->param('itemtype'); my $maxissueqty = $input->param('maxissueqty'); @@ -435,14 +433,10 @@ if ( $start && $start eq 'Start setting up my Koha' ){ $issuingrule->set($params)->store(); }else{ Koha::IssuingRule->new()->set($params)->store(); - } + } } + } - my $createcirculationrule = $query->param('createcirculationrule'); - $template->param('createcirculationrule'=>$createcirculationrule); -} - -} output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index f6d9e9b..a4bbe62 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -6,7 +6,7 @@ var debug = "[% debug %]"; var dformat = "[% dateformat %]"; var sentmsg = 0; if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");} -var MSG_PLEASE_ENTER_A_VALID_DATE = _("Please enter a valid date (should match %s)."); +var MSG_PLEASE_ENTER_A_VALID_DATE = (_("Please enter a valid date (should match %s).")); function is_valid_date(date) { // An empty string is considered as a valid date for convenient reasons. diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/installer-doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/installer-doc-head-close.inc index a4b435c..60d0e66 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/installer-doc-head-close.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/installer-doc-head-close.inc @@ -1,5 +1,9 @@ + + + + + + + + + + + + + + + + - - @@ -42,7 +103,6 @@ [% ELSIF op == "add_validate" %] [% IF message != "error_on_insert" %]
- Message is [%message%]

New patron category

@@ -67,21 +127,21 @@ [% ELSE %] -

Create a new Patron Category

- -
+

Create a new Patron Category

+ +
  1. - + Required
  2. - + Required
  3. @@ -101,41 +161,11 @@
  4. Required
  5. @@ -174,11 +204,11 @@
    1. - months + months
    2. - +
@@ -187,9 +217,7 @@ [% END %] - - - +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt index e33b5bc..83667cb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt @@ -54,12 +54,12 @@
  • - + Required
  • - + Required
  • @@ -68,7 +68,7 @@
    1. - + Required
    2. @@ -87,7 +87,7 @@ Required @@ -124,15 +124,4 @@

    -[% END %] - - - - - - - - - - - +[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt index 380488f..73400ff 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt @@ -67,13 +67,13 @@
    1. - - + + Required
    2. - + Required
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt index 5d78334..f2a7ac8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt @@ -57,9 +57,9 @@
  • Required @@ -77,13 +77,13 @@
  • - + Required
  • - + Required
  • @@ -109,13 +109,13 @@
  • - + Required
  • - + Required
  • -- 2.1.4