X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=labels%2Flabel-manager.pl;h=08432caa8c972fc0b8c3b83233054dcd19ad6b51;hb=37ca03479c2c3cfb04fc15214176f92bca2b6551;hp=50d81359e52e49e018e9d250d63b89672873d054;hpb=4cfbf45e355b5d80881e88711a2873824c3bb3b1;p=koha.git diff --git a/labels/label-manager.pl b/labels/label-manager.pl index 50d81359e5..08432caa8c 100755 --- a/labels/label-manager.pl +++ b/labels/label-manager.pl @@ -7,7 +7,7 @@ use C4::Labels; use C4::Output; use HTML::Template::Pro; #use POSIX qw(ceil); -use Data::Dumper; +#use Data::Dumper; #use Smart::Comments; use vars qw($debug); @@ -29,10 +29,7 @@ my $subtitle = $query->param('tx_subtitle'); my $isbn = $query->param('tx_isbn'); my $issn = $query->param('tx_issn'); my $itemtype = $query->param('tx_itemtype'); -my $dcn = $query->param('tx_dewey'); -my $classif = $query->param('tx_classif'); my $itemcallnumber = $query->param('tx_itemcallnumber'); -my $subclass = $query->param('tx_subclass'); my $author = $query->param('tx_author'); my $tmpl_id = $query->param('tmpl_id'); my $summary = $query->param('summary'); @@ -40,9 +37,13 @@ my $startlabel = $query->param('startlabel'); my $printingtype = $query->param('printingtype'); my $guidebox = $query->param('guidebox'); my $fontsize = $query->param('fontsize'); -my @itemnumber = $query->param('itemnumber') if ($query->param('type') eq 'labels'); -my @itemnumber = $query->param('borrowernumber') if ($query->param('type') eq 'patroncards'); +my $callnum_split = $query->param('callnum_split'); +my $text_justify = $query->param('text_justify'); +my $formatstring = $query->param('formatstring'); my $batch_type = $query->param('type'); +($batch_type and $batch_type eq 'patroncards') or $batch_type = 'labels'; +my @itemnumber; +($batch_type eq 'labels') ? (@itemnumber = $query->param('itemnumber')) : (@itemnumber = $query->param('borrowernumber')); # little block for displaying active layout/template/batch in templates # ---------- @@ -72,24 +73,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -if ( $op eq 'save_conf' ) { # this early sub is depreciated, use save_layout() - SaveConf( - $barcodetype, $title, $isbn, - $issn, $itemtype, $bcn, $dcn, - $classif, $subclass, $itemcallnumber, $author, - $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname - ); - print $query->redirect("label-home.pl"); - exit; -} -elsif ( $op eq 'save_layout' ) { +if ( $op eq 'save_layout' ) { save_layout( $barcodetype, $title, $subtitle, $isbn, - $issn, $itemtype, $bcn, $dcn, - $classif, $subclass, $itemcallnumber, $author, + $issn, $itemtype, $bcn, $text_justify, + $callnum_split, $itemcallnumber, $author, $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname, - $layout_id - ); + , $formatstring , $layout_id + ); ### $layoutname print $query->redirect("label-home.pl"); exit; @@ -97,10 +88,10 @@ elsif ( $op eq 'save_layout' ) { elsif ( $op eq 'add_layout' ) { add_layout( $barcodetype, $title, $subtitle, $isbn, - $issn, $itemtype, $bcn, $dcn, - $classif, $subclass, $itemcallnumber, $author, + $issn, $itemtype, $bcn, $text_justify, + $callnum_split, $itemcallnumber, $author, $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname, - $layout_id + $formatstring , $layout_id ); ### $layoutname print $query->redirect("label-home.pl"); @@ -110,22 +101,19 @@ elsif ( $op eq 'add_layout' ) { # FIXME: The trinary conditionals here really need to be replaced with a more robust form of db abstraction -fbcit elsif ( $op eq 'add' ) { # add item - warn "op \'add\': batch id = $batch_id, type = $batch_type"; - my $query2 = "INSERT INTO $batch_type ( " . (($batch_type eq 'labels') ? 'itemnumber' : 'borrowernumber') . ", batch_id ) values ( ?,? )"; - warn "op \'add\' \$query2=$query2"; + my $query2 = ($batch_type eq 'patroncards') ? + "INSERT INTO patroncards (borrowernumber, batch_id) values (?,?)" : + "INSERT INTO labels (itemnumber, batch_id) values (?,?)" ; my $sth2 = $dbh->prepare($query2); - warn Dumper($itemnumber); for my $inum (@itemnumber) { - warn "INSERTing " . (($batch_type eq 'labels') ? 'itemnumber' : 'borrowernumber') . ":$inum for batch $batch_id"; - $sth2->execute($inum, $batch_id); + # warn "INSERTing " . (($batch_type eq 'labels') ? 'itemnumber' : 'borrowernumber') . ":$inum for batch $batch_id"; + $sth2->execute($inum, $batch_id); } - $sth2->finish; } elsif ( $op eq 'deleteall' ) { my $query2 = "DELETE FROM $batch_type"; my $sth2 = $dbh->prepare($query2); $sth2->execute(); - $sth2->finish; } elsif ( $op eq 'delete' ) { my @labelids = $query->param((($batch_type eq 'labels') ? 'labelid' : 'cardid')); @@ -136,11 +124,10 @@ elsif ( $op eq 'delete' ) { $debug and push @messages, "query2: $query2 -- (@labelids)"; my $sth2 = $dbh->prepare($query2); $sth2->execute(@labelids); - $sth2->finish; } elsif ( $op eq 'delete_batch' ) { delete_batch($batch_id, $batch_type); - print $query->redirect("label-manager.pl"); + print $query->redirect("label-manager.pl?type=$batch_type"); exit; } elsif ( $op eq 'add_batch' ) { @@ -152,8 +139,9 @@ elsif ( $op eq 'set_active_layout' ) { exit; } elsif ( $op eq 'deduplicate' ) { - my $return = deduplicate_batch($batch_id); - my $msg = (($return) ? "Removed $return" : "Error revoving") . " duplicate items from Batch $batch_id"; + warn "\$batch_id=$batch_id and \$batch_type=$batch_type"; + my ($return, $dberror) = deduplicate_batch($batch_id, $batch_type); + my $msg = (($return) ? "Removed $return" : "Error removing") . " duplicate items from Batch $batch_id." . (($dberror) ? " Database returned: $dberror" : ""); push @messages, $msg; } @@ -180,12 +168,18 @@ if (scalar @messages) { } $template->param(message_loop => \@complex); } +if ($batch_type eq 'labels' or $batch_type eq 'patroncards') { + $template->param("batch_is_$batch_type" => 1); +} $template->param( - type => $batch_type, + batch_type => $batch_type, batch_id => $batch_id, batch_count => scalar @resultsloop, active_layout_name => $active_layout_name, active_template_name => $active_template_name, + outputformat => ( $active_layout->{'printingtype'} eq 'CSV' ) ? 'csv' : 'pdf' , + layout_tx => ( $active_layout->{'formatstring'}) ? 0 : 1 , + layout_string => ( $active_layout->{'formatstring'}) ? 1 : 0 , resultsloop => \@resultsloop, batches => \@batches,