Switch to new access levels system
[fa-stable.git] / reporting / rep201.php
index de1d47e461d8526abef07b569791fcc83d352797..fce973821f9303f2c82789854b31da7546f0feca 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
@@ -63,15 +63,14 @@ function getTransactions($supplier_id, $from, $to)
        $from = date2sql($from);
        $to = date2sql($to);
 
-    $sql = "SELECT ".TB_PREF."supp_trans.*, ".TB_PREF."sys_types.type_name,
+    $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)
                                        AND ".TB_PREF."supp_trans.due_date < '$to') AS OverDue
-                       FROM ".TB_PREF."supp_trans, ".TB_PREF."sys_types
+                       FROM ".TB_PREF."supp_trans
                        WHERE ".TB_PREF."supp_trans.tran_date >= '$from' AND ".TB_PREF."supp_trans.tran_date <= '$to' 
                        AND ".TB_PREF."supp_trans.supplier_id = '$supplier_id'
-                               AND ".TB_PREF."supp_trans.type = ".TB_PREF."sys_types.type_id
                                ORDER BY ".TB_PREF."supp_trans.tran_date";
 
     $TransResult = db_query($sql,"No transactions were returned");
@@ -171,7 +170,7 @@ function print_supplier_balances()
                while ($trans=db_fetch($res))
                {
                        $rep->NewLine(1, 2);
-                       $rep->TextCol(0, 1,     $trans['type_name']);
+                       $rep->TextCol(0, 1,     systypes::name($trans['type']));
                        $rep->TextCol(1, 2,     $trans['reference']);
                        $rep->DateCol(2, 3,     $trans['tran_date'], true);
                        if ($trans['type'] == 20)
@@ -199,7 +198,7 @@ function print_supplier_balances()
                        else
                                $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate;
                        */      
-                       if ($trans['type'] == 20)
+                       if ($trans['type'] == 20 || $trans['type'] == 2)
                                $item[3] = $item[0] + $item[1] - $item[2];
                        else    
                                $item[3] = $item[0] - $item[1] + $item[2];