X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fmanage%2Fcurrencies.php;h=9bf6a9cd9c6e6db2e4234e70fcc6926c49423826;hb=ebc600101ceab69c06eac4b1bd4d1782af45de05;hp=f1b91de01618371f218dca7c8c961eef070e4962;hpb=d48f1d6f613ffd8e7ab4fbc8840e0a8aab1ad3b6;p=fa-stable.git diff --git a/gl/manage/currencies.php b/gl/manage/currencies.php index f1b91de0..9bf6a9cd 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"); @@ -65,14 +65,14 @@ function handle_submit() { update_currency($_POST['Abbreviation'], $_POST['Symbol'], $_POST['CurrencyName'], - $_POST['country'], $_POST['hundreds_name']); + $_POST['country'], $_POST['hundreds_name'], check_value('auto_update')); display_notification(_('Selected currency settings has been updated')); } else { add_currency($_POST['Abbreviation'], $_POST['Symbol'], $_POST['CurrencyName'], - $_POST['country'], $_POST['hundreds_name']); + $_POST['country'], $_POST['hundreds_name'], check_value('auto_update')); display_notification(_('New currency has been added')); } $Mode = 'RESET'; @@ -86,8 +86,10 @@ 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'"; + $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) @@ -96,7 +98,7 @@ function check_can_delete() return false; } - $sql= "SELECT COUNT(*) FROM ".TB_PREF."suppliers WHERE curr_code = '$selected_id'"; + $sql= "SELECT COUNT(*) FROM ".TB_PREF."suppliers WHERE curr_code = $curr"; $result = db_query($sql); $myrow = db_fetch_row($result); if ($myrow[0] > 0) @@ -105,7 +107,7 @@ function check_can_delete() return false; } - $sql= "SELECT COUNT(*) FROM ".TB_PREF."company WHERE curr_default = '$selected_id'"; + $sql= "SELECT COUNT(*) FROM ".TB_PREF."company WHERE curr_default = $curr"; $result = db_query($sql); $myrow = db_fetch_row($result); if ($myrow[0] > 0) @@ -115,7 +117,7 @@ function check_can_delete() } // 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'"; + $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) @@ -146,13 +148,13 @@ function display_currencies() { global $table_style; - $company_currency = get_company_currency(); + $company_currency = get_company_currency(); - $result = get_currencies(); - start_form(); + $result = get_currencies(check_value('show_inactive')); start_table($table_style); $th = array(_("Abbreviation"), _("Symbol"), _("Currency Name"), - _("Hundredths name"), _("Country"), "", ""); + _("Hundredths name"), _("Country"), _("Auto update"), "", ""); + inactive_control_column($th); table_header($th); $k = 0; //row colour counter @@ -172,6 +174,9 @@ function display_currencies() label_cell($myrow["currency"]); label_cell($myrow["hundreds_name"]); label_cell($myrow["country"]); + label_cell( $myrow[1] == $company_currency ? '-' : + ($myrow["auto_update"] ? _('Yes') :_('No')), "align='center'"); + inactive_control_cell($myrow["curr_abrev"], $myrow["inactive"], 'currencies', 'curr_abrev'); edit_button_cell("Edit".$myrow["curr_abrev"], _("Edit")); if ($myrow["curr_abrev"] != $company_currency) delete_button_cell("Delete".$myrow["curr_abrev"], _("Delete")); @@ -181,8 +186,8 @@ function display_currencies() } //END WHILE LIST LOOP + inactive_control_row($th); end_table(); - end_form(); display_note(_("The marked currency is the home currency which cannot be deleted."), 0, 0, "class='currentfg'"); } @@ -192,7 +197,6 @@ function display_currency_edit($selected_id) { global $table_style2, $Mode; - start_form(); start_table($table_style2); if ($selected_id != '') @@ -206,6 +210,7 @@ function display_currency_edit($selected_id) $_POST['CurrencyName'] = $myrow["currency"]; $_POST['country'] = $myrow["country"]; $_POST['hundreds_name'] = $myrow["hundreds_name"]; + $_POST['auto_update'] = $myrow["auto_update"]; } hidden('Abbreviation'); hidden('selected_id', $selected_id); @@ -213,19 +218,18 @@ function display_currency_edit($selected_id) } else { - text_row_ex(_("Currency Abbreviation:"), 'Abbreviation', 4, 3); + $_POST['auto_update'] = 1; + text_row_ex(_("Currency Abbreviation:"), 'Abbreviation', 4, 3); } text_row_ex(_("Currency Symbol:"), 'Symbol', 10); text_row_ex(_("Currency Name:"), 'CurrencyName', 20); text_row_ex(_("Hundredths Name:"), 'hundreds_name', 15); text_row_ex(_("Country:"), 'country', 40); - + check_row(_("Automatic exchange rate update:"), 'auto_update', get_post('auto_update')); end_table(1); - submit_add_or_update_center($selected_id == '', '', true); - - end_form(); + submit_add_or_update_center($selected_id == '', '', 'both'); } //--------------------------------------------------------------------------------------------- @@ -247,10 +251,11 @@ if ($Mode == 'RESET') $_POST['hundreds_name'] = ''; } +start_form(); display_currencies(); display_currency_edit($selected_id); - +end_form(); //--------------------------------------------------------------------------------------------- end_page();