- FROM ".TB_PREF."grn_items,
- ".TB_PREF."grn_batch,
- ".TB_PREF."purch_order_details,
- ".TB_PREF."suppliers
- WHERE ".TB_PREF."grn_batch.supplier_id=".TB_PREF."suppliers.supplier_id
- AND ".TB_PREF."grn_batch.id = ".TB_PREF."grn_items.grn_batch_id
- AND ".TB_PREF."grn_items.po_detail_item = ".TB_PREF."purch_order_details.po_detail_item
- AND qty_recd-quantity_inv <>0 ";
-
- if ($fromsupp != ALL_NUMERIC)
- $sql .= "AND ".TB_PREF."grn_batch.supplier_id =".db_escape($fromsupp)." ";
- $sql .= "ORDER BY ".TB_PREF."grn_batch.supplier_id,
- ".TB_PREF."grn_batch.id";
+ FROM ".TB_PREF."grn_items item,
+ ".TB_PREF."grn_batch grn,
+ ".TB_PREF."purch_order_details poline,
+ ".TB_PREF."suppliers supplier
+ WHERE grn.supplier_id=supplier.supplier_id
+ AND grn.id = item.grn_batch_id
+ AND item.po_detail_item = poline.po_detail_item
+ AND qty_recd-quantity_inv!=0";
+
+ if ($fromsupp != ALL_TEXT)
+ $sql .= " AND grn.supplier_id =".db_escape($fromsupp);
+
+ $sql .= " ORDER BY grn.supplier_id, grn.id";