Rerun of implemented Selectable Print Orientation (Portrait, Landscape) for all repor...
[fa-stable.git] / reporting / rep107.php
index 9220166b4fdbd8a48338a17ab3dd4b66f8601215..a1d36e845e61ae3a0b6009562d26a1305410973d 100644 (file)
@@ -61,9 +61,11 @@ function print_invoices()
        $email = $_POST['PARAM_3'];
        $pay_service = $_POST['PARAM_4'];
        $comments = $_POST['PARAM_5'];
+       $orientation = $_POST['PARAM_6'];
 
        if (!$from || !$to) return;
 
+       $orientation = ($orientation ? 'L' : 'P');
        $dec = user_price_dec();
 
        $fno = explode("-", $from);
@@ -82,7 +84,9 @@ function print_invoices()
        $cur = get_company_Pref('curr_default');
 
        if ($email == 0)
-               $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize());
+               $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation);
+    if ($orientation == 'L')
+       recalculate_cols($cols);
 
        $range = get_invoice_range($from, $to);
        while($row = db_fetch($range))
@@ -98,12 +102,14 @@ function print_invoices()
                        $branch = get_branch($myrow["branch_code"]);
                        $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER);
                        if ($email == 1)
-                               $rep = new FrontReport("", "", user_pagesize());
+                       {
+                               $rep = new FrontReport("", "", user_pagesize(), 9, $orientation);
+                               $rep->title = _('INVOICE');
+                               $rep->filename = "Invoice" . $myrow['reference'] . ".pdf";
+                       }       
                    $rep->SetHeaderType('Header2');
                        $rep->currency = $cur;
                        $rep->Font();
-                       $rep->title = _('INVOICE');
-                       $rep->filename = "Invoice" . $myrow['reference'] . ".pdf";
                        $rep->Info($params, $cols, null, $aligns);
 
                        $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], false);
@@ -111,7 +117,7 @@ function print_invoices()
                        $rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts);
                        $rep->NewPage();
                        // calculate summary start row for later use
-                       $summary_start_row = $rep->bottomMargin + (20 * $rep->lineHeight);
+                       $summary_start_row = $rep->bottomMargin + (15 * $rep->lineHeight);
 
                        if ($rep->formData['prepaid'])
                        {
@@ -125,7 +131,7 @@ function print_invoices()
                                }
 
                                if (count($prepayments) > ($show_this_payment ? 0 : 1))
-                                       $summary_start_row += (count($prepayments)+3) * $rep->lineHeight;
+                                       $summary_start_row += (count($prepayments)) * $rep->lineHeight;
                                else
                                        unset($prepayments);
                        }
@@ -182,13 +188,13 @@ function print_invoices()
                        if (isset($prepayments))
                        {
                                // Partial invoices table
-                               $rep->NewLine();
-                               $rep->TextCol(1, 4,_("Prepayments invoiced to this order up to day:"));
-                               $rep->TextCol(1, 4,     str_pad('', 150, '_'));
-                               $rep->cols[3] -= 20;
-                               $rep->aligns[3] = 'right';
-                               $rep->NewLine(); $c = 1; $tot_pym=0;
-                               $rep->TextCol(1, 4,     str_pad('', 150, '_'));
+                               //$rep->NewLine();
+                               $rep->TextCol(0, 3,_("Prepayments invoiced to this order up to day:"));
+                               $rep->TextCol(0, 3,     str_pad('', 150, '_'));
+                               $rep->cols[2] -= 20;
+                               $rep->aligns[2] = 'right';
+                               $rep->NewLine(); $c = 0; $tot_pym=0;
+                               $rep->TextCol(0, 3,     str_pad('', 150, '_'));
                                $rep->TextCol($c++, $c, _("Date"));
                                $rep->TextCol($c++, $c, _("Invoice reference"));
                                $rep->TextCol($c++, $c, _("Amount"));
@@ -198,21 +204,25 @@ function print_invoices()
                                        if ($show_this_payment || ($invoice['reference'] != $myrow['reference']))
                                        {
                                                $rep->NewLine();
-                                               $c = 1; $tot_pym += $invoice['prep_amount'];
+                                               $c = 0; $tot_pym += $invoice['prep_amount'];
                                                $rep->TextCol($c++, $c, sql2date($invoice['tran_date']));
                                                $rep->TextCol($c++, $c, $invoice['reference']);
                                                $rep->TextCol($c++, $c, number_format2($invoice['prep_amount'], $dec));
                                        }
                                        if ($invoice['reference']==$myrow['reference']) break;
                                }
-                               $rep->TextCol(1, 4,     str_pad('', 150, '_'));
+                               $rep->TextCol(0, 3,     str_pad('', 150, '_'));
                                $rep->NewLine();
-                               $rep->TextCol(2, 3,     _("Total payments:"));
-                               $rep->TextCol(3, 4,     number_format2($tot_pym, $dec));
+                               $rep->TextCol(1, 2,     _("Total payments:"));
+                               $rep->TextCol(2, 3,     number_format2($tot_pym, $dec));
                        }
 
 
                        $doctype = ST_SALESINVOICE;
+               $rep->row = $summary_start_row;
+                       $rep->cols[2] += 20;
+                       $rep->cols[3] += 20;
+                       $rep->aligns[3] = 'left';
 
                        $rep->TextCol(3, 6, _("Sub-total"), -2);
                        $rep->TextCol(6, 7,     $DisplaySubTot, -2);