@@ -, +, @@ throughout the whole of the onboarding.pl script. --- installer/onboarding.pl | 103 ++++++++---------------------------------------- 1 file changed, 17 insertions(+), 86 deletions(-) --- a/installer/onboarding.pl +++ a/installer/onboarding.pl @@ -82,7 +82,7 @@ my $dbh = DBI->connect( ); #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. -my $op = $input->param('op'); +my $op = $input->param('op') || ''; $template->param( 'op' => $op ); my $schema = Koha::Database->new()->schema(); @@ -277,10 +277,6 @@ elsif ( $step && $step == 3 ) { my $existing_cardnumber = $schema->resultset('Borrower')->get_column('cardnumber')->max(); - warn $existing_cardnumber; - -#my $exisiting_cardnumber = my $sth_search = -# $dbh->prepare("SELECT MAX(cardnumber) FROM borrowers"); my $new_cardnumber = $existing_cardnumber + 1; $template->param( "newcardnumber" => $new_cardnumber ); @@ -563,98 +559,33 @@ elsif ( $step && $step == 5 ) { my @messages; -#New code from smart-rules.tt starts here. Needs to be added to library #Allows for the 'All' option to work when selecting all libraries for a circulation rule to apply to. if ( $branch eq "*" ) { my $search_default_rules = $schema->resultset('DefaultCircRule')->count(); -# my $sth_search = $dbh->prepare( -# "SELECT count(*) AS total -# FROM default_circ_rules" -# ); -# my $sth_insert = $dbh->prepare( -# "INSERT INTO default_circ_rules -# (maxissueqty, onshelfholds) -# VALUES (?, ?)" -# ); -# my $sth_update = $dbh->prepare( -# "UPDATE default_circ_rules -# SET maxissueqty = ?, onshelfholds = ?" -# ); - - -# my $search_default_rules = $schema->resultset('DefaultCircRule')->count(); -# warn $search_default_rules; - -# my $res = $search_default_rules->fetchrow_hashref(); -# if ( $res->{total} ) { -# $sth_update->execute( $maxissueqty, $onshelfholds ); - -# my $update_default_rules = $schema->resultset('DefaultCircrule')->set({maxissueqty => $maxissueqty}, {onshelfholds => $onshelfholds }); -# } -# else { -# $sth_insert->execute( $maxissueqty, $onshelfholds ); - my $insert_default_rules = $schema->resultset('Issuingrule')->set([ - { maxissueqty => $maxissueqty, onshelfholds => $onshelfholds }, - ]); -# } + my $insert_default_rules = $schema->resultset('Issuingrule')->new( + { maxissueqty => $maxissueqty, onshelfholds => $onshelfholds } + ); } - #Allows for the 'All' option to work when selecting all patron categories for a circulation rule to apply to. - if ( $bor eq "*" ) { - my $sth_search = $dbh->prepare( - "SELECT count(*) AS total - FROM default_circ_rules" - ); - my $sth_insert = $dbh->prepare( - q| - INSERT INTO default_circ_rules - (maxissueqty) - VALUES (?) - | - ); - my $sth_update = $dbh->prepare( - q| - UPDATE default_circ_rules - SET maxissueqty = ? - | - ); + elsif ( $bor eq "*" ) { - $sth_search->execute(); - my $res = $sth_search->fetchrow_hashref(); - if ( $res->{total} ) { - $sth_update->execute($maxissueqty); - } - else { - $sth_insert->execute($maxissueqty); - } + my $search_default_rules = $schema->resultset('DefaultCircRule')->count(); + my $insert_default_rules = $schema->resultset('Issuingrule')->new( + { maxissueqty => $maxissueqty} + ); } #Allows for the 'All' option to work when selecting all itemtypes for a circulation rule to apply to - if ( $itemtype eq "*" ) { - my $sth_search = $dbh->prepare( - "SELECT count(*) AS total - FROM default_branch_circ_rules - WHERE branchcode = ?" - ); - my $sth_insert = $dbh->prepare( - "INSERT INTO default_branch_circ_rules - (branchcode, onshelfholds) - VALUES (?, ?)" - ); - my $sth_update = $dbh->prepare( - "UPDATE default_branch_circ_rules - SET onshelfholds = ? - WHERE branchcode = ?" + elsif ( $itemtype eq "*" ) { + my $search_default_rules = $schema->resultset('DefaultCircRule')->search({},{ + branchcode => $branch + } + ); - $sth_search->execute($branch); - my $res = $sth_search->fetchrow_hashref(); - if ( $res->{total} ) { - $sth_update->execute( $onshelfholds, $branch ); - } - else { - $sth_insert->execute( $branch, $onshelfholds ); - } + my $insert_default_rules = $schema->resultset('Issuingrule')->new( + { branchcode => $branch, onshelfholds => $onshelfholds } + ); } my $issuingrule = Koha::IssuingRules->find( --