- $sql = "SELECT gl.*, j.event_date, j.doc_date, a.gl_seq, u.user_id, st.supp_reference, gl.person_id subcode,
- IFNULL(IFNULL(sup.supp_name, debt.name), bt.person_id) as person_name,
- IFNULL(gl.person_id, IFNULL(sup.supplier_id, debt.debtor_no)) as person_id,
- IFNULL(st.tran_date, IFNULL(dt.tran_date, IFNULL(bt.trans_date, IFNULL(grn.delivery_date, gl.tran_date)))) as doc_date,
- coa.account_name, ref.reference
- FROM "
- .TB_PREF."gl_trans gl
- LEFT JOIN ".TB_PREF."voided v ON gl.type_no=v.id AND v.type=gl.type
+ $sql = "SELECT gl.*, j.event_date, j.doc_date, a.gl_seq, u.user_id, st.supp_reference, gl.person_id subcode,
+ IFNULL(IFNULL(sup.supp_name, debt.name), bt.person_id) as person_name,
+ IFNULL(gl.person_id, IFNULL(sup.supplier_id, IFNULL(debt.debtor_no, bt.person_id))) as person_id,
+ IF(gl.person_id, gl.person_type_id, IF(sup.supplier_id,". PT_SUPPLIER . "," . "IF(debt.debtor_no," . PT_CUSTOMER . "," .
+ "IF(bt.person_id != '' AND !ISNULL(bt.person_id), bt.person_type_id, -1)))) as person_type_id,
+ IFNULL(st.tran_date, IFNULL(dt.tran_date, IFNULL(bt.trans_date, IFNULL(grn.delivery_date, gl.tran_date)))) as doc_date,
+ coa.account_name, ref.reference, IF(ISNULL(c.memo_), gl.memo_, CONCAT(gl.memo_,' ',c.memo_)) AS memo
+ FROM "
+ .TB_PREF."gl_trans gl
+ LEFT JOIN ".TB_PREF."voided v ON gl.type_no=v.id AND v.type=gl.type