td('50%');
source_graphic($today, $title[0], _("Supplier"), $pg);
br(3);
td('50%');
source_graphic($today, $title[0], _("Supplier"), $pg);
br(3);
echo number_format2($title[1])."</p></div>";
br(3);
echo "<div class='square square2'>"._('Aging Total')."<p class='span1'>";
echo number_format2($title[1])."</p></div>";
br(3);
echo "<div class='square square2'>"._('Aging Total')."<p class='span1'>";
$names = $totals = array();
$sales = 0;
while ($myrow = db_fetch($result))
{
$sales += round($myrow['total']);
$names = $totals = array();
$sales = 0;
while ($myrow = db_fetch($result))
{
$sales += round($myrow['total']);
- alt_table_row_color($k);
- $name = $myrow["debtor_no"]." ".htmlspecialchars_decode($myrow["name"]);
- label_cell($name);
- amount_cell($myrow['total']);
- if ($pg != null)
- {
- $names[] = $name;
- $totals[] = round($myrow['total']);
- }
- end_row();
- }
+ $names[] = $name;
+ $totals[] = round($myrow['total']);
+ }
+ end_row();
$names = $totals = array();
$total = 0;
while ($myrow = db_fetch($result))
{
$total += $myrow['total'];
$names = $totals = array();
$total = 0;
while ($myrow = db_fetch($result))
{
$total += $myrow['total'];
- alt_table_row_color($k);
- $name = $myrow["supplier_id"]." ".htmlspecialchars_decode($myrow["supp_name"]);
- label_cell($name);
- amount_cell($myrow['total']);
- if ($pg != null)
- {
- $names[] = $name;
- $totals[] = round($myrow['total']);
- }
- end_row();
- }
+ $names[] = $name;
+ $totals[] = round($myrow['total']);
+ }
+ end_row();
$names = $totals = $costs = $results = array();
$sales = $cost = $res = 0;
while ($myrow = db_fetch($result))
$names = $totals = $costs = $results = array();
$sales = $cost = $res = 0;
while ($myrow = db_fetch($result))
+ alt_table_row_color($k);
+ $name = $myrow["description"];
+ label_cell($name);
+ amount_cell($myrow['total']);
+ if ($type == 0)
+ {
+ amount_cell($myrow['costs']);
+ amount_cell($myrow['total'] - $myrow['costs']);
+ }
+ qty_cell($myrow['qty']);
+ if ($pg != NULL)
LEFT JOIN ".TB_PREF."dimensions AS d ON (g.dimension_id = d.id OR g.dimension2_id = d.id)
LEFT JOIN ".TB_PREF."chart_class AS c ON t.class_id = c.cid
WHERE IF(c.ctype > 3, tran_date >= '$begin', tran_date >= '0000-00-00')
LEFT JOIN ".TB_PREF."dimensions AS d ON (g.dimension_id = d.id OR g.dimension2_id = d.id)
LEFT JOIN ".TB_PREF."chart_class AS c ON t.class_id = c.cid
WHERE IF(c.ctype > 3, tran_date >= '$begin', tran_date >= '0000-00-00')
$result = db_query($sql, "Transactions could not be calculated");
$title = sprintf(_("Top %s Dimensions in fiscal year"), $limit);
display_title($title);
$result = db_query($sql, "Transactions could not be calculated");
$title = sprintf(_("Top %s Dimensions in fiscal year"), $limit);
display_title($title);
// removed - debtor_trans.alloc from all summations
$sign = "IF(`type` IN(".implode(',', array(ST_CUSTCREDIT,ST_CUSTPAYMENT,ST_BANKDEPOSIT))."), -1, 1)";
$value = "IFNULL($sign*((trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount -
// removed - debtor_trans.alloc from all summations
$sign = "IF(`type` IN(".implode(',', array(ST_CUSTCREDIT,ST_CUSTPAYMENT,ST_BANKDEPOSIT))."), -1, 1)";
$value = "IFNULL($sign*((trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount -
$due = "IF (trans.type=".ST_SALESINVOICE.", trans.due_date, trans.tran_date)";
$sql = "SELECT Sum($value) AS Balance,
Sum(IF ((TO_DAYS('$today1') - TO_DAYS($due)) > 0,$value,0)) AS Due,
$due = "IF (trans.type=".ST_SALESINVOICE.", trans.due_date, trans.tran_date)";
$sql = "SELECT Sum($value) AS Balance,
Sum(IF ((TO_DAYS('$today1') - TO_DAYS($due)) > 0,$value,0)) AS Due,
$result = db_query($sql,"The customer details could not be retrieved");
$row = db_fetch($result);
$result = db_query($sql,"The customer details could not be retrieved");
$row = db_fetch($result);
{
$today = date2sql($today);
$sign = "IF(`type` IN(".implode(',', array(ST_CUSTCREDIT,ST_CUSTPAYMENT,ST_BANKDEPOSIT))."), -1, 1)";
{
$today = date2sql($today);
$sign = "IF(`type` IN(".implode(',', array(ST_CUSTCREDIT,ST_CUSTPAYMENT,ST_BANKDEPOSIT))."), -1, 1)";
- $value = "IFNULL($sign*((trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount -
- trans.alloc)*trans.rate),0)";
+ $value = "IFNULL($sign*((trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount -
+ trans.alloc)*trans.rate),0)";
$due = "IF (trans.type=".ST_SALESINVOICE.", trans.due_date, trans.tran_date)";
$sql = "SELECT Sum($value) AS Balance
FROM ".TB_PREF."debtors_master debtor
LEFT JOIN ".TB_PREF."debtor_trans trans ON trans.tran_date <= '$today' AND debtor.debtor_no = trans.debtor_no AND trans.type <> ".ST_CUSTDELIVERY."
$due = "IF (trans.type=".ST_SALESINVOICE.", trans.due_date, trans.tran_date)";
$sql = "SELECT Sum($value) AS Balance
FROM ".TB_PREF."debtors_master debtor
LEFT JOIN ".TB_PREF."debtor_trans trans ON trans.tran_date <= '$today' AND debtor.debtor_no = trans.debtor_no AND trans.type <> ".ST_CUSTDELIVERY."
$result = db_query($sql,"The customer details could not be retrieved");
$row = db_fetch($result);
return $row[0];
$result = db_query($sql,"The customer details could not be retrieved");
$row = db_fetch($result);
return $row[0];
if (isset($_POST['select_s3']))
$pg->type = $_POST['select_s3'];
$today1 = date2sql($today);
if (isset($_POST['select_s3']))
$pg->type = $_POST['select_s3'];
$today1 = date2sql($today);
Sum(IF ((TO_DAYS('$today1') - TO_DAYS($due)) > 0,$value,0)) AS Due,
Sum(IF ((TO_DAYS('$today1') - TO_DAYS($due)) > $past1,$value,0)) AS Overdue1,
Sum(IF ((TO_DAYS('$today1') - TO_DAYS($due)) > $past2,$value,0)) AS Overdue2
Sum(IF ((TO_DAYS('$today1') - TO_DAYS($due)) > 0,$value,0)) AS Due,
Sum(IF ((TO_DAYS('$today1') - TO_DAYS($due)) > $past1,$value,0)) AS Overdue1,
Sum(IF ((TO_DAYS('$today1') - TO_DAYS($due)) > $past2,$value,0)) AS Overdue2
- FROM ".TB_PREF."suppliers supplier, ".TB_PREF."supp_trans trans
- WHERE supplier.supplier_id = trans.supplier_id
- AND trans.tran_date <= '$today1'
+ FROM ".TB_PREF."suppliers supp
+ LEFT JOIN ".TB_PREF."supp_trans trans ON supp.supplier_id = trans.supplier_id AND trans.tran_date <= '$today1'
AND ABS(trans.ov_amount + trans.ov_gst + trans.ov_discount) > ".FLOAT_COMP_DELTA."
AND ABS(trans.ov_amount + trans.ov_gst + trans.ov_discount) - trans.alloc > ".FLOAT_COMP_DELTA;
$result = db_query($sql,"The supplier details could not be retrieved");
AND ABS(trans.ov_amount + trans.ov_gst + trans.ov_discount) > ".FLOAT_COMP_DELTA."
AND ABS(trans.ov_amount + trans.ov_gst + trans.ov_discount) - trans.alloc > ".FLOAT_COMP_DELTA;
$result = db_query($sql,"The supplier details could not be retrieved");
$value = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_BANKDEPOSIT.",
(trans.ov_amount + trans.ov_gst + trans.ov_discount - trans.alloc) * trans.rate,
(trans.ov_amount + trans.ov_gst + trans.ov_discount + trans.alloc) * trans.rate)";
$value = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_BANKDEPOSIT.",
(trans.ov_amount + trans.ov_gst + trans.ov_discount - trans.alloc) * trans.rate,
(trans.ov_amount + trans.ov_gst + trans.ov_discount + trans.alloc) * trans.rate)";