*** empty log message ***
[fa-stable.git] / reporting / rep106.php
index ae3ae54b45e956c4e66c69136d0bb14b6f291488..aa3a83f7c49f8b4d5c8d8b1bb8d7145c2be87ceb 100644 (file)
@@ -1,5 +1,14 @@
 <?php
-
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
 $page_security = 2;
 // ----------------------------------------------------------------
 // $ Revision: 2.0 $
@@ -7,17 +16,16 @@ $page_security = 2;
 // date_:      2005-05-19
 // Title:      Order Status List
 // ----------------------------------------------------------------
-$path_to_root="../";
+$path_to_root="..";
 
-include_once($path_to_root . "includes/session.inc");
-include_once($path_to_root . "includes/date_functions.inc");
-include_once($path_to_root . "includes/data_checks.inc");
-include_once($path_to_root . "sales/includes/sales_db.inc");
-include_once($path_to_root . "inventory/includes/db/items_category_db.inc");
+include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/includes/date_functions.inc");
+include_once($path_to_root . "/includes/data_checks.inc");
+include_once($path_to_root . "/sales/includes/sales_db.inc");
+include_once($path_to_root . "/inventory/includes/db/items_category_db.inc");
 
 //----------------------------------------------------------------------------------------------------
 
-// trial_inquiry_controls();
 print_salesman_list();
 
 //----------------------------------------------------------------------------------------------------
@@ -51,19 +59,22 @@ function print_salesman_list()
 {
        global $path_to_root;
 
-       include_once($path_to_root . "reporting/includes/pdf_report.inc");
-
        $from = $_POST['PARAM_0'];
        $to = $_POST['PARAM_1'];
-       $detailed = $_POST['PARAM_2'];
+       $summary = $_POST['PARAM_2'];
        $comments = $_POST['PARAM_3'];
+       $destination = $_POST['PARAM_4'];
+       if ($destination)
+               include_once($path_to_root . "/reporting/includes/excel_report.inc");
+       else
+               include_once($path_to_root . "/reporting/includes/pdf_report.inc");
 
-       if ($detailed == 0)
-               $det = _("No");
+       if ($summary == 0)
+               $sum = _("No");
        else
-               $det = _("Yes");
+               $sum = _("Yes");
 
-       $dec = user_qty_dec();
+       $dec = user_price_dec();
 
        $cols = array(0, 60, 150, 220, 325,     385, 450, 515);
 
@@ -77,12 +88,12 @@ function print_salesman_list()
 
     $params =   array(         0 => $comments,
                                        1 => array(  'text' => _('Period'), 'from' => $from, 'to' => $to),
-                                       2 => array(  'text' => _('Detailed'),'from' => $det,'to' => ''));
+                                       2 => array(  'text' => _('Summary Only'),'from' => $sum,'to' => ''));
 
        $cols2 = $cols;
        $aligns2 = $aligns;
 
-       $rep = new FrontReport(_('Salesman Listing'), "SalesmanListing.pdf", user_pagesize());
+       $rep = new FrontReport(_('Salesman Listing'), "SalesmanListing", user_pagesize());
        $rep->Font();
        $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
 
@@ -107,17 +118,16 @@ function print_salesman_list()
                                $rep->Line($rep->row - 8);
                                $rep->NewLine(2);
                                $rep->TextCol(0, 3, _('Total'));
-                               $rep->TextCol(5, 6, number_format2($subtotal, $dec));
-                               $rep->TextCol(6, 7, number_format2($subprov, $dec));
+                               $rep->AmountCol(5, 6, $subtotal, $dec);
+                               $rep->AmountCol(6, 7, $subprov, $dec);
                        $rep->Line($rep->row  - 4);
                        $rep->NewLine(2);
-                               $rep->Line($rep->row);
                        }
                        $rep->TextCol(0, 2,     $myrow['salesman_code']." ".$myrow['salesman_name']);
                        $rep->TextCol(2, 3,     $myrow['salesman_phone']);
                        $rep->TextCol(3, 4,     $myrow['salesman_email']);
                        $rep->TextCol(4, 5,     number_format2($myrow['provision'], user_percent_dec()) ." %");
-                       $rep->TextCol(5, 6,     number_format2($myrow['break_pt'], $dec));
+                       $rep->AmountCol(5, 6, $myrow['break_pt'], $dec);
                        $rep->TextCol(6, 7,     number_format2($myrow['provision2'], user_percent_dec()) ." %");
                        $rep->NewLine(2);
                        $salesman = $myrow['salesman_code'];
@@ -126,22 +136,21 @@ function print_salesman_list()
                        $subtotal = 0;
                        $subprov = 0;
                }
-               $date = sql2date($myrow['tran_date']);
-               $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date);
+               $rate = $myrow['rate'];
                $amt = $myrow['InvoiceTotal'] * $rate;
                if ($subprov > $myrow['break_pt'] && $myrow['provision2'] != 0)
                        $prov = $myrow['provision2'] * $amt / 100;
                else
                        $prov = $myrow['provision'] * $amt / 100;
-               if ($detailed)
+               if (!$summary)
                {
                        $rep->TextCol(0, 1,     $myrow['trans_no']);
                        $rep->TextCol(1, 2,     $myrow['DebtorName']);
                        $rep->TextCol(2, 3,     $myrow['br_name']);
                        $rep->TextCol(3, 4,     $myrow['contact_name']);
-                       $rep->TextCol(4, 5,     $date);
-                       $rep->TextCol(5, 6,     number_format2($amt, $dec));
-                       $rep->TextCol(6, 7,     number_format2($prov, $dec));
+                       $rep->DateCol(4, 5,     $myrow['tran_date'], true);
+                       $rep->AmountCol(5, 6, $amt, $dec);
+                       $rep->AmountCol(6, 7, $prov, $dec);
                        $rep->NewLine();
                        if ($rep->row < $rep->bottomMargin + (2 * $rep->lineHeight))
                        {
@@ -157,20 +166,20 @@ function print_salesman_list()
                $rep->Line($rep->row - 4);
                $rep->NewLine(2);
                $rep->TextCol(0, 3, _('Total'));
-               $rep->TextCol(5, 6, number_format2($subtotal, $dec));
-               $rep->TextCol(6, 7, number_format2($subprov, $dec));
+               $rep->AmountCol(5, 6, $subtotal, $dec);
+               $rep->AmountCol(6, 7, $subprov, $dec);
                $rep->Line($rep->row  - 4);
                $rep->NewLine(2);
-               //$rep->Line($rep->row);
                $total += $subtotal;
                $provtotal += $subprov;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 3, _('Grand Total'));
        $rep->fontSize -= 2;
-       $rep->TextCol(5, 6, number_format2($total, $dec));
-       $rep->TextCol(6, 7, number_format2($provtotal, $dec));
+       $rep->AmountCol(5, 6, $total, $dec);
+       $rep->AmountCol(6, 7, $provtotal, $dec);
        $rep->Line($rep->row  - 4);
+       $rep->NewLine();
        $rep->End();
 }