From aca2102297680fa57fe507262d9152892ab2c007 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 7 Jan 2014 07:50:43 -0500 Subject: [PATCH] Bug 6254 [QA Followup 1] - can't set patron privacy by default * Adds default privacy column to summary table * Adds default privacy to delete category summary * Adds "AFTER categorycode" to the database update * Whitespace cleanup and formatting for affected code blocks * Switch basic DBI queries to DBIx::Class to simplify code * Adds reference to misc/cronjobs/batch_anonymise.pl to description --- admin/categorie.pl | 66 +++++---------- installer/data/mysql/updatedatabase.pl | 2 +- .../prog/en/modules/admin/categorie.tt | 89 ++++++++++++-------- .../prog/en/modules/admin/patron-attr-types.tt | 2 +- 4 files changed, 77 insertions(+), 82 deletions(-) diff --git a/admin/categorie.pl b/admin/categorie.pl index abd73f8..5a7e5fd 100755 --- a/admin/categorie.pl +++ b/admin/categorie.pl @@ -45,6 +45,7 @@ use C4::Branch; use C4::Output; use C4::Dates; use C4::Form::MessagingPreferences; +use Koha::Database; sub StringSearch { my ($searchstring,$type)=@_; @@ -188,36 +189,14 @@ if ($op eq 'add_form') { ################## DELETE_CONFIRM ################################## # called by default form, used to confirm deletion of data in DB } elsif ($op eq 'delete_confirm') { + my $schema = Koha::Database->new()->schema(); $template->param(delete_confirm => 1); - my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select count(*) as total from borrowers where categorycode=?"); - $sth->execute($categorycode); - my $total = $sth->fetchrow_hashref; - $sth->finish; - $template->param(total => $total->{'total'}); - - my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); - $sth2->execute($categorycode); - my $data=$sth2->fetchrow_hashref; - $sth2->finish; - if ($total->{'total'} >0) { - $template->param(totalgtzero => 1); - } - - $template->param( description => $data->{'description'}, - enrolmentperiod => $data->{'enrolmentperiod'}, - enrolmentperioddate => C4::Dates::format_date($data->{'enrolmentperioddate'}), - upperagelimit => $data->{'upperagelimit'}, - dateofbirthrequired => $data->{'dateofbirthrequired'}, - enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'}), - overduenoticerequired => $data->{'overduenoticerequired'}, - issuelimit => $data->{'issuelimit'}, - reservefee => sprintf("%.2f",$data->{'reservefee'}), - hidelostitems => $data->{'hidelostitems'}, - category_type => $data->{'category_type'}, - ); - # END $OP eq DELETE_CONFIRM + my $count = $schema->resultset('Borrower')->search( { categorycode => $categorycode } )->count(); + my $category = $schema->resultset('Category')->find($categorycode); + $category->enrolmentperioddate( C4::Dates::format_date( $category->enrolmentperioddate() ) ); + $template->param( category => $category, patrons_in_category => $count ); +# END $OP eq DELETE_CONFIRM ################## DELETE_CONFIRMED ################################## # called by delete_confirm, used to effectively confirm deletion of data in DB } elsif ($op eq 'delete_confirmed') { @@ -243,21 +222,22 @@ if ($op eq 'add_form') { while ( my $branch = $sth->fetchrow_hashref ) { push @selected_branches, $branch; } - my %row = ( - categorycode => $results->[$i]{'categorycode'}, - description => $results->[$i]{'description'}, - enrolmentperiod => $results->[$i]{'enrolmentperiod'}, - enrolmentperioddate => C4::Dates::format_date($results->[$i]{'enrolmentperioddate'}), - upperagelimit => $results->[$i]{'upperagelimit'}, - dateofbirthrequired => $results->[$i]{'dateofbirthrequired'}, - enrolmentfee => sprintf("%.2f",$results->[$i]{'enrolmentfee'}), - overduenoticerequired => $results->[$i]{'overduenoticerequired'}, - issuelimit => $results->[$i]{'issuelimit'}, - reservefee => sprintf("%.2f",$results->[$i]{'reservefee'}), - hidelostitems => $results->[$i]{'hidelostitems'}, - category_type => $results->[$i]{'category_type'}, - "type_".$results->[$i]{'category_type'} => 1, - branches => \@selected_branches, + my %row = ( + branches => \@selected_branches, + categorycode => $results->[$i]{'categorycode'}, + description => $results->[$i]{'description'}, + enrolmentperiod => $results->[$i]{'enrolmentperiod'}, + upperagelimit => $results->[$i]{'upperagelimit'}, + dateofbirthrequired => $results->[$i]{'dateofbirthrequired'}, + overduenoticerequired => $results->[$i]{'overduenoticerequired'}, + issuelimit => $results->[$i]{'issuelimit'}, + hidelostitems => $results->[$i]{'hidelostitems'}, + category_type => $results->[$i]{'category_type'}, + default_privacy => $results->[$i]{'default_privacy'}, + enrolmentfee => sprintf( "%.2f", $results->[$i]{'enrolmentfee'} ), + reservefee => sprintf( "%.2f", $results->[$i]{'reservefee'} ), + enrolmentperioddate => C4::Dates::format_date( $results->[$i]{'enrolmentperioddate'} ), + "type_" . $results->[$i]{'category_type'} => 1, ); if (C4::Context->preference('EnhancedMessagingPreferences')) { my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'}); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 3854752..4065a46 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7914,7 +7914,7 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.15.00.XXX"; if(CheckVersion($DBversion)) { - $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default'"); + $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default' AFTER categorycode"); print "Upgrade to $DBversion done (Bug 6254 - can't set patron privacy by default)\n"; SetVersion($DBversion); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt index 56b667a..8169fa9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt @@ -1,7 +1,7 @@ [% INCLUDE 'doc-head-open.inc' %] Koha › Administration › Patron categories › [% IF ( add_form ) %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %] [% IF ( add_validate ) %]Data recorded[% END %] -[% IF ( delete_confirm ) %][% IF ( totalgtzero ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] +[% IF ( delete_confirm ) %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] [% IF ( delete_confirmed ) %]Category deleted[% END %] [% INCLUDE 'doc-head-close.inc' %] [% INCLUDE 'calendar.inc' %] @@ -113,7 +113,7 @@ @@ -200,7 +200,7 @@ [% END %] [% END %] - Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value. + Select All branches if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
  • @@ -221,7 +221,7 @@ [% END %] - Controls how long a patrons checkout history is kept for new patrons of this category. "Default" lets the library decide, "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. + Controls how long a patrons checkout history is kept for new patrons of this category. "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob batch_anonymise.pl which should be set up by your system administrator.
  • @@ -242,43 +242,54 @@
    - [% END %] [% IF ( delete_confirm ) %] - -
    -
    - [% IF ( totalgtzero ) %] - Category [% categorycode |html %] is in use. Deletion not possible![% ELSE %] -Confirm deletion of category [% categorycode |html %][% END %] + +
    + + [% IF ( patrons_in_category > 0 ) %] + Category [% categorycode |html %] is in use. Deletion not possible! + [% ELSE %] + Confirm deletion of category [% categorycode |html %] + [% END %] + -[% IF ( totalgtzero ) %]
    This category is used [% total %] times. Deletion not possible
    [% END %] - - - - - - - - - - - - -
    Category code: [% categorycode |html %]
    Description: [% description |html %]
    Enrollment period: - [% IF ( enrolmentperiod ) %] - [% enrolmentperiod %] months - [% ELSE %] - until [% enrolmentperioddate %] - [% END %] -
    Age required: [% dateofbirthrequired %] years
    Upperage limit: [% upperagelimit %] years
    Enrollment fee: [% enrolmentfee %]
    Receives overdue notices: [% IF ( overduenoticerequired ) %]Yes[% ELSE %]No[% END %]
    Lost items in staff client[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]
    Hold fee: [% reservefee %]
    -
    [% IF ( totalgtzero ) %] - - [% ELSE %] - - Cancel - [% END %]
    + [% IF ( patrons_in_category > 0 ) %] +
    This category is used [% patrons_in_category %] times. Deletion not possible
    + [% END %] + + + + + + + + + + + + + + +
    Category code: [% categorycode |html %]
    Description: [% description |html %]
    Enrollment period: + [% IF ( enrolmentperiod ) %] + [% enrolmentperiod %] months + [% ELSE %] + until [% enrolmentperioddate %] + [% END %] +
    Age required: [% category.dateofbirthrequired %] years
    Upperage limit: [% category.upperagelimit %] years
    Enrollment fee: [% category.enrolmentfee | format('%.02f') %]
    Receives overdue notices: [% IF ( category.overduenoticerequired ) %]Yes[% ELSE %]No[% END %]
    Lost items in staff client[% IF ( category.hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]
    Hold fee: [% category.reservefee | format('%.02f') %]
    Default privacy: [% category.default_privacy %]
    + +
    + [% IF ( patrons_in_category > 0 ) %] + + [% ELSE %] + + Cancel + [% END %] +
    +
    + [% END %] [% IF ( delete_confirmed ) %] @@ -319,6 +330,7 @@ Confirm deletion of category [% categorycode |html %][% END %] Messaging [% END %] Branches limitations + Default privacy     @@ -392,6 +404,9 @@ Confirm deletion of category [% categorycode |html %][% END %] No limitation [% END %] + + [% loo.default_privacy %] + Edit Delete diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt index e561ae5..2fb8a68 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -202,7 +202,7 @@ function CheckAttributeTypeForm(f) { [% END %] [% END %] - Select All if this attribute type must to be displayed all the time. Otherwise select librairies you want to associate with this value. + Select All if this attribute type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
  • -- 1.7.2.5