X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep201.php;h=b176f2bdb8461591bb158f660df28944958fc3f1;hb=df3ebb4251529abb480179600417fe7164951fe2;hp=756e83c64ab696fdd9d9bcc9c610c3bb75bc6313;hpb=9b852b19c91b5af6400cf94a9ff65d37d1a730b4;p=fa-stable.git diff --git a/reporting/rep201.php b/reporting/rep201.php index 756e83c6..b176f2bd 100644 --- a/reporting/rep201.php +++ b/reporting/rep201.php @@ -9,7 +9,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -$page_security = 2; +$page_security = 'SA_SUPPLIERANALYTIC'; // ---------------------------------------------------------------- // $ Revision: 2.0 $ // Creator: Joe Hunt @@ -31,12 +31,12 @@ function get_open_balance($supplier_id, $to, $convert) { $to = date2sql($to); - $sql = "SELECT SUM(IF(".TB_PREF."supp_trans.type = 20, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + + $sql = "SELECT SUM(IF(".TB_PREF."supp_trans.type = ".ST_SUPPINVOICE.", (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; if ($convert) $sql .= " * rate"; $sql .= ", 0)) AS charges, - SUM(IF(".TB_PREF."supp_trans.type <> 20, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + + SUM(IF(".TB_PREF."supp_trans.type <> ".ST_SUPPINVOICE.", (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; if ($convert) $sql .= "* rate"; @@ -66,7 +66,7 @@ function getTransactions($supplier_id, $from, $to) $sql = "SELECT ".TB_PREF."supp_trans.*, (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount) AS TotalAmount, ".TB_PREF."supp_trans.alloc AS Allocated, - ((".TB_PREF."supp_trans.type = 20) + ((".TB_PREF."supp_trans.type = ".ST_SUPPINVOICE.") AND ".TB_PREF."supp_trans.due_date < '$to') AS OverDue FROM ".TB_PREF."supp_trans WHERE ".TB_PREF."supp_trans.tran_date >= '$from' AND ".TB_PREF."supp_trans.tran_date <= '$to' @@ -82,7 +82,7 @@ function getTransactions($supplier_id, $from, $to) function print_supplier_balances() { - global $path_to_root; + global $path_to_root, $systypes_array; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; @@ -95,13 +95,13 @@ function print_supplier_balances() else include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - if ($fromsupp == reserved_words::get_all_numeric()) + if ($fromsupp == ALL_NUMERIC) $supp = _('All'); else $supp = get_supplier_name($fromsupp); $dec = user_price_dec(); - if ($currency == reserved_words::get_all()) + if ($currency == ALL_TEXT) { $convert = true; $currency = _('Balances in Home currency'); @@ -125,15 +125,15 @@ function print_supplier_balances() $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); - $rep->Header(); + $rep->NewPage(); $total = array(); $grandtotal = array(0,0,0,0); - $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM ".TB_PREF."suppliers "; - if ($fromsupp != reserved_words::get_all_numeric()) - $sql .= "WHERE supplier_id=$fromsupp "; - $sql .= "ORDER BY supp_name"; + $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM ".TB_PREF."suppliers"; + if ($fromsupp != ALL_NUMERIC) + $sql .= " WHERE supplier_id=".db_escape($fromsupp); + $sql .= " ORDER BY supp_name"; $result = db_query($sql, "The customers could not be retrieved"); while ($myrow=db_fetch($result)) @@ -170,10 +170,10 @@ function print_supplier_balances() while ($trans=db_fetch($res)) { $rep->NewLine(1, 2); - $rep->TextCol(0, 1, systypes::name($trans['type'])); + $rep->TextCol(0, 1, $systypes_array[$trans['type']]); $rep->TextCol(1, 2, $trans['reference']); $rep->DateCol(2, 3, $trans['tran_date'], true); - if ($trans['type'] == 20) + if ($trans['type'] == ST_SUPPINVOICE) $rep->DateCol(3, 4, $trans['due_date'], true); $item[0] = $item[1] = 0.0; if ($convert) @@ -198,7 +198,7 @@ function print_supplier_balances() else $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; */ - if ($trans['type'] == 20 || $trans['type'] == 2) + if ($trans['type'] == ST_SUPPINVOICE || $trans['type'] == ST_BANKDEPOSIT) $item[3] = $item[0] + $item[1] - $item[2]; else $item[3] = $item[0] - $item[1] + $item[2];