Added issue date column to issues list
[koha.git] / labels / label-create-profile.pl
blobf2eb49a89a8015884d4835c7d68c296882669cd3
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;
13 #use Smart::Comments;
15 my $dbh = C4::Context->dbh;
16 my $query = new CGI;
17 ### $query
19 my $op = $query->param('op');
21 my $prof_id = $query->param('prof_id');
22 my $printername = $query->param('printername');
23 my $paper_bin = $query->param('paper_bin');
24 my $tmpl_id = $query->param('tmpl_id');
25 my $offset_horz = $query->param('offset_horz');
26 my $offset_vert = $query->param('offset_vert');
27 my $creep_horz = $query->param('creep_horz');
28 my $creep_vert = $query->param('creep_vert');
29 my $units = $query->param('unit');
31 my @resultsloop;
32 my @tmpllist;
34 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
36 template_name => "labels/label-create-profile.tmpl",
37 query => $query,
38 type => "intranet",
39 authnotrequired => 1,
40 flagsrequired => { catalogue => 1 },
41 debug => 1,
45 if ( $op eq 'blank' || $op eq '' ) {
47 my @units = (
48 { unit => 'INCH', desc => 'Inches' },
49 { unit => 'CM', desc => 'Centimeters' },
50 { unit => 'MM', desc => 'Millimeters' },
51 { unit => 'POINT', desc => 'Postscript Points' },
54 my @tmpl = GetAllLabelTemplates();
56 foreach my $data (@tmpl) {
57 push ( @tmpllist, {tmpl_id => $data->{'tmpl_id'},
58 tmpl_code => $data->{'tmpl_code'}} );
61 $template->param(
62 tmpllist => \@tmpllist,
63 unit => \@units,
68 elsif ( $op eq 'Save' ) {
69 my $errmsg;
70 my $dberror = CreateProfile(
71 $prof_id, $printername, $paper_bin, $tmpl_id, $offset_horz,
72 $offset_vert, $creep_horz, $creep_vert, $units
74 unless ( $dberror ) {
75 print $query->redirect("./label-profiles.pl");
76 exit;
79 # FIXME: This exposes all CGI vars. Surely there is a better way to do it? -fbcit
80 if ( $dberror =~ /Duplicate/ && $dberror =~ /$paper_bin/ ) {
81 $errmsg = "You cannot create duplicate profiles for $printername/$paper_bin.
82 Click the Back button on your browser and enter a different paper bin
83 for $printername.";
86 else {
87 $errmsg = $dberror;
90 $template->param (
91 dberror => $dberror,
92 errmsg => $errmsg,
95 warn "DB error: $dberror";
98 elsif ( $op eq 'Cancel' ) {
99 print $query->redirect("./label-profiles.pl");
100 exit;
103 output_html_with_http_headers $query, $cookie, $template->output;