Added offline circ sqlite database generator.
[koha.git] / labels / label-edit-profile.pl
blob4643b1c9b2ada1d57b7ba914cf0844254fd2785a
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 my $DEBUG = 0;
13 my $dbh = C4::Context->dbh;
14 my $query = new CGI;
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');
24 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
26 template_name => "labels/label-edit-profile.tmpl",
27 query => $query,
28 type => "intranet",
29 authnotrequired => 1,
30 flagsrequired => { catalogue => 1 },
31 debug => 1,
35 if ($op eq '' || undef) {
36 my $prof = GetSinglePrinterProfile($prof_id);
38 my $tmpl = GetSingleLabelTemplate($prof->{'tmpl_id'});
40 if ( $DEBUG ) {
41 use Data::Dumper;
42 warn Dumper($prof);
43 warn Dumper($tmpl);
46 my @units = (
47 { unit => 'INCH', desc => 'Inches' },
48 { unit => 'CM', desc => 'Centimeters' },
49 { unit => 'MM', desc => 'Millimeters' },
50 { unit => 'POINT', desc => 'Postscript Points' },
53 foreach my $unit (@units) {
54 if ( $unit->{'unit'} eq $prof->{'unit'} ) {
55 $unit->{'selected'} = 1;
59 $template->param(
61 units => \@units,
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'},
75 elsif ($op eq 'Save') {
76 warn "Units are now $units";
78 SaveProfile( $prof_id, $offset_horz, $offset_vert, $creep_horz, $creep_vert, $units );
79 print $query->redirect("./label-profiles.pl");
80 exit;
83 elsif ($op eq 'Cancel') {
84 print $query->redirect("./label-profiles.pl");
85 exit;
88 output_html_with_http_headers $query, $cookie, $template->output;