8 use HTML
::Template
::Pro
;
14 my $dbh = C4
::Context
->dbh;
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
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'};
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",
61 flagsrequired
=> { catalogue
=> 1 },
66 if ( $op eq 'save_conf' ) { # this early sub is depreciated, use save_layout()
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");
79 elsif ( $op eq 'save_layout' ) {
81 $barcodetype, $title, $subtitle, $isbn,
82 $issn, $itemtype, $bcn, $dcn,
83 $classif, $subclass, $itemcallnumber, $author,
84 $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
90 print $query->redirect("label-home.pl");
93 elsif ( $op eq 'add_layout' ) {
95 $barcodetype, $title, $subtitle, $isbn,
96 $issn, $itemtype, $bcn, $dcn,
97 $classif, $subclass, $itemcallnumber, $author,
98 $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
104 print $query->redirect("label-home.pl");
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);
120 elsif ( $op eq 'deleteall' ) {
121 my $query2 = "DELETE FROM labels";
122 my $sth2 = $dbh->prepare($query2);
126 elsif ( $op eq 'delete' ) {
127 my $query2 = "DELETE FROM labels where itemnumber = ?";
128 my $sth2 = $dbh->prepare($query2);
129 $sth2->execute($itemnumber);
134 elsif ( $op eq 'delete_batch' ) {
135 delete_batch
($batch_id);
136 print $query->redirect("label-manager.pl?batch_id=");
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");
152 # first lets do a read of the labels table , to get the a list of the
153 # currently entered items to be prinited
155 my @batches = get_batches
();
156 my @resultsloop = get_label_items
($batch_id);
159 #warn Dumper(@resultsloop);
161 my $tmpl =GetActiveLabelTemplate
();
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 );
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;