Modifying Label Creation to handle no Printer Profile existence case.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Chris Nighswonger 2008-02-16 07:54:52 +13:00 committed by Joshua Ferraro
parent e09c0bb918
commit 668aabcab1
4 changed files with 33 additions and 19 deletions

View file

@ -73,7 +73,9 @@
<!-- /TMPL_LOOP --> <!-- /TMPL_LOOP -->
</select></li> </select></li>
<li><label for="prof_id">Profile: </label><select id="prof_id" name="prof_id"> <li><label for="prof_id">Profile: </label>
<!-- TMPL_IF NAME="proflist" -->
<select id="prof_id" name="prof_id">
<!-- TMPL_LOOP NAME="proflist" --> <!-- TMPL_LOOP NAME="proflist" -->
<!-- TMPL_IF NAME="selected" --> <!-- TMPL_IF NAME="selected" -->
<option value="<!-- TMPL_VAR NAME="prof_id" -->" selected="selected"> <option value="<!-- TMPL_VAR NAME="prof_id" -->" selected="selected">
@ -81,7 +83,11 @@
<option value="<!-- TMPL_VAR NAME="prof_id" -->"> <option value="<!-- TMPL_VAR NAME="prof_id" -->">
<!-- /TMPL_IF --><!-- TMPL_VAR NAME="printername" -->/<!-- TMPL_VAR NAME="paper_bin" --></option> <!-- /TMPL_IF --><!-- TMPL_VAR NAME="printername" -->/<!-- TMPL_VAR NAME="paper_bin" --></option>
<!-- /TMPL_LOOP --> <!-- /TMPL_LOOP -->
</select></li> </select>
<!-- TMPL_ELSE -->
None Defined
<!-- /TMPL_IF -->
</li>
<li><label for="fontsize">Font Size:</label> <input type="text" id="fontsize" name="fontsize" size="1" value="<!-- TMPL_VAR NAME="fontsize" -->" /></li> <li><label for="fontsize">Font Size:</label> <input type="text" id="fontsize" name="fontsize" size="1" value="<!-- TMPL_VAR NAME="fontsize" -->" /></li>

View file

@ -57,6 +57,10 @@ foreach my $prof (@prof) {
printername => $prof->{'printername'}, printername => $prof->{'printername'},
paper_bin => $prof->{'paper_bin'}} ); paper_bin => $prof->{'paper_bin'}} );
} }
elsif ( !$prof ) {
undef @proflist;
}
} }
my @units = ( my @units = (

View file

@ -127,27 +127,31 @@ drawbox( ($left_margin), ($top_margin), ($page_width-(2*$left_margin)), ($page_h
# Suggested proceedure: Adjust margins until both top and left margins are correct. Then adjust the label # 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). # 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; warn "Active profile: " . ($profile->{'prof_id'}?$profile->{'prof_id'}:"None") if $DEBUG;
if ( $DEBUG ) { if ( $DEBUG ) {
warn "-------------------------INITIAL VALUES-----------------------------"; warn "-------------------------INITIAL VALUES-----------------------------";
warn "top margin = $top_margin points\n"; warn "top margin = $top_margin points\n";
warn "left margin = $left_margin points\n"; warn "left margin = $left_margin points\n";
warn "label height = $label_height points\n"; warn "label height = $label_height points\n";
warn "label width = $label_width points\n"; warn "label width = $label_width points\n";
} }
$top_margin = $top_margin + $profile->{'offset_vert'}; # controls vertical offset if ( $profile->{'prof_id'} ) {
$label_height = $label_height + $profile->{'creep_vert'}; # controls vertical creep $top_margin = $top_margin + $profile->{'offset_vert'}; # controls vertical offset
$left_margin = $left_margin + $profile->{'offset_horz'}; # controls horizontal offset $label_height = $label_height + $profile->{'creep_vert'}; # controls vertical creep
$label_width = $label_width + $profile->{'creep_horz'}; # controls horizontal creep $left_margin = $left_margin + $profile->{'offset_horz'}; # controls horizontal offset
$label_width = $label_width + $profile->{'creep_horz'}; # controls horizontal creep
}
if ( $DEBUG ) { if ( $DEBUG && $profile->{'prof_id'} ) {
warn "-------------------------ADJUSTED VALUES-----------------------------"; warn "-------------------------ADJUSTED VALUES-----------------------------";
warn "top margin = $top_margin points\n"; warn "top margin = $top_margin points\n";
warn "left margin = $left_margin points\n"; warn "left margin = $left_margin points\n";
warn "label height = $label_height points\n"; warn "label height = $label_height points\n";
warn "label width = $label_width points\n"; warn "label width = $label_width points\n";
} elsif ( $DEBUG ) {
warn "No profile associated so no adjustment applied.";
} }
my $item; my $item;

View file

@ -43,7 +43,7 @@ SaveTemplate(
); );
SetAssociatedProfile( $prof_id, $tmpl_id ); SetAssociatedProfile( $prof_id, $tmpl_id ) if $prof_id;
print $query->redirect("./label-templates.pl"); print $query->redirect("./label-templates.pl");