Updated INSTALL.opensuse for openSUSE 11.0 Final
[koha.git] / admin / cities.pl
index ac8f83f..fe26caa 100755 (executable)
 use strict;
 use CGI;
 use C4::Context;
-use C4::Output;
-
 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);
@@ -90,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 ##################################
@@ -140,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'},
@@ -163,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;