for other types.
case 'INVOICE':
$IV = $type_shortcuts[ST_SALESINVOICE];
$ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
$sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
concat('$IV ', debtor_trans.$ref,' ', debtor.name) as IName
FROM ".TB_PREF."debtors_master debtor,"
.TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND debtor_trans.trans_no=vd.id
WHERE debtor_trans.type=".ST_SALESINVOICE." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
ORDER BY debtor_trans.trans_no DESC";
return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
case 'CREDIT':
$CN = $type_shortcuts[ST_CUSTCREDIT];
$ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
$sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
concat('$CN ', debtor_trans.$ref,' ', debtor.name) as IName
FROM ".TB_PREF."debtors_master debtor,"
.TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND debtor_trans.trans_no=vd.id
WHERE debtor_trans.type=".ST_CUSTCREDIT." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
ORDER BY debtor_trans.trans_no DESC";
return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
case 'DELIVERY':
$DN = $type_shortcuts[ST_CUSTDELIVERY];
$sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO,
concat(debtor_trans.trans_no, ' $DN ', debtor.name) as IName
FROM ".TB_PREF."debtors_master debtor,"
.TB_PREF."debtor_trans debtor_trans LEFT JOIN ".TB_PREF."voided AS vd ON debtor_trans.type=vd.type AND debtor_trans.trans_no=vd.id
WHERE debtor_trans.type=".ST_CUSTDELIVERY." AND debtor.debtor_no=debtor_trans.debtor_no AND ISNULL(vd.id)
ORDER BY debtor_trans.trans_no DESC";
return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
case 'REMITTANCE':
$BP = $type_shortcuts[ST_BANKPAYMENT];
$SP = $type_shortcuts[ST_SUPPAYMENT];
$CN = $type_shortcuts[ST_SUPPCREDIT];
$ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
$sql = "SELECT concat(trans.trans_no, '-',trans.type) AS TNO,
concat(trans.$ref, IF(type=".ST_BANKPAYMENT.", ' $BP ', IF(type=".ST_SUPPAYMENT.", ' $SP ', ' $CN ')), supplier.supp_name) as IName
FROM ".TB_PREF."suppliers supplier, "
.TB_PREF."supp_trans trans LEFT JOIN ".TB_PREF."voided AS vd ON trans.type=vd.type AND trans.trans_no=vd.id
WHERE trans.type IN(".ST_BANKPAYMENT.",".ST_SUPPAYMENT.",".ST_SUPPCREDIT.") AND supplier.supplier_id=trans.supplier_id AND ISNULL(vd.id)
ORDER BY trans.trans_no DESC";
return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));
case 'RECEIPT':
$BD = $type_shortcuts[ST_BANKDEPOSIT];
$CP = $type_shortcuts[ST_CUSTPAYMENT];
$ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference");
$sql = "SELECT concat(trans.trans_no, '-', trans.type) AS TNO,
concat(trans.$ref, IF(trans.type=".ST_BANKDEPOSIT.", ' $BD ', ' $CP '), debtor.name) as IName
FROM ".TB_PREF."debtors_master debtor,"
.TB_PREF."debtor_trans trans LEFT JOIN ".TB_PREF."voided AS vd ON trans.type=vd.type AND trans.trans_no=vd.id
WHERE trans.type IN(".ST_BANKDEPOSIT.",".ST_CUSTPAYMENT.",".ST_CUSTCREDIT.") AND debtor.debtor_no=trans.debtor_no AND ISNULL(vd.id)
ORDER BY trans.trans_no DESC";
return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false));