***********************************************************************/
//---------------------------------------------------------------------------------------------
-function update_currency($curr_abrev, $symbol, $currency, $country, $hundreds_name)
+function update_currency($curr_abrev, $symbol, $currency, $country,
+ $hundreds_name, $auto_update)
{
$sql = "UPDATE ".TB_PREF."currencies SET currency=".db_escape($currency).", curr_symbol='$symbol',
- country=".db_escape($country).", hundreds_name=".db_escape($hundreds_name)." WHERE curr_abrev = '$curr_abrev'";
+ country=".db_escape($country).", hundreds_name=".db_escape($hundreds_name)
+ .",auto_update = '$auto_update'"." WHERE curr_abrev = '$curr_abrev'";
db_query($sql, "could not update currency for $curr_abrev");
}
//---------------------------------------------------------------------------------------------
-function add_currency($curr_abrev, $symbol, $currency, $country, $hundreds_name)
+function add_currency($curr_abrev, $symbol, $currency, $country,
+ $hundreds_name, $auto_update)
{
- $sql = "INSERT INTO ".TB_PREF."currencies (curr_abrev, curr_symbol, currency, country, hundreds_name)
- VALUES (".db_escape($curr_abrev).", '$symbol', ".db_escape($currency).", ".db_escape($country).", ".db_escape($hundreds_name).")";
+ $sql = "INSERT INTO ".TB_PREF."currencies (curr_abrev, curr_symbol, currency, country,
+ hundreds_name, auto_update)
+ VALUES (".db_escape($curr_abrev).", '$symbol', ".db_escape($currency)
+ .", ".db_escape($country).", ".db_escape($hundreds_name)
+ .",".db_escape($auto_update).")";
db_query($sql, "could not add currency for $curr_abrev");
}
{
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';
$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);
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)
$_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);
}
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 == '', '', 'both');
if ($date_ == Today()) {
$rate = get_date_exchange_rate($currency, $date_);
if (!$rate) {
- $rate = get_ecb_rate($currency);
- if ($rate)
- add_exchange_rate($currency, $date_, $rate, $rate);
+ $row = get_currency($currency);
+ if ($row['auto_update']) {
+ $rate = retrieve_exrate($currency, $date_);
+ if ($rate)
+ add_exchange_rate($currency, $date_, $rate, $rate);
+ }
}
}
if (!$rate)
KEY (`fiscal_year`, `gl_seq`)
) TYPE=InnoDB ;
-ALTER TABLE `0_stock_master` ADD COLUMN `no_sale` tinyint(1) NOT NULL default '0';
+ALTER TABLE `0_stock_master` ADD COLUMN `no_sale` tinyint(1) NOT NULL default '0';
+ALTER TABLE `0_currencies` ADD COLUMN `auto_update` tinyint(1) NOT NULL default '1';
`type` smallint(6) unsigned NOT NULL default '0',
`trans_no` int(11) unsigned NOT NULL default '0',
`user` smallint(6) unsigned NOT NULL default '0',
- `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
+ `stamp` timestamp NOT NULL,
`description` varchar(60) default NULL,
`fiscal_year` int(11) NOT NULL,
`gl_date` date NOT NULL default '0000-00-00',
`curr_symbol` varchar(10) NOT NULL default '',
`country` varchar(100) NOT NULL default '',
`hundreds_name` varchar(15) NOT NULL default '',
+ `auto_update` tinyint(1) NOT NULL default '1',
`inactive` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`curr_abrev`)
) TYPE=MyISAM ;
### Data of table `0_currencies` ###
-INSERT INTO `0_currencies` VALUES ('Kronor', 'SEK', 'kr', 'Sweden', '?ren', '0');
-INSERT INTO `0_currencies` VALUES ('Kroner', 'DKK', 'kr.', 'Denmark', '?re', '0');
-INSERT INTO `0_currencies` VALUES ('Euro', 'EUR', '?', 'Europe', 'Cents', '0');
-INSERT INTO `0_currencies` VALUES ('Pounds', 'GBP', '?', 'England', 'Pence', '0');
-INSERT INTO `0_currencies` VALUES ('US Dollars', 'USD', '$', 'United States', 'Cents', '0');
+INSERT INTO `0_currencies` VALUES ('Kronor', 'SEK', 'kr', 'Sweden', '?ren', '1', '0');
+INSERT INTO `0_currencies` VALUES ('Kroner', 'DKK', 'kr.', 'Denmark', '?re', '1', '0');
+INSERT INTO `0_currencies` VALUES ('Euro', 'EUR', '?', 'Europe', 'Cents', '1', '0');
+INSERT INTO `0_currencies` VALUES ('Pounds', 'GBP', '?', 'England', 'Pence', '1', '0');
+INSERT INTO `0_currencies` VALUES ('US Dollars', 'USD', '$', 'United States', 'Cents', '1', '0');
### Structure of table `0_cust_allocations` ###
`type` smallint(6) unsigned NOT NULL default '0',
`trans_no` int(11) unsigned NOT NULL default '0',
`user` smallint(6) unsigned NOT NULL default '0',
- `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
+ `stamp` timestamp NOT NULL,
`description` varchar(60) default NULL,
`fiscal_year` int(11) NOT NULL,
`gl_date` date NOT NULL default '0000-00-00',
`curr_symbol` varchar(10) NOT NULL default '',
`country` varchar(100) NOT NULL default '',
`hundreds_name` varchar(15) NOT NULL default '',
+ `auto_update` tinyint(1) NOT NULL default '1',
`inactive` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`curr_abrev`)
) TYPE=MyISAM ;
### Data of table `0_currencies` ###
-INSERT INTO `0_currencies` VALUES ('Euro', 'EUR', '?', 'Europe', 'Cents', '0');
-INSERT INTO `0_currencies` VALUES ('Pounds', 'GBP', '?', 'England', 'Pence', '0');
-INSERT INTO `0_currencies` VALUES ('US Dollars', 'USD', '$', 'United States', 'Cents', '0');
+INSERT INTO `0_currencies` VALUES ('Euro', 'EUR', '?', 'Europe', 'Cents', '1', '0');
+INSERT INTO `0_currencies` VALUES ('Pounds', 'GBP', '?', 'England', 'Pence', '1', '0');
+INSERT INTO `0_currencies` VALUES ('US Dollars', 'USD', '$', 'United States', 'Cents', '1', '0');
### Structure of table `0_cust_allocations` ###