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');
22 my $bcn = $query->param('tx_barcode');
23 my $author = $query->param('tx_author');
25 my $title = $query->param('tx_title');
26 my $subtitle = $query->param('tx_subtitle');
27 my $isbn = $query->param('tx_isbn');
28 my $issn = $query->param('tx_issn');
29 my $itemtype = $query->param('tx_itemtype');
30 my $dcn = $query->param('tx_dewey');
31 my $classif = $query->param('tx_classif');
32 my $itemcallnumber = $query->param('tx_itemcallnumber');
33 my $subclass = $query->param('tx_subclass');
34 my $author = $query->param('tx_author');
35 my $tmpl_id = $query->param('tmpl_id');
36 my $summary = $query->param('summary');
37 my $startlabel = $query->param('startlabel');
38 my $printingtype = $query->param('printingtype');
39 my $guidebox = $query->param('guidebox');
40 my $fontsize = $query->param('fontsize');
41 my @itemnumber = $query->param('itemnumber');
44 # little block for displaying active layout/template/batch in templates
46 my $batch_id = $query->param('batch_id');
47 my $active_layout = get_active_layout();
48 my $active_template = GetActiveLabelTemplate();
49 my $active_layout_name = $active_layout->{'layoutname'};
50 my $active_template_name = $active_template->{'tmpl_code'};
54 # $batch_id = get_highest_batch();
57 my ($itemnumber) = @itemnumber if (scalar(@itemnumber) == 1);
59 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
61 template_name => "labels/label-manager.tmpl",
65 flagsrequired => { catalogue => 1 },
70 if ( $op eq 'save_conf' ) { # this early sub is depreciated, use save_layout()
73 $barcodetype, $title, $isbn,
74 $issn, $itemtype, $bcn, $dcn,
75 $classif, $subclass, $itemcallnumber, $author,
76 $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname
78 print $query->redirect("label-home.pl");
83 elsif ( $op eq 'save_layout' ) {
85 $barcodetype, $title, $subtitle, $isbn,
86 $issn, $itemtype, $bcn, $dcn,
87 $classif, $subclass, $itemcallnumber, $author,
88 $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
94 print $query->redirect("label-home.pl");
97 elsif ( $op eq 'add_layout' ) {
99 $barcodetype, $title, $subtitle, $isbn,
100 $issn, $itemtype, $bcn, $dcn,
101 $classif, $subclass, $itemcallnumber, $author,
102 $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
108 print $query->redirect("label-home.pl");
116 elsif ( $op eq 'add' ) { # add item
117 my $query2 = "INSERT INTO labels ( itemnumber, batch_id ) values ( ?,? )";
118 my $sth2 = $dbh->prepare($query2);
119 for my $inum (@itemnumber) {
120 $sth2->execute($inum, $batch_id);
124 elsif ( $op eq 'deleteall' ) {
125 my $query2 = "DELETE FROM labels";
126 my $sth2 = $dbh->prepare($query2);
130 elsif ( $op eq 'delete' ) {
131 my $query2 = "DELETE FROM labels where itemnumber = ?";
132 my $sth2 = $dbh->prepare($query2);
133 $sth2->execute($itemnumber);
138 elsif ( $op eq 'delete_batch' ) {
139 delete_batch($batch_id);
140 print $query->redirect("label-manager.pl?batch_id=");
144 elsif ( $op eq 'add_batch' ) {
145 $batch_id= add_batch();
149 elsif ( $op eq 'set_active_layout' ) {
150 set_active_layout($layout_id);
151 print $query->redirect("label-home.pl");
156 # first lets do a read of the labels table , to get the a list of the
157 # currently entered items to be prinited
159 my @batches = get_batches();
160 my @resultsloop = get_label_items($batch_id);
163 #warn Dumper(@resultsloop);
165 my $tmpl =GetActiveLabelTemplate();
167 #calc-ing number of sheets
168 #my $number_of_results = scalar @resultsloop;
169 #my $sheets_needed = ( ( --$number_of_results + $startrow ) / 8 );
170 #$sheets_needed = ceil($sheets_needed); # rounding up int's
172 #my $tot_labels = ( $sheets_needed * 8 );
173 #my $start_results = ( $number_of_results + $startrow );
174 #my $labels_remaining = ( $tot_labels - $start_results );
177 batch_id => $batch_id,
178 batch_count => scalar @resultsloop,
179 active_layout_name => $active_layout_name,
180 active_template_name => $active_template_name,
182 resultsloop => \@resultsloop,
183 batches => \@batches,
184 tmpl_desc => $tmpl->{'tmpl_desc'},
186 # startrow => $startrow,
187 # sheets => $sheets_needed,
188 # labels_remaining => $labels_remaining,
190 intranetcolorstylesheet =>
191 C4::Context->preference("intranetcolorstylesheet"),
192 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
193 IntranetNav => C4::Context->preference("IntranetNav"),
195 output_html_with_http_headers $query, $cookie, $template->output;