Changed all numeric constants to the new defined constants. A huge task.
[fa-stable.git] / reporting / rep201.php
index 45ce3ef988440856c762033aa6ed96cc31b3ce77..a5614755dc079e4f0053fcafc8cc91847a51f8e6 100644 (file)
@@ -9,7 +9,7 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-$page_security = 2;
+$page_security = 'SA_SUPPLIERANALYTIC';
 // ----------------------------------------------------------------
 // $ Revision: 2.0 $
 // Creator:    Joe Hunt
@@ -31,12 +31,12 @@ function get_open_balance($supplier_id, $to, $convert)
 {
        $to = date2sql($to);
 
-    $sql = "SELECT SUM(IF(".TB_PREF."supp_trans.type = 20, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + 
+    $sql = "SELECT SUM(IF(".TB_PREF."supp_trans.type = ".ST_SUPPINVOICE.", (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + 
        ".TB_PREF."supp_trans.ov_discount)";
     if ($convert)
        $sql .= " * rate";
     $sql .= ", 0)) AS charges,
-       SUM(IF(".TB_PREF."supp_trans.type <> 20, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + 
+       SUM(IF(".TB_PREF."supp_trans.type <> ".ST_SUPPINVOICE.", (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + 
        ".TB_PREF."supp_trans.ov_discount)";
     if ($convert)
        $sql .= "* rate";
@@ -66,7 +66,7 @@ function getTransactions($supplier_id, $from, $to)
     $sql = "SELECT ".TB_PREF."supp_trans.*,
                                (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)
                                AS TotalAmount, ".TB_PREF."supp_trans.alloc AS Allocated,
-                               ((".TB_PREF."supp_trans.type = 20)
+                               ((".TB_PREF."supp_trans.type = ".ST_SUPPINVOICE.")
                                        AND ".TB_PREF."supp_trans.due_date < '$to') AS OverDue
                        FROM ".TB_PREF."supp_trans
                        WHERE ".TB_PREF."supp_trans.tran_date >= '$from' AND ".TB_PREF."supp_trans.tran_date <= '$to' 
@@ -82,7 +82,7 @@ function getTransactions($supplier_id, $from, $to)
 
 function print_supplier_balances()
 {
-    global $path_to_root;
+    global $path_to_root, $systypes_array;
 
     $from = $_POST['PARAM_0'];
     $to = $_POST['PARAM_1'];
@@ -95,13 +95,13 @@ function print_supplier_balances()
        else
                include_once($path_to_root . "/reporting/includes/pdf_report.inc");
 
-       if ($fromsupp == reserved_words::get_all_numeric())
+       if ($fromsupp == ALL_NUMERIC)
                $supp = _('All');
        else
                $supp = get_supplier_name($fromsupp);
     $dec = user_price_dec();
 
-       if ($currency == reserved_words::get_all())
+       if ($currency == ALL_TEXT)
        {
                $convert = true;
                $currency = _('Balances in Home currency');
@@ -131,7 +131,7 @@ function print_supplier_balances()
        $grandtotal = array(0,0,0,0);
 
        $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM ".TB_PREF."suppliers ";
-       if ($fromsupp != reserved_words::get_all_numeric())
+       if ($fromsupp != ALL_NUMERIC)
                $sql .= "WHERE supplier_id=$fromsupp ";
        $sql .= "ORDER BY supp_name";
        $result = db_query($sql, "The customers could not be retrieved");
@@ -170,10 +170,10 @@ function print_supplier_balances()
                while ($trans=db_fetch($res))
                {
                        $rep->NewLine(1, 2);
-                       $rep->TextCol(0, 1,     systypes::name($trans['type']));
+                       $rep->TextCol(0, 1, $systypes_array[$trans['type']]);
                        $rep->TextCol(1, 2,     $trans['reference']);
                        $rep->DateCol(2, 3,     $trans['tran_date'], true);
-                       if ($trans['type'] == 20)
+                       if ($trans['type'] == ST_SUPPINVOICE)
                                $rep->DateCol(3, 4,     $trans['due_date'], true);
                        $item[0] = $item[1] = 0.0;
                        if ($convert)
@@ -198,7 +198,7 @@ function print_supplier_balances()
                        else
                                $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate;
                        */      
-                       if ($trans['type'] == 20)
+                       if ($trans['type'] == ST_SUPPINVOICE || $trans['type'] == ST_BANKDEPOSIT)
                                $item[3] = $item[0] + $item[1] - $item[2];
                        else    
                                $item[3] = $item[0] - $item[1] + $item[2];