X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdata_checks.inc;h=d6e5261a0066acfc569dbd3709ec086c2145c09b;hb=b14f304532b7d124e79ee2a03d60a0850c8a417d;hp=7cc5586d4652e6c370109a3c668aebad75a47fee;hpb=fd069bba86276f15311ff6ab10b22d4a06a55513;p=fa-stable.git diff --git a/includes/data_checks.inc b/includes/data_checks.inc index 7cc5586d..d6e5261a 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -153,8 +153,8 @@ function check_db_has_sales_people($msg) { display_error($msg, true); end_page(); - exit; - } + exit; + } } function db_has_sales_areas() @@ -348,15 +348,16 @@ function db_has_fixed_asset_classes() function db_has_depreciable_fixed_assets() { $year = get_current_fiscalyear(); - $y = date('Y', strtotime($year['end'])); + $begin = date2sql(add_months(sql2date($year['begin']), -1)); + $end = date2sql(add_months(sql2date($year['end']), -1)); return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag='F' AND material_cost > 0 AND stock_id IN ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE type=".ST_SUPPRECEIVE." AND qty!=0 ) AND stock_id NOT IN ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE (type=".ST_CUSTDELIVERY." OR type=".ST_INVADJUST.") AND qty!=0 ) - AND depreciation_date < '".$y."-12-01' - AND depreciation_date >= '".($y-1)."-12-01'"); + AND depreciation_date <= '".$end."' + AND depreciation_date >='".$begin."'"); } function check_db_has_depreciable_fixed_assets($msg) @@ -566,7 +567,7 @@ 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 is_array($myrow) ? $myrow[0] > 0 : false; } // // Integer input check @@ -674,3 +675,14 @@ function check_reference($reference, $trans_type, $trans_no=0, $context=null, $l } return true; } + +function check_sys_pref($name, $msg, $empty = '') +{ + global $path_to_root; + + if (get_company_pref($name) === $empty) + { + display_error(menu_link("/admin/gl_setup.php", $msg), true); + display_footer_exit(); + } +}