Moved several etch packages from cpan install to the packages.debian.
[koha_gimpoz] / admin / cities.pl
index 5f092df..fe26caa 100755 (executable)
 use strict;
 use CGI;
 use C4::Context;
-use C4::Output;
-use C4::Search;
-use HTML::Template;
 use C4::Auth;
-use C4::Interface::CGI::Output;
+use C4::Output;
 
 sub StringSearch  {
-       my ($env,$searchstring,$type)=@_;
+       my ($searchstring,$type)=@_;
        my $dbh = C4::Context->dbh;
        $searchstring=~ s/\'/\\\'/g;
        my @data=split(' ',$searchstring);
@@ -54,7 +51,7 @@ my ($template, $loggedinuser, $cookie)
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
-                            flagsrequired => {parameters => 1, management => 1},
+                            flagsrequired => {parameters => 1},
                             debug => 1,
                             });
 
@@ -91,16 +88,16 @@ if ($op eq 'add_form') {
        my $sth;
        
        if ($input->param('cityid') ){
-               $sth=$dbh->prepare("replace cities (cityid,city_name,city_zipcode) values (?,?,?) ");
-               $sth->execute(map { $input->param($_) } ('cityid','city_name','city_zipcode'));
+               $sth=$dbh->prepare("UPDATE cities SET city_name=?,city_zipcode=? WHERE cityid=?");
+               $sth->execute($input->param('city_name'),$input->param('city_zipcode'),$input->param('cityid'));
        
        }
        else{   
-               $sth=$dbh->prepare("replace cities (city_name,city_zipcode) values (?,?)");
-               $sth->execute(map { $input->param($_) } ('city_name','city_zipcode'));
+               $sth=$dbh->prepare("INSERT INTO cities (city_name,city_zipcode) values (?,?)");
+               $sth->execute($input->param('city_name'),$input->param('city_zipcode'));
        }
        $sth->finish;
-       print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=cities.pl\"></html>";
+       print $input->redirect("/cgi-bin/koha/admin/cities.pl");
        exit;
 # END $OP eq ADD_VALIDATE
 ################## DELETE_CONFIRM ##################################
@@ -141,9 +138,8 @@ if ($op eq 'add_form') {
                                                                                                        # END $OP eq DELETE_CONFIRMED
 } else { # DEFAULT
        $template->param(else => 1);
-       my $env;
        my @loop;
-       my ($count,$results)=StringSearch($env,$searchfield,'web');
+       my ($count,$results)=StringSearch($searchfield,'web');
        my $toggle = 0;
        for (my $i=0; $i < $count; $i++){
                my %row = (cityid => $results->[$i]{'cityid'},
@@ -164,4 +160,4 @@ if ($op eq 'add_form') {
 
 
 } #---- END $OP eq DEFAULT
-output_html_with_http_headers $input, $cookie, $template->output;
\ No newline at end of file
+output_html_with_http_headers $input, $cookie, $template->output;