Added offline circ sqlite database generator.
[koha.git] / labels / label-edit-template.pl
blob47b6bd724600b348a750c18bb4b4e1b63e8d61b4
1 #!/usr/bin/perl
3 use strict;
4 use CGI;
5 use C4::Auth;
6 use C4::Context;
7 use C4::Output;
8 use C4::Labels;
9 use HTML::Template::Pro;
10 use POSIX;
12 # use Data::Dumper;
14 my $dbh = C4::Context->dbh;
15 my $query = new CGI;
17 my $tmpl_id = $query->param('tmpl_id');
19 my $width = $query->param('width');
20 my $height = $query->param('height');
21 my $topmargin = $query->param('topmargin');
22 my $leftmargin = $query->param('leftmargin');
23 my $columns = $query->param('columns');
24 my $rows = $query->param('rows');
25 my $colgap = $query->param('colgap');
26 my $rowgap = $query->param('rowgap');
27 my $prof_id = $query->param('prof_id');
29 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31 template_name => "labels/label-edit-template.tmpl",
32 query => $query,
33 type => "intranet",
34 authnotrequired => 1,
35 flagsrequired => { catalogue => 1 },
36 debug => 1,
40 my $tmpl = GetSingleLabelTemplate($tmpl_id);
41 my $curprof = GetAssociatedProfile($tmpl_id);
42 my @prof = GetAllPrinterProfiles();
43 my @proflist;
45 # Generate an array of hashes containing possible profiles for given template and mark the currently associated one...
47 foreach my $prof (@prof) {
48 if ( $prof->{'tmpl_id'} eq $tmpl->{'tmpl_id'} && $prof->{'prof_id'} eq $curprof->{'prof_id'} ) {
49 push ( @proflist, {prof_id => $prof->{'prof_id'},
50 printername => $prof->{'printername'},
51 paper_bin => $prof->{'paper_bin'},
52 selected => 1} );
55 elsif ( $prof->{'tmpl_id'} eq $tmpl->{'tmpl_id'} ) {
56 push ( @proflist, {prof_id => $prof->{'prof_id'},
57 printername => $prof->{'printername'},
58 paper_bin => $prof->{'paper_bin'}} );
61 elsif ( !$prof ) {
62 undef @proflist;
66 my @units = (
67 { unit => 'INCH', desc => 'Inches' },
68 { unit => 'CM', desc => 'Centimeters' },
69 { unit => 'MM', desc => 'Millimeters' },
70 { unit => 'POINT', desc => 'Postscript Points' },
73 foreach my $unit (@units) {
74 if ( $unit->{'unit'} eq $tmpl->{'units'} ) {
75 $unit->{'selected'} = 1;
79 my @fonts = ( #FIXME: There is probably a way to discover what additional fonts are installed on a user's system and generate this list dynamically...
80 { font => 'TR', name => 'Times Roman' },
81 { font => 'TB', name => 'Times Bold' },
82 { font => 'TI', name => 'Times Italic' },
83 { font => 'TBI', name => 'Times Bold Italic' },
84 { font => 'C', name => 'Courier' },
85 { font => 'CB', name => 'Courier Bold' },
86 { font => 'CO', name => 'Courier Oblique' },
87 { font => 'CBO', name => 'Courier Bold Oblique' },
88 { font => 'H', name => 'Helvetica' },
89 { font => 'HB', name => 'Helvetica Bold' },
90 { font => 'HO', name => 'Helvetica Oblique' },
91 { font => 'HBO', name => 'Helvetica Bold Oblique' },
94 foreach my $font (@fonts) {
95 if ( $font->{'font'} eq $tmpl->{'font'} ) {
96 $font->{'selected'} = 1;
100 $template->param(
102 proflist => \@proflist,
103 units => \@units,
104 fonts => \@fonts,
106 tmpl_id => $tmpl->{'tmpl_id'},
107 tmpl_code => $tmpl->{'tmpl_code'},
108 tmpl_desc => $tmpl->{'tmpl_desc'},
109 page_width => $tmpl->{'page_width'},
110 page_height => $tmpl->{'page_height'},
111 label_width => $tmpl->{'label_width'},
112 label_height => $tmpl->{'label_height'},
113 topmargin => $tmpl->{'topmargin'},
114 leftmargin => $tmpl->{'leftmargin'},
115 cols => $tmpl->{'cols'},
116 rows => $tmpl->{'rows'},
117 colgap => $tmpl->{'colgap'},
118 rowgap => $tmpl->{'rowgap'},
119 fontsize => $tmpl->{'fontsize'},
120 active => $tmpl->{'active'},
123 output_html_with_http_headers $query, $cookie, $template->output;