Bug 17845: Remove unused code related to printers
authorKatrin Fischer <katrin.fischer@bsz-bw.de>
Sun, 16 Sep 2018 21:25:37 +0000 (23:25 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 10 Mar 2020 15:18:27 +0000 (15:18 +0000)
There is some quite old and unused code in Koha related
to printer configuration and network printing. These code
hasn't been functional in a long time and should be removed.

This patch:

- Removes printcirculationslips system preference
- Removes table printers
- Removes branchprinter column from branches

Check that:
- Go to administration
- Open any age there, but change the last bit to: printers.pl
- Apply patch, run the database update
- Verify the hidden page no longer exists
- Verify that logging in and out still works correctly
- Verify that checkout and returns work correctly
- Switch to another branch using the "Set library" option

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

17 files changed:
C4/Auth.pm
C4/Context.pm
C4/InstallAuth.pm
C4/Koha.pm
C4/Print.pm [deleted file]
admin/printers.pl [deleted file]
circ/circulation.pl
circ/returns.pl
circ/selectbranchprinter.pl
installer/data/mysql/atomicupdate/bug_17845_remove_printers [new file with mode: 0644]
installer/data/mysql/kohastructure.sql
installer/data/mysql/ru-RU/optional/example_branches.sql
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt [deleted file]
koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectbranchprinter.tt
t/Print.t [deleted file]

index bf35b00..d3fc43f 100644 (file)
@@ -848,7 +848,7 @@ sub checkauth {
                 $session->param('cardnumber'),   $session->param('firstname'),
                 $session->param('surname'),      $session->param('branch'),
                 $session->param('branchname'),   $session->param('flags'),
-                $session->param('emailaddress'), $session->param('branchprinter'),
+                $session->param('emailaddress'),
                 $session->param('shibboleth')
             );
             C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') );
@@ -1069,14 +1069,12 @@ sub checkauth {
                     C4::Context->_unset_userenv($sessionID);
                 }
                 my ( $borrowernumber, $firstname, $surname, $userflags,
-                    $branchcode, $branchname, $branchprinter, $emailaddress );
+                    $branchcode, $branchname, $emailaddress );
 
                 if ( $return == 1 ) {
                     my $select = "
                     SELECT borrowernumber, firstname, surname, flags, borrowers.branchcode,
-                    branches.branchname    as branchname,
-                    branches.branchprinter as branchprinter,
-                    email
+                    branches.branchname    as branchname, email
                     FROM borrowers
                     LEFT JOIN branches on borrowers.branchcode=branches.branchcode
                     ";
@@ -1097,7 +1095,7 @@ sub checkauth {
                     }
                     if ( $sth->rows ) {
                         ( $borrowernumber, $firstname, $surname, $userflags,
-                            $branchcode, $branchname, $branchprinter, $emailaddress ) = $sth->fetchrow;
+                            $branchcode, $branchname, $emailaddress ) = $sth->fetchrow;
                         $debug and print STDERR "AUTH_3 results: " .
                           "$cardnumber,$borrowernumber,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress\n";
                     } else {
@@ -1139,8 +1137,7 @@ sub checkauth {
                         if ( $domain && $ip =~ /^$domain/ ) {
                             $branchcode = $branches->{$br}->{'branchcode'};
 
-                            # new op dev : add the branchprinter and branchname in the cookie
-                            $branchprinter = $branches->{$br}->{'branchprinter'};
+                            # new op dev : add the branchname to the cookie
                             $branchname    = $branches->{$br}->{'branchname'};
                         }
                     }
@@ -1165,8 +1162,7 @@ sub checkauth {
                     $session->param('cardnumber'),   $session->param('firstname'),
                     $session->param('surname'),      $session->param('branch'),
                     $session->param('branchname'),   $session->param('flags'),
-                    $session->param('emailaddress'), $session->param('branchprinter'),
-                    $session->param('shibboleth')
+                    $session->param('emailaddress'), $session->param('shibboleth')
                 );
 
             }
@@ -1444,7 +1440,7 @@ sub check_api_auth {
                 $session->param('cardnumber'),   $session->param('firstname'),
                 $session->param('surname'),      $session->param('branch'),
                 $session->param('branchname'),   $session->param('flags'),
-                $session->param('emailaddress'), $session->param('branchprinter')
+                $session->param('emailaddress')
             );
 
             my $ip       = $session->param('ip');
@@ -1532,35 +1528,35 @@ sub check_api_auth {
                 my (
                     $borrowernumber, $firstname,  $surname,
                     $userflags,      $branchcode, $branchname,
-                    $branchprinter,  $emailaddress
+                    $emailaddress
                 );
                 my $sth =
                   $dbh->prepare(
-"select borrowernumber, firstname, surname, flags, borrowers.branchcode, branches.branchname as branchname,branches.branchprinter as branchprinter, email from borrowers left join branches on borrowers.branchcode=branches.branchcode where userid=?"
+"select borrowernumber, firstname, surname, flags, borrowers.branchcode, branches.branchname as branchname, email from borrowers left join branches on borrowers.branchcode=branches.branchcode where userid=?"
                   );
                 $sth->execute($userid);
                 (
                     $borrowernumber, $firstname,  $surname,
                     $userflags,      $branchcode, $branchname,
-                    $branchprinter,  $emailaddress
+                    $emailaddress
                 ) = $sth->fetchrow if ( $sth->rows );
 
                 unless ( $sth->rows ) {
                     my $sth = $dbh->prepare(
-"select borrowernumber, firstname, surname, flags, borrowers.branchcode, branches.branchname as branchname, branches.branchprinter as branchprinter, email from borrowers left join branches on borrowers.branchcode=branches.branchcode where cardnumber=?"
+"select borrowernumber, firstname, surname, flags, borrowers.branchcode, branches.branchname as branchname, email from borrowers left join branches on borrowers.branchcode=branches.branchcode where cardnumber=?"
                     );
                     $sth->execute($cardnumber);
                     (
                         $borrowernumber, $firstname,  $surname,
                         $userflags,      $branchcode, $branchname,
-                        $branchprinter,  $emailaddress
+                        $emailaddress
                     ) = $sth->fetchrow if ( $sth->rows );
 
                     unless ( $sth->rows ) {
                         $sth->execute($userid);
                         (
                             $borrowernumber, $firstname,  $surname,       $userflags,
-                            $branchcode,     $branchname, $branchprinter, $emailaddress
+                            $branchcode,     $branchname, $emailaddress
                         ) = $sth->fetchrow if ( $sth->rows );
                     }
                 }
@@ -1581,8 +1577,7 @@ sub check_api_auth {
                     if ( $domain && $ip =~ /^$domain/ ) {
                         $branchcode = $branches->{$br}->{'branchcode'};
 
-                        # new op dev : add the branchprinter and branchname in the cookie
-                        $branchprinter = $branches->{$br}->{'branchprinter'};
+                        # new op dev : add the branchname to the cookie
                         $branchname    = $branches->{$br}->{'branchname'};
                     }
                 }
@@ -1605,7 +1600,7 @@ sub check_api_auth {
                 $session->param('cardnumber'),   $session->param('firstname'),
                 $session->param('surname'),      $session->param('branch'),
                 $session->param('branchname'),   $session->param('flags'),
-                $session->param('emailaddress'), $session->param('branchprinter')
+                $session->param('emailaddress')
             );
             return ( "ok", $cookie, $sessionID );
         } else {
@@ -1693,7 +1688,7 @@ sub check_cookie_auth {
             $session->param('cardnumber'),   $session->param('firstname'),
             $session->param('surname'),      $session->param('branch'),
             $session->param('branchname'),   $session->param('flags'),
-            $session->param('emailaddress'), $session->param('branchprinter')
+            $session->param('emailaddress')
         );
 
         my $ip       = $session->param('ip');
index 7b10f8f..df4b5db 100644 (file)
@@ -809,7 +809,7 @@ sub userenv {
   C4::Context->set_userenv($usernum, $userid, $usercnum,
                            $userfirstname, $usersurname,
                            $userbranch, $branchname, $userflags,
-                           $emailaddress, $branchprinter, $shibboleth);
+                           $emailaddress, $shibboleth);
 
 Establish a hash of user environment variables.
 
@@ -820,7 +820,7 @@ set_userenv is called in Auth.pm
 #'
 sub set_userenv {
     shift @_;
-    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $branchprinter, $shibboleth)=
+    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth)=
     map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here
     @_;
     my $var=$context->{"activeuser"} || '';
@@ -835,7 +835,6 @@ sub set_userenv {
         "branchname" => $branchname,
         "flags"      => $userflags,
         "emailaddress"     => $emailaddress,
-        "branchprinter"    => $branchprinter,
         "shibboleth" => $shibboleth,
     };
     $context->{userenv}->{$var} = $cell;
index 86d1241..b73794a 100644 (file)
@@ -259,8 +259,7 @@ sub checkauth {
                 $session->param('branch'),
                 $session->param('branchname'),
                 $session->param('flags'),
-                $session->param('emailaddress'),
-                $session->param('branchprinter')
+                $session->param('emailaddress')
             );
             $cookie = $query->cookie(
                 -name     => 'CGISESSID',
index 39bfb4f..2e51935 100644 (file)
@@ -39,7 +39,6 @@ BEGIN {
        require Exporter;
        @ISA    = qw(Exporter);
        @EXPORT = qw(
-        &GetPrinters &GetPrinter
         &GetItemTypesCategorized
         &getallthemes
         &getFacets
@@ -276,45 +275,6 @@ sub getImageSets {
     return \@imagesets;
 }
 
-=head2 GetPrinters
-
-  $printers = &GetPrinters();
-  @queues = keys %$printers;
-
-Returns information about existing printer queues.
-
-C<$printers> is a reference-to-hash whose keys are the print queues
-defined in the printers table of the Koha database. The values are
-references-to-hash, whose keys are the fields in the printers table.
-
-=cut
-
-sub GetPrinters {
-    my %printers;
-    my $dbh = C4::Context->dbh;
-    my $sth = $dbh->prepare("select * from printers");
-    $sth->execute;
-    while ( my $printer = $sth->fetchrow_hashref ) {
-        $printers{ $printer->{'printqueue'} } = $printer;
-    }
-    return ( \%printers );
-}
-
-=head2 GetPrinter
-
-  $printer = GetPrinter( $query, $printers );
-
-=cut
-
-sub GetPrinter {
-    my ( $query, $printers ) = @_;    # get printer for this query from printers
-    my $printer = $query->param('printer');
-    my %cookie = $query->cookie('userenv');
-    ($printer) || ( $printer = $cookie{'printer'} ) || ( $printer = '' );
-    ( $printers->{$printer} ) || ( $printer = ( keys %$printers )[0] );
-    return $printer;
-}
-
 =head2 getnbpages
 
 Returns the number of pages to display in a pagination bar, given the number
diff --git a/C4/Print.pm b/C4/Print.pm
deleted file mode 100644 (file)
index a5bd3d3..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-package C4::Print;
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# Koha is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Koha; if not, see <http://www.gnu.org/licenses>.
-
-use Modern::Perl;
-use C4::Context;
-
-use vars qw(@ISA @EXPORT);
-
-BEGIN {
-       require Exporter;
-       @ISA    = qw(Exporter);
-    @EXPORT = qw(&NetworkPrint);
-}
-
-=head1 NAME
-
-C4::Print - Koha module dealing with printing
-
-=head1 SYNOPSIS
-
-  use C4::Print;
-
-=head1 DESCRIPTION
-
-The functions in this module handle sending text to a printer.
-
-=head1 FUNCTIONS
-
-=head2 NetworkPrint
-
-  &NetworkPrint($text)
-
-Queue some text for printing on the selected branch printer
-
-=cut
-
-sub NetworkPrint {
-    my ($text) = @_;
-
-# FIXME - It'd be nifty if this could generate pretty PostScript.
-
-    my $queue = '';
-
-    # FIXME - If 'queue' is undefined or empty, then presumably it should
-    # mean "use the default queue", whatever the default is. Presumably
-    # the default depends on the physical location of the machine.
-    # FIXME - Perhaps "print to file" should be a supported option. Just
-    # set the queue to "file" (or " file", if real queues aren't allowed
-    # to have spaces in them). Or perhaps if $queue eq "" and
-    # $env->{file} ne "", then that should mean "print to $env->{file}".
-
-    my $fh;
-    if ( $queue eq "" || $queue eq 'nulllp' ) {
-        return;
-       #open( $fh, ">/tmp/kohaiss" );
-    }
-    else {
-
-        # FIXME - This assumes that 'lpr' exists, and works as expected.
-        # This is a reasonable assumption, but only because every other
-        # printing package has a wrapper script called 'lpr'. It'd still
-        # be better to be able to customize this.
-        open( $fh, "-|", "lpr -P $queue > /dev/null" )
-          or die "Couldn't write to queue:$queue!\n";
-    }
-
-    #  print $queue;
-    #open (FILE,">/tmp/$file");
-    print $fh $text;
-    print $fh "\r\n" x 7 ;
-    close $fh;
-
-    #system("lpr /tmp/$file");
-}
-
-1;
-__END__
-
-=head1 AUTHOR
-
-Koha Development Team <http://koha-community.org/>
-
-=head1 SEE ALSO
-
-C4::Circulation::Circ2(3)
-
-=cut
diff --git a/admin/printers.pl b/admin/printers.pl
deleted file mode 100755 (executable)
index 57a9133..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/usr/bin/perl
-
-#script to administer the aqbudget table
-#written 20/02/2002 by paul.poulain@free.fr
-# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
-
-# ALGO :
-# this script use an $op to know what to do.
-# if $op is empty or none of the above values,
-#      - the default screen is build (with all records, or filtered datas).
-#      - the   user can clic on add, modify or delete record.
-# if $op=add_form
-#      - if primkey exists, this is a modification,so we read the $primkey record
-#      - builds the add/modify form
-# if $op=add_validate
-#      - the user has just send datas, so we create/modify the record
-# if $op=delete_form
-#      - we show the record having primkey=$primkey and ask for deletion validation form
-# if $op=delete_confirm
-#      - we delete the record having primkey=$primkey
-
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# Koha is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Koha; if not, see <http://www.gnu.org/licenses>.
-
-use Modern::Perl;
-use CGI qw ( -utf8 );
-use C4::Context;
-use C4::Output;
-use C4::Auth;
-
-sub StringSearch  {
-       my ($searchstring,$type)=@_;            # why bother with $type if we don't use it?!
-       $searchstring=~ s/\'/\\\'/g;
-       my @data=split(' ',$searchstring);
-       my $sth = C4::Context->dbh->prepare("
-               SELECT printername,printqueue,printtype from printers 
-               WHERE (printername like ?) order by printername
-       ");
-       $sth->execute("$data[0]%");
-       my $data=$sth->fetchall_arrayref({});
-       return (scalar(@$data),$data);
-}
-
-my $input = new CGI;
-my $searchfield=$input->param('searchfield');
-#my $branchcode=$input->param('branchcode');
-my $script_name="/cgi-bin/koha/admin/printers.pl";
-
-my $op = $input->param('op');
-$searchfield=~ s/\,//g;
-
-my ($template, $loggedinuser, $cookie) = get_template_and_user(
-    {
-        template_name   => "admin/printers.tt",
-        query           => $input,
-        type            => "intranet",
-        authnotrequired => 0,
-        flagsrequired   => {parameters => '*'},
-        debug           => 1,
-    }
-);
-
-$template->param(searchfield => $searchfield,
-                script_name => $script_name);
-
-#start the page and read in includes
-
-my $dbh = C4::Context->dbh;
-################## ADD_FORM ##################################
-# called by default. Used to create form to add or  modify a record
-if ($op eq 'add_form') {
-       $template->param(add_form => 1);
-       #---- 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=?");
-               $sth->execute($searchfield);
-               $data=$sth->fetchrow_hashref;
-       }
-
-       $template->param(printqueue => $data->{'printqueue'},
-                        printtype => $data->{'printtype'});
-                                                                                                       # END $OP eq ADD_FORM
-################## ADD_VALIDATE ##################################
-# called by add_form, used to insert/modify data in DB
-} elsif ($op eq 'add_validate') {
-       $template->param(add_validate => 1);
-       if ($input->param('add')){
-               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'));
-       }
-                                                                                                       # 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=?");
-       $sth->execute($searchfield);
-       my $data=$sth->fetchrow_hashref;
-       $template->param(printqueue => $data->{'printqueue'},
-                        printtype  => $data->{'printtype'});
-                                                                                                       # END $OP eq DELETE_CONFIRM
-################## DELETE_CONFIRMED ##################################
-# 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=?");
-       $sth->execute($searchfield);
-                                                                                                       # END $OP eq DELETE_CONFIRMED
-################## DEFAULT ###########################################
-} else { # DEFAULT
-       $template->param(else => 1);
-       my ($count,$results)=StringSearch($searchfield,'web');
-    $template->param(loop => $results);
-
-} #---- END $OP eq DEFAULT
-
-output_html_with_http_headers $input, $cookie, $template->output;
-
index 1572a08..19feb30 100755 (executable)
@@ -30,9 +30,8 @@ use DateTime;
 use DateTime::Duration;
 use Scalar::Util qw( looks_like_number );
 use C4::Output;
-use C4::Print;
 use C4::Auth qw/:DEFAULT get_session haspermission/;
-use C4::Koha;   # GetPrinter
+use C4::Koha;
 use C4::Circulation;
 use C4::Utils::DataTables::Members;
 use C4::Members;
@@ -179,7 +178,6 @@ if ( $restoreduedatespec && $restoreduedatespec eq "highholds_empty" ) {
 }
 my $issueconfirmed = $query->param('issueconfirmed');
 my $cancelreserve  = $query->param('cancelreserve');
-my $print          = $query->param('print') || q{};
 my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
 my $charges        = $query->param('charges') || q{};
 
@@ -215,11 +213,6 @@ if( $onsite_checkout && !$duedatespec_allow ) {
     }
 }
 
-# check and see if we should print
-if ( @$barcodes == 0 && $print eq 'maybe' ) {
-    $print = 'yes';
-}
-
 my $inprocess = (@$barcodes == 0) ? '' : $query->param('inprocess');
 if ( @$barcodes == 0 && $charges eq 'yes' ) {
     $template->param(
@@ -228,16 +221,6 @@ if ( @$barcodes == 0 && $charges eq 'yes' ) {
     );
 }
 
-if ( $print eq 'yes' && $borrowernumber ne '' ) {
-    if ( C4::Context->boolean_preference('printcirculationslips') ) {
-        my $letter = IssueSlip($branch, $borrowernumber, "QUICK");
-        NetworkPrint($letter->{content});
-    }
-    $query->param( 'borrowernumber', '' );
-    $borrowernumber = '';
-    undef $patron;
-}
-
 #
 # STEP 2 : FIND BORROWER
 # if there is a list of find borrowers....
index 3bf7fee..65093b9 100755 (executable)
@@ -35,6 +35,9 @@ use CGI qw ( -utf8 );
 use DateTime;
 
 use C4::Auth qw/:DEFAULT get_session/;
+use C4::Output;
+use C4::Circulation;
+use C4::Reserves;
 use C4::Biblio;
 use C4::Circulation;
 use C4::Context;
@@ -43,7 +46,6 @@ use C4::Koha;   # FIXME : is it still useful ?
 use C4::Members::Messaging;
 use C4::Members;
 use C4::Output;
-use C4::Print;
 use C4::Reserves;
 use C4::RotatingCollections;
 use Koha::AuthorisedValues;
@@ -83,16 +85,11 @@ if ( $query->param('print_slip') ) {
 
 #####################
 #Global vars
-my $printers = GetPrinters();
 my $userenv = C4::Context->userenv;
 my $userenv_branch = $userenv->{'branch'} // '';
-my $printer = $userenv->{'branchprinter'} // '';
 my $forgivemanualholdsexpire = $query->param('forgivemanualholdsexpire');
 
 my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
- #
-# Some code to handle the error if there is no branch or printer setting.....
-#
 
 # Set up the item stack ....
 my %returneditems;
@@ -619,7 +616,6 @@ foreach ( sort { $a <=> $b } keys %returneditems ) {
 
 $template->param(
     riloop         => \@riloop,
-    printer        => $printer,
     errmsgloop     => \@errmsgloop,
     exemptfine     => $exemptfine,
     dropboxmode    => $dropboxmode,
index 0febd0f..c762876 100755 (executable)
@@ -23,13 +23,10 @@ use CGI qw ( -utf8 );
 use C4::Context;
 use C4::Output;
 use C4::Auth qw/:DEFAULT get_session/;
-use C4::Print;  # GetPrinters
 use C4::Koha;
 use Koha::BiblioFrameworks;
 use Koha::Libraries;
 
-# this will be the script that chooses branch and printer settings....
-
 my $query = CGI->new();
 
 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user({
@@ -44,14 +41,8 @@ my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user({
 my $sessionID = $query->cookie("CGISESSID");
 my $session = get_session($sessionID);
 
-# try to get the branch and printer settings from http, fallback to userenv
-my $printers = GetPrinters();
 my $branch   = $query->param('branch' );
-my $printer  = $query->param('printer');
-# fallbacks for $branch and $printer after possible session updates
-
 my $userenv_branch  = C4::Context->userenv->{'branch'}        || '';
-my $userenv_printer = C4::Context->userenv->{'branchprinter'} || '';
 my @updated;
 
 # $session lddines here are doing the updating
@@ -72,47 +63,12 @@ if ( $branch and my $library = Koha::Libraries->find($branch) ) {
     $branch = $userenv_branch;  # fallback value
 }
 
-# FIXME: branchprinter is not retained by session.  This feature was not adequately
-# ported from Koha 2.2.3 where it had been a separate cookie.
-# So this needs to be fixed for Koha 3 or removed outright.
-#   --atz (w/ info from chris cormack)
-
-if ($printer) {
-    if (! $userenv_printer or $userenv_printer ne $printer ) {
-        $session->param('branchprinter', $printer);         # update sesssion in DB
-        $session->flush();
-        $template->param('new_printer', $printer);          # update template
-        push @updated, {
-            updated_printer => 1,
-                old_printer => $userenv_printer,
-        };
-    } # else printer is the same, no update
-} else {
-    $printer = $userenv_printer;  # fallback value
-}
-
 $template->param(updated => \@updated) if (scalar @updated);
 
-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
     $_ eq "branch"     and next;  # disclude branch
-    $_ eq "printer"    and next;  # disclude printer
     $_ eq "oldreferer" and next;  # disclude oldreferer
     push @recycle_loop, {
         param => $_,
@@ -130,7 +86,6 @@ if (scalar @updated and not scalar @recycle_loop) {
 
 $template->param(
     referer     => $referer,
-    printerloop => \@printerloop,
     branch      => $branch,
     recycle_loop=> \@recycle_loop,
 );
diff --git a/installer/data/mysql/atomicupdate/bug_17845_remove_printers b/installer/data/mysql/atomicupdate/bug_17845_remove_printers
new file mode 100644 (file)
index 0000000..914860b
--- /dev/null
@@ -0,0 +1,4 @@
+DROP TABLE IF EXISTS printers;
+ALTER TABLE branches DROP COLUMN branchprinter;
+DELETE FROM systempreferences WHERE variable = "printcirculationslips";
+-- Bug 17845: Drop unused table printers and branchprinter column
index 5cb56ae..0f09272 100644 (file)
@@ -266,7 +266,6 @@ CREATE TABLE `branches` ( -- information about your libraries or branches are st
   `branchurl` LONGTEXT, -- 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
   `branchnotes` LONGTEXT, -- notes related to your library or branch
   opac_info MEDIUMTEXT, -- HTML that displays in OPAC
   `geolocation` VARCHAR(255) default NULL, -- geolocation of your library
@@ -1239,19 +1238,6 @@ CREATE TABLE pending_offline_operations (
   PRIMARY KEY (operationid)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
-
---
--- 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`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-
 --
 -- Table structure for table `printers_profile`
 --
index 51d1efe..df1f79e 100644 (file)
@@ -1,19 +1,19 @@
 TRUNCATE branches;
 
-INSERT INTO `branches` (`branchcode`, `branchname`, `branchaddress1`, `branchaddress2`, `branchaddress3`, `branchphone`, `branchfax`, `branchemail`, `issuing`, `branchip`, `branchprinter`) VALUES
+INSERT INTO `branches` (`branchcode`, `branchname`, `branchaddress1`, `branchaddress2`, `branchaddress3`, `branchphone`, `branchfax`, `branchemail`, `issuing`, `branchip`) VALUES
 ('AB',   'Абонемент', 
-             'Украина', 'г. Тернополь', 'кабинет 53 (2-ой этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, '', NULL),
+             'Украина', 'г. Тернополь', 'кабинет 53 (2-ой этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, ''),
 ('ABH',  'Абонемент художественной литературы', 
-             'Украина', 'г. Тернополь', 'кабинет 53 (2-ой этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, '', NULL),
+             'Украина', 'г. Тернополь', 'кабинет 53 (2-ой этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, ''),
 ('CHZ',  'Читательский зал', 
-             'Украина', 'г. Тернополь', 'кабинет 58 (3-ий этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, '', NULL),
+             'Украина', 'г. Тернополь', 'кабинет 58 (3-ий этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, ''),
 ('CHZP', 'Читательский зал периодики, каталог', 
-             'Украина', 'г. Тернополь', 'кабинет 2 (1-ый этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, '', NULL),
+             'Украина', 'г. Тернополь', 'кабинет 2 (1-ый этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, ''),
 ('ECHZ', 'Электронный читательский зал',
-             'Украина', 'г. Тернополь', 'кабинет 54 (2-ой этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, '', NULL),
+             'Украина', 'г. Тернополь', 'кабинет 54 (2-ой этаж)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, ''),
 ('LNSL', 'Львовская национальная научная библиотека им. В.Стефаника НАНУ', 
-             'Украина', 'г. Львов', 'ул. Стефаника 2', '8 (032) 272-45-36', '', 'library@library.lviv.ua', NULL, '', NULL),
+             'Украина', 'г. Львов', 'ул. Стефаника 2', '8 (032) 272-45-36', '', 'library@library.lviv.ua', NULL, ''),
 ('STL',  'Научно-техническая библиотека Тернопольского государственного техниеского университета им. Ив Пулюя', 
-             'Украина', 'м. Тернопіль', 'ул. Руська 56, кабинет 5 (второй корпус)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, '', NULL),
+             'Украина', 'м. Тернопіль', 'ул. Руська 56, кабинет 5 (второй корпус)', '8 (0352) 52-53-45', '', 'lib@tu.edu.te.ua', NULL, ''),
 ('NPLU', 'Национальная парламентская библиотека Украины', 
-             'Украина', 'г. Киев', 'ул. Грушевского, 1', '38 (044) 278-85-12', '38 (044) 278-85-12', 'office@nplu.org', NULL, '192.168.1.*', NULL);
+             'Украина', 'г. Киев', 'ул. Грушевского, 1', '38 (044) 278-85-12', '38 (044) 278-85-12', 'office@nplu.org', NULL, '192.168.1.*');
index 3e513fd..62283f1 100644 (file)
@@ -502,7 +502,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('PrefillItem','0','','When a new item is added, should it be prefilled with last created item values?','YesNo'),
 ('PreserveSerialNotes','1','','When a new "Expected" issue is generated, should it be prefilled with last created issue notes?','YesNo'),
 ('previousIssuesDefaultSortOrder','asc','asc|desc','Specify the sort order of Previous Issues on the circulation page','Choice'),
-('printcirculationslips','1','','If ON, enable printing circulation receipts','YesNo'),
 ('PrintNoticesMaxLines','0','','If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.','Integer'),
 ('PrivacyPolicyURL','',NULL,'This URL is used in messages about GDPR consents.', 'Free'),
 ('ProcessingFeeNote', '', NULL, 'Set the text to be recorded in the column note, table accountlines when the processing fee (defined in item type) is applied', 'textarea'),
index bb03bd5..bb71416 100644 (file)
@@ -1,5 +1,4 @@
 Circulation:
-# FIXME: printcirculationslips is also omitted. It _technically_ could work, but C4::Print is HLT specific and needs a little bit of refactoring.
     Interface:
         -
             - pref: CircSidebar
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt
deleted file mode 100644 (file)
index 1a83fe3..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-[% USE raw %]
-[% USE Asset %]
-[% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Administration &rsaquo;
-[% IF ( add_form ) %][% IF ( searchfield ) %] Printers &rsaquo; Modify printer '[% searchfield | html %]'[% ELSE %] Printers &rsaquo; New printer[% END %][% END %]
-[% IF ( add_validate ) %] Printers &rsaquo; Printer added[% END %]
-[% IF ( delete_confirm ) %] Printers &rsaquo; Confirm deletion of printer '[% searchfield | html %]'[% END %]
-[% IF ( delete_confirmed ) %] Printers &rsaquo; Printer deleted[% END %]
-[% IF ( else ) %]Printers[% END %]</title>
-[% INCLUDE 'doc-head-close.inc' %]
-[% IF ( loop ) %]
-[% INCLUDE 'datatables.inc' %]
-<script>
-//<![CDATA[
-    $(document).ready(function() {
-        $("#printerst").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "aoColumnDefs": [
-                { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
-            ],
-            "aaSorting": [[ 0, "asc" ]],
-            "sPaginationType": "full"
-        }));
-    });
-//]]>
-</script>
-[% END %]
-</head>
-<body id="admin_printers" class="admin">
-[% INCLUDE 'header.inc' %]
-[% INCLUDE 'cat-search.inc' %]
-
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( add_form ) %][% IF ( searchfield ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Modify printer '[% searchfield | html %]'[% ELSE %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; New printer[% END %][% END %]
-[% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Printer added[% END %]
-[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Confirm deletion of printer '[% searchfield | html %]'[% END %]
-[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Printer deleted[% END %]
-[% IF ( else ) %]Printers[% END %]</div>
-
-<div class="main container-fluid">
-    <div class="row">
-        <div class="col-sm-10 col-sm-push-2">
-            <main>
-
-[% IF ( add_form ) %]
-
-[% IF ( searchfield ) %]
-               <h1>Modify printer</h1>
-       [% ELSE %]
-               <h1>New printer</h1>
-       [% END %]
-        <form action="[% script_name | html %]" name="Aform" method="post" class="validated">
-        <input type="hidden" name="op" value="add_validate" />
-       [% IF ( 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 | html %]" />[% searchfield | html %]
-               </li>
-       [% ELSE %]
-               <li>
-            <label for="printername" class="required">Printer name: </label>
-                <input type="text" name="printername" id="printername" size="40" maxlength="40" class="required" required="required" />
-                <span class="required">Required</span>
-               </li>
-       [% END %]
-               <li>
-            <label for="printqueue" class="required">Queue: </label>
-            <input type="text" name="printqueue" id="printqueue" size="20" maxlength="20" value="[% printqueue | html %]"  class="required" required="required" />
-            <span class="required">Required</span>
-               </li>
-               <li>
-                       <label for="printtype">Type: </label>
-            <input type="text" name="printtype" id="printtype" size="20" maxlength="20" value="[% printtype | html %]" />
-               </li></ol>
-        </fieldset>
-        <fieldset class="action"><input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/printers.pl">Cancel</a></fieldset>
-        </form>
-
-[% END %]
-
-[% IF ( add_validate ) %]
-<h3>Printer added</h3>
-<form action="[% script_name | html %]" method="post">
-       <fieldset class="action"> <input type="submit" value="OK" /></fieldset>
-</form>
-[% END %]
-
-[% IF ( delete_confirm ) %]
-    <div class="dialog alert">
-        <h3>Confirm deletion of printer <em>[% searchfield | html %]</em></h3>
-
-        <table>
-            <tr>
-                <th scope="row">Printer: </th><td>[% searchfield | html %]</td>
-            </tr>
-            <tr>
-                <th scope="row">Queue: </th><td>[% printqueue | html %]</td>
-            </tr>
-            <tr>
-                <th scope="row">Type: </th><td>[% printtype | html %]</td>
-            </tr>
-        </table>
-
-        <form action="[% script_name | html %]" method="post">
-            <input type="hidden" name="op" value="delete_confirmed" />
-            <input type="hidden" name="searchfield" value="[% searchfield | html %]" />
-            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
-        </form>
-        <form action="/cgi-bin/koha/admin/printers.pl" method="get">
-            <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
-        </form>
-    </div>
-[% END %]
-
-[% IF ( delete_confirmed ) %]
-    <div class="dialog message">
-        <h3>Printer deleted</h3>
-        <form action="[% script_name | html %]" method="post">
-            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
-        </form>
-    </div>
-
-[% END %]
-
-[% IF ( else ) %]
-
-<div id="toolbar" class="btn-toolbar">
-    <a class="btn btn-default" id="newprinter" href="/cgi-bin/koha/admin/printers.pl?op=add_form"><i class="fa fa-plus"></i> New printer</a>
-</div>
-
-<h2>Printers</h2>
-       [% IF ( searchfield ) %]
-               You searched for [% searchfield | html %]</span>
-       [% END %]
-
-[% IF ( loop ) %]
-    <table id="printerst">
-        <thead>
-            <tr>
-                <th>Name</th>
-                <th>Queue</th>
-                <th>Type</th>
-                <th>&nbsp;</th>
-            </tr>
-        </thead>
-        <tbody>
-               [% FOREACH loo IN loop %]
-        <tr>
-                       <td>[% loo.printername | html %]</td>
-                       <td>[% loo.printqueue | html %]</td>
-                       <td>[% loo.printtype | html %]</td>
-            <td class="actions"><a class="btn btn-default btn-xs" href="[% loo.script_name | url %]?op=add_form&amp;searchfield=[% loo.printername |uri %]"><i class="fa fa-pencil"></i> Edit</a> <a class="btn btn-default btn-xs" href="[% loo.script_name | url %]?op=delete_confirm&amp;searchfield=[% loo.printername |uri %]"><i class="fa fa-trash"></i> Delete</a></td>
-               </tr>
-               [% END %]
-        </tbody>
-    </table>[% ELSE %]<div class="dialog message">No printers defined.</div>[% END %]
-[% END %]
-
-            </main>
-        </div> <!-- /.col-sm-10.col-sm-push-2 -->
-
-        <div class="col-sm-2 col-sm-pull-10">
-            <aside>
-                [% INCLUDE 'admin-menu.inc' %]
-            </aside>
-        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
-     </div> <!-- /.row -->
-
-[% INCLUDE 'intranet-bottom.inc' %]
index f2a65c9..19d462c 100644 (file)
@@ -37,8 +37,6 @@ Updated:<ul>
     [% FOREACH update IN updated %]
     [% IF ( update.updated_branch ) %]
         <li>Library: [% update.old_branch or "?" | html %] &rArr; [% update.LoginBranchcode or "?" | html %]</li>
-    [% ELSIF ( update.updated_printer ) %]
-      <!-- FIXME:  <li>Printer: [% update.old_printer or "?" | html %] &rArr; [% update.new_printer or "?" | html %]</li> -->
     [% ELSE %]
         <li>ERROR - unknown</li>
     [% END %]
@@ -67,19 +65,6 @@ Updated:<ul>
             [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
         </select></li>
     [% END %]
-<!--
-    [% IF ( printerloop ) %]
-        <li><label for="printer">Choose a network printer:</label>
-        <select name="printer" id="printer">
-            [% FOREACH printerloo IN printerloop %]
-                [% IF ( printerloo.selected ) %]
-                    <option value="[% printerloo.value | html %]" selected="selected">[% printerloo.name | html %]</option>
-                [% ELSE %]
-                    <option value="[% printerloo.value | html %]">[% printerloo.name | html %]</option>
-                [% END %]
-            [% END %]
-        </select></li>
-    [% END %] -->
     </ol>
 </fieldset>
 <fieldset class="action">
diff --git a/t/Print.t b/t/Print.t
deleted file mode 100755 (executable)
index faf729d..0000000
--- a/t/Print.t
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/perl
-#
-# This Koha test module is a stub!  
-# Add more tests here!!!
-
-use strict;
-use warnings;
-
-use Test::More tests => 2;
-
-BEGIN {
-        use_ok('C4::Print');
-}
-ok( !NetworkPrint(""));
-