From 590956b49d9552b5b7022ddd70c9437b8bd32850 Mon Sep 17 00:00:00 2001 From: wolfpac444 Date: Tue, 25 Feb 2003 04:19:33 +0000 Subject: [PATCH] Fixed &C4Connect problem and formating --- admin/z3950servers.pl | 178 +++++++++++++++++++++--------------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/admin/z3950servers.pl b/admin/z3950servers.pl index 7d013907cf..597bb77196 100755 --- a/admin/z3950servers.pl +++ b/admin/z3950servers.pl @@ -32,9 +32,9 @@ sub StringSearch { $searchstring=~ s/\'/\\\'/g; my @data=split(' ',$searchstring); my $count=@data; - my $query="Select host,port,db,userid,password,name,id,checked,rank from -z3950servers where (name like \"$data[0]\%\") order by rank,name"; my -$sth=$dbh->prepare($query); $sth->execute; + my $query="Select host,port,db,userid,password,name,id,checked,rank from z3950servers where (name like \"$data[0]\%\") order by rank,name"; + my $sth=$dbh->prepare($query); + $sth->execute; my @results; my $cnt=0; while (my $data=$sth->fetchrow_hashref) { @@ -49,11 +49,11 @@ $sth=$dbh->prepare($query); $sth->execute; my $input = new CGI; my $searchfield=$input->param('searchfield'); -my $reqsel="select host,port,db,userid,password,name,id,checked,rank from -z3950servers where (name = '$searchfield') order by rank,name";my -$reqdel="delete from z3950servers where name='$searchfield'";my -$offset=$input->param('offset');my -$script_name="/cgi-bin/koha/admin/z3950servers.pl"; +my $reqsel="select host,port,db,userid,password,name,id,checked,rank from z3950servers where (name = '$searchfield') order by rank,name"; +my $reqdel="delete from z3950servers where name='$searchfield'"; +my $offset=$input->param('offset'); +my $script_name="/cgi-bin/koha/admin/z3950servers.pl"; + my $pagesize=20; my $op = $input->param('op'); $searchfield=~ s/\,//g; @@ -70,28 +70,28 @@ if ($op eq 'add_form') { my $data; if ($searchfield) { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select -host,port,db,userid,password,name,id,checked,rank from z3950servers where (name -= '$searchfield') order by rank,name"); $sth->execute; -$data=$sth->fetchrow_hashref; $sth->finish; + my $sth=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank from z3950servers where (name = '$searchfield') order by rank,name"); + $sth->execute; + $data=$sth->fetchrow_hashref; + $sth->finish; } print < - /////////////////////////////////////////////////////////////////////////////// -////////////////////////////////// function isNotNull(f,noalert) { + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNotNull(f,noalert) { if (f.value.length ==0) { return false; } return true; } - /////////////////////////////////////////////////////////////////////////////// -////////////////////////////////// function toUC(f) { + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function toUC(f) { var x=f.value.toUpperCase(); f.value=x; return true; } - /////////////////////////////////////////////////////////////////////////////// -////////////////////////////////// function isNum(v,maybenull) { + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isNum(v,maybenull) { var n = new Number(v.value); if (isNaN(n)) { return false; @@ -101,15 +101,15 @@ $data=$sth->fetchrow_hashref; $sth->finish; } return true; } - /////////////////////////////////////////////////////////////////////////////// -////////////////////////////////// function isDate(f) { + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function isDate(f) { var t = Date.parse(f.value); if (isNaN(t)) { return false; } } - /////////////////////////////////////////////////////////////////////////////// -////////////////////////////////// function Check(f) { + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + function Check(f) { var ok=1; var _alertString=""; var alertString2; @@ -138,9 +138,9 @@ $data=$sth->fetchrow_hashref; $sth->finish; document.Aform.submit(); } else { alertString2 = "Form not submitted because of the following problem(s)\\n"; - alertString2 += -"------------------------------------------------------------------------------- ------\\n\\n"; alertString2 += _alertString; alert(alertString2); + alertString2 += "------------------------------------------------------------------------------------\\n\\n"; + alertString2 += _alertString; + alert(alertString2); } } @@ -155,32 +155,32 @@ printend print ""; print ""; if ($searchfield) { - print "\n"; } else { - print "\n"; } - print "\n"; print "\n"; print "\n"; print -"\n"; print "\n"; print -""; print -""; print -""; print "
Z39.50 Server$searchfield
Z39.50 Server
Hostname
Port
Database
Userid
Password
Checked (searched by default)
Rank (display order)
 
"; print "";; - # END $OP eq ADD_FORM################## ADD_VALIDATE -################################### called by add_form, used to insert/modify -data in DB} elsif ($op eq 'add_validate') { my $dbh=C4::Context->dbh; my -$sth=$dbh->prepare("select * from z3950servers where name=?"); -$sth->execute($input->param('searchfield')); if ($sth->rows) { - $sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, -password=?, name=?, checked=?, rank=? where name=?"); -$sth->execute($input->param('host'), $input->param('port'), + print "Z39.50 Server$searchfield\n"; + } else { + print "Z39.50 Server\n"; + } + print "Hostname\n"; + print "Port\n"; + print "Database\n"; + print "Userid\n"; + print "Password\n"; + print "Checked (searched by default)"; + print "Rank (display order)"; + print " "; + print ""; + print ""; +; + # END $OP eq ADD_FORM +################## ADD_VALIDATE ################################## +# called by add_form, used to insert/modify data in DB +} elsif ($op eq 'add_validate') { + my $dbh=C4::Context->dbh; + my $sth=$dbh->prepare("select * from z3950servers where name=?"); + $sth->execute($input->param('searchfield')); + if ($sth->rows) { + $sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=? where name=?"); + $sth->execute($input->param('host'), + $input->param('port'), $input->param('db'), $input->param('userid'), $input->param('password'), @@ -190,9 +190,9 @@ $sth->execute($input->param('host'), $input->param('port'), $input->param('searchfield') ); } else { - $sth=$dbh->prepare("insert into z3950servers -(host,port,db,userid,password,name,checked,rank) values (?, ?, ?, ?, ?, ?, ?, -?)"); $sth->execute($input->param('host'), $input->param('port'), + $sth=$dbh->prepare("insert into z3950servers (host,port,db,userid,password,name,checked,rank) values (?, ?, ?, ?, ?, ?, ?, ?)"); + $sth->execute($input->param('host'), + $input->param('port'), $input->param('db'), $input->param('userid'), $input->param('password'), @@ -211,8 +211,8 @@ $sth->execute($input->param('host'), $input->param('port'), # called by default form, used to confirm deletion of data in DB } elsif ($op eq 'delete_confirm') { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select count(*) as total from borrowers where -branchcode='$searchfield'"); $sth->execute; + my $sth=$dbh->prepare("select count(*) as total from borrowers where branchcode='$searchfield'"); + $sth->execute; my $total = $sth->fetchrow_hashref; $sth->finish; print "$reqsel"; @@ -221,32 +221,32 @@ branchcode='$searchfield'"); $sth->execute; my $data=$sth->fetchrow_hashref; $sth->finish; print mktablehdr; - print mktablerow(2,'#99cc33',bold('Branch -code'),bold("$searchfield"),'/images/background-mem.gif'); print "
"; print "Branch -code$data->{'branchcode'}"; print "  -name$data->{'branchname'}"; print "  -adress$data->{'branchaddress1'}"; print -" $data->{'branchaddress2'}"; print -" $data->{'branchaddress3'}"; print -" phone$data->{'branchphone'}"; print -"  fax$data->{'branchfax'}"; print -"  e-mail$data->{'branchemail'}"; print -"  issuing$data->{'issuing'}"; if -($total->{'total'} >0) { print "This record -is used $total->{'total'} times. Deletion not possible"; print -"
"; } else { print "CONFIRM DELETION"; print "
"; } # END $OP eq -DELETE_CONFIRM################## DELETE_CONFIRMED -################################### called by delete_confirm, used to -effectively confirm deletion of data in DB} elsif ($op eq 'delete_confirmed') { -my $dbh=C4::Context->dbh;# my $searchfield=$input->param('branchcode'); my -$sth=$dbh->prepare($reqdel); $sth->execute; + print mktablerow(2,'#99cc33',bold('Branch code'),bold("$searchfield"),'/images/background-mem.gif'); + print "
"; + print "Branch code$data->{'branchcode'}"; + print "  name$data->{'branchname'}"; + print "  adress$data->{'branchaddress1'}"; + print " $data->{'branchaddress2'}"; + print " $data->{'branchaddress3'}"; + print " phone$data->{'branchphone'}"; + print "  fax$data->{'branchfax'}"; + print "  e-mail$data->{'branchemail'}"; + print "  issuing$data->{'issuing'}"; + if ($total->{'total'} >0) { + print "This record is used $total->{'total'} times. Deletion not possible"; + print "
"; + } else { + print "CONFIRM DELETION"; + print "
"; + } + # END $OP eq DELETE_CONFIRM +################## DELETE_CONFIRMED ################################## +# called by delete_confirm, used to effectively confirm deletion of data in DB +} elsif ($op eq 'delete_confirmed') { + my $dbh=C4::Context->dbh; +# my $searchfield=$input->param('branchcode'); + my $sth=$dbh->prepare($reqdel); + $sth->execute; $sth->finish; print "data deleted"; print "
"; @@ -273,8 +273,8 @@ printend my $env; my ($count,$results)=StringSearch($env,$searchfield,'web'); my $toggle="white"; - for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); -$i++){ if ($toggle eq 'white'){ + for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){ + if ($toggle eq 'white'){ $toggle="#ffffcc"; } else { $toggle="white"; @@ -292,9 +292,9 @@ $i++){ if ($toggle eq 'white'){ $results->[$i]{'checked'}, $results->[$i]{'rank'}, mklink("$script_name?op=add_form&searchfield=$urlsearchfield".'','Edit'), - -mklink("$script_name?op=delete_confirm&searchfield=$urlsearchfield",'Delete')); -} print mktableft; + mklink("$script_name?op=delete_confirm&searchfield=$urlsearchfield",'Delete')); + } + print mktableft; print ""; print ""; if ($offset>0) { @@ -306,8 +306,8 @@ mklink("$script_name?op=delete_confirm&searchfield=$urlsearchfield",'Delete')); my $nextpage =$offset+$pagesize; print mklink("$script_name?offset=".$nextpage,'Next >>'); } - print "

"; print "
"; + print "

"; + print ""; } #---- END $OP eq DEFAULT print endmenu('admin'); print endpage(); -- 2.39.5