Changed Journal Inquiries so it shows the Bank Deposit/Payment amount instead of...
[fa-stable.git] / purchasing / includes / db / suppliers_db.inc
index 797e75e099f384a774e36737a8000d4a72e8a1bc..dd72a6cf94efa8628354bc9648ffe26fc31c699c 100644 (file)
@@ -1,13 +1,13 @@
 <?php
 /**********************************************************************
     Copyright (C) FrontAccounting, LLC.
-       Released under the terms of the GNU Affero General Public License,
-       AGPL, as published by the Free Software Foundation, either version 
-       of the License, or (at your option) any later version.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-    See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 function get_supplier_details($supplier_id, $to=null)
 {
@@ -21,7 +21,7 @@ function get_supplier_details($supplier_id, $to=null)
        // removed - supp_trans.alloc from all summations
 
     $value = "(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)";
-       $due = "IF (".TB_PREF."supp_trans.type=20 OR ".TB_PREF."supp_trans.type=21,".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)";
+       $due = "IF (".TB_PREF."supp_trans.type=".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type=".ST_SUPPCREDIT.",".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)";
     $sql = "SELECT ".TB_PREF."suppliers.supp_name, ".TB_PREF."suppliers.curr_code, ".TB_PREF."payment_terms.terms,
 
                Sum($value) AS Balance,
@@ -60,7 +60,7 @@ function get_supplier_details($supplier_id, $to=null)
                                 ".TB_PREF."payment_terms
                        WHERE
                                 ".TB_PREF."suppliers.payment_terms = ".TB_PREF."payment_terms.terms_indicator
-                                AND ".TB_PREF."suppliers.supplier_id = '$supplier_id'";
+                                AND ".TB_PREF."suppliers.supplier_id = ".db_escape($supplier_id);
 
        $result = db_query($sql,"The customer details could not be retrieved");
 
@@ -86,7 +86,7 @@ function get_supplier_details($supplier_id, $to=null)
 
 function get_supplier($supplier_id)
 {
-       $sql = "SELECT * FROM ".TB_PREF."suppliers WHERE supplier_id=$supplier_id";
+       $sql = "SELECT * FROM ".TB_PREF."suppliers WHERE supplier_id=".db_escape($supplier_id);
 
        $result = db_query($sql, "could not get supplier");
 
@@ -95,7 +95,7 @@ function get_supplier($supplier_id)
 
 function get_supplier_name($supplier_id)
 {
-       $sql = "SELECT supp_name AS name FROM ".TB_PREF."suppliers WHERE supplier_id=$supplier_id";
+       $sql = "SELECT supp_name AS name FROM ".TB_PREF."suppliers WHERE supplier_id=".db_escape($supplier_id);
 
        $result = db_query($sql, "could not get supplier");
 
@@ -106,7 +106,7 @@ function get_supplier_name($supplier_id)
 
 function get_supplier_accounts($supplier_id)
 {
-       $sql = "SELECT payable_account,purchase_account,payment_discount_account FROM ".TB_PREF."suppliers WHERE supplier_id=$supplier_id";
+       $sql = "SELECT payable_account,purchase_account,payment_discount_account FROM ".TB_PREF."suppliers WHERE supplier_id=".db_escape($supplier_id);
 
        $result = db_query($sql, "could not get supplier");