Merge remote-tracking branch 'origin/new/bug_5327'
[koha_fer] / acqui / pdfformat / layout3pages.pm
old mode 100755 (executable)
new mode 100644 (file)
index 50f4365..7dab18f
@@ -16,9 +16,9 @@
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 #you can use any PDF::API2 module, all you need to do is return the stringifyed pdf object from the printpdf sub.
 package pdfformat::layout3pages;
@@ -283,6 +283,7 @@ sub printhead {
     # get branch details
     my $billingdetails  = GetBranchDetail( $basketgroup->{billingplace} );
     my $deliverydetails = GetBranchDetail( $basketgroup->{deliveryplace} );
+    my $freedeliveryplace = $basketgroup->{freedeliveryplace};
     # get the subject
     my $subject;
 
@@ -348,13 +349,23 @@ sub printhead {
     # print delivery infos
     $text->font( $pdf->corefont("Times-Bold", -encoding => "utf8"), 4/mm );
     $text->translate(50/mm,  ($height-237)/mm);
-    $text->text($deliverydetails->{branchaddress1});
-    $text->translate(50/mm,  ($height-242)/mm);
-    $text->text($deliverydetails->{branchaddress2});
-    $text->translate(50/mm,  ($height-247)/mm);
-    $text->text($deliverydetails->{branchaddress3});
-    $text->translate(50/mm,  ($height-252)/mm);
-    $text->text(join(' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry}));
+    if ($freedeliveryplace) {
+        my $start = 242;
+        my @fdp = split('\n', $freedeliveryplace);
+        foreach (@fdp) {
+            $text->text($_);
+            $text->translate( 50 / mm, ( $height - $start ) / mm );
+            $start += 5;
+        }
+    } else {
+        $text->text($deliverydetails->{branchaddress1});
+        $text->translate(50/mm,  ($height-242)/mm);
+        $text->text($deliverydetails->{branchaddress2});
+        $text->translate(50/mm,  ($height-247)/mm);
+        $text->text($deliverydetails->{branchaddress3});
+        $text->translate(50/mm,  ($height-252)/mm);
+        $text->text(join(' ', $deliverydetails->{branchzip}, $deliverydetails->{branchcity}, $deliverydetails->{branchcountry}));
+    }
     $text->translate(50/mm,  ($height-262)/mm);
     $text->text($basketgroup->{deliverycomment});
 }
@@ -373,9 +384,8 @@ sub printfooters {
 sub printpdf {
     my ($basketgroup, $bookseller, $baskets, $orders, $GST) = @_;
     # open the default PDF that will be used for base (1st page already filled)
-    my $template = C4::Context->preference("OrderPdfTemplate");
-    $template = decode_base64($template);
-    my $pdf = PDF::API2->openScalar($template);
+    my $pdf_template = C4::Context->config('intrahtdocs') . '/' . C4::Context->preference('template') . '/pdf/layout3pages.pdf';
+    my $pdf = PDF::API2->open($pdf_template);
     $pdf->pageLabel( 0, {
         -style => 'roman',
     } ); # start with roman numbering