Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F726427
in-commerce
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jan 5, 2:06 PM
Size
28 KB
Mime Type
text/x-diff
Expires
Tue, Jan 7, 2:06 PM (7 h, 2 m ago)
Engine
blob
Format
Raw Data
Handle
536553
Attached To
rMINC Modules.In-Commerce
in-commerce
View Options
Index: branches/5.0.x/in-commerce/units/taxes/taxes_tag_processor.php
===================================================================
--- branches/5.0.x/in-commerce/units/taxes/taxes_tag_processor.php (revision 12851)
+++ branches/5.0.x/in-commerce/units/taxes/taxes_tag_processor.php (revision 12852)
@@ -1,492 +1,489 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class TaxesTagProcessor extends kDBTagProcessor
{
/*
function ShowDestinations($param)
{
$zone =& $this->Application->recallObject('tax');
$zone->SetDBField('TaxZoneId', $zone->ID);
$destination =& $this->Application->recallObject('taxdst');
if(!$this->Application->GetVar('loaded'))
{
if ($zone->GetID() == 0)
{
$this->Application->DeleteVar('taxdst');
}
else
{
$sql = 'SELECT * FROM '.$destination->TableName.' WHERE TaxZoneId='.$zone->GetID();
$res = $this->Conn->Query($sql);
if (is_array($res)) foreach ($res as $dest_record)
{
$temp[$dest_record['TaxZoneDestId']]['TaxZoneDestId'] = $dest_record['TaxZoneDestId'];
$temp[$dest_record['TaxZoneDestId']]['StdDestId'] = $dest_record['StdDestId'];
$temp[$dest_record['TaxZoneDestId']]['DestValue'] = $dest_record['DestValue'];
}
$this->Application->SetVar('taxdst', $temp);
}
}
$destination =& $this->Application->recallObject('taxdst');
$hidden_clause = '<input type="hidden" name="loaded" value="1"><input type="hidden" name="zone_id" value="'.$zone->GetDBField('TaxZoneId').'">';
switch ( $zone->GetDBField('Type') )
{
case 1:
$sql = 'SELECT * FROM '.TABLE_PREFIX.'StdDestinations WHERE DestType=1';
$res = $this->Conn->Query($sql, 'DestId');
$dropdown = '<select name="country">'."\n";
foreach ($res as $record)
{
$dropdown .= '<option value="'.$record['DestId'].'">'.$this->Application->Phrase($record['DestName']).'</option>'."\n";
}
$dropdown .= '</select>'."\n";
$form_params = Array();
$form_params['dropdown'] = $dropdown;
$form_params['block'] = $param['block'];
$form_params['res'] = $res;
$ret = $this->ShowDestionationForm($form_params);
break;
case 2:
$country_sql = 'SELECT d1.* FROM '.TABLE_PREFIX.'StdDestinations d1,
'.TABLE_PREFIX.'StdDestinations d2
WHERE d1.DestType=1 AND d1.DestId=d2.DestParentId
GROUP BY d1.DestId';
if( !($current_country = $this->Application->GetVar('StatesCountry')) )
{
$current_country_sql = 'SELECT sd.DestParentId FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
WHERE sd.DestType=2 AND zd.TaxZoneId='.$zone->GetDBField('TaxZoneId');
if($zone->GetDBField('TaxZoneId'))
{
$current_country = $this->Conn->GetOne($current_country_sql);
}
if(!$current_country)
{
$current_country_sql = 'SELECT DestId FROM '.TABLE_PREFIX.'StdDestinations WHERE DestType=1';
$current_country = $this->Conn->GetOne($current_country_sql);
}
}
$states_sql = 'SELECT * FROM '.TABLE_PREFIX.'StdDestinations WHERE DestType=2 AND DestParentId='.$current_country;
$countries = $this->Conn->Query($country_sql, 'DestId');
$states = $this->Conn->Query($states_sql, 'DestId');
if($countries)
{
$countries_dropdown = '<select name="StatesCountry" onchange="submit_event(\'tax\', \'OnCountryChange\')">'."\n";
foreach ($countries as $record)
{
$countries_dropdown .= '<option value="'.$record['DestId'].'" ';
if($record['DestId'] == $current_country)
{
$countries_dropdown .= 'selected';
}
$countries_dropdown .= '>'.$this->Application->Phrase($record['DestName']).'</option>'."\n";
}
$countries_dropdown .= '</select>'."\n";
}
if($states)
{
$states_dropdown = '<select name="state">'."\n";
foreach ($states as $id => $record)
{
$states_dropdown .= '<option value="'.$record['DestId'].'">'.$this->Application->Phrase($record['DestName']).'</option>'."\n";
}
$states_dropdown .= '</select>'."\n";
}
$form_params = Array();
$table = '<table border="0"><tr><td>'.$this->Application->Phrase('la_Country').': </td><td>'.$countries_dropdown.'</td></tr>';
$table .= '<tr><td>'.$this->Application->Phrase('la_State').': </td><td>'.$states_dropdown.'</td></tr></table>';
$form_params['dropdown'] = $table;
$form_params['block'] = $param['block'];
$form_params['res'] = $states;
$ret = $this->ShowDestionationForm($form_params);
break;
case 3:
if( !($current_country = $this->Application->GetVar('StatesCountry')) )
{
$current_country_sql = 'SELECT sd.DestParentId FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
WHERE sd.DestType=2 AND zd.TaxZoneId='.$zone->GetDBField('TaxZoneId');
if($zone->GetDBField('TaxZoneId'))
{
$current_country = $this->Conn->GetOne($current_country_sql);
}
if(!$current_country)
{
$current_country_sql = 'SELECT StdDestId FROM '.$destination->TableName.' WHERE TaxZoneId='.$zone->GetID();
$current_country = $this->Conn->GetOne($current_country_sql);
}
if(!$current_country)
{
$current_country_sql = 'SELECT DestId FROM '.TABLE_PREFIX.'StdDestinations WHERE DestType=1';
$current_country = $this->Conn->GetOne($current_country_sql);
}
}
$country_sql = 'SELECT d1.* FROM '.TABLE_PREFIX.'StdDestinations d1
WHERE d1.DestType=1
GROUP BY d1.DestId';
$countries = $this->Conn->Query($country_sql, 'DestId');
if($countries)
{
$countries_dropdown = '<select name="StatesCountry" onchange="submit_event(\'tax\', \'OnCountryChange\')">'."\n";
foreach ($countries as $record)
{
print "<br>";
$countries_dropdown .= '<option value="'.$record['DestId'].'" ';
if($record['DestId'] == $current_country)
{
$countries_dropdown .= 'selected';
}
$countries_dropdown .= '>'.$this->Application->Phrase($record['DestName']).'</option>'."\n";
}
$countries_dropdown .= '</select>'."\n";
}
$sql = 'SELECT DestValue FROM '.$this->Application->getUnitOption('taxdst', 'TableName').' WHERE NOT(DestValue IS NULL) AND DestValue<>"" AND StdDestId='.$current_country;
$res = array_unique( $this->Conn->GetCol($sql) );
$dropdown = '<input type="text" name="zip_input" id="zip_input" size="15">';
if($res)
{
$dropdown .= ' or <select name="zip_dropdown">'."\n";
$dropdown .= '<option value=""></option>';
foreach ($res as $record)
{
$dropdown .= '<option value="'.$record.'">'.$record.'</option>'."\n";
}
$dropdown .= '</select>'."\n";
}
$table = '<table border="0"><tr><td>'.$this->Application->Phrase('la_Country').': </td><td>'.$countries_dropdown.'</td></tr>';
$table .= '<tr><td>'.$this->Application->Phrase('la_fld_ZIP').': </td><td>'.$dropdown.'</td></tr></table>';
$form_params = Array();
$form_params['dropdown'] = $table;
$form_params['block'] = $param['block'];
$form_params['res'] = $res;
$ret = $this->ShowDestionationForm($form_params);
break;
default:
}
$ret .= $hidden_clause;
return $ret;
}
*/
/*
function ShowDestionationForm($param)
{
$add_button = '<input type="button" class="button" value="'.$this->Application->Phrase('la_btn_AddLocation').'" onclick="submit_event(\'tax\', \'OnAddLocation\')">';
$main_processor =& $this->Application->RecallObject('m_TagProcessor');
$oddevenparam['odd'] = 'table-color1';
$oddevenparam['even'] = 'table-color2';
$ret = '<tr class="'.$main_processor->Odd_Even($oddevenparam).'"><td></td><td>'.$param['dropdown'].'</td><td>'.$add_button.'</td></tr>';
$dest_list = $this->Application->GetVar('taxdst');
if (is_array($dest_list))
{
if (sizeof($dest_list)>0){
$ret .= '<tr class="'.$main_processor->Odd_Even($oddevenparam).'"><td> </td><td>';
$ret .= '<select multiple name="location_list" onchange="SelectToString(this)">';
$hidden = '';
foreach ($dest_list as $id => $destination)
{
$params = $destination;
$params['id'] = $id;
$hidden .= '<input type="hidden" id="taxdst['.$destination['TaxZoneDestId'].'][TaxZoneDestId]" name="taxdst['.$destination['TaxZoneDestId'].'][TaxZoneDestId]" value="'.$destination['TaxZoneDestId'].'">';
if($destination['StdDestId'] && !$destination['DestValue'])
{
$params['destination_title'] = $param['res'][$destination['StdDestId']]['DestName'];
$hidden .= '<input type="hidden" id="taxdst['.$destination['TaxZoneDestId'].'][StdDestId]" name="taxdst['.$destination['TaxZoneDestId'].'][StdDestId]" value="'.$destination['StdDestId'].'">';
}
else
{
$params['destination_title'] = $destination['DestValue'];
$hidden .= '<input type="hidden" id="taxdst['.$destination['TaxZoneDestId'].'][DestValue]" name="taxdst['.$destination['TaxZoneDestId'].'][DestValue]" value="'.$destination['DestValue'].'">';
}
$params['name'] = $param['block'];
$ret .= $main_processor->ParseBlock($params);
}
$ret .= '</select>';
$ret .= '</td><td><input type="button" class="button" value="'.$this->Application->Phrase('la_btn_RemoveLocations').'" onclick="remove_location('.$destination['TaxZoneDestId'].')">';
$ret .= $hidden;
$ret .= " </td></tr>";
}else{
}
}
// <input type="hidden" id="taxdst[<inp:m_param name="id"/>][TaxZoneDestId]" name="taxdst[<inp:m_param name="id"/>][TaxZoneDestId]" value="<inp:m_param name="id"/>">
return $ret;
}
*/
function ShowCountries($param){
$param = $this->prepareTagParams($param);
$param['name'] = $param['block'];
$destination = &$this->Application->recallObject('taxdst');
$zone = &$this->Application->recallObject('tax');
switch ($param['show']){
case 'current':
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=1
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND zd.TaxZoneId='.$zone->GetDBField('TaxZoneId').'
ORDER BY Translation
';
break;
case 'available':
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=1
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND zd.TaxZoneId IS NULL
ORDER BY Translation
';
break;
case 'all':
$selected_country = $this->Application->GetVar('CountrySelector');
if (!$selected_country){
// get 1st available country ID
$selected_country = $this->Conn->GetOne('SELECT StdDestId FROM '.$destination->TableName.'
WHERE TaxZoneId='.$zone->GetDBField('TaxZoneId'));
if ($selected_country){
$this->Application->SetVar('CountrySelector', $selected_country);
}
}
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=1
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
ORDER BY Translation
';
break;
case 'has_states':
$has_states = $this->Conn->GetCol('SELECT DISTINCT DestParentId FROM '.TABLE_PREFIX.'StdDestinations sd
WHERE sd.DestType=2');
$selected_country = $this->Application->GetVar('CountrySelector');
if ($selected_country && !in_array($selected_country, $has_states)){
$selected_country = $has_states[0];
$this->Application->SetVar('CountrySelector', $selected_country);
}
if (!$selected_country){
// get 1st available country ID
$selected_country = $this->Conn->GetOne('SELECT DestParentId FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
WHERE sd.DestType=2
AND zd.TaxZoneId='.$zone->GetDBField('TaxZoneId'));
if ($selected_country){
$this->Application->SetVar('CountrySelector', $selected_country);
}
else {
$selected_country = $has_states[0];
$this->Application->SetVar('CountrySelector', $selected_country);
}
}
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=1
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND DestId IN ('.implode(',', $has_states).')
ORDER BY Translation
';
break;
}
$countries = $this->Conn->Query($sql);
$o = '';
foreach($countries as $key => $country) {
$param['id'] = $country['DestId'];
$param['destination_title'] = $this->Application->Phrase($country['DestName']);
if (isset($selected_country) && $selected_country == $param['id']){
$param['selected'] = ' selected="selected"';
}
else {
$param['selected']='';
}
$o .= $this->Application->ParseBlock($param);
}
return $o;
}
function ShowStates($param){
$param = $this->prepareTagParams($param);
$param['name'] = $param['block'];
$destination = &$this->Application->recallObject('taxdst');
$zone = &$this->Application->recallObject('tax');
switch ($param['show']){
case 'current':
$sql = 'SELECT * FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=2
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND sd.DestParentId='.$this->Application->GetVar('CountrySelector').'
AND zd.TaxZoneId='.$zone->GetDBField('TaxZoneId').'
ORDER BY Translation
';
break;
case 'available':
$sql = 'SELECT * FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.$destination->TableName.' zd
ON zd.StdDestId = sd.DestId
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=2
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND zd.TaxZoneId IS NULL
AND sd.DestParentId='.$this->Application->GetVar('CountrySelector').'
ORDER BY Translation
';
break;
case 'all':
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
LEFT JOIN '.TABLE_PREFIX.'Phrase
ON '.TABLE_PREFIX.'Phrase.Phrase = sd.DestName
WHERE sd.DestType=2
AND LanguageId='.$this->Application->GetVar('lang.current_id').'
AND sd.DestParentId='.$this->Application->GetVar('CountrySelector').'
ORDER BY Translation
';
break;
}
$states = $this->Conn->Query($sql);
$o = '';
foreach($states as $key => $state) {
$param['id'] = $state['DestId'];
$param['destination_title'] = $this->Application->Phrase($state['DestName']);
$o .= $this->Application->ParseBlock($param);
}
return $o;
}
function ShowZips($param){
$param = $this->prepareTagParams($param);
$param['name'] = $param['block'];
$destination = &$this->Application->recallObject('taxdst');
$zone = &$this->Application->recallObject('tax');
$country_selector = $this->Application->GetVar('CountrySelector');
if (!$country_selector){
$country_selector=0;
}
switch ($param['show']){
case 'current':
$sql = 'SELECT * FROM '.$destination->TableName.'
WHERE NOT(DestValue IS NULL)
AND DestValue<>""
AND TaxZoneID='.$zone->GetDBField('TaxZoneId').'
ORDER BY DestValue
';
break;
case 'available':
$selected_zips = $this->Conn->GetCol('SELECT DestValue FROM '.$destination->TableName.'
WHERE NOT(DestValue IS NULL)
AND DestValue<>""
AND TaxZoneID='.$zone->GetDBField('TaxZoneId').'
ORDER BY DestValue
');
$sql = 'SELECT DISTINCT(DestValue) FROM '.$this->Application->getUnitOption('taxdst', 'TableName').'
WHERE NOT(DestValue IS NULL)
AND TaxZoneID!='.$zone->GetDBField('TaxZoneId').'
AND DestValue NOT IN ("'.implode('", "', $selected_zips).'")
AND DestValue<>"" AND StdDestId='.$country_selector.'
ORDER BY DestValue
';
break;
case 'all':
$sql = 'SELECT sd.* FROM '.TABLE_PREFIX.'StdDestinations sd
WHERE sd.DestType=3 AND sd.DestParentId='.$country_selector.'
ORDER BY DestValue
';
break;
}
$zips = $this->Conn->Query($sql);
$o = '';
foreach($zips as $key => $zip) {
$param['id'] = $zip['DestId'].'|'.$zip['DestValue'];
$param['destination_title'] = $zip['DestValue'];
$o .= $this->Application->ParseBlock($param);
}
return $o;
}
-
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file
Index: branches/5.0.x/in-commerce/units/currencies/currency_rates.php
===================================================================
--- branches/5.0.x/in-commerce/units/currencies/currency_rates.php (revision 12851)
+++ branches/5.0.x/in-commerce/units/currencies/currency_rates.php (revision 12852)
@@ -1,286 +1,285 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class kCurrencyRates extends kBase {
var $RateSource;
var $ExchangeRates = Array();
var $PrimaryCurrency;
function kCurrencyRates()
{
$this->Application =& kApplication::Instance();
$this->GetRatesData();
}
function GetRatesData()
{
// written :) just check that it's correct
$conn =& $this->Application->GetADODBConnection();
$table = $this->Application->getUnitOption('curr', 'TableName');
$primary = $this->GetPrimaryCurrency();
$sql = 'SELECT "'.$primary.'" AS TARGET, ISO AS ID, RateToPrimary As RATE, 1 AS UNITS FROM '.$table.' WHERE 1';
$rates = $conn->Query($sql);
foreach ($rates as $a_rate) {
$this->SetRate($primary, $a_rate['ID'], $a_rate['RATE']);
}
}
function GetRate($source_cur, $target_cur, $units = 1)
{
$source_cur = ($source_cur == 'PRIMARY') ? $this->GetPrimaryCurrency() : $source_cur;
$target_cur = ($target_cur == 'PRIMARY') ? $this->GetPrimaryCurrency() : $target_cur;
if($source_cur == $target_cur)
{
return 1;
}
if($this->ExchangeRates[$target_cur]['TARGET'] == $source_cur)
{
$rate = ($this->ExchangeRates[$target_cur]['RATE'] == 0) ? false : 1 / $this->ExchangeRates[$target_cur]['RATE'];
}
elseif($this->ExchangeRates[$source_cur]['TARGET'] == $target_cur)
{
$rate = $this->ExchangeRates[$source_cur]['RATE'];
}
else
{
$rate = ($this->ExchangeRates[$target_cur]['RATE'] == 0) ? false : $this->ExchangeRates[$source_cur]['RATE'] / $this->ExchangeRates[$target_cur]['RATE'];
}
$rate *= $units;
return $rate;
}
function Convert($amount, $source_cur, $target_cur)
{
return $amount * $this->GetRate($source_cur, $target_cur);
}
function SetRate($source_cur, $target_cur, $rate, $units = 1)
{
$this->ExchangeRates[$target_cur]['TARGET'] = $source_cur;
$this->ExchangeRates[$target_cur]['ID'] = $target_cur;
$this->ExchangeRates[$target_cur]['RATE'] = $rate;
$this->ExchangeRates[$target_cur]['UNITS'] = $units;
}
function GetPrimaryCurrency()
{
if(!$this->PrimaryCurrency)
{
$conn =& $this->Application->GetADODBConnection();
$table = $this->Application->getUnitOption('curr', 'TableName');
$sql = 'SELECT ISO FROM '.$table.' WHERE IsPrimary = 1';
$this->PrimaryCurrency = $conn->GetOne($sql);
}
return $this->PrimaryCurrency;
}
function StoreRates($currencies=null)
{
$curr_object =& $this->Application->recallObject('curr', null, Array ('skip_autoload' => true));
/* @var $curr_object kDBItem */
if ($currencies) {
if (!is_array($currencies)) {
$currencies = explode(',', $currencies);
}
}
else {
$currencies = array_keys($this->ExchangeRates);
}
foreach ($currencies as $id) {
$rate = $this->GetRate($id, 'PRIMARY');
if ($rate) {
$curr_object->Clear();
$curr_object->Load($id, 'ISO');
$curr_object->SetDBField('RateToPrimary', $rate);
$curr_object->SetDBField('Modified_date', adodb_mktime());
$curr_object->SetDBField('Modified_time', adodb_mktime());
$curr_object->Update();
}
}
}
}
class kBankLVCurrencyRates extends kCurrencyRates {
function kBankLVCurrencyRates()
{
$this->RateSource = 'http://www.bank.lv/ValutuKursi/XML/xml.cfm';
parent::kCurrencyRates();
}
function GetRatesData()
{
$this->GetPrimaryCurrency();
$xml_parser = xml_parser_create();
$curl_helper =& $this->Application->recallObject('CurlHelper');
/* @var $curl_helper kCurlHelper */
$xml = $curl_helper->Send($this->RateSource);
xml_parse_into_struct($xml_parser, $xml, $struct, $index);
$data_res = Array();
$currency = '';
foreach($struct as $element)
{
switch($element['tag'])
{
case 'ID':
$currency = $element['value'];
$data_res[$currency]['ID'] = $currency;
$data_res[$currency]['TARGET'] = 'LVL';
break;
case 'UNITS':
$data_res[$currency]['UNITS'] = $element['value'];
break;
case 'RATE':
$data_res[$currency]['RATE'] = $element['value'];
break;
default:
}
}
if(!$data_res['LVL'])
{
$data_res['LVL']['ID'] = 'LVL';
$data_res['LVL']['UNITS'] = 1;
$data_res['LVL']['TARGET'] = 'LVL';
$data_res['LVL']['RATE'] = 1;
}
$this->ExchangeRates = $data_res;
}
}
class kECBCurrencyRates extends kCurrencyRates {
function kECBCurrencyRates()
{
$this->RateSource = 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml';
parent::kCurrencyRates();
}
function GetRatesData()
{
$this->GetPrimaryCurrency();
$xml_parser = xml_parser_create();
$curl_helper =& $this->Application->recallObject('CurlHelper');
/* @var $curl_helper kCurlHelper */
$xml = $curl_helper->Send($this->RateSource);
xml_parse_into_struct($xml_parser, $xml, $struct, $index);
$data_res = Array();
foreach($struct as $element)
{
if(isset($element['attributes']) && isset($element['attributes']['CURRENCY']))
{
$currency = $element['attributes']['CURRENCY'];
$data_res[$currency]['ID'] = $currency;
$data_res[$currency]['TARGET'] = 'EUR';
$data_res[$currency]['UNITS'] = 1;
$data_res[$currency]['RATE'] = ($element['attributes']['RATE'] == 0) ? 0 : 1 / $element['attributes']['RATE'];
}
}
if(!$data_res['EUR'])
{
$data_res['EUR']['ID'] = 'EUR';
$data_res['EUR']['UNITS'] = 1;
$data_res['EUR']['TARGET'] = 'EUR';
$data_res['EUR']['RATE'] = 1;
}
$this->ExchangeRates = $data_res;
}
}
class kFRNYCurrencyRates extends kCurrencyRates {
function kFRNYCurrencyRates()
{
$this->RateSource = 'http://www.ny.frb.org/markets/fxrates/FXtoXML.cfm?FEXdate=%s&FEXtime=1200';
parent::kCurrencyRates();
}
function GetRatesData()
{
$curl_helper =& $this->Application->recallObject('CurlHelper');
/* @var $curl_helper kCurlHelper */
$this->GetPrimaryCurrency();
for($i = 0; $i < 10; $i++)
{
$time = adodb_mktime() - $i * 3600 * 24;
$source_file = sprintf($this->RateSource, adodb_date('Y-m-d', $time));
$xml = $curl_helper->Send($source_file);
$xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $xml, $struct, $index);
foreach($struct as $element)
{
if($element['tag'] == 'FRBNY:DATASET')
{
break;
}
}
if($element['type'] == 'open')
{
break;
}
}
if($element['type'] != 'open')
{
return false;
}
foreach($struct as $element)
{
switch($element['tag'])
{
case 'FRBNY:SERIES':
$currency = $element['attributes']['UNIT'];
if($currency)
{
$data_res[$currency]['ID'] = $currency;
$data_res[$currency]['UNITS'] = 1;
}
break;
case 'FRBNY:CURR':
$data_res[$currency]['TARGET'] = $element['value'];
break;
case 'FRBNY:OBS_VALUE':
$data_res[$currency]['RATE'] = ($element['value'] == 0) ? 0 : 1 / $element['value'];
break;
default:
}
}
if(!$data_res['USD'])
{
$data_res['USD']['ID'] = 'USD';
$data_res['USD']['UNITS'] = 1;
$data_res['USD']['TARGET'] = 'USD';
$data_res['USD']['RATE'] = 1;
}
$this->ExchangeRates = $data_res;
}
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
Index: branches/5.0.x/in-commerce/install/prerequisites.php
===================================================================
--- branches/5.0.x/in-commerce/install/prerequisites.php (revision 12851)
+++ branches/5.0.x/in-commerce/install/prerequisites.php (revision 12852)
@@ -1,79 +1,77 @@
<?php
/**
* @version $Id$
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
$prerequisite_class = 'InCommercePrerequisites';
/**
* Class, that holds all prerequisite scripts for "In-Commerce" module
*
*/
class InCommercePrerequisites extends kHelper {
/**
* Install toolkit instance
*
* @var kInstallToolkit
*/
var $_toolkit = null;
/**
* Sets common instance of installator toolkit
*
* @param kInstallToolkit $instance
*/
function setToolkit(&$instance)
{
$this->_toolkit =& $instance;
}
/**
* Checks minimal version, that could be upgradeable
*
* @param string $mode when called mode {install, standalone, upgrade)
*/
function CheckPrerequisites($versions, $mode)
{
$errors = Array ();
if ($mode == 'standalone') {
if (!$this->Application->isModuleEnabled('In-Portal')) {
$errors[] = 'Please install or enable "In-Portal" module first';
}
}
if ($mode == 'upgrade') {
$sql = 'SELECT Version
FROM ' . TABLE_PREFIX . 'Modules
WHERE Name = "In-Portal"';
$inportal_version = $this->Conn->GetOne($sql);
if ($inportal_version === false) {
// only, when In-Portal was installed
return $errors;
}
$min_version = '4.3.1';
$current_version = $this->_toolkit->ConvertModuleVersion($inportal_version);
$needed_version = $this->_toolkit->ConvertModuleVersion($min_version);
if ($current_version < $needed_version) {
$errors[] = 'Please upgrade "In-Portal" to version ' . $min_version;
}
}
return $errors;
}
}
-
-?>
\ No newline at end of file
Event Timeline
Log In to Comment