$pg->setLabels($week_names);
$pg->addSerie(_('Sales'), $sales, 'bar');
$pg->addSerie(_('Costs'), $costs, 'bar');
- $pg->addSerie(_('Results'), $results, 8);
+ $pg->addSerie(_('Results'), $results, 'spline');
source_graphic($today, $title, _("Week"), $pg, _("Weeks"), $weeks);
}
$pg->setLabels($month_names);
$pg->addSerie(_('Sales'), $sales, 'bar');
$pg->addSerie(_('Costs'), $costs, 'bar');
- $pg->addSerie(_('Results'), $results, 8);
+ $pg->addSerie(_('Results'), $results, 'spline');
source_graphic($today, $title, _("Month"), $pg, _("Months"), $months);
}
$today1 = date2sql($today);
$past1 = get_company_pref('past_due_days');
$past2 = 2 * $past1;
- // 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 -
- trans.alloc)*trans.rate),0)";
+
+ $value = "$sign*(IF(trans.prep_amount, trans.prep_amount,
+ ABS(trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount)) - trans.alloc)*trans.rate";
+
$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,
WHERE
debtor.payment_terms = terms.terms_indicator
AND debtor.credit_status = credit_status.id";
- $sql .= " AND ABS(trans.ov_amount + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount) - trans.alloc > ".FLOAT_COMP_DELTA;
+ $sql .= " AND ABS(IF(trans.prep_amount, trans.prep_amount, ABS(trans.ov_amount) + trans.ov_gst + trans.ov_freight + trans.ov_freight_tax + trans.ov_discount) - trans.alloc) > ".FLOAT_COMP_DELTA;
$result = db_query($sql,"The customer details could not be retrieved");
$row = db_fetch($result);
FROM ".TB_PREF."supp_trans as trans, ".TB_PREF."suppliers as s
WHERE s.supplier_id = trans.supplier_id
AND trans.type = ".ST_SUPPINVOICE." AND (ABS(trans.ov_amount + trans.ov_gst +
- trans.ov_discount) - trans.alloc) > ".FLOAT_COMP_DELTA."
- AND DATEDIFF('$today', trans.due_date) > 0 ORDER BY days DESC";
+ trans.ov_discount) - trans.alloc) > ".FLOAT_COMP_DELTA." ORDER BY days DESC";
$result = db_query($sql);
- $title = db_num_rows($result) . _(" overdue Purchase Invoices");
+ $title = db_num_rows($result) . _(" unpaid Purchase Invoices");
display_title($title);
$th = array("#", _("Ref."), _("Date"), _("Due Date"), _("Supplier"), _("Currency"), _("Total"),
_("Remainder"), _("Days"));
start_table(TABLESTYLE, "width=90%");
headers($th);
$k = 0; //row colour counter
+ $due = false;
while ($myrow = db_fetch($result))
{
- alt_table_row_color($k);
+ if ($myrow['days'] > 0)
+ {
+ start_row("class='overduebg'");
+ $due = true;
+ }
+ else
+ alt_table_row_color($k);
label_cell(get_trans_view_str(ST_SUPPINVOICE, $myrow["trans_no"]));
label_cell($myrow['reference']);
label_cell(sql2date($myrow['tran_date']));
label_cell($myrow['days'], "align='right'");
end_row();
}
- end_table(2);
+ end_table();
+ if ($due)
+ display_note(_("Marked items are overdue."), 1, 0, "class='overduefg'");
+ br();
}
function stock_below_reorder($today, $type)