Bug 22664: Link names in order search results instead of numbers
[srvgit] / installer / onboarding.pl
index 83859e7..77aa120 100755 (executable)
@@ -22,15 +22,14 @@ use C4::Context;
 use C4::InstallAuth;
 use CGI qw ( -utf8 );
 use C4::Output;
-use C4::Members;
+use C4::Members qw(checkcardnumber);
 use Koha::Patrons;
 use Koha::Libraries;
 use Koha::Database;
 use Koha::DateUtils;
+use Koha::Patrons;
 use Koha::Patron::Categories;
-use Koha::Patron::Category;
 use Koha::ItemTypes;
-use Koha::IssuingRule;
 use Koha::IssuingRules;
 
 #Setting variables
@@ -174,12 +173,10 @@ if ( $step == 3 ) {
                 branchcode   => scalar $input->param('libraries'),
                 categorycode => scalar $input->param('categorycode_entry'),
                 userid       => scalar $input->param('userid'),
-                password     => scalar $input->param('password'),
-                password2    => scalar $input->param('password2'),
                 privacy      => "default",
                 address      => "",
                 city         => "",
-                flags => 1,    # Will be superlibrarian
+                flags        => 1,    # Will be superlibrarian
             };
 
             my $patron_category =
@@ -187,13 +184,17 @@ if ( $step == 3 ) {
             $patron_data->{dateexpiry} =
               $patron_category->get_expiry_date( $patron_data->{dateenrolled} );
 
-            my $borrowernumber = C4::Members::AddMember(%$patron_data);
+            eval {
+                my $patron = Koha::Patron->new($patron_data)->store;
+                $patron->set_password({ password =>  $firstpassword });
+            };
 
             #Error handling checking if the patron was created successfully
-            if ($borrowernumber) {
+            unless ($@) {
                 push @messages, { code => 'success_on_insert_patron' };
             }
             else {
+                warn $@;
                 push @messages, { code => 'error_on_insert_patron' };
             }
         }
@@ -250,7 +251,6 @@ if ( $step == 5 ) {
             branchcode      => $branchcode,
             categorycode    => $categorycode,
             itemtype        => $itemtype,
-            maxissueqty     => $maxissueqty,
             renewalsallowed => $renewalsallowed,
             renewalperiod   => $renewalperiod,
             issuelength     => $issuelength,
@@ -261,11 +261,29 @@ if ( $step == 5 ) {
         my $issuingrule = Koha::IssuingRule->new($params);
         eval { $issuingrule->store; };
 
-        unless ($@) {
-            push @messages, { code => 'success_on_insert_circ_rule' };
-        }
-        else {
+        if ($@) {
             push @messages, { code => 'error_on_insert_circ_rule' };
+        } else {
+
+            eval {
+                Koha::CirculationRules->set_rules(
+                    {
+                        categorycode => $categorycode,
+                        itemtype     => $itemtype,
+                        branchcode   => $branchcode,
+                        rules        => {
+                            maxissueqty => $maxissueqty,
+                        }
+                    }
+                );
+            };
+
+            unless ($@) {
+                push @messages, { code => 'success_on_insert_circ_rule' };
+            }
+            else {
+                push @messages, { code => 'error_on_insert_circ_rule' };
+            }
         }
     }