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

(-)a/installer/onboarding.pl (-100 / +134 lines)
Lines 4-14 use strict; Link Here
4
use warnings;
4
use warnings;
5
use diagnostics;
5
use diagnostics;
6
6
7
8
use Modern::Perl;
7
use Modern::Perl;
9
 use C4::InstallAuth;
8
use C4::InstallAuth;
10
11
#External modules
12
use CGI qw ( -utf8 );
9
use CGI qw ( -utf8 );
13
use List::MoreUtils qw/uniq/;
10
use List::MoreUtils qw/uniq/;
14
use Digest::MD5 qw(md5_base64);
11
use Digest::MD5 qw(md5_base64);
Lines 44-53 use Module::Load; Link Here
44
use Koha::IssuingRule;
41
use Koha::IssuingRule;
45
use Koha::IssuingRules;
42
use Koha::IssuingRules;
46
43
47
48
49
50
51
#Setting variables
44
#Setting variables
52
my $input    = new CGI;
45
my $input    = new CGI;
53
my $query    = new CGI;
46
my $query    = new CGI;
Lines 92-98 if ( $op && $op eq 'finish' ) { #If the value of $op equals 'finish' then redire Link Here
92
}
85
}
93
86
94
87
95
#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
88
#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 started the onboarding tool process
96
my $start = $query->param('start');
89
my $start = $query->param('start');
97
$template->param('start'=>$start); #Hand the start variable back to the template
90
$template->param('start'=>$start); #Hand the start variable back to the template
98
if ( $start && $start eq 'Start setting up my Koha' ){ 
91
if ( $start && $start eq 'Start setting up my Koha' ){ 
Lines 108-115 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
108
              ]
101
              ]
109
    );
102
    );
110
103
111
112
#Select any library records from the database and hand them back to the template in the libraries variable. 
113
}elsif (  $start && $start eq 'Add a patron category' ){
104
}elsif (  $start && $start eq 'Add a patron category' ){
114
105
115
#Select all the patron category records in the categories database table and store them in the newly declared variable $categories
106
#Select all the patron category records in the categories database table and store them in the newly declared variable $categories
Lines 122-133 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
122
     my $itemtypes = Koha::ItemTypes->search();
113
     my $itemtypes = Koha::ItemTypes->search();
123
     $template->param(
114
     $template->param(
124
             itemtypes => $itemtypes,
115
             itemtypes => $itemtypes,
125
    );
116
    );#Hand the variable itemtypes back to the template
126
117
127
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 
118
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 
128
}elsif ( $step && $step == 1 ) {
119
}elsif ( $step && $step == 1 ) {
129
120
    my $createlibrary = $query->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary variable
130
    my $createlibrary = $query->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary
131
    $template->param('createlibrary'=>$createlibrary); # Hand the library values back to the template in the createlibrary variable
121
    $template->param('createlibrary'=>$createlibrary); # Hand the library values back to the template in the createlibrary variable
132
122
133
    #store inputted parameters in variables
123
    #store inputted parameters in variables
Lines 136-155 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
136
    my $op               = $input->param('op') || 'list';
126
    my $op               = $input->param('op') || 'list';
137
    my $message;
127
    my $message;
138
    my $library;
128
    my $library;
139
#my @messages;
140
129
141
    #Take the text 'branchname' and store it in the @fields array
130
    #Take the text 'branchname' and store it in the @fields array
142
    my @fields = qw(
131
    my @fields = qw(
143
        branchname
132
        branchname
144
    ); 
133
    ); 
145
134
146
147
#test
148
    $template->param('branchcode'=>$branchcode); 
135
    $template->param('branchcode'=>$branchcode); 
149
150
    $branchcode =~ s|\s||g; # Use a regular expression to check the value of the inputted branchcode 
136
    $branchcode =~ s|\s||g; # Use a regular expression to check the value of the inputted branchcode 
151
137
152
    #Create a new library object and store the branchcode and @fields array values in this new library object
138
    #Create a new library object and store the branchcode and @fields array values in this new library object    
153
    $library = Koha::Library->new(
139
    $library = Koha::Library->new(
154
        {   branchcode => $branchcode, 
140
        {   branchcode => $branchcode, 
155
            ( map { $_ => scalar $input->param($_) || undef } @fields )
141
            ( map { $_ => scalar $input->param($_) || undef } @fields )
Lines 157-185 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
157
    );
143
    );
158
144
159
    eval { $library->store; }; #Use the eval{} function to store the library object
145
    eval { $library->store; }; #Use the eval{} function to store the library object
160
161
    if($library){
146
    if($library){
162
       $message = 'success_on_insert';
147
       $message = 'success_on_insert';
163
   }else{
148
    }else{
164
       $message = 'error_on_insert';
149
       $message = 'error_on_insert';
165
   }
150
    }
166
151
167
   $template->param('message' => $message); 
152
    $template->param('message' => $message); 
168
153
169
154
170
#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
155
#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
171
}elsif ( $step && $step == 2 ){
156
}elsif ( $step && $step == 2 ){
172
    my $createcat = $query->param('createcat'); #Store the inputted library branch code and name in $createlibrary
157
    my $createcat = $query->param('createcat'); #Store the inputted category code and name in $createcat
173
    $template->param('createcat'=>$createcat); # Hand the library values back to the template in the createlibrary variable
158
    $template->param('createcat'=>$createcat);
174
175
159
176
    #Initialising values
160
    #Initialising values
177
    my $input         = new CGI;
178
    my $searchfield   = $input->param('description') // q||;
161
    my $searchfield   = $input->param('description') // q||;
179
    my $categorycode  = $input->param('categorycode');
162
    my $categorycode  = $input->param('categorycode');
180
    my $op            = $input->param('op') // 'list';
163
    my $op            = $input->param('op') // 'list';
181
    my $message;
164
    my $message;
182
    my $category;
165
    my $category;
166
    $template->param('categorycode' =>$categorycode);
183
167
184
    my ( $template, $loggedinuser, $cookie ) =  C4::InstallAuth::get_template_and_user(
168
    my ( $template, $loggedinuser, $cookie ) =  C4::InstallAuth::get_template_and_user(
185
    {
169
    {
Lines 194-200 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
194
178
195
    #Once the user submits the page, this code validates the input and adds it
179
    #Once the user submits the page, this code validates the input and adds it
196
    #to the database as a new patron category 
180
    #to the database as a new patron category 
197
    my $categorycode = $input->param('categorycode');
181
    $categorycode = $input->param('categorycode');
198
    my $description = $input->param('description');
182
    my $description = $input->param('description');
199
    my $overduenoticerequired = $input->param('overduenoticerequired');
183
    my $overduenoticerequired = $input->param('overduenoticerequired');
200
    my $category_type = $input->param('category_type');
184
    my $category_type = $input->param('category_type');
Lines 204-243 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
204
188
205
    #Converts the string into a date format
189
    #Converts the string into a date format
206
    if ( $enrolmentperioddate) {
190
    if ( $enrolmentperioddate) {
207
        $enrolmentperioddate = output_pref(
191
         $enrolmentperioddate = output_pref(
208
                {
192
                    {
209
                    dt         => dt_from_string($enrolmentperioddate),
193
                        dt         => dt_from_string($enrolmentperioddate),
210
                    dateformat => 'iso',
194
                        dateformat => 'iso',
211
                    dateonly   => 1,
195
                        dateonly   => 1,
212
                }
196
                    }
213
        );
197
            );
214
    }
198
        }
215
199
216
    #Adds to the database
200
    #Adds a new patron category to the database
217
    $category = Koha::Patron::Category->new({
201
    $category = Koha::Patron::Category->new({
218
            categorycode=> $categorycode,
202
             categorycode=> $categorycode,
219
            description => $description,
203
             description => $description,
220
            overduenoticerequired => $overduenoticerequired,
204
             overduenoticerequired => $overduenoticerequired,
221
            category_type=> $category_type,
205
             category_type=> $category_type,
222
            default_privacy => $default_privacy,
206
             default_privacy => $default_privacy,
223
            enrolmentperiod => $enrolmentperiod,
207
             enrolmentperiod => $enrolmentperiod,
224
            enrolmentperioddate => $enrolmentperioddate,
208
             enrolmentperioddate => $enrolmentperioddate,
225
    });
209
    });
210
226
    eval {
211
    eval {
227
        $category->store;
212
         $category->store;
228
    };
213
    };
229
214
230
    #Error messages
215
    #Error messages
231
    if($category){
216
    if($category){
232
        $message = 'success_on_insert';
217
         $message = 'success_on_insert';
233
    }else{
218
    }else{
234
        $message = 'error_on_insert';
219
         $message = 'error_on_insert';
235
    }
220
    }
236
221
237
    $template->param('message' => $message); 
222
    $template->param('message' => $message); 
238
223
239
#Create a patron
224
#Create a patron
240
}elsif ( $step && $step == 3 ){
225
}elsif ( $step && $step == 3 ){
226
    my $firstpassword = $input->param('password');
227
    my $secondpassword = $input->param('password2');
228
229
230
    if ($firstpassword ne $secondpassword){
231
            my $DisplayError='Please rewrite the password';
232
            warn $DisplayError;
233
            $template->param(DisplayError=>$DisplayError,
234
            );
235
    }
236
237
#Find all library records in the database and hand them to the template to display in the library dropdown box
241
    my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
238
    my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
242
    $template->param(libraries   => $libraries,
239
    $template->param(libraries   => $libraries,
243
              group_types => [
240
              group_types => [
Lines 250-267 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
250
              ]
247
              ]
251
    );
248
    );
252
249
253
    my $categories;
250
#Find all patron categories in the database and hand them to the template to display in the patron category dropdown box
254
    $categories= Koha::Patron::Categories->search();
251
    my $categories= Koha::Patron::Categories->search();
255
    $template->param(
252
    $template->param(
256
            categories => $categories,
253
            categories => $categories,
257
    );
254
    );
258
255
259
    my $input = new CGI;
260
    my $op = $input->param('op') // 'list';
256
    my $op = $input->param('op') // 'list';
257
    my $minpw = C4::Context->preference("minPasswordLength");
258
    $template->param("minPasswordLength" => $minpw);
261
259
262
    my @messages;
260
    my @messages;
263
    my @errors;
261
    my @errors;
262
    my $nok = $input->param('nok');
264
263
264
    my $firstpassword = $input->param('password');
265
    my $secondpassword = $input->param('password2');
266
    my $cardnumber= $input->param('cardnumber');
267
    my $borrowernumber= $input->param('borrowernumber');
268
    my $userid=$input->param('userid');
269
270
    if(my $error_code = checkcardnumber($cardnumber, $borrowernumber)){
271
            push @errors, $error_code == 1
272
                ? 'ERROR_cardnumber_already_exists'
273
                :$error_code == 2 
274
                    ? 'ERROR_cardnumber_length'
275
                    :()
276
    }
277
278
#  unless(Check_Userid($userid, $borrowernumber)){
279
#          push @errors, "ERROR_login_exist";
280
#  }
281
  push @errors, "ERROR_password_mismatch" if $firstpassword ne $secondpassword;
282
  push @errors, "ERROR_short_password" if ($firstpassword && $minpw && $firstpassword ne '****' && (length($firstpassword) < $minpw));
283
#
284
#Passing errors to template
285
    $nok = $nok || scalar(@errors);
286
287
    if($nok){
288
289
       foreach my $error (@errors){
290
           if ($error eq 'ERROR_password_mismatch'){
291
               $template->param(errorpasswordmismatch => 1);
292
           }
293
           if ($error eq 'ERROR_login_exist'){
294
                $template->param(errorloginexists =>1);
295
           }
296
           if ($error eq 'ERROR_cardnumber_already_exists'){
297
                $template->param(errorcardnumberexists => 1);
298
           }
299
           if ($error eq 'ERROR_cardnumber_length'){
300
                $template->param(errorcardnumberlength => 1);
301
           }
302
           if ($error eq 'ERROR_short_password'){
303
                $template->param(errorshortpassword => 1);
304
           }
305
       }
306
        $template->param('nok' => 1);
307
        warn $nok;
308
    }else{
265
    my ($template, $loggedinuser, $cookie)= C4::InstallAuth::get_template_and_user({
309
    my ($template, $loggedinuser, $cookie)= C4::InstallAuth::get_template_and_user({
266
                template_name => "/onboarding/onboardingstep3.tt",
310
                template_name => "/onboarding/onboardingstep3.tt",
267
                query => $input,
311
                query => $input,
Lines 287-307 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
287
         $newdata{dateexpiry} = '12/10/2016';
331
         $newdata{dateexpiry} = '12/10/2016';
288
         $newdata{privacy} = "default";
332
         $newdata{privacy} = "default";
289
333
290
        if(my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){
291
            push @errors, $error_code == 1
292
                ? 'ERROR_cardnumber_already_exists'
293
                :$error_code == 2 
294
                    ? 'ERROR_cardnumber_length'
295
                    :()
296
        }
297
298
299
#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
334
#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
300
        my $borrowernumber = &AddMember(%newdata);
335
        my $borrowernumber = &AddMember(%newdata);
301
#Create a hash named member2 and fillit with the borrowernumber of the borrower that has just been created 
336
337
#Create a hash named member2 and fill it with the borrowernumber of the borrower that has just been created 
302
        my %member2;
338
        my %member2;
303
        $member2{'borrowernumber'}=$borrowernumber;
339
        $member2{'borrowernumber'}=$borrowernumber;
304
340
341
#Perform data validation on the flag that has been handed to onboarding.pl by the template
305
        my $flag = $input->param('flag');
342
        my $flag = $input->param('flag');
306
        if ($input->param('newflags')) {
343
        if ($input->param('newflags')) {
307
             my $dbh=C4::Context->dbh();
344
             my $dbh=C4::Context->dbh();
Lines 317-349 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
317
                   }
354
                   }
318
             }
355
             }
319
356
357
             # construct flags
358
             my $module_flags = 0;
359
             my $sth=$dbh->prepare("SELECT bit,flag FROM userflags ORDER BY bit");
360
             $sth->execute(); 
361
             while (my ($bit, $flag) = $sth->fetchrow_array) {
362
                  if (exists $all_module_perms{$flag}) {
363
                     $module_flags += 2**$bit;
364
                  }
365
             }
320
366
321
               # construct flags
367
#Set the superlibrarian permission of the newly created patron to superlibrarian
322
               my $module_flags = 0;
368
             $sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?");
323
               my $sth=$dbh->prepare("SELECT bit,flag FROM userflags ORDER BY bit");
369
             $sth->execute($module_flags, $borrowernumber);
324
               $sth->execute(); 
370
325
               while (my ($bit, $flag) = $sth->fetchrow_array) {
371
              #Error handling checking if the patron was created successfully
326
                    if (exists $all_module_perms{$flag}) {
372
              if(!$borrowernumber){
327
                       $module_flags += 2**$bit;
373
                   push @messages, {type=> 'error', code => 'error_on_insert'};
328
                    }
374
              }else{
329
               }
375
                   push @messages, {type=> 'message', code => 'success_on_insert'};
330
376
              }
331
               $sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?");
377
            }
332
               $sth->execute($module_flags, $borrowernumber);
378
        }
333
334
               #Error handling checking if the patron was created successfully
335
               if(!$borrowernumber){
336
                    push @messages, {type=> 'error', code => 'error_on_insert'};
337
               }else{
338
                    push @messages, {type=> 'message', code => 'success_on_insert'};
339
               }
340
         }
341
    }
379
    }
342
}elsif ( $step && $step == 4){
380
}elsif ( $step && $step == 4){
343
    my $createitemtype = $input->param('createitemtype');
381
    my $createitemtype = $input->param('createitemtype');
344
    $template->param('createitemtype'=> $createitemtype );
382
    $template->param('createitemtype'=> $createitemtype );
345
383
346
    my $input = new CGI;
347
    my $itemtype_code = $input->param('itemtype');
384
    my $itemtype_code = $input->param('itemtype');
348
    my $op = $input->param('op') // 'list';
385
    my $op = $input->param('op') // 'list';
349
    my $message;
386
    my $message;
Lines 358-379 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
358
            }
395
            }
359
    );
396
    );
360
397
361
    if($op eq 'add_form'){
398
    if($op eq 'add_validate'){
362
        my $itemtype = Koha::ItemTypes->find($itemtype_code);
363
        $template->param(itemtype=> $itemtype,);
364
    }elsif($op eq 'add_validate'){
365
        my $itemtype = Koha::ItemTypes->find($itemtype_code);
366
        my $description = $input->param('description');
399
        my $description = $input->param('description');
367
400
368
        #store the input from the form - only 2 fields 
401
        #store the input from the form - only 2 fields 
369
        my $thisitemtype= Koha::ItemType->new(
402
        my $itemtype= Koha::ItemType->new(
370
            { itemtype    => $itemtype_code,
403
            { itemtype    => $itemtype_code,
371
              description => $description,
404
              description => $description,
372
            }
405
            }
373
        );
406
        );
374
        eval{ $thisitemtype->store; };
407
        eval{ $itemtype->store; };
375
        #Error messages
408
        #Error messages
376
        if($thisitemtype){
409
        if($itemtype){
377
            $message = 'success_on_insert';
410
            $message = 'success_on_insert';
378
        }else{
411
        }else{
379
            $message = 'error_on_insert';
412
            $message = 'error_on_insert';
Lines 382-401 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
382
        $template->param('message' => $message); 
415
        $template->param('message' => $message); 
383
    }
416
    }
384
}elsif ( $step && $step == 5){
417
}elsif ( $step && $step == 5){
385
418
    #Find all the existing categories to display in a dropdown box in the template
386
    #Fetching all the existing categories to display in a drop down box
387
    my $categories;
419
    my $categories;
388
    $categories= Koha::Patron::Categories->search();
420
    $categories= Koha::Patron::Categories->search();
389
    $template->param(
421
    $template->param(
390
        categories => $categories,
422
        categories => $categories,
391
    );
423
    );
392
424
425
    #Find all the exisiting item types to display in a dropdown box in the template
393
    my $itemtypes;
426
    my $itemtypes;
394
    $itemtypes= Koha::ItemTypes->search();
427
    $itemtypes= Koha::ItemTypes->search();
395
    $template->param(
428
    $template->param(
396
        itemtypes => $itemtypes,
429
        itemtypes => $itemtypes,
397
    );
430
    );
398
431
432
    #Find all the exisiting libraries to display in a dropdown box in the template
399
    my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
433
    my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
400
    $template->param(libraries   => $libraries,
434
    $template->param(libraries   => $libraries,
401
                     group_types => [
435
                     group_types => [
Lines 412-427 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
412
    my $dbh = C4::Context->dbh;
446
    my $dbh = C4::Context->dbh;
413
447
414
    my ($template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user({template_name => "/onboarding/onboardingstep5.tt",
448
    my ($template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user({template_name => "/onboarding/onboardingstep5.tt",
415
                     query => $input,
449
                query => $input,
416
                     type => "intranet",
450
                type => "intranet",
417
                     authnotrequired => 0,
451
                authnotrequired => 0,
418
                     flagsrequired => {parameters => 'manage_circ_rules'},
452
                flagsrequired => {parameters => 'manage_circ_rules'},
419
                     debug => 1,
453
                debug => 1,
420
                     });
454
    });
421
455
422
    my $branch = $input->param('branch');
456
    my $branch = $input->param('branch');
423
    unless ( $branch ) {
457
 unless ( $branch ) {
424
           if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) {
458
          if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) {
425
                $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Context::mybranch();
459
                $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Context::mybranch();
426
           }
460
           }
427
           else {
461
           else {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/installer/step3.tt (-2 / +2 lines)
Lines 217-227 function Hide(link) Link Here
217
    [% END %]
217
    [% END %]
218
    <h3>All done!</h3>
218
    <h3>All done!</h3>
219
    <p>Installation complete.<br />
219
    <p>Installation complete.<br />
220
        <p>Click on 'Finish' to complete and load the Koha Staff Interface.
220
        <p>Click on 'Continue to onboarding tool' to complete and load the Koha onboarding tool.
221
        <form name="finish">
221
        <form name="finish">
222
        <input type="hidden" name="step" value="3" />
222
        <input type="hidden" name="step" value="3" />
223
        <input type="hidden" name="op" value="finish" />
223
        <input type="hidden" name="op" value="finish" />
224
        <input type="submit" value="Finish"/>
224
        <input type="submit" value="Continue to Koha onboarding tool"/>
225
        </form>
225
        </form>
226
        </p>
226
        </p>
227
    </p>
227
    </p>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt (-3 / +3 lines)
Lines 57-63 Link Here
57
                <input type="hidden" name="step" value="2"/>
57
                <input type="hidden" name="step" value="2"/>
58
                <h1 align="left"> New Library</h1>
58
                <h1 align="left"> New Library</h1>
59
                <div>
59
                <div>
60
                    <p> Success: Library created! Your branchcode is [% branchcode %]</p>
60
                    <p> Success: Library created!</p>
61
                    <p> To add another library and for more settings, <br>
61
                    <p> To add another library and for more settings, <br>
62
                    go to Tools->Administration->Libraries and Groups
62
                    go to Tools->Administration->Libraries and Groups
63
                </div>
63
                </div>
Lines 87-98 Link Here
87
                 <ol>
87
                 <ol>
88
                     <li>
88
                     <li>
89
                        <label for="branchcode" class="required">Library code: </label>
89
                        <label for="branchcode" class="required">Library code: </label>
90
                        <input type="text" style="text-transform: uppercase;"name="branchcode" id="branchcode" size="10" maxlength="10" value="[% library.branchcode |html %]" class="required" required="required" />
90
                        <input type="text"  pattern="[A-Z]{3}" title="Please enter 3 capital letters" name="branchcode" id="branchcode" size="10" maxlength="10" value="[% library.branchcode |html %]" class="required" required="required" />
91
                        <span class="required">Required</span>
91
                        <span class="required">Required</span>
92
                    </li>
92
                    </li>
93
                    <li>
93
                    <li>
94
                        <label for="branchname" class="required">Name: </label>
94
                        <label for="branchname" class="required">Name: </label>
95
                        <input type="text" style="text-transform:capitalize;" name="branchname" id="branchname" size="42" value="[% library.branchname |html %]" class="    required" required="required" style="width:200px;">
95
                        <input type="text" pattern="[a-zA-Z ]+" title="Please enter a sentence of letters only" name="branchname" id="branchname" size="42" value="[% library.branchname |html %]" class="    required" required="required" style="width:200px;">
96
                        <span class="required">Required</span>
96
                        <span class="required">Required</span>
97
                    </li>
97
                    </li>
98
                 </ol>
98
                 </ol>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt (-14 / +5 lines)
Lines 30-40 jQuery.validator.addMethod( "enrollment_period", function(){ Link Here
30
    }
30
    }
31
}, MSG_ONE_ENROLLMENTPERIOD);
31
}, MSG_ONE_ENROLLMENTPERIOD);
32
32
33
//Testing the jquery
34
35
36
37
38
var debug    = "";
33
var debug    = "";
39
var dformat  = "us";
34
var dformat  = "us";
40
var sentmsg = 0;
35
var sentmsg = 0;
Lines 192-201 $(document).ready(function(){ Link Here
192
    });
187
    });
193
});
188
});
194
189
195
196
197
198
199
$(document).ready(function(){
190
$(document).ready(function(){
200
     $("#category_form").validate({
191
     $("#category_form").validate({
201
         rules: {
192
         rules: {
Lines 266-278 $(document).ready(function(){ Link Here
266
     </form>
257
     </form>
267
258
268
<!--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-->
259
<!--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-->
269
[% ELSIF op == "add_validate" %]
260
[% ELSIF createcat %]
270
    [% IF message != "error_on_insert" %]
261
    [% IF message != "error_on_insert" %]
271
     <form name="createcat" method="post" action="onboarding.pl">
262
     <form name="createcat" method="post" action="onboarding.pl">
272
            <input type="hidden" name="step" value="3"/>
263
            <input type="hidden" name="step" value="3"/>
273
             <h1 align="left">  New patron category</h1>
264
             <h1 align="left">  New patron category</h1>
274
             <div>
265
             <div>
275
                 <p> Success: Patron category created! Your patron category code is [% category.categorycode %] </p>
266
                 <p> Success: Patron category created! </p>
276
                 <p> To add another patron category and for more settings<br>
267
                 <p> To add another patron category and for more settings<br>
277
                 go to More->Administration->Patrons & Circulation->Patron Categories</p>
268
                 go to More->Administration->Patrons & Circulation->Patron Categories</p>
278
             </div>
269
             </div>
Lines 297-313 $(document).ready(function(){ Link Here
297
       <form id="category_form" method="post" action="onboarding.pl">  
288
       <form id="category_form" method="post" action="onboarding.pl">  
298
       <fieldset class="rows">
289
       <fieldset class="rows">
299
            <input type="hidden" name="step" value="2"/>
290
            <input type="hidden" name="step" value="2"/>
300
            <input type="hidden" name="op" value="add_validate" />
291
            <input type="hidden" name="createcat" value="createcat" />
301
                <ol>
292
                <ol>
302
                    <li>
293
                    <li>
303
                        <label for="categorycode" class="required">Category code: </label>
294
                        <label for="categorycode" class="required">Category code: </label>
304
                        <input type="text" style="text-transform: uppercase;" name="categorycode" value="[% category.categorycode |html %]" size="10" maxlength="10" class="required" required="required" />
295
                        <input type="text" pattern="^[A-Z]{1,2}" title="Please enter 1 or 2 capital letters" style="text-transform: uppercase;" name="categorycode" value="[% category.categorycode |html %]" size="10" maxlength="10" class="required" required="required" />
305
                        <span class="required">Required</span>
296
                        <span class="required">Required</span>
306
                    </li>
297
                    </li>
307
298
308
                    <li>
299
                    <li>
309
                        <label for="description" class="required">Description: </label>
300
                        <label for="description" class="required">Description: </label>
310
                        <input type="text" style="text-transform:capitalize;" name="description" size="40" maxlength="80" class="required" required="required" value="[% category.description |html %]" />
301
                        <input type="text"  pattern="[a-zA-Z ]+" title="Please enter a description sentence of letters only" name="description" size="40" maxlength="80" class="required" required="required" value="[% category.description |html %]" />
311
                        <span class="required">Required</span>
302
                        <span class="required">Required</span>
312
                    </li>
303
                    </li>
313
304
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt (-37 / +105 lines)
Lines 4-12 Link Here
4
[% USE Price %]
4
[% USE Price %]
5
<!--[% USE Branches %]-->
5
<!--[% USE Branches %]-->
6
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END     %]
7
[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END%]
8
9
10
[% INCLUDE 'installer-doc-head-close.inc' %]
8
[% INCLUDE 'installer-doc-head-close.inc' %]
11
[% INCLUDE 'calendar.inc' %]
9
[% INCLUDE 'calendar.inc' %]
12
[% INCLUDE 'datatables.inc' %]
10
[% INCLUDE 'datatables.inc' %]
Lines 16-60 Link Here
16
<title>Create Patron</title>
14
<title>Create Patron</title>
17
15
18
<!--jQuery scripts for creating patron-->
16
<!--jQuery scripts for creating patron-->
19
<!--<script type="text/javascript" src="[% interface %]/[% theme %]/js/members.js"></script>
17
<script type-"text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
20
-->
18
<script type="text/javascipt">
19
        var MSG_DUPLICATE_PATRON = _("Warning: Duplicate patron");
20
        var MSG_PASSWORD_MISMATCH = _("The passwords entered do not match");
21
        var MSG_PASSWORD_CONTAINS_TRAILING_SPACES = _("Password contains leading and/or trailing spaces.");
22
function check_password(password){
23
    if(password.match(/^\s/) || password.match(/\s$/)){
24
        return false;
25
    }return true;
26
}
27
28
$(document).ready(function(){
29
     $("#createpatron").validate({
30
         rules: {
31
            borrowernumber: {
32
                 required: true,
33
                 digits: true
34
             },
35
            surname:{
36
                required: true,
37
                letters: true
38
            },
39
            firstname:{
40
                required:true,
41
                letters:true
42
            },
43
            userid: {
44
                required: true; 
45
                letters_numbers: true
46
            },
47
            password: {
48
                 letters_numbers: true
49
            },
50
         },
51
         messages: {
52
             password: {
53
                 required: MSG_PASSWORD_MISMATCH
54
             },
55
             userid: {
56
                 required: MSG_DUPLICATE_PATRON
57
             }
58
         }
59
 
60
     });
61
62
})
63
</script>
64
<script type="text/javascript" src="[% interface %]/[% theme %]/js/members.js"></script>
21
</head>
65
</head>
22
66
23
<div>
67
<div>
24
    <h1 align="center"> Welcome to Koha</h1>
68
    <h1 align="center"> Welcome to Koha</h1>
25
    <h1 id="logo"><img alt="Koha" style="width:50%;margin:auto;display:block;align:center;"  src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/></h1>
69
    <h1 id="logo"><img alt="Koha" style="width:50%;margin:auto;display:block;align:center;"  src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/></h1>
26
</div>
70
</div>
71
72
[%  IF (nok) %]
73
        <form name="errors" method="post" action="onboarding.pl">
74
            <input type="hidden" name="step" value="3"/>
75
            <h1 align="left">There was an error</h1>
76
            <p>Try again </p>
77
            <div>
78
            <ul>
79
            [% IF errorloginexists %]
80
                <li id="ERROR_login_exist">Username/password already exists.</li>
81
            [% END %]
82
            [% IF errorcardnumberexists %]
83
                <li id="ERROR_cardnumber">Cardnumber already in use.</li>
84
            [% END %]
85
            [% IF errorcardnumberlength %]
86
                <li id="ERROR_cardnumber">Cardnumber length is incorrect</li>
87
            [% END %]
88
            [% IF errorshortpassword %]
89
                <li id="ERROR_short_password">Password length is incorrect, must be at least [% minPasswordLength %] characters long.</li>
90
            [% END %]
91
            [% IF errorpasswordmismatch %]
92
                <li id="ERROR_password_mismatch">Passwords do not match.</li>
93
            [% END %]
94
            </ul>
95
96
            </div>
97
            <input type="submit" name="step" value="Try again"/>
98
        </form>
99
100
27
<!--Create a patron screen 2-->
101
<!--Create a patron screen 2-->
28
[% IF op == 'add_validate' %]
102
[% ELSIF op == 'add_validate' %]
29
        <!--New patron created-->
103
          <!--New patron created-->
30
        <form name="patrondone" method="post" action="onboarding.pl">
104
        <form name="patrondone" method="post" action="onboarding.pl">
31
            <input type="hidden" name="step" value="4"/>
105
            <input type="hidden" name="step" value="4"/>
32
            <h1 align="left"> New Patron </h1>
106
            <h1 align="left"> New Patron </h1>
33
            <div>   
107
            <div>
34
                 <p> Success: New patron created!</p>
108
                 <p> Success: New patron created!</p>
35
                 <p> To create another patron, go to Patrons > New Patron. <br>
109
                 <p> To create another patron, go to Patrons > New Patron. <br>
36
                More > Set Permissions in a user page to gain superlibrarian permissions.
110
                More > Set Permissions in a user page to gain superlibrarian permissions.
37
                </div>
111
            </div>
38
                 Next up:
112
            Next up:
39
                 <input type="submit" name="start" value="Add an item type"/>
113
            <input type="submit" name="start" value="Add an item type"/>
40
        </form>
114
        </form>
41
       <!--Implement a if statement to check if the patron was successfully created
115
[% ELSE %]
42
                <div>
43
                    <p> Oh no! Patron was not created</p>
44
                </div>-->
45
[% ELSE %]    
46
<!--Create a patron screen 1-->
116
<!--Create a patron screen 1-->
47
       <h1 align="left"> Create a new Patron </h2>
117
       <h1 align="left"> Create a new Patron </h1>
118
       <legend id="library_management_lgd">Library Management</legend>
119
        <p>
120
        Now we will create a patron with superlibrarian permissions. Login with this to access Koha as a staff member will all permissions. 
121
        </p>
122
48
        <form name="createpatron" method="post" action="onboarding.pl">
123
        <form name="createpatron" method="post" action="onboarding.pl">
49
            <fieldset class="rows">
124
            <fieldset class="rows">
50
                 <input type="hidden" name="step" value="3"/>
125
                 <input type="hidden" name="step" value="3"/>
51
                 <input type="hidden" name="op" value="add_validate" />
126
                 <input type="hidden" name="op" value="add_validate" />
52
                     <legend id="library_management_lgd">Library Management</legend>
127
                 <ol>
53
                     <p>
128
                 <h3>Patron Identity</h3> 
54
                        Now we will create a patron with superlibrarian permissions. Login with this to access Koha as a staff member will all permissions. 
55
                     </p>
56
                     <ol>
57
                    <h3>Patron Identity</h3> 
58
                        <li>
129
                        <li>
59
                            <label for="surname" class="required">Surname: </label>
130
                            <label for="surname" class="required">Surname: </label>
60
131
Lines 66-75 Link Here
66
                            <input style= "text-transform:capitalize;" type="text" name="firstname" id="firstname" size="20" value="[% firstname |html %]" class="required" required="required">
137
                            <input style= "text-transform:capitalize;" type="text" name="firstname" id="firstname" size="20" value="[% firstname |html %]" class="required" required="required">
67
                            <span class="required">Required</span>
138
                            <span class="required">Required</span>
68
                        </li>
139
                        </li>
69
                    </ol>
140
                </ol>
70
                    
141
71
    
142
                <ol>
72
                    <ol>
73
                        <li>
143
                        <li>
74
                            <label for="cardnumber" class="required">Card Number: </label>
144
                            <label for="cardnumber" class="required">Card Number: </label>
75
                            <input type="number" min="1" id="cardnumber" class="noEnterSubmit valid" name="cardnumber" maxlength="[%maxlength_cardnumber%]" minlength="[%minlength_cardnumber%]" value="[% cardnumber | html %]" class="required" required="required">
145
                            <input type="number" min="1" id="cardnumber" class="noEnterSubmit valid" name="cardnumber" maxlength="[%maxlength_cardnumber%]" minlength="[%minlength_cardnumber%]" value="[% cardnumber | html %]" class="required" required="required">
Lines 83-89 Link Here
83
                             [% FOREACH library IN libraries %]
153
                             [% FOREACH library IN libraries %]
84
                                  <option name="libraries" value="[% library.branchcode %]"> [% library.branchname %]
154
                                  <option name="libraries" value="[% library.branchcode %]"> [% library.branchname %]
85
                             [% END %]
155
                             [% END %]
86
                                    
156
87
                                </select>
157
                                </select>
88
                            <span class="required"> Required</span>
158
                            <span class="required"> Required</span>
89
                        </li>
159
                        </li>
Lines 96-113 Link Here
96
                            </select>
166
                            </select>
97
                            <span class="required">Required</span>
167
                            <span class="required">Required</span>
98
                        </li> 
168
                        </li> 
99
                    </ol>
169
                </ol>
100
                    
170
101
                    <ol>
171
                <ol>
102
                    
103
                            <h3> Patron permissions</h3>
172
                            <h3> Patron permissions</h3>
104
                            <input type="hidden" name="newflags" value="1"/>
173
                            <input type="hidden" name="newflags" value="1"/>
105
                            <li>
174
                            <li>
106
                                <input type="hidden" class="flag parent" id="flag-0" name="flag" value="superlibrarian"/>
175
                                <input type="hidden" class="flag parent" id="flag-0" name="flag" value="superlibrarian"/>
107
                                <label name="permissioncode" for="flag-0"> superlibrarian</label>
176
                                <label name="permissioncode" for="flag-0"> superlibrarian</label>
108
                            </li>                    
177
                            </li>
109
                    </ol>
178
                </ol>
110
                    <ol>
179
                <ol>
111
                    <h3>OPAC/Staff Login</h3> 
180
                    <h3>OPAC/Staff Login</h3> 
112
                        <li>
181
                        <li>
113
                            <label for="userid" class="required">Username: </label>
182
                            <label for="userid" class="required">Username: </label>
Lines 124-130 Link Here
124
                            <input type="password" id="password2" name="password2" size="20" value="" class="required" required="required">
193
                            <input type="password" id="password2" name="password2" size="20" value="" class="required" required="required">
125
                            <span class="required">Required</span>
194
                            <span class="required">Required</span>
126
                        </li>
195
                        </li>
127
                    </ol>
196
                </ol>
128
             </fieldset><br>
197
             </fieldset><br>
129
                <input type="submit" class="action" value="Submit"/>
198
                <input type="submit" class="action" value="Submit"/>
130
     </form>
199
     </form>
131
- 

Return to bug 17855