|
Lines 67-76
references-to-hash, whose keys are the fields in the printers table.
Link Here
|
| 67 |
|
67 |
|
| 68 |
=cut |
68 |
=cut |
| 69 |
|
69 |
|
|
|
70 |
my $PRINTER_SELECT_FROM = <<EOQ; |
| 71 |
SELECT printername, printqueue, printtype, branches |
| 72 |
FROM printers |
| 73 |
LEFT OUTER JOIN (SELECT branchprinter, COUNT(*) AS branches FROM branches GROUP BY branchprinter) b |
| 74 |
ON (branchprinter = printqueue) |
| 75 |
EOQ |
| 76 |
|
| 70 |
sub GetPrinters { |
77 |
sub GetPrinters { |
| 71 |
my %printers; |
78 |
my %printers; |
| 72 |
my $dbh = C4::Context->dbh; |
79 |
my $dbh = C4::Context->dbh; |
| 73 |
my $sth = $dbh->prepare("select * from printers"); |
80 |
my $sth = $dbh->prepare($PRINTER_SELECT_FROM); |
| 74 |
$sth->execute; |
81 |
$sth->execute; |
| 75 |
while ( my $printer = $sth->fetchrow_hashref ) { |
82 |
while ( my $printer = $sth->fetchrow_hashref ) { |
| 76 |
$printers{ $printer->{'printqueue'} } = $printer; |
83 |
$printers{ $printer->{'printqueue'} } = $printer; |
|
Lines 87-96
sub GetPrinters {
Link Here
|
| 87 |
sub SearchPrinters { |
94 |
sub SearchPrinters { |
| 88 |
my ($searchstring)=@_; |
95 |
my ($searchstring)=@_; |
| 89 |
$searchstring .= '%'; |
96 |
$searchstring .= '%'; |
| 90 |
return C4::Context->dbh->selectall_arrayref(" |
97 |
return C4::Context->dbh->selectall_arrayref( |
| 91 |
SELECT * FROM printers |
98 |
"$PRINTER_SELECT_FROM |
| 92 |
WHERE printername like ? OR printqueue like ? ORDER BY printername |
99 |
WHERE printername like ? OR printqueue like ? ORDER BY printername", |
| 93 |
", {Slice => {}}, $searchstring, $searchstring); |
100 |
{Slice => {}}, |
|
|
101 |
$searchstring, $searchstring); |
| 94 |
} |
102 |
} |
| 95 |
|
103 |
|
| 96 |
=head2 GetPrinterDetails |
104 |
=head2 GetPrinterDetails |
|
Lines 102-109
sub SearchPrinters {
Link Here
|
| 102 |
sub GetPrinterDetails { |
110 |
sub GetPrinterDetails { |
| 103 |
my ( $printer ) = @_; |
111 |
my ( $printer ) = @_; |
| 104 |
my $dbh = C4::Context->dbh; |
112 |
my $dbh = C4::Context->dbh; |
| 105 |
my $printername = $dbh->selectrow_hashref('SELECT * FROM printers WHERE printqueue = ?', undef, $printer); |
113 |
return $dbh->selectrow_hashref( |
| 106 |
return $printername; |
114 |
"$PRINTER_SELECT_FROM |
|
|
115 |
WHERE printqueue = ?", |
| 116 |
undef, $printer); |
| 107 |
} |
117 |
} |
| 108 |
|
118 |
|
| 109 |
=head2 AddPrinter |
119 |
=head2 AddPrinter |