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
32 use PDF::API2::PDF::Utils;
33 use C4::Interface::CGI::Output;
35 # This function returns the path to deal with the correct files, considering
36 # templates set and language.
39 my $templatesSet = C4::Context->preference('template');
40 my $lang = C4::Context->preference('opaclanguages');
41 if ($type eq "intranet") {
42 return "$ENV{'DOCUMENT_ROOT'}/intranet-tmpl/$templatesSet/$lang";
44 return "$ENV{'DOCUMENT_ROOT'}/opac-tmpl/$templatesSet/$lang";
48 # Load a configuration file.
49 sub loadConfFromFile {
50 my $fileName = shift @_;
52 open FILE, "<$fileName";
55 if (/\s*([\w_]*)\s*=\s*([\[\]\<\>\w_\s:@,\.-]*)\s*/) {
63 # Save settings to a configuration file.
65 my $fileName = shift @_;
66 my %keyValues = %{shift @_};
68 open FILE, ">$fileName";
70 foreach $i (keys(%keyValues)) {
71 print FILE $i." = ".$keyValues{$i}."\n";
76 # Creates a CGI object and take his parameters
79 if ($input->param('saveSettings')) {
80 my $labelConf = &getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
81 my %newConfiguration = (pageType => $input->param('pageType'),
82 columns => $input->param('columns'),
83 rows => $input->param('rows'),
84 systemDpi => $input->param('systemDpi'),
85 labelWidth => $input->param('labelWidth'),
86 labelHeigth => $input->param('labelHeigth'),
87 marginBottom => $input->param('marginBottom'),
88 marginLeft => $input->param('marginLeft'));
89 saveConfToFile($labelConf, \%newConfiguration);
90 print $input->redirect('/cgi-bin/koha/barcodes/barcodes.pl')
93 # Get the template to use
94 my ($template, $loggedinuser, $cookie)
95 = get_template_and_user({template_name => "tools/printerConfig.tmpl",
99 flagsrequired => {parameters => 1},
103 my $filenameConf = &getPath("intranet")."/includes/labelConfig/itemsLabelConfig.conf";
104 my %labelConfig = &loadConfFromFile($filenameConf);
106 $template->param(COLUMNS => $labelConfig{'columns'});
107 $template->param(ROWS => $labelConfig{'rows'});
108 $template->param(SYSTEM_DPI => $labelConfig{'systemDpi'});
109 $template->param(LABEL_WIDTH => $labelConfig{'labelWidth'});
110 $template->param(LABEL_HEIGTH => $labelConfig{'labelHeigth'});
111 $template->param(MARGIN_TOP => $labelConfig{'marginBottom'});
112 $template->param(MARGIN_LEFT => $labelConfig{'marginLeft'});
113 $template->param(SCRIPT_NAME => '/cgi-bin/koha/tools/printerConfig.pl');
114 $template->param("$labelConfig{'pageType'}" => 1);
115 output_html_with_http_headers $input, $cookie, $template->output;