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

(-)a/installer/onboarding.pl (-50 / +27 lines)
Lines 10-17 use CGI qw ( -utf8 ); Link Here
10
use List::MoreUtils qw/uniq/;
10
use List::MoreUtils qw/uniq/;
11
use Digest::MD5 qw(md5_base64);
11
use Digest::MD5 qw(md5_base64);
12
use Encode qw( encode );
12
use Encode qw( encode );
13
14
#Internal modules 
15
use C4::Koha;
13
use C4::Koha;
16
use C4::Auth;
14
use C4::Auth;
17
use C4::Context;
15
use C4::Context;
Lines 46-52 my $input = new CGI; Link Here
46
my $query    = new CGI;
44
my $query    = new CGI;
47
my $step     = $query->param('step');
45
my $step     = $query->param('step');
48
46
49
#Getting the appropriate template to display to the user-->
47
#Getting the appropriate template to display to the user
50
my ( $template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user(
48
my ( $template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user(
51
     {
49
     {
52
        template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt",
50
        template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt",
Lines 87-94 if ( $op && $op eq 'finish' ) { #If the value of $op equals 'finish' then redire Link Here
87
85
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
86
#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
89
my $start = $query->param('start');
87
my $start = $query->param('start');
90
$template->param('start'=>$start); #Hand the start variable back to the template
88
$template->param('start'=>$start);
91
if ( $start && $start eq 'Start setting up my Koha' ){ 
89
90
if ( $start && $start eq 'Start setting up my Koha' ){
92
    my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
91
    my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
93
    $template->param(libraries   => $libraries,
92
    $template->param(libraries   => $libraries,
94
              group_types => [
93
              group_types => [
Lines 101-120 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
101
              ]
100
              ]
102
    );
101
    );
103
102
104
}elsif (  $start && $start eq 'Add a patron category' ){
105
106
#Select all the patron category records in the categories database table and store them in the newly declared variable $categories
107
    my $categories = Koha::Patron::Categories->search(); 
108
    $template->param(
109
        categories => $categories,
110
    ); #Hand the variable categories back to the template
111
112
}elsif ( $start && $start eq 'Add an item type' ){
113
     my $itemtypes = Koha::ItemTypes->search();
114
     $template->param(
115
             itemtypes => $itemtypes,
116
    );#Hand the variable itemtypes back to the template
117
118
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 
103
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1 
119
}elsif ( $step && $step == 1 ) {
104
}elsif ( $step && $step == 1 ) {
120
    my $createlibrary = $query->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary variable
105
    my $createlibrary = $query->param('createlibrary'); #Store the inputted library branch code and name in $createlibrary variable
Lines 157-162 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
157
    my $createcat = $query->param('createcat'); #Store the inputted category code and name in $createcat
142
    my $createcat = $query->param('createcat'); #Store the inputted category code and name in $createcat
158
    $template->param('createcat'=>$createcat);
143
    $template->param('createcat'=>$createcat);
159
144
145
#Select all the patron category records in the categories database table and give them to the template
146
    my $categories = Koha::Patron::Categories->search(); 
147
    $template->param(
148
        categories => $categories,
149
    );
150
160
    #Initialising values
151
    #Initialising values
161
    my $searchfield   = $input->param('description') // q||;
152
    my $searchfield   = $input->param('description') // q||;
162
    my $categorycode  = $input->param('categorycode');
153
    my $categorycode  = $input->param('categorycode');
Lines 195-201 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
195
                        dateonly   => 1,
186
                        dateonly   => 1,
196
                    }
187
                    }
197
            );
188
            );
198
        }
189
    }
199
190
200
    #Adds a new patron category to the database
191
    #Adds a new patron category to the database
201
    $category = Koha::Patron::Category->new({
192
    $category = Koha::Patron::Category->new({
Lines 275-294 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
275
                    :()
266
                    :()
276
    }
267
    }
277
268
278
#  unless(Check_Userid($userid, $borrowernumber)){
279
#          push @errors, "ERROR_login_exist";
280
#  }
281
  push @errors, "ERROR_password_mismatch" if $firstpassword ne $secondpassword;
269
  push @errors, "ERROR_password_mismatch" if $firstpassword ne $secondpassword;
282
  push @errors, "ERROR_short_password" if ($firstpassword && $minpw && $firstpassword ne '****' && (length($firstpassword) < $minpw));
270
  push @errors, "ERROR_short_password" if ($firstpassword && $minpw && $firstpassword ne '****' && (length($firstpassword) < $minpw));
283
#
271
272
284
#Passing errors to template
273
#Passing errors to template
285
    $nok = $nok || scalar(@errors);
274
   $nok = $nok || scalar(@errors);
286
275
287
    if($nok){
276
   if($nok){
288
277
289
       foreach my $error (@errors){
278
      foreach my $error (@errors){
290
           if ($error eq 'ERROR_password_mismatch'){
279
          if ($error eq 'ERROR_password_mismatch'){
291
               $template->param(errorpasswordmismatch => 1);
280
              $template->param(errorpasswordmismatch => 1);
292
           }
281
           }
293
           if ($error eq 'ERROR_login_exist'){
282
           if ($error eq 'ERROR_login_exist'){
294
                $template->param(errorloginexists =>1);
283
                $template->param(errorloginexists =>1);
Lines 368-383 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
368
             $sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?");
357
             $sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?");
369
             $sth->execute($module_flags, $borrowernumber);
358
             $sth->execute($module_flags, $borrowernumber);
370
359
371
              #Error handling checking if the patron was created successfully
360
             #Error handling checking if the patron was created successfully
372
              if(!$borrowernumber){
361
             if(!$borrowernumber){
373
                   push @messages, {type=> 'error', code => 'error_on_insert'};
362
                  push @messages, {type=> 'error', code => 'error_on_insert'};
374
              }else{
363
             }else{
375
                   push @messages, {type=> 'message', code => 'success_on_insert'};
364
                  push @messages, {type=> 'message', code => 'success_on_insert'};
376
              }
365
             }
377
            }
366
          }
378
        }
367
        }
379
    }
368
    }
380
}elsif ( $step && $step == 4){
369
 }elsif ( $step && $step == 4){
381
    my $createitemtype = $input->param('createitemtype');
370
    my $createitemtype = $input->param('createitemtype');
382
    $template->param('createitemtype'=> $createitemtype );
371
    $template->param('createitemtype'=> $createitemtype );
383
372
Lines 554-561 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
554
            } else {
543
            } else {
555
            $sth_insert->execute($branch, $onshelfholds);
544
            $sth_insert->execute($branch, $onshelfholds);
556
            }
545
            }
557
        }   
546
        }
558
#End new code
559
547
560
       my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br });
548
       my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br });
561
       if($issuingrule){
549
       if($issuingrule){
Lines 566-582 if ( $start && $start eq 'Start setting up my Koha' ){ Link Here
566
           Koha::IssuingRule->new()->set($params)->store(); 
554
           Koha::IssuingRule->new()->set($params)->store(); 
567
       }
555
       }
568
    }
556
    }
569
570
        my @messages;
571
572
        my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br });
573
        if($issuingrule){
574
            $issuingrule->set($params)->store();
575
            push @messages, {type=> 'error', code => 'error_on_insert'};#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. 
576
        }else{
577
            Koha::IssuingRule->new()->set($params)->store(); 
578
        }
579
    }
580
}
557
}
581
558
582
output_html_with_http_headers $input, $cookie, $template->output;
559
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt (-1 / +1 lines)
Lines 36-42 Link Here
36
36
37
<!--Header for the koha onboarding tool-->
37
<!--Header for the koha onboarding tool-->
38
<div>
38
<div>
39
    <h1 align="center"> Welcome to Koha</h1>
39
    <h1 align="center"> Welcome to Koha test if in correct repo</h1>
40
    <h1 id="logo"><img alt="Koha" style="width:50%;margin:auto;display:block;align:center;"  src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/></h1>
40
    <h1 id="logo"><img alt="Koha" style="width:50%;margin:auto;display:block;align:center;"  src="[% interface %]/[% theme %]/img/koha.org-logo.gif"/></h1>
41
</div>
41
</div>
42
 [% IF libraries.count > 0 %]
42
 [% IF libraries.count > 0 %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep2.tt (-3 / +2 lines)
Lines 284-290 $(document).ready(function(){ Link Here
284
        
284
        
285
285
286
[% ELSE %] <!--Else display create patron category screen 1 where the user can input values to create their first patron category-->
286
[% ELSE %] <!--Else display create patron category screen 1 where the user can input values to create their first patron category-->
287
    <h1 align="left"> Create a new Patron Category</h1>
287
    <h1 align="left"> Create a new Patron Category testing rwq</h1>
288
       <form id="category_form" method="post" action="onboarding.pl">  
288
       <form id="category_form" method="post" action="onboarding.pl">  
289
       <fieldset class="rows">
289
       <fieldset class="rows">
290
            <input type="hidden" name="step" value="2"/>
290
            <input type="hidden" name="step" value="2"/>
Lines 292-298 $(document).ready(function(){ Link Here
292
                <ol>
292
                <ol>
293
                    <li>
293
                    <li>
294
                        <label for="categorycode" class="required">Category code: </label>
294
                        <label for="categorycode" class="required">Category code: </label>
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" />
295
                        <input type="text" pattern="^[A-Z]{1,2}" title="Please enter 1 or 2 capital letters" name="categorycode" value="[% category.categorycode |html %]" size="10" maxlength="10" class="required" required="required" />
296
                        <span class="required">Required</span>
296
                        <span class="required">Required</span>
297
                    </li>
297
                    </li>
298
298
299
- 

Return to bug 17855