Bug 17855: Simplify the onboarding tool
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 17 Apr 2017 18:42:35 +0000 (15:42 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 28 Apr 2017 12:36:20 +0000 (08:36 -0400)
This patch should not modify a lot the behaviours of the onboarding
tool.
Its goal is mainly to remove duplicated as well as useless (because
copy/pasted from existing script files) code.

It assumes that the onboarding tool will be done on an empty database
and will skip steps that are not needed. For instance if a library
already exists, the first step will be skipped.

One of the main problem was the lack of feedback messages sent to the
user when something wrong/ok happened.

Explanation on main changes:
1. Use checkauth first, then get_template_and_user
=> As we do not know the template to use, it's better to use checkauth
first to know if the user is logged in, then retrieve the template we
need, depending on the success or the failure of the action
2. Create a @messages variables
Pushing messages to this variable and handling the messages via an
include files (onboarding_messages.inc) simplify error handling. Note
that we could remove this include file if we merge all the
onboardingstepX.tt files altogether
3. Simplify creation of the admnistrator user
This patch removes some unecessary checks done on the user's info
(passwd to short, mandatory fields

Todo (minor): Add style to feedback messages

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
installer/onboarding.pl
koha-tmpl/intranet-tmpl/prog/en/includes/onboarding_messages.inc [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt
koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt
koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt
koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt
koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt

index d24f17c..02d4827 100755 (executable)
@@ -35,133 +35,66 @@ use Koha::IssuingRules;
 
 #Setting variables
 my $input = new CGI;
-my $step  = $input->param('step');
 
 unless ( C4::Context->preference('Version') ) {
     print $input->redirect("/cgi-bin/koha/installer/install.pl");
     exit;
 }
 
-#Getting the appropriate template to display to the user
-my ( $template, $loggedinuser, $cookie ) =
-  C4::InstallAuth::get_template_and_user(
-    {
-        template_name => "/onboarding/onboardingstep"
-          . ( $step ? $step : 1 ) . ".tt",
-        query           => $input,
-        type            => "intranet",
-        authnotrequired => 0,
-        debug           => 1,
-    }
-  );
+my ( $user, $cookie, $sessionID, $flags ) =
+  C4::InstallAuth::checkauth( $input, 0, undef, 'intranet' );
+die "Not logged in"
+  unless $user
+  ; # Should not happen, we should be redirect if the user is not logged in. But do not trust authentication...
 
-#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') || '';
-$template->param( 'op' => $op );
+my $step = $input->param('step') || 1;
+my $op   = $input->param('op')   || '';
+
+my $template_params = {};
+$template_params->{op} = $op;
 
 my $schema = Koha::Database->new()->schema();
 
-if ( $op && $op eq 'finish' )
-{ #If the value of $op equals 'finish' then redirect user to /cgi-bin/koha/mainpage.pl
-    print $input->redirect("/cgi-bin/koha/mainpage.pl");
-    exit;
-}
+my @messages;
 
-my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
-$template->param(
-    libraries   => $libraries,
-    group_types => [
-        {
-            categorytype => 'searchdomain',
-            categories   => [
-                Koha::LibraryCategories->search(
-                    { categorytype => 'searchdomain' }
-                )
-            ],
-        },
-        {
-            categorytype => 'properties',
-            categories   => [
-                Koha::LibraryCategories->search(
-                    { categorytype => 'properties' }
-                )
-            ],
-        },
-    ]
-);
+if ( $step == 1 ) {
 
-#Select all the patron category records in the categories database table and give them to the template
-my $categories = Koha::Patron::Categories->search();
-$template->param( 'categories' => $categories, );
+    if ( $op eq 'add_validate_library' ) {
 
-#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1
-my $itemtypes = Koha::ItemTypes->search();
-$template->param( 'itemtypes' => $itemtypes, );
-
-if ( $step && $step == 1 ) {
-
-    #store inputted parameters in variables
-    my $branchcode = $input->param('branchcode');
-    $branchcode = uc($branchcode);
-    my $categorycode = $input->param('categorycode');
-    my $op = $input->param('op') || 'list';
-    my $message;
-    my $library;
-
-    #Take the text 'branchname' and store it in the @fields array
-    my @fields = qw(
-      branchname
-    );
-
-    $template->param( 'branchcode' => $branchcode );
-    $branchcode =~ s|\s||g
-      ; # Use a regular expression to check the value of the inputted branchcode
-
-#Create a new library object and store the branchcode and @fields array values in this new library object
-    $library = Koha::Library->new(
-        {
-            branchcode => $branchcode,
-            ( map { $_ => scalar $input->param($_) || undef } @fields )
-        }
-    );
+        my $branchcode = $input->param('branchcode');
+        $branchcode = uc($branchcode);
 
-    eval { $library->store; }; #Use the eval{} function to store the library object
-    if ($library) {
-        $message = 'success_on_insert';
-    }
-    else {
-        $message = 'error_on_insert';
+        $branchcode =~ s|\s||g
+          ; # Use a regular expression to check the value of the inputted branchcode
+
+        my $library = Koha::Library->new(
+            {
+                branchcode => $branchcode,
+                branchname => scalar $input->param('branchname'),
+            }
+        );
+
+        eval { $library->store; };
+        unless ($@) {
+            push @messages,
+              { type => 'message', code => 'success_on_insert_library' };
+        }
+        else {
+            push @messages,
+              { type => 'message', code => 'error_on_insert_library' };
+        }
     }
-    $template->param( 'message' => $message );
 
-#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
+    $step++ if Koha::Libraries->count;
 }
-elsif ( $step && $step == 2 ) {
+if ( $step == 2 ) {
     if ( $op eq "add_validate_category" ) {
 
-        #Initialising values
-        my $searchfield  = $input->param('description') // q||;
+        my $searchfield = $input->param('description') // q||;
         my $categorycode = $input->param('categorycode');
-        my $op           = $input->param('op') // 'list';
-        my $message;
         my $category;
-        $template->param( 'categorycode' => $categorycode );
-
-        my ( $template, $loggedinuser, $cookie ) =
-          C4::InstallAuth::get_template_and_user(
-            {
-                template_name   => "/onboarding/onboardingstep2.tt",
-                query           => $input,
-                type            => "intranet",
-                authnotrequired => 0,
-                flagsrequired =>
-                  { parameters => 'parameters_remaining_permissions' },
-                debug => 1,
-            }
-          );
+        $template_params->{categorycode} = $categorycode;
 
-      #Once the user submits the page, this code validates the input and adds it
-      #to the database as a new patron category
         $categorycode = $input->param('categorycode');
         my $description           = $input->param('description');
         my $overduenoticerequired = $input->param('overduenoticerequired');
@@ -196,210 +129,89 @@ elsif ( $step && $step == 2 ) {
 
         eval { $category->store; };
 
-        #Error messages
-        if ($category) {
-            $message = 'success_on_insert';
+        unless ($@) {
+            push @messages,
+              { type => 'message', code => 'success_on_insert_category' };
         }
         else {
-            $message = 'error_on_insert';
+            push @messages,
+              { type => 'message', code => 'error_on_insert_category' };
         }
-
-        $template->param( 'message' => $message );
     }
 
-    #Create a patron
+    $step++ if Koha::Patron::Categories->count;
 }
-elsif ( $step && $step == 3 ) {
-    my $firstpassword  = $input->param('password')  || '';
-    my $secondpassword = $input->param('password2') || '';
-
-    #Find all patron records in the database and hand them to the template
-    my %currentpatrons = Koha::Patrons->search();
-    my $currentpatrons = values %currentpatrons;
-    $template->param( 'patrons' => $currentpatrons );
-
-#Find all patron categories in the database and hand them to the template to display in the patron category dropdown box
-    my $categories = Koha::Patron::Categories->search();
-    $template->param( 'categories' => $categories, );
-
-#Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry
-
-    my $existing_cardnumber =
-      $schema->resultset('Borrower')->get_column('cardnumber')->max() // 0;
-
-    my $new_cardnumber = $existing_cardnumber + 1;
-    $template->param( "newcardnumber" => $new_cardnumber );
-
-    my $op = $input->param('op') // 'list';
-    my $minpw = C4::Context->preference("minPasswordLength");
-    $template->param( "minPasswordLength" => $minpw );
-    my @messages;
-    my @errors;
-    my $nok            = $input->param('nok');
-    my $cardnumber     = $input->param('cardnumber');
-    my $borrowernumber = $input->param('borrowernumber');
-    my $userid         = $input->param('userid');
-
-    # function to designate mandatory fields (visually with css)
-    my $check_BorrowerMandatoryField =
-      C4::Context->preference("BorrowerMandatoryField");
-    my @field_check = split( /\|/, $check_BorrowerMandatoryField );
-    foreach (@field_check) {
-        $template->param( "mandatory$_" => 1 );
-        $template->param(
-            BorrowerMandatoryField =>
-              C4::Context->preference("BorrowerMandatoryField")
-            ,    #field to test with javascript
-        );
-    }
-
- #If the entered cardnumber causes an error hand this error to the @errors array
-    if ( my $error_code = checkcardnumber( $cardnumber, $borrowernumber ) ) {
-        push @errors,
-            $error_code == 1 ? 'ERROR_cardnumber_already_exists'
-          : $error_code == 2 ? 'ERROR_cardnumber_length'
-          :                    ();
-    }
-
-   #If the entered password causes an error hand this error to the @errors array
-    push @errors, "ERROR_password_mismatch"
-      if $firstpassword ne $secondpassword;
-    push @errors, "ERROR_short_password"
-      if ( $firstpassword
-        && $minpw
-        && $firstpassword ne '****'
-        && ( length($firstpassword) < $minpw ) );
-
-    #Passing errors to template
-    $nok = $nok || scalar(@errors);
-
-#If errors have been generated from the users inputted cardnumber or password then display the error and do not insert the patron into the borrowers table
-    if ($nok) {
-        foreach my $error (@errors) {
-            if ( $error eq 'ERROR_password_mismatch' ) {
-                $template->param( errorpasswordmismatch => 1 );
+if ( $step == 3 ) {
+    if ( $op eq 'add_validate_patron' ) {
+
+        #Create a patron
+        my $firstpassword  = $input->param('password')  || '';
+        my $secondpassword = $input->param('password2') || '';
+        my $cardnumber     = $input->param('cardnumber');
+        my $userid         = $input->param('userid');
+
+        if ( my $error_code = checkcardnumber($cardnumber) ) {
+            if ( $error_code == 1 ) {
+                push @messages,
+                  {
+                    type => 'alert',
+                    code => 'ERROR_cardnumber_already_exists'
+                  };
             }
-            if ( $error eq 'ERROR_login_exist' ) {
-                $template->param( errorloginexists => 1 );
-            }
-            if ( $error eq 'ERROR_cardnumber_already_exists' ) {
-                $template->param( errorcardnumberexists => 1 );
-            }
-            if ( $error eq 'ERROR_cardnumber_length' ) {
-                $template->param( errorcardnumberlength => 1 );
-            }
-            if ( $error eq 'ERROR_short_password' ) {
-                $template->param( errorshortpassword => 1 );
+            elsif ( $error_code == 2 ) {
+                push @messages,
+                  { type => 'alert', code => 'ERROR_cardnumber_length' };
             }
         }
-        $template->param( 'nok' => 1 );
+        elsif ( $firstpassword ne $secondpassword ) {
+
+            push @messages,
+              { type => 'alert', code => 'ERROR_password_mismatch' };
+        }
+        else {
+
+            my $patron_data = {
+                surname      => scalar $input->param('surname'),
+                firstname    => scalar $input->param('firstname'),
+                cardnumber   => scalar $input->param('cardnumber'),
+                branchcode   => scalar $input->param('libraries'),
+                categorycode => scalar $input->param('categorycode_entry'),
+                userid       => scalar $input->param('userid'),
+                password     => scalar $input->param('password'),
+                password2    => scalar $input->param('password2'),
+                privacy      => "default",
+                address      => "",
+                city         => "",
+                flags => 1,    # Will be superlibrarian
+            };
 
-#Else if no errors have been caused by the users inputted card number or password then insert the patron into the borrowers table
-    }
-    else {
-        my ( $template, $loggedinuser, $cookie ) =
-          C4::InstallAuth::get_template_and_user(
-            {
-                template_name   => "/onboarding/onboardingstep3.tt",
-                query           => $input,
-                type            => "intranet",
-                authnotrequired => 0,
-                flagsrequired   => { borrowers => 1 },
-                debug           => 1,
-            }
-          );
-
-        if ( $op eq 'add_validate' ) {
-            my %newdata;
-
-            #Store the template form values in the newdata hash
-            $newdata{borrowernumber} = $input->param('borrowernumber');
-            $newdata{surname}        = $input->param('surname');
-            $newdata{firstname}      = $input->param('firstname');
-            $newdata{cardnumber}     = $input->param('cardnumber');
-            $newdata{branchcode}     = $input->param('libraries');
-            $newdata{categorycode}   = $input->param('categorycode_entry');
-            $newdata{userid}         = $input->param('userid');
-            $newdata{password}       = $input->param('password');
-            $newdata{password2}      = $input->param('password2');
-            $newdata{privacy}        = "default";
-            $newdata{address}        = "";
-            $newdata{city}           = "";
-
-#Hand tne 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);
-
-#Create a hash named member2 and fill it with the borrowernumber of the borrower that has just been created
-            my %member2;
-            $member2{'borrowernumber'} = $borrowernumber;
-
-#Perform data validation on the flag that has been handed to onboarding.pl by the template
-            my $flag = $input->param('flag');
-            if ( $input->param('newflags') ) {
-                my @perms            = $input->multi_param('flag');
-                my %all_module_perms = ();
-                my %sub_perms        = ();
-                foreach my $perm (@perms) {
-                    if ( $perm !~ /:/ ) {
-                        $all_module_perms{$perm} = 1;
-                    }
-                    else {
-                        my ( $module, $sub_perm ) = split /:/, $perm, 2;
-                        push @{ $sub_perms{$module} }, $sub_perm;
-                    }
-                }
+              Koha::Patron::Categories->find( $patron_data->{categorycode} );
+            $patron_data->{dateexpiry} =
+              $patron_category->get_expiry_date( $patron_data->{dateenrolled} );
 
-                # construct flags
-                my @userflags = $schema->resultset('Userflag')->search(
-                    {},
-                    {
-                        order_by => { -asc => 'bit' },
-                    }
-                );
-
-                #Setting superlibrarian permissions for new patron
-                my $flags =
-                  Koha::Patrons->find($borrowernumber)->set( { flags => 1 } )
-                  ->store;
-
-                #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' };
-                }
+            my $borrowernumber = C4::Members::AddMember(%$patron_data);
+
+            #Error handling checking if the patron was created successfully
+            if ($borrowernumber) {
+                push @messages,
+                  { type => 'message', code => 'success_on_insert_patron' };
+            }
+            else {
+                push @messages,
+                  { type => 'error', code => 'error_on_insert_patron' };
             }
         }
     }
+
+    $step++ if Koha::Patrons->search( { flags => 1 } )->count;
 }
-elsif ( $step && $step == 4 ) {
-    my ( $template, $borrowernumber, $cookie ) =
-      C4::InstallAuth::get_template_and_user(
-        {
-            template_name   => "/onboarding/onboardingstep4.tt",
-            query           => $input,
-            type            => "intranet",
-            authnotrequired => 0,
-            flagsrequired =>
-              { parameters => 'parameters_remaining_permissions' },
-            debug => 1,
-        }
-      );
-    if ( $op eq "add_validate" ) {
+if ( $step == 4 ) {
+    if ( $op eq 'add_validate_itemtype' ) {
         my $description   = $input->param('description');
         my $itemtype_code = $input->param('itemtype');
         $itemtype_code = uc($itemtype_code);
 
-  #Create a new itemtype object using the user inputted itemtype and description
         my $itemtype = Koha::ItemType->new(
             {
                 itemtype    => $itemtype_code,
@@ -407,67 +219,29 @@ elsif ( $step && $step == 4 ) {
             }
         );
         eval { $itemtype->store; };
-        my $message;
 
-#Fill the $message variable with an error if the item type object was not successfully created and inserted into the itemtypes table
-        if ($itemtype) {
-            $message = 'success_on_insert';
+        unless ($@) {
+            push @messages,
+              { type => 'message', code => 'success_on_insert_itemtype' };
         }
         else {
-            $message = 'error_on_insert';
+            push @messages,
+              { type => 'message', code => 'error_on_insert_itemtype' };
         }
-        $template->param( 'message' => $message );
     }
+
+    $step++ if Koha::ItemTypes->count;
 }
-elsif ( $step && $step == 5 ) {
-
-  #Find all the existing categories to display in a dropdown box in the template
-    my $categories;
-    $categories = Koha::Patron::Categories->search();
-    $template->param( categories => $categories, );
-
- #Find all the exisiting item types to display in a dropdown box in the template
-    my $itemtypes;
-    $itemtypes = Koha::ItemTypes->search();
-    $template->param( itemtypes => $itemtypes, );
-
-    my $input = CGI->new;
-
-    my ( $template, $loggedinuser, $cookie ) =
-      C4::InstallAuth::get_template_and_user(
-        {
-            template_name   => "/onboarding/onboardingstep5.tt",
-            query           => $input,
-            type            => "intranet",
-            authnotrequired => 0,
-            flagsrequired   => { parameters => 'manage_circ_rules' },
-            debug           => 1,
-        }
-      );
-
-    #If no libraries exist then set the $branch value to *
-    my $branch = $input->param('branch');
-    unless ($branch) {
-        if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) {
-            $branch =
-              Koha::Libraries->search->count() == 1
-              ? undef
-              : C4::Context::mybranch();
-        }
-        else {
-            $branch =
-              C4::Context::only_my_library()
-              ? ( C4::Context::mybranch() || '*' )
-              : '*';
-        }
-    }
-    $branch = '*' if $branch eq 'NO_LIBRARY_SET';
-    my $op = $input->param('op') || q{};
+if ( $step == 5 ) {
+
+    if ( $op eq 'add_validate_circ_rule' ) {
+
+        #If no libraries exist then set the $branch value to *
+        my $branch = $input->param('branch') || '*';
 
-    if ( $op eq 'add_validate' ) {
         my $type            = $input->param('type');
-        my $br              = $input->param('branch');
-        my $bor             = $input->param('categorycode');
+        my $branchcode      = $input->param('branch');
+        my $categorycode    = $input->param('categorycode');
         my $itemtype        = $input->param('itemtype');
         my $maxissueqty     = $input->param('maxissueqty');
         my $issuelength     = $input->param('issuelength');
@@ -480,8 +254,8 @@ elsif ( $step && $step == 5 ) {
         $issuelength = $issuelength eq q{} ? undef : $issuelength;
 
         my $params = {
-            branchcode      => $br,
-            categorycode    => $bor,
+            branchcode      => $branchcode,
+            categorycode    => $categorycode,
             itemtype        => $itemtype,
             maxissueqty     => $maxissueqty,
             renewalsallowed => $renewalsallowed,
@@ -491,59 +265,65 @@ elsif ( $step && $step == 5 ) {
             onshelfholds    => $onshelfholds,
         };
 
-        my @messages;
-
-#Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to.
-        if ( $branch eq "*" ) {
-            my $search_default_rules =
-              $schema->resultset('DefaultCircRule')->count();
-            my $insert_default_rules =
-              $schema->resultset('Issuingrule')
-              ->new(
-                { maxissueqty => $maxissueqty, onshelfholds => $onshelfholds }
-              );
-        }
-
-#Allows for the 'All' option to work when selecting all patron categories for a circulation rule to apply to.
-        elsif ( $bor eq "*" ) {
-
-            my $search_default_rules =
-              $schema->resultset('DefaultCircRule')->count();
-            my $insert_default_rules = $schema->resultset('Issuingrule')
-              ->new( { maxissueqty => $maxissueqty } );
-        }
-
-#Allows for the 'All' option to work when selecting all itemtypes for a circulation rule to apply to
-        elsif ( $itemtype eq "*" ) {
-            my $search_default_rules =
-              $schema->resultset('DefaultCircRule')->search(
-                {},
-                {
-                    branchcode => $branch
-                }
-
-              );
+        my $issuingrule = Koha::IssuingRule->new($params);
+        eval { $issuingrule->store; };
 
-            my $insert_default_rules = $schema->resultset('Issuingrule')
-              ->new( { branchcode => $branch, onshelfholds => $onshelfholds } );
-        }
-
-        my $issuingrule = Koha::IssuingRules->find(
-            { categorycode => $bor, itemtype => $itemtype, branchcode => $br }
-        );
-        if ($issuingrule) {
-            $issuingrule->set($params)->store();
+        unless ($@) {
             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.
-
+              { type => 'message', code => 'success_on_insert_circ_rule' };
         }
         else {
-            Koha::IssuingRule->new()->set($params)->store();
+            push @messages,
+              { type => 'message', code => 'error_on_insert_circ_rule' };
         }
     }
+
+    $step++ if Koha::IssuingRules->count;
+}
+
+my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
+$template_params->{libraries}   = $libraries;
+$template_params->{group_types} = [
+    {
+        categorytype => 'searchdomain',
+        categories   => [
+            Koha::LibraryCategories->search(
+                { categorytype => 'searchdomain' }
+            )
+        ],
+    },
+    {
+        categorytype => 'properties',
+        categories   => [
+            Koha::LibraryCategories->search( { categorytype => 'properties' } )
+        ],
+    },
+];
+
+if ( $step > 5 ) {
+    $template_params->{all_done} = 1;    # If step 5 is complete, we are done!
+    $step = 5;
 }
 
+#Getting the appropriate template to display to the user
+my ( $template, $loggedinuser );
+( $template, $loggedinuser, $cookie ) = C4::InstallAuth::get_template_and_user(
+    {
+        template_name   => "onboarding/onboardingstep${step}.tt",
+        query           => $input,
+        type            => "intranet",
+        authnotrequired => 0,
+        debug           => 1,
+    }
+);
+
+$template_params->{messages} = \@messages;
+my $categories = Koha::Patron::Categories->search();
+$template_params->{categories} = $categories;
+
+my $itemtypes = Koha::ItemTypes->search();
+$template_params->{itemtypes} = $itemtypes;
+
+$template->param(%$template_params);
+
 output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/onboarding_messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/onboarding_messages.inc
new file mode 100644 (file)
index 0000000..67eabef
--- /dev/null
@@ -0,0 +1,20 @@
+[% FOR m IN messages %]
+    <div class="dialog [% m.type %]">
+        [% SWITCH m.code %]
+        [% CASE 'success_on_insert_library' %]<span>Library created!</span>
+        [% CASE 'error_on_insert_library' %]<span>Library already exists and cannot be modified!</span>
+        [% CASE 'success_on_insert_category' %]<span>Patron category created!</span>
+        [% CASE 'error_on_insert_category' %]<span>Patron category already exists and cannot be modified!</span>
+        [% CASE 'success_on_insert_patron' %]<span>Administrator Patron created!</span>
+        [% CASE 'error_on_insert_patron' %]<span>The patron has not been created! Cardnumber or Userid may already exist.</span>
+        [% CASE 'ERROR_cardnumber_already_exists' %]<span>Cardnumber already in use.</span>
+        [% CASE 'ERROR_cardnumber_length' %]<span>Cardnumber length is incorrect.</span>
+        [% CASE 'ERROR_password_mismatch' %]<span>Passwords do not match.</span>
+        [% CASE 'success_on_insert_itemtype' %]<span>New item type created!</span>
+        [% CASE 'error_on_insert_itemtype' %]<span>Item type already exists!</span>
+        [% CASE 'success_on_insert_circ_rule' %]<span>Circulation rule created!</span>
+        [% CASE 'error_on_insert_circ_rule' %]<span>Circulation rule not created!</span>
+        [% CASE %][% message %]
+        [% END %]
+    </div>
+[% END %]
index b295fc9..9754f74 100644 (file)
@@ -1,81 +1,38 @@
-<!--Includes for creating library-->
 [% INCLUDE 'doc-head-open.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
 [% INCLUDE 'installer-doc-head-close.inc' %]
 [% INCLUDE 'datatables.inc' %]
 
-[% IF (libraries && libraries.count > 1) %]
-    <meta http-equiv="refresh" content="0; url=/cgi-bin/koha/installer/onboarding.pl?step=2">
-
-[% ELSIF (op == "add_validate_library") %]
-    <head>
-        <title>Welcome &rsaquo; to  &rsaquo; Koha</title>
-    </head>
-
-    <!--Header for the koha onboarding tool-->
-    <div>
-        <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
-    </div>
-
-<!--New Library created-->
-       [% IF message == "success_on_insert" %]
-            <form name="createlibrary" method="post" action="onboarding.pl" >
-                <input type="hidden" name="step" value="2"/>
-                <h1 align="left"> New library</h1>
-                <div>
-                    <p> Success: library created!
-                    </p>
-                    <p> To add another library and for more settings, <br>
-                    go to:<br>
-                    More -> Administration -> Libraries and groups<br>
-                    </p>
-                </div>
-                Next up:
-                <input type="submit" name="start" value="Minimal patron category setup"/>
-            </form>
-
-        [%ELSE %]
-            <form name="retrylibrary" method="post" action="onboarding.pl">
-                <input type="hidden" name="step" value="1"/>
-                <h1 align="left">Failed </h1>
-                <div>
-                    <p> Library was not successfully created</br>
-                    Please try again or contact your system administrator. </p>
-                </div>
-                <input type="submit" value="Try again"/>
-            </form>
-        [%END%]
-
-[% ELSE %]
-    <head>
-        <title>Welcome &rsaquo; to  &rsaquo; Koha</title>
-    </head>
-
-    <!--Header for the koha onboarding tool-->
-    <div>
-        <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
-    </div>
-
-<!--Create a library screen 1-->
-        <form name="LibraryCreation" method="post" action="onboarding.pl">
-            <fieldset class="rows" >
-                 <h2>Create a library</h2>
-                 <input type="hidden" name="step" value="1"/>
-                 <input type="hidden" name="op" value="add_validate_library"/>
-                 <ol>
-                     <li>
-                        <label for="branchcode" class="required">Library code: </label>
-                        <input type="text"  pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" name="branchcode" id="branchcode" size="10" maxlength="10" value="[% library.branchcode |html %]" class="required" required="required" />
-                        <span class="required">Required</span>
-                    </li>
-                    <li>
-                        <label for="branchname" class="required">Name: </label>
-                        <input type="text" name="branchname" id="branchname" title="Please enter the name of your institution" size="42" value="[% library.branchname |html %]" class="    required" required="required" style="width:200px;">
-                        <span class="required">Required</span>
-                    </li>
-                 </ol>
-             <br>
-             <input type="submit" class="action" value="Submit"/>
-            </fieldset>
-     </form>
-[% END %]
+<head><title>Welcome &rsaquo; to  &rsaquo; Koha</title></head>
+
+<div>
+    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
+</div>
+
+[% INCLUDE 'onboarding_messages.inc' %]
+
+<form name="LibraryCreation" method="post" action="onboarding.pl">
+    <fieldset class="rows" >
+         <h2>Create a library</h2>
+         <input type="hidden" name="step" value="1"/>
+         <input type="hidden" name="op" value="add_validate_library"/>
+         <ol>
+             <li>
+                <label for="branchcode" class="required">Library code: </label>
+                <input type="text"  pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" name="branchcode" id="branchcode" size="10" maxlength="10" value="" class="required" required="required" />
+                <span class="required">Required</span>
+            </li>
+            <li>
+                <label for="branchname" class="required">Name: </label>
+                <input type="text" name="branchname" id="branchname" title="Please enter the name of your institution" size="42" value="" class="required" required="required" style="width:200px;">
+                <span class="required">Required</span>
+            </li>
+         </ol>
+         <p>
+            To add another library and for more settings, <br>
+            go to:<br>
+            More -> Administration -> Libraries and groups<br>
+         </p>
+         <input type="submit" class="action" value="Submit"/>
+    </fieldset>
+</form>
index 2b82d44..0d682bc 100644 (file)
@@ -26,139 +26,98 @@ jQuery.validator.addMethod( "enrollment_period", function(){
 <script type="text/javascript" src="[% themelang %]/js/categories.js"></script>
 </head>
 
-[% IF (categories && categories.count > 1 ) %] <!--This if statement checks if the categories variable handed to this template by onboarding.pl has data in it. If the categories variable does have data in it this means that the user has previously imported sample patron category data and so we do not need to show them the create patron category screen 1, instead we can display a screen with ubtton redirecting the user to step 3-->
 
+<div>
+    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
+</div>
 
-     <meta http-equiv="refresh" content="0; url=/cgi-bin/koha/installer/onboarding.pl?step=3">
-
-[% ELSIF (op == "add_validate_category") %]
-<!--else if the user has not previously imported sample patron categories check if the user has pressed the button name="add_validate" in the create patron category screen 1, and if they have pressed that button then display the below screen with a button to redirect the user to step 3-->
-
-    <div> <!-- Header that appears at the top of every screen in the koha onboarding tool-->
-        <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
-    </div>
-
-    [% IF message != "error_on_insert" %]
-     <form name="createcat" method="post" action="onboarding.pl">
-            <input type="hidden" name="step" value="3"/>
-             <h1 align="left">  New patron category</h1>
-             <div>
-                 <p> Success: patron category created! </p>
-                 <p> To add another patron category and for more settings<br>
-                 go to:<br>
-                 More -> Administration -> Patron categories<br>
-             </div>
-             Next up:<br>
-             <input type="submit" name="start" value="Add a patron"><!-- When the user clicks on this button then redirect them to step 3 of the onboarding tool-->
-     </form>
-     [% ELSE %]
-        <form name="retrypatcat" method="post" action="onboarding.pl">
-        Message is [% message %]
+[% INCLUDE 'onboarding_messages.inc' %]
+<h1 align="left"> Create a new patron category</h1>
+<p> The patron category you create in this form is going to be the one which the new administrator patron account will have.</p>
+   <form id="category_form" method="post" action="onboarding.pl">
+   <fieldset class="rows">
         <input type="hidden" name="step" value="2"/>
-            <h1 align="left">Failed</h1>
-            <div>Patron category was not successfully created.</br>
-            Please try again or contact your system administrator.</p>
-            </div>
-            <input type="submit" value="Try again"/>
-        </form>
-    [% END %]
-
-
-[% ELSE %] <!--Else display create patron category screen 1 where the user can input values to create their first patron category-->
-    <div> <!-- Header that appears at the top of every screen in the koha onboarding tool-->
-        <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
-    </div>
-
-    <h1 align="left"> Create a new patron category</h1>
-    <p> The patron category you create in this form is going to be the one which the new administrator patron account will have.</p>
-       <form id="category_form" method="post" action="onboarding.pl">
-       <fieldset class="rows">
-            <input type="hidden" name="step" value="2"/>
-            <input type="hidden" name="op" value="add_validate_category" />
-                <ol>
-                    <li>
-                        <label for="categorycode" class="required">Category code: </label>
-                        <input type="text" pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" id="categorycode" name="categorycode" value="[% category.categorycode |html %]" size="10" maxlength="10" class="required" required="required" />
-                        <span class="required">Required</span>
-                    </li>
-
-                    <li>
-                        <label for="description" class="required">Description: </label>
-                        <input type="text" name="description" title="Please enter a description of the category" size="40" maxlength="80" class="required" required="required" value="[% category.description |html%]" />
-                        <span class="required">Required</span>
-                    </li>
-
-                    <li>
-                        <label for="overduenoticerequired">Overdue notice required: </label>
-                        <select name="overduenoticerequired" value="overduenoticerequired">
-                            [% IF category.overduenoticerequired %]
-                                <option value="0">No</option>
-                                <option value="1" selected="selected">Yes</option>
-                            [% ELSE %]
-                                <option value="0" selected="selected">No</option>
-                                <option value="1">Yes</option>
-                            [% END %]
-                        </select>
-                    </li>
-
-                    <li>
-                        <label for="category_type" class="required">Category type: </label>
-                        <select name="category_type" value="category_type" class='required' required='required'>
-                            [% IF category and category.category_type == 'S' %]
-                                <option value="S" selected="selected">Staff</option>
-                            [% ELSE %]
-                                <option value="S">Staff</option>
-                            [% END %]
-                        </select>
-                        <span class="required">Required</span>
-                    </li>
-
-                    <li>
-                        <label for="default_privacy">Default privacy: </label>
-                        <select value="default_privacy" name="default_privacy" required="required">
-                            [% SET default_privacy = 'default' %]
-
-                            [% IF category %]
-                               [% SET default_privacy = category.default_privacy %]
-                            [% END %]
-
-                            [% SWITCH default_privacy %]
-                            [% CASE 'forever' %]
-                                <option value="default">Default</option>
-                                <option value="never">Never</option>
-                                <option value="forever" selected="selected">Forever</option>
-                            [% CASE 'never' %]
-                                <option value="default">Default</option>
-                                <option value="never" selected="selected">Never</option>
-                                <option value="forever">Forever</option>
-                            [% CASE %]
-                                <option value="default" selected="selected">Default</option>
-                                <option value="never">Never</option>
-                                <option value="forever">Forever</option>
-                            [% END %]
-                        </select>
-                        <p>Controls how long a patrons checkout history is kept for new patrons of this category. "Never"     anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</p>
-                    </li>
-            </ol>
-            <span class="label">Enrolment period: </span>
-            </br>
-                    <fieldset>
-                    <legend>Choose one</legend>
-                            <ol>
-                                <li>
-                                    <label for="enrolmentperiod" style="width:6em;">In months: </label>
-                                    <input type="number" class="enrolmentperiod" name="enrolmentperiod" id="enrolmentperiod" min="0" size="3" maxlength="3" value="[% IF category.enrolmentperiod %][% category.enrolmentperiod %][% END %]" /> months
-                                </li>
-                                <li>
-                                    <label for="enrolmentperioddate" style="width:6em;">Until date: </label>
-                                    <input type="text" class="enrolmentperioddate datepicker" name="enrolmentperioddate" id="enrolmentperioddate" value="[% category.enrolmentperioddate | $KohaDates %]" />
-                                </li>
-                            </ol>
-                     </fieldset>
-                    <br>
-                    <input type="submit" class="action" value="Submit" />
-    </fieldset>
-    </form>
-[% END %]
+        <input type="hidden" name="op" value="add_validate_category" />
+            <ol>
+                <li>
+                    <label for="categorycode" class="required">Category code: </label>
+                    <input type="text" pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" id="categorycode" name="categorycode" value="[% category.categorycode |html %]" size="10" maxlength="10" class="required" required="required" />
+                    <span class="required">Required</span>
+                </li>
+
+                <li>
+                    <label for="description" class="required">Description: </label>
+                    <input type="text" name="description" title="Please enter a description of the category" size="40" maxlength="80" class="required" required="required" value="[% category.description |html%]" />
+                    <span class="required">Required</span>
+                </li>
+
+                <li>
+                    <label for="overduenoticerequired">Overdue notice required: </label>
+                    <select name="overduenoticerequired" value="overduenoticerequired">
+                        [% IF category.overduenoticerequired %]
+                            <option value="0">No</option>
+                            <option value="1" selected="selected">Yes</option>
+                        [% ELSE %]
+                            <option value="0" selected="selected">No</option>
+                            <option value="1">Yes</option>
+                        [% END %]
+                    </select>
+                </li>
+
+                <li>
+                    <label for="category_type" class="required">Category type: </label>
+                    Staff
+                </li>
+
+                <li>
+                    <label for="default_privacy">Default privacy: </label>
+                    <select value="default_privacy" name="default_privacy" required="required">
+                        [% SET default_privacy = 'default' %]
+
+                        [% IF category %]
+                           [% SET default_privacy = category.default_privacy %]
+                        [% END %]
+
+                        [% SWITCH default_privacy %]
+                        [% CASE 'forever' %]
+                            <option value="default">Default</option>
+                            <option value="never">Never</option>
+                            <option value="forever" selected="selected">Forever</option>
+                        [% CASE 'never' %]
+                            <option value="default">Default</option>
+                            <option value="never" selected="selected">Never</option>
+                            <option value="forever">Forever</option>
+                        [% CASE %]
+                            <option value="default" selected="selected">Default</option>
+                            <option value="never">Never</option>
+                            <option value="forever">Forever</option>
+                        [% END %]
+                    </select>
+                    <p>Controls how long a patrons checkout history is kept for new patrons of this category. "Never"     anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</p>
+                </li>
+        </ol>
+        <span class="label">Enrolment period: </span>
+        </br>
+                <fieldset>
+                <legend>Choose one</legend>
+                        <ol>
+                            <li>
+                                <label for="enrolmentperiod" style="width:6em;">In months: </label>
+                                <input type="number" class="enrolmentperiod" name="enrolmentperiod" id="enrolmentperiod" min="0" size="3" maxlength="3" value="[% IF category.enrolmentperiod %][% category.enrolmentperiod %][% END %]" /> months
+                            </li>
+                            <li>
+                                <label for="enrolmentperioddate" style="width:6em;">Until date: </label>
+                                <input type="text" class="enrolmentperioddate datepicker" name="enrolmentperioddate" id="enrolmentperioddate" value="[% category.enrolmentperioddate | $KohaDates %]" />
+                            </li>
+                        </ol>
+                 </fieldset>
+             <p> Success: patron category created! </p>
+             <p> To add another patron category and for more settings<br>
+             go to:<br>
+             More -> Administration -> Patron categories<br>
+
+                <input type="submit" class="action" value="Submit" />
+</fieldset>
+</form>
 
 [% INCLUDE 'intranet-bottom.inc' %]
index de2e595..dc94b0f 100644 (file)
@@ -3,7 +3,6 @@
 [% USE KohaDates %]
 [% USE Price %]
 [% INCLUDE 'doc-head-open.inc' %]
-[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END%]
 [% INCLUDE 'installer-doc-head-close.inc' %]
 [% INCLUDE 'calendar.inc' %]
 [% INCLUDE 'datatables.inc' %]
@@ -59,138 +58,95 @@ $(document).ready(function(){
     <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
 </div>
 
+[% INCLUDE 'onboarding_messages.inc' %]
 
-[%  IF (nok) %]
-        <form name="errors" method="post" action="onboarding.pl">
-            <input type="hidden" name="step" value="3"/>
-            <h1 align="left">There was an error</h1>
-            <p>Try again </p>
-            <div>
-            <ul>
-            [% IF errorloginexists %]
-                <li id="ERROR_login_exist">Username/password already exists.</li>
-            [% END %]
-            [% IF errorcardnumberexists %]
-                <li id="ERROR_cardnumber">Cardnumber already in use.</li>
-            [% END %]
-            [% IF errorcardnumberlength %]
-                <li id="ERROR_cardnumber">Cardnumber length is incorrect</li>
-            [% END %]
-            [% IF errorshortpassword %]
-                <li id="ERROR_short_password">Password length is incorrect, must be at least [% minPasswordLength %] characters long.</li>
-            [% END %]
-            [% IF errorpasswordmismatch %]
-                <li id="ERROR_password_mismatch">Passwords do not match.</li>
-            [% END %]
-            </ul>
+<h1 align="left"> Create koha administrator patron</h1>
+<p>
+Now we will create a patron with superlibrarian permissions. Login with this to access Koha as a staff member will all permissions.
+</p>
+<form name="createpatron" id="createpatron" method="post" action="onboarding.pl">
+    <fieldset class="rows">
+         <input type="hidden" name="step" value="3"/>
+         <input type="hidden" name="op" value="add_validate_patron" />
+            <legend id="library_management_lgd">Library management</legend>
+            <ol>
+            <h3>Patron identity</h3>
+                <li>
+                    <label for="surname" class="required">Surname: </label>
+                    <input type="text" id="surname" name="surname" title="Please only enter letters in the surname field" value="[% surname |html %]" class="required" required="required" />
+                    <span class="required">Required</span>
+                </li>
+                <li>
+                    <label for="firstname" class="required">First name: </label>
+                    <input  type="text" name="firstname" title="Please only enter letters in the first name field" id="firstname" size="20" value="[% firstname |html %]" class="required" required="required">
+                    <span class="required">Required</span>
+                </li>
+            </ol>
 
-            </div>
-            <input type="submit" name="step" value="Try again"/>
-        </form>
+            <ol>
+                <li>
+                    <label for="cardnumber" class="required">Card number: </label>
+                    [% IF patrons && patrons > 1 %]
+                        <input type="text" id="cardnumber" title="Please enter a cardnumber" class="noEnterSubmit valid" name="cardnumber" value="[% newcardnumber | html %]" class="required" required="required">
+                    [% ELSE %]
+                        <input type="text" id="cardnumber" title="Please enter a cardnumber" name="cardnumber" value="[% cardnumber | html %]" class="required" required="required">
+                    [% END %]
+                    <span class="required">Required</span>
+                </li>
+                <li>
 
+                <!--require a foreach loop to get all the values for the library that the user has either imported (in web installer) or created in the first step of this onboarding tool-->
+                    <label for="libraries" class="required"> Library: </label>
+                    <select name="libraries" size="1" id="libraries">
 
-<!--Create a patron screen 2-->
-[% ELSIF op == 'add_validate' %]
-          <!--New patron created-->
-        <form name="patrondone" method="post" action="onboarding.pl">
-            <input type="hidden" name="step" value="4"/>
-            <h1 align="left"> Koha administrator patron </h1>
-            <div>
-                 <p> Success: administrator patron created!</p>
-                 <p> To create another patron, go to Patrons -> New Patron. <br>
-                More -> Set Permissions in a user page to gain superlibrarian permissions.
-            </div>
-            Next up:
-            <input type="submit" name="start" value="Minimal item type setup"/>
-        </form>
-[% ELSE %]
-<!--Create a patron screen 1-->
-       <h1 align="left"> Create koha administrator patron</h1>
-        <p>
-        Now we will create a patron with superlibrarian permissions. Login with this to access Koha as a staff member will all permissions.
-        </p>
-        <form name="createpatron" id="createpatron" method="post" action="onboarding.pl">
-            <fieldset class="rows">
-                 <input type="hidden" name="step" value="3"/>
-                 <input type="hidden" name="op" value="add_validate" />
-                    <legend id="library_management_lgd">Library management</legend>
-                    <ol>
-                    <h3>Patron identity</h3>
-                        <li>
-                            <label for="surname" class="required">Surname: </label>
-                            <input type="text" id="surname" name="surname" title="Please only enter letters in the surname field" value="[% surname |html %]" class="required" required="required" />
-                            <span class="required">Required</span>
-                        </li>
-                        <li>
-                            <label for="firstname" class="required">First name: </label>
-                            <input  type="text" name="firstname" title="Please only enter letters in the first name field" id="firstname" size="20" value="[% firstname |html %]" class="required" required="required">
-                            <span class="required">Required</span>
-                        </li>
-                    </ol>
-
-                    <ol>
-                        <li>
-                            <label for="cardnumber" class="required">Card number: </label>
-                            [% IF patrons && patrons > 1 %]
-                                <input type="text" id="cardnumber" title="Please enter a cardnumber" class="noEnterSubmit valid" name="cardnumber" value="[% newcardnumber | html %]" class="required" required="required">
-                            [% ELSE %]
-                                <input type="text" id="cardnumber" title="Please enter a cardnumber" name="cardnumber" value="[% cardnumber | html %]" class="required" required="required">
-                            [% END %]
-                            <span class="required">Required</span>
-                        </li>
-                        <li>
-
-                        <!--require a foreach loop to get all the values for the library that the user has either imported (in web installer) or created in the first step of this onboarding tool-->
-                            <label for="libraries" class="required"> Library: </label>
-                            <select name="libraries" size="1" id="libraries">
+                     [% FOREACH library IN libraries %]
+                          <option name="libraries" value="[% library.branchcode %]"> [% library.branchname %]
+                     [% END %]
 
-                             [% FOREACH library IN libraries %]
-                                  <option name="libraries" value="[% library.branchcode %]"> [% library.branchname %]
-                             [% END %]
+                        </select>
+                    <span class="required"> Required</span>
+                </li>
+                <li>
+                    <label for="categorycode_entry" class="required"> Patron category</label>
+                    <select id="categorycode_entry" name="categorycode_entry" onchange="update_category_code(this);">
+                    [% FOREACH category IN categories %]
+                        <option name="categorycode_entry" value = "[% category.categorycode %]">[%category.description %]</option>
+                    [% END %]
+                    </select>
+                    <span class="required">Required</span><br><br>
+                    <b>Note:</b> If you installed sample patron categories please select the "Staff" option in the patron categories dropdown box.
+                </li>
+            </ol>
 
-                                </select>
-                            <span class="required"> Required</span>
-                        </li>
-                        <li>
-                            <label for="categorycode_entry" class="required"> Patron category</label>
-                            <select id="categorycode_entry" name="categorycode_entry" onchange="update_category_code(this);">
-                            [% FOREACH category IN categories %]
-                                <option name="categorycode_entry" value = "[% category.categorycode %]">[%category.description %]</option>
-                            [% END %]
-                            </select>
-                            <span class="required">Required</span><br><br>
-                            <b>Note:</b> If you installed sample patron categories please select the "Staff" option in the patron categories dropdown box.
-                        </li>
-                    </ol>
-
-                    <ol>
-                            <h3> Koha administrator patron permissions</h3>
-                            <input type="hidden" name="newflags" value="1"/>
-                            <li>
-                                <input type="hidden" class="flag parent" id="flag-0" name="flag" value="superlibrarian"/>
-                                <label name="permissioncode" for="flag-0"> superlibrarian</label>
-                            </li>
-                    </ol>
-                    <ol>
-                    <h3>OPAC/Staff Login</h3>
-                        <li>
-                            <input type="hidden" name="BorrowerMandatoryField" value = "[% BorrowerMandatoryField %]" />
-                            <label for="userid" class="required">Username: </label>
-                            <input type="text" name="userid" id ="userid" size="20" title="Please only enter a username of letters and numbers" value="[% userid |html %]" class="required" required="required" />
-                            <span class="required">Required</span>
-                        </li>
-                        <li>
-                            <label for="passwordlabel" class="required">Password: </label>
-                            <input type="password" name="password" id="password" size="20" value="[% member.password |html %]" class="required" required="required">
-                            <span class="required">Required</span>
-                        </li>
-                        <li>
-                            <label for="password2" class="required">Confirm password: </label>
-                            <input type="password" id="password2" name="password2" size="20" value="" class="required" required="required">
-                            <span class="required">Required</span>
-                        </li>
-                    </ol>
-             </fieldset><br>
-                <input type="submit" id="Submit" class="action" value="Submit"/>
-     </form>
-[% END %]
+            <ol>
+                    <h3> Koha administrator patron permissions</h3>
+                    <li>
+                        <label> superlibrarian</label>
+                    </li>
+            </ol>
+            <ol>
+            <h3>OPAC/Staff Login</h3>
+                <li>
+                    <label for="userid" class="required">Username: </label>
+                    <input type="text" name="userid" id ="userid" size="20" title="Please only enter a username of letters and numbers" value="[% userid |html %]" class="required" required="required" />
+                    <span class="required">Required</span>
+                </li>
+                <li>
+                    <label for="passwordlabel" class="required">Password: </label>
+                    <input type="password" name="password" id="password" size="20" value="[% member.password |html %]" class="required" required="required">
+                    <span class="required">Required</span>
+                </li>
+                <li>
+                    <label for="password2" class="required">Confirm password: </label>
+                    <input type="password" id="password2" name="password2" size="20" value="" class="required" required="required">
+                    <span class="required">Required</span>
+                </li>
+            </ol>
+        <p>
+            To create another patron, go to Patrons -> New Patron. <br>
+            More -> Set Permissions in a user page to gain superlibrarian permissions.
+        </p>
+    </fieldset>
+    <br>
+    <input type="submit" id="Submit" class="action" value="Submit"/>
+</form>
index 6176fb4..2ca3ef4 100644 (file)
@@ -1,6 +1,5 @@
 <!-- includes for creating item type-->
 [% INCLUDE 'doc-head-open.inc' %]
-[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END%]
 [% INCLUDE 'installer-doc-head-close.inc' %]
 <head>
     <title>Create item type</title>
@@ -9,59 +8,34 @@
     <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
 </div>
 
-[% IF (itemtypes && itemtypes.count >1) %]
+[% INCLUDE 'onboarding_messages.inc' %]
 
-     <meta http-equiv="refresh" content="0; url=/cgi-bin/koha/installer/onboarding.pl?step=5">
+<!--Create a item type screen 1-->
+<h1 align="center"> Create a new Item type </h1>
+<p> Item types are used to group related items. Examples of item types are books, cds, and DVDs. <br><br> When adding to your institutions catalogue you will create an item of a particular item type. <br><br> Importantly item types are what you apply     circulation rules to. Circulation rules govern how your institution will lend its items, for example a circulation rule applied to the DVD item type may enforce a payment of $1.00 for borrowing any DVD.</p>
+<form name="createitemform" method="post" action="onboarding.pl">
+    <fieldset class="rows">
+        <input type="hidden" name="step" value="4"/>
+        <input type="hidden" name="op" value="add_validate_itemtype" />
+        <ol>
+            <li>
+                <label for="itemtype" class="required">Item type code: </label>
+                <input type="text" name="itemtype" pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" id="itemtype" size="10" maxlength="10"  class="required" required="required" value="[% itemtype.itemtype |html %]" />
+                <span class="required">Required</span>
+            </li>
 
-[% ELSIF op == "add_validate" %]
-        [% IF message != "error_on_insert" %]
-            <form name="createitemtype" method="post" action="onboarding.pl">
-                <input type="hidden" name="step" value="5"/>
-                <h1 align="left"> New Item type </h1>
-                <div>
-                    <p> Success: New item type created!</p>
-                    <p> To create another item type later and for more settings <br>
-                    go to: <br>
-                    More -> Administration -> Item types <br>
-                </div>
-                Next up:
-                <input type="submit" value="Add a circulation rule"/>
-            </form>
-        [% ELSE %]
-        <form name="retryitem" method="post" action="onboarding.pl">
-            <input type="hidden" name="step" value="4"/>
-            <h1 align="left">Failed </h1>
-            <div>
-                <p>Item type was not successfully created. </br>
-                Please try again or contact your system administrator.
-                </p>
-            </div>
-        </form>
-        <!--Implement a if statement to check if the item type was successfully created or not -->
-        [% END %]
-[% ELSE %]
-    <!--Create a item type screen 1-->
-        <h1 align="center"> Create a new Item type </h1>
-        <p> Item types are used to group related items. Examples of item types are books, cds, and DVDs. <br><br> When adding to your institutions catalogue you will create an item of a particular item type. <br><br> Importantly item types are what you apply     circulation rules to. Circulation rules govern how your institution will lend its items, for example a circulation rule applied to the DVD item type may enforce a payment of $1.00 for borrowing any DVD.</p>
-        <form name="createitemform" method="post" action="onboarding.pl">
-            <fieldset class="rows">
-                <input type="hidden" name="step" value="4"/>
-                <input type="hidden" name="op" value="add_validate" />
-                <ol>
-                    <li>
-                        <label for="itemtype" class="required">Item type code: </label>
-                        <input type="text" name="itemtype" pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" id="itemtype" size="10" maxlength="10"  class="required" required="required" value="[% itemtype.itemtype |html %]" />
-                        <span class="required">Required</span>
-                    </li>
+            <li>
+                <label for="description" class="required">Description: </label>
+                <input type="text" name="description" id="description" title="Please only enter letters and/or numbers into this item type description" size="42" value="[% itemtype.description |html %]" class="required" required="required">
+                <span class="required">Required</span>
+            </li>
+        </ol>
+    <br>
+    <p> To create another item type later and for more settings <br>
+            go to: <br>
+            More -> Administration -> Item types <br>
+    </p>
 
-                    <li>
-                        <label for="description" class="required">Description: </label>
-                        <input type="text" name="description" id="description" title="Please only enter letters and/or numbers into this item type description" size="42" value="[% itemtype.description |html %]" class="required" required="required">
-                        <span class="required">Required</span>
-                    </li>
-                </ol>
-            <br>
-            <input type="submit" class="action" value="Submit"/>
-        </fieldset>
-        </form>
-[% END %]
+    <input type="submit" class="action" value="Submit"/>
+</fieldset>
+</form>
index bad9a2a..9701e62 100644 (file)
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Create Circulation rule</title>
-[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END %]
 [% INCLUDE 'installer-doc-head-close.inc' %]
 
 <div>
     <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
 </div>
 
-[% IF (finish) %]
+[% INCLUDE 'onboarding_messages.inc' %]
+
+[% IF all_done %]
 <h1>Congratulations you have finished and ready to use Koha</h1>
 <a href="/cgi-bin/koha/mainpage.pl">Start using Koha</a>
-
-[% END %]
-
-<!--Create a circulation rule screen 2-->
-[% IF op == "add_validate" %]
-        <!--New circulation rule created-->
-        <form name="finish" method="post" action="onboarding.pl">
-            <input type="hidden" name="op" value="finish" />
-            <h1 align="left"> New circulation rule </h1>
-            <div>
-                 <p> Success: circulation rule created!</p>
-                 <p> To create circulation rule, go to <br>
-                 More -> Administration -> Circulation and Fine Rules
-            </div>
-                 Next up:
-                 <input type="submit" name="op" value="Finish"/>
-        </form>
 [% ELSE %]
-<!--Create a circulation rule screen 1-->
-       <h1 align="left"> Create a new circulation rule </h1>
-       <form name="createcirculationrule" method="post" action="onboarding.pl">
-            <fieldset class="rows">
-                 <input type="hidden" name="step" value="5"/>
-                 <input type="hidden" name="op" value="add_validate" />
-                    <ol>
-                    <li>
-                        <label for="branch" class="required"> Library branch</label>
-                        <select name="branch" id="branchname" required="required">
-                        <option value""> Choose</option>
-                        <option value="*" selected="selected">All</option>
-                        [% FOREACH library IN libraries %]
-                            <option id="branch" value="[% library.branchcode %]"> [% library.branchname %]</option>
-                        [% END %]
-                        </select>
-                        <span class="required">Required</span>
-                    </li>
-                    <li>
-                        <label for="categorycode" class="required">Patron category: </label>
-                        <select name="categorycode" id="categorycodeselection" required="required" onchange = "update_categorycode(this);">
-                            <option value=""> Choose</option>
-                            <option value="*" selected="selected">All</option>
-                            [% FOREACH category IN categories %]
-                                <option id="categorycode" value = "[% category.categorycode %]"> [%category.description %]</option>
-                            [%END%]
-                        </select>
-                        <span class="required">Required</span>
-                    </li>
+    <h1 align="left"> Create a new circulation rule </h1>
+    <form name="createcirculationrule" method="post" action="onboarding.pl">
+        <fieldset class="rows">
+           <input type="hidden" name="step" value="5"/>
+           <input type="hidden" name="op" value="add_validate_circ_rule" />
+              <ol>
+              <li>
+                  <label for="branch" class="required"> Library branch</label>
+                  <select name="branch" id="branchname" required="required">
+                  <option value""> Choose</option>
+                  <option value="*" selected="selected">All</option>
+                  [% FOREACH library IN libraries %]
+                      <option id="branch" value="[% library.branchcode %]"> [% library.branchname %]</option>
+                  [% END %]
+                  </select>
+                  <span class="required">Required</span>
+              </li>
+              <li>
+                  <label for="categorycode" class="required">Patron category: </label>
+                  <select name="categorycode" id="categorycodeselection" required="required" onchange = "update_categorycode(this);">
+                      <option value=""> Choose</option>
+                      <option value="*" selected="selected">All</option>
+                      [% FOREACH category IN categories %]
+                          <option id="categorycode" value = "[% category.categorycode %]"> [%category.description %]</option>
+                      [%END%]
+                  </select>
+                  <span class="required">Required</span>
+              </li>
+
+              <li>
+                  <label for="itemtype"> Item type: </label>
+                  <select id="itemtype" name="itemtype" required="required">
+                  <option value""> Choose </option>
+                  <option value="*" selected="selected">All</option>
+                      [% FOREACH item IN itemtypes %]
+                          <option name="itemtype" value = "[% item.itemtype %]"> [% item.itemtype %]
+                      [%END%]
+                  </select>
+                  <span class="required"> Required</span>
+              </li>
+              <li>
+                  <label for="maxissueqty" class="required">Current checkouts allowed: </label>
+                  <input type="number" min="0" name="maxissueqty" title="Please only enter numbers" id="maxissueqty" size="10" value="50" class="required" required="required" />
+                  <span class="required">Required</span>
+              </li>
 
-                    <li>
-                        <label for="itemtype"> Item type: </label>
-                        <select id="itemtype" name="itemtype" required="required">
-                        <option value""> Choose </option>
-                        <option value="*" selected="selected">All</option>
-                            [% FOREACH item IN itemtypes %]
-                                <option name="itemtype" value = "[% item.itemtype %]"> [% item.itemtype %]
-                            [%END%]
-                        </select>
-                        <span class="required"> Required</span>
-                    </li>
-                    <li>
-                        <label for="maxissueqty" class="required">Current checkouts allowed: </label>
-                        <input type="number" min="0" name="maxissueqty" title="Please only enter numbers" id="maxissueqty" size="10" value="50" class="required" required="required" />
-                        <span class="required">Required</span>
-                    </li>
+              <li>
+                  <label for="issuelength" class="required">Loan period: </label>
+                  <input type="number" min="0" name="issuelength" title="Please only enter numbers" id="issuelength" size="10" value="14" class="required" required="required" />
+                  <span class="required">Required</span>
+             </li>
+             <li>
+                  <label for="lengthunit">Units: </label>
+                  <select name="lengthunit" id="lengthunit" required="required">
+                  <option value=""> Choose </option>
+                  [% SET units = 'days' %]
+                  [% IF category %]
+                      [% SET default_privacy = category.default_privacy %]
+                  [% END %]
 
-                    <li>
-                        <label for="issuelength" class="required">Loan period: </label>
-                        <input type="number" min="0" name="issuelength" title="Please only enter numbers" id="issuelength" size="10" value="14" class="required" required="required" />
-                        <span class="required">Required</span>
-                   </li>
-                   <li>
-                        <label for="lengthunit">Units: </label>
-                        <select name="lengthunit" id="lengthunit" required="required">
-                        <option value=""> Choose </option>
-                        [% SET units = 'days' %]
-                        [% IF category %]
-                            [% SET default_privacy = category.default_privacy %]
-                        [% END %]
+                  [% SWITCH units %]
+                       [% CASE 'days' %]
+                             <option value="days" selected="selected">Days</option>
+                             <option value="hours">Hours</option>
+                       [% CASE 'hours' %]
+                             <option value="days">Days</option>
+                             <option value="hours" selected="selected">Hours</option>
+                  [% END %]
+                  </select>
+               </li>
+               <li>
+                  <label for="renewalsallowed" class="required">Renewals allowed: </label>
+                  <input type="number" min="0" name="renewalsallowed" title="Please only enter numbers" id="renewalsallowed" size="10" max="10" value="10" class="required" required="required" />
+                  <span class="required">Required</span>
+               </li>
 
-                        [% SWITCH units %]
-                             [% CASE 'days' %]
-                                   <option value="days" selected="selected">Days</option>
-                                   <option value="hours">Hours</option>
-                             [% CASE 'hours' %]
-                                   <option value="days">Days</option>
-                                   <option value="hours" selected="selected">Hours</option>
-                        [% END %]
-                        </select>
-                     </li>
-                     <li>
-                        <label for="renewalsallowed" class="required">Renewals allowed: </label>
-                        <input type="number" min="0" name="renewalsallowed" title="Please only enter numbers" id="renewalsallowed" size="10" max="10" value="10" class="required" required="required" />
-                        <span class="required">Required</span>
-                     </li>
+               <li>
+                  <label for="renewalperiod" class="required">Renewals period: </label>
+                  <input type="number" min="0" name="renewalperiod" title="Please only enter numbers" id="renewalperiod" size="10" value="14" class="required" required="required" />
+                  <span class="required">Required</span>
+               </li>
 
-                     <li>
-                        <label for="renewalperiod" class="required">Renewals period: </label>
-                        <input type="number" min="0" name="renewalperiod" title="Please only enter numbers" id="renewalperiod" size="10" value="14" class="required" required="required" />
-                        <span class="required">Required</span>
-                     </li>
+               <li>
+                  <label for="onshelfholds">On shelf holds allowed: </label>
+                  <select name="onshelfholds" id="onshelfholds" required="required">
+                        <option value="">Choose</option>
+                        <option value="1" selected="selected">Yes</option>
+                        <option value="0">If any unavailable</option>
+                        <option value="2">If all unavailable</option>
+                  </select>
+               </li>
+            </ol>
+            <p> To create circulation rule, go to <br>
+            More -> Administration -> Circulation and Fine Rules
+            </p>
 
-                     <li>
-                        <label for="onshelfholds">On shelf holds allowed: </label>
-                        <select name="onshelfholds" id="onshelfholds" required="required">
-                              <option value="">Choose</option>
-                              <option value="1" selected="selected">Yes</option>
-                              <option value="0">If any unavailable</option>
-                              <option value="2">If all unavailable</option>
-                        </select>
-                     </li>
-                  </ol>
-            </fieldset><br>
-                <input type="submit" class="action" value="Submit"/>
-     </form>
+        </fieldset><br>
+        <input type="submit" class="action" value="Submit"/>
+    </form>
 [% END %]