From 2b837f90232069d9ab5a8746301d9908cf8c29d2 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 10 Jan 2014 00:06:21 -0500 Subject: [PATCH] Bug 11513 - Warnings in Patron categories Just going to the patron categories page triggered errors. Running through all the plain options also triggered other warnings. This patch silences them. TEST PLAN --------- 1) Log in to staff client 2) Click 'Administration' 3) Click 'Patron categories' 4) Click '+ New category' 5) Enter a dummy category and click 'Save' 6) Click 'Edit' for the dummy category. 7) Change a value and click 'Save' 8) Click 'Delete' for the dummy category. 9) Confirm to delete. 10) Review error log, several new warnings 11) Apply patch 12) Click 'Home' 13) Click 'Administration' 14) Click 'Patron categories' 15) Click '+ New category' 16) Enter a dummy category and click 'Save' 17) Click 'Edit' for the dummy category. 18) Change a value and click 'Save' 19) Click 'Delete' for the dummy category. 20) Confirm to delete. 21) Review error log, no new warnings --- admin/categorie.pl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/admin/categorie.pl b/admin/categorie.pl index 952ef7a..bee241a 100755 --- a/admin/categorie.pl +++ b/admin/categorie.pl @@ -49,8 +49,10 @@ use C4::Form::MessagingPreferences; sub StringSearch { my ($searchstring,$type)=@_; my $dbh = C4::Context->dbh; + $searchstring //= ''; $searchstring=~ s/\'/\\\'/g; my @data=split(' ',$searchstring); + push @data,q{} if $#data==-1; my $count=@data; my $sth=$dbh->prepare("Select * from categories where (description like ?) order by category_type,description,categorycode"); $sth->execute("$data[0]%"); @@ -67,7 +69,7 @@ my $input = new CGI; my $searchfield=$input->param('description'); my $script_name="/cgi-bin/koha/admin/categorie.pl"; my $categorycode=$input->param('categorycode'); -my $op = $input->param('op'); +my $op = $input->param('op') // ''; my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "admin/categorie.tmpl", @@ -106,7 +108,8 @@ if ($op eq 'add_form') { $sth->finish; } - $data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} eq '0000-00-00'); + $data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} && $data->{'enrolmentperioddate'} eq '0000-00-00'); + $data->{'category_type'} //= ''; my $branches = GetBranches; my @branches_loop; @@ -124,10 +127,10 @@ if ($op eq 'add_form') { enrolmentperioddate => C4::Dates::format_date($data->{'enrolmentperioddate'}), upperagelimit => $data->{'upperagelimit'}, dateofbirthrequired => $data->{'dateofbirthrequired'}, - enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'}), + enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'} || 0), overduenoticerequired => $data->{'overduenoticerequired'}, issuelimit => $data->{'issuelimit'}, - reservefee => sprintf("%.2f",$data->{'reservefee'}), + reservefee => sprintf("%.2f",$data->{'reservefee'} || 0), hidelostitems => $data->{'hidelostitems'}, category_type => $data->{'category_type'}, SMSSendDriver => C4::Context->preference("SMSSendDriver"), @@ -202,6 +205,7 @@ if ($op eq 'add_form') { $template->param(totalgtzero => 1); } + $data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} && $data->{'enrolmentperioddate'} eq '0000-00-00'); $template->param( description => $data->{'description'}, enrolmentperiod => $data->{'enrolmentperiod'}, enrolmentperioddate => C4::Dates::format_date($data->{'enrolmentperioddate'}), @@ -240,11 +244,14 @@ if ($op eq 'add_form') { while ( my $branch = $sth->fetchrow_hashref ) { push @selected_branches, $branch; } + my $enrolmentperioddate = $results->[$i]{'enrolmentperioddate'}; + $enrolmentperioddate = undef if $enrolmentperioddate eq '0000-00-00'; + $enrolmentperioddate = C4::Dates::format_date($enrolmentperioddate); my %row = ( categorycode => $results->[$i]{'categorycode'}, description => $results->[$i]{'description'}, enrolmentperiod => $results->[$i]{'enrolmentperiod'}, - enrolmentperioddate => C4::Dates::format_date($results->[$i]{'enrolmentperioddate'}), + enrolmentperioddate => $enrolmentperioddate, upperagelimit => $results->[$i]{'upperagelimit'}, dateofbirthrequired => $results->[$i]{'dateofbirthrequired'}, enrolmentfee => sprintf("%.2f",$results->[$i]{'enrolmentfee'}), -- 1.7.9.5