X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fmanage%2Fcurrencies.php;h=b14b79fde4c4e7a4114a73e008a51b93fd107812;hb=1d8ca637beb25da5f36084fdecb6c24dc5d61eab;hp=4d5bf91892f1dc1557fb2b05b0c1345991c03f6c;hpb=a1e0df1ef259550f26bc150cf912fd518c7344e3;p=fa-stable.git diff --git a/gl/manage/currencies.php b/gl/manage/currencies.php index 4d5bf918..b14b79fd 100644 --- a/gl/manage/currencies.php +++ b/gl/manage/currencies.php @@ -9,11 +9,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -$page_security = 9; -$path_to_root="../.."; +$page_security = 'SA_CURRENCY'; +$path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); -page(_("Currencies")); +page(_($help_context = "Currencies")); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/banking.inc"); @@ -86,39 +86,29 @@ function check_can_delete() if ($selected_id == "") return false; + $curr = db_escape($selected_id); + // PREVENT DELETES IF DEPENDENT RECORDS IN debtors_master - $sql= "SELECT COUNT(*) FROM ".TB_PREF."debtors_master WHERE curr_code = '$selected_id'"; - $result = db_query($sql); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + if (key_in_foreign_table($curr, 'debtors_master', 'curr_code', true)) { display_error(_("Cannot delete this currency, because customer accounts have been created referring to this currency.")); return false; } - $sql= "SELECT COUNT(*) FROM ".TB_PREF."suppliers WHERE curr_code = '$selected_id'"; - $result = db_query($sql); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + if (key_in_foreign_table($curr, 'suppliers', 'curr_code', true)) { display_error(_("Cannot delete this currency, because supplier accounts have been created referring to this currency.")); return false; } - - $sql= "SELECT COUNT(*) FROM ".TB_PREF."company WHERE curr_default = '$selected_id'"; - $result = db_query($sql); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + + if ($curr == get_company_pref('curr_default')) { display_error(_("Cannot delete this currency, because the company preferences uses this currency.")); return false; } // see if there are any bank accounts that use this currency - $sql= "SELECT COUNT(*) FROM ".TB_PREF."bank_accounts WHERE bank_curr_code = '$selected_id'"; - $result = db_query($sql); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + if (key_in_foreign_table($curr, 'bank_accounts', 'bank_curr_code', true)) { display_error(_("Cannot delete this currency, because thre are bank accounts that use this currency.")); return false; @@ -144,12 +134,10 @@ function handle_delete() function display_currencies() { - global $table_style; - $company_currency = get_company_currency(); $result = get_currencies(check_value('show_inactive')); - start_table($table_style); + start_table(TABLESTYLE); $th = array(_("Abbreviation"), _("Symbol"), _("Currency Name"), _("Hundredths name"), _("Country"), _("Auto update"), "", ""); inactive_control_column($th); @@ -193,9 +181,9 @@ function display_currencies() function display_currency_edit($selected_id) { - global $table_style2, $Mode; + global $Mode; - start_table($table_style2); + start_table(TABLESTYLE2); if ($selected_id != '') {