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

(-)a/C4/Auth.pm (-12 / +41 lines)
Lines 29-34 use C4::Context; Link Here
29
use C4::Templates;    # to get the template
29
use C4::Templates;    # to get the template
30
use C4::Languages;
30
use C4::Languages;
31
use C4::Branch;       # GetBranches
31
use C4::Branch;       # GetBranches
32
use C4::Printer qw(GetPrinterDetails);
32
use C4::Search::History;
33
use C4::Search::History;
33
use Koha;
34
use Koha;
34
use Koha::AuthUtils qw(hash_password);
35
use Koha::AuthUtils qw(hash_password);
Lines 52-58 BEGIN { Link Here
52
    @ISA       = qw(Exporter);
53
    @ISA       = qw(Exporter);
53
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
54
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
54
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
55
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
55
      &get_all_subpermissions &get_user_subpermissions
56
      &get_all_subpermissions &get_user_subpermissions &get_user_printer
56
    );
57
    );
57
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
58
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
58
    $ldap      = C4::Context->config('useldapserver') || 0;
59
    $ldap      = C4::Context->config('useldapserver') || 0;
Lines 398-403 sub get_template_and_user { Link Here
398
399
399
    $template->param(auth_forwarded_hash => $in->{'query'}->param('auth_forwarded_hash'));
400
    $template->param(auth_forwarded_hash => $in->{'query'}->param('auth_forwarded_hash'));
400
401
402
    my $userenv = C4::Context->userenv;
403
    my $userenv_branch = $userenv ? $userenv->{"branch"} : undef;
404
401
    # these template parameters are set the same regardless of $in->{'type'}
405
    # these template parameters are set the same regardless of $in->{'type'}
402
406
403
    # Set the using_https variable for templates
407
    # Set the using_https variable for templates
Lines 411-421 sub get_template_and_user { Link Here
411
        GoogleJackets                                                      => C4::Context->preference("GoogleJackets"),
415
        GoogleJackets                                                      => C4::Context->preference("GoogleJackets"),
412
        OpenLibraryCovers                                                  => C4::Context->preference("OpenLibraryCovers"),
416
        OpenLibraryCovers                                                  => C4::Context->preference("OpenLibraryCovers"),
413
        KohaAdminEmailAddress                                              => "" . C4::Context->preference("KohaAdminEmailAddress"),
417
        KohaAdminEmailAddress                                              => "" . C4::Context->preference("KohaAdminEmailAddress"),
414
        LoginBranchcode => ( C4::Context->userenv ? C4::Context->userenv->{"branch"}    : undef ),
418
        LoginBranchcode => $userenv_branch,
415
        LoginFirstname  => ( C4::Context->userenv ? C4::Context->userenv->{"firstname"} : "Bel" ),
419
        LoginFirstname  => ( $userenv ? $userenv->{"firstname"} : undef ),
416
        LoginSurname    => C4::Context->userenv ? C4::Context->userenv->{"surname"}      : "Inconnu",
420
        LoginSurname    => $userenv ? $userenv->{"surname"}      : undef,
417
        emailaddress    => C4::Context->userenv ? C4::Context->userenv->{"emailaddress"} : undef,
421
        emailaddress    => $userenv ? $userenv->{"emailaddress"} : undef,
418
        loggedinpersona => C4::Context->userenv ? C4::Context->userenv->{"persona"}      : undef,
422
        loggedinpersona => $userenv ? $userenv->{"persona"}      : undef,
419
        TagsEnabled     => C4::Context->preference("TagsEnabled"),
423
        TagsEnabled     => C4::Context->preference("TagsEnabled"),
420
        hide_marc       => C4::Context->preference("hide_marc"),
424
        hide_marc       => C4::Context->preference("hide_marc"),
421
        item_level_itypes  => C4::Context->preference('item-level_itypes'),
425
        item_level_itypes  => C4::Context->preference('item-level_itypes'),
Lines 440-446 sub get_template_and_user { Link Here
440
            IntranetNav                                                                => C4::Context->preference("IntranetNav"),
444
            IntranetNav                                                                => C4::Context->preference("IntranetNav"),
441
            IntranetmainUserblock                                                      => C4::Context->preference("IntranetmainUserblock"),
445
            IntranetmainUserblock                                                      => C4::Context->preference("IntranetmainUserblock"),
442
            LibraryName                                                                => C4::Context->preference("LibraryName"),
446
            LibraryName                                                                => C4::Context->preference("LibraryName"),
443
            LoginBranchname                                                            => ( C4::Context->userenv ? C4::Context->userenv->{"branchname"} : undef ),
447
            LoginBranchname                                                            => ( $userenv ? $userenv->{"branchname"} : undef ),
444
            advancedMARCEditor                                                         => C4::Context->preference("advancedMARCEditor"),
448
            advancedMARCEditor                                                         => C4::Context->preference("advancedMARCEditor"),
445
            canreservefromotherbranches                                                => C4::Context->preference('canreservefromotherbranches'),
449
            canreservefromotherbranches                                                => C4::Context->preference('canreservefromotherbranches'),
446
            intranetcolorstylesheet                                                    => C4::Context->preference("intranetcolorstylesheet"),
450
            intranetcolorstylesheet                                                    => C4::Context->preference("intranetcolorstylesheet"),
Lines 462-467 sub get_template_and_user { Link Here
462
            UseCourseReserves                                                          => C4::Context->preference("UseCourseReserves"),
466
            UseCourseReserves                                                          => C4::Context->preference("UseCourseReserves"),
463
            useDischarge                                                               => C4::Context->preference('useDischarge'),
467
            useDischarge                                                               => C4::Context->preference('useDischarge'),
464
        );
468
        );
469
        if ( C4::Context->preference('UsePrintQueues') ) {
470
            my $printer = get_user_printer();
471
            my $printer_rec = $printer ? GetPrinterDetails($printer) : {};
472
            $template->param(
473
                UsePrintQueues          => 1,
474
                PrinterName             => $printer_rec->{printername},
475
            );
476
        }
465
    }
477
    }
466
    else {
478
    else {
467
        warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' );
479
        warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' );
Lines 497-504 sub get_template_and_user { Link Here
497
            $opac_name = $1;    # opac_search_limit is a branch, so we use it.
509
            $opac_name = $1;    # opac_search_limit is a branch, so we use it.
498
        } elsif ( $in->{'query'}->param('multibranchlimit') ) {
510
        } elsif ( $in->{'query'}->param('multibranchlimit') ) {
499
            $opac_name = $in->{'query'}->param('multibranchlimit');
511
            $opac_name = $in->{'query'}->param('multibranchlimit');
500
        } elsif ( C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'} ) {
512
        } elsif ( C4::Context->preference("SearchMyLibraryFirst") && $userenv_branch ) {
501
            $opac_name = C4::Context->userenv->{'branch'};
513
            $opac_name = $userenv_branch;
502
        }
514
        }
503
515
504
        $template->param(
516
        $template->param(
Lines 509-515 sub get_template_and_user { Link Here
509
            BranchCategoriesLoop                  => GetBranchCategories( 'searchdomain', 1, $opac_name ),
521
            BranchCategoriesLoop                  => GetBranchCategories( 'searchdomain', 1, $opac_name ),
510
            LibraryName                           => "" . C4::Context->preference("LibraryName"),
522
            LibraryName                           => "" . C4::Context->preference("LibraryName"),
511
            LibraryNameTitle                      => "" . $LibraryNameTitle,
523
            LibraryNameTitle                      => "" . $LibraryNameTitle,
512
            LoginBranchname                       => C4::Context->userenv ? C4::Context->userenv->{"branchname"} : "",
524
            LoginBranchname                       => $userenv ? $userenv->{"branchname"} : "",
513
            OPACAmazonCoverImages                 => C4::Context->preference("OPACAmazonCoverImages"),
525
            OPACAmazonCoverImages                 => C4::Context->preference("OPACAmazonCoverImages"),
514
            OPACFRBRizeEditions                   => C4::Context->preference("OPACFRBRizeEditions"),
526
            OPACFRBRizeEditions                   => C4::Context->preference("OPACFRBRizeEditions"),
515
            OpacHighlightedWords                  => C4::Context->preference("OpacHighlightedWords"),
527
            OpacHighlightedWords                  => C4::Context->preference("OpacHighlightedWords"),
Lines 535-541 sub get_template_and_user { Link Here
535
            RequestOnOpac                         => C4::Context->preference("RequestOnOpac"),
547
            RequestOnOpac                         => C4::Context->preference("RequestOnOpac"),
536
            'Version'                             => C4::Context->preference('Version'),
548
            'Version'                             => C4::Context->preference('Version'),
537
            hidelostitems                         => C4::Context->preference("hidelostitems"),
549
            hidelostitems                         => C4::Context->preference("hidelostitems"),
538
            mylibraryfirst                        => ( C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv ) ? C4::Context->userenv->{'branch'} : '',
550
            mylibraryfirst                        => ( C4::Context->preference("SearchMyLibraryFirst") && $userenv ) ? $userenv_branch : '',
539
            opaclayoutstylesheet                  => "" . C4::Context->preference("opaclayoutstylesheet"),
551
            opaclayoutstylesheet                  => "" . C4::Context->preference("opaclayoutstylesheet"),
540
            opacbookbag                           => "" . C4::Context->preference("opacbookbag"),
552
            opacbookbag                           => "" . C4::Context->preference("opacbookbag"),
541
            opaccredits                           => "" . C4::Context->preference("opaccredits"),
553
            opaccredits                           => "" . C4::Context->preference("opaccredits"),
Lines 2023-2029 sub getborrowernumber { Link Here
2023
    return 0;
2035
    return 0;
2024
}
2036
}
2025
2037
2026
END { }    # module clean-up code here (global destructor)
2038
=head2 get_user_printer
2039
2040
  $printer = get_user_printer();
2041
2042
  Returns printer queue that is to be used for the logged in user
2043
2044
=cut
2045
2046
sub get_user_printer {
2047
    my $userenv = C4::Context->userenv or return;
2048
    if (my $printer = $userenv->{branchprinter}) {
2049
        return $printer;
2050
    }
2051
    my $branchname = $userenv->{branch} or return;
2052
    my $branch = GetBranchDetail($branchname) or return;
2053
    return $branch->{branchprinter};
2054
}
2055
2027
1;
2056
1;
2028
__END__
2057
__END__
2029
2058
(-)a/C4/Koha.pm (-40 lines)
Lines 40-46 BEGIN { Link Here
40
	@EXPORT = qw(
40
	@EXPORT = qw(
41
		&slashifyDate
41
		&slashifyDate
42
		&subfield_is_koha_internal_p
42
		&subfield_is_koha_internal_p
43
		&GetPrinters &GetPrinter
44
		&GetItemTypes &getitemtypeinfo
43
		&GetItemTypes &getitemtypeinfo
45
                &GetItemTypesCategorized &GetItemTypesByCategory
44
                &GetItemTypesCategorized &GetItemTypesByCategory
46
		&GetSupportName &GetSupportList
45
		&GetSupportName &GetSupportList
Lines 672-716 sub getImageSets { Link Here
672
    return \@imagesets;
671
    return \@imagesets;
673
}
672
}
674
673
675
=head2 GetPrinters
676
677
  $printers = &GetPrinters();
678
  @queues = keys %$printers;
679
680
Returns information about existing printer queues.
681
682
C<$printers> is a reference-to-hash whose keys are the print queues
683
defined in the printers table of the Koha database. The values are
684
references-to-hash, whose keys are the fields in the printers table.
685
686
=cut
687
688
sub GetPrinters {
689
    my %printers;
690
    my $dbh = C4::Context->dbh;
691
    my $sth = $dbh->prepare("select * from printers");
692
    $sth->execute;
693
    while ( my $printer = $sth->fetchrow_hashref ) {
694
        $printers{ $printer->{'printqueue'} } = $printer;
695
    }
696
    return ( \%printers );
697
}
698
699
=head2 GetPrinter
700
701
  $printer = GetPrinter( $query, $printers );
702
703
=cut
704
705
sub GetPrinter {
706
    my ( $query, $printers ) = @_;    # get printer for this query from printers
707
    my $printer = $query->param('printer');
708
    my %cookie = $query->cookie('userenv');
709
    ($printer) || ( $printer = $cookie{'printer'} ) || ( $printer = '' );
710
    ( $printers->{$printer} ) || ( $printer = ( keys %$printers )[0] );
711
    return $printer;
712
}
713
714
=head2 getnbpages
674
=head2 getnbpages
715
675
716
Returns the number of pages to display in a pagination bar, given the number
676
Returns the number of pages to display in a pagination bar, given the number
(-)a/C4/Printer.pm (+158 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
package C4::Printer;
4
5
# Copyright 2012 Catalyst IT
6
#
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
use strict;
23
use warnings;
24
25
use C4::Context;
26
27
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
28
29
BEGIN {
30
    $VERSION = 3.07.00.049;
31
    require Exporter;
32
    @ISA    = qw(Exporter);
33
    @EXPORT = qw(
34
    );
35
    @EXPORT_OK = qw(
36
        &GetPrinters &SearchPrinters &GetPrinterDetails
37
        &AddPrinter &UpdatePrinter &DeletePrinter
38
    );
39
}
40
41
=head1 NAME
42
43
C4::Printer - functions that deal with printer selection
44
45
=head1 SYNOPSIS
46
47
  use C4::Printer;
48
49
=head1 DESCRIPTION
50
51
This module provides functions to select printer for slips etc.
52
53
TODO: Move SQL from admin/printers.pl to this module
54
55
=head1 FUNCTIONS
56
57
=head2 GetPrinters
58
59
  $printers = &GetPrinters();
60
  @queues = keys %$printers;
61
62
Returns information about existing printer queues.
63
64
C<$printers> is a reference-to-hash whose keys are the print queues
65
defined in the printers table of the Koha database. The values are
66
references-to-hash, whose keys are the fields in the printers table.
67
68
=cut
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
77
sub GetPrinters {
78
    my %printers;
79
    my $dbh = C4::Context->dbh;
80
    my $sth = $dbh->prepare($PRINTER_SELECT_FROM);
81
    $sth->execute;
82
    while ( my $printer = $sth->fetchrow_hashref ) {
83
        $printers{ $printer->{'printqueue'} } = $printer;
84
    }
85
    return ( \%printers );
86
}
87
88
=head2 SearchPrinters
89
90
  $printers = SearchPrinters( $searchstring );
91
92
=cut
93
94
sub SearchPrinters {
95
    my ($searchstring)=@_;
96
    $searchstring .= '%';
97
    return C4::Context->dbh->selectall_arrayref(
98
        "$PRINTER_SELECT_FROM
99
         WHERE printername like ? OR printqueue like ? ORDER BY printername",
100
        {Slice => {}},
101
        $searchstring, $searchstring);
102
}
103
104
=head2 GetPrinterDetails
105
106
  $printer_rec = GetPrinterDetails( $printqueue );
107
108
=cut
109
110
sub GetPrinterDetails {
111
    my ( $printer ) = @_;
112
    my $dbh = C4::Context->dbh;
113
    return $dbh->selectrow_hashref(
114
        "$PRINTER_SELECT_FROM
115
         WHERE printqueue = ?",
116
        undef, $printer);
117
}
118
119
=head2 AddPrinter
120
121
  AddPrinter( $data );
122
123
=cut
124
125
sub AddPrinter {
126
    my ( $data ) = @_;
127
    my $dbh = C4::Context->dbh;
128
    $dbh->do("INSERT INTO printers (printername,printqueue,printtype) VALUES (?,?,?)", undef,
129
        $data->{printername}, $data->{printqueue}, $data->{printtype});
130
}
131
132
=head2 UpdatePrinter
133
134
  UpdatePrinter( $printqueue, $data );
135
136
=cut
137
138
sub UpdatePrinter {
139
    my ( $printqueue, $data ) = @_;
140
    my $dbh = C4::Context->dbh;
141
    $dbh->do("UPDATE printers SET printqueue = ?, printername = ?, printtype = ? WHERE printqueue = ?", undef,
142
        $data->{printqueue}, $data->{printername}, $data->{printtype}, $printqueue);
143
}
144
145
=head2 DeletePrinter
146
147
  DeletePrinter( $printqueue );
148
149
=cut
150
151
sub DeletePrinter {
152
    my ( $printqueue ) = @_;
153
    my $dbh = C4::Context->dbh;
154
    $dbh->do("DELETE FROM printers WHERE printqueue = ?", undef,
155
        $printqueue);
156
}
157
158
1;
(-)a/admin/branches.pl (-12 / +19 lines)
Lines 45-50 use C4::Context; Link Here
45
use C4::Output;
45
use C4::Output;
46
use C4::Koha;
46
use C4::Koha;
47
use C4::Branch;
47
use C4::Branch;
48
use C4::Printer qw(GetPrinters);
48
49
49
# Fixed variables
50
# Fixed variables
50
my $script_name = "/cgi-bin/koha/admin/branches.pl";
51
my $script_name = "/cgi-bin/koha/admin/branches.pl";
Lines 228-240 sub default { Link Here
228
229
229
sub editbranchform {
230
sub editbranchform {
230
    my ($branchcode,$innertemplate) = @_;
231
    my ($branchcode,$innertemplate) = @_;
231
    # initiate the scrolling-list to select the printers
232
232
    my $printers = GetPrinters();
233
    my @printerloop;
234
    my $data;
233
    my $data;
235
    my $oldprinter = "";
234
    my $oldprinter = "";
236
235
237
238
    # make the checkboxes.....
236
    # make the checkboxes.....
239
    my $catinfo = GetBranchCategories();
237
    my $catinfo = GetBranchCategories();
240
238
Lines 260-274 sub editbranchform { Link Here
260
    }
258
    }
261
    $innertemplate->param( categoryloop => $catinfo );
259
    $innertemplate->param( categoryloop => $catinfo );
262
260
263
    foreach my $thisprinter ( keys %$printers ) {
261
    if ( C4::Context->preference('UsePrintQueues') ) {
264
        push @printerloop, {
262
        # initiate the scrolling-list to select the printers
265
            value         => $thisprinter,
263
        my $printers = GetPrinters();
266
            selected      => ( $oldprinter eq $printers->{$thisprinter} ),
264
        my @printerloop;
267
            branchprinter => $printers->{$thisprinter}->{'printqueue'},
265
        foreach my $thisprinter ( keys %$printers ) {
268
        };
266
            push @printerloop, {
269
    }
267
                value         => $thisprinter,
268
                selected      => ( $oldprinter eq $thisprinter ),
269
                branchprinter => $printers->{$thisprinter}->{'printername'},
270
            };
271
        }
270
272
271
    $innertemplate->param( printerloop => \@printerloop );
273
        $innertemplate->param( printerloop => \@printerloop );
274
    }
272
275
273
    for my $obsolete ( 'categoryname', 'categorycode', 'codedescription' ) {
276
    for my $obsolete ( 'categoryname', 'categorycode', 'codedescription' ) {
274
        $innertemplate->param(
277
        $innertemplate->param(
Lines 304-309 sub branchinfotable { Link Here
304
307
305
    my ($branchcode,$innertemplate) = @_;
308
    my ($branchcode,$innertemplate) = @_;
306
    my $branchinfo = $branchcode ? GetBranchInfo($branchcode) : GetBranchInfo();
309
    my $branchinfo = $branchcode ? GetBranchInfo($branchcode) : GetBranchInfo();
310
    my $printers = GetPrinters();
307
    my @loop_data = ();
311
    my @loop_data = ();
308
    foreach my $branch (@$branchinfo) {
312
    foreach my $branch (@$branchinfo) {
309
        #
313
        #
Lines 363-368 sub branchinfotable { Link Here
363
        $row{'branch_name'} = $branch->{'branchname'};
367
        $row{'branch_name'} = $branch->{'branchname'};
364
        $row{'branch_code'} = $branch->{'branchcode'};
368
        $row{'branch_code'} = $branch->{'branchcode'};
365
        $row{'value'}       = $branch->{'branchcode'};
369
        $row{'value'}       = $branch->{'branchcode'};
370
        if (my $printer = $branch->{'branchprinter'}) {
371
            $row{'branchprintername'} = $printers->{$printer}->{'printername'};
372
        }
366
373
367
        push @loop_data, \%row;
374
        push @loop_data, \%row;
368
    }
375
    }
(-)a/admin/printers.pl (-71 / +77 lines)
Lines 7-23 Link Here
7
# ALGO :
7
# ALGO :
8
# this script use an $op to know what to do.
8
# this script use an $op to know what to do.
9
# if $op is empty or none of the above values,
9
# if $op is empty or none of the above values,
10
#	- the default screen is build (with all records, or filtered datas).
10
#   - the default screen is build (with all records, or filtered datas).
11
#	- the   user can clic on add, modify or delete record.
11
#   - the   user can clic on add, modify or delete record.
12
# if $op=add_form
12
# if $op=add_form
13
#	- if primkey exists, this is a modification,so we read the $primkey record
13
#   - if primkey exists, this is a modification,so we read the $primkey record
14
#	- builds the add/modify form
14
#   - builds the add/modify form
15
# if $op=add_validate
15
# if $op=add_validate
16
#	- the user has just send datas, so we create/modify the record
16
#   - the user has just send datas, so we create/modify the record
17
# if $op=delete_form
17
# if $op=delete_form
18
#	- we show the record having primkey=$primkey and ask for deletion validation form
18
#   - we show the record having primkey=$primkey and ask for deletion validation form
19
# if $op=delete_confirm
19
# if $op=delete_confirm
20
#	- we delete the record having primkey=$primkey
20
#   - we delete the record having primkey=$primkey
21
21
22
22
23
# Copyright 2000-2002 Katipo Communications
23
# Copyright 2000-2002 Katipo Communications
Lines 43-61 use CGI qw ( -utf8 ); Link Here
43
use C4::Context;
43
use C4::Context;
44
use C4::Output;
44
use C4::Output;
45
use C4::Auth;
45
use C4::Auth;
46
46
use C4::Printer qw(GetPrinterDetails SearchPrinters AddPrinter UpdatePrinter DeletePrinter);
47
sub StringSearch  {
48
	my ($searchstring,$type)=@_;		# why bother with $type if we don't use it?!
49
	$searchstring=~ s/\'/\\\'/g;
50
	my @data=split(' ',$searchstring);
51
	my $sth = C4::Context->dbh->prepare("
52
		SELECT printername,printqueue,printtype from printers 
53
		WHERE (printername like ?) order by printername
54
	");
55
	$sth->execute("$data[0]%");
56
	my $data=$sth->fetchall_arrayref({});
57
	return (scalar(@$data),$data);
58
}
59
47
60
my $input = new CGI;
48
my $input = new CGI;
61
my $searchfield=$input->param('searchfield');
49
my $searchfield=$input->param('searchfield');
Lines 78-152 my ($template, $loggedinuser, $cookie) = get_template_and_user( Link Here
78
    }
66
    }
79
);
67
);
80
68
81
$template->param(searchfield => $searchfield,
82
		 script_name => $script_name);
83
84
#start the page and read in includes
69
#start the page and read in includes
85
70
86
my $dbh = C4::Context->dbh;
71
my $dbh = C4::Context->dbh;
72
my $list_printers = 1;
87
################## ADD_FORM ##################################
73
################## ADD_FORM ##################################
88
# called by default. Used to create form to add or  modify a record
74
# called by default. Used to create form to add or  modify a record
89
if ($op eq 'add_form') {
75
if ($op eq 'add_form') {
90
	$template->param(add_form => 1);
76
    $list_printers = 0;
91
	#---- if primkey exists, it's a modify action, so read values to modify...
77
    $template->param(add_form => 1);
92
	my $data;
78
    #---- if primkey exists, it's a modify action, so read values to modify...
93
	if ($searchfield) {
79
    my $data;
94
		my $sth=$dbh->prepare("SELECT printername,printqueue,printtype from printers where printername=?");
80
    if ($searchfield) {
95
		$sth->execute($searchfield);
81
        $data=GetPrinterDetails($searchfield);
96
		$data=$sth->fetchrow_hashref;
82
    }
97
	}
83
98
84
    $template->param(
99
	$template->param(printqueue => $data->{'printqueue'},
85
        printqueue => $data->{'printqueue'},
100
			 printtype => $data->{'printtype'});
86
        printername => $data->{'printername'},
101
													# END $OP eq ADD_FORM
87
        printtype => $data->{'printtype'}
88
    );
89
# END $OP eq ADD_FORM
102
################## ADD_VALIDATE ##################################
90
################## ADD_VALIDATE ##################################
103
# called by add_form, used to insert/modify data in DB
91
# called by add_form, used to insert/modify data in DB
104
} elsif ($op eq 'add_validate') {
92
} elsif ($op eq 'add_validate') {
105
	$template->param(add_validate => 1);
93
    my $params = $input->Vars;
106
	if ($input->param('add')){
94
    if ($input->param('add')){
107
		my $sth=$dbh->prepare("INSERT INTO printers (printername,printqueue,printtype) VALUES (?,?,?)");
95
        AddPrinter($params);
108
		$sth->execute($input->param('printername'),$input->param('printqueue'),$input->param('printtype'));
96
    } else {
109
	} else {
97
        UpdatePrinter($searchfield, $params);
110
		my $sth=$dbh->prepare("UPDATE printers SET printqueue=?,printtype=? WHERE printername=?");
98
    }
111
		$sth->execute($input->param('printqueue'),$input->param('printtype'),$input->param('printername'));
99
    $template->param(add_validate => 1);
112
	}
100
    $searchfield = '';
113
													# END $OP eq ADD_VALIDATE
101
# END $OP eq ADD_VALIDATE
114
################## DELETE_CONFIRM ##################################
102
################## DELETE_CONFIRM ##################################
115
# called by default form, used to confirm deletion of data in DB
103
# called by default form, used to confirm deletion of data in DB
116
} elsif ($op eq 'delete_confirm') {
104
} elsif ($op eq 'delete_confirm') {
117
	$template->param(delete_confirm => 1);
105
    $list_printers = 0;
118
	my $sth=$dbh->prepare("select printername,printqueue,printtype from printers where printername=?");
106
    my $data=GetPrinterDetails($searchfield);
119
	$sth->execute($searchfield);
107
    my $branches = $data->{branches};
120
	my $data=$sth->fetchrow_hashref;
108
    if ($branches && $branches > 0) {
121
	$template->param(printqueue => $data->{'printqueue'},
109
        $template->param(cannot_delete_branches => $branches);
122
			 printtype  => $data->{'printtype'});
110
        $template->param(add_form => 1);
123
													# END $OP eq DELETE_CONFIRM
111
    } else {
112
        $template->param(delete_confirm => 1);
113
    }
114
    $template->param(
115
        printqueue => $data->{'printqueue'},
116
        printtype  => $data->{'printtype'},
117
    );
118
# END $OP eq DELETE_CONFIRM
124
################## DELETE_CONFIRMED ##################################
119
################## DELETE_CONFIRMED ##################################
125
# called by delete_confirm, used to effectively confirm deletion of data in DB
120
# called by delete_confirm, used to effectively confirm deletion of data in DB
126
} elsif ($op eq 'delete_confirmed') {
121
} elsif ($op eq 'delete_confirmed') {
127
	$template->param(delete_confirmed => 1);
122
    # XXX Delete can fail
128
	my $sth=$dbh->prepare("delete from printers where printername=?");
123
    DeletePrinter($searchfield);
129
	$sth->execute($searchfield);
124
    $template->param(delete_confirmed => 1);
130
													# END $OP eq DELETE_CONFIRMED
125
    $template->param(list_printers => 1);
126
    $searchfield = '';
127
# END $OP eq DELETE_CONFIRMED
131
################## DEFAULT ###########################################
128
################## DEFAULT ###########################################
132
} else { # DEFAULT
129
} else { # DEFAULT
133
	$template->param(else => 1);
130
    $searchfield ||= $input->param('description') || "";
134
	my ($count,$results)=StringSearch($searchfield,'web');
135
	my $max = ($offset+$pagesize < $count) ? $offset+$pagesize : $count;
136
	my @loop = (@$results)[$offset..$max];
137
	
138
	$template->param(loop => \@loop);
139
	
140
	if ($offset>0) {
141
		$template->param(offsetgtzero => 1,
142
				 prevpage => $offset-$pagesize);
143
	}
144
	if ($offset+$pagesize<$count) {
145
		$template->param(ltcount => 1,
146
				 nextpage => $offset+$pagesize);
147
	}
148
149
} #---- END $OP eq DEFAULT
131
} #---- END $OP eq DEFAULT
150
132
133
if ($list_printers) {
134
    $template->param(list_printers => 1);
135
    my $results=SearchPrinters($searchfield);
136
    my $count = $results ? scalar(@$results) : 0;
137
    my $max = ($offset+$pagesize < $count) ? $offset+$pagesize : $count;
138
    my @loop = (@$results)[$offset..$max-1];
139
140
    $template->param(loop => \@loop);
141
142
    if ($offset>0) {
143
        $template->param(offsetgtzero => 1,
144
                 prevpage => $offset-$pagesize);
145
    }
146
    if ($offset+$pagesize<$count) {
147
        $template->param(ltcount => 1,
148
                 nextpage => $offset+$pagesize);
149
    }
150
}
151
152
$template->param(
153
    searchfield => $searchfield,
154
    script_name => $script_name
155
);
156
151
output_html_with_http_headers $input, $cookie, $template->output;
157
output_html_with_http_headers $input, $cookie, $template->output;
152
158
(-)a/circ/circulation.pl (-10 / +1 lines)
Lines 31-37 use C4::Output; Link Here
31
use C4::Print;
31
use C4::Print;
32
use C4::Auth qw/:DEFAULT get_session haspermission/;
32
use C4::Auth qw/:DEFAULT get_session haspermission/;
33
use C4::Branch; # GetBranches
33
use C4::Branch; # GetBranches
34
use C4::Koha;   # GetPrinter
34
use C4::Koha;
35
use C4::Circulation;
35
use C4::Circulation;
36
use C4::Utils::DataTables::Members;
36
use C4::Utils::DataTables::Members;
37
use C4::Members;
37
use C4::Members;
Lines 73-84 if ($branch){ Link Here
73
    $session->param('branchname', GetBranchName($branch));
73
    $session->param('branchname', GetBranchName($branch));
74
}
74
}
75
75
76
my $printer = $query->param('printer');
77
if ($printer){
78
    # update our session so the userenv is updated
79
    $session->param('branchprinter', $printer);
80
}
81
82
if (!C4::Context->userenv && !$branch){
76
if (!C4::Context->userenv && !$branch){
83
    if ($session->param('branch') eq 'NO_LIBRARY_SET'){
77
    if ($session->param('branch') eq 'NO_LIBRARY_SET'){
84
        # no branch set we can't issue
78
        # no branch set we can't issue
Lines 153-159 my $findborrower = $query->param('findborrower') || q{}; Link Here
153
$findborrower =~ s|,| |g;
147
$findborrower =~ s|,| |g;
154
148
155
$branch  = C4::Context->userenv->{'branch'};  
149
$branch  = C4::Context->userenv->{'branch'};  
156
$printer = C4::Context->userenv->{'branchprinter'};
157
150
158
# If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
151
# If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
159
if (C4::Context->preference("AutoLocation") != 1) {
152
if (C4::Context->preference("AutoLocation") != 1) {
Lines 600-607 $template->param( Link Here
600
    categoryname      => $borrower->{'description'},
593
    categoryname      => $borrower->{'description'},
601
    branch            => $branch,
594
    branch            => $branch,
602
    branchname        => GetBranchName($borrower->{'branchcode'}),
595
    branchname        => GetBranchName($borrower->{'branchcode'}),
603
    printer           => $printer,
604
    printername       => $printer,
605
    was_renewed       => $query->param('was_renewed') ? 1 : 0,
596
    was_renewed       => $query->param('was_renewed') ? 1 : 0,
606
    expiry            => $borrower->{'dateexpiry'},
597
    expiry            => $borrower->{'dateexpiry'},
607
    roadtype          => $roadtype,
598
    roadtype          => $roadtype,
(-)a/circ/returns.pl (-12 / +1 lines)
Lines 39-45 use C4::Context; Link Here
39
use C4::Auth qw/:DEFAULT get_session/;
39
use C4::Auth qw/:DEFAULT get_session/;
40
use C4::Output;
40
use C4::Output;
41
use C4::Circulation;
41
use C4::Circulation;
42
use C4::Print;
43
use C4::Reserves;
42
use C4::Reserves;
44
use C4::Biblio;
43
use C4::Biblio;
45
use C4::Items;
44
use C4::Items;
Lines 83-98 if ( $query->param('print_slip') ) { Link Here
83
#####################
82
#####################
84
#Global vars
83
#Global vars
85
my $branches = GetBranches();
84
my $branches = GetBranches();
86
my $printers = GetPrinters();
87
my $userenv = C4::Context->userenv;
85
my $userenv = C4::Context->userenv;
88
my $userenv_branch = $userenv->{'branch'} // '';
86
my $userenv_branch = $userenv->{'branch'} // '';
89
my $printer = $userenv->{'branchprinter'} // '';
90
my $forgivemanualholdsexpire = $query->param('forgivemanualholdsexpire');
87
my $forgivemanualholdsexpire = $query->param('forgivemanualholdsexpire');
91
88
92
my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
89
my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
93
#
94
# Some code to handle the error if there is no branch or printer setting.....
95
#
96
90
97
# Set up the item stack ....
91
# Set up the item stack ....
98
my %returneditems;
92
my %returneditems;
Lines 600-618 foreach ( sort { $a <=> $b } keys %returneditems ) { Link Here
600
    }
594
    }
601
    push @riloop, \%ri;
595
    push @riloop, \%ri;
602
}
596
}
603
my ($genbrname, $genprname);
597
my $genbrname;
604
if (my $b = $branches->{$userenv_branch}) {
598
if (my $b = $branches->{$userenv_branch}) {
605
    $genbrname = $b->{'branchname'};
599
    $genbrname = $b->{'branchname'};
606
}
600
}
607
if (my $p = $printers->{$printer}) {
608
    $genprname = $p->{'printername'};
609
}
610
$template->param(
601
$template->param(
611
    riloop         => \@riloop,
602
    riloop         => \@riloop,
612
    genbrname      => $genbrname,
603
    genbrname      => $genbrname,
613
    genprname      => $genprname,
614
    branchname     => $genbrname,
604
    branchname     => $genbrname,
615
    printer        => $printer,
616
    errmsgloop     => \@errmsgloop,
605
    errmsgloop     => \@errmsgloop,
617
    exemptfine     => $exemptfine,
606
    exemptfine     => $exemptfine,
618
    dropboxmode    => $dropboxmode,
607
    dropboxmode    => $dropboxmode,
(-)a/circ/selectbranchprinter.pl (-21 / +28 lines)
Lines 23-32 use CGI qw ( -utf8 ); Link Here
23
23
24
use C4::Context;
24
use C4::Context;
25
use C4::Output;
25
use C4::Output;
26
use C4::Auth qw/:DEFAULT get_session/;
26
use C4::Auth qw/:DEFAULT get_session get_user_printer/;
27
use C4::Print;  # GetPrinters
28
use C4::Koha;
27
use C4::Koha;
29
use C4::Branch; # GetBranches GetBranchesLoop
28
use C4::Branch; # GetBranches GetBranchesLoop
29
use C4::Printer qw(GetPrinters);
30
30
31
# this will be the script that chooses branch and printer settings....
31
# this will be the script that chooses branch and printer settings....
32
32
Lines 56-64 my $userenv_printer = C4::Context->userenv->{'branchprinter'} || ''; Link Here
56
my @updated;
56
my @updated;
57
57
58
# $session lddines here are doing the updating
58
# $session lddines here are doing the updating
59
if ($branch and $branches->{$branch}) {
59
my $branch_rec = $branch ? $branches->{$branch} : undef;
60
if ($branch_rec) {
60
    if (! $userenv_branch or $userenv_branch ne $branch ) {
61
    if (! $userenv_branch or $userenv_branch ne $branch ) {
61
        my $branchname = GetBranchName($branch);
62
        my $branchname = $branch_rec->{branchname};
62
        $template->param(LoginBranchname => $branchname);   # update template for new branch
63
        $template->param(LoginBranchname => $branchname);   # update template for new branch
63
        $template->param(LoginBranchcode => $branch);       # update template for new branch
64
        $template->param(LoginBranchcode => $branch);       # update template for new branch
64
        $session->param('branchname', $branchname);         # update sesssion in DB
65
        $session->param('branchname', $branchname);         # update sesssion in DB
Lines 67-72 if ($branch and $branches->{$branch}) { Link Here
67
            updated_branch => 1,
68
            updated_branch => 1,
68
                old_branch => $userenv_branch,
69
                old_branch => $userenv_branch,
69
        };
70
        };
71
        $printer ||= $branch_rec->{branchprinter};
72
        undef $userenv_printer;
70
    } # else branch the same, no update
73
    } # else branch the same, no update
71
} else {
74
} else {
72
    $branch = $userenv_branch;  # fallback value
75
    $branch = $userenv_branch;  # fallback value
Lines 87-93 if ($printer) { Link Here
87
        };
90
        };
88
    } # else printer is the same, no update
91
    } # else printer is the same, no update
89
} else {
92
} else {
90
    $printer = $userenv_printer;  # fallback value
93
    $printer = get_user_printer();  # fallback value
91
}
94
}
92
95
93
$template->param(updated => \@updated) if (scalar @updated);
96
$template->param(updated => \@updated) if (scalar @updated);
Lines 96-116 unless ($branches->{$branch}) { Link Here
96
    $branch = (keys %$branches)[0];  # if branch didn't really exist, then replace it w/ one that does
99
    $branch = (keys %$branches)[0];  # if branch didn't really exist, then replace it w/ one that does
97
}
100
}
98
101
99
my @printkeys = sort keys %$printers;
100
if (scalar(@printkeys) == 1 or not $printers->{$printer}) {
101
    $printer = $printkeys[0];   # if printer didn't really exist, or there is only 1 anyway, then replace it w/ one that does
102
}
103
104
my @printerloop;
105
foreach ( @printkeys ) {
106
    next unless ($_); # skip printer if blank.
107
    push @printerloop, {
108
        selected => ( $_ eq $printer ),
109
        name     => $printers->{$_}->{'printername'},
110
        value    => $_,
111
    };
112
}
113
114
my @recycle_loop;
102
my @recycle_loop;
115
foreach ($query->param()) {
103
foreach ($query->param()) {
116
    $_ or next;                   # disclude blanks
104
    $_ or next;                   # disclude blanks
Lines 133-141 if (scalar @updated and not scalar @recycle_loop) { Link Here
133
121
134
$template->param(
122
$template->param(
135
    referer     => $referer,
123
    referer     => $referer,
136
    printerloop => \@printerloop,
137
    branchloop  => GetBranchesLoop($branch),
124
    branchloop  => GetBranchesLoop($branch),
138
    recycle_loop=> \@recycle_loop,
125
    recycle_loop=> \@recycle_loop,
139
);
126
);
140
127
128
if ( C4::Context->preference('UsePrintQueues') ) {
129
    my @printkeys = keys %$printers;
130
    if (scalar(@printkeys) == 1 or not $printers->{$printer}) {
131
        $printer = $printkeys[0];   # if printer didn't really exist, or there is only 1 anyway, then replace it w/ one that does
132
    }
133
134
    my @printerloop;
135
    foreach ( @printkeys ) {
136
        push @printerloop, {
137
            selected => ( $_ eq $printer ),
138
            name     => $printers->{$_}->{'printername'},
139
            value    => $_,
140
        };
141
    }
142
143
    $template->param(
144
        printerloop => \@printerloop,
145
    );
146
}
147
141
output_html_with_http_headers $query, $cookie, $template->output;
148
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/installer/data/mysql/atomicupdate/bug_8034_printer_queues.sql (+8 lines)
Line 0 Link Here
1
ALTER TABLE printers DROP PRIMARY KEY;
2
ALTER TABLE printers MODIFY printqueue varchar(20) NOT NULL PRIMARY KEY;
3
ALTER TABLE printers ADD UNIQUE (printername);
4
5
ALTER TABLE branches MODIFY branchprinter varchar(20) NULL;
6
ALTER TABLE branches ADD FOREIGN KEY (branchprinter) REFERENCES printers (printqueue) ON UPDATE CASCADE;
7
8
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UsePrintQueues','0',NULL,NULL,'YesNo');
(-)a/installer/data/mysql/kohastructure.sql (-9 / +11 lines)
Lines 413-422 CREATE TABLE `branches` ( -- information about your libraries or branches are st Link Here
413
  `branchurl` mediumtext, -- the URL for your library or branch's website
413
  `branchurl` mediumtext, -- the URL for your library or branch's website
414
  `issuing` tinyint(4) default NULL, -- unused in Koha
414
  `issuing` tinyint(4) default NULL, -- unused in Koha
415
  `branchip` varchar(15) default NULL, -- the IP address for your library or branch
415
  `branchip` varchar(15) default NULL, -- the IP address for your library or branch
416
  `branchprinter` varchar(100) default NULL, -- unused in Koha
416
  `branchprinter` varchar(20) default NULL,
417
  `branchnotes` mediumtext, -- notes related to your library or branch
417
  `branchnotes` mediumtext, -- notes related to your library or branch
418
  opac_info text, -- HTML that displays in OPAC
418
  opac_info text, -- HTML that displays in OPAC
419
  PRIMARY KEY (`branchcode`)
419
  PRIMARY KEY (`branchcode`),
420
  FOREIGN KEY (branchprinter) REFERENCES printers (printqueue) ON UPDATE CASCADE
420
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
421
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
421
422
422
--
423
--
Lines 1774-1786 CREATE TABLE pending_offline_operations ( Link Here
1774
-- Table structure for table `printers`
1775
-- Table structure for table `printers`
1775
--
1776
--
1776
1777
1777
DROP TABLE IF EXISTS `printers`;
1778
DROP TABLE IF EXISTS printers;
1778
CREATE TABLE `printers` (
1779
CREATE TABLE printers (
1779
  `printername` varchar(40) NOT NULL default '',
1780
  printername varchar(40) NOT NULL default '',
1780
  `printqueue` varchar(20) default NULL,
1781
  printqueue varchar(20) NOT NULL,
1781
  `printtype` varchar(20) default NULL,
1782
  printtype varchar(20) default NULL,
1782
  PRIMARY KEY  (`printername`)
1783
  PRIMARY KEY  (printqueue),
1783
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
1784
  UNIQUE (printername)
1785
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1784
1786
1785
--
1787
--
1786
-- Table structure for table `printers_profile`
1788
-- Table structure for table `printers_profile`
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 501-506 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
501
('useDischarge','','','Allows librarians to discharge borrowers and borrowers to request a discharge','YesNo'),
501
('useDischarge','','','Allows librarians to discharge borrowers and borrowers to request a discharge','YesNo'),
502
('UseICU','0','1','Tell Koha if ICU indexing is in use for Zebra or not.','YesNo'),
502
('UseICU','0','1','Tell Koha if ICU indexing is in use for Zebra or not.','YesNo'),
503
('UseKohaPlugins','0','','Enable or disable the ability to use Koha Plugins.','YesNo'),
503
('UseKohaPlugins','0','','Enable or disable the ability to use Koha Plugins.','YesNo'),
504
('UsePrintQueues','0',NULL,'Use printer queues','YesNo'),
504
('UseQueryParser','0',NULL,'If enabled, try to use QueryParser for queries.','YesNo'),
505
('UseQueryParser','0',NULL,'If enabled, try to use QueryParser for queries.','YesNo'),
505
('UseTransportCostMatrix','0','','Use Transport Cost Matrix when filling holds','YesNo'),
506
('UseTransportCostMatrix','0','','Use Transport Cost Matrix when filling holds','YesNo'),
506
('UseWYSIWYGinSystemPreferences','0','','Show WYSIWYG editor when editing certain HTML system preferences.','YesNo'),
507
('UseWYSIWYGinSystemPreferences','0','','Show WYSIWYG editor when editing certain HTML system preferences.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (-1 / +1 lines)
Lines 67-73 Link Here
67
<h5>Additional parameters</h5>
67
<h5>Additional parameters</h5>
68
68
69
<ul>
69
<ul>
70
    <!-- <li><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></li> -->
70
    [% IF UsePrintQueues %]<li><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></li>[% END %]
71
    <li><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></li>
71
    <li><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></li>
72
    <li><a href="/cgi-bin/koha/admin/didyoumean.pl">Did you mean?</a></li>
72
    <li><a href="/cgi-bin/koha/admin/didyoumean.pl">Did you mean?</a></li>
73
    <li><a href="/cgi-bin/koha/admin/columns_settings.pl">Columns settings</a></li>
73
    <li><a href="/cgi-bin/koha/admin/columns_settings.pl">Columns settings</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (+3 lines)
Lines 59-64 Link Here
59
                    [% END %]
59
                    [% END %]
60
                    </strong>
60
                    </strong>
61
                    [% END %]
61
                    [% END %]
62
                    [% IF UsePrintQueues && PrinterName %]
63
                    - [% PrinterName %]
64
                    [% END %]
62
                    <b class="caret"></b>
65
                    <b class="caret"></b>
63
                </a>
66
                </a>
64
                <ul class="dropdown-menu" role="menu" aria-labelledby="drop3">
67
                <ul class="dropdown-menu" role="menu" aria-labelledby="drop3">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (-2 / +4 lines)
Lines 100-107 Link Here
100
100
101
                <h3>Additional parameters</h3>
101
                <h3>Additional parameters</h3>
102
                <dl>
102
                <dl>
103
                    <!-- <dt><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></dt>
103
                [% IF UsePrintQueues %]
104
                    <dd>Printers (UNIX paths).</dd> -->
104
                    <dt><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></dt>
105
                    <dd>Printers (UNIX paths).</dd>
106
                [% END %]
105
                    <dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></dt>
107
                    <dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></dt>
106
                    <dd>Define which external servers to query for MARC data.</dd>
108
                    <dd>Define which external servers to query for MARC data.</dd>
107
                    <dt><a href="/cgi-bin/koha/admin/didyoumean.pl">Did you mean?</a></dt>
109
                    <dt><a href="/cgi-bin/koha/admin/didyoumean.pl">Did you mean?</a></dt>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-7 / +11 lines)
Lines 143-152 tinyMCE.init({ Link Here
143
        <li><label for="branchurl">URL: </label><input type="text" name="branchurl" id="branchurl"  size="80" value="[% branchurl |html %]" class="url" /></li>
143
        <li><label for="branchurl">URL: </label><input type="text" name="branchurl" id="branchurl"  size="80" value="[% branchurl |html %]" class="url" /></li>
144
        <li><label for="opac_info">OPAC info: </label><textarea name="opac_info" id="opac_info">[% opac_info |html %]</textarea></li>
144
        <li><label for="opac_info">OPAC info: </label><textarea name="opac_info" id="opac_info">[% opac_info |html %]</textarea></li>
145
        <li><label for="branchip">IP: </label><input type="text" name="branchip" id="branchip"  size="15" maxlength="15" value="[% branchip |html %]" /> <span class="hint">Can be entered as a single IP, or a subnet such as 192.168.1.*</span></li>
145
        <li><label for="branchip">IP: </label><input type="text" name="branchip" id="branchip"  size="15" maxlength="15" value="[% branchip |html %]" /> <span class="hint">Can be entered as a single IP, or a subnet such as 192.168.1.*</span></li>
146
		<!--
146
[% IF UsePrintQueues %]
147
        <li><label for="branchprinter">Library Printer: </label>
147
        <li><label for="branchprinter">Library Printer: </label>
148
            <select id="branchprinter" name="branchprinter">
148
            <select id="branchprinter" name="branchprinter">
149
                <option value="">None</option>
149
                <option value="">(None)</option>
150
            [% FOREACH printerloo IN printerloop %]
150
            [% FOREACH printerloo IN printerloop %]
151
                [% IF ( printerloo.selected ) %]
151
                [% IF ( printerloo.selected ) %]
152
				<option value="[% printerloo.value %]" selected="selected">[% printerloo.branchprinter %]</option>
152
				<option value="[% printerloo.value %]" selected="selected">[% printerloo.branchprinter %]</option>
Lines 155-161 tinyMCE.init({ Link Here
155
				[% END %]
155
				[% END %]
156
                [% END %]
156
                [% END %]
157
            </select></li>
157
            </select></li>
158
			-->
158
[% END %]
159
        <li><label for="branchnotes">Notes: </label><input type="text" name="branchnotes" id="branchnotes" size="80" value="[% branchnotes |html %]" /></li>
159
        <li><label for="branchnotes">Notes: </label><input type="text" name="branchnotes" id="branchnotes" size="80" value="[% branchnotes |html %]" /></li>
160
        </ol>
160
        </ol>
161
        </fieldset>
161
        </fieldset>
Lines 195-201 tinyMCE.init({ Link Here
195
            <th>Address</th>
195
            <th>Address</th>
196
            <th>Properties</th>
196
            <th>Properties</th>
197
            <th>IP</th>
197
            <th>IP</th>
198
            <!-- <th>Printer</th> -->
198
[% IF UsePrintQueues %]
199
            <th>Printer</th>
200
[% END %]
199
            <th>&nbsp;</th>
201
            <th>&nbsp;</th>
200
            <th>&nbsp;</th>
202
            <th>&nbsp;</th>
201
        </tr></thead><tbody>
203
        </tr></thead><tbody>
Lines 244-252 tinyMCE.init({ Link Here
244
                <td>
246
                <td>
245
                    [% branche.branchip %]
247
                    [% branche.branchip %]
246
                </td>
248
                </td>
247
                <!-- <td>
249
[% IF UsePrintQueues %]
248
                    [% branche.branchprinter %]
250
                <td>
249
                </td> -->
251
                    [% branche.branchprintername %]
252
                </td>
253
[% END %]
250
                <td>
254
                <td>
251
                    <a href="[% branche.action %]?op=edit&amp;branchcode=[% branche.value |url %]">Edit</a>
255
                    <a href="[% branche.action %]?op=edit&amp;branchcode=[% branche.value |url %]">Edit</a>
252
                </td>
256
                </td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 117-122 Circulation: Link Here
117
                  no: "Do not"
117
                  no: "Do not"
118
            - update a bibliographic record's total issues count whenever an item is issued (WARNING! This increases server load significantly; if performance is a concern, use the update_totalissues.pl cron job to update the total issues count).
118
            - update a bibliographic record's total issues count whenever an item is issued (WARNING! This increases server load significantly; if performance is a concern, use the update_totalissues.pl cron job to update the total issues count).
119
        -
119
        -
120
            - pref: UsePrintQueues
121
              choices:
122
                  yes: "Use"
123
                  no: "Don't use"
124
            - server print queues.
125
        -
120
            - Use the
126
            - Use the
121
            - pref: ExportWithCsvProfile
127
            - pref: ExportWithCsvProfile
122
            - CSV profile when exporting patron checkout history (enter CSV Profile name)
128
            - CSV profile when exporting patron checkout history (enter CSV Profile name)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/printers.tt (-26 / +14 lines)
Lines 4-10 Link Here
4
[% IF ( add_validate ) %] Printers &rsaquo; Printer added[% END %]
4
[% IF ( add_validate ) %] Printers &rsaquo; Printer added[% END %]
5
[% IF ( delete_confirm ) %] Printers &rsaquo; Confirm deletion of printer '[% searchfield %]'[% END %]
5
[% IF ( delete_confirm ) %] Printers &rsaquo; Confirm deletion of printer '[% searchfield %]'[% END %]
6
[% IF ( delete_confirmed ) %] Printers &rsaquo; Printer deleted[% END %]
6
[% IF ( delete_confirmed ) %] Printers &rsaquo; Printer deleted[% END %]
7
[% IF ( else ) %]Printers[% END %]</title>
7
[% IF ( list_printers ) %]Printers[% END %]</title>
8
[% INCLUDE 'doc-head-close.inc' %]
8
[% INCLUDE 'doc-head-close.inc' %]
9
[% IF ( add_form ) %]<script type="text/javascript">
9
[% IF ( add_form ) %]<script type="text/javascript">
10
//<![CDATA[
10
//<![CDATA[
Lines 58-64 Link Here
58
[% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Printer added[% END %]
58
[% IF ( add_validate ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Printer added[% END %]
59
[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Confirm deletion of printer '[% searchfield %]'[% END %]
59
[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Confirm deletion of printer '[% searchfield %]'[% END %]
60
[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Printer deleted[% END %]
60
[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/printers.pl">Printers</a> &rsaquo; Printer deleted[% END %]
61
[% IF ( else ) %]Printers[% END %]</div>
61
[% IF ( list_printers ) %]Printers[% END %]</div>
62
62
63
<div id="doc3" class="yui-t2">
63
<div id="doc3" class="yui-t2">
64
   
64
   
Lines 76-97 Link Here
76
        <form action="[% script_name %]" name="Aform" method="post">
76
        <form action="[% script_name %]" name="Aform" method="post">
77
        <input type="hidden" name="op" value="add_validate" />
77
        <input type="hidden" name="op" value="add_validate" />
78
	[% IF ( searchfield ) %]
78
	[% IF ( searchfield ) %]
79
          <input type="hidden" name="searchfield" value="[% searchfield %]" />
79
		<input type="hidden" name="add" value="0" />
80
		<input type="hidden" name="add" value="0" />
80
	[% ELSE %]
81
	[% ELSE %]
81
		<input type="hidden" name="add" value="1" />
82
		<input type="hidden" name="add" value="1" />
82
	[% END %]
83
	[% END %]
83
	<fieldset class="rows">
84
	<fieldset class="rows">
84
<ol>	[% IF ( searchfield ) %]
85
<ol>
85
		<li>
86
            <span class="label">Printer name: </span>
87
				<input type="hidden" name="printername" id="" value="[% searchfield %]" />[% searchfield %]
88
		</li>
89
	[% ELSE %]
90
		<li>
86
		<li>
91
            <label for="printername">Printer name: </label>
87
            <label for="printername">Printer name: </label>
92
				<input type="text" name="printername" id="printername" size="50" maxlength="50" />
88
                             <input type="text" name="printername" id="printername" size="50" maxlength="50" value="[% printername %]" />
93
		</li>
89
		</li>
94
	[% END %]
95
        	<li>
90
        	<li>
96
			<label for="printqueue">Queue: </label>
91
			<label for="printqueue">Queue: </label>
97
			<input type="text" name="printqueue" id="printqueue" size="50" maxlength="50" value="[% printqueue %]" /> 
92
			<input type="text" name="printqueue" id="printqueue" size="50" maxlength="50" value="[% printqueue %]" /> 
Lines 106-118 Link Here
106
101
107
[% END %]
102
[% END %]
108
103
109
[% IF ( add_validate ) %]
110
<h3>Printer added</h3>
111
<form action="[% script_name %]" method="post">
112
       <fieldset class="action"> <input type="submit" value="OK" /></fieldset>
113
</form>
114
[% END %]
115
116
[% IF ( delete_confirm ) %]
104
[% IF ( delete_confirm ) %]
117
<h3>Confirm deletion of printer <em>[% searchfield %]</em></h3>
105
<h3>Confirm deletion of printer <em>[% searchfield %]</em></h3>
118
<ul>
106
<ul>
Lines 138-151 Link Here
138
			</form>
126
			</form>
139
[% END %]
127
[% END %]
140
128
141
[% IF ( delete_confirmed ) %]
129
[% IF ( list_printers ) %]
142
<h3>Printer deleted</h3>
143
<form action="[% script_name %]" method="post">
144
		<fieldset class="action"><input type="submit" value="OK" /></fieldset>
145
</form>
146
[% END %]
147
148
[% IF ( else ) %]
149
130
150
<div id="toolbar" class="btn-toolbar">
131
<div id="toolbar" class="btn-toolbar">
151
    <a class="btn btn-small" id="newprinter" href="/cgi-bin/koha/admin/printers.pl?op=add_form"><i class="fa fa-plus"></i> New printer</a>
132
    <a class="btn btn-small" id="newprinter" href="/cgi-bin/koha/admin/printers.pl?op=add_form"><i class="fa fa-plus"></i> New printer</a>
Lines 168-174 Link Here
168
			<td>[% loo.printername %]</td>
149
			<td>[% loo.printername %]</td>
169
			<td>[% loo.printqueue %]</td>
150
			<td>[% loo.printqueue %]</td>
170
			<td>[% loo.printtype %]</td>
151
			<td>[% loo.printtype %]</td>
171
			<td><a href="[% loo.script_name %]?op=add_form&amp;searchfield=[% loo.printername %]">Edit</a> <a href="[% loo.script_name %]?op=delete_confirm&amp;searchfield=[% loo.printername %]">Delete</a></td>
152
                     <td>
153
                         <a href="[% loo.script_name %]?op=add_form&amp;searchfield=[% loo.printqueue %]">Edit</a>
154
                     [% IF loo.branches %]
155
                         Default printer for [% loo.branches %] branch(es)
156
                     [% ELSE %]
157
                         <a href="[% loo.script_name %]?op=delete_confirm&amp;searchfield=[% loo.printqueue %]">Delete</a>
158
                     [% END %]
159
                     </td>
172
		</tr>
160
		</tr>
173
		[% END %]
161
		[% END %]
174
	</table>[% ELSE %]<div class="notice">No printers defined.</div>[% END %]
162
	</table>[% ELSE %]<div class="notice">No printers defined.</div>[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-2 lines)
Lines 559-565 No patron matched <span class="ex">[% message %]</span> Link Here
559
559
560
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
560
[% IF (forceallow) %]<input type="hidden" name="forceallow" value="1">[% END %]
561
    <input type="hidden" name="branch" value="[% branch %]" />
561
    <input type="hidden" name="branch" value="[% branch %]" />
562
    <input type="hidden" name="printer" value="[% printer %]" />
563
    <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
562
    <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
564
    <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
563
    <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
565
564
Lines 678-684 No patron matched <span class="ex">[% message %]</span> Link Here
678
677
679
          <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
678
          <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
680
          <input type="hidden" name="branch" value="[% branch %]" />
679
          <input type="hidden" name="branch" value="[% branch %]" />
681
          <input type="hidden" name="printer" value="[% printer %]" />
682
          <input type="hidden" name="print" value="maybe" />
680
          <input type="hidden" name="print" value="maybe" />
683
          <input type="hidden" name="debt_confirmed" value="[% debt_confirmed %]" />
681
          <input type="hidden" name="debt_confirmed" value="[% debt_confirmed %]" />
684
                [% IF ( CHARGES ) %]
682
                [% IF ( CHARGES ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/selectbranchprinter.tt (-3 / +2 lines)
Lines 28-34 Updated:<ul> Link Here
28
    [% IF ( update.updated_branch ) %]
28
    [% IF ( update.updated_branch ) %]
29
        <li>Library: [% update.old_branch or "?" %] &rArr; [% update.LoginBranchcode or "?" %]</li>
29
        <li>Library: [% update.old_branch or "?" %] &rArr; [% update.LoginBranchcode or "?" %]</li>
30
    [% ELSIF ( update.updated_printer ) %]
30
    [% ELSIF ( update.updated_printer ) %]
31
      <!-- FIXME:  <li>Printer: [% update.old_printer or "?" %] &rArr; [% update.new_printer or "?" %]</li> -->
31
        <li>Printer: [% update.old_printer or "?" %] &rArr; [% update.new_printer or "?" %]</li>
32
    [% ELSE %]
32
    [% ELSE %]
33
        <li>ERROR - unknown</li>
33
        <li>ERROR - unknown</li>
34
    [% END %]
34
    [% END %]
Lines 63-69 Updated:<ul> Link Here
63
        [% END %]
63
        [% END %]
64
        </select></li>
64
        </select></li>
65
    [% END %]
65
    [% END %]
66
<!--
67
    [% IF ( printerloop ) %]
66
    [% IF ( printerloop ) %]
68
        <li><label for="printer">Choose a network printer:</label>
67
        <li><label for="printer">Choose a network printer:</label>
69
        <select name="printer" id="printer">
68
        <select name="printer" id="printer">
Lines 75-81 Updated:<ul> Link Here
75
                [% END %]
74
                [% END %]
76
            [% END %]
75
            [% END %]
77
        </select></li>
76
        </select></li>
78
    [% END %] -->
77
    [% END %]
79
    </ol>
78
    </ol>
80
</fieldset>
79
</fieldset>
81
<fieldset class="action">
80
<fieldset class="action">
(-)a/t/db_dependent/Printer.t (-1 / +62 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Koha::Database;
4
use Data::Dumper;
5
6
use Test::More tests => 7;
7
8
my $TEST_PRINTER_QUEUE = "TEST_PRINTER_QUEUE";
9
my %TEST_PRINTER = (
10
    printqueue => $TEST_PRINTER_QUEUE,
11
    printername => "Test printer",
12
    printtype => "Some string",
13
);
14
my $UPDATED_NAME = "Updated Test printer";
15
16
use_ok("C4::Printer");
17
18
my $schema = Koha::Database->new()->schema();
19
$schema->storage->txn_begin();
20
21
C4::Printer::AddPrinter(\%TEST_PRINTER);
22
pass("AddPrinter");
23
24
C4::Printer::UpdatePrinter($TEST_PRINTER_QUEUE, {%TEST_PRINTER, printername => $UPDATED_NAME});
25
26
my $p = C4::Printer::GetPrinterDetails($TEST_PRINTER_QUEUE);
27
my $found = $p && $p->{printqueue} eq $TEST_PRINTER_QUEUE;
28
ok($found, "GetPrinterDetails") or diag(Dumper($p));
29
30
SKIP: {
31
    skip 1, "Cannot find printer" unless $found;
32
33
    is($p->{printername}, $UPDATED_NAME, "UpdatePrinter")
34
      or diag(Dumper($p));
35
}
36
37
my $printers = C4::Printer::GetPrinters();
38
$found = 0;
39
while (my ($q, $p) = each %$printers) {
40
    if ($q eq $TEST_PRINTER_QUEUE) {
41
        $found = $p->{printername} eq $UPDATED_NAME;
42
        last;
43
    }
44
}
45
ok($found, "GetPrinters") or diag(Dumper($printers));
46
47
$printers = C4::Printer::SearchPrinters("TEST");
48
$found = 0;
49
foreach $p (@$printers) {
50
    if ($p->{printqueue} eq $TEST_PRINTER_QUEUE) {
51
        $found = $p->{printername} eq $UPDATED_NAME;
52
        last;
53
    }
54
}
55
ok($found, "SearchPrinters") or diag(Dumper($printers));
56
57
C4::Printer::DeletePrinter($TEST_PRINTER_QUEUE);
58
$p = C4::Printer::GetPrinterDetails($TEST_PRINTER_QUEUE);
59
$found = $p && $p->{printqueue} eq $TEST_PRINTER_QUEUE;
60
ok(!$found, "DeletePrinter") or diag(Dumper($p));
61
62
$schema->storage->txn_rollback();

Return to bug 8034