Bug 10811 - Add a 999$c record matching rule to the MARC21 defaults
[koha_fer] / acqui / pdfformat / layout2pages.pm
old mode 100755 (executable)
new mode 100644 (file)
index 5614800..66e2ba0
@@ -82,24 +82,24 @@ sub printorders {
     
     my $abaskets;
     my $arrbasket;
-    my @keys = ('Basket (N°)','Document','Qty','RRT GST Inc.','Discount','Discount price GST Exc.','GST', 'Total GST Inc.'); 
+    my @keys = ('Basket (No.)', 'Document', 'Qty', 'RRP tax inc.', 'Discount', 'GST', 'Total tax exc.', 'Total tax inc.');
     for my $bkey (@keys) {
         push(@$arrbasket, $bkey);
     }
     push(@$abaskets, $arrbasket);
-    
+
     for my $basket (@$baskets){
         for my $line (@{$orders->{$basket->{basketno}}}) {
             $arrbasket = undef;
-            push( @$arrbasket, 
-                $basket->{basketno}, 
-                @$line[3]." / ".@$line[2].(@$line[0]?" ISBN : ".@$line[0]:'').(@$line[10]?" EN : ".@$line[10]:'').", ".@$line[1].(@$line[4]?' publié par '.@$line[4]:''), 
-                @$line[5],
-                $num->format_price(@$line[6]),
-                $num->format_price(@$line[8]).'%',
-                $num->format_price(@$line[7]/(1+@$line[9]/100)),
-                $num->format_price(@$line[9]).'%',
-                $num->format_price($num->round(@$line[7])*@$line[5])
+            push( @$arrbasket,
+                $basket->{basketno},
+                $line->{title} . " / " . $line->{author} . ( $line->{isbn} ? " ISBN : " . $line->{isbn} : '' ) . ( $line->{en} ? " EN : " . $line->{en} : '' ) . ", " . $line->{itemtype} . ( $line->{publishercode} ? ' published by '. $line->{publishercode} : ""),
+                $line->{quantity},
+                $num->format_price($line->{rrpgsti}),
+                $num->format_price($line->{discount}).'%',
+                $num->format_price($line->{gstrate} * 100).'%',
+                $num->format_price($line->{totalgste}),
+                $num->format_price($line->{totalgsti}),
             );
             push(@$abaskets, $arrbasket);
         }
@@ -146,6 +146,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;
 
@@ -211,13 +212,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});
 }
@@ -236,9 +247,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/layout2pages.pdf';
+    my $pdf = PDF::API2->open($pdf_template);
     $pdf->pageLabel( 0, {
         -style => 'roman',
     } ); # start with roman numbering