= '$data_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 (isset($_POST['filterType']) && $_POST['filterType'] != reserved_words::get_all()) { if ($_POST['filterType'] == '1' || $_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(); } 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 (round(abs(".TB_PREF."debtor_trans.ov_amount + " .TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + " .TB_PREF."debtor_trans.ov_freight_tax + ".TB_PREF."debtor_trans.ov_discount) - ".TB_PREF."debtor_trans.alloc,6) > 0) "; } }else { $sql .= " AND ".TB_PREF."debtor_trans.type != 13 "; } if (!check_value('showSettled')) { $sql .= " AND (round(abs(".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + " .TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_freight_tax + " .TB_PREF."debtor_trans.ov_discount) - ".TB_PREF."debtor_trans.alloc,6) != 0) "; } $sql .= " ORDER BY ".TB_PREF."debtor_trans.tran_date"; return db_query($sql,"No transactions were returned"); } //------------------------------------------------------------------------------------------------ $result = get_transactions(); if (db_num_rows($result) == 0) { display_note(_("The selected customer has no transactions for the given dates."), 1, 1); end_page(); exit; } //------------------------------------------------------------------------------------------------ start_table("$table_style width='80%'"); if ($_POST['customer_id'] == reserved_words::get_all()) $th = array(_("Type"), _("Number"), _("Reference"), _("Order"), _("Date"), _("Due Date"), _("Customer"), _("Currency"), _("Debit"), _("Credit"), _("Allocated"), _("Balance"), ""); else $th = array(_("Type"), _("Number"), _("Reference"), _("Order"), _("Date"), _("Due Date"), _("Debit"), _("Credit"), _("Allocated"), _("Balance"), ""); table_header($th); $j = 1; $k = 0; //row colour counter $over_due = false; while ($myrow = db_fetch($result)) { if ($myrow['OverDue'] == 1 && (abs($myrow["TotalAmount"]) - $myrow["Allocated"] != 0)) { start_row("class='overduebg'"); $over_due = true; } else alt_table_row_color($k); $date = sql2date($myrow["tran_date"]); if ($myrow["order_"] > 0) $preview_order_str = get_customer_trans_view_str(systypes::sales_order(), $myrow["order_"]); else $preview_order_str = ""; $allocations_str = ""; $allocations = "" . _("Allocation") . ""; $due_date_str = ""; if ($myrow["type"] == 10) $due_date_str = sql2date($myrow["due_date"]); elseif ($myrow["type"] == 11 && $myrow['TotalAmount'] > 0) { /*its a credit note which could have an allocation */ $allocations_str = $allocations; } elseif (($myrow["type"] == systypes::cust_payment() || $myrow["type"] == systypes::bank_deposit()) && ($myrow['TotalAmount'] - $myrow['Allocated']) > 0) { /*its a receipt which could have an allocation*/ $allocations_str = $allocations; } elseif ($myrow["type"] == systypes::cust_payment() && $myrow['TotalAmount'] < 0) { /*its a negative receipt */ } label_cell(systypes::name($myrow["type"])); label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"])); label_cell($myrow["reference"]); label_cell($preview_order_str); label_cell(sql2date($myrow["tran_date"]), "nowrap"); label_cell($due_date_str, "nowrap"); if ($_POST['customer_id'] == reserved_words::get_all()) { label_cell($myrow["CustName"]); label_cell($myrow["CustCurrCode"]); } display_debit_or_credit_cells( $myrow['type']==11 || $myrow['type']==12 || $myrow['type']==2 ? -$myrow["TotalAmount"] : $myrow["TotalAmount"]); amount_cell(abs($myrow["Allocated"])); amount_cell(abs($myrow["TotalAmount"]) - $myrow["Allocated"]); label_cell($allocations_str); end_row(); $j++; If ($j == 12) { $j = 1; table_header($th); } //end of page full new headings if } //end of while loop end_table(1); if ($over_due) display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'"); end_page(); ?>