Work on adding patron search to patron card generation feature.
[koha.git] / labels / label-create-template.pl
1 #!/usr/bin/perl
2
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;
11
12 #use Data::Dumper;
13 #use Smart::Comments;
14
15 my $dbh   = C4::Context->dbh;
16 my $query = new CGI;
17 ### $query
18
19 my $tmpl_code    = $query->param('tmpl_code');
20 my $tmpl_desc    = $query->param('tmpl_desc');
21 my $page_height  = $query->param('page_height');
22 my $page_width   = $query->param('page_width');
23 my $label_height = $query->param('label_height');
24 my $label_width  = $query->param('label_width');
25 my $topmargin    = $query->param('topmargin');
26 my $leftmargin   = $query->param('leftmargin');
27 my $cols         = $query->param('cols');
28 my $rows         = $query->param('rows');
29 my $colgap       = $query->param('colgap');
30 my $rowgap       = $query->param('rowgap');
31 my $units        = $query->param('units');
32 my $font         = $query->param('fonts');
33 my $fontsize     = $query->param('fontsize');
34
35 my $batch_id     = $query->param('batch_id');
36
37
38 my $op = $query->param('op');
39 my @resultsloop;
40
41 my ( $template, $loggedinuser, $cookie );
42
43 if ( $op eq 'blank' ) {
44
45     my @units = (
46         { unit => 'INCH',  desc => 'Inches' },
47         { unit => 'CM',    desc => 'Centimeters' },
48         { unit => 'MM',    desc => 'Millimeters' },
49         { unit => 'POINT', desc => 'Postscript Points' },
50     );
51
52     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...
53         { font => 'TR',     name => 'Times Roman' },
54         { font => 'TB',     name => 'Times Bold' },
55         { font => 'TI',     name => 'Times Italic' },
56         { font => 'TBI',    name => 'Times Bold Italic' },
57         { font => 'C',      name => 'Courier' },
58         { font => 'CB',     name => 'Courier Bold' },
59         { font => 'CO',     name => 'Courier Oblique' },
60         { font => 'CBO',    name => 'Courier Bold Oblique' },
61         { font => 'H',      name => 'Helvetica' },
62         { font => 'HB',     name => 'Helvetica Bold' },
63         { font => 'HO',     name => 'Helvetica Oblique' },
64         { font => 'HBO',    name => 'Helvetica Bold Oblique' },
65     );
66
67     ( $template, $loggedinuser, $cookie ) = get_template_and_user(
68         {
69             template_name   => "labels/label-create-template.tmpl",
70             query           => $query,
71             type            => "intranet",
72             authnotrequired => 1,
73             flagsrequired   => { catalogue => 1 },
74             debug           => 1,
75         }
76     );
77
78     $template->param(
79         units   => \@units,
80         fonts   => \@fonts,
81     );
82
83 }
84
85 elsif ( $op eq 'Create' ) {
86     CreateTemplate(
87
88         $tmpl_code,   $tmpl_desc,   $page_width,
89         $page_height, $label_width, $label_height, $topmargin,
90         $leftmargin,  $cols,        $rows,         $colgap,
91         $rowgap,      $font,        $fontsize,     $units );
92
93  print $query->redirect("./label-templates.pl");
94 exit;
95
96 }
97
98 elsif ( $op eq 'Cancel' ) {
99     print $query->redirect("./label-home.pl");
100     exit;
101 }
102
103 output_html_with_http_headers $query, $cookie, $template->output;