View | Details | Raw Unified | Return to bug 17855
Collapse All | Expand All

(-)a/installer/onboarding.pl (+143 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
#Recommended pragmas
3
use strict;
4
use warnings;
5
use diagnostics;
6
7
8
use C4::Koha;
9
#Pragmas for creating library
10
use Modern::Perl;
11
use CGI qw (-utf8);
12
use C4::Auth;
13
use C4::Context;
14
use C4::Output;
15
use Koha::Items;
16
use Koha::Libraries;
17
use Koha::LibraryCategories;
18
19
20
use POSIX;
21
use C4::Templates;
22
use C4::Languages qw(getAllLanguages getTranslatedLanguages);
23
use C4::Installer;
24
use Koha;
25
use installer::install.pl;
26
27
#Setting variables from install.pl origin
28
my $query    = new CGI;
29
my $step     = $query->param('step');
30
31
my ( $template, $loggedinuser, $cookie) = get_template_and_user(
32
     {
33
        template_name => "/onboarding/onboardingstep" . ( $step ? $step : 1 ) . ".tt",
34
        query         => $query,
35
        type          => "intranet",
36
        authnotrequired => 0,
37
        debug           => 1,
38
    }
39
);
40
41
#Check database connection
42
my %info;
43
$info{'dbname'} = C4::Context->config("database");
44
$info{'dbms'} =
45
(   C4::Context->config("db_scheme")
46
    ? C4::Context->config("db_scheme")
47
     : "mysql" );
48
49
$info{'hostname'} = C4::Context->config("hostname");
50
$info{'port'}     = C4::Context->config("port");
51
$info{'user'}     = C4::Context->config("user");
52
$info{'password'} = C4::Context->config("pass");
53
my $dbh = DBI->connect(
54
         "DBI:$info{dbms}:dbname=$info{dbname};host=$info{hostname}"
55
          . ( $info{port} ? ";port=$info{port}" : "" ),
56
           $info{'user'}, $info{'password'}
57
);
58
59
60
61
62
#Performing each step of the onboarding tool
63
if ( $step && $step == 1 ) {
64
#This is the Initial step of the onboarding tool to create a library 
65
66
#store inputted parameters in variables
67
    my $branchcode       = $input->param('branchcode');
68
    my $categorycode     = $input->param('categorycode');
69
    my $op               = $input->param('op') || 'list';
70
    my @messages;
71
    my $library;
72
73
#Find branchcode if it exists
74
    if ( $op eq 'add_form' ) {
75
        if ($branchcode) {
76
            $library = Koha::Libraries->find($branchcode);
77
         }
78
79
        $template->param(
80
            library    => $library,
81
            categories => [ Koha::LibraryCategories->search( {}, { order_by => [ 'categorytype', 'categoryname' ] } ) ],
82
            $library ? ( selected_categorycodes => [ map { $_->categorycode } $library->get_categories ] ) : (),
83
        );
84
    } elsif ( $op eq 'add_validate' ) {
85
        my @fields = qw(
86
            branchname
87
        );
88
89
        my $is_a_modif = $input->param('is_a_modif');
90
91
        my @categories;
92
        for my $category ( Koha::LibraryCategories->search ) {
93
            push @categories, $category
94
                if $input->param( "selected_categorycode_" . $category->categorycode );
95
         }
96
        if ($is_a_modif) {
97
            my $library = Koha::Libraries->find($branchcode);
98
            for my $field (@fields) {
99
                 $library->$field( scalar $input->param($field) );
100
            }
101
            $library->update_categories( \@categories );
102
103
            eval { $library->store; };
104
105
            if ($@) {
106
                push @messages, { type => 'alert', code => 'error_on_update' };
107
            } else {
108
                push @messages, { type => 'message', code => 'success_on_update' };
109
            }
110
        } else {
111
            $branchcode =~ s|\s||g;
112
            my $library = Koha::Library->new(
113
                 {   branchcode => $branchcode,
114
                    ( map { $_ => scalar $input->param($_) || undef } @fields )
115
                }
116
            );
117
            eval { $library->store; };
118
            $library->add_to_categories( \@categories );
119
            if ($@) {
120
                push @messages, { type => 'alert', code => 'error_on_insert' };
121
            } else {
122
                push @messages, { type => 'message', code => 'success_on_insert' };
123
            }
124
        }
125
            $op = 'list';
126
        [% END %]
127
128
        if ($op eq 'list'){
129
             print redirect(-url=>'koha/cgi-bin/koha/onboarding/onboarding.cgi?step=2');
130
        }
131
        [% END %]
132
[% END %]
133
[% END %]
134
135
136
137
138
139
140
141
142
143
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt (-44 / +47 lines)
Lines 1-5 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]<title>Koha &rsaquo; Web installer &rsaquo; Step 3</title>
1
[% INCLUDE 'doc-head-open.inc' %]<title>Koha &rsaquo; Web installer &rsaquo; Step 3</title>
2
[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END %]
2
[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/installer/onboarding.pl">[% END %]
3
[% INCLUDE 'installer-doc-head-close.inc' %]
3
[% INCLUDE 'installer-doc-head-close.inc' %]
4
<div>
4
<div>
5
<h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif" /> Koha web  installer &rsaquo; Step 3</h1>
5
<h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif" /> Koha web  installer &rsaquo; Step 3</h1>
Lines 64-70 Link Here
64
[% END %]
64
[% END %]
65
[% IF ( finish ) %]
65
[% IF ( finish ) %]
66
    <h1>Congratulations, installation complete</h1>
66
    <h1>Congratulations, installation complete</h1>
67
    <p>If this page does not redirect in 5 seconds, click <a href="/">here</a>.</p>
67
    <p>If this page does not redirect in 5 seconds, click <a href="/cgi-bin/koha/installer/onboarding.pl">here</a>.</p>
68
[% END %]
68
[% END %]
69
[% IF ( choosemarc ) %]
69
[% IF ( choosemarc ) %]
70
    <h2 align="center">Select your MARC flavor</h2>
70
    <h2 align="center">Select your MARC flavor</h2>
Lines 97-147 Link Here
97
    <input type="hidden" name="step" value="3" />
97
    <input type="hidden" name="step" value="3" />
98
    <input type="hidden" name="op" value="addframeworks" />
98
    <input type="hidden" name="op" value="addframeworks" />
99
99
100
      [% IF ( frameworksloop ) %]
100
    [% IF ( frameworksloop ) %]
101
      <h2>MARC frameworks: [% marcflavour %]</h2>
101
    <h2>MARC frameworks: [% marcflavour %]</h2>
102
      [% IF ( en_marc_frameworks ) %]
102
    [% IF ( en_marc_frameworks ) %]
103
      <h4><span class="error">No MARC frameworks are available for your language.                 Defaulting to the frameworks supplied for English (en)<span></h4>
103
        <h4><span class="error">No MARC frameworks are available for your language.
104
      [% END %]
104
                Defaulting to the frameworks supplied for English (en)<span></h4>
105
      [% FOREACH frameworksloo IN frameworksloop %]
105
    [% END %]
106
      <div>
106
    [% FOREACH frameworksloo IN frameworksloop %]
107
      <h3>[% frameworksloo.label %]</h3>
107
    <div>
108
      [% FOREACH framework IN frameworksloo.frameworks %]         <table style="border:1px;vertical-align:top;">
108
    <h3>[% frameworksloo.label %]</h3>
109
      <tr>
109
    [% FOREACH framework IN frameworksloo.frameworks %]
110
        <table style="border:1px;vertical-align:top;">
111
        <tr>
110
         <td style = "border:1px; vertical-align:top;">
112
         <td style = "border:1px; vertical-align:top;">
111
        [% IF (frameworksloo.label == "Default" ) %]   
113
         [% IF (frameworksloo.label == "Default" ) %]   
112
        <input type="hidden" name="framework" value="[%     framework.fwkfile %]" id =="[%framework.fwkname%]" />
114
            <ul>
113
        [% ELSE %]
115
            </ul>
114
             <input type="checkbox" name="framework" value="[% framework.fwkfile %]" id =="[%framework.fwkname%]" />
116
         [% ELSE %]
117
            <input type="checkbox" name="framework" value="[% framework.fwkfile %]" id =="[%framework.fwkname%]" />
115
         [% END %]
118
         [% END %]
116
      </td>
119
        </td>
117
      <td>
120
        <td>
118
      [% IF (frameworksloo.label == "Default" ) %]
121
        [% IF (frameworksloo.label == "Default" ) %]
119
        <ul>
122
        <ul>
120
        <label for="[% framework.fwkname %]">
123
            <label for="[% framework.fwkname %]">
121
            <li>[% framework.fwkdescription %]</li>
124
               <li> [% framework.fwkdescription %]</li>
122
            <em>([% framework.fwkname %])</em>
125
                 <em>([% framework.fwkname %])</em>   
123
        </label>
126
            </label>
124
        </ul>
127
            </ul>
125
      </td>
128
         </td>
126
      [% ELSE %]
129
        [% ELSE %]
127
      <td>
130
        <td>
128
         <label for= "[% framework.fwkname %]">
131
            <label for= "[% framework.fwkname %]">
129
            [% framework.fwkdescription %]
132
                [% framework.fwkdescription %]
130
            <em>([% framework.fwkname %])</em>
133
                <em>([% framework.fwkname %])</em>
131
         </label>
134
            </label>
132
      </td>
135
        </td>
133
      [% END %]
136
        [% END %]
134
      </tr>
137
        </tr>
135
        </table>
138
        </table>
136
      [% END %]
139
    [% END %]
137
      </div>
140
    </div>
138
      [% END %]
141
    [% END %]
139
    <h2>Other data</h2>
142
    <h2>Other data</h2>
140
                  [% END %]
143
    [% END %]
141
                  [% IF ( en_sample_data ) %]
144
    [% IF ( en_sample_data ) %]
142
                      <h4><span class="error">No sample data and settings ar    e available for your language.
145
        <h4><span class="error">No sample data and settings are available for your language.
143
             132                 Defaulting to the samples supplied for English     (en)<span></h4>
146
                Defaulting to the samples supplied for English (en)<span></h4>
144
                 [% END %]
147
    [% END %]
145
    [% FOREACH levelloo IN levelloop %]
148
    [% FOREACH levelloo IN levelloop %]
146
    <div>
149
    <div>
147
    <h3>[% levelloo.label %]</h3>
150
    <h3>[% levelloo.label %]</h3>
Lines 157-168 Link Here
157
        </td>
160
        </td>
158
        <td>
161
        <td>
159
        [% IF (levelloo.label == "Default") %]
162
        [% IF (levelloo.label == "Default") %]
160
           <ul>
163
            <ul>
161
            <label for="[% framework.fwkname %]">
164
            <label for="[% framework.fwkname %]">
162
               <li> [% framework.fwkdescription %]</li>
165
               <li> [% framework.fwkdescription %]</li>
163
                <em>([% framework.fwkname %])</em>
166
                <em>([% framework.fwkname %])</em>
164
            </label>
167
            </label>
165
           </ul>
168
            </ul>
166
        </td>
169
        </td>
167
        [% ELSE %]
170
        [% ELSE %]
168
        <td>
171
        <td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt (+109 lines)
Line 0 Link Here
1
2
3
<!--Includes for creating library--> 
4
[% INCLUDE 'doc-head-open.inc' %]
5
6
<head>
7
<title>Welcome &rsaquo; to  &rsaquo; Koha</title>
8
9
<!--jQuery code for create library-->
10
<script type="text/javascript" src="[% interface %]/lib/tiny_mce/tiny_mce.js"></script>
11
<script type="text/javascript">
12
    //<![CDATA[
13
          $(document).ready(function() {
14
                  $("#branchest").dataTable($.extend(true, {}, dataTablesDefaults, {
15
                     "aoColumnDefs": [
16
                         { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
17
                     ],
18
                     "iDisplayLength": 10,
19
                     "sPaginationType": "four_button"
20
                  }));
21
22
                  [% UNLESS library %]
23
                      $("#Aform").on("submit", function( event ) {
24
                               if ( $("#branchcode").val().match(/\s/) ) {
25
                                 event.preventDefault();
26
                                 alert(_("The library code entered contains whitespace characters. Please remove any whitespace     characters from the library code"));
27
                                 return false;
28
                                } else {
29
                                 return true;
30
                                }
31
                       });
32
                 [% END %]..
33
         });
34
    //]]>
35
</script>
36
</head>
37
38
[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END %]
39
[% INCLUDE 'installer-doc-head-close.inc' %]
40
<div>
41
    <h1 align="center"> Welcome to Koha</h1>
42
    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/></h1>
43
    <form name="startonboarding" method="post" action="onboarding.pl">
44
    <input type="hidden" name="step" value="0">
45
    <a href="onboarding.pl?setupmyKoha=yes" <button>Set up my koha</button></a>
46
</div>
47
48
<!--Onboarding tool step 1 - Create a new library screen 1-->
49
[% IF (setupmyKoha) %]
50
    <h1 align="left"> New Library</h2>
51
        <form name="LibraryCreation" method="post" action="onboarding.pl">
52
            <fieldset class="rows">
53
                 <input type="hidden" name="step" value="1"/>
54
                 <input type="hidden" name="op" value="add_validate" />
55
                 <input type="hidden" name="op" value="createlibrary"/>
56
                 <ol>
57
                     <li>
58
                        <label for="branchcode" class="required">Library code: </label>
59
                        <input type="text" name="branchcode" id="branchcode" size="10" maxlength="10" value="[% library.branchcode |html %]" class="required" required="required" />
60
                        <span class="required">Required</span>
61
                    </li>
62
                    <li>
63
                        <label for="branchname" class="required">Name: </label>
64
                        <input type="text" name="branchname" id="branchname" size="80" value="[% library.branchname |html %]" class="    required" required="required" />
65
                        <span class="required">Required</span>
66
                    </li>
67
                 </ol>
68
             </fieldset>
69
            <fieldset class="action">
70
                <input type="submit" value="Create Library"/>
71
            </fieldset>
72
     </form>
73
[% END %]
74
75
<!--Create a library screen 2-->
76
[% IF (createlibrary) %]
77
    [% IF (library) %]
78
        <!--New Library created-->
79
        <form name="createlibrary" method="post" action="onboarding.pl">
80
            <input type="hidden" name="step" value="1"/>
81
            <input type="hidden" name="op" value="addpatroncategory"/>
82
            <h1 align="left"> New Library</h1>
83
84
            <div>   
85
                 <p> Success: Library created!</p><br>
86
                 <p> To add another library and for more settings, <br>
87
                go to Tools->Administration->Libraries and Groups
88
                </div>
89
                 Next up:
90
                 <input type="submit" value="Add a patron category"/>
91
             </form>
92
         [% ELSE %] <!-- Library not created successfully-->
93
                 <div>
94
                    <p> Library was not successfully created</p>
95
                 </div>
96
         [% END %]
97
    [% END %]
98
99
100
101
102
103
104
105
106
107
108
109
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt (-1 / +213 lines)
Line 0 Link Here
0
- 
1
<!--Pragmas for using and including packages for create patron category-->
2
[% USE Koha %]
3
[% USE KohaDates %]
4
[% USE Price %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'calendar.inc' %]
8
[% INCLUDE 'datatables.inc' %]
9
10
11
<head>
12
<title> Add a patron category</title>
13
14
<!--JQuery scripts for create patron category-->
15
<script type="text/javascript">
16
     var MSG_CATEGORYCODE_CHARS = _("Category code can only contain the following characters: letters, numbers, - and _.");
17
     var MSG_BOTH_ENROLLMENTPERIODS = _("Please choose only one enrollment period setting.");
18
     var MSG_ONE_ENROLLMENTPERIOD = ("Please choose an enrollment period in months OR by date.");
19
</script>
20
<script type="text/javascript" src="[% themelang %]/js/categories.js"></script>
21
<style type="text/css">#enrolmentmessage.hint { display : none; }</style>
22
23
</head>
24
25
     [% IF (addpatroncategory) %]
26
         <!--Onboarding tool step 2-Create a patron category screen 1-->........
27
         <div id="doc3" class="yui-t2">
28
            <div id="bd">
29
                <div id="yui-main">
30
                <div class="yui-b">
31
         [% FOR m IN messages %]
32
            <div class="dialog [% m.type %]">
33
                [% SWITCH m.code %]
34
                    [% CASE 'error_on_insert' %]
35
                        An error occurred when inserting this patron category. The patron category might already exist.
36
                    [% CASE 'success_on_insert' %]
37
                         Patron category inserted successfully.
38
                    [% CASE 'already_exists' %]
39
                         This patron category already exists.
40
                    [% CASE %]
41
                        [% m.code %]
42
                    [% END %]
43
            </div>
44
        [% END %]
45
46
        <form id="category_form" action="/cgi-bin/koha/admin/categories.pl" method="post">
47
            <input type="hidden" name="step" value="2"/>
48
            <input type="hidden" name="op" value="add_validate" />
49
            <input type="hidden" name="op" value="addpatroncategory"/>
50
51
            <h1 align="left"> New Patron Category</h2>
52
            <div style="border-width:5px;">
53
                <fieldset class="rows">
54
                     <ol>
55
                        <li>
56
                            <label for="categorycode" class="required">Category code: </label>
57
                            <input type="text" name="categorycode" id="categorycode" size="10" maxlength="10" class="required" re    quir    ed="required" />
58
                             <span class="required">Required</span>
59
                        </li>
60
61
                        <li>
62
                            <label for="description" class="required">Description: </label>
63
                            <input type="text" name="description" id="description" size="40" maxlength="80" class="required" requ    ired="re    quired" value="[% category.description |html %]" />
64
                            <span class="required">Required</span>
65
                        </li>
66
67
                        <li>
68
                             <label for="overduenoticerequired">Overdue notice required: </label>
69
                             <select name="overduenoticerequired" id="overduenoticerequired">
70
                                [% IF category.overduenoticerequired %]
71
                                    <option value="0">No</option>
72
                                    <option value="1" selected="selected">Yes</option>
73
                                [% ELSE %]
74
                                    <option value="0" selected="selected">No</option>
75
                                    <option value="1">Yes</option>
76
                                [% END %]
77
                            </select>
78
                        </li>
79
80
                        <li>
81
                            <label for="category_type" class="required">Category type: </label>
82
                            <select name="category_type" id="category_type">
83
                                [% UNLESS category %]
84
                                <option value="" selected="selected">Select a category type</option>
85
                                [% ELSE %]
86
                                <option value="">Select a category type</option>
87
                                [% END %]
88
89
                                [% IF category and category.category_type == 'A' %]
90
                                <option value="A" selected="selected">Adult</ option>
91
                                [% ELSE %]
92
                                <option value="A">Adult</option>
93
                                [% END %]
94
95
                                [% IF category and category.category_type == 'C' %]
96
                                <option value="C" selected="selected">Child</ option>
97
                                [% ELSE %]
98
                                <option value="C">Child</option>[% END %]
99
100
                                [% IF category and category.category_type == 'S' %]
101
                                <option value="S" selected="selected">Staff</option>
102
                                [% ELSE %]
103
                                <option value="S">Staff</option>
104
                                [% END %]
105
106
                                [% IF category and category.category_type == 'I' %]
107
                                <option value="I" selected="selected">Organization</option>
108
                                [% ELSE %]
109
                                <option value="I">Organization</option>
110
                                [% END %]
111
112
                                [% IF category and category.category_type == 'P' %]
113
                                <option value="P" selected="selected">Professional</option>
114
                                [% ELSE %]
115
                                <option value="P">Professional</option>
116
                                [% END %]
117
118
                                [% IF category and category.category_type == 'X' %]
119
                                <option value="X" selected="selected">Statistical</option>
120
                                [% ELSE %]
121
                                <option value="X">Statistical</option>
122
                                [% END %]
123
                            </select>
124
                            <span class="required">Required</span>
125
                        </li>
126
127
                        <li>
128
                            <label for="default_privacy">Default privacy: </label>
129
                            <select id="default_privacy" name="default_privacy">
130
                                [% SET default_privacy = 'default' %]
131
                                
132
                                [% IF category %]
133
                                [% SET default_privacy = category.default_privacy %]
134
                                [% END %]
135
                            
136
                                [% SWITCH default_privacy %]
137
                                [% CASE 'forever' %]
138
                                    <option value="default">Default</option>
139
                                    <option value="never">Never</option>
140
                                    <option value="forever" selected="selected">Forever</option>
141
                                [% CASE 'never' %]
142
                                    <option value="default">Default</option>
143
                                    <option value="never" selected="selected">Never</option>
144
                                    <option value="forever">Forever</option>
145
                                [% CASE %]
146
                                    <option value="default" selected="selected">Default</option>
147
                                    <option value="never">Never</option>
148
                                    <option value="forever">Forever</option>
149
                                [% END %]
150
                            </select>
151
                            <span>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.</span>
152
                        </li>
153
154
                        <li>
155
                             <span class="label">Enrollment period: </span>
156
                             <fieldset>
157
                                <legend>Choose one</legend>
158
                                    <ol>
159
                                         <li>
160
                                             <label for="enrolmentperiod" style="width:6em;">In months: </label>
161
                                             <input type="text" class="enrollmentperiod" name="enrolmentperiod" id="enrolmentperio    d" size="3"     maxlength="3" value="[% IF category.enrolmentperiod %][% category.enrolmentperiod %][% END %]" /> months
162
                                        </li>
163
                                        <li>
164
                                         <label for="enrolmentperioddate" style="width:6em;">Until date: </label>
165
                                          <input type="text" class="enrollmentperiod" name="enrolmentperioddate" id="enrolmentp    erioddate" value="[% category.enrolmentperioddate | $KohaDates %]" />
166
                                        </li>
167
                                    </ol>
168
                            </fieldset>
169
                        </li>
170
171
                        <fieldset class="action">
172
                            <input type="submit" value="Create Patron Category" />
173
                        </fieldset>
174
                    </form>
175
                 [% END %]
176
177
                 [% IF (addpatroncategory) %]
178
                    [% IF (categorycode) %]
179
                     <form name="createpatroncategory" method="post" action="onboarding.pl">...
180
                     <input type="hidden" name="op" value="addpatron"/>
181
                     <h1 align="left"> New patron category</h1>
182
                        <div style="border-width:5px;">.
183
                            <p> Success: Patron category created!</p>
184
                            <p> To add another patron category and for more settings<br>
185
                             go to More->Administration->Patrons & Circulation->Patron Categories</p>
186
                        </div>
187
                        Next up:
188
                        <input type="submit" value="Add a patron">
189
190
                        [% ELSE %]
191
                             <p> Patron category was not successfully created</p>
192
                    [% END %]
193
                [% END %]
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213

Return to bug 17855