Bug 21066: Code changes needed for replacing opac_news.timestamp
[srvgit] / admin / cities.pl
index 306927f..0688852 100755 (executable)
@@ -1,6 +1,7 @@
 #! /usr/bin/perl
 
 # Copyright 2006 SAN OUEST-PROVENCE et Paul POULAIN
+# Copyright 2015 Koha Development Team
 #
 # This file is part of Koha.
 #
@@ -26,7 +27,7 @@ use C4::Output;
 use Koha::Cities;
 
 my $input       = new CGI;
-my $searchfield = $input->param('city_name') // q||;
+my $city_name_filter = $input->param('city_name_filter') // q||;
 my $cityid      = $input->param('cityid');
 my $op          = $input->param('op') || 'list';
 my @messages;
@@ -36,7 +37,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         query           => $input,
         type            => "intranet",
         authnotrequired => 0,
-        flagsrequired   => { parameters => 'parameters_remaining_permissions' },
+        flagsrequired   => { parameters => 'manage_cities' },
         debug           => 1,
     }
 );
@@ -50,7 +51,6 @@ if ( $op eq 'add_form' ) {
 
     $template->param( city => $city, );
 } elsif ( $op eq 'add_validate' ) {
-    my $cityid       = $input->param('cityid');
     my $city_name    = $input->param('city_name');
     my $city_state   = $input->param('city_state');
     my $city_zipcode = $input->param('city_zipcode');
@@ -83,8 +83,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,13 +101,12 @@ if ( $op eq 'add_form' ) {
 }
 
 if ( $op eq 'list' ) {
-    my $cities = Koha::Cities->search( { city_name => { -like => "%$searchfield%" } } );
-    $template->param( cities => $cities, );
+    $template->param( cities_count => Koha::Cities->search->count );
 }
 
 $template->param(
     cityid      => $cityid,
-    searchfield => $searchfield,
+    city_name_filter => $city_name_filter,
     messages    => \@messages,
     op          => $op,
 );