Merged changes from main branch up to 2.1.3.
[fa-stable.git] / includes / data_checks.inc
index 57f71e8f634ad1573ce17051c1962d0a46d3dfc7..8e03d5849567ff107b12d1e3029ea537b0750ddb 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 db_has_customers()
 {
@@ -123,12 +123,14 @@ function check_db_has_movement_types($msg)
 
 function db_customer_has_branches($customer_id)
 {
-       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch WHERE debtor_no='$customer_id'");
+       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch "
+               ."WHERE debtor_no='$customer_id'");
 }
 
 function db_has_customer_branches()
 {
-       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch");
+       return check_empty_result("SELECT COUNT(*) FROM "
+               .TB_PREF."cust_branch WHERE !inactive");
 }
 
 function check_db_has_customer_branches($msg)
@@ -267,7 +269,7 @@ function check_db_has_stock_items($msg)
 
 function db_has_bom_stock_items()
 {
-       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag='M' OR mb_flag='K')");
+       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag='M'");
 }
 
 function check_db_has_bom_stock_items($msg)
@@ -299,7 +301,7 @@ function check_db_has_manufacturable_items($msg)
 
 function db_has_purchasable_items()
 {
-       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag!='M' AND mb_flag!='K')");
+       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag!='M'");
 }
 
 function check_db_has_purchasable_items($msg)
@@ -315,7 +317,7 @@ function check_db_has_purchasable_items($msg)
 
 function db_has_costable_items()
 {
-       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag!='D' AND mb_flag!='K')");
+       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag!='D'");
 }
 
 function check_db_has_costable_items($msg)
@@ -385,6 +387,7 @@ function db_has_bank_accounts()
 function check_db_has_bank_accounts($msg)
 {
        global $path_to_root;
+
     if (!db_has_bank_accounts()) 
     {
        display_error($msg, true);
@@ -393,6 +396,12 @@ function check_db_has_bank_accounts($msg)
     }  
 }
 
+function db_has_cash_accounts()
+{
+       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."bank_accounts
+               WHERE account_type=3");
+}
+
 function db_has_gl_accounts()
 {
        return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."chart_master");