Add a new Debian package and GoogleJacket on OPAC detail page
[koha.git] / labels / label-edit-profile.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 my $DEBUG = 0;
13 my $dbh       = C4::Context->dbh;
14 my $query     = new CGI;
15
16 my $op          = $query->param('op');
17 my $prof_id     = $query->param('prof_id');
18 my $offset_horz = $query->param('offset_horz');
19 my $offset_vert = $query->param('offset_vert');
20 my $creep_horz  = $query->param('creep_horz');
21 my $creep_vert  = $query->param('creep_vert');
22 my $units       = $query->param('unit');
23
24 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
25     {
26         template_name   => "labels/label-edit-profile.tmpl",
27         query           => $query,
28         type            => "intranet",
29         authnotrequired => 1,
30         flagsrequired   => { catalogue => 1 },
31         debug           => 1,
32     }
33 );
34
35 if ($op eq '' || undef) {
36     my $prof = GetSinglePrinterProfile($prof_id);
37
38     my $tmpl = GetSingleLabelTemplate($prof->{'tmpl_id'});
39
40     if ( $DEBUG ) {
41         use Data::Dumper;
42         warn Dumper($prof);
43         warn Dumper($tmpl);
44     }       
45
46     my @units = (
47         { unit => 'INCH',  desc => 'Inches' },
48         { unit => 'CM',    desc => 'Centimeters' },
49         { unit => 'MM',    desc => 'Millimeters' },
50         { unit => 'POINT', desc => 'Postscript Points' },
51     );
52
53     foreach my $unit (@units) {
54         if ( $unit->{'unit'} eq $prof->{'unit'} ) {
55             $unit->{'selected'} = 1;
56         }
57     }
58
59     $template->param(
60
61         units => \@units,
62
63         prof_id      => $prof->{'prof_id'},
64         printername  => $prof->{'printername'},
65         paper_bin    => $prof->{'paper_bin'},
66         tmpl_code    => $tmpl->{'tmpl_code'},
67         prof_code    => $prof->{'prof_code'},
68         offset_horz  => $prof->{'offset_horz'},
69         offset_vert  => $prof->{'offset_vert'},
70         creep_horz   => $prof->{'creep_horz'},
71         creep_vert   => $prof->{'creep_vert'},
72     );
73 }
74
75 elsif ($op eq 'Save') {
76     warn "Units are now $units";
77
78     SaveProfile( $prof_id,   $offset_horz,   $offset_vert,   $creep_horz,    $creep_vert,    $units );
79     print $query->redirect("./label-profiles.pl");
80     exit;
81 }
82
83 elsif ($op eq 'Cancel') {
84     print $query->redirect("./label-profiles.pl");
85     exit;
86 }
87
88 output_html_with_http_headers $query, $cookie, $template->output;