Bugzilla – Attachment 15286 Details for
Bug 8034
Enable server print queue selection
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bug_8034: Disable delete printer for printers asigned to branches
bug8034-Disable-delete-printer-for-printers-asigne.patch (text/plain), 4.26 KB, created by
Srdjan Jankovic
on 2013-02-13 05:39:34 UTC
(
hide
)
Description:
bug_8034: Disable delete printer for printers asigned to branches
Filename:
MIME Type:
Creator:
Srdjan Jankovic
Created:
2013-02-13 05:39:34 UTC
Size:
4.26 KB
patch
obsolete
>From 87d73f3a1ce45e5e4b2cb9b2de81f0f21ba00509 Mon Sep 17 00:00:00 2001 >From: Srdjan <srdjan@catalyst.net.nz> >Date: Wed, 13 Feb 2013 18:30:31 +1300 >Subject: [PATCH] bug_8034: Disable delete printer for printers asigned to > branches > >* C4::Printer - added branch count to printer queries >* admin/printers.tt - show or not delete link >--- > C4/Printer.pm | 24 ++++++++++++++------ > admin/printers.pl | 8 ++++++- > .../prog/en/modules/admin/printers.tt | 9 +++++++- > 3 files changed, 32 insertions(+), 9 deletions(-) > >diff --git a/C4/Printer.pm b/C4/Printer.pm >index 0990bad..e24c9b2 100644 >--- a/C4/Printer.pm >+++ b/C4/Printer.pm >@@ -67,10 +67,17 @@ references-to-hash, whose keys are the fields in the printers table. > > =cut > >+my $PRINTER_SELECT_FROM = <<EOQ; >+SELECT printername, printqueue, printtype, branches >+FROM printers >+LEFT OUTER JOIN (SELECT branchprinter, COUNT(*) AS branches FROM branches GROUP BY branchprinter) b >+ ON (branchprinter = printqueue) >+EOQ >+ > sub GetPrinters { > my %printers; > my $dbh = C4::Context->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 >diff --git a/admin/printers.pl b/admin/printers.pl >index 12e42d7..38eb177 100755 >--- a/admin/printers.pl >+++ b/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'}, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt >index 06fd229..29445c4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt >@@ -171,7 +171,14 @@ > <td>[% loo.printername %]</td> > <td>[% loo.printqueue %]</td> > <td>[% loo.printtype %]</td> >- <td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.printqueue %]">Edit</a> <a href="[% loo.script_name %]?op=delete_confirm&searchfield=[% loo.printqueue %]">Delete</a></td> >+ <td> >+ <a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.printqueue %]">Edit</a> >+ [% IF loo.branches %] >+ Default printer for [% loo.branches %] branch(es) >+ [% ELSE %] >+ <a href="[% loo.script_name %]?op=delete_confirm&searchfield=[% loo.printqueue %]">Delete</a> >+ [% END %] >+ </td> > </tr> > [% END %] > </table>[% ELSE %]<div class="notice">No printers defined.</div>[% END %] >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8034
:
9386
|
9546
|
9787
|
10762
|
11557
|
11995
|
12096
|
12157
|
12161
|
12322
|
13797
|
14357
|
15286
|
17569
|
46414
|
46415