@@ -, +, @@ backends working successfully inserting into the database. --- .../en/{default => optional}/patron_categories.sql | 0 .../en/{default => optional}/patron_categories.txt | 0 .../en/{default => optional}/sample_itemtypes.sql | 0 .../en/{default => optional}/sample_itemtypes.txt | 0 installer/onboarding.pl | 430 ++++++++++++++++----- .../prog/en/modules/onboarding/onboardingstep0.tt | 54 +++ .../prog/en/modules/onboarding/onboardingstep1.tt | 42 +- .../prog/en/modules/onboarding/onboardingstep2.tt | 79 ++-- .../prog/en/modules/onboarding/onboardingstep3.tt | 92 ++--- .../prog/en/modules/onboarding/onboardingstep4.tt | 37 +- .../prog/en/modules/onboarding/onboardingstep5.tt | 168 ++------ koha-tmpl/intranet-tmpl/prog/en/modules/summary.tt | 2 +- 12 files changed, 554 insertions(+), 350 deletions(-) rename installer/data/mysql/en/{default => optional}/patron_categories.sql (100%) rename installer/data/mysql/en/{default => optional}/patron_categories.txt (100%) rename installer/data/mysql/en/{default => optional}/sample_itemtypes.sql (100%) rename installer/data/mysql/en/{default => optional}/sample_itemtypes.txt (100%) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt --- a/installer/onboarding.pl +++ a/installer/onboarding.pl @@ -6,31 +6,61 @@ use diagnostics; use Modern::Perl; + +#External modules use CGI qw ( -utf8 ); +use List::MoreUtils qw/uniq/; +use Digest::MD5 qw(md5_base64); +use Encode qw( encode ); + +#Internal modules use C4::Koha; use C4::Auth; use C4::Context; use C4::Output; +use C4::Members; +use C4::Members::Attributes; +use C4::Members::AttributeTypes; +use C4::Log; +use C4::Letters; +use C4::Form::MessagingPreferences; +use Koha::AuthorisedValues; +use Koha::Patron::Debarments; +use Koha::Cities; use Koha::Patrons; use Koha::Items; use Koha::Libraries; use Koha::LibraryCategories; - - -#use POSIX; -#use C4::Templates; -#use C4::Languages qw(getAllLanguages getTranslatedLanguages); -#use C4::Installer; -#use Koha; +use Koha::Database; +use Koha::DateUtils; +use Koha::Patron::Categories; +use Koha::ItemTypes; +use Koha::Patron::HouseboundRole; +use Koha::Patron::HouseboundRoles; +use Koha::Token; +use Email::Valid; +use Module::Load; + +#Imports for item types step 4 +use Koha::ItemTypes; +use Koha::Localizations; + +#Imports for circulation rule step 5 +use Koha::IssuingRule; +use Koha::IssuingRules; +use Koha::Logger; +use Koha::RefundLostItemFeeRule; +use Koha::RefundLostItemFeeRules; #Setting variables my $input = new CGI; my $query = new CGI; my $step = $query->param('step'); +#Getting the appropriate template to display to the user--> my ( $template, $loggedinuser, $cookie) = get_template_and_user( { - template_name => "/onboarding/onboardingstep" . ( $step ? $step : 1 ) . ".tt", + template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt", query => $query, type => "intranet", authnotrequired => 0, @@ -57,124 +87,348 @@ 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 = $query->param('op'); +$template->param('op'=>$op); +if ( $op && $op eq 'finish' ) { #If the value of $op equals 'finish' then redirect user to /cgi-bin/koha/mainpage.pl + print $query->redirect("/cgi-bin/koha/mainpage.pl"); + exit; +} - my $op = $query->param('op'); - $template->param('op'=>$op); - warn $op; - if ( $op && $op eq 'finish' ) { - print $query->redirect("/cgi-bin/koha/mainpage.pl"); - exit; - } - - - -#Performing each step of the onboarding tool -if ( $step && $step == 1 ) { -#This is the Initial step of the onboarding tool to create a library - - - my $createlibrary = $query->param('createlibrary'); - $template->param('createlibrary'=>$createlibrary); -#store inputted parameters in variables +#Store the value of the template input name='start' in the variable $start so we can check if the user has pressed this button and starting the onboarding tool process +my $start = $query->param('start'); +$template->param('start'=>$start); #Hand the start variable back to the template +if ( $start && $start eq 'Start setting up my Koha' ){ + 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' } ) ], + }, + ] + ); + + +#Select any library records from the database and hand them back to the template in the libraries variable. +}elsif ( $start && $start eq 'Add a patron category' ){ + +#Select all the patron category records in the categories database table and store them in the newly declared variable $categories + my $categories = Koha::Patron::Categories->search(); + $template->param( + categories => $categories, + ); #Hand the variable categories back to the template + +}elsif ( $start && $start eq 'Add an item type' ){ + my $itemtypes = Koha::ItemTypes->search(); + warn $itemtypes; + $template->param( + itemtypes => $itemtypes, + ); + +#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 +}elsif ( $step && $step == 1 ) { + + my $createlibrary = $query->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary + $template->param('createlibrary'=>$createlibrary); # Hand the library values back to the template in the createlibrary variable + + #store inputted parameters in variables my $branchcode = $input->param('branchcode'); my $categorycode = $input->param('categorycode'); my $op = $input->param('op') || 'list'; my @messages; my $library; -#Find branchcode if it exists - if ( $op eq 'add_form' ) { - if ($branchcode) { - $library = Koha::Libraries->find($branchcode); - } + #Take the text 'branchname' and store it in the @fields array + my @fields = qw( + branchname + ); - $template->param( - library => $library, - categories => [ Koha::LibraryCategories->search( {}, { order_by => [ 'categorytype', 'categoryname' ] } ) ], - $library ? ( selected_categorycodes => [ map { $_->categorycode } $library->get_categories ] ) : (), - ); - } elsif ( $op eq 'add_validate' ) { - my @fields = qw( - branchname - ); + $branchcode =~ s|\s||g; # Use a regular expression to check the value of the inputted branchcode - my $is_a_modif = $input->param('is_a_modif'); - - my @categories; - for my $category ( Koha::LibraryCategories->search ) { - push @categories, $category - if $input->param( "selected_categorycode_" . $category->categorycode ); - } - if ($is_a_modif) { - my $library = Koha::Libraries->find($branchcode); - for my $field (@fields) { - $library->$field( scalar $input->param($field) ); - } - $library->update_categories( \@categories ); + #Create a new library object and store the branchcode and @fields array values in this new library object + my $library = Koha::Library->new( + { branchcode => $branchcode, + ( map { $_ => scalar $input->param($_) || undef } @fields ) + } + ); - eval { $library->store; }; + eval { $library->store; }; #Use the eval{} function to store the library object - if ($@) { - push @messages, { type => 'alert', code => 'error_on_update' }; - } else { - push @messages, { type => 'message', code => 'success_on_update' }; - } - } else { - $branchcode =~ s|\s||g; - my $library = Koha::Library->new( - { branchcode => $branchcode, - ( map { $_ => scalar $input->param($_) || undef } @fields ) - } - ); - eval { $library->store; }; - $library->add_to_categories( \@categories ); - if ($@) { - push @messages, { type => 'alert', code => 'error_on_insert' }; - } else { - push @messages, { type => 'message', code => 'success_on_insert' }; - } - } - $op = 'list'; + #If there are values in the $@ then push the values type => 'alert', code => 'error_on_insert' into the @messages array el se push the values type => 'message', code => 'success_on_insert' to that array + if ($@) { + push @messages, { type => 'alert', code => 'error_on_insert' }; + } else { + push @messages, { type => 'message', code => 'success_on_insert' }; } - +#Check if the $step vairable equals 2 i.e. the user has clicked to create a patron category in the create patron category screen 1 }elsif ( $step && $step == 2 ){ - my $createpatroncategory = $query->param('createpatroncategory'); - $template->param('createpatroncategory'=>$createpatroncategory); + #Initialising values + my $input = new CGI; + my $searchfield = $input->param('description') // q||; + my $categorycode = $input->param('categorycode'); + my $op = $input->param('op') // 'list'; + my @messages; + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "/onboarding/onboardingstep2.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { parameters => 'parameters_remaining_permissions' }, + debug => 1, + } + ); + #When the user first arrives on the page + if ( $op eq 'add_form' ) { + my $category; + if ($categorycode) { + $category = Koha::Patron::Categories->find($categorycode); + } + + $template->param( + category => $category, + ); + + if ( C4::Context->preference('EnhancedMessagingPreferences') ) { + C4::Form::MessagingPreferences::set_form_values( + { categorycode => $categorycode }, $template ); + } + } + #Once the user submits the page, this code validates the input and adds it + #to the database as a new patron category + elsif ( $op eq 'add_validate' ) { + my $categorycode = $input->param('categorycode'); + my $description = $input->param('description'); + my $overduenoticerequired = $input->param('overduenoticerequired'); + my $category_type = $input->param('category_type'); + my $default_privacy = $input->param('default_privacy'); + my $enrolmentperiod = $input->param('enrolmentperiod'); + my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef; + + #Converts the string into a date format + if ( $enrolmentperioddate) { + $enrolmentperioddate = output_pref( + { + dt => dt_from_string($enrolmentperioddate), + dateformat => 'iso', + dateonly => 1, + } + ); + } + #Adds to the database + my $category = Koha::Patron::Category->new({ + categorycode=> $categorycode, + description => $description, + overduenoticerequired => $overduenoticerequired, + category_type=> $category_type, + default_privacy => $default_privacy, + enrolmentperiod => $enrolmentperiod, + enrolmentperioddate => $enrolmentperioddate, + }); + eval { + $category->store; + }; + + #Error messages + if($@){ + push @messages, {type=> 'error', code => 'error_on_insert'}; + }else{ + push @messages, {type=> 'message', code => 'success_on_insert'}; + } + } +#Create a patron }elsif ( $step && $step == 3 ){ - my $createpatron = $query->param('createpatron'); - $template->param('createpatron'=>$createpatron); + 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' } ) ], + }, + ] + ); + + my $categories; + $categories= Koha::Patron::Categories->search(); + $template->param( + categories => $categories, + ); -}elsif ( $step && $step == 4){ - my $createitemtype = $query->param('createitemtype'); - $template->param('createitemtype'=>$createitemtype); -}elsif ( $step && $step == 5){ + my $input = new CGI; + my $op = $input->param('op'); + my @messages; - my $createcirculationrule = $query->param('createcirculationrule'); - $template->param('createcirculationrule'=>$createcirculationrule); + my ($template, $loggedinuser, $cookie) + = get_template_and_user({ + template_name => "/onboarding/onboardingstep3.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); + if($op eq 'add_form'){ + my $member; + $template->param( + member => $member, + ); -} + } + elsif($op eq 'add_validate'){ + my $surname => $input->param('surname'); + my $firstname => $input->param('firstname'); + my $cardnumber => $input->param('cardnumber'); + my $libraries => $input->param('libraries'); + my $categorycode_entry => $input->param('categorycode_entry'); + my $userid => $input->param('userid'); + my $password => $input->param('password'); + my $password2 =>$input->param('password2'); + + my $member = Koha::Patron->new({ + surname => $surname, + firstname => $firstname, + cardnumber => $cardnumber, + libraries => $libraries, + categorycode_entry => $categorycode_entry, + userid => $userid, + password => $password, + password2 => $password2, + }); + eval { + $member->store; + }; + if($@){ + push @messages, {type=> 'error', code => 'error_on_insert'}; + }else{ + push @messages, {type=> 'message', code => 'success_on_insert'}; + } + + } +#Create item type +}elsif ( $step && $step == 4){ + my $input = new CGI; + my $itemtype_code = $input->param('itemtype'); + my $op = $input->param('op') // 'list'; + my @messages; + my( $template, $borrowernumber, $cookie) = 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_form'){ + my $itemtype = Koha::ItemTypes->find($itemtype_code); + template->param(itemtype=>$itemtype,); + }elsif($op eq 'add_validate'){ + my $itemtype = Koha::ItemTypes->find($itemtype_code); + my $description = $input->param('description'); + + #store the input from the form - only 2 fields + my $itemtype= Koha::ItemType->new( + { itemtype => $itemtype_code, + description => $description, + } + ); + eval{ $itemtype->store; }; + #Error messages + if($@){ + push @messages, {type=> 'error', code => 'error_on_insert'}; + }else{ + push @messages, {type=> 'message', code => 'success_on_insert'}; + } + } +}elsif ( $step && $step == 5){ + #Fetching all the existing categories to display in a drop down box + my $categories; + $categories= Koha::Patron::Categories->search(); + $template->param( + categories => $categories, + ); + + my $itemtypes; + $itemtypes= Koha::ItemTypes->search(); + $template->param( + itemtypes => $itemtypes, + ); + + my $input = CGI->new; + my($template, $loggedinuser, $cookie) =get_template_and_user({ + template_name => "/onboarding/onboardingstep5.tt", + query => $input, + type => "intranet", + authnotrequired=>0, + flagsrequired=> {parameters => 'manage_circ_rules'}, + debug =>1, + }); + + my $type = $input->param('type'); + my $branch = $input->param('branch'); + + + + if($op eq 'add_form'){ -output_html_with_http_headers $input, $cookie, $template->output; + } + elsif($op eq 'add_validate'){ + my $bor = $input->param('categorycode'); + my $itemtype = $input->param('itemtype'); + my $maxissueqty = $input->param('maxissueqty'); + my $issuelength = $input->param('issuelength'); + #$issuelength = $issuelength eq q{} ? undef : $issuelength; + my $lengthunit = $input->param('lengthunit'); + my $renewalsallowed = $input->param('renewalsallowed'); + my $renewalperiod = $input->param('renewalperiod'); + my $onshelfholds = $input->param('onshelfholds'); + + my $params ={ + categorycode => $bor, + itemtype => $itemtype, + maxissueqty => $maxissueqty, + renewalsallowed => $renewalsallowed, + renewalperiod => $renewalperiod, + lengthunit => $lengthunit, + onshelfholds => $onshelfholds, + }; + my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype}); + if($issuingrule){ + $issuingrule->set($params)->store(); + }else{ + Koha::IssuingRule->new()->set($params)->store(); + } + + } + +} +output_html_with_http_headers $input, $cookie, $template->output; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt @@ -0,0 +1,54 @@ + +[% INCLUDE 'doc-head-open.inc' %] +[% INCLUDE 'installer-doc-head-close.inc' %] + + + +Welcome › to › Koha + + + + + + + +
+

Welcome to Koha

+

Koha

+

We're just going to set up a few things......

+
+ + +
+
+ + + + + + + --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt @@ -1,7 +1,5 @@ [% INCLUDE 'doc-head-open.inc' %] - -[% IF ( finish ) %][% END %] [% INCLUDE 'installer-doc-head-close.inc' %] @@ -31,41 +29,49 @@ } }); [% END %].. - }); - //]]> + }); +//]]> +

Welcome to Koha

Koha

-

We're just going to set up a few things

- - -[% IF (createlibrary) %] + [% IF libraries.count > 0 %] +
+

You do not need to create a library as you have already installed the sample library data previously

+
+ +
+ +
+
+ + +[% ELSIF (createlibrary) %]

New Library

- -
+

Success: Library created!

To add another library and for more settings,
go to Tools->Administration->Libraries and Groups

Next up: - + - + -[% ELSE %] - -

New Library

+[% ELSE %] + +

Create a Library

@@ -85,9 +91,11 @@

- +
-[% END %] +[% END %] + + --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt @@ -4,8 +4,6 @@ [% USE Price %] [% INCLUDE 'doc-head-open.inc' %] - -[% IF ( finish ) %][% END %] [% INCLUDE 'installer-doc-head-close.inc' %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %] @@ -13,7 +11,6 @@ Add a patron category - - -
+

Welcome to Koha

Koha

- -[% IF (createpatroncategory) %] - + +[% IF categories.count > 0 %] +
+

You do not need to create a patron category as you have already installed the sample patron categories data previously

+
+ +
+ +
+
+ + +[% ELSIF op == 'add_validate' %]
-

New patron category

+

New patron category

Success: Patron category created!

To add another patron category and for more settings
go to More->Administration->Patrons & Circulation->Patron Categories

Next up:
- +
-[% ELSE %] -

New Patron Category

- +[% ELSE %] +

Create a new Patron Category

-
+
-
  1. - + Required
  2. - + Required
  3. - [% IF category.overduenoticerequired %] @@ -80,7 +84,7 @@
  4. - [% UNLESS category %] [% ELSE %] @@ -128,7 +132,7 @@
  5. - [% SET default_privacy = 'default' %] [% IF category %] @@ -153,46 +157,25 @@

    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 batch_anonymise.pl which should be set up by your system administrator.

  6. - Enrollment period: + Enrolment period: +
    - Choose one + Choose one
    1. - months + months
    2. - +
    -
    - +
    + [% END %] - - - --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt @@ -1,27 +1,33 @@ - + +[% USE Koha %] +[% USE KohaDates %] +[% USE Price %] + [% INCLUDE 'doc-head-open.inc' %] +[% IF ( finish ) %][% END %] + -[% IF ( finish ) %][% END %] [% INCLUDE 'installer-doc-head-close.inc' %] +[% INCLUDE 'calendar.inc' %] +[% INCLUDE 'datatables.inc' %] + Create Patron - - - +

    Welcome to Koha

    Koha

    - -[% IF (createpatron) %] +[% IF op == 'add_validate' %] -
    +

    New Patron

    @@ -31,82 +37,82 @@ More > Set Permissions in a user page to gain superlibrarian permissions.
Next up: - + -
+ [% ELSE %] -

New Patron

-
+

Create a new Patron

+
-

    Patron Identity

  1. - + Required
  2. - + Required
+ + Library Management
    -

    Library Management

  1. - - + + Required
  2. - + + + + Required
  3. - + + + Required

    OPAC/Staff Login

  1. - - + + Required
  2. - + Required
  3. - - + + Required
-
-
+

-
[% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt @@ -17,13 +17,23 @@

Welcome to Koha

Koha

- + +[% IF itemtypes.count > 0 %] +
+

You do not need to create a item type as you have already installed the sample item type data previously

+
+ +
+ +
+
+ + -[% IF (createitemtype) %] +[% ELSIF op == "add_validate" %]
-

New Item type

@@ -32,38 +42,33 @@ go to More->Administration->Item types
Next up: - -
- Or: - +
+ [% ELSE %] -

New Item type

-
+

Create a new Item type

+
-
  1. - + Required
  2. - + Required
-
-
+

-
[% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt @@ -25,12 +25,12 @@ [% END %] -[% IF (createcirculationrule) %] +[% IF op == "add_validate" %]
-

New Item type

+

New Circulation rule

Success: New circulation rule created!

@@ -38,145 +38,58 @@ More->Administration->Circulation and Fine Rules
Next up: - +
-
+ [% ELSE %] -

New Circulation rule

-
+

Create a new Circulation rule

+ +
-
    -
  1. - - +
  2. + + Required
  3. - - + [% FOREACH item IN itemtypes %] +
  4. - - + + Required
  5. - - + + Required
  6. - - [% SET units = 'days' %] [% IF category %] @@ -208,34 +121,15 @@
  7. - - - [% CASE 'anyunavailable' %] - - - - [% CASE 'allunavailable' %] - - - - [% END %] +
-
-
- -
+
+
[% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/summary.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/summary.tt @@ -13,7 +13,7 @@

Tutorial Summary Page

-
+

Library

To add another library and for more settings, go to
More > Administration > Libraries and Groups

--