X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fmanage%2Fcurrencies.php;h=971dbf3b123ca6a38047314c12084ce2f47fbbeb;hb=c82cbc67f22454e4afd30e53c40043b54a732be3;hp=c040e173fe68b1a92d8b0a5e98c2bbb3967c158b;hpb=d9b4de9d7e9d3ba77f6ece752fd6cc988effd8f1;p=fa-stable.git diff --git a/gl/manage/currencies.php b/gl/manage/currencies.php index c040e173..971dbf3b 100644 --- a/gl/manage/currencies.php +++ b/gl/manage/currencies.php @@ -80,35 +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 - if (key_in_foreign_table($curr, 'debtors_master', 'curr_code', true)) + 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; } - if (key_in_foreign_table($curr, 'suppliers', 'curr_code', true)) + 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; } - if (key_in_foreign_table($curr, 'company', 'curr_default', true)) + 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 - if (key_in_foreign_table($curr, 'bank_accounts', 'bank_curr_code', true)) + 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; @@ -122,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')); @@ -246,4 +244,3 @@ end_form(); end_page(); -?>