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
{
$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";
$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'
function print_supplier_balances()
{
- global $path_to_root;
+ global $path_to_root, $systypes_array;
$from = $_POST['PARAM_0'];
$to = $_POST['PARAM_1'];
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');
$total = array();
$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())
- $sql .= "WHERE supplier_id=$fromsupp ";
- $sql .= "ORDER BY supp_name";
+ $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM ".TB_PREF."suppliers";
+ if ($fromsupp != ALL_NUMERIC)
+ $sql .= " WHERE supplier_id=".db_escape($fromsupp);
+ $sql .= " ORDER BY supp_name";
$result = db_query($sql, "The customers could not be retrieved");
while ($myrow=db_fetch($result))
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)
else
$item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate;
*/
- if ($trans['type'] == 20 || $trans['type'] == 2)
+ 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];