more re-arranging prior to release
[koha.git] / admin / printers.pl
index 6e6e9f5..3e3071d 100755 (executable)
@@ -41,24 +41,22 @@ use strict;
 use CGI;
 use C4::Context;
 use C4::Output;
-
 use C4::Auth;
-use C4::Interface::CGI::Output;
 
 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;
@@ -78,14 +76,14 @@ my $pagesize=20;
 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,
@@ -101,7 +99,7 @@ if ($op eq 'add_form') {
        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;
@@ -115,7 +113,7 @@ if ($op eq 'add_form') {
 } 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
@@ -154,15 +152,7 @@ if ($op eq 'add_form') {
                            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);
@@ -171,16 +161,13 @@ if ($op eq 'add_form') {
                $template->param(offsetgtzero => 1,
                                 prevpage => $offset-$pagesize);
        }
-       print "      ";
+       print " " x 6;
        if ($offset+$pagesize<$count) {
                $template->param(ltcount => 1,
                                 nextpage => $offset+$pagesize);
        }
 
 } #---- END $OP eq DEFAULT
-$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
-               intranetstylesheet => C4::Context->preference("intranetstylesheet"),
-               IntranetNav => C4::Context->preference("IntranetNav"),
-               );
+
 output_html_with_http_headers $input, $cookie, $template->output;