@@ -, +, @@ branches --- C4/Printer.pm | 24 ++++++++++++++------ admin/printers.pl | 8 ++++++- .../prog/en/modules/admin/printers.tt | 9 +++++++- 3 files changed, 32 insertions(+), 9 deletions(-) --- a/C4/Printer.pm +++ a/C4/Printer.pm @@ -67,10 +67,17 @@ references-to-hash, whose keys are the fields in the printers table. =cut +my $PRINTER_SELECT_FROM = <dbh; - my $sth = $dbh->prepare("select * from printers"); + my $sth = $dbh->prepare($PRINTER_SELECT_FROM); $sth->execute; while ( my $printer = $sth->fetchrow_hashref ) { $printers{ $printer->{'printqueue'} } = $printer; @@ -87,10 +94,11 @@ sub GetPrinters { sub SearchPrinters { my ($searchstring)=@_; $searchstring .= '%'; - return C4::Context->dbh->selectall_arrayref(" - SELECT * FROM printers - WHERE printername like ? OR printqueue like ? ORDER BY printername - ", {Slice => {}}, $searchstring, $searchstring); + return C4::Context->dbh->selectall_arrayref( + "$PRINTER_SELECT_FROM + WHERE printername like ? OR printqueue like ? ORDER BY printername", + {Slice => {}}, + $searchstring, $searchstring); } =head2 GetPrinterDetails @@ -102,8 +110,10 @@ sub SearchPrinters { sub GetPrinterDetails { my ( $printer ) = @_; my $dbh = C4::Context->dbh; - my $printername = $dbh->selectrow_hashref('SELECT * FROM printers WHERE printqueue = ?', undef, $printer); - return $printername; + return $dbh->selectrow_hashref( + "$PRINTER_SELECT_FROM + WHERE printqueue = ?", + undef, $printer); } =head2 AddPrinter --- a/admin/printers.pl +++ a/admin/printers.pl @@ -101,8 +101,14 @@ if ($op eq 'add_form') { # called by default form, used to confirm deletion of data in DB } elsif ($op eq 'delete_confirm') { $list_printers = 0; - $template->param(delete_confirm => 1); my $data=GetPrinterDetails($searchfield); + my $branches = $data->{branches}; + if ($branches && $branches > 0) { + $template->param(cannot_delete_branches => $branches); + $template->param(add_form => 1); + } else { + $template->param(delete_confirm => 1); + } $template->param( printqueue => $data->{'printqueue'}, printtype => $data->{'printtype'}, --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt @@ -171,7 +171,14 @@ [% loo.printername %] [% loo.printqueue %] [% loo.printtype %] - Edit Delete + + Edit + [% IF loo.branches %] + Default printer for [% loo.branches %] branch(es) + [% ELSE %] + Delete + [% END %] + [% END %] [% ELSE %]
No printers defined.
[% END %] --