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

(-)a/installer/onboarding.pl (-391 / +171 lines)
Lines 35-167 use Koha::IssuingRules; Link Here
35
35
36
#Setting variables
36
#Setting variables
37
my $input = new CGI;
37
my $input = new CGI;
38
my $step  = $input->param('step');
39
38
40
unless ( C4::Context->preference('Version') ) {
39
unless ( C4::Context->preference('Version') ) {
41
    print $input->redirect("/cgi-bin/koha/installer/install.pl");
40
    print $input->redirect("/cgi-bin/koha/installer/install.pl");
42
    exit;
41
    exit;
43
}
42
}
44
43
45
#Getting the appropriate template to display to the user
44
my ( $user, $cookie, $sessionID, $flags ) =
46
my ( $template, $loggedinuser, $cookie ) =
45
  C4::InstallAuth::checkauth( $input, 0, undef, 'intranet' );
47
  C4::InstallAuth::get_template_and_user(
46
die "Not logged in"
48
    {
47
  unless $user
49
        template_name => "/onboarding/onboardingstep"
48
  ; # Should not happen, we should be redirect if the user is not logged in. But do not trust authentication...
50
          . ( $step ? $step : 1 ) . ".tt",
51
        query           => $input,
52
        type            => "intranet",
53
        authnotrequired => 0,
54
        debug           => 1,
55
    }
56
  );
57
49
58
#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.
50
my $step = $input->param('step') || 1;
59
my $op = $input->param('op') || '';
51
my $op   = $input->param('op')   || '';
60
$template->param( 'op' => $op );
52
53
my $template_params = {};
54
$template_params->{op} = $op;
61
55
62
my $schema = Koha::Database->new()->schema();
56
my $schema = Koha::Database->new()->schema();
63
57
64
if ( $op && $op eq 'finish' )
58
my @messages;
65
{ #If the value of $op equals 'finish' then redirect user to /cgi-bin/koha/mainpage.pl
66
    print $input->redirect("/cgi-bin/koha/mainpage.pl");
67
    exit;
68
}
69
59
70
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
60
if ( $step == 1 ) {
71
$template->param(
72
    libraries   => $libraries,
73
    group_types => [
74
        {
75
            categorytype => 'searchdomain',
76
            categories   => [
77
                Koha::LibraryCategories->search(
78
                    { categorytype => 'searchdomain' }
79
                )
80
            ],
81
        },
82
        {
83
            categorytype => 'properties',
84
            categories   => [
85
                Koha::LibraryCategories->search(
86
                    { categorytype => 'properties' }
87
                )
88
            ],
89
        },
90
    ]
91
);
92
61
93
#Select all the patron category records in the categories database table and give them to the template
62
    if ( $op eq 'add_validate_library' ) {
94
my $categories = Koha::Patron::Categories->search();
95
$template->param( 'categories' => $categories, );
96
63
97
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1
64
        my $branchcode = $input->param('branchcode');
98
my $itemtypes = Koha::ItemTypes->search();
65
        $branchcode = uc($branchcode);
99
$template->param( 'itemtypes' => $itemtypes, );
100
101
if ( $step && $step == 1 ) {
102
103
    #store inputted parameters in variables
104
    my $branchcode = $input->param('branchcode');
105
    $branchcode = uc($branchcode);
106
    my $categorycode = $input->param('categorycode');
107
    my $op = $input->param('op') || 'list';
108
    my $message;
109
    my $library;
110
111
    #Take the text 'branchname' and store it in the @fields array
112
    my @fields = qw(
113
      branchname
114
    );
115
116
    $template->param( 'branchcode' => $branchcode );
117
    $branchcode =~ s|\s||g
118
      ; # Use a regular expression to check the value of the inputted branchcode
119
120
#Create a new library object and store the branchcode and @fields array values in this new library object
121
    $library = Koha::Library->new(
122
        {
123
            branchcode => $branchcode,
124
            ( map { $_ => scalar $input->param($_) || undef } @fields )
125
        }
126
    );
127
66
128
    eval { $library->store; }; #Use the eval{} function to store the library object
67
        $branchcode =~ s|\s||g
129
    if ($library) {
68
          ; # Use a regular expression to check the value of the inputted branchcode
130
        $message = 'success_on_insert';
69
131
    }
70
        my $library = Koha::Library->new(
132
    else {
71
            {
133
        $message = 'error_on_insert';
72
                branchcode => $branchcode,
73
                branchname => scalar $input->param('branchname'),
74
            }
75
        );
76
77
        eval { $library->store; };
78
        unless ($@) {
79
            push @messages,
80
              { type => 'message', code => 'success_on_insert_library' };
81
        }
82
        else {
83
            push @messages,
84
              { type => 'message', code => 'error_on_insert_library' };
85
        }
134
    }
86
    }
135
    $template->param( 'message' => $message );
136
87
137
#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
88
    $step++ if Koha::Libraries->count;
138
}
89
}
139
elsif ( $step && $step == 2 ) {
90
if ( $step == 2 ) {
140
    if ( $op eq "add_validate_category" ) {
91
    if ( $op eq "add_validate_category" ) {
141
92
142
        #Initialising values
93
        my $searchfield = $input->param('description') // q||;
143
        my $searchfield  = $input->param('description') // q||;
144
        my $categorycode = $input->param('categorycode');
94
        my $categorycode = $input->param('categorycode');
145
        my $op           = $input->param('op') // 'list';
146
        my $message;
147
        my $category;
95
        my $category;
148
        $template->param( 'categorycode' => $categorycode );
96
        $template_params->{categorycode} = $categorycode;
149
150
        my ( $template, $loggedinuser, $cookie ) =
151
          C4::InstallAuth::get_template_and_user(
152
            {
153
                template_name   => "/onboarding/onboardingstep2.tt",
154
                query           => $input,
155
                type            => "intranet",
156
                authnotrequired => 0,
157
                flagsrequired =>
158
                  { parameters => 'parameters_remaining_permissions' },
159
                debug => 1,
160
            }
161
          );
162
97
163
      #Once the user submits the page, this code validates the input and adds it
164
      #to the database as a new patron category
165
        $categorycode = $input->param('categorycode');
98
        $categorycode = $input->param('categorycode');
166
        my $description           = $input->param('description');
99
        my $description           = $input->param('description');
167
        my $overduenoticerequired = $input->param('overduenoticerequired');
100
        my $overduenoticerequired = $input->param('overduenoticerequired');
Lines 196-405 elsif ( $step && $step == 2 ) { Link Here
196
129
197
        eval { $category->store; };
130
        eval { $category->store; };
198
131
199
        #Error messages
132
        unless ($@) {
200
        if ($category) {
133
            push @messages,
201
            $message = 'success_on_insert';
134
              { type => 'message', code => 'success_on_insert_category' };
202
        }
135
        }
203
        else {
136
        else {
204
            $message = 'error_on_insert';
137
            push @messages,
138
              { type => 'message', code => 'error_on_insert_category' };
205
        }
139
        }
206
207
        $template->param( 'message' => $message );
208
    }
140
    }
209
141
210
    #Create a patron
142
    $step++ if Koha::Patron::Categories->count;
211
}
143
}
212
elsif ( $step && $step == 3 ) {
144
if ( $step == 3 ) {
213
    my $firstpassword  = $input->param('password')  || '';
145
    if ( $op eq 'add_validate_patron' ) {
214
    my $secondpassword = $input->param('password2') || '';
146
215
147
        #Create a patron
216
    #Find all patron records in the database and hand them to the template
148
        my $firstpassword  = $input->param('password')  || '';
217
    my %currentpatrons = Koha::Patrons->search();
149
        my $secondpassword = $input->param('password2') || '';
218
    my $currentpatrons = values %currentpatrons;
150
        my $cardnumber     = $input->param('cardnumber');
219
    $template->param( 'patrons' => $currentpatrons );
151
        my $userid         = $input->param('userid');
220
152
221
#Find all patron categories in the database and hand them to the template to display in the patron category dropdown box
153
        if ( my $error_code = checkcardnumber($cardnumber) ) {
222
    my $categories = Koha::Patron::Categories->search();
154
            if ( $error_code == 1 ) {
223
    $template->param( 'categories' => $categories, );
155
                push @messages,
224
156
                  {
225
#Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry
157
                    type => 'alert',
226
158
                    code => 'ERROR_cardnumber_already_exists'
227
    my $existing_cardnumber =
159
                  };
228
      $schema->resultset('Borrower')->get_column('cardnumber')->max() // 0;
229
230
    my $new_cardnumber = $existing_cardnumber + 1;
231
    $template->param( "newcardnumber" => $new_cardnumber );
232
233
    my $op = $input->param('op') // 'list';
234
    my $minpw = C4::Context->preference("minPasswordLength");
235
    $template->param( "minPasswordLength" => $minpw );
236
    my @messages;
237
    my @errors;
238
    my $nok            = $input->param('nok');
239
    my $cardnumber     = $input->param('cardnumber');
240
    my $borrowernumber = $input->param('borrowernumber');
241
    my $userid         = $input->param('userid');
242
243
    # function to designate mandatory fields (visually with css)
244
    my $check_BorrowerMandatoryField =
245
      C4::Context->preference("BorrowerMandatoryField");
246
    my @field_check = split( /\|/, $check_BorrowerMandatoryField );
247
    foreach (@field_check) {
248
        $template->param( "mandatory$_" => 1 );
249
        $template->param(
250
            BorrowerMandatoryField =>
251
              C4::Context->preference("BorrowerMandatoryField")
252
            ,    #field to test with javascript
253
        );
254
    }
255
256
 #If the entered cardnumber causes an error hand this error to the @errors array
257
    if ( my $error_code = checkcardnumber( $cardnumber, $borrowernumber ) ) {
258
        push @errors,
259
            $error_code == 1 ? 'ERROR_cardnumber_already_exists'
260
          : $error_code == 2 ? 'ERROR_cardnumber_length'
261
          :                    ();
262
    }
263
264
   #If the entered password causes an error hand this error to the @errors array
265
    push @errors, "ERROR_password_mismatch"
266
      if $firstpassword ne $secondpassword;
267
    push @errors, "ERROR_short_password"
268
      if ( $firstpassword
269
        && $minpw
270
        && $firstpassword ne '****'
271
        && ( length($firstpassword) < $minpw ) );
272
273
    #Passing errors to template
274
    $nok = $nok || scalar(@errors);
275
276
#If errors have been generated from the users inputted cardnumber or password then display the error and do not insert the patron into the borrowers table
277
    if ($nok) {
278
        foreach my $error (@errors) {
279
            if ( $error eq 'ERROR_password_mismatch' ) {
280
                $template->param( errorpasswordmismatch => 1 );
281
            }
160
            }
282
            if ( $error eq 'ERROR_login_exist' ) {
161
            elsif ( $error_code == 2 ) {
283
                $template->param( errorloginexists => 1 );
162
                push @messages,
284
            }
163
                  { type => 'alert', code => 'ERROR_cardnumber_length' };
285
            if ( $error eq 'ERROR_cardnumber_already_exists' ) {
286
                $template->param( errorcardnumberexists => 1 );
287
            }
288
            if ( $error eq 'ERROR_cardnumber_length' ) {
289
                $template->param( errorcardnumberlength => 1 );
290
            }
291
            if ( $error eq 'ERROR_short_password' ) {
292
                $template->param( errorshortpassword => 1 );
293
            }
164
            }
294
        }
165
        }
295
        $template->param( 'nok' => 1 );
166
        elsif ( $firstpassword ne $secondpassword ) {
167
168
            push @messages,
169
              { type => 'alert', code => 'ERROR_password_mismatch' };
170
        }
171
        else {
172
173
            my $patron_data = {
174
                surname      => scalar $input->param('surname'),
175
                firstname    => scalar $input->param('firstname'),
176
                cardnumber   => scalar $input->param('cardnumber'),
177
                branchcode   => scalar $input->param('libraries'),
178
                categorycode => scalar $input->param('categorycode_entry'),
179
                userid       => scalar $input->param('userid'),
180
                password     => scalar $input->param('password'),
181
                password2    => scalar $input->param('password2'),
182
                privacy      => "default",
183
                address      => "",
184
                city         => "",
185
                flags => 1,    # Will be superlibrarian
186
            };
296
187
297
#Else if no errors have been caused by the users inputted card number or password then insert the patron into the borrowers table
298
    }
299
    else {
300
        my ( $template, $loggedinuser, $cookie ) =
301
          C4::InstallAuth::get_template_and_user(
302
            {
303
                template_name   => "/onboarding/onboardingstep3.tt",
304
                query           => $input,
305
                type            => "intranet",
306
                authnotrequired => 0,
307
                flagsrequired   => { borrowers => 1 },
308
                debug           => 1,
309
            }
310
          );
311
312
        if ( $op eq 'add_validate' ) {
313
            my %newdata;
314
315
            #Store the template form values in the newdata hash
316
            $newdata{borrowernumber} = $input->param('borrowernumber');
317
            $newdata{surname}        = $input->param('surname');
318
            $newdata{firstname}      = $input->param('firstname');
319
            $newdata{cardnumber}     = $input->param('cardnumber');
320
            $newdata{branchcode}     = $input->param('libraries');
321
            $newdata{categorycode}   = $input->param('categorycode_entry');
322
            $newdata{userid}         = $input->param('userid');
323
            $newdata{password}       = $input->param('password');
324
            $newdata{password2}      = $input->param('password2');
325
            $newdata{privacy}        = "default";
326
            $newdata{address}        = "";
327
            $newdata{city}           = "";
328
329
#Hand tne the dateexpiry of the patron based on the patron category it is created from
330
            my $patron_category =
188
            my $patron_category =
331
              Koha::Patron::Categories->find( $newdata{categorycode} );
189
              Koha::Patron::Categories->find( $patron_data->{categorycode} );
332
            $newdata{dateexpiry} =
190
            $patron_data->{dateexpiry} =
333
              $patron_category->get_expiry_date( $newdata{dateenrolled} );
191
              $patron_category->get_expiry_date( $patron_data->{dateenrolled} );
334
335
#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
336
            my $borrowernumber = &AddMember(%newdata);
337
338
#Create a hash named member2 and fill it with the borrowernumber of the borrower that has just been created
339
            my %member2;
340
            $member2{'borrowernumber'} = $borrowernumber;
341
342
#Perform data validation on the flag that has been handed to onboarding.pl by the template
343
            my $flag = $input->param('flag');
344
            if ( $input->param('newflags') ) {
345
                my @perms            = $input->multi_param('flag');
346
                my %all_module_perms = ();
347
                my %sub_perms        = ();
348
                foreach my $perm (@perms) {
349
                    if ( $perm !~ /:/ ) {
350
                        $all_module_perms{$perm} = 1;
351
                    }
352
                    else {
353
                        my ( $module, $sub_perm ) = split /:/, $perm, 2;
354
                        push @{ $sub_perms{$module} }, $sub_perm;
355
                    }
356
                }
357
192
358
                # construct flags
193
            my $borrowernumber = C4::Members::AddMember(%$patron_data);
359
                my @userflags = $schema->resultset('Userflag')->search(
194
360
                    {},
195
            #Error handling checking if the patron was created successfully
361
                    {
196
            if ($borrowernumber) {
362
                        order_by => { -asc => 'bit' },
197
                push @messages,
363
                    }
198
                  { type => 'message', code => 'success_on_insert_patron' };
364
                );
199
            }
365
200
            else {
366
                #Setting superlibrarian permissions for new patron
201
                push @messages,
367
                my $flags =
202
                  { type => 'error', code => 'error_on_insert_patron' };
368
                  Koha::Patrons->find($borrowernumber)->set( { flags => 1 } )
369
                  ->store;
370
371
                #Error handling checking if the patron was created successfully
372
                if ( !$borrowernumber ) {
373
                    push @messages,
374
                      { type => 'error', code => 'error_on_insert' };
375
                }
376
                else {
377
                    push @messages,
378
                      { type => 'message', code => 'success_on_insert' };
379
                }
380
            }
203
            }
381
        }
204
        }
382
    }
205
    }
206
207
    $step++ if Koha::Patrons->search( { flags => 1 } )->count;
383
}
208
}
384
elsif ( $step && $step == 4 ) {
209
if ( $step == 4 ) {
385
    my ( $template, $borrowernumber, $cookie ) =
210
    if ( $op eq 'add_validate_itemtype' ) {
386
      C4::InstallAuth::get_template_and_user(
387
        {
388
            template_name   => "/onboarding/onboardingstep4.tt",
389
            query           => $input,
390
            type            => "intranet",
391
            authnotrequired => 0,
392
            flagsrequired =>
393
              { parameters => 'parameters_remaining_permissions' },
394
            debug => 1,
395
        }
396
      );
397
    if ( $op eq "add_validate" ) {
398
        my $description   = $input->param('description');
211
        my $description   = $input->param('description');
399
        my $itemtype_code = $input->param('itemtype');
212
        my $itemtype_code = $input->param('itemtype');
400
        $itemtype_code = uc($itemtype_code);
213
        $itemtype_code = uc($itemtype_code);
401
214
402
  #Create a new itemtype object using the user inputted itemtype and description
403
        my $itemtype = Koha::ItemType->new(
215
        my $itemtype = Koha::ItemType->new(
404
            {
216
            {
405
                itemtype    => $itemtype_code,
217
                itemtype    => $itemtype_code,
Lines 407-473 elsif ( $step && $step == 4 ) { Link Here
407
            }
219
            }
408
        );
220
        );
409
        eval { $itemtype->store; };
221
        eval { $itemtype->store; };
410
        my $message;
411
222
412
#Fill the $message variable with an error if the item type object was not successfully created and inserted into the itemtypes table
223
        unless ($@) {
413
        if ($itemtype) {
224
            push @messages,
414
            $message = 'success_on_insert';
225
              { type => 'message', code => 'success_on_insert_itemtype' };
415
        }
226
        }
416
        else {
227
        else {
417
            $message = 'error_on_insert';
228
            push @messages,
229
              { type => 'message', code => 'error_on_insert_itemtype' };
418
        }
230
        }
419
        $template->param( 'message' => $message );
420
    }
231
    }
232
233
    $step++ if Koha::ItemTypes->count;
421
}
234
}
422
elsif ( $step && $step == 5 ) {
235
if ( $step == 5 ) {
423
236
424
  #Find all the existing categories to display in a dropdown box in the template
237
    if ( $op eq 'add_validate_circ_rule' ) {
425
    my $categories;
238
426
    $categories = Koha::Patron::Categories->search();
239
        #If no libraries exist then set the $branch value to *
427
    $template->param( categories => $categories, );
240
        my $branch = $input->param('branch') || '*';
428
429
 #Find all the exisiting item types to display in a dropdown box in the template
430
    my $itemtypes;
431
    $itemtypes = Koha::ItemTypes->search();
432
    $template->param( itemtypes => $itemtypes, );
433
434
    my $input = CGI->new;
435
436
    my ( $template, $loggedinuser, $cookie ) =
437
      C4::InstallAuth::get_template_and_user(
438
        {
439
            template_name   => "/onboarding/onboardingstep5.tt",
440
            query           => $input,
441
            type            => "intranet",
442
            authnotrequired => 0,
443
            flagsrequired   => { parameters => 'manage_circ_rules' },
444
            debug           => 1,
445
        }
446
      );
447
448
    #If no libraries exist then set the $branch value to *
449
    my $branch = $input->param('branch');
450
    unless ($branch) {
451
        if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) {
452
            $branch =
453
              Koha::Libraries->search->count() == 1
454
              ? undef
455
              : C4::Context::mybranch();
456
        }
457
        else {
458
            $branch =
459
              C4::Context::only_my_library()
460
              ? ( C4::Context::mybranch() || '*' )
461
              : '*';
462
        }
463
    }
464
    $branch = '*' if $branch eq 'NO_LIBRARY_SET';
465
    my $op = $input->param('op') || q{};
466
241
467
    if ( $op eq 'add_validate' ) {
468
        my $type            = $input->param('type');
242
        my $type            = $input->param('type');
469
        my $br              = $input->param('branch');
243
        my $branchcode      = $input->param('branch');
470
        my $bor             = $input->param('categorycode');
244
        my $categorycode    = $input->param('categorycode');
471
        my $itemtype        = $input->param('itemtype');
245
        my $itemtype        = $input->param('itemtype');
472
        my $maxissueqty     = $input->param('maxissueqty');
246
        my $maxissueqty     = $input->param('maxissueqty');
473
        my $issuelength     = $input->param('issuelength');
247
        my $issuelength     = $input->param('issuelength');
Lines 480-487 elsif ( $step && $step == 5 ) { Link Here
480
        $issuelength = $issuelength eq q{} ? undef : $issuelength;
254
        $issuelength = $issuelength eq q{} ? undef : $issuelength;
481
255
482
        my $params = {
256
        my $params = {
483
            branchcode      => $br,
257
            branchcode      => $branchcode,
484
            categorycode    => $bor,
258
            categorycode    => $categorycode,
485
            itemtype        => $itemtype,
259
            itemtype        => $itemtype,
486
            maxissueqty     => $maxissueqty,
260
            maxissueqty     => $maxissueqty,
487
            renewalsallowed => $renewalsallowed,
261
            renewalsallowed => $renewalsallowed,
Lines 491-549 elsif ( $step && $step == 5 ) { Link Here
491
            onshelfholds    => $onshelfholds,
265
            onshelfholds    => $onshelfholds,
492
        };
266
        };
493
267
494
        my @messages;
268
        my $issuingrule = Koha::IssuingRule->new($params);
495
269
        eval { $issuingrule->store; };
496
#Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to.
497
        if ( $branch eq "*" ) {
498
            my $search_default_rules =
499
              $schema->resultset('DefaultCircRule')->count();
500
            my $insert_default_rules =
501
              $schema->resultset('Issuingrule')
502
              ->new(
503
                { maxissueqty => $maxissueqty, onshelfholds => $onshelfholds }
504
              );
505
        }
506
507
#Allows for the 'All' option to work when selecting all patron categories for a circulation rule to apply to.
508
        elsif ( $bor eq "*" ) {
509
510
            my $search_default_rules =
511
              $schema->resultset('DefaultCircRule')->count();
512
            my $insert_default_rules = $schema->resultset('Issuingrule')
513
              ->new( { maxissueqty => $maxissueqty } );
514
        }
515
516
#Allows for the 'All' option to work when selecting all itemtypes for a circulation rule to apply to
517
        elsif ( $itemtype eq "*" ) {
518
            my $search_default_rules =
519
              $schema->resultset('DefaultCircRule')->search(
520
                {},
521
                {
522
                    branchcode => $branch
523
                }
524
525
              );
526
270
527
            my $insert_default_rules = $schema->resultset('Issuingrule')
271
        unless ($@) {
528
              ->new( { branchcode => $branch, onshelfholds => $onshelfholds } );
529
        }
530
531
        my $issuingrule = Koha::IssuingRules->find(
532
            { categorycode => $bor, itemtype => $itemtype, branchcode => $br }
533
        );
534
        if ($issuingrule) {
535
            $issuingrule->set($params)->store();
536
            push @messages,
272
            push @messages,
537
              {
273
              { type => 'message', code => 'success_on_insert_circ_rule' };
538
                type => 'error',
539
                code => 'error_on_insert'
540
              }; #Stops crash of the onboarding tool if someone makes a circulation rule with the same item type, library and patron categroy as an exisiting circulation rule.
541
542
        }
274
        }
543
        else {
275
        else {
544
            Koha::IssuingRule->new()->set($params)->store();
276
            push @messages,
277
              { type => 'message', code => 'error_on_insert_circ_rule' };
545
        }
278
        }
546
    }
279
    }
280
281
    $step++ if Koha::IssuingRules->count;
282
}
283
284
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
285
$template_params->{libraries}   = $libraries;
286
$template_params->{group_types} = [
287
    {
288
        categorytype => 'searchdomain',
289
        categories   => [
290
            Koha::LibraryCategories->search(
291
                { categorytype => 'searchdomain' }
292
            )
293
        ],
294
    },
295
    {
296
        categorytype => 'properties',
297
        categories   => [
298
            Koha::LibraryCategories->search( { categorytype => 'properties' } )
299
        ],
300
    },
301
];
302
303
if ( $step > 5 ) {
304
    $template_params->{all_done} = 1;    # If step 5 is complete, we are done!
305
    $step = 5;
547
}
306
}
548
307
308
#Getting the appropriate template to display to the user
309
my ( $template, $loggedinuser );
310
( $template, $loggedinuser, $cookie ) = C4::InstallAuth::get_template_and_user(
311
    {
312
        template_name   => "onboarding/onboardingstep${step}.tt",
313
        query           => $input,
314
        type            => "intranet",
315
        authnotrequired => 0,
316
        debug           => 1,
317
    }
318
);
319
320
$template_params->{messages} = \@messages;
321
my $categories = Koha::Patron::Categories->search();
322
$template_params->{categories} = $categories;
323
324
my $itemtypes = Koha::ItemTypes->search();
325
$template_params->{itemtypes} = $itemtypes;
326
327
$template->param(%$template_params);
328
549
output_html_with_http_headers $input, $cookie, $template->output;
329
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/onboarding_messages.inc (+20 lines)
Line 0 Link Here
1
[% FOR m IN messages %]
2
    <div class="dialog [% m.type %]">
3
        [% SWITCH m.code %]
4
        [% CASE 'success_on_insert_library' %]<span>Library created!</span>
5
        [% CASE 'error_on_insert_library' %]<span>Library already exists and cannot be modified!</span>
6
        [% CASE 'success_on_insert_category' %]<span>Patron category created!</span>
7
        [% CASE 'error_on_insert_category' %]<span>Patron category already exists and cannot be modified!</span>
8
        [% CASE 'success_on_insert_patron' %]<span>Administrator Patron created!</span>
9
        [% CASE 'error_on_insert_patron' %]<span>The patron has not been created! Cardnumber or Userid may already exist.</span>
10
        [% CASE 'ERROR_cardnumber_already_exists' %]<span>Cardnumber already in use.</span>
11
        [% CASE 'ERROR_cardnumber_length' %]<span>Cardnumber length is incorrect.</span>
12
        [% CASE 'ERROR_password_mismatch' %]<span>Passwords do not match.</span>
13
        [% CASE 'success_on_insert_itemtype' %]<span>New item type created!</span>
14
        [% CASE 'error_on_insert_itemtype' %]<span>Item type already exists!</span>
15
        [% CASE 'success_on_insert_circ_rule' %]<span>Circulation rule created!</span>
16
        [% CASE 'error_on_insert_circ_rule' %]<span>Circulation rule not created!</span>
17
        [% CASE %][% message %]
18
        [% END %]
19
    </div>
20
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt (-76 / +33 lines)
Lines 1-81 Link Here
1
<!--Includes for creating library-->
2
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
3
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
2
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
4
[% INCLUDE 'installer-doc-head-close.inc' %]
3
[% INCLUDE 'installer-doc-head-close.inc' %]
5
[% INCLUDE 'datatables.inc' %]
4
[% INCLUDE 'datatables.inc' %]
6
5
7
[% IF (libraries && libraries.count > 1) %]
6
<head><title>Welcome &rsaquo; to  &rsaquo; Koha</title></head>
8
    <meta http-equiv="refresh" content="0; url=/cgi-bin/koha/installer/onboarding.pl?step=2">
7
9
8
<div>
10
[% ELSIF (op == "add_validate_library") %]
9
    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
11
    <head>
10
</div>
12
        <title>Welcome &rsaquo; to  &rsaquo; Koha</title>
11
13
    </head>
12
[% INCLUDE 'onboarding_messages.inc' %]
14
13
15
    <!--Header for the koha onboarding tool-->
14
<form name="LibraryCreation" method="post" action="onboarding.pl">
16
    <div>
15
    <fieldset class="rows" >
17
        <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
16
         <h2>Create a library</h2>
18
    </div>
17
         <input type="hidden" name="step" value="1"/>
19
18
         <input type="hidden" name="op" value="add_validate_library"/>
20
<!--New Library created-->
19
         <ol>
21
       [% IF message == "success_on_insert" %]
20
             <li>
22
            <form name="createlibrary" method="post" action="onboarding.pl" >
21
                <label for="branchcode" class="required">Library code: </label>
23
                <input type="hidden" name="step" value="2"/>
22
                <input type="text"  pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" name="branchcode" id="branchcode" size="10" maxlength="10" value="" class="required" required="required" />
24
                <h1 align="left"> New library</h1>
23
                <span class="required">Required</span>
25
                <div>
24
            </li>
26
                    <p> Success: library created!
25
            <li>
27
                    </p>
26
                <label for="branchname" class="required">Name: </label>
28
                    <p> To add another library and for more settings, <br>
27
                <input type="text" name="branchname" id="branchname" title="Please enter the name of your institution" size="42" value="" class="required" required="required" style="width:200px;">
29
                    go to:<br>
28
                <span class="required">Required</span>
30
                    More -> Administration -> Libraries and groups<br>
29
            </li>
31
                    </p>
30
         </ol>
32
                </div>
31
         <p>
33
                Next up:
32
            To add another library and for more settings, <br>
34
                <input type="submit" name="start" value="Minimal patron category setup"/>
33
            go to:<br>
35
            </form>
34
            More -> Administration -> Libraries and groups<br>
36
35
         </p>
37
        [%ELSE %]
36
         <input type="submit" class="action" value="Submit"/>
38
            <form name="retrylibrary" method="post" action="onboarding.pl">
37
    </fieldset>
39
                <input type="hidden" name="step" value="1"/>
38
</form>
40
                <h1 align="left">Failed </h1>
41
                <div>
42
                    <p> Library was not successfully created</br>
43
                    Please try again or contact your system administrator. </p>
44
                </div>
45
                <input type="submit" value="Try again"/>
46
            </form>
47
        [%END%]
48
49
[% ELSE %]
50
    <head>
51
        <title>Welcome &rsaquo; to  &rsaquo; Koha</title>
52
    </head>
53
54
    <!--Header for the koha onboarding tool-->
55
    <div>
56
        <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
57
    </div>
58
59
<!--Create a library screen 1-->
60
        <form name="LibraryCreation" method="post" action="onboarding.pl">
61
            <fieldset class="rows" >
62
                 <h2>Create a library</h2>
63
                 <input type="hidden" name="step" value="1"/>
64
                 <input type="hidden" name="op" value="add_validate_library"/>
65
                 <ol>
66
                     <li>
67
                        <label for="branchcode" class="required">Library code: </label>
68
                        <input type="text"  pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" name="branchcode" id="branchcode" size="10" maxlength="10" value="[% library.branchcode |html %]" class="required" required="required" />
69
                        <span class="required">Required</span>
70
                    </li>
71
                    <li>
72
                        <label for="branchname" class="required">Name: </label>
73
                        <input type="text" name="branchname" id="branchname" title="Please enter the name of your institution" size="42" value="[% library.branchname |html %]" class="    required" required="required" style="width:200px;">
74
                        <span class="required">Required</span>
75
                    </li>
76
                 </ol>
77
             <br>
78
             <input type="submit" class="action" value="Submit"/>
79
            </fieldset>
80
     </form>
81
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt (-131 / +90 lines)
Lines 26-164 jQuery.validator.addMethod( "enrollment_period", function(){ Link Here
26
<script type="text/javascript" src="[% themelang %]/js/categories.js"></script>
26
<script type="text/javascript" src="[% themelang %]/js/categories.js"></script>
27
</head>
27
</head>
28
28
29
[% IF (categories && categories.count > 1 ) %] <!--This if statement checks if the categories variable handed to this template by onboarding.pl has data in it. If the categories variable does have data in it this means that the user has previously imported sample patron category data and so we do not need to show them the create patron category screen 1, instead we can display a screen with ubtton redirecting the user to step 3-->
30
29
30
<div>
31
    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
32
</div>
31
33
32
     <meta http-equiv="refresh" content="0; url=/cgi-bin/koha/installer/onboarding.pl?step=3">
34
[% INCLUDE 'onboarding_messages.inc' %]
33
35
<h1 align="left"> Create a new patron category</h1>
34
[% ELSIF (op == "add_validate_category") %]
36
<p> The patron category you create in this form is going to be the one which the new administrator patron account will have.</p>
35
<!--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-->
37
   <form id="category_form" method="post" action="onboarding.pl">
36
38
   <fieldset class="rows">
37
    <div> <!-- Header that appears at the top of every screen in the koha onboarding tool-->
38
        <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
39
    </div>
40
41
    [% IF message != "error_on_insert" %]
42
     <form name="createcat" method="post" action="onboarding.pl">
43
            <input type="hidden" name="step" value="3"/>
44
             <h1 align="left">  New patron category</h1>
45
             <div>
46
                 <p> Success: patron category created! </p>
47
                 <p> To add another patron category and for more settings<br>
48
                 go to:<br>
49
                 More -> Administration -> Patron categories<br>
50
             </div>
51
             Next up:<br>
52
             <input type="submit" name="start" value="Add a patron"><!-- When the user clicks on this button then redirect them to step 3 of the onboarding tool-->
53
     </form>
54
     [% ELSE %]
55
        <form name="retrypatcat" method="post" action="onboarding.pl">
56
        Message is [% message %]
57
        <input type="hidden" name="step" value="2"/>
39
        <input type="hidden" name="step" value="2"/>
58
            <h1 align="left">Failed</h1>
40
        <input type="hidden" name="op" value="add_validate_category" />
59
            <div>Patron category was not successfully created.</br>
41
            <ol>
60
            Please try again or contact your system administrator.</p>
42
                <li>
61
            </div>
43
                    <label for="categorycode" class="required">Category code: </label>
62
            <input type="submit" value="Try again"/>
44
                    <input type="text" pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" id="categorycode" name="categorycode" value="[% category.categorycode |html %]" size="10" maxlength="10" class="required" required="required" />
63
        </form>
45
                    <span class="required">Required</span>
64
    [% END %]
46
                </li>
65
47
66
48
                <li>
67
[% ELSE %] <!--Else display create patron category screen 1 where the user can input values to create their first patron category-->
49
                    <label for="description" class="required">Description: </label>
68
    <div> <!-- Header that appears at the top of every screen in the koha onboarding tool-->
50
                    <input type="text" name="description" title="Please enter a description of the category" size="40" maxlength="80" class="required" required="required" value="[% category.description |html%]" />
69
        <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
51
                    <span class="required">Required</span>
70
    </div>
52
                </li>
71
53
72
    <h1 align="left"> Create a new patron category</h1>
54
                <li>
73
    <p> The patron category you create in this form is going to be the one which the new administrator patron account will have.</p>
55
                    <label for="overduenoticerequired">Overdue notice required: </label>
74
       <form id="category_form" method="post" action="onboarding.pl">
56
                    <select name="overduenoticerequired" value="overduenoticerequired">
75
       <fieldset class="rows">
57
                        [% IF category.overduenoticerequired %]
76
            <input type="hidden" name="step" value="2"/>
58
                            <option value="0">No</option>
77
            <input type="hidden" name="op" value="add_validate_category" />
59
                            <option value="1" selected="selected">Yes</option>
78
                <ol>
60
                        [% ELSE %]
79
                    <li>
61
                            <option value="0" selected="selected">No</option>
80
                        <label for="categorycode" class="required">Category code: </label>
62
                            <option value="1">Yes</option>
81
                        <input type="text" pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" id="categorycode" name="categorycode" value="[% category.categorycode |html %]" size="10" maxlength="10" class="required" required="required" />
63
                        [% END %]
82
                        <span class="required">Required</span>
64
                    </select>
83
                    </li>
65
                </li>
84
66
85
                    <li>
67
                <li>
86
                        <label for="description" class="required">Description: </label>
68
                    <label for="category_type" class="required">Category type: </label>
87
                        <input type="text" name="description" title="Please enter a description of the category" size="40" maxlength="80" class="required" required="required" value="[% category.description |html%]" />
69
                    Staff
88
                        <span class="required">Required</span>
70
                </li>
89
                    </li>
71
90
72
                <li>
91
                    <li>
73
                    <label for="default_privacy">Default privacy: </label>
92
                        <label for="overduenoticerequired">Overdue notice required: </label>
74
                    <select value="default_privacy" name="default_privacy" required="required">
93
                        <select name="overduenoticerequired" value="overduenoticerequired">
75
                        [% SET default_privacy = 'default' %]
94
                            [% IF category.overduenoticerequired %]
76
95
                                <option value="0">No</option>
77
                        [% IF category %]
96
                                <option value="1" selected="selected">Yes</option>
78
                           [% SET default_privacy = category.default_privacy %]
97
                            [% ELSE %]
79
                        [% END %]
98
                                <option value="0" selected="selected">No</option>
80
99
                                <option value="1">Yes</option>
81
                        [% SWITCH default_privacy %]
100
                            [% END %]
82
                        [% CASE 'forever' %]
101
                        </select>
83
                            <option value="default">Default</option>
102
                    </li>
84
                            <option value="never">Never</option>
103
85
                            <option value="forever" selected="selected">Forever</option>
104
                    <li>
86
                        [% CASE 'never' %]
105
                        <label for="category_type" class="required">Category type: </label>
87
                            <option value="default">Default</option>
106
                        <select name="category_type" value="category_type" class='required' required='required'>
88
                            <option value="never" selected="selected">Never</option>
107
                            [% IF category and category.category_type == 'S' %]
89
                            <option value="forever">Forever</option>
108
                                <option value="S" selected="selected">Staff</option>
90
                        [% CASE %]
109
                            [% ELSE %]
91
                            <option value="default" selected="selected">Default</option>
110
                                <option value="S">Staff</option>
92
                            <option value="never">Never</option>
111
                            [% END %]
93
                            <option value="forever">Forever</option>
112
                        </select>
94
                        [% END %]
113
                        <span class="required">Required</span>
95
                    </select>
114
                    </li>
96
                    <p>Controls how long a patrons checkout history is kept for new patrons of this category. "Never"     anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</p>
115
97
                </li>
116
                    <li>
98
        </ol>
117
                        <label for="default_privacy">Default privacy: </label>
99
        <span class="label">Enrolment period: </span>
118
                        <select value="default_privacy" name="default_privacy" required="required">
100
        </br>
119
                            [% SET default_privacy = 'default' %]
101
                <fieldset>
120
102
                <legend>Choose one</legend>
121
                            [% IF category %]
103
                        <ol>
122
                               [% SET default_privacy = category.default_privacy %]
104
                            <li>
123
                            [% END %]
105
                                <label for="enrolmentperiod" style="width:6em;">In months: </label>
124
106
                                <input type="number" class="enrolmentperiod" name="enrolmentperiod" id="enrolmentperiod" min="0" size="3" maxlength="3" value="[% IF category.enrolmentperiod %][% category.enrolmentperiod %][% END %]" /> months
125
                            [% SWITCH default_privacy %]
107
                            </li>
126
                            [% CASE 'forever' %]
108
                            <li>
127
                                <option value="default">Default</option>
109
                                <label for="enrolmentperioddate" style="width:6em;">Until date: </label>
128
                                <option value="never">Never</option>
110
                                <input type="text" class="enrolmentperioddate datepicker" name="enrolmentperioddate" id="enrolmentperioddate" value="[% category.enrolmentperioddate | $KohaDates %]" />
129
                                <option value="forever" selected="selected">Forever</option>
111
                            </li>
130
                            [% CASE 'never' %]
112
                        </ol>
131
                                <option value="default">Default</option>
113
                 </fieldset>
132
                                <option value="never" selected="selected">Never</option>
114
             <p> Success: patron category created! </p>
133
                                <option value="forever">Forever</option>
115
             <p> To add another patron category and for more settings<br>
134
                            [% CASE %]
116
             go to:<br>
135
                                <option value="default" selected="selected">Default</option>
117
             More -> Administration -> Patron categories<br>
136
                                <option value="never">Never</option>
118
137
                                <option value="forever">Forever</option>
119
                <input type="submit" class="action" value="Submit" />
138
                            [% END %]
120
</fieldset>
139
                        </select>
121
</form>
140
                        <p>Controls how long a patrons checkout history is kept for new patrons of this category. "Never"     anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</p>
141
                    </li>
142
            </ol>
143
            <span class="label">Enrolment period: </span>
144
            </br>
145
                    <fieldset>
146
                    <legend>Choose one</legend>
147
                            <ol>
148
                                <li>
149
                                    <label for="enrolmentperiod" style="width:6em;">In months: </label>
150
                                    <input type="number" class="enrolmentperiod" name="enrolmentperiod" id="enrolmentperiod" min="0" size="3" maxlength="3" value="[% IF category.enrolmentperiod %][% category.enrolmentperiod %][% END %]" /> months
151
                                </li>
152
                                <li>
153
                                    <label for="enrolmentperioddate" style="width:6em;">Until date: </label>
154
                                    <input type="text" class="enrolmentperioddate datepicker" name="enrolmentperioddate" id="enrolmentperioddate" value="[% category.enrolmentperioddate | $KohaDates %]" />
155
                                </li>
156
                            </ol>
157
                     </fieldset>
158
                    <br>
159
                    <input type="submit" class="action" value="Submit" />
160
    </fieldset>
161
    </form>
162
[% END %]
163
122
164
[% INCLUDE 'intranet-bottom.inc' %]
123
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt (-130 / +86 lines)
Lines 3-9 Link Here
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% USE Price %]
4
[% USE Price %]
5
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END%]
7
[% INCLUDE 'installer-doc-head-close.inc' %]
6
[% INCLUDE 'installer-doc-head-close.inc' %]
8
[% INCLUDE 'calendar.inc' %]
7
[% INCLUDE 'calendar.inc' %]
9
[% INCLUDE 'datatables.inc' %]
8
[% INCLUDE 'datatables.inc' %]
Lines 59-196 $(document).ready(function(){ Link Here
59
    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
58
    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
60
</div>
59
</div>
61
60
61
[% INCLUDE 'onboarding_messages.inc' %]
62
62
63
[%  IF (nok) %]
63
<h1 align="left"> Create koha administrator patron</h1>
64
        <form name="errors" method="post" action="onboarding.pl">
64
<p>
65
            <input type="hidden" name="step" value="3"/>
65
Now we will create a patron with superlibrarian permissions. Login with this to access Koha as a staff member will all permissions.
66
            <h1 align="left">There was an error</h1>
66
</p>
67
            <p>Try again </p>
67
<form name="createpatron" id="createpatron" method="post" action="onboarding.pl">
68
            <div>
68
    <fieldset class="rows">
69
            <ul>
69
         <input type="hidden" name="step" value="3"/>
70
            [% IF errorloginexists %]
70
         <input type="hidden" name="op" value="add_validate_patron" />
71
                <li id="ERROR_login_exist">Username/password already exists.</li>
71
            <legend id="library_management_lgd">Library management</legend>
72
            [% END %]
72
            <ol>
73
            [% IF errorcardnumberexists %]
73
            <h3>Patron identity</h3>
74
                <li id="ERROR_cardnumber">Cardnumber already in use.</li>
74
                <li>
75
            [% END %]
75
                    <label for="surname" class="required">Surname: </label>
76
            [% IF errorcardnumberlength %]
76
                    <input type="text" id="surname" name="surname" title="Please only enter letters in the surname field" value="[% surname |html %]" class="required" required="required" />
77
                <li id="ERROR_cardnumber">Cardnumber length is incorrect</li>
77
                    <span class="required">Required</span>
78
            [% END %]
78
                </li>
79
            [% IF errorshortpassword %]
79
                <li>
80
                <li id="ERROR_short_password">Password length is incorrect, must be at least [% minPasswordLength %] characters long.</li>
80
                    <label for="firstname" class="required">First name: </label>
81
            [% END %]
81
                    <input  type="text" name="firstname" title="Please only enter letters in the first name field" id="firstname" size="20" value="[% firstname |html %]" class="required" required="required">
82
            [% IF errorpasswordmismatch %]
82
                    <span class="required">Required</span>
83
                <li id="ERROR_password_mismatch">Passwords do not match.</li>
83
                </li>
84
            [% END %]
84
            </ol>
85
            </ul>
86
85
87
            </div>
86
            <ol>
88
            <input type="submit" name="step" value="Try again"/>
87
                <li>
89
        </form>
88
                    <label for="cardnumber" class="required">Card number: </label>
89
                    [% IF patrons && patrons > 1 %]
90
                        <input type="text" id="cardnumber" title="Please enter a cardnumber" class="noEnterSubmit valid" name="cardnumber" value="[% newcardnumber | html %]" class="required" required="required">
91
                    [% ELSE %]
92
                        <input type="text" id="cardnumber" title="Please enter a cardnumber" name="cardnumber" value="[% cardnumber | html %]" class="required" required="required">
93
                    [% END %]
94
                    <span class="required">Required</span>
95
                </li>
96
                <li>
90
97
98
                <!--require a foreach loop to get all the values for the library that the user has either imported (in web installer) or created in the first step of this onboarding tool-->
99
                    <label for="libraries" class="required"> Library: </label>
100
                    <select name="libraries" size="1" id="libraries">
91
101
92
<!--Create a patron screen 2-->
102
                     [% FOREACH library IN libraries %]
93
[% ELSIF op == 'add_validate' %]
103
                          <option name="libraries" value="[% library.branchcode %]"> [% library.branchname %]
94
          <!--New patron created-->
104
                     [% END %]
95
        <form name="patrondone" method="post" action="onboarding.pl">
96
            <input type="hidden" name="step" value="4"/>
97
            <h1 align="left"> Koha administrator patron </h1>
98
            <div>
99
                 <p> Success: administrator patron created!</p>
100
                 <p> To create another patron, go to Patrons -> New Patron. <br>
101
                More -> Set Permissions in a user page to gain superlibrarian permissions.
102
            </div>
103
            Next up:
104
            <input type="submit" name="start" value="Minimal item type setup"/>
105
        </form>
106
[% ELSE %]
107
<!--Create a patron screen 1-->
108
       <h1 align="left"> Create koha administrator patron</h1>
109
        <p>
110
        Now we will create a patron with superlibrarian permissions. Login with this to access Koha as a staff member will all permissions.
111
        </p>
112
        <form name="createpatron" id="createpatron" method="post" action="onboarding.pl">
113
            <fieldset class="rows">
114
                 <input type="hidden" name="step" value="3"/>
115
                 <input type="hidden" name="op" value="add_validate" />
116
                    <legend id="library_management_lgd">Library management</legend>
117
                    <ol>
118
                    <h3>Patron identity</h3>
119
                        <li>
120
                            <label for="surname" class="required">Surname: </label>
121
                            <input type="text" id="surname" name="surname" title="Please only enter letters in the surname field" value="[% surname |html %]" class="required" required="required" />
122
                            <span class="required">Required</span>
123
                        </li>
124
                        <li>
125
                            <label for="firstname" class="required">First name: </label>
126
                            <input  type="text" name="firstname" title="Please only enter letters in the first name field" id="firstname" size="20" value="[% firstname |html %]" class="required" required="required">
127
                            <span class="required">Required</span>
128
                        </li>
129
                    </ol>
130
131
                    <ol>
132
                        <li>
133
                            <label for="cardnumber" class="required">Card number: </label>
134
                            [% IF patrons && patrons > 1 %]
135
                                <input type="text" id="cardnumber" title="Please enter a cardnumber" class="noEnterSubmit valid" name="cardnumber" value="[% newcardnumber | html %]" class="required" required="required">
136
                            [% ELSE %]
137
                                <input type="text" id="cardnumber" title="Please enter a cardnumber" name="cardnumber" value="[% cardnumber | html %]" class="required" required="required">
138
                            [% END %]
139
                            <span class="required">Required</span>
140
                        </li>
141
                        <li>
142
143
                        <!--require a foreach loop to get all the values for the library that the user has either imported (in web installer) or created in the first step of this onboarding tool-->
144
                            <label for="libraries" class="required"> Library: </label>
145
                            <select name="libraries" size="1" id="libraries">
146
105
147
                             [% FOREACH library IN libraries %]
106
                        </select>
148
                                  <option name="libraries" value="[% library.branchcode %]"> [% library.branchname %]
107
                    <span class="required"> Required</span>
149
                             [% END %]
108
                </li>
109
                <li>
110
                    <label for="categorycode_entry" class="required"> Patron category</label>
111
                    <select id="categorycode_entry" name="categorycode_entry" onchange="update_category_code(this);">
112
                    [% FOREACH category IN categories %]
113
                        <option name="categorycode_entry" value = "[% category.categorycode %]">[%category.description %]</option>
114
                    [% END %]
115
                    </select>
116
                    <span class="required">Required</span><br><br>
117
                    <b>Note:</b> If you installed sample patron categories please select the "Staff" option in the patron categories dropdown box.
118
                </li>
119
            </ol>
150
120
151
                                </select>
121
            <ol>
152
                            <span class="required"> Required</span>
122
                    <h3> Koha administrator patron permissions</h3>
153
                        </li>
123
                    <li>
154
                        <li>
124
                        <label> superlibrarian</label>
155
                            <label for="categorycode_entry" class="required"> Patron category</label>
125
                    </li>
156
                            <select id="categorycode_entry" name="categorycode_entry" onchange="update_category_code(this);">
126
            </ol>
157
                            [% FOREACH category IN categories %]
127
            <ol>
158
                                <option name="categorycode_entry" value = "[% category.categorycode %]">[%category.description %]</option>
128
            <h3>OPAC/Staff Login</h3>
159
                            [% END %]
129
                <li>
160
                            </select>
130
                    <label for="userid" class="required">Username: </label>
161
                            <span class="required">Required</span><br><br>
131
                    <input type="text" name="userid" id ="userid" size="20" title="Please only enter a username of letters and numbers" value="[% userid |html %]" class="required" required="required" />
162
                            <b>Note:</b> If you installed sample patron categories please select the "Staff" option in the patron categories dropdown box.
132
                    <span class="required">Required</span>
163
                        </li>
133
                </li>
164
                    </ol>
134
                <li>
165
135
                    <label for="passwordlabel" class="required">Password: </label>
166
                    <ol>
136
                    <input type="password" name="password" id="password" size="20" value="[% member.password |html %]" class="required" required="required">
167
                            <h3> Koha administrator patron permissions</h3>
137
                    <span class="required">Required</span>
168
                            <input type="hidden" name="newflags" value="1"/>
138
                </li>
169
                            <li>
139
                <li>
170
                                <input type="hidden" class="flag parent" id="flag-0" name="flag" value="superlibrarian"/>
140
                    <label for="password2" class="required">Confirm password: </label>
171
                                <label name="permissioncode" for="flag-0"> superlibrarian</label>
141
                    <input type="password" id="password2" name="password2" size="20" value="" class="required" required="required">
172
                            </li>
142
                    <span class="required">Required</span>
173
                    </ol>
143
                </li>
174
                    <ol>
144
            </ol>
175
                    <h3>OPAC/Staff Login</h3>
145
        <p>
176
                        <li>
146
            To create another patron, go to Patrons -> New Patron. <br>
177
                            <input type="hidden" name="BorrowerMandatoryField" value = "[% BorrowerMandatoryField %]" />
147
            More -> Set Permissions in a user page to gain superlibrarian permissions.
178
                            <label for="userid" class="required">Username: </label>
148
        </p>
179
                            <input type="text" name="userid" id ="userid" size="20" title="Please only enter a username of letters and numbers" value="[% userid |html %]" class="required" required="required" />
149
    </fieldset>
180
                            <span class="required">Required</span>
150
    <br>
181
                        </li>
151
    <input type="submit" id="Submit" class="action" value="Submit"/>
182
                        <li>
152
</form>
183
                            <label for="passwordlabel" class="required">Password: </label>
184
                            <input type="password" name="password" id="password" size="20" value="[% member.password |html %]" class="required" required="required">
185
                            <span class="required">Required</span>
186
                        </li>
187
                        <li>
188
                            <label for="password2" class="required">Confirm password: </label>
189
                            <input type="password" id="password2" name="password2" size="20" value="" class="required" required="required">
190
                            <span class="required">Required</span>
191
                        </li>
192
                    </ol>
193
             </fieldset><br>
194
                <input type="submit" id="Submit" class="action" value="Submit"/>
195
     </form>
196
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt (-54 / +28 lines)
Lines 1-6 Link Here
1
<!-- includes for creating item type-->
1
<!-- includes for creating item type-->
2
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END%]
4
[% INCLUDE 'installer-doc-head-close.inc' %]
3
[% INCLUDE 'installer-doc-head-close.inc' %]
5
<head>
4
<head>
6
    <title>Create item type</title>
5
    <title>Create item type</title>
Lines 9-67 Link Here
9
    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
8
    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
10
</div>
9
</div>
11
10
12
[% IF (itemtypes && itemtypes.count >1) %]
11
[% INCLUDE 'onboarding_messages.inc' %]
13
12
14
     <meta http-equiv="refresh" content="0; url=/cgi-bin/koha/installer/onboarding.pl?step=5">
13
<!--Create a item type screen 1-->
14
<h1 align="center"> Create a new Item type </h1>
15
<p> Item types are used to group related items. Examples of item types are books, cds, and DVDs. <br><br> When adding to your institutions catalogue you will create an item of a particular item type. <br><br> Importantly item types are what you apply     circulation rules to. Circulation rules govern how your institution will lend its items, for example a circulation rule applied to the DVD item type may enforce a payment of $1.00 for borrowing any DVD.</p>
16
<form name="createitemform" method="post" action="onboarding.pl">
17
    <fieldset class="rows">
18
        <input type="hidden" name="step" value="4"/>
19
        <input type="hidden" name="op" value="add_validate_itemtype" />
20
        <ol>
21
            <li>
22
                <label for="itemtype" class="required">Item type code: </label>
23
                <input type="text" name="itemtype" pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" id="itemtype" size="10" maxlength="10"  class="required" required="required" value="[% itemtype.itemtype |html %]" />
24
                <span class="required">Required</span>
25
            </li>
15
26
16
[% ELSIF op == "add_validate" %]
27
            <li>
17
        [% IF message != "error_on_insert" %]
28
                <label for="description" class="required">Description: </label>
18
            <form name="createitemtype" method="post" action="onboarding.pl">
29
                <input type="text" name="description" id="description" title="Please only enter letters and/or numbers into this item type description" size="42" value="[% itemtype.description |html %]" class="required" required="required">
19
                <input type="hidden" name="step" value="5"/>
30
                <span class="required">Required</span>
20
                <h1 align="left"> New Item type </h1>
31
            </li>
21
                <div>
32
        </ol>
22
                    <p> Success: New item type created!</p>
33
    <br>
23
                    <p> To create another item type later and for more settings <br>
34
    <p> To create another item type later and for more settings <br>
24
                    go to: <br>
35
            go to: <br>
25
                    More -> Administration -> Item types <br>
36
            More -> Administration -> Item types <br>
26
                </div>
37
    </p>
27
                Next up:
28
                <input type="submit" value="Add a circulation rule"/>
29
            </form>
30
        [% ELSE %]
31
        <form name="retryitem" method="post" action="onboarding.pl">
32
            <input type="hidden" name="step" value="4"/>
33
            <h1 align="left">Failed </h1>
34
            <div>
35
                <p>Item type was not successfully created. </br>
36
                Please try again or contact your system administrator.
37
                </p>
38
            </div>
39
        </form>
40
        <!--Implement a if statement to check if the item type was successfully created or not -->
41
        [% END %]
42
[% ELSE %]
43
    <!--Create a item type screen 1-->
44
        <h1 align="center"> Create a new Item type </h1>
45
        <p> Item types are used to group related items. Examples of item types are books, cds, and DVDs. <br><br> When adding to your institutions catalogue you will create an item of a particular item type. <br><br> Importantly item types are what you apply     circulation rules to. Circulation rules govern how your institution will lend its items, for example a circulation rule applied to the DVD item type may enforce a payment of $1.00 for borrowing any DVD.</p>
46
        <form name="createitemform" method="post" action="onboarding.pl">
47
            <fieldset class="rows">
48
                <input type="hidden" name="step" value="4"/>
49
                <input type="hidden" name="op" value="add_validate" />
50
                <ol>
51
                    <li>
52
                        <label for="itemtype" class="required">Item type code: </label>
53
                        <input type="text" name="itemtype" pattern="[0-9A-Za-z]{1,10}" title="Please enter up to 10 letters and/or numbers" id="itemtype" size="10" maxlength="10"  class="required" required="required" value="[% itemtype.itemtype |html %]" />
54
                        <span class="required">Required</span>
55
                    </li>
56
38
57
                    <li>
39
    <input type="submit" class="action" value="Submit"/>
58
                        <label for="description" class="required">Description: </label>
40
</fieldset>
59
                        <input type="text" name="description" id="description" title="Please only enter letters and/or numbers into this item type description" size="42" value="[% itemtype.description |html %]" class="required" required="required">
41
</form>
60
                        <span class="required">Required</span>
61
                    </li>
62
                </ol>
63
            <br>
64
            <input type="submit" class="action" value="Submit"/>
65
        </fieldset>
66
        </form>
67
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt (-111 / +97 lines)
Lines 1-127 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Create Circulation rule</title>
2
<title>Create Circulation rule</title>
3
[% IF ( finish ) %]<meta http-equiv="refresh" content="10; url=/cgi-bin/koha/mainpage.pl">[% END %]
4
[% INCLUDE 'installer-doc-head-close.inc' %]
3
[% INCLUDE 'installer-doc-head-close.inc' %]
5
4
6
<div>
5
<div>
7
    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
6
    <h1 id="logo"><img alt="Koha" src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/> Welcome to Koha</h1>
8
</div>
7
</div>
9
8
10
[% IF (finish) %]
9
[% INCLUDE 'onboarding_messages.inc' %]
10
11
[% IF all_done %]
11
<h1>Congratulations you have finished and ready to use Koha</h1>
12
<h1>Congratulations you have finished and ready to use Koha</h1>
12
<a href="/cgi-bin/koha/mainpage.pl">Start using Koha</a>
13
<a href="/cgi-bin/koha/mainpage.pl">Start using Koha</a>
13
14
[% END %]
15
16
<!--Create a circulation rule screen 2-->
17
[% IF op == "add_validate" %]
18
        <!--New circulation rule created-->
19
        <form name="finish" method="post" action="onboarding.pl">
20
            <input type="hidden" name="op" value="finish" />
21
            <h1 align="left"> New circulation rule </h1>
22
            <div>
23
                 <p> Success: circulation rule created!</p>
24
                 <p> To create circulation rule, go to <br>
25
                 More -> Administration -> Circulation and Fine Rules
26
            </div>
27
                 Next up:
28
                 <input type="submit" name="op" value="Finish"/>
29
        </form>
30
[% ELSE %]
14
[% ELSE %]
31
<!--Create a circulation rule screen 1-->
15
    <h1 align="left"> Create a new circulation rule </h1>
32
       <h1 align="left"> Create a new circulation rule </h1>
16
    <form name="createcirculationrule" method="post" action="onboarding.pl">
33
       <form name="createcirculationrule" method="post" action="onboarding.pl">
17
        <fieldset class="rows">
34
            <fieldset class="rows">
18
           <input type="hidden" name="step" value="5"/>
35
                 <input type="hidden" name="step" value="5"/>
19
           <input type="hidden" name="op" value="add_validate_circ_rule" />
36
                 <input type="hidden" name="op" value="add_validate" />
20
              <ol>
37
                    <ol>
21
              <li>
38
                    <li>
22
                  <label for="branch" class="required"> Library branch</label>
39
                        <label for="branch" class="required"> Library branch</label>
23
                  <select name="branch" id="branchname" required="required">
40
                        <select name="branch" id="branchname" required="required">
24
                  <option value""> Choose</option>
41
                        <option value""> Choose</option>
25
                  <option value="*" selected="selected">All</option>
42
                        <option value="*" selected="selected">All</option>
26
                  [% FOREACH library IN libraries %]
43
                        [% FOREACH library IN libraries %]
27
                      <option id="branch" value="[% library.branchcode %]"> [% library.branchname %]</option>
44
                            <option id="branch" value="[% library.branchcode %]"> [% library.branchname %]</option>
28
                  [% END %]
45
                        [% END %]
29
                  </select>
46
                        </select>
30
                  <span class="required">Required</span>
47
                        <span class="required">Required</span>
31
              </li>
48
                    </li>
32
              <li>
49
                    <li>
33
                  <label for="categorycode" class="required">Patron category: </label>
50
                        <label for="categorycode" class="required">Patron category: </label>
34
                  <select name="categorycode" id="categorycodeselection" required="required" onchange = "update_categorycode(this);">
51
                        <select name="categorycode" id="categorycodeselection" required="required" onchange = "update_categorycode(this);">
35
                      <option value=""> Choose</option>
52
                            <option value=""> Choose</option>
36
                      <option value="*" selected="selected">All</option>
53
                            <option value="*" selected="selected">All</option>
37
                      [% FOREACH category IN categories %]
54
                            [% FOREACH category IN categories %]
38
                          <option id="categorycode" value = "[% category.categorycode %]"> [%category.description %]</option>
55
                                <option id="categorycode" value = "[% category.categorycode %]"> [%category.description %]</option>
39
                      [%END%]
56
                            [%END%]
40
                  </select>
57
                        </select>
41
                  <span class="required">Required</span>
58
                        <span class="required">Required</span>
42
              </li>
59
                    </li>
43
44
              <li>
45
                  <label for="itemtype"> Item type: </label>
46
                  <select id="itemtype" name="itemtype" required="required">
47
                  <option value""> Choose </option>
48
                  <option value="*" selected="selected">All</option>
49
                      [% FOREACH item IN itemtypes %]
50
                          <option name="itemtype" value = "[% item.itemtype %]"> [% item.itemtype %]
51
                      [%END%]
52
                  </select>
53
                  <span class="required"> Required</span>
54
              </li>
55
              <li>
56
                  <label for="maxissueqty" class="required">Current checkouts allowed: </label>
57
                  <input type="number" min="0" name="maxissueqty" title="Please only enter numbers" id="maxissueqty" size="10" value="50" class="required" required="required" />
58
                  <span class="required">Required</span>
59
              </li>
60
60
61
                    <li>
61
              <li>
62
                        <label for="itemtype"> Item type: </label>
62
                  <label for="issuelength" class="required">Loan period: </label>
63
                        <select id="itemtype" name="itemtype" required="required">
63
                  <input type="number" min="0" name="issuelength" title="Please only enter numbers" id="issuelength" size="10" value="14" class="required" required="required" />
64
                        <option value""> Choose </option>
64
                  <span class="required">Required</span>
65
                        <option value="*" selected="selected">All</option>
65
             </li>
66
                            [% FOREACH item IN itemtypes %]
66
             <li>
67
                                <option name="itemtype" value = "[% item.itemtype %]"> [% item.itemtype %]
67
                  <label for="lengthunit">Units: </label>
68
                            [%END%]
68
                  <select name="lengthunit" id="lengthunit" required="required">
69
                        </select>
69
                  <option value=""> Choose </option>
70
                        <span class="required"> Required</span>
70
                  [% SET units = 'days' %]
71
                    </li>
71
                  [% IF category %]
72
                    <li>
72
                      [% SET default_privacy = category.default_privacy %]
73
                        <label for="maxissueqty" class="required">Current checkouts allowed: </label>
73
                  [% END %]
74
                        <input type="number" min="0" name="maxissueqty" title="Please only enter numbers" id="maxissueqty" size="10" value="50" class="required" required="required" />
75
                        <span class="required">Required</span>
76
                    </li>
77
74
78
                    <li>
75
                  [% SWITCH units %]
79
                        <label for="issuelength" class="required">Loan period: </label>
76
                       [% CASE 'days' %]
80
                        <input type="number" min="0" name="issuelength" title="Please only enter numbers" id="issuelength" size="10" value="14" class="required" required="required" />
77
                             <option value="days" selected="selected">Days</option>
81
                        <span class="required">Required</span>
78
                             <option value="hours">Hours</option>
82
                   </li>
79
                       [% CASE 'hours' %]
83
                   <li>
80
                             <option value="days">Days</option>
84
                        <label for="lengthunit">Units: </label>
81
                             <option value="hours" selected="selected">Hours</option>
85
                        <select name="lengthunit" id="lengthunit" required="required">
82
                  [% END %]
86
                        <option value=""> Choose </option>
83
                  </select>
87
                        [% SET units = 'days' %]
84
               </li>
88
                        [% IF category %]
85
               <li>
89
                            [% SET default_privacy = category.default_privacy %]
86
                  <label for="renewalsallowed" class="required">Renewals allowed: </label>
90
                        [% END %]
87
                  <input type="number" min="0" name="renewalsallowed" title="Please only enter numbers" id="renewalsallowed" size="10" max="10" value="10" class="required" required="required" />
88
                  <span class="required">Required</span>
89
               </li>
91
90
92
                        [% SWITCH units %]
91
               <li>
93
                             [% CASE 'days' %]
92
                  <label for="renewalperiod" class="required">Renewals period: </label>
94
                                   <option value="days" selected="selected">Days</option>
93
                  <input type="number" min="0" name="renewalperiod" title="Please only enter numbers" id="renewalperiod" size="10" value="14" class="required" required="required" />
95
                                   <option value="hours">Hours</option>
94
                  <span class="required">Required</span>
96
                             [% CASE 'hours' %]
95
               </li>
97
                                   <option value="days">Days</option>
98
                                   <option value="hours" selected="selected">Hours</option>
99
                        [% END %]
100
                        </select>
101
                     </li>
102
                     <li>
103
                        <label for="renewalsallowed" class="required">Renewals allowed: </label>
104
                        <input type="number" min="0" name="renewalsallowed" title="Please only enter numbers" id="renewalsallowed" size="10" max="10" value="10" class="required" required="required" />
105
                        <span class="required">Required</span>
106
                     </li>
107
96
108
                     <li>
97
               <li>
109
                        <label for="renewalperiod" class="required">Renewals period: </label>
98
                  <label for="onshelfholds">On shelf holds allowed: </label>
110
                        <input type="number" min="0" name="renewalperiod" title="Please only enter numbers" id="renewalperiod" size="10" value="14" class="required" required="required" />
99
                  <select name="onshelfholds" id="onshelfholds" required="required">
111
                        <span class="required">Required</span>
100
                        <option value="">Choose</option>
112
                     </li>
101
                        <option value="1" selected="selected">Yes</option>
102
                        <option value="0">If any unavailable</option>
103
                        <option value="2">If all unavailable</option>
104
                  </select>
105
               </li>
106
            </ol>
107
            <p> To create circulation rule, go to <br>
108
            More -> Administration -> Circulation and Fine Rules
109
            </p>
113
110
114
                     <li>
111
        </fieldset><br>
115
                        <label for="onshelfholds">On shelf holds allowed: </label>
112
        <input type="submit" class="action" value="Submit"/>
116
                        <select name="onshelfholds" id="onshelfholds" required="required">
113
    </form>
117
                              <option value="">Choose</option>
118
                              <option value="1" selected="selected">Yes</option>
119
                              <option value="0">If any unavailable</option>
120
                              <option value="2">If all unavailable</option>
121
                        </select>
122
                     </li>
123
                  </ol>
124
            </fieldset><br>
125
                <input type="submit" class="action" value="Submit"/>
126
     </form>
127
[% END %]
114
[% END %]
128
- 

Return to bug 17855