Bugzilla – Attachment 10477 Details for
Bug 8309
Koha namespace organisation, first implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Categories management
Categories-management.patch (text/plain), 31.12 KB, created by
Paul Poulain
on 2012-06-25 13:05:45 UTC
(
hide
)
Description:
Categories management
Filename:
MIME Type:
Creator:
Paul Poulain
Created:
2012-06-25 13:05:45 UTC
Size:
31.12 KB
patch
obsolete
>From d60a4192cea4c6800b7efe71d40d7a9bb8dd5832 Mon Sep 17 00:00:00 2001 >From: Paul Poulain <paul.poulain@biblibre.com> >Date: Mon, 25 Jun 2012 14:48:15 +0200 >Subject: [PATCH] Categories management > >This package is a POC to manage the Categories table. It contains : >* Category.pm (DB, DataObject and BusinessLogic levels) >* the Category.t test >* categorie.pl DBIx::Classed > * updating copyright > * removing a lot of useless files > * tabs replaced by 4 spaces, result in some minor changes > * use [% IF condition %] in templates, to avoid some pl level hacks > >http://bugs.koha-community.org/show_bug.cgi?id=8309 >--- > Koha/BusinessLogic/Category.pm | 5 + > Koha/DB/Borrower.pm | 4 +- > Koha/DB/Branch2.pm | 4 +- > Koha/DB/Category.pm | 76 +++++ > Koha/DataObject/Category.pm | 5 + > admin/categorie.pl | 305 ++++++++------------ > .../prog/en/modules/admin/categorie.tt | 34 +-- > .../lib/KohaTest/Koha/BusinessLogic/Category.t | 24 ++ > 8 files changed, 251 insertions(+), 206 deletions(-) > create mode 100644 Koha/BusinessLogic/Category.pm > create mode 100644 Koha/DB/Category.pm > create mode 100644 Koha/DataObject/Category.pm > create mode 100644 t/db_dependent/lib/KohaTest/Koha/BusinessLogic/Category.t > >diff --git a/Koha/BusinessLogic/Category.pm b/Koha/BusinessLogic/Category.pm >new file mode 100644 >index 0000000..1a83ad2 >--- /dev/null >+++ b/Koha/BusinessLogic/Category.pm >@@ -0,0 +1,5 @@ >+package Koha::BusinessLogic::Category; >+ >+use Modern::Perl; >+use Moose; >+extends (qw(Koha::DataObject::Category)); >diff --git a/Koha/DB/Borrower.pm b/Koha/DB/Borrower.pm >index 9f033f5..398b0ac 100644 >--- a/Koha/DB/Borrower.pm >+++ b/Koha/DB/Borrower.pm >@@ -17,7 +17,9 @@ my $schema = Koha::Schema->connect( > 'dbi:mysql:dbname='.C4::Context->config("database"), > C4::Context->config("user"), > C4::Context->config("pass"), >- { AutoCommit => 1 }, >+ { AutoCommit => 1 >+# cursor_class => 'DBIx::Class::Cursor::Cached', >+ }, > ); > > sub create { >diff --git a/Koha/DB/Branch2.pm b/Koha/DB/Branch2.pm >index 6bdbb08..3ccfa18 100644 >--- a/Koha/DB/Branch2.pm >+++ b/Koha/DB/Branch2.pm >@@ -7,6 +7,8 @@ use Koha::Schema; > > use Moose; > >+# the attributes must be exactly what is in the database. If you declare something that is not in the database >+# adding or updating will fail, complaining for an attribute (declared) here that is not a column > has 'branchcode' => (is => 'rw', required => 1, isa => 'Str'); > has 'branchname' => (is => 'rw', required => 1, isa => 'Str'); > has 'branchaddress1' => (is => 'rw', required => 0, isa => 'Str'); >@@ -31,7 +33,7 @@ my $schema = Koha::Schema->connect( > C4::Context->config("user"), > C4::Context->config("pass"), > { AutoCommit => 1, >- cursor_class => 'DBIx::Class::Cursor::Cached', >+# cursor_class => 'DBIx::Class::Cursor::Cached', > }, > ); > >diff --git a/Koha/DB/Category.pm b/Koha/DB/Category.pm >new file mode 100644 >index 0000000..78f54d8 >--- /dev/null >+++ b/Koha/DB/Category.pm >@@ -0,0 +1,76 @@ >+package Koha::DB::Category; >+ >+use Modern::Perl; >+use C4::Context; #FIXME = create a Koha package for KOHA_CONF reading >+ >+use Koha::Schema; >+ >+use Moose; >+ >+# the attributes must be exactly what is in the database. If you declare something that is not in the database >+# adding or updating will fail, complaining for an attribute (declared) here that is not a column >+has 'categorycode' => ( is => 'rw', required => 1, isa => 'Str' ); >+has 'description' => ( is => 'rw', required => 1, isa => 'Str' ); >+has 'enrolmentperiod' => ( is => 'rw', required => 0, isa => 'Int' ); >+has 'enrolmentperioddate' => ( is => 'rw', required => 0, isa => 'Str' ); >+has 'upperagelimit' => ( is => 'rw', required => 0, isa => 'Int' ); >+has 'dateofbirthrequired' => ( is => 'rw', required => 0, isa => 'Str' ); >+has 'finetype' => ( is => 'rw', required => 0, isa => 'Str' ); >+has 'bulk' => ( is => 'rw', required => 0, isa => 'Int' ); >+has 'enrolmentfee' => ( is => 'rw', required => 0, isa => 'Str' ); >+has 'overduenoticerequired' => ( is => 'rw', required => 0, isa => 'Int' ); >+has 'issuelimit' => ( is => 'rw', required => 0, isa => 'Str' ); #FIXME : this column is unused : not filled by admin/categories or used anywhere >+has 'reservefee' => ( is => 'rw', required => 0, isa => 'Str' ); >+has 'hidelostitems' => >+ ( is => 'rw', required => 0, isa => 'Str', default => 0 ); >+has 'category_type' => ( is => 'rw', required => 0, isa => 'Str' ); >+ >+# FIXME : we need a package to read the schema and connect to the database >+my $schema = Koha::Schema->connect( >+ 'dbi:mysql:dbname=' . C4::Context->config("database"), >+ C4::Context->config("user"), >+ C4::Context->config("pass"), >+ { >+ AutoCommit => 1, >+ >+ # cursor_class => 'DBIx::Class::Cursor::Cached', # FIXME does not work, ask why on a mailing list of IRC >+ mysql_enable_utf8 => 1, # REQUIRED to handle properly utf8 >+ }, >+); >+ >+sub create { >+ my ($self) = @_; >+ $schema->resultset('Category') >+ ->create( # FIXME : the issuelimit field is unused, remove the grep once the column has been removed from the database >+ { map { $_ => $self->$_ } grep {$_ ne 'issuelimit'} $schema->source('Category')->columns } ); >+} >+ >+sub read { >+ my ( $self, $category ) = @_; >+ return $schema->resultset('Category')->search( >+ $category, >+ { >+ cache_for => 300, >+ result_class => 'DBIx::Class::ResultClass::HashRefInflator' # HashRefInflator return an array of hashref, which is what we usually need >+ # FIXME : improve the read to return a Category object when needed >+ # defaulting to HashRefInflator sounds like a good idea >+ } >+ ); >+} >+ >+sub update { >+ my ( $self, $category ) = @_; >+ return $schema->resultset('Category') >+ ->search( { 'categorycode' => $category->{categorycode} } ) >+ ->update($category); >+} >+ >+sub delete { >+ my ( $self, $category ) = @_; >+ $schema->resultset('Category')->search($category)->delete; >+} >+ >+sub columns { >+ my ( $self, $category ) = @_; >+ return $schema->source('Category')->columns; >+} >diff --git a/Koha/DataObject/Category.pm b/Koha/DataObject/Category.pm >new file mode 100644 >index 0000000..0cd5b06 >--- /dev/null >+++ b/Koha/DataObject/Category.pm >@@ -0,0 +1,5 @@ >+package Koha::DataObject::Category; >+ >+use Modern::Perl; >+use Moose; >+extends (qw(Koha::DB::Category)); >diff --git a/admin/categorie.pl b/admin/categorie.pl >index 7a02a5d..5d99627 100755 >--- a/admin/categorie.pl >+++ b/admin/categorie.pl >@@ -1,7 +1,8 @@ > #!/usr/bin/perl > > #script to administer the categories table >-#written 20/02/2002 by paul.poulain@free.fr >+# Copyright 2000-2002 Katipo Communications >+# Copyright 2002, 2012 BibLibre ()paul.poulain@biblibre.com) > > # ALGO : > # this script use an $op to know what to do. >@@ -18,8 +19,6 @@ > # if $op=delete_confirm > # - we delete the record having primkey=$primkey > >- >-# Copyright 2000-2002 Katipo Communications > # > # This file is part of Koha. > # >@@ -37,223 +36,155 @@ > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > > use strict; >+ > #use warnings; FIXME - Bug 2505 > use CGI; > use C4::Context; > use C4::Auth; > use C4::Output; >-use C4::Dates; >+#use C4::Dates; > use C4::Form::MessagingPreferences; >- >-sub StringSearch { >- my ($searchstring,$type)=@_; >- my $dbh = C4::Context->dbh; >- $searchstring=~ s/\'/\\\'/g; >- my @data=split(' ',$searchstring); >- my $count=@data; >- my $sth=$dbh->prepare("Select * from categories where (description like ?) order by category_type,description,categorycode"); >- $sth->execute("$data[0]%"); >- my @results; >- while (my $data=$sth->fetchrow_hashref){ >- push(@results,$data); >- } >- # $sth->execute; >- $sth->finish; >- return (scalar(@results),\@results); >-} >+use Koha::BusinessLogic::Category; >+use Koha::BusinessLogic::Borrower; > > my $input = new CGI; >-my $searchfield=$input->param('description'); >+my $searchfield=$input->param('description'); # FIXME : for categories, this is useless (datatable handle that much better) > my $script_name="/cgi-bin/koha/admin/categorie.pl"; > my $categorycode=$input->param('categorycode'); > my $op = $input->param('op'); > > my ($template, $loggedinuser, $cookie) > = get_template_and_user({template_name => "admin/categorie.tmpl", >- query => $input, >- type => "intranet", >- authnotrequired => 0, >- flagsrequired => {parameters => 1}, >- debug => 1, >- }); >- >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { parameters => 1 }, >+ debug => 1, >+ }); > > $template->param(script_name => $script_name, >- categorycode => $categorycode, >- searchfield => $searchfield); >- >+ categorycode => $categorycode, >+ searchfield => $searchfield >+); > > ################## ADD_FORM ################################## > # called by default. Used to create form to add or modify a record > if ($op eq 'add_form') { >- $template->param(add_form => 1); >- >- #---- if primkey exists, it's a modify action, so read values to modify... >- my $data; >- if ($categorycode) { >- my $dbh = C4::Context->dbh; >- my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?"); >- $sth->execute($categorycode); >- $data=$sth->fetchrow_hashref; >- $sth->finish; >- } >- >- $data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} eq '0000-00-00'); >+ $template->param(add_form => 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'}, >- DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), >- SMSSendDriver => C4::Context->preference("SMSSendDriver"), >- TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"), >- "type_".$data->{'category_type'} => 1, >- ); >- if (C4::Context->preference('EnhancedMessagingPreferences')) { >- C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template); >+ #---- if primkey exists, it's a modify action, so read values to modify... >+ my $data; >+ if ($categorycode) { >+ $data = Koha::BusinessLogic::Category->read({'categorycode' => $categorycode})->first; > } >- # END $OP eq ADD_FORM >+ $template->param( >+ %{$data}, >+ DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), >+ SMSSendDriver => C4::Context->preference("SMSSendDriver"), >+ TalkingTechItivaPhone => >+ C4::Context->preference("TalkingTechItivaPhoneNotification"), >+ ); >+ if ( C4::Context->preference('EnhancedMessagingPreferences') ) { >+ C4::Form::MessagingPreferences::set_form_values( >+ { categorycode => $categorycode }, $template ); >+ } >+ >+ # END $OP eq ADD_FORM > ################## ADD_VALIDATE ################################## > # called by add_form, used to insert/modify data in DB > } elsif ($op eq 'add_validate') { >- $template->param(add_validate => 1); >- my $is_a_modif = $input->param("is_a_modif"); >- my $dbh = C4::Context->dbh; >- if($input->param('enrolmentperioddate')){ >- $input->param('enrolmentperioddate' => C4::Dates::format_date_in_iso($input->param('enrolmentperioddate')) ); >- } >- >- if ($is_a_modif) { >- my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?"); >- $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode')); >- $sth->finish; >- } else { >- my $sth=$dbh->prepare("INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)"); >- $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type')); >- $sth->finish; >- } >- if (C4::Context->preference('EnhancedMessagingPreferences')) { >- C4::Form::MessagingPreferences::handle_form_action($input, >- { categorycode => $input->param('categorycode') }, $template); >+ $template->param( add_validate => 1 ); >+ if ( $input->param('enrolmentperioddate') ) { >+ $input->param( >+ 'enrolmentperioddate' => C4::Dates::format_date_in_iso( >+ $input->param('enrolmentperioddate') >+ ) >+ ); > } >- print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; >- exit; > >- # END $OP eq ADD_VALIDATE >-################## DELETE_CONFIRM ################################## >-# called by default form, used to confirm deletion of data in DB >-} elsif ($op eq 'delete_confirm') { >- $template->param(delete_confirm => 1); >+ if ($input->param("is_a_modif")) { >+ Koha::BusinessLogic::Category->update({ map { $_ => $input->param($_) } grep {$_ ne 'issuelimit'} # FIXME : remove grep when issuelimit has been removed from the database >+ Koha::BusinessLogic::Category->columns }); >+ } >+ else { >+ Koha::BusinessLogic::Category->new({ map { $_ => $input->param($_) } grep {$_ ne 'issuelimit'} # FIXME : remove grep when issuelimit has been removed from the database >+ Koha::BusinessLogic::Category->columns })->create; >+ } >+ if ( C4::Context->preference('EnhancedMessagingPreferences') ) { >+ C4::Form::MessagingPreferences::handle_form_action( $input, >+ { categorycode => $input->param('categorycode') }, $template ); >+ } >+ print >+"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; >+ exit; > >- 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); >- } >+ # END $OP eq ADD_VALIDATE >+################## DELETE_CONFIRM ################################## >+ # called by default form, used to confirm deletion of data in DB >+} >+elsif ( $op eq 'delete_confirm' ) { >+ $template->param( delete_confirm => 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 >-################## DELETE_CONFIRMED ################################## >-# called by delete_confirm, used to effectively confirm deletion of data in DB >-} elsif ($op eq 'delete_confirmed') { >- $template->param(delete_confirmed => 1); >- my $dbh = C4::Context->dbh; >- my $categorycode=uc($input->param('categorycode')); >- my $sth=$dbh->prepare("delete from categories where categorycode=?"); >- $sth->execute($categorycode); >- $sth->finish; >- print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; >- exit; >+ # Retrieve how many borrowers are using this categorycode >+ # retrieving a scalar result in retrieving the number of lines >+ # FIXME = this is not a real SQL count(*), so it's inefficient. A specific method in Koha::Business::Borrowers for that is needed ! >+ my $total = Koha::BusinessLogic::Borrower->read({'me.categorycode' => $categorycode })->all; >+ $template->param( total => $total); > >- # END $OP eq DELETE_CONFIRMED >-} else { # DEFAULT >- $template->param(else => 1); >- my @loop; >- my ($count,$results)=StringSearch($searchfield,'web'); >- for (my $i=0; $i < $count; $i++){ >- 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); >- if (C4::Context->preference('EnhancedMessagingPreferences')) { >- my $brief_prefs = _get_brief_messaging_prefs($results->[$i]{'categorycode'}); >- $row{messaging_prefs} = $brief_prefs if @$brief_prefs; >- } >- push @loop, \%row; >- } >- $template->param(loop => \@loop); >- # check that I (institution) and C (child) exists. otherwise => warning to the user >- my $dbh = C4::Context->dbh; >- my $sth=$dbh->prepare("select category_type from categories where category_type='C'"); >- $sth->execute; >- my ($categoryChild) = $sth->fetchrow; >- $template->param(categoryChild => $categoryChild); >- $sth=$dbh->prepare("select category_type from categories where category_type='I'"); >- $sth->execute; >- my ($categoryInstitution) = $sth->fetchrow; >- $template->param(categoryInstitution => $categoryInstitution); >- $sth->finish; >+ my $data = Koha::BusinessLogic::Category->read({'categorycode' => $categorycode})->first; > >+ $template->param( >+ %{$data} >+ ); > >-} #---- END $OP eq DEFAULT >+ # 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' ) { >+ $template->param( delete_confirmed => 1 ); >+ Koha::BusinessLogic::Category->delete( >+ { 'categorycode' => $categorycode } ); >+ print >+"Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=categorie.pl\"></html>"; >+ exit; >+ >+ # END $OP eq DELETE_CONFIRMED >+} >+else { # DEFAULT >+ my @loop = Koha::BusinessLogic::Category->read()->all; >+ $template->param( >+ else => 1, >+ loop => \@loop, >+ ); >+ >+} #---- END $OP eq DEFAULT > output_html_with_http_headers $input, $cookie, $template->output; > > exit 0; > >-sub _get_brief_messaging_prefs { >- my $categorycode = shift; >- my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); >- my $results = []; >- PREF: foreach my $option ( @$messaging_options ) { >- my $pref = C4::Members::Messaging::GetMessagingPreferences( { categorycode => $categorycode, >- message_name => $option->{'message_name'} } ); >- next unless $pref->{'transports'}; >- my $brief_pref = { >- message_attribute_id => $option->{'message_attribute_id'}, >- message_name => $option->{'message_name'}, >- $option->{'message_name'} => 1 >- }; >- foreach my $transport ( keys %{$pref->{'transports'}} ) { >- push @{ $brief_pref->{'transports'} }, { transport => $transport }; >- } >- push @$results, $brief_pref; >- } >- return $results; >-} >+# FIXME : should not be here but in a Koha::BusinessLogic Messaging package >+#sub _get_brief_messaging_prefs { >+# my $categorycode = shift; >+# my $messaging_options = C4::Members::Messaging::GetMessagingOptions(); >+# my $results = []; >+# PREF: foreach my $option (@$messaging_options) { >+# my $pref = C4::Members::Messaging::GetMessagingPreferences( >+# { >+# categorycode => $categorycode, >+# message_name => $option->{'message_name'} >+# } >+# ); >+# next unless $pref->{'transports'}; >+# my $brief_pref = { >+# message_attribute_id => $option->{'message_attribute_id'}, >+# message_name => $option->{'message_name'}, >+# $option->{'message_name'} => 1 >+# }; >+# foreach my $transport ( keys %{ $pref->{'transports'} } ) { >+# push @{ $brief_pref->{'transports'} }, { transport => $transport }; >+# } >+# push @$results, $brief_pref; >+# } >+# return $results; >+#} >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 e2425af..89b566a 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' %] > <title>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 total >0 %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] > [% IF ( delete_confirmed ) %]Category deleted[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] > <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >@@ -95,7 +95,7 @@ > > <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › [% IF ( add_form ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %] > [% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › Data recorded[% END %] >-[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF ( totalgtzero ) %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] >+[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › [% IF total > 0 %]Cannot delete: Category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] > [% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/categorie.pl">Patron categories</a> › Category deleted[% END %] > [% IF ( else ) %]Patron categories[% END %]</div> > >@@ -172,12 +172,12 @@ > <li><label for="reservefee">Hold fee: </label><input type="text" name="reservefee" id="reservefee" size="6" value="[% reservefee %]" /></li> > <li><label for="category_type">Category type: </label> <select name="category_type" id="category_type"> > [% IF ( type_n ) %]<option value="" selected="selected">Select a category type</option>[% ELSE %]<option value="">Select a category type</option>[% END %] >- [% IF ( type_A ) %]<option value="A" selected="selected">Adult</option>[% ELSE %]<option value="A">Adult</option>[% END %] >- [% IF ( type_C ) %]<option value="C" selected="selected">Child</option>[% ELSE %]<option value="C">Child</option>[% END %] >- [% IF ( type_S ) %]<option value="S" selected="selected">Staff</option>[% ELSE %]<option value="S">Staff</option>[% END %] >- [% IF ( type_I ) %]<option value="I" selected="selected">Organization</option>[% ELSE %]<option value="I">Organization</option>[% END %] >- [% IF ( type_P ) %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %] >- [% IF ( type_X ) %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %] >+ [% IF category_type == 'A' %]<option value="A" selected="selected">Adult</option>[% ELSE %]<option value="A">Adult</option>[% END %] >+ [% IF ( category_type == "C" ) %]<option value="C" selected="selected">Child</option>[% ELSE %]<option value="C">Child</option>[% END %] >+ [% IF ( category_type == "S" ) %]<option value="S" selected="selected">Staff</option>[% ELSE %]<option value="S">Staff</option>[% END %] >+ [% IF ( category_type == "I" ) %]<option value="I" selected="selected">Organization</option>[% ELSE %]<option value="I">Organization</option>[% END %] >+ [% IF ( category_type == "P" ) %]<option value="P" selected="selected">Professional</option>[% ELSE %]<option value="P">Professional</option>[% END %] >+ [% IF ( category_type == "X" ) %]<option value="X" selected="selected">Statistical</option>[% ELSE %]<option value="X">Statistical</option>[% END %] > </select> > </li></ol> > </fieldset> >@@ -205,11 +205,11 @@ > > <form action="[% script_name %]" method="post"> > <fieldset><legend> >- [% IF ( totalgtzero ) %] >+ [% IF total >0 %] > Category [% categorycode |html %] is in use. Deletion not possible![% ELSE %] > Confirm deletion of category [% categorycode |html %][% END %]</legend> > >-[% IF ( totalgtzero ) %]<div class="dialog alert"><strong>This category is used [% total %] times</strong>. Deletion not possible</div>[% END %] >+[% IF total >0 %]<div class="dialog alert"><strong>This category is used [% total %] times</strong>. Deletion not possible</div>[% END %] > <table> > <tr><th scope="row">Category code: </th><td>[% categorycode |html %]</td></tr> > <tr><th scope="row">Description: </th><td>[% description |html %]</td></tr> >@@ -229,7 +229,7 @@ Confirm deletion of category [% categorycode |html %][% END %]</legend> > <tr><th scope="row">Lost items in staff client</th><td>[% IF ( hidelostitems ) %]Hidden by default[% ELSE %]Shown[% END %]</td></tr> > <tr><th scope="row">Hold fee: </th><td>[% reservefee %]</td></tr> > </table> >- <fieldset class="action">[% IF ( totalgtzero ) %] >+ <fieldset class="action">[% IF total >0 %] > <input type="submit" value="OK" /></form> > [% ELSE %] > <input type="hidden" name="op" value="delete_confirmed" /> >@@ -301,12 +301,12 @@ Confirm deletion of category [% categorycode |html %][% END %]</legend> > <a href="[% loo.script_name %]?op=add_form&categorycode=[% loo.categorycode |url %]">[% loo.description |html %]</a> > </td> > <td> >- [% IF ( loo.type_A ) %]Adult[% END %] >- [% IF ( loo.type_C ) %]Child[% END %] >- [% IF ( loo.type_P ) %]Prof.[% END %] >- [% IF ( loo.type_I ) %]Org.[% END %] >- [% IF ( loo.type_S ) %]Staff[% END %] >- [% IF ( loo.type_X ) %]Statistical[% END %] >+ [% IF loo.category_type == "A" %]Adult[% END %] >+ [% IF loo.category_type == "C" %]Child[% END %] >+ [% IF loo.category_type == "P" %]Prof.[% END %] >+ [% IF loo.category_type == "I" %]Org.[% END %] >+ [% IF loo.category_type == "S" %]Staff[% END %] >+ [% IF loo.category_type == "X" %]Statistical[% END %] > </td> > <td> > [% IF ( loo.enrolmentperiod ) %] >diff --git a/t/db_dependent/lib/KohaTest/Koha/BusinessLogic/Category.t b/t/db_dependent/lib/KohaTest/Koha/BusinessLogic/Category.t >new file mode 100644 >index 0000000..976b1b8 >--- /dev/null >+++ b/t/db_dependent/lib/KohaTest/Koha/BusinessLogic/Category.t >@@ -0,0 +1,24 @@ >+#!/usr/bin/perl >+ >+use v5.10.0; >+use Modern::Perl; >+ >+use Test::More tests => 5; >+ >+BEGIN { >+ use_ok('Koha::BusinessLogic::Category', 'Loading Koha::BusinessLogic::Category OK'); >+} >+ >+# CREATE >+my $category = Koha::BusinessLogic::Category->new({'categorycode' => 'TEST_C','description' => 'CATEGORY TEST NAME', 'category_type' => 'A'}); >+ok($category->create->id eq 'TEST_C','Creating a category OK'); >+ >+# READ >+ok(Koha::BusinessLogic::Category->read({'categorycode' => 'TEST_C'})->first->description eq 'CATEGORY TEST NAME','Reading a category OK'); >+ >+# UPDATE >+Koha::BusinessLogic::Category->update({'categorycode' => 'TEST_C','description' => 'TEST UPDATED'}); >+ok(Koha::BusinessLogic::Category->read({'categorycode' => 'TEST_C'})->first->description eq 'TEST UPDATED','Updating a category OK'); >+ >+# DELETE >+ok(Koha::BusinessLogic::Category->delete({'categorycode' => 'TEST_C'}),'Deleting a category OK'); >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8309
:
10473
|
10474
|
10475
|
10476
| 10477 |
10478