X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fmanage%2Fcurrencies.php;h=971dbf3b123ca6a38047314c12084ce2f47fbbeb;hb=aec1717f263bf767543afa6bd0cb960ce53e0a0d;hp=bb83098ad3922c3242a64feb18f136b83b833187;hpb=d67f3efea0aa65cea4f875e2b46d0dacc3e838ef;p=fa-stable.git diff --git a/gl/manage/currencies.php b/gl/manage/currencies.php index bb83098a..971dbf3b 100644 --- a/gl/manage/currencies.php +++ b/gl/manage/currencies.php @@ -13,7 +13,7 @@ $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"); @@ -80,47 +80,33 @@ function handle_submit() //--------------------------------------------------------------------------------------------- -function check_can_delete() +function check_can_delete($curr) { - global $selected_id; - - if ($selected_id == "") + + if ($curr == "") 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 = $curr"; - $result = db_query($sql); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + if (key_in_foreign_table($curr, 'debtors_master', 'curr_code')) { 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 = $curr"; - $result = db_query($sql); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + if (key_in_foreign_table($curr, 'suppliers', 'curr_code')) { 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 = $curr"; - $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 = $curr"; - $result = db_query($sql); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + if (key_in_foreign_table($curr, 'bank_accounts', 'bank_curr_code')) { display_error(_("Cannot delete this currency, because thre are bank accounts that use this currency.")); return false; @@ -134,7 +120,7 @@ function check_can_delete() function handle_delete() { global $selected_id, $Mode; - if (check_can_delete()) { + if (check_can_delete($selected_id)) { //only delete if used in neither customer or supplier, comp prefs, bank trans accounts delete_currency($selected_id); display_notification(_('Selected currency has been deleted')); @@ -146,12 +132,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); @@ -195,9 +179,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 != '') { @@ -260,4 +244,3 @@ end_form(); end_page(); -?>