[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/barcodes label-item-search.pl label-manage... [rel_2_2]
From: |
Mason James |
Subject: |
[Koha-cvs] koha/barcodes label-item-search.pl label-manage... [rel_2_2] |
Date: |
Tue, 10 Jul 2007 10:54:05 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: rel_2_2
Changes by: Mason James <sushi> 07/07/10 10:54:05
Modified files:
barcodes : label-item-search.pl label-manager.pl
label-print-opus-pdf.pl label-print-pdf.pl
label-print.pl
Added files:
barcodes : label-add-layout.pl label-create-template.pl
label-edit-layout.pl label-edit-template.pl
label-save-template.pl label-select-pdf.pl
label-templates.pl
Log message:
updating rel2_2 with newer version of barcodes/spinelabels
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-item-search.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.2&r2=1.1.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-manager.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.3&r2=1.1.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-opus-pdf.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print-pdf.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.16&r2=1.1.2.17
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-print.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.4&r2=1.1.2.5
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-add-layout.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.4.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-create-template.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.4.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-edit-layout.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.4.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-edit-template.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.4.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-save-template.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.4.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-select-pdf.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.4.2
http://cvs.savannah.gnu.org/viewcvs/koha/barcodes/label-templates.pl?cvsroot=koha&only_with_tag=rel_2_2&rev=1.1.4.2
Patches:
Index: label-item-search.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-item-search.pl,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- label-item-search.pl 19 Jul 2006 01:37:23 -0000 1.1.2.2
+++ label-item-search.pl 10 Jul 2007 10:54:04 -0000 1.1.2.3
@@ -34,6 +34,9 @@
use C4::SearchMarc;
use C4::Koha; # XXX subfield_is_koha_internal_p
+#use Smart::Comments;
+#use Data::Dumper;
+
# Creates a scrolling list with the associated default value.
# Using more than one scrolling list in a CGI assigns the same default value
to all the
# scrolling lists on the page !?!? That's why this function was written.
@@ -41,6 +44,11 @@
my $query = new CGI;
my $type = $query->param('type');
my $op = $query->param('op');
+my $batch_id = $query->param('batch_id');
+my $dateaccessioned = $query->param('dateaccessioned');
+
+### $query;
+
my $dbh = C4::Context->dbh;
my $startfrom = $query->param('startfrom');
@@ -151,7 +159,8 @@
#warn $i;
#warn Dumper $results->[$i]{'bibid'};
my $type = 'intra';
- my @item_results = &ItemInfo( 0, $results->[$i]{'biblionumber'}, $type
);
+ my @item_results =
+ &ItemInfo( 0, $results->[$i]{'biblionumber'}, $type );
foreach my $item (@item_results) {
@@ -174,8 +183,16 @@
from => $from,
to => $to,
numbers => address@hidden,
+ batch_id => $batch_id,
);
}
+
+#
+#
+# search section
+#
+#
+
else {
( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
@@ -187,38 +204,34 @@
debug => 1,
}
);
- my $sth =
- $dbh->prepare(
- "Select itemtype,description from itemtypes order by description");
- $sth->execute;
- my @itemtype;
- my %itemtypes;
- push @itemtype, "";
- $itemtypes{''} = "";
- while ( my ( $value, $lib ) = $sth->fetchrow_array ) {
- push @itemtype, $value;
- $itemtypes{$value} = $lib;
- }
-
- my $CGIitemtype = CGI::scrolling_list(
- -name => 'value',
- -values => address@hidden,
- -labels => \%itemtypes,
- -size => 1,
- -multiple => 0
+
+
+ #using old rel2.2 getitemtypes for testing!!!!, not devweek's GetItemTypes()
+
+ my $itemtypes = getitemtypes;
+ my @itemtypeloop;
+ my ($thisitemtype );
+ foreach my $thisitemtype (keys %$itemtypes) {
+ my %row =(value => $thisitemtype,
+ description =>
$itemtypes->{$thisitemtype}->{'description'},
);
- $sth->finish;
+ push @itemtypeloop, \%row;
+ }
- $template->param( CGIitemtype => $CGIitemtype, );
-}
-# Print the page
-$template->param(
+ $template->param(
+ itemtypeloop =>address@hidden,
+ batch_id => $batch_id,
+ );
+
+ # Print the page
+ $template->param(
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
-);
+ );
+}
output_html_with_http_headers $query, $cookie, $template->output;
# Local Variables:
Index: label-manager.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-manager.pl,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- label-manager.pl 20 Jul 2006 15:30:16 -0000 1.1.2.3
+++ label-manager.pl 10 Jul 2007 10:54:04 -0000 1.1.2.4
@@ -3,32 +3,59 @@
use strict;
use CGI;
use C4::Auth;
+use C4::Labels;
use C4::Output;
use C4::Interface::CGI::Output;
use HTML::Template;
use POSIX;
+#use Data::Dumper;
+#use Smart::Comments;
+
my $dbh = C4::Context->dbh;
my $query = new CGI;
my $op = $query->param('op');
+my $layout_id = $query->param('layout_id');
+my $layoutname = $query->param('layoutname');
my $barcodetype = $query->param('barcodetype');
-my $title = $query->param('title');
-my $isbn = $query->param('isbn');
-my $itemtype = $query->param('itemtype');
-my $bcn = $query->param('bcn');
-my $dcn = $query->param('dcn');
-my $classif = $query->param('classif');
+
+
+my $bcn = $query->param('tx_barcode');
+my $author = $query->param('tx_author');
+
+my $title = $query->param('tx_title');
+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('itemcallnumber');
-my $subclass = $query->param('subclass');
-my $author = $query->param('author');
-my $papertype = $query->param('papertype');
-my $itemnumber = $query->param('itemnumber');
+my $subclass = $query->param('tx_subclass');
+my $author = $query->param('tx_author');
+my $tmpl_id = $query->param('tmpl_id');
my $summary = $query->param('summary');
-my $startrow = $query->param('startrow');
+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');
+
-warn $printingtype;
+# little block for displaying active layout/template/batch in templates
+# ----------
+my $batch_id = $query->param('batch_id');
+my $active_layout = get_active_layout();
+my $active_template = GetActiveLabelTemplate();
+my $active_layout_name = $active_layout->{'layoutname'};
+my $active_template_name = $active_template->{'tmpl_code'};
+# ----------
+
+if (!$batch_id ) {
+ $batch_id = get_highest_batch();
+}
+
+my ($itemnumber) = @itemnumber if (scalar(@itemnumber) == 1);
+### $batch_id;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
@@ -41,30 +68,43 @@
}
);
-if ( $op eq 'save_conf' ) {
- my $query2 = "DELETE FROM labels_conf";
- my $sth2 = $dbh->prepare($query2);
- $sth2->execute();
- $sth2->finish;
- my $query2 = "INSERT INTO labels_conf
- ( barcodetype, title, isbn, itemtype, barcode,
- dewey, class, subclass, itemcallnumber, author,
papertype, printingtype,
- guidebox, startrow)
- values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
- my $sth2 = $dbh->prepare($query2);
- $sth2->execute(
- $barcodetype, $title, $isbn, $itemtype,
- $bcn, $dcn, $classif, $subclass,
- $itemcallnumber, $author, $papertype,$printingtype,
- $guidebox, $startrow
+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
);
- $sth2->finish;
+ print $query->redirect("../label-home.pl");
+ exit;
+}
+
+
+elsif ( $op eq 'save_layout' ) {
+ save_layout(
+ $barcodetype, $title, $isbn,
+ $issn, $itemtype, $bcn, $dcn,
+ $classif, $subclass, $itemcallnumber, $author,
+ $tmpl_id, $printingtype, $guidebox, $startlabel, $layoutname,
+ $layout_id
+ );
+
+### $layoutname
+ print $query->redirect("../label-home.pl");
+ exit;
}
-elsif ( $op eq 'add' ) {
- my $query2 = "INSERT INTO labels ( itemnumber ) values ( ? )";
+
+
+
+
+
+elsif ( $op eq 'add' ) { # add item
+ my $query2 = "INSERT INTO labels ( itemnumber, batch_id ) values ( ?,? )";
my $sth2 = $dbh->prepare($query2);
- $sth2->execute($itemnumber);
+ for my $inum (@itemnumber) {
+ $sth2->execute($inum, $batch_id);
+ }
$sth2->finish;
}
elsif ( $op eq 'deleteall' ) {
@@ -74,76 +114,59 @@
$sth2->finish;
}
elsif ( $op eq 'delete' ) {
- warn "MASON, deleting label..";
my $query2 = "DELETE FROM labels where itemnumber = ?";
my $sth2 = $dbh->prepare($query2);
$sth2->execute($itemnumber);
$sth2->finish;
}
+
+elsif ( $op eq 'delete_batch' ) {
+ delete_batch($batch_id);
+}
+
+elsif ( $op eq 'add_batch' ) {
+ $batch_id= add_batch();
+
+}
+
+elsif ( $op eq 'set_active_layout' ) {
+ set_active_layout($layout_id);
+ print $query->redirect("../label-home.pl");
+ exit;
+}
+
+
# first lets do a read of the labels table , to get the a list of the
# currently entered items to be prinited
-my @resultsloop = ();
-my $count;
-my @data;
-my $query3 = "Select * from labels";
-my $sth = $dbh->prepare($query3);
-$sth->execute();
-
-my $cnt = $sth->rows;
-my $i1 = 1;
-while ( my $data = $sth->fetchrow_hashref ) {
-
- # lets get some summary info from each item
- my $query1 = "
- select * from biblio,biblioitems,items where
itemnumber=? and
-
items.biblioitemnumber=biblioitems.biblioitemnumber and
- biblioitems.biblionumber=biblio.biblionumber";
-
- my $sth1 = $dbh->prepare($query1);
- $sth1->execute( $data->{'itemnumber'} );
- my $data1 = $sth1->fetchrow_hashref();
-
- $data1->{'labelno'} = $i1;
- $data1->{'summary'} =
- "$data1->{'barcode'}, $data1->{'title'}, $data1->{'isbn'}";
-
- push( @resultsloop, $data1 );
- $sth1->finish;
-
- $i1++;
-}
-$sth->finish;
-
-# this script can be run from the side nav, and is not passed a value for
$startrow
-# so lets get it from the DB
-if ( !$startrow ) {
-
- my $dbh = C4::Context->dbh;
- my $query2 = "SELECT * FROM labels_conf LIMIT 1";
- my $sth = $dbh->prepare($query2);
- $sth->execute();
-
- my $data = $sth->fetchrow_hashref;
- $startrow = $data->{'startrow'};
- $sth->finish;
-}
+my @batches = get_batches();
+my @resultsloop = get_label_items($batch_id);
+my $tmpl =GetActiveLabelTemplate();
+### $tmpl
#calc-ing number of sheets
-my $number_of_results = scalar @resultsloop;
-my $sheets_needed = ( ( --$number_of_results + $startrow ) / 8 );
-$sheets_needed = ceil($sheets_needed); # rounding up int's
-
-my $tot_labels = ( $sheets_needed * 8 );
-my $start_results = ( $number_of_results + $startrow );
-my $labels_remaining = ( $tot_labels - $start_results );
+#my $number_of_results = scalar @resultsloop;
+#my $sheets_needed = ( ( --$number_of_results + $startrow ) / 8 );
+#$sheets_needed = ceil($sheets_needed); # rounding up int's
+
+#my $tot_labels = ( $sheets_needed * 8 );
+#my $start_results = ( $number_of_results + $startrow );
+#my $labels_remaining = ( $tot_labels - $start_results );
$template->param(
+ batch_id => $batch_id,
+ active_layout_name => $active_layout_name,
+ active_template_name => $active_template_name,
+
resultsloop => address@hidden,
- startrow => $startrow,
- sheets => $sheets_needed,
- labels_remaining => $labels_remaining,
+ batches => address@hidden,
+batch_id => $batch_id,
+tmpl_desc => $tmpl->{'tmpl_desc'},
+
+ # startrow => $startrow,
+ # sheets => $sheets_needed,
+ # labels_remaining => $labels_remaining,
intranetcolorstylesheet =>
C4::Context->preference("intranetcolorstylesheet"),
Index: label-print-opus-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-opus-pdf.pl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- label-print-opus-pdf.pl 19 Jul 2006 01:37:23 -0000 1.1.2.1
+++ label-print-opus-pdf.pl 10 Jul 2007 10:54:04 -0000 1.1.2.2
@@ -1,62 +1,187 @@
#!/usr/bin/perl
-#use lib '/usr/local/opus-dev/intranet/modules';
-#use C4::Context("/etc/koha-opus-dev.conf");
+# use lib '/usr/local/opus-dev/intranet/modules';
+# use C4::Context("/etc/koha-opus-dev.conf");
use strict;
use CGI;
use C4::Labels;
use C4::Auth;
-use C4::Bull;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Context;
+use HTML::Template;
use PDF::Reuse;
use PDF::Reuse::Barcode;
-use PDF::Report;
-use PDF::Create;
-use PDF::Labels;
-use Acme::Comment;
-use Data::Dumper;
-warn "-------";
+use POSIX;
+use Text::Wrap;
-my $htdocs_path = C4::Context->config('intrahtdocs');
-my $cgi = new CGI;
+#use Data::Dumper;
+#use Acme::Comment;
-my $pdf = new PDF::Labels(
- $PDF::Labels::PageFormats[1],
- filename => "$htdocs_path/barcodes/opus.pdf",
- Author => 'PDF Labelmaker',
- 'PageMode' => 'UseOutlines',
- Title => 'My Labels'
-);
+$Text::Wrap::columns = 39;
+$Text::Wrap::separator = "\n";
-warn "$htdocs_path/barcodes/opus.pdf";
+my $htdocs_path = C4::Context->config('intrahtdocs');
+my $cgi = new CGI;
+my $spine_text = "";
+# get the printing settings
+my $conf_data = get_label_options();
my @resultsloop = get_label_items();
-
-#warn Dumper @resultsloop;
-warn Dumper $pdf->{'filename'};
-
-$pdf->setlabel(0); # Start with label 5 on first page
-
-foreach my $result (@resultsloop) {
- warn Dumper $result;
- $pdf->label( $result->{'itemtype'}, $result->{'number'}, 'LAK',
- $result->{'barcode'} );
- $pdf->label( $result->{'itemtype'}, $result->{'dewey'}, 'LAK',
- $result->{'barcode'} );
-
+my $barcodetype = $conf_data->{'barcodetype'};
+my $printingtype = $conf_data->{'printingtype'};
+my $guidebox = $conf_data->{'guidebox'};
+my $startrow = $conf_data->{'startrow'};
+
+# if none selected, then choose 'both'
+if ( !$printingtype ) {
+ $printingtype = 'both';
}
-warn "HERE";
-$pdf->close();
-#--------------------------------------------------
+# opus paper dims. in *millimeters*
+# multiply values by '2.83465', to find their value in Postscript points.
-use PDF::Reuse;
-prFile("$htdocs_path/barcodes/opus1.pdf");
-prDoc("$htdocs_path/barcodes/opus.pdf");
+# $xmargin = 12;
+# $label_height = 34;
+# $label_width = 74;
+# $x_pos_spine = 12;
+# $pageheight = 304;
+# $pagewidth = 174;
+# $line_spacer = 10;
+# $label_rows = 8;
+
+# sheet dimensions in PS points.
+
+my $top_margin = 7;
+my $left_margin = 34;
+my $top_text_margin = 20;
+my $left_text_margin = 10;
+my $label_height = 96;
+my $spine_width = 210;
+my $colspace = 9;
+my $rowspace = 11;
+my $x_pos_spine = 36;
+my $pageheight = 861;
+my $pagewidth = 493;
+my $line_spacer = 10;
+my $label_rows = 8;
+
+# setting up the pdf doc
+#remove the file before write, for testing
+#unlink "$htdocs_path/barcodes/new.pdf";
+#prFile("$htdocs_path/barcodes/new.pdf");
+#prLogDir("$htdocs_path/barcodes");
+
+# fix, no longer writes to temp dir
+prInitVars(); # To initiate ALL global variables and tables
+$| = 1;
+print STDOUT "Content-Type: application/pdf \n\n";
+prFile();
+
+prMbox( 0, 0, $pagewidth, $pageheight );
+prFont('courier'); # Just setting a font
+prFontSize(9);
+
+my $str;
+
+#warn "STARTROW = $startrow\n";
+
+my $y_pos_initial = ( ( $pageheight - $top_margin ) - $label_height );
+my $y_pos_initial_startrow =
+ ( ( $pageheight - $top_margin ) - ( $label_height * $startrow ) );
+my $y_pos = $y_pos_initial_startrow;
+
+#warn "Y POS INITAL : $y_pos_initial";
+#warn "Y POS : $y_pos";
+#warn "Y START ROW = $y_pos_initial_startrow";
+
+my $page_break_count = $startrow;
+my $codetype = 'Code39';
+
+#do page border
+# commented out coz it was running into the side-feeds of the paper.
+# drawbox( 0, 0 , $pagewidth, $pageheight );
+
+my $item;
+
+# for loop
+my $i2 = 1;
+
+foreach $item (@resultsloop) {
+ my $x_pos_spine_tmp = $x_pos_spine;
+
+ for ( 1 .. 2 ) {
+
+ if ( $guidebox == 1 ) {
+ warn
+"COUNT1, PBREAKCNT=$page_break_count, y=$y_pos, labhght = $label_height";
+ drawbox( $x_pos_spine_tmp, $y_pos, $spine_width, $label_height );
+ }
+
+ #-----------------draw spine text
+ if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
+
+ #warn "PRINTTYPE = $printingtype";
+
+ # add your printable fields manually in here
+ my @fields = qw (itemtype dewey isbn classification);
+ my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
+ my $hPos = ( $x_pos_spine_tmp + $left_text_margin );
+ foreach my $field (@fields) {
+
+ # if the display option for this field is selected in the DB,
+ # and the item record has some values for this field, display
it.
+ if ( $conf_data->{"$field"} && $item->{"$field"} ) {
+
+ #warn "CONF_TYPE = $field";
+
+ # get the string
+ $str = $item->{"$field"};
+
+ # strip out naughty existing nl/cr's
+ $str =~ s/\n//g;
+ $str =~ s/\r//g;
+
+ # chop the string up into _upto_ 12 chunks
+ # and seperate the chunks with newlines
+
+ $str = wrap( "", "", "$str" );
+ $str = wrap( "", "", "$str" );
+
+ # split the chunks between newline's, into an array
+ my @strings = split /\n/, $str;
+
+ # then loop for each string line
+ foreach my $str (@strings) {
+
+ warn "HPOS , VPOS $hPos, $vPos ";
+ prText( $hPos, $vPos, $str );
+ $vPos = $vPos - $line_spacer;
+ }
+ } # if field is valid
+ } # foreach @field
+ } #if spine
+
+ $x_pos_spine_tmp = ( $x_pos_spine_tmp + $spine_width + $colspace );
+ } # for 1 ..2
+ warn " $y_pos - $label_height - $rowspace";
+ $y_pos = ( $y_pos - $label_height - $rowspace );
+ warn " $y_pos - $label_height - $rowspace";
+
+ #-----------------draw spine text
+
+ # the gaylord labels have 8 rows per sheet, this pagebreaks after 8 rows
+ if ( $page_break_count == $label_rows ) {
+ prPage();
+ $page_break_count = 0;
+ $i2 = 0;
+ $y_pos = $y_pos_initial;
+ }
+ $page_break_count++;
+ $i2++;
+}
prEnd();
-print $cgi->redirect("/intranet-tmpl/barcodes/opus1.pdf");
+#print $cgi->redirect("/intranet-tmpl/barcodes/new.pdf");
Index: label-print-pdf.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print-pdf.pl,v
retrieving revision 1.1.2.16
retrieving revision 1.1.2.17
diff -u -b -r1.1.2.16 -r1.1.2.17
--- label-print-pdf.pl 25 Apr 2007 15:34:27 -0000 1.1.2.16
+++ label-print-pdf.pl 10 Jul 2007 10:54:04 -0000 1.1.2.17
@@ -1,19 +1,5 @@
#!/usr/bin/perl
-#----------------------------------------------------------------------
-# this script is really divided into 2 differenvt section,
-
-# the first section creates, and defines the new PDF file the barcodes
-# using PDF::Reuse::Barcode, then saves the file to disk.
-
-# the second section then opens the pdf file off disk, and places the spline
label
-# text in the left-most column of the page. then save the file again.
-
-# the reason for this goofyness, it that i couldnt find a single perl package
that handled both barcodes and decent text placement.
-
-#use lib '/usr/local/opus-import/intranet/modules';
-#use C4::Context("/etc/koha-opus-import.conf");
-
use strict;
use CGI;
use C4::Labels;
@@ -25,170 +11,244 @@
use PDF::Reuse;
use PDF::Reuse::Barcode;
use POSIX;
-use Text::Wrap;
-
-#use Data::Dumper;
-#use Acme::Comment;
-
-$Text::Wrap::columns = 14;
-$Text::Wrap::separator = "\n";
+#use C4::Labels;
+#use Smart::Comments;
my $htdocs_path = C4::Context->config('intrahtdocs');
my $cgi = new CGI;
+print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.pdf' );
+
my $spine_text = "";
# get the printing settings
+my $template = GetActiveLabelTemplate();
my $conf_data = get_label_options();
-my @resultsloop = get_label_items();
+
+my $batch_id = $cgi->param('batch_id');
+my @resultsloop = get_label_items($batch_id);
+
+$DB::single = 1;
+
+
my $barcodetype = $conf_data->{'barcodetype'};
my $printingtype = $conf_data->{'printingtype'};
my $guidebox = $conf_data->{'guidebox'};
-my $startrow = $conf_data->{'startrow'};
+my $start_label = $conf_data->{'startlabel'};
+my $fontsize = $template->{'fontsize'};
+my $units = $template->{'units'};
+
+### $printingtype;
+
+=c
+################### defaults for testing
+my $barcodetype = 'CODE39';
+my $printingtype = 'BARBIB';
+my $guidebox = 1;
+my $start_label = 1;
+my $units = 'POINTS'
+=cut
+
+#my $fontsize = 3;
+
+#warn "UNITS $units";
+#warn "fontsize = $fontsize";
+#warn Dumper $template;
+
+my $unitvalue = GetUnitsValue($units);
+
+my $tmpl_code = $template->{'tmpl_code'};
+my $tmpl_desc = $template->{'tmpl_desc'};
+
+my $page_height = ( $template->{'page_height'} * $unitvalue );
+my $page_width = ( $template->{'page_width'} * $unitvalue );
+my $label_height = ( $template->{'label_height'} * $unitvalue );
+my $label_width = ( $template->{'label_width'} * $unitvalue );
+my $spine_width = ( $template->{'label_width'} * $unitvalue );
+my $circ_width = ( $template->{'label_width'} * $unitvalue );
+my $top_margin = ( $template->{'topmargin'} * $unitvalue );
+my $left_margin = ( $template->{'leftmargin'} * $unitvalue );
+my $colspace = ( $template->{'colgap'} * $unitvalue );
+my $rowspace = ( $template->{'rowgap'} * $unitvalue );
-# if none selected, then choose 'both'
-if ( !$printingtype ) {
- $printingtype = 'both';
-}
+my $label_cols = $template->{'cols'};
+my $label_rows = $template->{'rows'};
+
+my $text_wrap_cols = GetTextWrapCols( $fontsize, $label_width );
-# dimensions of gaylord paper
+#warn $label_cols, $label_rows;
+
+# set the paper size
my $lowerLeftX = 0;
my $lowerLeftY = 0;
-my $upperRightX = 612;
-my $upperRightY = 792;
-
-# setting up the pdf doc
+my $upperRightX = $page_width;
+my $upperRightY = $page_height;
prInitVars();
$| = 1;
-#print STDOUT "Content-Disposition: attachment; \r\n";
-#print STDOUT "filename: \"KohaBarcodes.pdf\" \r\n";
-#print STDOUT "Content-Type: application/pdf \r\n\r\n";
-print $cgi->header( -type => 'application/pdf',
--attachment => 'kohaBarcodes.pdf' );
prFile();
prMbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
-prFont('courier'); # Just setting a font
-prFontSize(9);
-my $margin = 36;
-my $top_text_margin = 10;
-my $left_text_margin = 3;
-my $label_height = 90;
-my $spine_width = 72;
-my $circ_width = 207;
-my $colspace = 27;
-my $x_pos_spine = 36;
-my $x_pos_circ1 = 135;
-my $x_pos_circ2 = 369;
-my $pageheight = 792;
-my $line_spacer = 10;
-my $label_rows = 8;
+# later feature, change the font-type and size?
+prFont('C'); # Just setting a font
+prFontSize($fontsize);
+my $margin = $top_margin;
+my $left_text_margin = 3;
my $str;
#warn "STARTROW = $startrow\n";
-my $y_pos_initial = ( ( $pageheight - $margin ) - $label_height );
-my $y_pos_initial_startrow =
- ( ( $pageheight - $margin ) - ( $label_height * $startrow ) );
-my $y_pos = $y_pos_initial_startrow;
-
-#warn "Y POS INITAL : $y_pos_initial";
-#warn "Y POS : $y_pos";
-#warn "Y START ROW = $y_pos_initial_startrow";
-
-my $rowspace = 36;
-my $page_break_count = $startrow;
+#my $page_break_count = $startrow;
my $codetype = 'Code39';
#do page border
-drawbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
+#drawbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY );
my $item;
+my ( $i, $i2 ); # loop counters
+
+# big row loop
+
+#warn " $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY";
+#warn "$label_rows, $label_cols\n";
+#warn "$label_height, $label_width\n";
+#warn "$page_height, $page_width\n";
+
+my ( $rowcount, $colcount, $x_pos, $y_pos, $rowtemp, $coltemp );
+
+if ( $start_label eq 1 ) {
+ $rowcount = 1;
+ $colcount = 1;
+ $x_pos = $left_margin;
+ $y_pos = ( $page_height - $top_margin - $label_height );
+}
-# for loop
-my $i2 = 1;
+else {
+
+ #eval {
+ $rowcount = ceil( $start_label / $label_cols );
+
+ #} ;
+ #$rowcount = 1 if $@;
+
+ $colcount = ( $start_label - ( ( $rowcount - 1 ) * $label_cols ) );
+
+ $x_pos = $left_margin + ( $label_width * ( $colcount - 1 ) ) +
+ ( $colspace * ( $colcount - 1 ) );
+
+ $y_pos = $page_height - $top_margin - ( $label_height * $rowcount ) -
+ ( $rowspace * ( $rowcount - 1 ) );
+
+}
+
+warn "ROW COL $rowcount, $colcount";
+
+my $barcodetype = 'Code39';
+
+#
+# main foreach loop
+#
foreach $item (@resultsloop) {
- if ( $i2 == 1 && $guidebox == 1 ) {
- draw_boundaries(
- $x_pos_spine, $x_pos_circ1, $x_pos_circ2, $y_pos,
- $spine_width, $label_height, $circ_width
- );
+# warn "$x_pos, $y_pos, $label_width, $label_height";
+ my $barcode = $item->{'barcode'};
+
+ if ( $printingtype eq 'BAR' ) {
+ drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
+ DrawBarcode( $x_pos, $y_pos, $label_height, $label_width, $barcode,
+ $barcodetype );
+ CalcNextLabelPos();
}
- if ( $printingtype eq 'barcode' || $printingtype eq 'both' ) {
+ elsif ( $printingtype eq 'BARBIB' ) {
+ drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
- #warn "COUNT=$i2, PBREAKCNT=$page_break_count, X,Y POS x=$x_pos_circ1,
y=$y_pos";
+ # reposoitioning barcode up the top of label
+ my $barcode_height = ($label_height / 1.5 ); ## scaling voodoo
+ my $text_height = $label_height / 2;
+ my $barcode_y = $y_pos + ( $label_height / 2.5 ); ## scaling
voodoo
+
+ DrawBarcode( $x_pos, $barcode_y, $barcode_height, $label_width,
+ $barcode, $barcodetype );
+ DrawSpineText( $y_pos, $text_height, $fontsize, $x_pos,
+ $left_text_margin, $text_wrap_cols, \$item, \$conf_data );
+
+ CalcNextLabelPos();
+
+ } # correct
+ elsif ( $printingtype eq 'BIBBAR' ) {
+ drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
+ my $barcode_height = $label_height / 2;
+ DrawBarcode( $x_pos, $y_pos, $barcode_height, $label_width, $barcode,
+ $barcodetype );
+ DrawSpineText( $y_pos, $label_height, $fontsize, $x_pos,
+ $left_text_margin, $text_wrap_cols, \$item, \$conf_data );
- build_circ_barcode( $x_pos_circ1, $y_pos, $item->{'barcode'},
- $conf_data->{'barcodetype'} );
- build_circ_barcode( $x_pos_circ2, $y_pos, $item->{'barcode'},
- $conf_data->{'barcodetype'} );
+ CalcNextLabelPos();
+ }
+
+ elsif ( $printingtype eq 'ALT' ) {
+ drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
+ DrawBarcode( $x_pos, $y_pos, $label_height, $label_width, $barcode,
+ $barcodetype );
+ CalcNextLabelPos();
+ drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
+ DrawSpineText( $y_pos, $label_height, $fontsize, $x_pos,
+ $left_text_margin, $text_wrap_cols, \$item, \$conf_data );
+ CalcNextLabelPos();
}
- #-----------------draw spine text
- if ( $printingtype eq 'spine' || $printingtype eq 'both' ) {
- #warn "PRINTTYPE = $printingtype";
- # add your printable fields manually in here
- my @fields =
- qw (dewey isbn classification itemtype subclass itemcallnumber);
- my $vPos = ( $y_pos + ( $label_height - $top_text_margin ) );
- my $hPos = ( $x_pos_spine + $left_text_margin );
+ elsif ( $printingtype eq 'BIB' ) {
+ drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox;
+ DrawSpineText( $y_pos, $label_height, $fontsize, $x_pos,
+ $left_text_margin, $text_wrap_cols, \$item, \$conf_data );
+ CalcNextLabelPos();
+ }
-# chris's extra line fix, to clear top label margin.
- prText( $hPos, $vPos, "\n" );
- $vPos = $vPos - $line_spacer;
- foreach my $field (@fields) {
- # if the display option for this field is selected in the DB,
- # and the item record has some values for this field, display it.
- if ( $conf_data->{"$field"} && $item->{"$field"} ) {
- #warn "CONF_TYPE = $field";
- # get the string
- $str = $item->{"$field"};
- # strip out naughty existing nl/cr's
- $str =~ s/\n//g;
- $str =~ s/\r//g;
- # chop the string up into _upto_ 12 chunks
- # and seperate the chunks with newlines
- $str = wrap( "", "", "$str" );
- $str = wrap( "", "", "$str" );
- # split the chunks between newline's, into an array
- my @strings = split /\n/, $str;
- # then loop for each string line
- foreach my $str (@strings) {
- #warn "HPOS , VPOS $hPos, $vPos ";
- prText( $hPos, $vPos, $str );
- $vPos = $vPos - $line_spacer;
- }
- } # if field is valid
- } #foreach feild
+} # end for item loop
+prEnd();
+
+#
+#
+#
+#
+#
+sub CalcNextLabelPos {
+ if ( $colcount lt $label_cols ) {
+
+ # warn "new col";
+ $x_pos = ( $x_pos + $label_width + $colspace );
+ $colcount++;
}
- $y_pos = ( $y_pos - $label_height );
- #-----------------draw spine text
+ else {
+ $x_pos = $left_margin;
+ if ( $rowcount eq $label_rows ) {
- # the gaylord labels have 8 rows per sheet, this pagebreaks after 8 rows
- if ( $page_break_count == $label_rows ) {
+ # warn "new page";
prPage();
- $page_break_count = 0;
- $i2 = 0;
- $y_pos = $y_pos_initial;
+ $y_pos = ( $page_height - $top_margin - $label_height );
+ $rowcount = 1;
+ }
+ else {
+
+ # warn "new row";
+ $y_pos = ( $y_pos - $rowspace - $label_height );
+ $rowcount++;
+ }
+ $colcount = 1;
}
- $page_break_count++;
- $i2++;
}
-prEnd();
Index: label-print.pl
===================================================================
RCS file: /sources/koha/koha/barcodes/label-print.pl,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -b -r1.1.2.4 -r1.1.2.5
--- label-print.pl 20 Jul 2006 18:32:24 -0000 1.1.2.4
+++ label-print.pl 10 Jul 2007 10:54:04 -0000 1.1.2.5
@@ -68,45 +68,37 @@
#warn Dumper @resultsloop;
-
-
-
#------------------------------------------------------
#lets write barcode files to tmp dir for every item in @resultsloop
-
-
binmode(FILE);
-foreach my $item (@resultsloop){
+foreach my $item (@resultsloop) {
+ my $random = int( rand(100000000000) ) + 999999999999;
-my $random = int( rand(100000000000)) + 999999999999;
-#warn "$random\n";
+ #warn "$random\n";
$item->{'barcode'} = $random;
-# my $itembarcode = $item->{'barcode'};
-# warn $item->{'barcode'};
-
+ # my $itembarcode = $item->{'barcode'};
+ # warn $item->{'barcode'};
my $filename = "$htdocs_path/barcodes/$item->{'barcode'}.png";
+
#warn $filename;
- open(FILE, ">$filename");
+ open( FILE, ">$filename" );
- print FILE GD::Barcode->new('EAN13', $item->{'barcode'})->plot->png;
-# warn $GD::Barcode::errStr;
+ print FILE GD::Barcode->new( 'EAN13', $item->{'barcode'} )->plot->png;
+
+ # warn $GD::Barcode::errStr;
close(FILE);
-#warn Dumper $item->{'barcode'};
+ #warn Dumper $item->{'barcode'};
}
-
-
-
-
# lets pass the config setting
$template->param(
@@ -133,4 +125,3 @@
);
output_html_with_http_headers $query, $cookie, $template->output;
-
Index: label-add-layout.pl
===================================================================
RCS file: label-add-layout.pl
diff -N label-add-layout.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ label-add-layout.pl 10 Jul 2007 10:54:03 -0000 1.1.4.2
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Output;
+use C4::Labels;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use HTML::Template;
+
+#use Data::Dumper;
+#use Smart::Comments;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "barcodes/label-add-layout.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { catalogue => 1 },
+ debug => 1,
+ }
+);
+
+my $data = get_label_options();
+my $op = $query->param('op');
+
+my $active_template = GetActiveLabelTemplate();
+my @label_templates = GetAllLabelTemplates();
+my @printingtypes = get_printingtypes();
+my @layouts = get_layouts();
+my @barcode_types = get_barcode_types();
+my @batches = get_batches();
+
+if ($op = 'add_layout') {
+}
+
+
+
+
+### $data
+
+$template->param( guidebox => 1 ) if ( $data->{'guidebox'} );
+$template->param( "papertype_$data->{'papertype'}" => 1 );
+$template->param( "$data->{'barcodetype'}_checked" => 1 );
+$template->param( "startrow" . $data->{'startrow'} . "_checked" => 1 );
+
+$template->param(
+
+ op => $op,
+ active_template => $data->{'active_template'},
+ label_templates => address@hidden,
+ barcode_types => address@hidden,
+ printingtypes => address@hidden,
+layout_loop => address@hidden,
+
+batches => address@hidden,
+ id => $data->{'id'},
+ barcodetype => $data->{'barcodetype'},
+ papertype => $data->{'papertype'},
+
+ tx_author => $data->{'author'},
+ tx_barcode => $data->{'barcode'},
+ tx_title => $data->{'title'},
+ tx_isbn => $data->{'isbn'},
+ tx_issn => $data->{'issn'},
+ tx_itemtype => $data->{'itemtype'},
+ tx_dewey => $data->{'dewey'},
+ tx_class => $data->{'class'},
+ tx_subclass => $data->{'subclass'},
+ tx_itemcallnumber => $data->{'itemcallnumber'},
+
+ startlabel => $data->{'startlabel'},
+ fontsize => $active_template->{'fontsize'},
+
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
Index: label-create-template.pl
===================================================================
RCS file: label-create-template.pl
diff -N label-create-template.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ label-create-template.pl 10 Jul 2007 10:54:03 -0000 1.1.4.2
@@ -0,0 +1,105 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Context;
+use C4::Output;
+use C4::Labels;
+use C4::Interface::CGI::Output;
+use HTML::Template;
+use POSIX;
+
+#use Data::Dumper;
+
+my $dbh = C4::Context->dbh;
+my $query = new CGI;
+
+my $tmpl_code = $query->param('tmpl_code');
+my $tmpl_desc = $query->param('tmpl_desc');
+my $page_height = $query->param('page_height');
+my $page_width = $query->param('page_width');
+my $label_height = $query->param('label_height');
+my $label_width = $query->param('label_width');
+my $topmargin = $query->param('topmargin');
+my $leftmargin = $query->param('leftmargin');
+my $cols = $query->param('cols');
+my $rows = $query->param('rows');
+my $colgap = $query->param('colgap');
+my $rowgap = $query->param('rowgap');
+my $units = $query->param('units');
+my $fontsize = $query->param('fontsize');
+
+my $batch_id = $query->param('batch_id');
+
+
+my $op = $query->param('op');
+my @resultsloop;
+
+my ( $template, $loggedinuser, $cookie );
+
+if ( $op eq 'blank' ) {
+
+ my @units = (
+ { unit => 'INCH', desc => 'Inches' },
+ { unit => 'CM', desc => 'Centimeters' },
+ { unit => 'MM', desc => 'Millimeters' },
+ { unit => 'POINT', desc => 'Postscript Points' },
+ );
+
+ ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "barcodes/label-create-template.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 1,
+ flagsrequired => { catalogue => 1 },
+ debug => 1,
+ }
+ );
+
+ $template->param(
+ units => address@hidden,
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+ );
+
+}
+
+elsif ( $op eq 'create' ) {
+
+ ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "barcodes/label-templates.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 1,
+ flagsrequired => { catalogue => 1 },
+ debug => 1,
+ }
+ );
+
+ CreateTemplate(
+
+ $tmpl_code, $tmpl_desc, $page_width,
+ $page_height, $label_width, $label_height, $topmargin,
+ $leftmargin, $cols, $rows, $colgap,
+ $rowgap, $fontsize, $units
+
+ );
+
+ @resultsloop = GetAllLabelTemplates();
+
+ $template->param(
+ resultsloop => address@hidden,
+
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+ );
+
+}
+output_html_with_http_headers $query, $cookie, $template->output;
Index: label-edit-layout.pl
===================================================================
RCS file: label-edit-layout.pl
diff -N label-edit-layout.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ label-edit-layout.pl 10 Jul 2007 10:54:03 -0000 1.1.4.2
@@ -0,0 +1,85 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Context;
+use C4::Output;
+use C4::Labels;
+use C4::Interface::CGI::Output;
+use HTML::Template;
+use POSIX;
+
+#use Data::Dumper;
+#use Smart::Comments;
+
+my $dbh = C4::Context->dbh;
+my $query = new CGI;
+my $layout_id = $query->param('layout_id');
+
+### $query;
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "barcodes/label-edit-layout.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 1,
+ flagsrequired => { catalogue => 1 },
+ debug => 1,
+ }
+);
+
+my $layout = get_layout($layout_id);
+ my @barcode_types = get_barcode_types($layout_id);
+my @printingtypes = get_printingtypes($layout_id);
+### @printingtypes
+### $layout
+
+my $layoutname = $layout->{'layoutname'};
+my $layout_id = $layout->{'id'};
+my $guidebox = $layout->{'guidebox'};
+my $startlabel = $layout->{'startlabel'};
+
+my @title = build_text_dropbox( $layout->{'title'} );
+my @author = build_text_dropbox( $layout->{'author'} );
+my @barcode = build_text_dropbox( $layout->{'barcode'} );
+my @isbn = build_text_dropbox( $layout->{'isbn'} );
+my @issn = build_text_dropbox( $layout->{'issn'} );
+my @itemtype = build_text_dropbox( $layout->{'itemtype'} );
+my @dewey = build_text_dropbox( $layout->{'dewey'} );
+my @class = build_text_dropbox( $layout->{'class'} );
+my @subclass = build_text_dropbox( $layout->{'subclass'} );
+my @itemcallnumber = build_text_dropbox( $layout->{'itemcallnumber'} );
+
+
+### @subclass
+
+$template->param(
+ barcode_types => address@hidden,
+ printingtypes => address@hidden,
+
+ layoutname => $layoutname,
+ layout_id => $layout_id,
+
+guidebox => $guidebox,
+startlabel => $startlabel,
+
+ tx_title => address@hidden,
+ tx_author => address@hidden,
+ tx_isbn => address@hidden,
+ tx_issn => address@hidden,
+ tx_itemtype => address@hidden,
+ tx_dewey => address@hidden,
+ tx_barcode => address@hidden,
+ tx_classif => address@hidden,
+ tx_subclass => address@hidden,
+ tx_itemcallnumber => address@hidden,
+
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
Index: label-edit-template.pl
===================================================================
RCS file: label-edit-template.pl
diff -N label-edit-template.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ label-edit-template.pl 10 Jul 2007 10:54:04 -0000 1.1.4.2
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Context;
+use C4::Output;
+use C4::Labels;
+use C4::Interface::CGI::Output;
+use HTML::Template;
+use POSIX;
+
+# use Data::Dumper;
+
+my $dbh = C4::Context->dbh;
+my $query = new CGI;
+
+my $tmpl_id = $query->param('tmpl_id');
+
+my $width = $query->param('width');
+my $height = $query->param('height');
+my $topmargin = $query->param('topmargin');
+my $leftmargin = $query->param('leftmargin');
+my $columns = $query->param('columns');
+my $rows = $query->param('rows');
+my $colgap = $query->param('colgap');
+my $rowgap = $query->param('rowgap');
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "barcodes/label-edit-template.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 1,
+ flagsrequired => { catalogue => 1 },
+ debug => 1,
+ }
+);
+
+my $tmpl = GetSingleLabelTemplate($tmpl_id);
+
+my @units = (
+ { unit => 'INCH', desc => 'Inches' },
+ { unit => 'CM', desc => 'Centimeters' },
+ { unit => 'MM', desc => 'Millimeters' },
+ { unit => 'POINT', desc => 'Postscript Points' },
+);
+
+foreach my $unit (@units) {
+ if ( $unit->{'unit'} eq $tmpl->{'units'} ) {
+ $unit->{'selected'} = 1;
+ }
+}
+
+$template->param(
+
+ units => address@hidden,
+
+ tmpl_id => $tmpl->{'tmpl_id'},
+ tmpl_code => $tmpl->{'tmpl_code'},
+ tmpl_desc => $tmpl->{'tmpl_desc'},
+ page_width => $tmpl->{'page_width'},
+ page_height => $tmpl->{'page_height'},
+ label_width => $tmpl->{'label_width'},
+ label_height => $tmpl->{'label_height'},
+ topmargin => $tmpl->{'topmargin'},
+ leftmargin => $tmpl->{'leftmargin'},
+ cols => $tmpl->{'cols'},
+ rows => $tmpl->{'rows'},
+ colgap => $tmpl->{'colgap'},
+ rowgap => $tmpl->{'rowgap'},
+ fontsize => $tmpl->{'fontsize'},
+ active => $tmpl->{'active'},
+
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
Index: label-save-template.pl
===================================================================
RCS file: label-save-template.pl
diff -N label-save-template.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ label-save-template.pl 10 Jul 2007 10:54:04 -0000 1.1.4.2
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Context;
+use C4::Output;
+use C4::Labels;
+use C4::Interface::CGI::Output;
+use HTML::Template;
+use POSIX;
+
+#use Data::Dumper;
+
+my $dbh = C4::Context->dbh;
+my $query = new CGI;
+
+my $tmpl_id = $query->param('tmpl_id');
+my $tmpl_code = $query->param('tmpl_code');
+my $tmpl_desc = $query->param('tmpl_desc');
+my $page_height = $query->param('page_height');
+my $page_width = $query->param('page_width');
+my $label_height = $query->param('label_height');
+my $label_width = $query->param('label_width');
+my $topmargin = $query->param('topmargin');
+my $leftmargin = $query->param('leftmargin');
+my $cols = $query->param('cols');
+my $rows = $query->param('rows');
+my $colgap = $query->param('colgap');
+my $rowgap = $query->param('rowgap');
+my $fontsize = $query->param('fontsize');
+my $units = $query->param('units');
+my $active = $query->param('active');
+
+$active = 1 if ( $active == 'on' );
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "barcodes/label-templates.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 1,
+ flagsrequired => { catalogue => 1 },
+ debug => 1,
+ }
+);
+
+my @resultsloop;
+
+SaveTemplate(
+
+ $tmpl_id, $tmpl_code, $tmpl_desc, $page_width,
+ $page_height, $label_width, $label_height, $topmargin,
+ $leftmargin, $cols, $rows, $colgap,
+ $rowgap, $active, $fontsize, $units
+
+);
address@hidden = GetAllLabelTemplates();
+
+$template->param(
+ resultsloop => address@hidden,
+
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
Index: label-select-pdf.pl
===================================================================
RCS file: label-select-pdf.pl
diff -N label-select-pdf.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ label-select-pdf.pl 10 Jul 2007 10:54:04 -0000 1.1.4.2
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+use lib '/usr/local/opus-dev/intranet/modules';
+use C4::Context("/etc/koha-opus-dev.conf");
+
+use strict;
+use CGI;
+use C4::Labels;
+use C4::Auth;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use HTML::Template;
+
+use Data::Dumper;
+
+# get the printing settings
+my $conf_data = get_label_options();
+my $cgi = new CGI;
+
+my $papertype = $conf_data->{'papertype'};
+warn $papertype;
+
+if ( $papertype eq "Gaylord8511" ) {
+ warn "GAY";
+ print $cgi->redirect("/cgi-bin/koha/barcodes/label-print-pdf.pl");
+}
+elsif ( $papertype eq "OPUS-Dot Matrix" ) {
+ warn "OPUS labes";
+ print $cgi->redirect("/cgi-bin/koha/barcodes/label-print-opus-pdf.pl");
+}
+
Index: label-templates.pl
===================================================================
RCS file: label-templates.pl
diff -N label-templates.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ label-templates.pl 10 Jul 2007 10:54:05 -0000 1.1.4.2
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Context;
+use C4::Output;
+use C4::Labels;
+use C4::Interface::CGI::Output;
+use HTML::Template;
+use POSIX;
+
+#use Data::Dumper;
+
+my $dbh = C4::Context->dbh;
+my $query = new CGI;
+my $op = $query->param('op');
+my $tmpl_code = $query->param('tmpl_code');
+my $tmpl_id = $query->param('tmpl_id');
+
+
+my $width = $query->param('width');
+my $height = $query->param('height');
+my $topmargin = $query->param('topmargin');
+my $leftmargin = $query->param('leftmargin');
+my $columns = $query->param('columns');
+my $rows = $query->param('rows');
+my $colgap = $query->param('colgap');
+my $rowgap = $query->param('rowgap');
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "barcodes/label-templates.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 1,
+ flagsrequired => { catalogue => 1 },
+ debug => 1,
+ }
+);
+
+
+# little block for displaying active layout/template/batch in templates
+# ----------
+my $batch_id = $query->param('batch_id');
+my $active_layout = get_active_layout();
+my $active_template = GetActiveLabelTemplate();
+my $active_layout_name = $active_layout->{'layoutname'};
+my $active_template_name = $active_template->{'tmpl_code'};
+# ----------
+
+
+
+
+my @resultsloop;
+
+
+if ( $op eq 'set_active_template' ) {
+ SetActiveTemplate($tmpl_id);
+}
+
+elsif ( $op eq 'delete' ) {
+ DeleteTemplate($tmpl_id);
+}
+
+elsif ( $op eq 'save' ) {
+ SaveTemplate($tmpl_code);
+}
+
+ @resultsloop = GetAllLabelTemplates();
+
+$template->param(
+
+ batch_id => $batch_id,
+ active_layout_name => $active_layout_name,
+ active_template_name => $active_template_name,
+
+ resultsloop => address@hidden,
+
+ intranetcolorstylesheet =>
+ C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha/barcodes label-item-search.pl label-manage... [rel_2_2],
Mason James <=