3 # script to set the labels configuration for the printer process.
5 # by Veleda Matias - matias_veleda@hotmail.com - Physics Library UNLP Argentina and
7 # This file is part of Koha.
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
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.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
34 use C4::Interface::CGI::Output;
36 # This function returns the path to deal with the correct files, considering
37 # templates set and language.
40 my $templatesSet = C4::Context->preference('template');
41 my $lang = C4::Context->preference('opaclanguages');
42 if ( $type eq "intranet" ) {
43 return "$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
46 return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
50 # Load a configuration file.
51 sub loadConfFromFile {
52 my $fileName = shift @_;
54 open FILE, "<$fileName";
57 if (/\s*([\w_]*)\s*=\s*([\[\]\<\>\w_\s:@,\.-]*)\s*/) {
65 # Save settings to a configuration file.
67 my $fileName = shift @_;
68 my %keyValues = %{ shift @_ };
70 open FILE, ">$fileName";
72 foreach $i ( keys(%keyValues) ) {
73 print FILE $i . " = " . $keyValues{$i} . "\n";
78 # Creates a CGI object and take his parameters
81 if ( $input->param('saveSettings') ) {
83 &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
84 my %newConfiguration = (
85 pageType => $input->param('pageType'),
86 columns => $input->param('columns'),
87 rows => $input->param('rows'),
88 systemDpi => $input->param('systemDpi'),
89 labelWidth => $input->param('labelWidth'),
90 labelHeigth => $input->param('labelHeigth'),
91 marginBottom => $input->param('marginBottom'),
92 marginLeft => $input->param('marginLeft')
94 saveConfToFile( $labelConf, \%newConfiguration );
95 print $input->redirect('/cgi-bin/koha/barcodes/barcodes.pl');
98 # Get the template to use
99 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
101 template_name => "barcodes/printerConfig.tmpl",
104 authnotrequired => 0,
105 flagsrequired => { tools => 1 },
111 &getPath("intranet") . "/includes/labelConfig/itemsLabelConfig.conf";
112 my %labelConfig = &loadConfFromFile($filenameConf);
114 $template->param( COLUMNS => $labelConfig{'columns'} );
115 $template->param( ROWS => $labelConfig{'rows'} );
116 $template->param( SYSTEM_DPI => $labelConfig{'systemDpi'} );
117 $template->param( LABEL_WIDTH => $labelConfig{'labelWidth'} );
118 $template->param( LABEL_HEIGTH => $labelConfig{'labelHeigth'} );
119 $template->param( MARGIN_TOP => $labelConfig{'marginBottom'} );
120 $template->param( MARGIN_LEFT => $labelConfig{'marginLeft'} );
121 $template->param( SCRIPT_NAME => '/cgi-bin/koha/barcodes/printerConfig.pl' );
122 $template->param( "$labelConfig{'pageType'}" => 1 );
124 intranetcolorstylesheet =>
125 C4::Context->preference("intranetcolorstylesheet"),
126 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
127 IntranetNav => C4::Context->preference("IntranetNav"),
129 output_html_with_http_headers $input, $cookie, $template->output;