From: <dai...@us...> - 2013-05-24 22:47:03
|
Revision: 5983 http://sourceforge.net/p/web-erp/reponame/5983 Author: daintree Date: 2013-05-24 22:47:01 +0000 (Fri, 24 May 2013) Log Message: ----------- Rafael Chac?\195?\179n: New include/CurrenciesArray.php listing all ISO currencies and their code Modified Paths: -------------- trunk/Currencies.php trunk/doc/Change.log Modified: trunk/Currencies.php =================================================================== --- trunk/Currencies.php 2013-05-23 04:22:02 UTC (rev 5982) +++ trunk/Currencies.php 2013-05-24 22:47:01 UTC (rev 5983) @@ -7,6 +7,8 @@ $ViewTopic= 'Currencies'; $BookMark = 'Currencies'; include('includes/header.inc'); +include('includes/CurrenciesArray.php'); + include('includes/SQL_CommonFunctions.inc'); if (isset($_GET['SelectedCurrency'])){ @@ -53,12 +55,7 @@ $Errors[$i] = 'Abbreviation'; $i++; } - if (mb_strlen($_POST['Abbreviation']) > 3 OR mb_strlen($_POST['Abbreviation']) < 1) { - $InputError = 1; - prnMsg(_('The currency abbreviation must be 3 characters or less long and for automated currency updates to work correctly be one of the ISO4217 currency codes'),'error'); - $Errors[$i] = 'Abbreviation'; - $i++; - } + if (!is_numeric(filter_number_format($_POST['ExchangeRate']))){ $InputError = 1; prnMsg(_('The exchange rate must be numeric'),'error'); @@ -81,12 +78,7 @@ $Errors[$i] = 'DecimalPlaces'; $i++; } - if (mb_strlen($_POST['CurrencyName']) > 20) { - $InputError = 1; - prnMsg(_('The currency name must be 20 characters or less long'),'error'); - $Errors[$i] = 'CurrencyName'; - $i++; - } + if (mb_strlen($_POST['Country']) > 50) { $InputError = 1; prnMsg(_('The currency country must be 50 characters or less long'),'error'); @@ -103,18 +95,11 @@ $InputError = 1; prnMsg(_('The functional currency cannot be modified or deleted'),'error'); } - if (ContainsIllegalCharacters($_POST['Abbreviation'])) { - $InputError = 1; - prnMsg( _('The currency code cannot contain any of the following characters') . " . - ' & + \" " . _('or a space'),'error'); - $Errors[$i] = 'Abbreviation'; - $i++; - } - + if (isset($SelectedCurrency) AND $InputError !=1) { /*SelectedCurrency could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ - $sql = "UPDATE currencies SET currency='" . $_POST['CurrencyName'] . "', - country='". $_POST['Country']. "', + $sql = "UPDATE currencies SET country='". $_POST['Country']. "', hundredsname='" . $_POST['HundredsName'] . "', decimalplaces='" . filter_number_format($_POST['DecimalPlaces']) . "', rate='" .filter_number_format($_POST['ExchangeRate']) . "', @@ -132,7 +117,7 @@ decimalplaces, rate, webcart) - VALUES ('" . $_POST['CurrencyName'] . "', + VALUES ('" . $CurrenciesArray[$_POST['Abbreviation']]['Currency'] . "', '" . $_POST['Abbreviation'] . "', '" . $_POST['Country'] . "', '" . $_POST['HundredsName'] . "', @@ -148,7 +133,6 @@ prnMsg( $msg,'success'); } unset($SelectedCurrency); - unset($_POST['CurrencyName']); unset($_POST['Country']); unset($_POST['HundredsName']); unset($_POST['DecimalPlaces']); @@ -276,7 +260,7 @@ </tr>', $ImageFile, $myrow['currabrev'], - $myrow['currency'], + _($myrow['currency']), $myrow['country'], $myrow['hundredsname'], locale_number_format($myrow['decimalplaces'],0), @@ -304,7 +288,7 @@ </tr>', $ImageFile, $myrow['currabrev'], - $myrow['currency'], + _($myrow['currency']), $myrow['country'], $myrow['hundredsname'], locale_number_format($myrow['decimalplaces'],0), @@ -350,7 +334,6 @@ $myrow = DB_fetch_array($result); $_POST['Abbreviation'] = $myrow['currabrev']; - $_POST['CurrencyName'] = $myrow['currency']; $_POST['Country'] = $myrow['country']; $_POST['HundredsName'] = $myrow['hundredsname']; $_POST['ExchangeRate'] = locale_number_format($myrow['rate'],8); @@ -369,20 +352,17 @@ if (!isset($_POST['Abbreviation'])) {$_POST['Abbreviation']='';} echo '<table class="selection"> <tr> - <td>' ._('Currency Abbreviation') . ':</td> - <td><input ' . (in_array('Abbreviation',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="Abbreviation" value="' . $_POST['Abbreviation'] . '" size="4" maxlength="3" /></td> + <td>' ._('Currency') . ':</td> + <td><select name="Abbreviation">'; + foreach ($CurrenciesArray as $CurrencyAbbreviation => $CurrencyArray) { + echo '<option value="' . $CurrencyAbbreviation . '">' . $CurrencyAbbreviation . '-' . $CurrencyArray['Currency'] . '</option>'; + } + + echo '</select></td> </tr>'; } echo '<tr> - <td>'._('Currency Name').':</td> - <td>'; - if (!isset($_POST['CurrencyName'])) { - $_POST['CurrencyName']=''; - } - echo '<input ' . (in_array('CurrencyName',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="CurrencyName" size="20" maxlength="20" value="' . $_POST['CurrencyName'] . '" /></td> - </tr> - <tr> <td>'._('Country').':</td> <td>'; if (!isset($_POST['Country'])) { Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2013-05-23 04:22:02 UTC (rev 5982) +++ trunk/doc/Change.log 2013-05-24 22:47:01 UTC (rev 5983) @@ -1,5 +1,7 @@ OwebERP Change Log +25/5/13 Phil: Currencies.php now takes advantage of Rafael's new CurrenciesArray - to ensure correct ISO 3 letter abbreviation is selected - also allows for translation of currency names +25/5/13 Rafael Chacón: New include/CurrenciesArray.php listing all ISO currencies and their code 22/5/13 Rafael Chacón: include/PO_PDFOrderPageHeader.inc now allows different length labels for date and intiator without running into the field data - needed for translations of different lengths 18/5/13 Exson: Stop session.inc execution when there is no config.php found. 17/5/13 Phil: ConfirmDispatch_Invoice.php -include qty already invoiced in order when cancelling any balance on subsequent deliveries. |