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

(-)a/installer/onboarding.pl (-54 / +66 lines)
Lines 84-120 if ( $op && $op eq 'finish' ) Link Here
84
84
85
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
85
my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, );
86
$template->param(
86
$template->param(
87
     libraries   => $libraries,
87
    libraries   => $libraries,
88
     group_types => [
88
    group_types => [
89
     {
89
        {
90
            categorytype => 'searchdomain',
90
            categorytype => 'searchdomain',
91
            categories   => [
91
            categories   => [
92
               Koha::LibraryCategories->search(
92
                Koha::LibraryCategories->search(
93
                   { categorytype => 'searchdomain' }
93
                    { categorytype => 'searchdomain' }
94
               )
94
                )
95
            ],
95
            ],
96
     },
96
        },
97
     {
97
        {
98
            categorytype => 'properties',
98
            categorytype => 'properties',
99
            categories   => [
99
            categories   => [
100
               Koha::LibraryCategories->search(
100
                Koha::LibraryCategories->search(
101
                   { categorytype => 'properties' }
101
                    { categorytype => 'properties' }
102
               )
102
                )
103
            ],
103
            ],
104
     },
104
        },
105
     ]
105
    ]
106
);
106
);
107
107
108
109
#Select all the patron category records in the categories database table and give them to the template
108
#Select all the patron category records in the categories database table and give them to the template
110
    my $categories = Koha::Patron::Categories->search();
109
my $categories = Koha::Patron::Categories->search();
111
    $template->param( 'categories' => $categories, );
110
$template->param( 'categories' => $categories, );
112
111
113
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1
112
#Check if the $step variable equals 1 i.e. the user has clicked to create a library in the create library screen 1
114
    my $itemtypes = Koha::ItemTypes->search();
113
my $itemtypes = Koha::ItemTypes->search();
115
    $template->param( 'itemtypes' => $itemtypes, );
114
$template->param( 'itemtypes' => $itemtypes, );
116
115
117
if ( $step && $step == 1 ) {
116
if ( $step && $step == 1 ) {
117
118
    #store inputted parameters in variables
118
    #store inputted parameters in variables
119
    my $branchcode = $input->param('branchcode');
119
    my $branchcode = $input->param('branchcode');
120
    $branchcode = uc($branchcode);
120
    $branchcode = uc($branchcode);
Lines 152-158 if ( $step && $step == 1 ) { Link Here
152
#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
152
#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
153
}
153
}
154
elsif ( $step && $step == 2 ) {
154
elsif ( $step && $step == 2 ) {
155
    if ($op eq "add_validate_category"){
155
    if ( $op eq "add_validate_category" ) {
156
156
        #Initialising values
157
        #Initialising values
157
        my $searchfield  = $input->param('description') // q||;
158
        my $searchfield  = $input->param('description') // q||;
158
        my $categorycode = $input->param('categorycode');
159
        my $categorycode = $input->param('categorycode');
Lines 162-188 elsif ( $step && $step == 2 ) { Link Here
162
        $template->param( 'categorycode' => $categorycode );
163
        $template->param( 'categorycode' => $categorycode );
163
164
164
        my ( $template, $loggedinuser, $cookie ) =
165
        my ( $template, $loggedinuser, $cookie ) =
165
            C4::InstallAuth::get_template_and_user(
166
          C4::InstallAuth::get_template_and_user(
166
            {
167
            {
167
                template_name   => "/onboarding/onboardingstep2.tt",
168
                template_name   => "/onboarding/onboardingstep2.tt",
168
                query           => $input,
169
                query           => $input,
169
                type            => "intranet",
170
                type            => "intranet",
170
                authnotrequired => 0,
171
                authnotrequired => 0,
171
                flagsrequired =>
172
                flagsrequired =>
172
                { parameters => 'parameters_remaining_permissions' },
173
                  { parameters => 'parameters_remaining_permissions' },
173
                debug => 1,
174
                debug => 1,
174
            }
175
            }
175
            );
176
          );
176
177
177
        #Once the user submits the page, this code validates the input and adds it
178
      #Once the user submits the page, this code validates the input and adds it
178
        #to the database as a new patron category
179
      #to the database as a new patron category
179
        $categorycode = $input->param('categorycode');
180
        $categorycode = $input->param('categorycode');
180
        my $description           = $input->param('description');
181
        my $description           = $input->param('description');
181
        my $overduenoticerequired = $input->param('overduenoticerequired');
182
        my $overduenoticerequired = $input->param('overduenoticerequired');
182
        my $category_type         = $input->param('category_type');
183
        my $category_type         = $input->param('category_type');
183
        my $default_privacy       = $input->param('default_privacy');
184
        my $default_privacy       = $input->param('default_privacy');
184
        my $enrolmentperiod       = $input->param('enrolmentperiod');
185
        my $enrolmentperiod       = $input->param('enrolmentperiod');
185
        my $enrolmentperioddate   = $input->param('enrolmentperioddate') || undef;
186
        my $enrolmentperioddate = $input->param('enrolmentperioddate') || undef;
186
187
187
        #Converts the string into a date format
188
        #Converts the string into a date format
188
        if ($enrolmentperioddate) {
189
        if ($enrolmentperioddate) {
Lines 220-237 elsif ( $step && $step == 2 ) { Link Here
220
221
221
        $template->param( 'message' => $message );
222
        $template->param( 'message' => $message );
222
    }
223
    }
224
223
    #Create a patron
225
    #Create a patron
224
}
226
}
225
elsif ( $step && $step == 3 ) {
227
elsif ( $step && $step == 3 ) {
226
    my $firstpassword  = $input->param('password') || '';
228
    my $firstpassword  = $input->param('password')  || '';
227
    my $secondpassword = $input->param('password2') || '';
229
    my $secondpassword = $input->param('password2') || '';
228
230
229
230
    #Find all patron records in the database and hand them to the template
231
    #Find all patron records in the database and hand them to the template
231
    my %currentpatrons = Koha::Patrons->search();
232
    my %currentpatrons = Koha::Patrons->search();
232
    my $currentpatrons = values %currentpatrons;
233
    my $currentpatrons = values %currentpatrons;
233
    $template->param( 'patrons' =>$currentpatrons);
234
    $template->param( 'patrons' => $currentpatrons );
234
235
235
236
#Find all library records in the database and hand them to the template to display in the library dropdown box
236
#Find all library records in the database and hand them to the template to display in the library dropdown box
237
    my $libraries =
237
    my $libraries =
Lines 264-270 elsif ( $step && $step == 3 ) { Link Here
264
264
265
#Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry
265
#Incrementing the highest existing patron cardnumber to prevent duplicate cardnumber entry
266
266
267
    my $existing_cardnumber = $schema->resultset('Borrower')->get_column('cardnumber')->max() // 0;
267
    my $existing_cardnumber =
268
      $schema->resultset('Borrower')->get_column('cardnumber')->max() // 0;
268
269
269
    my $new_cardnumber = $existing_cardnumber + 1;
270
    my $new_cardnumber = $existing_cardnumber + 1;
270
    $template->param( "newcardnumber" => $new_cardnumber );
271
    $template->param( "newcardnumber" => $new_cardnumber );
Lines 366-373 elsif ( $step && $step == 3 ) { Link Here
366
            $newdata{city}           = "";
367
            $newdata{city}           = "";
367
368
368
#Hand tne the dateexpiry of the patron based on the patron category it is created from
369
#Hand tne the dateexpiry of the patron based on the patron category it is created from
369
            my $patron_category = Koha::Patron::Categories->find( $newdata{categorycode} );
370
            my $patron_category =
370
            $newdata{dateexpiry} = $patron_category->get_expiry_date( $newdata{dateenrolled} );
371
              Koha::Patron::Categories->find( $newdata{categorycode} );
372
            $newdata{dateexpiry} =
373
              $patron_category->get_expiry_date( $newdata{dateenrolled} );
371
374
372
#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
375
#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
373
            my $borrowernumber = &AddMember(%newdata);
376
            my $borrowernumber = &AddMember(%newdata);
Lines 394-406 elsif ( $step && $step == 3 ) { Link Here
394
                }
397
                }
395
398
396
                # construct flags
399
                # construct flags
397
                my @userflags = $schema->resultset('Userflag')->search({},{
400
                my @userflags = $schema->resultset('Userflag')->search(
398
                        order_by => { -asc =>'bit'},
401
                    {},
399
                        }
402
                    {
403
                        order_by => { -asc => 'bit' },
404
                    }
400
                );
405
                );
401
406
402
#Setting superlibrarian permissions for new patron
407
                #Setting superlibrarian permissions for new patron
403
                my $flags = Koha::Patrons->find($borrowernumber)->set({flags=>1})->store;
408
                my $flags =
409
                  Koha::Patrons->find($borrowernumber)->set( { flags => 1 } )
410
                  ->store;
404
411
405
                #Error handling checking if the patron was created successfully
412
                #Error handling checking if the patron was created successfully
406
                if ( !$borrowernumber ) {
413
                if ( !$borrowernumber ) {
Lines 427-434 elsif ( $step && $step == 4 ) { Link Here
427
              { parameters => 'parameters_remaining_permissions' },
434
              { parameters => 'parameters_remaining_permissions' },
428
            debug => 1,
435
            debug => 1,
429
        }
436
        }
430
    );
437
      );
431
  if ($op eq "add_validate"){
438
    if ( $op eq "add_validate" ) {
432
        my $description   = $input->param('description');
439
        my $description   = $input->param('description');
433
        my $itemtype_code = $input->param('itemtype');
440
        my $itemtype_code = $input->param('itemtype');
434
        $itemtype_code = uc($itemtype_code);
441
        $itemtype_code = uc($itemtype_code);
Lines 555-585 elsif ( $step && $step == 5 ) { Link Here
555
562
556
#Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to.
563
#Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to.
557
        if ( $branch eq "*" ) {
564
        if ( $branch eq "*" ) {
558
            my $search_default_rules = $schema->resultset('DefaultCircRule')->count();
565
            my $search_default_rules =
559
            my $insert_default_rules = $schema->resultset('Issuingrule')->new(
566
              $schema->resultset('DefaultCircRule')->count();
560
                    { maxissueqty => $maxissueqty, onshelfholds => $onshelfholds }
567
            my $insert_default_rules =
561
                );
568
              $schema->resultset('Issuingrule')
569
              ->new(
570
                { maxissueqty => $maxissueqty, onshelfholds => $onshelfholds }
571
              );
562
        }
572
        }
573
563
#Allows for the 'All' option to work when selecting all patron categories for a circulation rule to apply to.
574
#Allows for the 'All' option to work when selecting all patron categories for a circulation rule to apply to.
564
        elsif ( $bor eq "*" ) {
575
        elsif ( $bor eq "*" ) {
565
576
566
            my $search_default_rules = $schema->resultset('DefaultCircRule')->count();
577
            my $search_default_rules =
567
            my $insert_default_rules = $schema->resultset('Issuingrule')->new(
578
              $schema->resultset('DefaultCircRule')->count();
568
                        { maxissueqty => $maxissueqty}
579
            my $insert_default_rules = $schema->resultset('Issuingrule')
569
            );
580
              ->new( { maxissueqty => $maxissueqty } );
570
        }
581
        }
571
582
572
#Allows for the 'All' option to work when selecting all itemtypes for a circulation rule to apply to
583
#Allows for the 'All' option to work when selecting all itemtypes for a circulation rule to apply to
573
        elsif ( $itemtype eq "*" ) {
584
        elsif ( $itemtype eq "*" ) {
574
            my $search_default_rules = $schema->resultset('DefaultCircRule')->search({},{
585
            my $search_default_rules =
586
              $schema->resultset('DefaultCircRule')->search(
587
                {},
588
                {
575
                    branchcode => $branch
589
                    branchcode => $branch
576
                    }
590
                }
577
591
578
            );
592
              );
579
593
580
            my $insert_default_rules = $schema->resultset('Issuingrule')->new(
594
            my $insert_default_rules = $schema->resultset('Issuingrule')
581
                           { branchcode => $branch, onshelfholds => $onshelfholds }
595
              ->new( { branchcode => $branch, onshelfholds => $onshelfholds } );
582
            );
583
        }
596
        }
584
597
585
        my $issuingrule = Koha::IssuingRules->find(
598
        my $issuingrule = Koha::IssuingRules->find(
586
- 

Return to bug 17855