systempreferences - remove dateformat from admin tab
[koha.git] / labels / label-manager.pl
blob5e53ab6b8211ea57bcfa527a4f8f477a6ce81c01
1 #!/usr/bin/perl
3 use strict;
4 use CGI;
5 use C4::Auth;
6 use C4::Labels;
7 use C4::Output;
8 use HTML::Template::Pro;
9 use POSIX;
11 #use Data::Dumper;
12 #use Smart::Comments;
14 my $dbh = C4::Context->dbh;
15 my $query = new CGI;
16 my $op = $query->param('op');
17 my $layout_id = $query->param('layout_id');
18 my $layoutname = $query->param('layoutname');
19 my $barcodetype = $query->param('barcodetype');
20 my $bcn = $query->param('tx_barcode');
21 my $title = $query->param('tx_title');
22 my $subtitle = $query->param('tx_subtitle');
23 my $isbn = $query->param('tx_isbn');
24 my $issn = $query->param('tx_issn');
25 my $itemtype = $query->param('tx_itemtype');
26 my $dcn = $query->param('tx_dewey');
27 my $classif = $query->param('tx_classif');
28 my $itemcallnumber = $query->param('tx_itemcallnumber');
29 my $subclass = $query->param('tx_subclass');
30 my $author = $query->param('tx_author');
31 my $tmpl_id = $query->param('tmpl_id');
32 my $summary = $query->param('summary');
33 my $startlabel = $query->param('startlabel');
34 my $printingtype = $query->param('printingtype');
35 my $guidebox = $query->param('guidebox');
36 my $fontsize = $query->param('fontsize');
37 my @itemnumber = $query->param('itemnumber');
40 # little block for displaying active layout/template/batch in templates
41 # ----------
42 my $batch_id = $query->param('batch_id');
43 my $active_layout = get_active_layout();
44 my $active_template = GetActiveLabelTemplate();
45 my $active_layout_name = $active_layout->{'layoutname'};
46 my $active_template_name = $active_template->{'tmpl_code'};
47 # ----------
49 #if (!$batch_id ) {
50 # $batch_id = get_highest_batch();
53 my ($itemnumber) = @itemnumber if (scalar(@itemnumber) == 1);
55 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
57 template_name => "labels/label-manager.tmpl",
58 query => $query,
59 type => "intranet",
60 authnotrequired => 1,
61 flagsrequired => { catalogue => 1 },
62 debug => 1,
66 if ( $op eq 'save_conf' ) { # this early sub is depreciated, use save_layout()
68 SaveConf(
69 $barcodetype, $title, $isbn,
70 $issn, $itemtype, $bcn, $dcn,
71 $classif, $subclass, $itemcallnumber, $author,
72 $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname
74 print $query->redirect("label-home.pl");
75 exit;
79 elsif ( $op eq 'save_layout' ) {
80 save_layout(
81 $barcodetype, $title, $subtitle, $isbn,
82 $issn, $itemtype, $bcn, $dcn,
83 $classif, $subclass, $itemcallnumber, $author,
84 $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
85 $layout_id
88 ### $layoutname
90 print $query->redirect("label-home.pl");
91 exit;
93 elsif ( $op eq 'add_layout' ) {
94 add_layout(
95 $barcodetype, $title, $subtitle, $isbn,
96 $issn, $itemtype, $bcn, $dcn,
97 $classif, $subclass, $itemcallnumber, $author,
98 $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
99 $layout_id
102 ### $layoutname
104 print $query->redirect("label-home.pl");
105 exit;
112 elsif ( $op eq 'add' ) { # add item
113 my $query2 = "INSERT INTO labels ( itemnumber, batch_id ) values ( ?,? )";
114 my $sth2 = $dbh->prepare($query2);
115 for my $inum (@itemnumber) {
116 $sth2->execute($inum, $batch_id);
118 $sth2->finish;
120 elsif ( $op eq 'deleteall' ) {
121 my $query2 = "DELETE FROM labels";
122 my $sth2 = $dbh->prepare($query2);
123 $sth2->execute();
124 $sth2->finish;
126 elsif ( $op eq 'delete' ) {
127 my $query2 = "DELETE FROM labels where itemnumber = ?";
128 my $sth2 = $dbh->prepare($query2);
129 $sth2->execute($itemnumber);
130 $sth2->finish;
134 elsif ( $op eq 'delete_batch' ) {
135 delete_batch($batch_id);
136 print $query->redirect("label-manager.pl?batch_id=");
137 exit;
140 elsif ( $op eq 'add_batch' ) {
141 $batch_id= add_batch();
145 elsif ( $op eq 'set_active_layout' ) {
146 set_active_layout($layout_id);
147 print $query->redirect("label-home.pl");
148 exit;
152 # first lets do a read of the labels table , to get the a list of the
153 # currently entered items to be prinited
154 #use Data::Dumper;
155 my @batches = get_batches();
156 my @resultsloop = get_label_items($batch_id);
157 #warn $batches[0];
158 #warn $batch_id;
159 #warn Dumper(@resultsloop);
161 my $tmpl =GetActiveLabelTemplate();
162 ### $tmpl
163 #calc-ing number of sheets
164 #my $number_of_results = scalar @resultsloop;
165 #my $sheets_needed = ( ( --$number_of_results + $startrow ) / 8 );
166 #$sheets_needed = ceil($sheets_needed); # rounding up int's
168 #my $tot_labels = ( $sheets_needed * 8 );
169 #my $start_results = ( $number_of_results + $startrow );
170 #my $labels_remaining = ( $tot_labels - $start_results );
172 $template->param(
173 batch_id => $batch_id,
174 batch_count => scalar @resultsloop,
175 active_layout_name => $active_layout_name,
176 active_template_name => $active_template_name,
178 resultsloop => \@resultsloop,
179 batches => \@batches,
180 tmpl_desc => $tmpl->{'tmpl_desc'},
182 # startrow => $startrow,
183 # sheets => $sheets_needed,
184 # labels_remaining => $labels_remaining,
186 output_html_with_http_headers $query, $cookie, $template->output;