@@ -, +, @@ - Uses a call to Koha::Cities->search(*)->count to display the same message we displayed before when no city was found/defined (datatable not rendered at all). - Restores the main search box functionality, the passed param is used to query on the city name with wildcards on both sides, for (a) counting results and for (b) apending to the API call with the same behaviour. --- admin/cities.pl | 15 ++++-- .../prog/en/modules/admin/cities.tt | 47 ++++++++++++------- 2 files changed, 42 insertions(+), 20 deletions(-) --- a/admin/cities.pl +++ a/admin/cities.pl @@ -27,7 +27,7 @@ use C4::Output; use Koha::Cities; my $input = new CGI; -my $searchfield = $input->param('city_name') // q||; +my $city_name = $input->param('city_name') // q||; my $cityid = $input->param('cityid'); my $op = $input->param('op') || 'list'; my @messages; @@ -84,8 +84,8 @@ if ( $op eq 'add_form' ) { push @messages, { type => 'message', code => 'success_on_insert' }; } } - $searchfield = q||; - $op = 'list'; + $city_name = q||; + $op = 'list'; } elsif ( $op eq 'delete_confirm' ) { my $city = Koha::Cities->find($cityid); $template->param( city => $city, ); @@ -101,9 +101,16 @@ if ( $op eq 'add_form' ) { $op = 'list'; } +if ( $op eq 'list' ) { + my $filter = {}; + $filter->{city_name} = { -like => '%'.$city_name.'%' } + if $city_name; + $template->param( cities_count => Koha::Cities->search($filter)->count ); +} + $template->param( cityid => $cityid, - searchfield => $searchfield, + city_name_filter => $city_name, messages => \@messages, op => $op, ); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt @@ -129,22 +129,28 @@

Cities

- [% IF searchfield %] - Searching: [% searchfield | html %] + [% IF city_name_filter %] + Searching: [% city_name_filter | html %] [% END %] - - - - - - - - - - - -
City IDCityStateZIP/Postal codeCountryActions
+ [% IF cities_count > 0 %] + + + + + + + + + + + +
City IDCityStateZIP/Postal codeCountryActions
+ [% ELSE %] +
+ There are no cities defined. Create a new city. +
+ [% END %] [% END %] @@ -162,12 +168,21 @@ [% INCLUDE 'datatables.inc' %]