From a4758f3e9762622a7f3446c92bdf53db6bd4b497 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 Content-Type: text/plain; charset=utf-8 Just going to the patron categories page triggered errors. Running through all the plain options also triggered other warnings. This fix silences them. Discovered tabs I had not corrected by running qa test tool. Some errors which I could not trigger were also fixed, such as line 248 shown by Merllissia Manueli. 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) Run the koha qa test tool. 13) Click 'Home' 14) Click 'Administration' 15) Click 'Patron categories' 16) Click '+ New category' 17) Enter a dummy category and click 'Save' 18) Click 'Edit' for the dummy category. 19) Change a value and click 'Save' 20) Click 'Delete' for the dummy category. 21) Confirm to delete. 22) Review error log, no new warnings Signed-off-by: Owen Leonard Followed test plan, saw no errors in the log after applying the patch. Signed-off-by: Marcel de Rooy Tested various dates and enrollment periods with different settings of dateformat pref. Works as advertised. No warnings. --- admin/categorie.pl | 35 +++++++++++++------ .../prog/en/modules/admin/categorie.tt | 3 +- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/admin/categorie.pl b/admin/categorie.pl index 952ef7a..6ea7b5a 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,10 @@ if ($op eq 'add_form') { $sth->finish; } - $data->{'enrolmentperioddate'} = undef if ($data->{'enrolmentperioddate'} eq '0000-00-00'); + if ($data->{'enrolmentperioddate'} && $data->{'enrolmentperioddate'} eq '0000-00-00') { + $data->{'enrolmentperioddate'} = undef; + } + $data->{'category_type'} //= ''; my $branches = GetBranches; my @branches_loop; @@ -121,13 +126,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,15 +207,18 @@ if ($op eq 'add_form') { $template->param(totalgtzero => 1); } + if ($data->{'enrolmentperioddate'} && $data->{'enrolmentperioddate'} eq '0000-00-00') { + $data->{'enrolmentperioddate'} = undef; + } $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'}, ); @@ -240,17 +248,22 @@ if ($op eq 'add_form') { while ( my $branch = $sth->fetchrow_hashref ) { push @selected_branches, $branch; } + my $enrolmentperioddate = $results->[$i]{'enrolmentperioddate'}; + if ($enrolmentperioddate && $enrolmentperioddate eq '0000-00-00') { + $enrolmentperioddate = undef; + } + $results->[$i]{'category_type'} //= ''; 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'}), + enrolmentfee => sprintf("%.2f",$results->[$i]{'enrolmentfee'} || 0), overduenoticerequired => $results->[$i]{'overduenoticerequired'}, issuelimit => $results->[$i]{'issuelimit'}, - reservefee => sprintf("%.2f",$results->[$i]{'reservefee'}), + reservefee => sprintf("%.2f",$results->[$i]{'reservefee'} || 0), hidelostitems => $results->[$i]{'hidelostitems'}, category_type => $results->[$i]{'category_type'}, "type_".$results->[$i]{'category_type'} => 1, 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.7.6