- $sql = "SELECT trans.trans_no, trans.reference
- FROM ".TB_PREF."debtor_trans trans
- LEFT JOIN ".TB_PREF."voided voided ON trans.type=voided.type AND trans.trans_no=voided.id
- WHERE trans.type=".ST_SALESINVOICE
- ." AND ISNULL(voided.id)"
- ." AND trans.reference>=".db_escape(get_reference(ST_SALESINVOICE, $from))
- ." AND trans.reference<=".db_escape(get_reference(ST_SALESINVOICE, $to))
- ." ORDER BY trans.tran_date, trans.$ref";
+ $sql = "SELECT trans.trans_no, trans.reference";
+
+// if($currency !== false)
+// $sql .= ", cust.curr_code";
+
+ $sql .= " FROM ".TB_PREF."debtor_trans trans
+ LEFT JOIN ".TB_PREF."voided voided ON trans.type=voided.type AND trans.trans_no=voided.id";
+
+ if ($currency !== false)
+ $sql .= " LEFT JOIN ".TB_PREF."debtors_master cust ON trans.debtor_no=cust.debtor_no";
+
+ $sql .= " WHERE trans.type=".ST_SALESINVOICE
+ ." AND ISNULL(voided.id)"
+ ." AND trans.trans_no BETWEEN ".db_escape($from)." AND ".db_escape($to);
+
+ if ($currency !== false)
+ $sql .= " AND cust.curr_code=".db_escape($currency);
+
+ $sql .= " ORDER BY trans.tran_date, trans.$ref";