X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdata_checks.inc;h=f50e94540319f94d40b1a684c2e93f7de3751081;hb=7840540918bfd37c886877a5d52e3ba0b3373289;hp=8e03d5849567ff107b12d1e3029ea537b0750ddb;hpb=2383d33373d6ddec06906658a0ed6398077c1147;p=fa-stable.git diff --git a/includes/data_checks.inc b/includes/data_checks.inc index 8e03d584..f50e9454 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -124,7 +124,7 @@ 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'"); + ."WHERE debtor_no=".db_escape($customer_id)); } function db_has_customer_branches() @@ -428,12 +428,28 @@ function db_has_quick_entries() return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."quick_entries"); } +function db_has_tags($type) +{ + return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."tags WHERE type=".db_escape($type)); +} + +function check_db_has_tags($type, $msg) +{ + global $path_to_root; + if (!db_has_tags($type)) + { + display_error($msg, true); + end_page(); + exit; + } +} + function check_empty_result($sql) { $result = db_query($sql, "could not do check empty query"); $myrow = db_fetch_row($result); - return $myrow[0] > 0; + return $myrow[0] > 0; } // // Integer input check @@ -454,12 +470,13 @@ function check_int($postname, $min=null, $max=null) { // // Numeric input check. // Return 1 if number has proper form and is within range +// Empty/not defined fields are defaulted to $dflt value. // -function check_num($postname, $min=null, $max=null) { +function check_num($postname, $min=null, $max=null, $dflt=0) { if(!isset($_POST[$postname])) return 0; - $num = input_num($postname); - if ($num === false) + $num = input_num($postname, $dflt); + if ($num === false || $num === null) return 0; if (isset($min) && ($num<$min)) return 0; @@ -468,5 +485,16 @@ function check_num($postname, $min=null, $max=null) { return 1; } - -?> \ No newline at end of file +function check_is_closed($type, $type_no, $msg=null) +{ + global $systypes_array; + + if (($type_no > 0) && is_closed_trans($type, $type_no)) + { + if (!$msg) + $msg = sprintf(_("%s #%s is closed for further edition."), $systypes_array[$type], $type_no); + display_error($msg, true); + end_page(); + exit; + } +}