@@ -, +, @@ step 3 is showing bulletpoints for default data values which stops the user being able to unselect data neccisary to use Koha. --- .../en/{optional => default}/patron_categories.sql | 0 .../en/{optional => default}/patron_categories.txt | 0 installer/onboarding.pl | 142 ++++++++++++++ .../prog/en/modules/installer/step3.tt | 102 +++++----- .../en/modules/onboarding/.onboardingstep1.tt.swp | Bin 0 -> 36864 bytes .../en/modules/onboarding/.onboardingstep2.tt.swp | Bin 0 -> 20480 bytes .../prog/en/modules/onboarding/onboardingstep1.tt | 109 +++++++++++ .../prog/en/modules/onboarding/onboardingstep2.tt | 213 +++++++++++++++++++++ 8 files changed, 518 insertions(+), 48 deletions(-) rename installer/data/mysql/en/{optional => default}/patron_categories.sql (100%) rename installer/data/mysql/en/{optional => default}/patron_categories.txt (100%) create mode 100755 installer/onboarding.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/.onboardingstep1.tt.swp create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/.onboardingstep2.tt.swp create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt --- a/installer/onboarding.pl +++ a/installer/onboarding.pl @@ -0,0 +1,142 @@ +#!/usr/bin/perl +#Recommended pragmas +use strict; +use warnings; +use diagnostics; + + +use C4::Koha; +#Pragmas for creating library +use Modern::Perl; +use CGI qw (-utf8); +use C4::Auth; +use C4::Context; +use C4::Output; +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 installer::install.pl; + +#Setting variables from install.pl origin +my $query = new CGI; +my $step = $query->param('step'); + +my ( $template, $loggedinuser, $cookie) = get_template_and_user( + { + template_name => "/onboarding/onboardingstep" . ( $step ? $step : 1 ) . ".tt", + query => $query, + type => "intranet", + authnotrequired => 0, + debug => 1, + } +); + +#Check database connection +my %info; +$info{'dbname'} = C4::Context->config("database"); +$info{'dbms'} = +( C4::Context->config("db_scheme") + ? C4::Context->config("db_scheme") + : "mysql" ); + +$info{'hostname'} = C4::Context->config("hostname"); +$info{'port'} = C4::Context->config("port"); +$info{'user'} = C4::Context->config("user"); +$info{'password'} = C4::Context->config("pass"); +my $dbh = DBI->connect( + "DBI:$info{dbms}:dbname=$info{dbname};host=$info{hostname}" + . ( $info{port} ? ";port=$info{port}" : "" ), + $info{'user'}, $info{'password'} +); + + + + +#Performing each step of the onboarding tool +if ( $step && $step == 1 ) { +#This is the Initial step of the onboarding tool to create a library + +#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); + } + + $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 + ); + + 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 ); + + eval { $library->store; }; + + 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 ($op eq 'list'){ + print redirect(-url=>'koha/cgi-bin/koha/onboarding/onboarding.cgi?step=2'); + } + +} + + + + + + + + + --- a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt @@ -1,5 +1,5 @@ [% INCLUDE 'doc-head-open.inc' %]
If this page does not redirect in 5 seconds, click here.
+If this page does not redirect in 5 seconds, click here.
[% END %] [% IF ( choosemarc ) %][% FOREACH flavourloo IN flavourloop %]
- [% IF (frameworksloo.label == "Default" ) %]
-
+
+
- [% END %]
+ [% END %]
+
+ [% END %]
[% frameworksloo.label %]+ [% FOREACH framework IN frameworksloo.frameworks %] +
Other data- [% END %] - [% IF ( en_sample_data ) %] -No sample data and settings ar e available for your language. - 132 Defaulting to the samples supplied for English (en)- [% END %] + [% END %] + [% IF ( en_sample_data ) %] +No sample data and settings are available for your language. + Defaulting to the samples supplied for English (en)+ [% END %] [% FOREACH levelloo IN levelloop %][% levelloo.label %]@@ -151,19 +151,24 @@
[% IF (levelloo.label == "Default" ) %]
-
+<<<<<<< HEAD
+
+=======
+ |
[% IF (levelloo.label == "Default") %]
- |
[% ELSE %]
@@ -201,7 +206,8 @@
+
+
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt
@@ -0,0 +1,109 @@
+
+
+
+[% INCLUDE 'doc-head-open.inc' %]
+
+
+ |
+
+
+
+[% IF (setupmyKoha) %]
+ Welcome to Koha+ +New Library ++[% END %] + + +[% IF (createlibrary) %] + [% IF (library) %] + + + [% ELSE %] +
+
+ [% END %]
+ [% END %]
+
+
+
+
+
+
+
+
+
+
+
+
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt
@@ -0,0 +1,213 @@
+
+[% USE Koha %]
+[% USE KohaDates %]
+[% USE Price %]
+[% INCLUDE 'doc-head-open.inc' %]
+[% INCLUDE 'doc-head-close.inc' %]
+[% INCLUDE 'calendar.inc' %]
+[% INCLUDE 'datatables.inc' %]
+
+
+
+Library was not successfully created +
+
+
+
+ [% FOR m IN messages %]
+
+ [% SWITCH m.code %]
+ [% CASE 'error_on_insert' %]
+ An error occurred when inserting this patron category. The patron category might already exist.
+ [% CASE 'success_on_insert' %]
+ Patron category inserted successfully.
+ [% CASE 'already_exists' %]
+ This patron category already exists.
+ [% CASE %]
+ [% m.code %]
+ [% END %]
+
+ [% END %]
+
+ |