function get_supplier_details_to_order(&$order, $supplier_id)
{
$sql = "SELECT curr_code, supp_name, tax_group_id, supp.tax_included, dimension_id, dimension2_id,
- supp.credit_limit - Sum(IFNULL(IF(trans.type=".ST_SUPPCREDIT.", -1, 1)
- * (ov_amount + ov_gst + ov_discount),0)) as cur_credit,
+ supp.credit_limit - Sum((ov_amount + ov_gst + ov_discount)) as cur_credit,
terms.terms, terms.days_before_due, terms.day_in_following_month
FROM ".TB_PREF."suppliers supp
LEFT JOIN ".TB_PREF."supp_trans trans ON supp.supplier_id = trans.supplier_id
global $Refs;
begin_transaction();
- hook_db_prevoid($po, ST_PURCHORDER);
+ hook_db_prevoid(ST_PURCHORDER, $po);
$sql = "DELETE FROM ".TB_PREF."purch_orders WHERE order_no=".db_escape($po);
db_query($sql, "The order header could not be deleted");
//----------------------------------------------------------------------------------------
+function get_po($order_no) {
+ $sql = "SELECT * FROM ".TB_PREF."purch_orders WHERE order_no = ".db_escape($order_no);
+ $result = db_query($sql);
+
+ return db_fetch($result);
+}
+
+//----------------------------------------------------------------------------------------
+
function read_po_header($order_no, &$order)
{
$sql = "SELECT po.*, supplier.*, loc.location_name
porder.ord_date,
supplier.curr_code,
Sum(line.unit_price*line.quantity_ordered) AS OrderValue,
+ Sum(line.delivery_date < '". date2sql(Today()) ."'
+ AND (line.quantity_ordered > line.quantity_received)) As OverDue,
porder.into_stock_location,
chk.isopen
FROM ".TB_PREF."purch_orders as porder