[Koha-patches] [PATCH] bug_8034: Restored network printer maintenance and selection
Srdjan
srdjan at catalyst.net.nz
Mon May 14 03:02:30 CEST 2012
This patch is just for restoring printer maintenance and selection, not
for priting itself. It is just a preparation step.
* Added UsePrintQueues syspref. If set to No, no printer info will be
displayed/used
* Database changes:
- printers table PRIMARY KEY is now printqueue. It is more natural. We
should really have a synthetic id, but printqueue is good enough
- branches.branchprinter is a FOREIGN KEY to printers.printqueue
* Created C4::Auth::get_user_printer() function that will return
appropriate printer. In order of preference:
- session selected
- logged in branch branchprinter
* Created C4::Koha::GetPrinterDetails($printqueue)
* Restored printer maint/selection in admin zone UsePrintQueues
permitting
* Restored printer selection in circ/selectbranchprinter.pl
UsePrintQueues permitting
---
C4/Auth.pm | 49 ++++++++++++++++----
C4/Context.pm | 2 +-
C4/Koha.pm | 15 +++++-
C4/Members.pm | 1 -
admin/branches.pl | 29 +++++++-----
admin/printers.pl | 13 +++---
circ/circulation.pl | 10 ----
circ/returns.pl | 8 ----
circ/selectbranchprinter.pl | 48 ++++++++++---------
installer/data/mysql/kohastructure.sql | 18 +++----
installer/data/mysql/sysprefs.sql | 1 +
installer/data/mysql/updatedatabase.pl | 13 ++++++
.../intranet-tmpl/prog/en/includes/header.inc | 3 ++
.../prog/en/modules/admin/admin-home.tt | 4 +-
.../prog/en/modules/admin/branches.tt | 20 ++++----
.../en/modules/admin/preferences/circulation.pref | 6 +++
.../prog/en/modules/admin/printers.tt | 13 ++----
.../prog/en/modules/circ/circulation.tt | 2 -
.../prog/en/modules/circ/selectbranchprinter.tt | 5 +-
19 files changed, 159 insertions(+), 101 deletions(-)
diff --git a/C4/Auth.pm b/C4/Auth.pm
index ffee1bb..9ab1942 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -26,6 +26,7 @@ use CGI::Session;
require Exporter;
use C4::Context;
+use C4::Koha;
use C4::Templates; # to get the template
use C4::Branch; # GetBranches
use C4::VirtualShelves;
@@ -45,7 +46,8 @@ BEGIN {
$debug = $ENV{DEBUG};
@ISA = qw(Exporter);
@EXPORT = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
- @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &get_all_subpermissions &get_user_subpermissions);
+ @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw
+ &get_all_subpermissions &get_user_subpermissions &get_user_printer);
%EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
$ldap = C4::Context->config('useldapserver') || 0;
$cas = C4::Context->preference('casAuthentication');
@@ -309,6 +311,9 @@ sub get_template_and_user {
$template->param(dateformat_iso => 1);
}
+ my $userenv = C4::Context->userenv;
+ my $userenv_branch = $userenv ? $userenv->{"branch"} : undef;
+
# these template parameters are set the same regardless of $in->{'type'}
$template->param(
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
@@ -316,9 +321,9 @@ sub get_template_and_user {
GoogleJackets => C4::Context->preference("GoogleJackets"),
OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"),
KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"),
- LoginBranchcode => (C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"),
- LoginFirstname => (C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"),
- LoginSurname => C4::Context->userenv?C4::Context->userenv->{"surname"}:"Inconnu",
+ LoginBranchcode => ($userenv?$userenv_branch:"insecure"),
+ LoginFirstname => ($userenv?$userenv->{"firstname"}:"Bel"),
+ LoginSurname => $userenv?$userenv->{"surname"}:"Inconnu",
TagsEnabled => C4::Context->preference("TagsEnabled"),
hide_marc => C4::Context->preference("hide_marc"),
item_level_itypes => C4::Context->preference('item-level_itypes'),
@@ -345,7 +350,7 @@ sub get_template_and_user {
IntranetNav => C4::Context->preference("IntranetNav"),
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"),
LibraryName => C4::Context->preference("LibraryName"),
- LoginBranchname => (C4::Context->userenv?C4::Context->userenv->{"branchname"}:"insecure"),
+ LoginBranchname => ($userenv?$userenv->{"branchname"}:"insecure"),
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"),
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'),
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
@@ -364,6 +369,14 @@ sub get_template_and_user {
OPACLocalCoverImages => C4::Context->preference('OPACLocalCoverImages'),
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'),
);
+ if ( C4::Context->preference('UsePrintQueues') ) {
+ my $printer = get_user_printer();
+ my $printer_rec = $printer ? GetPrinterDetails($printer) : {};
+ $template->param(
+ UsePrintQueues => 1,
+ PrinterName => $printer_rec->{printername},
+ );
+ }
}
else {
warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' );
@@ -382,8 +395,8 @@ sub get_template_and_user {
my $opac_name = '';
if (($opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || $in->{'query'}->param('limit') =~ /branch:(\w+)/){
$opac_name = $1; # opac_search_limit is a branch, so we use it.
- } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) {
- $opac_name = C4::Context->userenv->{'branch'};
+ } elsif (C4::Context->preference("SearchMyLibraryFirst") && $userenv_branch) {
+ $opac_name = $userenv_branch
}
my $checkstyle = C4::Context->preference("opaccolorstylesheet");
if ($checkstyle =~ /http/)
@@ -402,7 +415,7 @@ sub get_template_and_user {
CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1,
LibraryName => "" . C4::Context->preference("LibraryName"),
LibraryNameTitle => "" . $LibraryNameTitle,
- LoginBranchname => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"",
+ LoginBranchname => $userenv?$userenv->{"branchname"}:"",
OPACAmazonEnabled => C4::Context->preference("OPACAmazonEnabled"),
OPACAmazonSimilarItems => C4::Context->preference("OPACAmazonSimilarItems"),
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"),
@@ -435,7 +448,7 @@ sub get_template_and_user {
RequestOnOpac => C4::Context->preference("RequestOnOpac"),
'Version' => C4::Context->preference('Version'),
hidelostitems => C4::Context->preference("hidelostitems"),
- mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv) ? C4::Context->userenv->{'branch'} : '',
+ mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && $userenv) ? $userenv_branch : '',
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"),
opacstylesheet => "" . C4::Context->preference("opacstylesheet"),
opacbookbag => "" . C4::Context->preference("opacbookbag"),
@@ -1664,8 +1677,24 @@ sub getborrowernumber {
return 0;
}
+=head2 get_user_printer
+
+ $printer = get_user_printer();
+
+ Returns printer queue that is to be used for the logged in user
+
+=cut
+
+sub get_user_printer {
+ my $userenv = C4::Context->userenv or return;
+ if (my $printer = $userenv->{branchprinter}) {
+ return $printer;
+ }
+ my $branchname = $userenv->{branch} or return;
+ my $branch = GetBranchDetail($branchname) or return;
+ return $branch->{branchprinter};
+}
-END { } # module clean-up code here (global destructor)
1;
__END__
diff --git a/C4/Context.pm b/C4/Context.pm
index 67d31ee..32c15aa 100644
--- a/C4/Context.pm
+++ b/C4/Context.pm
@@ -998,7 +998,7 @@ sub userenv {
=head2 set_userenv
C4::Context->set_userenv($usernum, $userid, $usercnum, $userfirstname,
- $usersurname, $userbranch, $userflags, $emailaddress);
+ $usersurname, $userbranch, $userflags, $emailaddress, $branchprinter);
Establish a hash of user environment variables.
diff --git a/C4/Koha.pm b/C4/Koha.pm
index a028937..7f911c3 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -34,7 +34,7 @@ BEGIN {
@EXPORT = qw(
&slashifyDate
&subfield_is_koha_internal_p
- &GetPrinters &GetPrinter
+ &GetPrinters &GetPrinter &GetPrinterDetails
&GetItemTypes &getitemtypeinfo
&GetCcodes
&GetSupportName &GetSupportList
@@ -633,6 +633,19 @@ sub GetPrinter ($$) {
return $printer;
}
+=head2 GetPrinterDetails
+
+ $printer_rec = GetPrinterDetails( $printqueue );
+
+=cut
+
+sub GetPrinterDetails {
+ my ( $printer ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $printername = $dbh->selectrow_hashref('SELECT * FROM printers WHERE printqueue = ?', undef, $printer);
+ return $printername;
+}
+
=head2 getnbpages
Returns the number of pages to display in a pagination bar, given the number
diff --git a/C4/Members.pm b/C4/Members.pm
index 6161ac9..693e0ba 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -997,7 +997,6 @@ sub GetPendingIssues {
# must avoid biblioitems.* to prevent large marc and marcxml fields from killing performance
# FIXME: namespace collision: each table has "timestamp" fields. Which one is "timestamp" ?
# FIXME: circ/ciculation.pl tries to sort by timestamp!
- # FIXME: C4::Print::printslip tries to sort by timestamp!
# FIXME: namespace collision: other collisions possible.
# FIXME: most of this data isn't really being used by callers.
my $query =
diff --git a/admin/branches.pl b/admin/branches.pl
index c12762d..2b4c982 100755
--- a/admin/branches.pl
+++ b/admin/branches.pl
@@ -226,12 +226,9 @@ sub default {
sub editbranchform {
my ($branchcode,$innertemplate) = @_;
- # initiate the scrolling-list to select the printers
- my $printers = GetPrinters();
- my @printerloop;
+
my $data;
my $oldprinter = "";
-
if ($branchcode) {
$data = GetBranchInfo($branchcode);
$data = $data->[0];
@@ -241,15 +238,21 @@ sub editbranchform {
_branch_to_template($data, $innertemplate);
}
- foreach my $thisprinter ( keys %$printers ) {
- push @printerloop, {
- value => $thisprinter,
- selected => ( $oldprinter eq $printers->{$thisprinter} ),
- branchprinter => $printers->{$thisprinter}->{'printqueue'},
- };
+ if ( C4::Context->preference('UsePrintQueues') ) {
+ # initiate the scrolling-list to select the printers
+ my $printers = GetPrinters();
+ my @printerloop;
+ foreach my $thisprinter ( keys %$printers ) {
+ push @printerloop, {
+ value => $thisprinter,
+ selected => ( $oldprinter eq $printers->{$thisprinter} ),
+ branchprinter => $printers->{$thisprinter}->{'printername'},
+ };
+ }
+
+ $innertemplate->param( printerloop => \@printerloop );
}
- $innertemplate->param( printerloop => \@printerloop );
# make the checkboxes.....
#
# We export a "categoryloop" array to the template, each element of which
@@ -308,6 +311,7 @@ sub branchinfotable {
my ($branchcode,$innertemplate) = @_;
my $branchinfo = $branchcode ? GetBranchInfo($branchcode) : GetBranchInfo();
+ my $printers = GetPrinters();
my @loop_data = ();
foreach my $branch (@$branchinfo) {
#
@@ -367,6 +371,9 @@ sub branchinfotable {
$row{'branch_name'} = $branch->{'branchname'};
$row{'branch_code'} = $branch->{'branchcode'};
$row{'value'} = $branch->{'branchcode'};
+ if (my $printer = $branch->{'branchprinter'}) {
+ $row{'branchprintername'} = $printers->{$printer}->{'printername'};
+ }
push @loop_data, \%row;
}
diff --git a/admin/printers.pl b/admin/printers.pl
index c32b4e6..a81e3ab 100755
--- a/admin/printers.pl
+++ b/admin/printers.pl
@@ -89,12 +89,13 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($searchfield) {
- my $sth=$dbh->prepare("SELECT printername,printqueue,printtype from printers where printername=?");
+ my $sth=$dbh->prepare("SELECT printername,printqueue,printtype from printers where printqueue=?");
$sth->execute($searchfield);
$data=$sth->fetchrow_hashref;
}
$template->param(printqueue => $data->{'printqueue'},
+ printername => $data->{'printername'},
printtype => $data->{'printtype'});
# END $OP eq ADD_FORM
################## ADD_VALIDATE ##################################
@@ -105,15 +106,15 @@ if ($op eq 'add_form') {
my $sth=$dbh->prepare("INSERT INTO printers (printername,printqueue,printtype) VALUES (?,?,?)");
$sth->execute($input->param('printername'),$input->param('printqueue'),$input->param('printtype'));
} else {
- my $sth=$dbh->prepare("UPDATE printers SET printqueue=?,printtype=? WHERE printername=?");
- $sth->execute($input->param('printqueue'),$input->param('printtype'),$input->param('printername'));
+ my $sth=$dbh->prepare("UPDATE printers SET printername=?,printqueue=?,printtype=? WHERE printqueue=?");
+ $sth->execute($input->param('printername'),$input->param('printqueue'),$input->param('printtype'),$searchfield);
}
# END $OP eq ADD_VALIDATE
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
$template->param(delete_confirm => 1);
- my $sth=$dbh->prepare("select printername,printqueue,printtype from printers where printername=?");
+ my $sth=$dbh->prepare("select printername,printqueue,printtype from printers where printqueue=?");
$sth->execute($searchfield);
my $data=$sth->fetchrow_hashref;
$template->param(printqueue => $data->{'printqueue'},
@@ -123,7 +124,7 @@ if ($op eq 'add_form') {
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
$template->param(delete_confirmed => 1);
- my $sth=$dbh->prepare("delete from printers where printername=?");
+ my $sth=$dbh->prepare("delete from printers where printqueue=?");
$sth->execute($searchfield);
# END $OP eq DELETE_CONFIRMED
################## DEFAULT ###########################################
@@ -131,7 +132,7 @@ if ($op eq 'add_form') {
$template->param(else => 1);
my ($count,$results)=StringSearch($searchfield,'web');
my $max = ($offset+$pagesize < $count) ? $offset+$pagesize : $count;
- my @loop = (@$results)[$offset..$max];
+ my @loop = (@$results)[$offset..$max-1];
$template->param(loop => \@loop);
diff --git a/circ/circulation.pl b/circ/circulation.pl
index bcbcb6f..4815879 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -66,12 +66,6 @@ if ($branch){
$session->param('branchname', GetBranchName($branch));
}
-my $printer = $query->param('printer');
-if ($printer){
- # update our session so the userenv is updated
- $session->param('branchprinter', $printer);
-}
-
if (!C4::Context->userenv && !$branch){
if ($session->param('branch') eq 'NO_LIBRARY_SET'){
# no branch set we can't issue
@@ -101,8 +95,6 @@ $findborrower =~ s|,| |g;
my $borrowernumber = $query->param('borrowernumber');
$branch = C4::Context->userenv->{'branch'};
-$printer = C4::Context->userenv->{'branchprinter'};
-
# If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
if (C4::Context->preference("AutoLocation") != 1) {
@@ -661,8 +653,6 @@ $template->param(
borrowernumber => $borrowernumber,
branch => $branch,
branchname => GetBranchName($borrower->{'branchcode'}),
- printer => $printer,
- printername => $printer,
firstname => $borrower->{'firstname'},
surname => $borrower->{'surname'},
showname => $borrower->{'showname'},
diff --git a/circ/returns.pl b/circ/returns.pl
index bd60d42..0add27d 100755
--- a/circ/returns.pl
+++ b/circ/returns.pl
@@ -36,7 +36,6 @@ use C4::Context;
use C4::Auth qw/:DEFAULT get_session/;
use C4::Output;
use C4::Circulation;
-use C4::Print;
use C4::Reserves;
use C4::Biblio;
use C4::Items;
@@ -73,15 +72,10 @@ my ( $template, $librarian, $cookie ) = get_template_and_user(
#####################
#Global vars
my $branches = GetBranches();
-my $printers = GetPrinters();
-my $printer = C4::Context->userenv ? C4::Context->userenv->{'branchprinter'} : "";
my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
my $userenv_branch = C4::Context->userenv->{'branch'} || '';
-#
-# Some code to handle the error if there is no branch or printer setting.....
-#
# Set up the item stack ....
my %returneditems;
@@ -605,9 +599,7 @@ foreach ( sort { $a <=> $b } keys %returneditems ) {
$template->param(
riloop => \@riloop,
genbrname => $branches->{$userenv_branch}->{'branchname'},
- genprname => $printers->{$printer}->{'printername'},
branchname => $branches->{$userenv_branch}->{'branchname'},
- printer => $printer,
errmsgloop => \@errmsgloop,
exemptfine => $exemptfine,
dropboxmode => $dropboxmode,
diff --git a/circ/selectbranchprinter.pl b/circ/selectbranchprinter.pl
index b5adcfc..e3c3d26 100755
--- a/circ/selectbranchprinter.pl
+++ b/circ/selectbranchprinter.pl
@@ -23,8 +23,7 @@ use CGI;
use C4::Context;
use C4::Output;
-use C4::Auth qw/:DEFAULT get_session/;
-use C4::Print; # GetPrinters
+use C4::Auth qw/:DEFAULT get_session get_user_printer/;
use C4::Koha;
use C4::Branch; # GetBranches GetBranchesLoop
@@ -56,9 +55,10 @@ my $userenv_printer = C4::Context->userenv->{'branchprinter'} || '';
my @updated;
# $session lddines here are doing the updating
-if ($branch and $branches->{$branch}) {
+my $branch_rec = $branch ? $branches->{$branch} : undef;
+if ($branch_rec) {
if (! $userenv_branch or $userenv_branch ne $branch ) {
- my $branchname = GetBranchName($branch);
+ my $branchname = $branch_rec->{branchname};
$template->param(LoginBranchname => $branchname); # update template for new branch
$template->param(LoginBranchcode => $branch); # update template for new branch
$session->param('branchname', $branchname); # update sesssion in DB
@@ -67,6 +67,8 @@ if ($branch and $branches->{$branch}) {
updated_branch => 1,
old_branch => $userenv_branch,
};
+ $printer ||= $branch_rec->{branchprinter};
+ undef $userenv_printer;
} # else branch the same, no update
} else {
$branch = $userenv_branch; # fallback value
@@ -87,7 +89,7 @@ if ($printer) {
};
} # else printer is the same, no update
} else {
- $printer = $userenv_printer; # fallback value
+ $printer = get_user_printer(); # fallback value
}
$template->param(updated => \@updated) if (scalar @updated);
@@ -96,21 +98,6 @@ unless ($branches->{$branch}) {
$branch = (keys %$branches)[0]; # if branch didn't really exist, then replace it w/ one that does
}
-my @printkeys = sort keys %$printers;
-if (scalar(@printkeys) == 1 or not $printers->{$printer}) {
- $printer = $printkeys[0]; # if printer didn't really exist, or there is only 1 anyway, then replace it w/ one that does
-}
-
-my @printerloop;
-foreach ( @printkeys ) {
- next unless ($_); # skip printer if blank.
- push @printerloop, {
- selected => ( $_ eq $printer ),
- name => $printers->{$_}->{'printername'},
- value => $_,
- };
-}
-
my @recycle_loop;
foreach ($query->param()) {
$_ or next; # disclude blanks
@@ -133,9 +120,28 @@ if (scalar @updated and not scalar @recycle_loop) {
$template->param(
referer => $referer,
- printerloop => \@printerloop,
branchloop => GetBranchesLoop($branch),
recycle_loop=> \@recycle_loop,
);
+if ( C4::Context->preference('UsePrintQueues') ) {
+ my @printkeys = keys %$printers;
+ if (scalar(@printkeys) == 1 or not $printers->{$printer}) {
+ $printer = $printkeys[0]; # if printer didn't really exist, or there is only 1 anyway, then replace it w/ one that does
+ }
+
+ my @printerloop;
+ foreach ( @printkeys ) {
+ push @printerloop, {
+ selected => ( $_ eq $printer ),
+ name => $printers->{$_}->{'printername'},
+ value => $_,
+ };
+ }
+
+ $template->param(
+ printerloop => \@printerloop,
+ );
+}
+
output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 9a94e0f..6e13369 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -362,10 +362,11 @@ CREATE TABLE `branches` ( -- information about your libraries or branches are st
`branchurl` mediumtext, -- the URL for your library or branch's website
`issuing` tinyint(4) default NULL, -- unused in Koha
`branchip` varchar(15) default NULL, -- the IP address for your library or branch
- `branchprinter` varchar(100) default NULL, -- unused in Koha
+ `branchprinter` varchar(20) default NULL,
`branchnotes` mediumtext, -- notes related to your library or branch
opac_info text, -- HTML that displays in OPAC
- UNIQUE KEY `branchcode` (`branchcode`)
+ UNIQUE KEY `branchcode` (`branchcode`),
+ FOREIGN KEY (branchprinter) REFERENCES printers (printqueue) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
@@ -1563,12 +1564,13 @@ CREATE TABLE `pending_offline_operations` (
-- Table structure for table `printers`
--
-DROP TABLE IF EXISTS `printers`;
-CREATE TABLE `printers` (
- `printername` varchar(40) NOT NULL default '',
- `printqueue` varchar(20) default NULL,
- `printtype` varchar(20) default NULL,
- PRIMARY KEY (`printername`)
+DROP TABLE IF EXISTS printers;
+CREATE TABLE printers (
+ printername varchar(40) NOT NULL default '',
+ printqueue varchar(20) NOT NULL,
+ printtype varchar(20) default NULL,
+ PRIMARY KEY (printqueue),
+ UNIQUE (printername)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index 1edf08e..f09000f 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -363,3 +363,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES (
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');
+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UsePrintQueues','0',NULL,NULL,'YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 035e1e6..91b14cf 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -5239,6 +5239,19 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
SetVersion($DBversion);
}
+
+
+
+$DBversion = "3.09.00.XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+ $dbh->do("ALTER TABLE printers DROP PRIMARY KEY, MODIFY printqueue varchar(20) NOT NULL PRIMARY KEY, ADD UNIQUE (printername)");
+ $dbh->do("ALTER TABLE branches MODIFY branchprinter varchar(20) NULL, ADD FOREIGN KEY (branchprinter) REFERENCES printers (printqueue) ON UPDATE CASCADE");
+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UsePrintQueues','0',NULL,NULL,'YesNo')");
+
+ print "Upgrade to $DBversion done (Add borrowers.default_printqueue and 'UsePrintQueues' syspref)\n";
+ SetVersion($DBversion);
+}
+
=head1 FUNCTIONS
=head2 TableExists($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
index 4783523..019a15e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
@@ -57,6 +57,9 @@
[% LoginBranchname %]
[% END %]
</strong>
+ [% IF UsePrintQueues %]
+ - [% PrinterName %]
+ [% END %]
[% IF ( IndependantBranches ) %]
[% IF ( CAN_user_management || CAN_user_editcatalogue_edit_catalogue ) %]
( <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a> )
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt
index ef46ede..0954a8c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt
@@ -95,8 +95,8 @@
<dl>
[% IF ( NoZebra ) %]<dt><a href="/cgi-bin/koha/admin/stopwords.pl">Stop words</a></dt>
<dd>Words ignored during search.</dd>[% END %]
- <!-- <dt><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></dt>
- <dd>Printers (UNIX paths).</dd> -->
+ [% IF UsePrintQueues %]<dt><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></dt>
+ <dd>Printers (UNIX paths).</dd>[% END %]
<dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50 client targets</a></dt>
<dd>Define which servers to query for MARC data in the integrated Z39.50 client.</dd>
</dl>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt
index bedeb8b..da70a42 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt
@@ -143,10 +143,10 @@ tinyMCE.init({
<li><label for="branchurl">URL</label><input type="text" name="branchurl" id="branchurl" value="[% branchurl |html %]" /></li>
<li><label for="opac_info">OPAC info</label><textarea name="opac_info" id="opac_info">[% opac_info |html %]</textarea></li>
<li><label for="branchip">IP</label><input type="text" name="branchip" id="branchip" value="[% branchip |html %]" /> <span class="hint">Can be entered as a single IP, or a subnet such as 192.168.1.*</span></li>
- <!--
- <li><label for="branchprinter">Library Printer</label>
+[% IF UsePrintQueues %]
+ <li><label for="branchprinter">Library printer</label>
<select id="branchprinter" name="branchprinter">
- <option value="">None</option>
+ <option value="">(None)</option>
[% FOREACH printerloo IN printerloop %]
[% IF ( printerloo.selected ) %]
<option value="[% printerloo.value %]" selected="selected">[% printerloo.branchprinter %]</option>
@@ -155,7 +155,7 @@ tinyMCE.init({
[% END %]
[% END %]
</select></li>
- -->
+[% END %]
<li><label for="branchnotes">Notes</label><input type="text" name="branchnotes" id="branchnotes" value="[% branchnotes |html %]" /></li>
</ol>
</fieldset>
@@ -198,7 +198,9 @@ tinyMCE.init({
<th>Address</th>
<th>Properties</th>
<th>IP</th>
- <!-- <th>Printer</th> -->
+[% IF UsePrintQueues %]
+ <th>Printer</th>
+[% END %]
<th colspan="2"> </th>
</tr></thead><tbody>
[% FOREACH branche IN branches %]
@@ -250,9 +252,11 @@ tinyMCE.init({
<td>
[% branche.branchip %]
</td>
- <!-- <td>
- [% branche.branchprinter %]
- </td> -->
+[% IF UsePrintQueues %]
+ <td>
+ [% branche.branchprintername %]
+ </td>
+[% END %]
<td>
<a href="[% branche.action %]?op=edit&branchcode=[% branche.value |url %]">Edit</a>
</td>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
index 471aa0e..d3b804b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
@@ -103,6 +103,12 @@ Circulation:
- pref: NoticeCSS
class: url
- on Notices. (This should be a complete URL, starting with <code>http://</code>)
+ -
+ - pref: UsePrintQueues
+ choices:
+ yes: "Use"
+ no: "Don't use"
+ - server print queues.
Checkout Policy:
-
- pref: AllowNotForLoanOverride
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 7dfb80b..887c715 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt
@@ -89,22 +89,17 @@
<form action="[% script_name %]" name="Aform" method="post">
<input type="hidden" name="op" value="add_validate" />
[% IF ( searchfield ) %]
+ <input type="hidden" name="searchfield" value="[% searchfield %]" />
<input type="hidden" name="add" value="0" />
[% ELSE %]
<input type="hidden" name="add" value="1" />
[% END %]
<fieldset class="rows">
-<ol> [% IF ( searchfield ) %]
- <li>
- <span class="label">Printer name: </span>
- <input type="hidden" name="printername" id="" value="[% searchfield %]" />[% searchfield %]
- </li>
- [% ELSE %]
+<ol>
<li>
<label for="printername">Printer name: </label>
- <input type="text" name="printername" id="printername" size="50" maxlength="50" />
+ <input type="text" name="printername" id="printername" size="50" maxlength="50" value="[% printername %]" />
</li>
- [% END %]
<li>
<label for="printqueue">Queue: </label>
<input type="text" name="printqueue" id="printqueue" size="50" maxlength="50" value="[% printqueue %]" />
@@ -190,7 +185,7 @@
<td>[% loo.printername %]</td>
<td>[% loo.printqueue %]</td>
<td>[% loo.printtype %]</td>
- <td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.printername %]">Edit</a> <a href="[% loo.script_name %]?op=delete_confirm&searchfield=[% loo.printername %]">Delete</a></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>
</tr>
[% END %]
</table>[% ELSE %]<div class="notice">No printers defined.</div>[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
index fa92507..86c84f9 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ -435,7 +435,6 @@ No patron matched <span class="ex">[% message %]</span>
<legend>Patron selection</legend>
<input type="hidden" name="branch" value="[% branch %]" />
- <input type="hidden" name="printer" value="[% printer %]" />
<input type="hidden" name="duedatespec" value="[% duedatespec %]" />
<input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
@@ -522,7 +521,6 @@ No patron matched <span class="ex">[% message %]</span>
</div>[% END %]
<input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
<input type="hidden" name="branch" value="[% branch %]" />
- <input type="hidden" name="printer" value="[% printer %]" />
<input type="hidden" name="print" value="maybe" />
<input type="hidden" name="debt_confirmed" value="[% debt_confirmed %]" />
[% IF ( CHARGES ) %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectbranchprinter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectbranchprinter.tt
index acad21c..e742f81 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectbranchprinter.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectbranchprinter.tt
@@ -28,7 +28,7 @@ Updated:<ul>
[% IF ( update.updated_branch ) %]
<li>Library: [% update.old_branch or "?" %] ⇒ [% update.LoginBranchcode or "?" %]</li>
[% ELSIF ( update.updated_printer ) %]
- <!-- FIXME: <li>Printer: [% update.old_printer or "?" %] ⇒ [% update.new_printer or "?" %]</li> -->
+ <li>Printer: [% update.old_printer or "?" %] ⇒ [% update.new_printer or "?" %]</li>
[% ELSE %]
<li>ERROR - unknown</li>
[% END %]
@@ -63,7 +63,6 @@ Updated:<ul>
[% END %]
</select></li>
[% END %]
-<!--
[% IF ( printerloop ) %]
<li><label for="printer">Choose a network printer:</label>
<select name="printer" id="printer">
@@ -75,7 +74,7 @@ Updated:<ul>
[% END %]
[% END %]
</select></li>
- [% END %] -->
+ [% END %]
</ol>
</fieldset>
<fieldset class="action"><input type="submit" value="Submit" /></fieldset>
--
1.7.9.5
More information about the Koha-patches
mailing list