X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdata_checks.inc;h=7ce8d668adced13db154009c9bca372e8d77edc6;hb=7e8df3a179c05c51085349e139aac9ce88b9378d;hp=cfb87a61e5c4d9c89c396431eab442b359dfa018;hpb=7e830126b96477e969fe3b48d9fc0e78f6c1fe00;p=fa-stable.git diff --git a/includes/data_checks.inc b/includes/data_checks.inc index cfb87a61..7ce8d668 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -41,6 +41,19 @@ function check_db_has_currencies($msg) } } +function db_has_currency_rates($currency, $date_, $msg=false) +{ + $date = date2sql($date_); + + if (is_company_currency($currency)) + return 1; + $ret = check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."exchange_rates WHERE curr_code = '$currency' && date_ <= '$date'"); + if ($ret == 0 && $msg) + display_error(sprintf(_("Cannot retrieve exchange rate for currency %s as of %s. Please add exchange rate manually on Exchange Rates page."), + $currency, $date_), true); + return $ret; +} + function db_has_sales_types() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."sales_types"); @@ -105,22 +118,6 @@ function check_db_has_tax_groups($msg) } } -function db_has_movement_types() -{ - return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."movement_types"); -} - -function check_db_has_movement_types($msg) -{ - global $path_to_root; - if (!db_has_movement_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 " @@ -488,15 +485,14 @@ function check_num($postname, $min=null, $max=null, $dflt=0) { 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; - } + display_error($msg, true); + display_footer_exit(); + } } function check_deferred_income_act($msg) @@ -506,7 +502,25 @@ function check_deferred_income_act($msg) if (!get_company_pref('deferred_income_act')) { display_error($msg, true); - end_page(); - exit; + display_footer_exit(); } } + +function check_is_editable($trans_type, $trans_no, $msg=null) +{ + if (!$_SESSION['wa_current_user']->can_access('SA_EDITOTHERSTRANS')) + { + $audit = get_audit_trail_last($trans_type, $trans_no); + + if ($_SESSION['wa_current_user']->user != $audit['user']) + { + if (!$msg) + $msg = ''._("You have no edit access to transactions created by other users.").''; + display_note($msg); + display_footer_exit(); + } + } + if (!in_array($trans_type, array(ST_SALESORDER, ST_SALESQUOTE, ST_PURCHORDER, ST_WORKORDER))) + check_is_closed($trans_type, $trans_no, $msg); +} +