Bug 32348: Add library public in columns settings
[koha-ffzg.git] / admin / cities.pl
index 306927f..f16c9d7 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.
 #
 use Modern::Perl;
 use CGI qw ( -utf8 );
 use C4::Context;
-use C4::Auth;
-use C4::Output;
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_html_with_http_headers );
 
 use Koha::Cities;
 
-my $input       = new CGI;
-my $searchfield = $input->param('city_name') // q||;
+my $input       = CGI->new;
+my $city_name_filter = $input->param('city_name_filter') // q||;
 my $cityid      = $input->param('cityid');
 my $op          = $input->param('op') || 'list';
 my @messages;
@@ -35,9 +36,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {   template_name   => "admin/cities.tt",
         query           => $input,
         type            => "intranet",
-        authnotrequired => 0,
-        flagsrequired   => { parameters => 'parameters_remaining_permissions' },
-        debug           => 1,
+        flagsrequired   => { parameters => 'manage_cities' },
     }
 );
 
@@ -50,7 +49,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 +81,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 +99,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,
 );