From bc895d86267d0084cdd7df35617bb572a36d22e3 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Sat, 16 Feb 2008 07:54:50 +1300 Subject: [PATCH] Adding Printer Profiles feature to the Label Creator. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Labels.pm | 168 +++++++++++++++++- installer/data/mysql/kohastructure.sql | 32 ++++ installer/data/mysql/updatedatabase.pl | 26 +++ .../prog/en/includes/labels-menu.inc | 3 +- .../prog/en/includes/tools-labels-toolbar.inc | 6 +- .../en/modules/labels/label-templates.tmpl | 4 +- kohaversion.pl | 2 +- labels/label-create-profile.pl | 103 +++++++++++ labels/label-edit-profile.pl | 88 +++++++++ labels/label-edit-template.pl | 24 ++- labels/label-print-pdf.pl | 52 +++++- labels/label-profiles.pl | 50 ++++++ labels/label-save-profile.pl | 33 ++++ labels/label-save-template.pl | 5 +- 14 files changed, 582 insertions(+), 14 deletions(-) create mode 100755 labels/label-create-profile.pl create mode 100755 labels/label-edit-profile.pl create mode 100755 labels/label-profiles.pl create mode 100755 labels/label-save-profile.pl diff --git a/C4/Labels.pm b/C4/Labels.pm index f78310dd67..7a1d60bef0 100644 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -52,9 +52,14 @@ BEGIN { &delete_layout &get_active_layout &get_highest_batch &deduplicate_batch + &GetAllPrinterProfiles &GetSinglePrinterProfile + &SaveProfile &CreateProfile &DeleteProfile + &GetAssociatedProfile &SetAssociatedProfile ); } +my $DEBUG = 0; + =head1 NAME C4::Labels - Functions for printing spine labels and barcodes in Koha @@ -558,6 +563,164 @@ sub save_layout { return; } +=item GetAllPrinterProfiles; + + @profiles = GetAllPrinterProfiles() + +Returns an array of references-to-hash, whos keys are ..... + +=cut + +sub GetAllPrinterProfiles { + + my $dbh = C4::Context->dbh; + my @data; + my $query = "SELECT * FROM printers_profile AS pp INNER JOIN labels_templates AS lt ON pp.tmpl_id = lt.tmpl_id; "; + my $sth = $dbh->prepare($query); + $sth->execute(); + my @resultsloop; + while ( my $data = $sth->fetchrow_hashref ) { + push( @resultsloop, $data ); + } + $sth->finish; + + return @resultsloop; +} + +=item GetSinglePrinterProfile; + + $profile = GetSinglePrinterProfile() + +Returns a hashref whos keys are... + +=cut + +sub GetSinglePrinterProfile { + my ($prof_id) = @_; + my $dbh = C4::Context->dbh; + my $query = " SELECT * FROM printers_profile WHERE prof_id = ?; "; + my $sth = $dbh->prepare($query); + $sth->execute($prof_id); + my $template = $sth->fetchrow_hashref; + $sth->finish; + return $template; +} + +=item SaveProfile; + + SaveProfile('parameters') + +When passed a set of parameters, this function updates the given profile with the new parameters. + +=cut + +sub SaveProfile { + my ( + $prof_id, $offset_horz, $offset_vert, $creep_horz, $creep_vert, $units + ) = @_; + my $dbh = C4::Context->dbh; + my $query = + " UPDATE printers_profile + SET offset_horz=?, offset_vert=?, creep_horz=?, creep_vert=?, unit=? + WHERE prof_id = ? "; + my $sth = $dbh->prepare($query); + $sth->execute( + $offset_horz, $offset_vert, $creep_horz, $creep_vert, $units, $prof_id + ); + $sth->finish; +} + +=item CreateProfile; + + CreateProfile('parameters') + +When passed a set of parameters, this function creates a new profile containing those parameters +and returns any errors. + +=cut + +sub CreateProfile { + my ( + $prof_id, $printername, $paper_bin, $tmpl_id, $offset_horz, + $offset_vert, $creep_horz, $creep_vert, $units + ) = @_; + my $dbh = C4::Context->dbh; + my $query = + " INSERT INTO printers_profile (prof_id, printername, paper_bin, tmpl_id, + offset_horz, offset_vert, creep_horz, creep_vert, unit) + VALUES(?,?,?,?,?,?,?,?,?) "; + my $sth = $dbh->prepare($query); + $sth->execute( + $prof_id, $printername, $paper_bin, $tmpl_id, $offset_horz, + $offset_vert, $creep_horz, $creep_vert, $units + ); + my $error = $sth->errstr; + $sth->finish; + return $error; +} + +=item DeleteProfile; + + DeleteProfile(prof_id) + +When passed a profile id, this function deletes that profile from the database and returns any errors. + +=cut + +sub DeleteProfile { + my ($prof_id) = @_; + my $dbh = C4::Context->dbh; + my $query = " DELETE FROM printers_profile WHERE prof_id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($prof_id); + my $error = $sth->errstr; + $sth->finish; + return $error; +} + +=item GetAssociatedProfile; + + $assoc_prof = GetAssociatedProfile(tmpl_id) + +When passed a template id, this function returns the parameters from the currently associated printer profile +in a hashref where key=fieldname and value=fieldvalue. + +=cut + +sub GetAssociatedProfile { + my ($tmpl_id) = @_; + my $dbh = C4::Context->dbh; + # First we find out the prof_id for the associated profile... + my $query = "SELECT * FROM labels_profile WHERE tmpl_id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($tmpl_id); + my $assoc_prof = $sth->fetchrow_hashref; + $sth->finish; + # Then we retrieve that profile and return it to the caller... + $assoc_prof = GetSinglePrinterProfile($assoc_prof->{'prof_id'}); + return $assoc_prof; +} + +=item SetAssociatedProfile; + + SetAssociatedProfile($prof_id, $tmpl_id) + +When passed both a profile id and template id, this function establishes an association between the two. No more +than one profile may be associated with any given template at the same time. + +=cut + +sub SetAssociatedProfile { + + my ($prof_id, $tmpl_id) = @_; + + my $dbh = C4::Context->dbh; + my $query = "INSERT INTO labels_profile (prof_id, tmpl_id) VALUES (?,?) ON DUPLICATE KEY UPDATE prof_id = ?"; + my $sth = $dbh->prepare($query); + $sth->execute($prof_id, $tmpl_id, $prof_id); + $sth->finish; +} + =item get_label_items; $options = get_label_items() @@ -875,9 +1038,8 @@ sub DrawBarcode { my $moo2 = $tot_bar_length * $xsize_ratio; - warn " $x_pos, $y_pos, $barcode, $barcodetype\n"; - warn -"BAR_WDTH = $bar_width, TOT.BAR.LGHT=$tot_bar_length R*TOT.BAR =$moo2 \n"; + warn "$x_pos, $y_pos, $barcode, $barcodetype" if $DEBUG; + warn "BAR_WDTH = $bar_width, TOT.BAR.LGHT=$tot_bar_length R*TOT.BAR =$moo2" if $DEBUG; } =item build_circ_barcode; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 40d9768d20..42f42a30b6 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1123,6 +1123,18 @@ CREATE TABLE `labels_conf` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `labels_profile` +-- + +DROP TABLE IF EXISTS `labels_profile`; +CREATE TABLE `labels_profile` ( + `tmpl_id` int(4) NOT NULL, + `prof_id` int(4) NOT NULL, + UNIQUE KEY `tmpl_id` (`tmpl_id`), + UNIQUE KEY `prof_id` (`prof_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- -- Table structure for table `labels_templates` -- @@ -1388,6 +1400,26 @@ CREATE TABLE `printers` ( PRIMARY KEY (`printername`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `printers_profile` +-- + +DROP TABLE IF EXISTS `printers_profile`; +CREATE TABLE `printers_profile` ( + `prof_id` int(4) NOT NULL auto_increment, + `printername` varchar(40) NOT NULL, + `tmpl_id` int(4) NOT NULL, + `paper_bin` varchar(20) NOT NULL, + `offset_horz` float default NULL, + `offset_vert` float default NULL, + `creep_horz` float default NULL, + `creep_vert` float default NULL, + `unit` char(20) NOT NULL default 'POINT', + PRIMARY KEY (`prof_id`), + UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`), + CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- -- Table structure for table `repeatable_holidays` -- diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 0a68226d90..c11e66d60c 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -988,6 +988,32 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.00.053"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("CREATE TABLE `printers_profile` ( + `prof_id` int(4) NOT NULL auto_increment, + `printername` varchar(40) NOT NULL, + `tmpl_id` int(4) NOT NULL, + `paper_bin` varchar(20) NOT NULL, + `offset_horz` float default NULL, + `offset_vert` float default NULL, + `creep_horz` float default NULL, + `creep_vert` float default NULL, + `unit` char(20) NOT NULL default 'POINT', + PRIMARY KEY (`prof_id`), + UNIQUE KEY `printername` (`printername`,`tmpl_id`,`paper_bin`), + CONSTRAINT `printers_profile_pnfk_1` FOREIGN KEY (`tmpl_id`) REFERENCES `labels_templates` (`tmpl_id`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 "); + $dbh->do("CREATE TABLE `labels_profile` ( + `tmpl_id` int(4) NOT NULL, + `prof_id` int(4) NOT NULL, + UNIQUE KEY `tmpl_id` (`tmpl_id`), + UNIQUE KEY `prof_id` (`prof_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 "); + print "Upgrade to $DBversion done ( Printer Profile tables added )\n"; + SetVersion ($DBversion); +} + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-menu.inc index 08b4508eea..bb66506078 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-menu.inc @@ -1,5 +1,6 @@ \ No newline at end of file + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-labels-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-labels-toolbar.inc index e303223de3..7a19c52111 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-labels-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-labels-toolbar.inc @@ -12,8 +12,9 @@ function yuiToolbar() { new YAHOO.widget.Button("newlabel"); - new YAHOO.widget.Button("newtemplate"); - new YAHOO.widget.Button("newbatch"); + new YAHOO.widget.Button("newtemplate"); + new YAHOO.widget.Button("newprofile"); + new YAHOO.widget.Button("newbatch"); } //]]> @@ -21,5 +22,6 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-templates.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-templates.tmpl index e62fa32435..868750c638 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-templates.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-templates.tmpl @@ -5,7 +5,7 @@ - +
@@ -67,4 +67,4 @@
- \ No newline at end of file + diff --git a/kohaversion.pl b/kohaversion.pl index 5b5605cb04..10af996790 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = "3.00.00.052"; + our $VERSION = "3.00.00.053"; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install diff --git a/labels/label-create-profile.pl b/labels/label-create-profile.pl new file mode 100755 index 0000000000..f2eb49a89a --- /dev/null +++ b/labels/label-create-profile.pl @@ -0,0 +1,103 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Context; +use C4::Output; +use C4::Labels; +use HTML::Template::Pro; +use POSIX; + +use Data::Dumper; +#use Smart::Comments; + +my $dbh = C4::Context->dbh; +my $query = new CGI; +### $query + +my $op = $query->param('op'); + +my $prof_id = $query->param('prof_id'); +my $printername = $query->param('printername'); +my $paper_bin = $query->param('paper_bin'); +my $tmpl_id = $query->param('tmpl_id'); +my $offset_horz = $query->param('offset_horz'); +my $offset_vert = $query->param('offset_vert'); +my $creep_horz = $query->param('creep_horz'); +my $creep_vert = $query->param('creep_vert'); +my $units = $query->param('unit'); + +my @resultsloop; +my @tmpllist; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "labels/label-create-profile.tmpl", + query => $query, + type => "intranet", + authnotrequired => 1, + flagsrequired => { catalogue => 1 }, + debug => 1, + } + ); + +if ( $op eq 'blank' || $op eq '' ) { + + my @units = ( + { unit => 'INCH', desc => 'Inches' }, + { unit => 'CM', desc => 'Centimeters' }, + { unit => 'MM', desc => 'Millimeters' }, + { unit => 'POINT', desc => 'Postscript Points' }, + ); + + my @tmpl = GetAllLabelTemplates(); + + foreach my $data (@tmpl) { + push ( @tmpllist, {tmpl_id => $data->{'tmpl_id'}, + tmpl_code => $data->{'tmpl_code'}} ); + } + + $template->param( + tmpllist => \@tmpllist, + unit => \@units, + ); + +} + +elsif ( $op eq 'Save' ) { + my $errmsg; + my $dberror = CreateProfile( + $prof_id, $printername, $paper_bin, $tmpl_id, $offset_horz, + $offset_vert, $creep_horz, $creep_vert, $units + ); + unless ( $dberror ) { + print $query->redirect("./label-profiles.pl"); + exit; + } + + # FIXME: This exposes all CGI vars. Surely there is a better way to do it? -fbcit + if ( $dberror =~ /Duplicate/ && $dberror =~ /$paper_bin/ ) { + $errmsg = "You cannot create duplicate profiles for $printername/$paper_bin. + Click the Back button on your browser and enter a different paper bin + for $printername."; + } + + else { + $errmsg = $dberror; + } + + $template->param ( + dberror => $dberror, + errmsg => $errmsg, + ); + + warn "DB error: $dberror"; +} + +elsif ( $op eq 'Cancel' ) { + print $query->redirect("./label-profiles.pl"); + exit; +} + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/labels/label-edit-profile.pl b/labels/label-edit-profile.pl new file mode 100755 index 0000000000..4643b1c9b2 --- /dev/null +++ b/labels/label-edit-profile.pl @@ -0,0 +1,88 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Context; +use C4::Output; +use C4::Labels; +use HTML::Template::Pro; +use POSIX; + +my $DEBUG = 0; +my $dbh = C4::Context->dbh; +my $query = new CGI; + +my $op = $query->param('op'); +my $prof_id = $query->param('prof_id'); +my $offset_horz = $query->param('offset_horz'); +my $offset_vert = $query->param('offset_vert'); +my $creep_horz = $query->param('creep_horz'); +my $creep_vert = $query->param('creep_vert'); +my $units = $query->param('unit'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "labels/label-edit-profile.tmpl", + query => $query, + type => "intranet", + authnotrequired => 1, + flagsrequired => { catalogue => 1 }, + debug => 1, + } +); + +if ($op eq '' || undef) { + my $prof = GetSinglePrinterProfile($prof_id); + + my $tmpl = GetSingleLabelTemplate($prof->{'tmpl_id'}); + + if ( $DEBUG ) { + use Data::Dumper; + warn Dumper($prof); + warn Dumper($tmpl); + } + + 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 $prof->{'unit'} ) { + $unit->{'selected'} = 1; + } + } + + $template->param( + + units => \@units, + + prof_id => $prof->{'prof_id'}, + printername => $prof->{'printername'}, + paper_bin => $prof->{'paper_bin'}, + tmpl_code => $tmpl->{'tmpl_code'}, + prof_code => $prof->{'prof_code'}, + offset_horz => $prof->{'offset_horz'}, + offset_vert => $prof->{'offset_vert'}, + creep_horz => $prof->{'creep_horz'}, + creep_vert => $prof->{'creep_vert'}, + ); +} + +elsif ($op eq 'Save') { + warn "Units are now $units"; + + SaveProfile( $prof_id, $offset_horz, $offset_vert, $creep_horz, $creep_vert, $units ); + print $query->redirect("./label-profiles.pl"); + exit; +} + +elsif ($op eq 'Cancel') { + print $query->redirect("./label-profiles.pl"); + exit; +} + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/labels/label-edit-template.pl b/labels/label-edit-template.pl index 1cc6804fe2..5f0bf9451a 100755 --- a/labels/label-edit-template.pl +++ b/labels/label-edit-template.pl @@ -24,6 +24,7 @@ my $columns = $query->param('columns'); my $rows = $query->param('rows'); my $colgap = $query->param('colgap'); my $rowgap = $query->param('rowgap'); +my $prof_id = $query->param('prof_id'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -37,6 +38,26 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); my $tmpl = GetSingleLabelTemplate($tmpl_id); +my $curprof = GetAssociatedProfile($tmpl_id); +my @prof = GetAllPrinterProfiles(); +my @proflist; + +# Generate an array of hashes containing possible profiles for given template and mark the currently associated one... + +foreach my $prof (@prof) { + if ( $prof->{'tmpl_id'} eq $tmpl->{'tmpl_id'} && $prof->{'prof_id'} eq $curprof->{'prof_id'} ) { + push ( @proflist, {prof_id => $prof->{'prof_id'}, + printername => $prof->{'printername'}, + paper_bin => $prof->{'paper_bin'}, + selected => 1} ); + } + + elsif ( $prof->{'tmpl_id'} eq $tmpl->{'tmpl_id'} ) { + push ( @proflist, {prof_id => $prof->{'prof_id'}, + printername => $prof->{'printername'}, + paper_bin => $prof->{'paper_bin'}} ); + } +} my @units = ( { unit => 'INCH', desc => 'Inches' }, @@ -53,7 +74,8 @@ foreach my $unit (@units) { $template->param( - units => \@units, + proflist => \@proflist, + units => \@units, tmpl_id => $tmpl->{'tmpl_id'}, tmpl_code => $tmpl->{'tmpl_code'}, diff --git a/labels/label-print-pdf.pl b/labels/label-print-pdf.pl index efdbed86ca..2abacd6097 100755 --- a/labels/label-print-pdf.pl +++ b/labels/label-print-pdf.pl @@ -13,6 +13,9 @@ use POSIX; #use C4::Labels; #use Smart::Comments; +my $DEBUG = 0; +my $DEBUG_LPT = 0; + my $htdocs_path = C4::Context->config('intrahtdocs'); my $cgi = new CGI; print $cgi->header( -type => 'application/pdf', -attachment => 'barcode.pdf' ); @@ -24,6 +27,7 @@ my $spine_text = ""; # get the printing settings my $template = GetActiveLabelTemplate(); my $conf_data = get_label_options(); +my $profile = GetAssociatedProfile($template->{'tmpl_id'}); my $batch_id = $cgi->param('batch_id'); my @resultsloop = get_label_items($batch_id); @@ -34,6 +38,10 @@ my $barcodetype = $conf_data->{'barcodetype'}; my $printingtype = $conf_data->{'printingtype'}; my $guidebox = $conf_data->{'guidebox'}; my $start_label = $conf_data->{'startlabel'}; +if ($cgi->param('startlabel')) { + $start_label = $cgi->param('startlabel'); # A bit of a hack to allow setting the starting label from the address bar... -fbcit + } +warn "Starting on label #$start_label" if $DEBUG; my $fontsize = $template->{'fontsize'}; my $units = $template->{'units'}; @@ -56,6 +64,8 @@ my $units = 'POINTS' my $unitvalue = GetUnitsValue($units); +warn "Template units: $units which converts to $unitvalue PostScript Points" if $DEBUG; + my $tmpl_code = $template->{'tmpl_code'}; my $tmpl_desc = $template->{'tmpl_desc'}; @@ -70,11 +80,15 @@ my $left_margin = ( $template->{'leftmargin'} * $unitvalue ); my $colspace = ( $template->{'colgap'} * $unitvalue ); my $rowspace = ( $template->{'rowgap'} * $unitvalue ); +warn "Converted dimensions are:" if $DEBUG; +warn "pghth=$page_height, pgwth=$page_width, lblhth=$label_height, lblwth=$label_width, spinwth=$spine_width, circwth=$circ_width, tpmar=$top_margin, lmar=$left_margin, colsp=$colspace, rowsp=$rowspace" if $DEBUG; + my $label_cols = $template->{'cols'}; my $label_rows = $template->{'rows'}; my $text_wrap_cols = GetTextWrapCols( $fontsize, $label_width ); + #warn $label_cols, $label_rows; # set the paper size @@ -103,7 +117,38 @@ my $str; my $codetype; # = 'Code39'; #do page border -#drawbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY ); +# drawbox( $lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY ); + +# draw margin box for alignment page +drawbox( ($left_margin), ($top_margin), ($page_width-(2*$left_margin)), ($page_height-(2*$top_margin)) ) if $DEBUG_LPT; + +# Adjustments for image position and creep -fbcit +# NOTE: *All* of these factor in to image position and creep. Keep this in mind when makeing adjustments. +# Suggested proceedure: Adjust margins until both top and left margins are correct. Then adjust the label +# height and width to correct label creep across and down page. Units are PostScript Points (72 per inch). + +warn "Active profile: $profile->{'prof_id'}" if $DEBUG; + +if ( $DEBUG ) { +warn "-------------------------INITIAL VALUES-----------------------------"; +warn "top margin = $top_margin points\n"; +warn "left margin = $left_margin points\n"; +warn "label height = $label_height points\n"; +warn "label width = $label_width points\n"; +} + +$top_margin = $top_margin + $profile->{'offset_vert'}; # controls vertical offset +$label_height = $label_height + $profile->{'creep_vert'}; # controls vertical creep +$left_margin = $left_margin + $profile->{'offset_horz'}; # controls horizontal offset +$label_width = $label_width + $profile->{'creep_horz'}; # controls horizontal creep + +if ( $DEBUG ) { +warn "-------------------------ADJUSTED VALUES-----------------------------"; +warn "top margin = $top_margin points\n"; +warn "left margin = $left_margin points\n"; +warn "label height = $label_height points\n"; +warn "label width = $label_width points\n"; +} my $item; my ( $i, $i2 ); # loop counters @@ -140,6 +185,9 @@ else { $y_pos = $page_height - $top_margin - ( $label_height * $rowcount ) - ( $rowspace * ( $rowcount - 1 ) ); + warn "Start label specified: $start_label Beginning in row $rowcount, column $colcount" if $DEBUG; + warn "X position = $x_pos Y position = $y_pos" if $DEBUG; + warn "Rowspace = $rowspace Label height = $label_height" if $DEBUG; } #warn "ROW COL $rowcount, $colcount"; @@ -151,7 +199,7 @@ else { # foreach $item (@resultsloop) { -# warn "$x_pos, $y_pos, $label_width, $label_height"; + warn "Label parameters: xpos=$x_pos, ypos=$y_pos, lblwid=$label_width, lblhig=$label_height" if $DEBUG; my $barcode = $item->{'barcode'}; if ( $printingtype eq 'BAR' ) { drawbox( $x_pos, $y_pos, $label_width, $label_height ) if $guidebox; diff --git a/labels/label-profiles.pl b/labels/label-profiles.pl new file mode 100755 index 0000000000..2cc9893b00 --- /dev/null +++ b/labels/label-profiles.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Context; +use C4::Output; +use C4::Labels; +use HTML::Template::Pro; +use POSIX; + + +my $dbh = C4::Context->dbh; +my $query = new CGI; +my $op = $query->param('op'); +#my $prof_code = $query->param('prof_code'); +my $prof_id = $query->param('prof_id'); +#my $printername = $query->param('printername'); +#my $tmpl_id = $query->param('tmpl_id'); +#my $paper_bin = $query->param('paper_bin'); +#my $offset_horz = $query->param('offset_horz'); +#my $offset_vert = $query->param('offset_vert'); +#my $creep_horz = $query->param('creep_horz'); +#my $creep_vert = $query->param('creep_vert'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "labels/label-profiles.tmpl", + query => $query, + type => "intranet", + authnotrequired => 1, + flagsrequired => { catalogue => 1 }, + debug => 1, + } +); + +my @resultsloop; + +if ( $op eq 'delete' ) { + my $dberror = DeleteProfile($prof_id); + warn "DB returned error: $dberror" if $dberror; +} + +@resultsloop = GetAllPrinterProfiles(); + +$template->param( + resultsloop => \@resultsloop, +); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/labels/label-save-profile.pl b/labels/label-save-profile.pl new file mode 100755 index 0000000000..dab3ca5e43 --- /dev/null +++ b/labels/label-save-profile.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Context; +use C4::Output; +use C4::Labels; +use HTML::Template::Pro; +use POSIX; + +#use Data::Dumper; +#use Smart::Comments; + + +my $dbh = C4::Context->dbh; +my $query = new CGI; + +my $prof_id = $query->param('prof_id'); +my $offset_horz = $query->param('offset_horz'); +my $offset_vert = $query->param('offset_vert'); +my $creep_horz = $query->param('creep_horz'); +my $creep_vert = $query->param('creep_vert'); +my $units = $query->param('unit'); + +SaveProfile( + $prof_id, $offset_horz, $offset_vert, $creep_horz, $creep_vert, $units +); + + + print $query->redirect("./label-profiles.pl"); + + diff --git a/labels/label-save-template.pl b/labels/label-save-template.pl index 4a5192cca6..b4d362ae66 100755 --- a/labels/label-save-template.pl +++ b/labels/label-save-template.pl @@ -32,7 +32,7 @@ my $rowgap = $query->param('rowgap'); my $fontsize = $query->param('fontsize'); my $units = $query->param('units'); my $active = $query->param('active'); - +my $prof_id = $query->param('prof_id'); SaveTemplate( @@ -43,7 +43,8 @@ SaveTemplate( ); +SetAssociatedProfile( $prof_id, $tmpl_id ); - print $query->redirect("./label-templates.pl"); +print $query->redirect("./label-templates.pl"); -- 2.39.5