From: <tim...@us...> - 2010-04-28 08:17:33
|
Revision: 3431 http://web-erp.svn.sourceforge.net/web-erp/?rev=3431&view=rev Author: tim_schofield Date: 2010-04-28 08:17:27 +0000 (Wed, 28 Apr 2010) Log Message: ----------- Tim Schofield: MiscFunctions.php : Fix currency download for when there is no internat connection. Modified Paths: -------------- trunk/doc/Change.log.html trunk/includes/MiscFunctions.php Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-04-25 09:47:46 UTC (rev 3430) +++ trunk/doc/Change.log.html 2010-04-28 08:17:27 UTC (rev 3431) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>28/04/10 Tim Schofield: MiscFunctions.php : Fix currency download for when there is no internat connection.</p> <p>23/04/10 Matt Taylor: MiscFunctions.js : Fix IsDate() function for Y/m/d format.</p> <p>23/04/10 Matt Taylor: DateFunctions.inc : Fix Date1GreaterThanDate2() function for Y/m/d format.</p> <p>23/04/10 Matt Taylor: Z_BottomUpCost.php : Add script for batch updating BOM costs.</p> Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2010-04-25 09:47:46 UTC (rev 3430) +++ trunk/includes/MiscFunctions.php 2010-04-28 08:17:27 UTC (rev 3431) @@ -104,44 +104,45 @@ function GetECBCurrencyRates () { /* See http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html for detail of the European Central Bank rates - published daily */ - $xml = file_get_contents('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml'); - $parser = xml_parser_create(); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); - xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); - xml_parse_into_struct($parser, $xml, $tags); - xml_parser_free($parser); + if ($xml = file_get_contents('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml')) { + $parser = xml_parser_create(); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); + xml_parse_into_struct($parser, $xml, $tags); + xml_parser_free($parser); - $elements = array(); // the currently filling [child] XmlElement array - $stack = array(); - foreach ($tags as $tag) { - $index = count($elements); - if ($tag['type'] == "complete" || $tag['type'] == "open") { - $elements[$index] = new XmlElement; - $elements[$index]->name = $tag['tag']; - $elements[$index]->attributes = $tag['attributes']; - $elements[$index]->content = $tag['value']; - if ($tag['type'] == "open") { // push - $elements[$index]->children = array(); - $stack[count($stack)] = &$elements; - $elements = &$elements[$index]->children; - } + $elements = array(); // the currently filling [child] XmlElement array + $stack = array(); + foreach ($tags as $tag) { + $index = count($elements); + if ($tag['type'] == "complete" || $tag['type'] == "open") { + $elements[$index] = new XmlElement; + $elements[$index]->name = $tag['tag']; + $elements[$index]->attributes = $tag['attributes']; + $elements[$index]->content = $tag['value']; + if ($tag['type'] == "open") { // push + $elements[$index]->children = array(); + $stack[count($stack)] = &$elements; + $elements = &$elements[$index]->children; + } + } + if ($tag['type'] == "close") { // pop + $elements = &$stack[count($stack) - 1]; + unset($stack[count($stack) - 1]); + } } - if ($tag['type'] == "close") { // pop - $elements = &$stack[count($stack) - 1]; - unset($stack[count($stack) - 1]); + + + $Currencies = array(); + foreach ($elements[0]->children[2]->children[0]->children as $CurrencyDetails){ + $Currencies[$CurrencyDetails->attributes['currency']]= $CurrencyDetails->attributes['rate'] ; } - } - - - $Currencies = array(); - foreach ($elements[0]->children[2]->children[0]->children as $CurrencyDetails){ - $Currencies[$CurrencyDetails->attributes['currency']]= $CurrencyDetails->attributes['rate'] ; - } - $Currencies['EUR']=1; //ECB delivers no rate for Euro - //return an array of the currencies and rates - return $Currencies; -} - + $Currencies['EUR']=1; //ECB delivers no rate for Euro + //return an array of the currencies and rates + return $Currencies; + } +} + function GetCurrencyRate($CurrCode,$CurrenciesArray) { if ((!isset($CurrenciesArray[$CurrCode]) or !isset($CurrenciesArray[$_SESSION['CompanyRecord']['currencydefault']]))){ return quote_oanda_currency($CurrCode); @@ -174,12 +175,12 @@ function AddCarriageReturns($str) { - return str_replace('\r\n',chr(10),$str); + return str_replace('\r\n',chr(10),$str); } function wikiLink($type, $id) { - + if ($_SESSION['WikiApp']==_('WackoWiki')){ echo '<a target="_blank" href="../' . $_SESSION['WikiPath'] . '/' . $type . $id . '">' . _('Wiki ' . $type . ' Knowlege Base') . '</A><BR>'; } elseif ($_SESSION['WikiApp']==_('MediaWiki')){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |