From 4846a773787f7ddd328f109c419ce4bb78d51492 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Wed, 21 Dec 2016 04:09:35 +0000 Subject: [PATCH] Bug 17855 - The 'All' dropdown box option is working for patron categories, item types, and libraries for the create circulation rule screen of the onboarding tool. Test plan: 1. Go through the web installer and the onboarding tool (up to the point of creating a circulation rule in the onboarding tool) as outlined here: https://koha-community.org/manual/installation/html/ 2. When creating a circulation rule using the onboarding tool apply it to all patron categories, libraries and item types by leaving the default 'All' option in the respective dropdown boxes selected. 3.Having finished the onboarding tool log into the staff interface and go to Checkouts 4. Check out 2 items (of differing item types, e.g. book and cd) to 2 different patrons (these patrons need to be of different patron types to test the circulation rule properly), in two two different libraries 5. Notice that the due date for all the checkouts is the same. This is because the 'All' dropdown option is successfully applying the circulation rule to all libraries, item types, and patron categories as intended. Bug 17855 - 'All' option is working to select for a circulation rule to apply to all patron categories. Tested where there were two circulation rules; 'All, Books' as 5 days and 'All, Computer Files' as 2 days. Checked out each to 5 different types of borrowers, due date reflects the specified loan period. Test plan: 1. Go through the web installer and the onboarding tool (up to the point of creating a circulation rule in the onboarding tool) as outlined here: https://koha-community.org/manual/installation/html/ 2. When creating a circulation rule using the onboarding tool apply it to all patron categories by leaving the default 'All' option in the Patron categories dropdown box selected. 3.Having finished the onboarding tool log into the staff interface and go to Checkouts 4. Check out an item (this item must be the same item type that you applied the aforementioned circulation rule to) to 2 different patrons (these patrons need to be of different patron types to test the circulation rule properly). 5. Notice that the due date is the same for both patrons. This is because the 'All' dropdown button for patron categories in the onboarding tool is successfully applying the circulation rule to all patron categories. Bug 17855 - Working login of the web installer and onboarding tool Test plan: 1. Go through the web installer and onboarding tool as outlined here: https://koha-community.org/manual/installation/html/ 2. Notice that the you can login after the onboarding tool in order to access the Koha main page Item type 'All' choice now working also. Tested same as previous. Library 'All' option now working for circulation rule, though more testing is needed. Cleaned up some other text and added a description to Create a Patron --- installer/onboarding.pl | 112 ++++++++++++---- .../prog/en/modules/onboarding/onboardingstep0.tt | 2 +- .../prog/en/modules/onboarding/onboardingstep1.tt | 2 +- .../prog/en/modules/onboarding/onboardingstep3.tt | 10 +- .../prog/en/modules/onboarding/onboardingstep4.tt | 2 - .../prog/en/modules/onboarding/onboardingstep5.tt | 142 +++++++++------------ 6 files changed, 158 insertions(+), 112 deletions(-) diff --git a/installer/onboarding.pl b/installer/onboarding.pl index 0024db5..5435db5 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -6,6 +6,7 @@ use diagnostics; use Modern::Perl; + use C4::InstallAuth; #External modules use CGI qw ( -utf8 ); @@ -53,7 +54,7 @@ my $query = new CGI; my $step = $query->param('step'); #Getting the appropriate template to display to the user--> -my ( $template, $loggedinuser, $cookie) = get_template_and_user( +my ( $template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user( { template_name => "/onboarding/onboardingstep" . ( $step ? $step : 0 ) . ".tt", query => $query, @@ -180,7 +181,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my $message; my $category; - my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + my ( $template, $loggedinuser, $cookie ) = C4::InstallAuth::get_template_and_user( { template_name => "/onboarding/onboardingstep2.tt", query => $input, @@ -193,7 +194,6 @@ if ( $start && $start eq 'Start setting up my Koha' ){ #Once the user submits the page, this code validates the input and adds it #to the database as a new patron category - my $categorycode = $input->param('categorycode'); my $description = $input->param('description'); my $overduenoticerequired = $input->param('overduenoticerequired'); @@ -238,7 +238,6 @@ if ( $start && $start eq 'Start setting up my Koha' ){ #Create a patron }elsif ( $step && $step == 3 ){ - my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); $template->param(libraries => $libraries, group_types => [ @@ -257,15 +256,13 @@ if ( $start && $start eq 'Start setting up my Koha' ){ categories => $categories, ); - my $input = new CGI; my $op = $input->param('op') // 'list'; my @messages; my @errors; - my $nok = $input->param('nok'); - my ($template, $loggedinuser, $cookie)= get_template_and_user({ + my ($template, $loggedinuser, $cookie)= C4::InstallAuth::get_template_and_user({ template_name => "/onboarding/onboardingstep3.tt", query => $input, type => "intranet", @@ -290,25 +287,22 @@ if ( $start && $start eq 'Start setting up my Koha' ){ $newdata{dateexpiry} = '12/10/2016'; $newdata{privacy} = "default"; - $newdata{'cardnumber'} = undef if $newdata{'cardnumber'} =~ /^\s*$/; - if(my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ + if(my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ push @errors, $error_code == 1 ? 'ERROR_cardnumber_already_exists' - :$error_code == 2 + :$error_code == 2 ? 'ERROR_cardnumber_length' :() - } + } #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 my $borrowernumber = &AddMember(%newdata); - #Create a hash named member2 and fillit with the borrowernumber of the borrower that has just been created my %member2; $member2{'borrowernumber'}=$borrowernumber; my $flag = $input->param('flag'); - if ($input->param('newflags')) { my $dbh=C4::Context->dbh(); my @perms = $input->multi_param('flag'); @@ -354,7 +348,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my $op = $input->param('op') // 'list'; my $message; - my( $template, $borrowernumber, $cookie) = get_template_and_user( + my( $template, $borrowernumber, $cookie) = C4::InstallAuth::get_template_and_user( { template_name => "/onboarding/onboardingstep4.tt", query => $input, type => "intranet", @@ -372,14 +366,14 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my $description = $input->param('description'); #store the input from the form - only 2 fields - $itemtype= Koha::ItemType->new( + my $thisitemtype= Koha::ItemType->new( { itemtype => $itemtype_code, description => $description, } ); - eval{ $itemtype->store; }; + eval{ $thisitemtype->store; }; #Error messages - if($itemtype){ + if($thisitemtype){ $message = 'success_on_insert'; }else{ $message = 'error_on_insert'; @@ -387,11 +381,8 @@ if ( $start && $start eq 'Start setting up my Koha' ){ $template->param('message' => $message); } - - - - }elsif ( $step && $step == 5){ + #Fetching all the existing categories to display in a drop down box my $categories; $categories= Koha::Patron::Categories->search(); @@ -420,8 +411,7 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my $input = CGI->new; my $dbh = C4::Context->dbh; - my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "/onboarding/onboardingstep5.tt", + my ($template, $loggedinuser, $cookie) = C4::InstallAuth::get_template_and_user({template_name => "/onboarding/onboardingstep5.tt", query => $input, type => "intranet", authnotrequired => 0, @@ -442,7 +432,6 @@ if ( $start && $start eq 'Start setting up my Koha' ){ my $op = $input->param('op') || q{}; if($op eq 'add_validate'){ - my $type = $input->param('type'); my $br = $branch; my $bor = $input->param('categorycode'); @@ -468,6 +457,81 @@ if ( $start && $start eq 'Start setting up my Koha' ){ lengthunit => $lengthunit, onshelfholds => $onshelfholds, }; + 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 $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 = ?"); + + $sth_search->execute(); + my $res = $sth_search->fetchrow_hashref(); + if ($res->{total}) { + $sth_update->execute($maxissueqty, $onshelfholds); + } else { + $sth_insert->execute($maxissueqty, $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 = ? + |); + + $sth_search->execute(); + my $res = $sth_search->fetchrow_hashref(); + if ($res->{total}) { + $sth_update->execute($maxissueqty); + } else { + $sth_insert->execute($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 = ?"); + $sth_search->execute($branch); + my $res = $sth_search->fetchrow_hashref(); + if ($res->{total}) { + $sth_update->execute($onshelfholds, $branch); + } else { + $sth_insert->execute($branch, $onshelfholds); + } + } +#End new code + + my $issuingrule = Koha::IssuingRules->find({categorycode => $bor, itemtype => $itemtype, branchcode => $br }); + if($issuingrule){ + $issuingrule->set($params)->store(); + 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. + + }else{ + Koha::IssuingRule->new()->set($params)->store(); + } + } my @messages; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt index 8eed408..9d18344 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep0.tt @@ -39,7 +39,7 @@

Welcome to Koha

Koha

-

We're just going to set up a few things......

+

You haven't installed some sample data, so we're just going to set up a few more things...

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt index 44c86ce..bde6ca5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep1.tt @@ -92,7 +92,7 @@
  • - + Required
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt index 8191801..ff0745b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep3.tt @@ -49,7 +49,11 @@
    -
      + Library Management +

      + Now we will create a patron with superlibrarian permissions. Login with this to access Koha as a staff member will all permissions. +

      +

        Patron Identity

      1. @@ -64,11 +68,11 @@
      - Library Management +
      1. - + Required
      2. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt index 73400ff..fe6fb59 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep4.tt @@ -20,8 +20,6 @@ [% IF itemtypes.count > 0 %]
        - h no! Patron was not created

        -

        You do not need to create a item type as you have already installed the sample item type data previously

        diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt index c00c7ca..6bd611a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt @@ -1,18 +1,9 @@ - [% INCLUDE 'doc-head-open.inc' %] - +Create Circulation rule [% IF ( finish ) %][% END %] [% INCLUDE 'installer-doc-head-close.inc' %] - -Create Circulation rule - - - - - -

        Welcome to Koha

        Koha

        @@ -28,10 +19,8 @@ [% IF op == "add_validate" %] - - +

        New Circulation rule

        -

        Success: New circulation rule created!

        To create circulation rule, go to
        @@ -40,15 +29,9 @@ Next up:

        - - - -[% ELSE %] +[% ELSE %]

        Create a new Circulation rule

        -
        @@ -57,7 +40,7 @@
      3. - + + + [% FOREACH item IN itemtypes %]
      4. +
      5. + + + Required +
      6. + +
      7. + + + Required +
      8. +
      9. + + - Required -
      10. - -
      11. - - - Required -
      12. - -
      13. - - - Required -
      14. - -
      15. - - -
      16. - -
      17. - - - Required -
      18. - -
      19. - - - Required -
      20. - -
      21. - - -
      22. -
      + +
    1. + + + Required +
    2. + +
    3. + + + Required +
    4. + +
    5. + + +
    6. +

    -[% END %] +[% END %] -- 2.1.4