porting sort_by stuff from staff to opac
[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;
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 $fontsize     = $query->param('fontsize');
33
34 my $batch_id     = $query->param('batch_id');
35
36
37 my $op = $query->param('op');
38 my @resultsloop;
39
40 my ( $template, $loggedinuser, $cookie );
41
42 if ( $op eq 'blank' ) {
43
44     my @units = (
45         { unit => 'INCH',  desc => 'Inches' },
46         { unit => 'CM',    desc => 'Centimeters' },
47         { unit => 'MM',    desc => 'Millimeters' },
48         { unit => 'POINT', desc => 'Postscript Points' },
49     );
50
51     ( $template, $loggedinuser, $cookie ) = get_template_and_user(
52         {
53             template_name   => "labels/label-create-template.tmpl",
54             query           => $query,
55             type            => "intranet",
56             authnotrequired => 1,
57             flagsrequired   => { catalogue => 1 },
58             debug           => 1,
59         }
60     );
61
62     $template->param(
63         units                   => \@units,
64     );
65
66 }
67
68 elsif ( $op eq 'create' ) {
69     CreateTemplate(
70
71         $tmpl_code, $tmpl_desc, $page_width,
72         $page_height, $label_width, $label_height, $topmargin,
73         $leftmargin,  $cols,        $rows,         $colgap,
74         $rowgap,      $fontsize,     $units );
75
76  print $query->redirect("./label-templates.pl");
77 exit;
78
79 }
80
81 output_html_with_http_headers $query, $cookie, $template->output;