From 44fd20595015cf66cddd24cf63f9e117e23be4c8 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 fix 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 | 22 +++++++++++++------- .../prog/en/modules/admin/categorie.tt | 3 ++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/admin/categorie.pl b/admin/categorie.pl index 952ef7a..99e034b 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; @@ -121,13 +124,13 @@ if ($op eq 'add_form') { $template->param(description => $data->{'description'}, enrolmentperiod => $data->{'enrolmentperiod'}, - enrolmentperioddate => C4::Dates::format_date($data->{'enrolmentperioddate'}), + enrolmentperioddate => $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,9 +205,10 @@ 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'}), + enrolmentperioddate => $data->{'enrolmentperioddate'}, upperagelimit => $data->{'upperagelimit'}, dateofbirthrequired => $data->{'dateofbirthrequired'}, enrolmentfee => sprintf("%.2f",$data->{'enrolmentfee'}), @@ -240,11 +244,15 @@ if ($op eq 'add_form') { while ( my $branch = $sth->fetchrow_hashref ) { push @selected_branches, $branch; } + my $enrolmentperioddate = $results->[$i]{'enrolmentperioddate'}; + if (defined($enrolmentperioddate) && $enrolmentperioddate eq '0000-00-00') { + $enrolmentperioddate = undef; + } 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'}), 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 d1c2e4c..6106e5f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt @@ -1,3 +1,4 @@ +[% USE KohaDates -%] [% 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 %] @@ -151,7 +152,7 @@ <li><label for="enrolmentperiod" style="width:6em;">In months: </label> <input type="text" name="enrolmentperiod" id="enrolmentperiod" size="3" maxlength="3" value="[% IF ( enrolmentperiod ) %][% enrolmentperiod %][% END %]" /> months</li> <li><label for="enrolmentperioddate" style="width:6em;">Until date: </label> - <input type="text" name="enrolmentperioddate" id="enrolmentperioddate" value="[% enrolmentperioddate %]" /> + <input type="text" name="enrolmentperioddate" id="enrolmentperioddate" value="[% enrolmentperioddate | $KohaDates %]" /> <div id="enrolmentmessage" class="hint" style="margin-left:0;">Cannot have "months" and "until date" at the same time</div> </li> </ol> -- 1.7.9.5