use C4::Auth;
sub StringSearch {
- my ($searchstring,$type)=@_;
- my $dbh = C4::Context->dbh;
+ my ($searchstring,$type)=@_; # why bother with $type if we don't use it?!
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
- my $count=@data;
- my $query="";
- my $sth=$dbh->prepare("Select printername,printqueue,printtype from printers where (printername like ?) order by printername");
+ my $sth = C4::Context->dbh->prepare("
+ SELECT printername,printqueue,printtype from printers
+ WHERE (printername like ?) order by printername
+ ");
$sth->execute("$data[0]%");
my @results;
my $cnt=0;
while (my $data=$sth->fetchrow_hashref){
- push(@results,$data);
- $cnt ++;
+ push(@results,$data);
+ $cnt ++;
}
# $sth->execute;
$sth->finish;
my $op = $input->param('op');
$searchfield=~ s/\,//g;
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "admin/printers.tmpl",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {parameters => 1},
- debug => 1,
- });
+my ($template, $loggedinuser, $cookie) = get_template_and_user({
+ template_name => "admin/printers.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => {parameters => 1},
+ debug => 1,
+});
$template->param(searchfield => $searchfield,
my $data;
if ($searchfield) {
my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("select printername,printqueue,printtype from printers where printername=?");
+ my $sth=$dbh->prepare("SELECT printername,printqueue,printtype from printers where printername=?");
$sth->execute($searchfield);
$data=$sth->fetchrow_hashref;
$sth->finish;
} elsif ($op eq 'add_validate') {
$template->param(add_validate => 1);
my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("replace printers (printername,printqueue,printtype) values (?,?,?)");
+ my $sth=$dbh->prepare("REPLACE printers (printername,printqueue,printtype) values (?,?,?)");
$sth->execute($input->param('printername'),$input->param('printqueue'),$input->param('printtype'));
$sth->finish;
# END $OP eq ADD_VALIDATE
printtype => $results->[$i]{'printtype'},
toggle => $toggle);
push @loop, \%row;
-
- if ( $toggle eq 'white' )
- {
- $toggle = '#ffffcc';
- }
- else
- {
- $toggle = 'white';
- }
+ $toggle = ($toggle eq 'white') ? '#ffffcc' : 'white';
}
$template->param(loop => \@loop);
$template->param(offsetgtzero => 1,
prevpage => $offset-$pagesize);
}
- print " ";
+ print " " x 6;
if ($offset+$pagesize<$count) {
$template->param(ltcount => 1,
nextpage => $offset+$pagesize);