View | Details | Raw Unified | Return to bug 8034
Collapse All | Expand All

(-)a/C4/Printer.pm (-7 / +17 lines)
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
(-)a/admin/printers.pl (-1 / +7 lines)
Lines 101-108 if ($op eq 'add_form') { Link Here
101
# called by default form, used to confirm deletion of data in DB
101
# called by default form, used to confirm deletion of data in DB
102
} elsif ($op eq 'delete_confirm') {
102
} elsif ($op eq 'delete_confirm') {
103
    $list_printers = 0;
103
    $list_printers = 0;
104
    $template->param(delete_confirm => 1);
105
    my $data=GetPrinterDetails($searchfield);
104
    my $data=GetPrinterDetails($searchfield);
105
    my $branches = $data->{branches};
106
    if ($branches && $branches > 0) {
107
        $template->param(cannot_delete_branches => $branches);
108
        $template->param(add_form => 1);
109
    } else {
110
        $template->param(delete_confirm => 1);
111
    }
106
    $template->param(
112
    $template->param(
107
        printqueue => $data->{'printqueue'},
113
        printqueue => $data->{'printqueue'},
108
        printtype  => $data->{'printtype'},
114
        printtype  => $data->{'printtype'},
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt (-2 / +8 lines)
Lines 171-177 Link Here
171
			<td>[% loo.printername %]</td>
171
			<td>[% loo.printername %]</td>
172
			<td>[% loo.printqueue %]</td>
172
			<td>[% loo.printqueue %]</td>
173
			<td>[% loo.printtype %]</td>
173
			<td>[% loo.printtype %]</td>
174
                     <td><a href="[% loo.script_name %]?op=add_form&amp;searchfield=[% loo.printqueue %]">Edit</a> <a href="[% loo.script_name %]?op=delete_confirm&amp;searchfield=[% loo.printqueue %]">Delete</a></td>
174
                     <td>
175
                         <a href="[% loo.script_name %]?op=add_form&amp;searchfield=[% loo.printqueue %]">Edit</a>
176
                     [% IF loo.branches %]
177
                         Default printer for [% loo.branches %] branch(es)
178
                     [% ELSE %]
179
                         <a href="[% loo.script_name %]?op=delete_confirm&amp;searchfield=[% loo.printqueue %]">Delete</a>
180
                     [% END %]
181
                     </td>
175
		</tr>
182
		</tr>
176
		[% END %]
183
		[% END %]
177
	</table>[% ELSE %]<div class="notice">No printers defined.</div>[% END %]
184
	</table>[% ELSE %]<div class="notice">No printers defined.</div>[% END %]
178
- 

Return to bug 8034