From 668aabcab1086b238715d1421ec662f5cf13ac73 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Sat, 16 Feb 2008 07:54:52 +1300 Subject: [PATCH] Modifying Label Creation to handle no Printer Profile existence case. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- .../modules/labels/label-edit-template.tmpl | 10 ++++-- labels/label-edit-template.pl | 4 +++ labels/label-print-pdf.pl | 36 ++++++++++--------- labels/label-save-template.pl | 2 +- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-template.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-template.tmpl index f03af70e16..a0615a0717 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-template.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-template.tmpl @@ -73,7 +73,9 @@ -
  • -
  • + + + None Defined + +
  • " />
  • diff --git a/labels/label-edit-template.pl b/labels/label-edit-template.pl index 5f0bf9451a..0cb2ae6dff 100755 --- a/labels/label-edit-template.pl +++ b/labels/label-edit-template.pl @@ -57,6 +57,10 @@ foreach my $prof (@prof) { printername => $prof->{'printername'}, paper_bin => $prof->{'paper_bin'}} ); } + + elsif ( !$prof ) { + undef @proflist; + } } my @units = ( diff --git a/labels/label-print-pdf.pl b/labels/label-print-pdf.pl index 2abacd6097..79e01c9aa7 100755 --- a/labels/label-print-pdf.pl +++ b/labels/label-print-pdf.pl @@ -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 # 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 ) { -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"; + 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 ( $profile->{'prof_id'} ) { + $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"; +if ( $DEBUG && $profile->{'prof_id'} ) { + 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"; +} elsif ( $DEBUG ) { + warn "No profile associated so no adjustment applied."; } my $item; diff --git a/labels/label-save-template.pl b/labels/label-save-template.pl index b4d362ae66..b8e477b179 100755 --- a/labels/label-save-template.pl +++ b/labels/label-save-template.pl @@ -43,7 +43,7 @@ SaveTemplate( ); -SetAssociatedProfile( $prof_id, $tmpl_id ); +SetAssociatedProfile( $prof_id, $tmpl_id ) if $prof_id; print $query->redirect("./label-templates.pl"); -- 2.20.1