= '$date_after' AND ".TB_PREF."supp_trans.tran_date <= '$date_to'"; if ($_POST['supplier_id'] != reserved_words::get_all()) $sql .= " AND ".TB_PREF."supp_trans.supplier_id = '" . $_POST['supplier_id'] . "'"; if (isset($_POST['filterType']) && $_POST['filterType'] != reserved_words::get_all()) { if (($_POST['filterType'] == '1') || ($_POST['filterType'] == '2')) { $sql .= " AND ".TB_PREF."supp_trans.type = 20 "; } elseif ($_POST['filterType'] == '3') { $sql .= " AND ".TB_PREF."supp_trans.type = 22 "; } elseif (($_POST['filterType'] == '4') || ($_POST['filterType'] == '5')) { $sql .= " AND ".TB_PREF."supp_trans.type = 21 "; } if (($_POST['filterType'] == '2') || ($_POST['filterType'] == '5')) { $today = date2sql(Today()); $sql .= " AND ".TB_PREF."supp_trans.due_date < '$today' "; } } if (!check_value('showSettled')) { $sql .= " AND (round(abs(ov_amount + ov_gst + ov_discount) - alloc,6) != 0) "; } $sql .= " ORDER BY ".TB_PREF."supp_trans.tran_date"; return db_query($sql,"No supplier transactions were returned"); } //------------------------------------------------------------------------------------------------ $result = get_transactions(); //------------------------------------------------------------------------------------------------ if(get_post('RefreshInquiry')) { $Ajax->activate('doc_tbl'); } //------------------------------------------------------------------------------------------------ /*show a table of the transactions returned by the sql */ div_start('doc_tbl'); if (db_num_rows($result) == 0) { display_note(_("There are no transactions to display for the given dates."), 1, 1); } else { start_table("$table_style width=90%"); if ($_POST['supplier_id'] == reserved_words::get_all()) $th = array(_("Type"), _("Number"), _("Reference"), _("Supplier"), _("Supp Reference"), _("Date"), _("Due Date"), _("Currency"), _("Debit"), _("Credit"), _("Allocated"), _("Balance"), ""); else $th = array(_("Type"), _("Number"), _("Reference"), _("Supp Reference"), _("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) { start_row("class='overduebg'"); $over_due = true; } else { alt_table_row_color($k); } $date = sql2date($myrow["tran_date"]); $duedate = ((($myrow["type"] == 20) || ($myrow["type"]== 21))?sql2date($myrow["due_date"]):""); label_cell(systypes::name($myrow["type"])); label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"])); label_cell($myrow["reference"]); if ($_POST['supplier_id'] == reserved_words::get_all()) label_cell($myrow["supp_name"]); label_cell($myrow["supp_reference"]); label_cell($date); label_cell($duedate); if ($_POST['supplier_id'] == reserved_words::get_all()) label_cell($myrow["curr_code"]); if ($myrow["TotalAmount"] >= 0) label_cell(""); amount_cell(abs($myrow["TotalAmount"])); if ($myrow["TotalAmount"] < 0) label_cell(""); amount_cell($myrow["Allocated"]); if ($myrow["type"] == 1 || $myrow["type"] == 21 || $myrow["type"] == 22) $balance = -$myrow["TotalAmount"] - $myrow["Allocated"]; else $balance = $myrow["TotalAmount"] - $myrow["Allocated"]; amount_cell($balance); //if (($myrow["type"] == 1 || $myrow["type"] == 21 || $myrow["type"] == 22) && // $myrow["Void"] == 0) if (($myrow["type"] == 1 || $myrow["type"] == 21 || $myrow["type"] == 22) && $balance > 0) { label_cell("" . _("Allocations") . ""); } else label_cell(""); 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'"); } div_end(); end_page(); ?>