- end_table();;
-}
-
-//------------------------------------------------------------------------------------------------
-
-function get_transactions()
-{
- $date_after = date2sql($_POST['TransAfterDate']);
- $date_to = date2sql($_POST['TransToDate']);
-
- $sql = "SELECT ".TB_PREF."debtor_trans.*,
- ".TB_PREF."debtors_master.name AS CustName, ".TB_PREF."debtors_master.curr_code AS CustCurrCode,
- (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount)
- AS TotalAmount, ".TB_PREF."debtor_trans.alloc AS Allocated,
- ((".TB_PREF."debtor_trans.type = 10)
- AND ".TB_PREF."debtor_trans.due_date < '" . date2sql(Today()) . "') AS OverDue
- FROM ".TB_PREF."debtor_trans, ".TB_PREF."debtors_master
- WHERE ".TB_PREF."debtors_master.debtor_no = ".TB_PREF."debtor_trans.debtor_no
- AND ".TB_PREF."debtor_trans.tran_date >= '$date_after'
- AND ".TB_PREF."debtor_trans.tran_date <= '$date_to'";
-
- if ($_POST['customer_id'] != reserved_words::get_all())
- $sql .= " AND ".TB_PREF."debtor_trans.debtor_no = '" . $_POST['customer_id'] . "'";
-
- if ($_POST['filterType'] != reserved_words::get_all())
- {
- if ($_POST['filterType'] == '1')
- {
- $sql .= " AND (".TB_PREF."debtor_trans.type = 10 OR ".TB_PREF."debtor_trans.type = 1) ";
- }
- elseif ($_POST['filterType'] == '2')
- {
- $sql .= " AND (".TB_PREF."debtor_trans.type = 10) ";
- }
- elseif ($_POST['filterType'] == '3')
- {
- $sql .= " AND (".TB_PREF."debtor_trans.type = " . systypes::cust_payment() . " OR ".TB_PREF."debtor_trans.type = 2) ";
- }
- elseif ($_POST['filterType'] == '4')
- {
- $sql .= " AND ".TB_PREF."debtor_trans.type = 11 ";
- }
-
- if ($_POST['filterType'] == '2')
- {
- $today = date2sql(Today());
- $sql .= " AND ".TB_PREF."debtor_trans.due_date < '$today'
- AND (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount - ".TB_PREF."debtor_trans.alloc > 0) ";
- }
- }
-
- $sql .= " ORDER BY ".TB_PREF."debtor_trans.tran_date";
-
- return db_query($sql,"No transactions were returned");