X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdata_checks.inc;h=633daa87e43a400c9df7403e6ecb8ba62b9bfe49;hb=f4737ea725de62440c8bf58a7b4d7b187268fe93;hp=ef33acfdfd4d329412a7461586c07488f20b526a;hpb=da8311619dd73feae101d246a1957b972e00cbd2;p=fa-stable.git diff --git a/includes/data_checks.inc b/includes/data_checks.inc index ef33acfd..633daa87 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -1,5 +1,14 @@ . +***********************************************************************/ function db_has_customers() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."debtors_master"); @@ -112,30 +121,16 @@ function check_db_has_movement_types($msg) } } -function db_has_bank_trans_types() -{ - return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."bank_trans_types"); -} - -function check_db_has_bank_trans_types($msg) -{ - global $path_to_root; - if (!db_has_bank_trans_types()) - { - display_error($msg, true); - end_page(); - exit; - } -} - 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) @@ -392,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); @@ -400,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"); @@ -421,6 +423,11 @@ function check_db_has_gl_account_groups($msg) } } +function db_has_quick_entries() +{ + return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."quick_entries"); +} + function check_empty_result($sql) { $result = db_query($sql, "could not do check empty query"); @@ -428,5 +435,38 @@ function check_empty_result($sql) $myrow = db_fetch_row($result); return $myrow[0] > 0; } +// +// Integer input check +// Return 1 if number has proper form and is within range +// +function check_int($postname, $min=null, $max=null) { + if(!isset($_POST[$postname])) + return 0; + $num = input_num($postname); + if(!is_int($num)) + return 0; + if (isset($min) && ($num<$min)) + return 0; + if (isset($max) && ($num>$max)) + return 0; + return 1; +} +// +// Numeric input check. +// Return 1 if number has proper form and is within range +// +function check_num($postname, $min=null, $max=null) { + if(!isset($_POST[$postname])) + return 0; + $num = input_num($postname); + if ($num === false) + return 0; + if (isset($min) && ($num<$min)) + return 0; + if (isset($max) && ($num>$max)) + return 0; + return 1; +} + ?> \ No newline at end of file