本文整理汇总了PHP中SoapClient::GetCursOnDate方法的典型用法代码示例。如果您正苦于以下问题:PHP SoapClient::GetCursOnDate方法的具体用法?PHP SoapClient::GetCursOnDate怎么用?PHP SoapClient::GetCursOnDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoapClient
的用法示例。
在下文中一共展示了SoapClient::GetCursOnDate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrencyForDate
private function getCurrencyForDate($date)
{
$soap = new \SoapClient('http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?WSDL');
$result = new \SimpleXMLElement($soap->GetCursOnDate(['On_date' => $date])->GetCursOnDateResult->any);
foreach ($result->ValuteData->ValuteCursOnDate as $valute) {
if ($valute->VchCode == self::USD) {
return floatval($valute->Vcurs);
}
}
}
示例2: __construct
/**
* This method creates a connection to webservice of Central Bank of Russia
* and obtains exchange rates, parse it and fills $rates property
*
* @param string $date The date on which exchange rates will be obtained
*/
public function __construct($date = null)
{
if (!isset($date)) {
$date = date("Y-m-d");
}
$client = new SoapClient("http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?WSDL");
$curs = $client->GetCursOnDate(array("On_date" => $date));
$rates = new SimpleXMLElement($curs->GetCursOnDateResult->any);
foreach ($rates->ValuteData->ValuteCursOnDate as $rate) {
$r = (double) $rate->Vcurs / (int) $rate->Vnom;
$this->rates['byChCode'][(string) $rate->VchCode] = $r;
$this->rates['byCode'][(int) $rate->Vcode] = $r;
}
// Adding an exchange rate of Russian Ruble
$this->rates['byChCode']['RUB'] = 1;
$this->rates['byCode'][643] = 1;
}
示例3: getRates
/**
* Load rates by date
*
* @param ICurrency[] $currencies
* @param \DateTime $date
* @return ICurrencyRate[]
*/
public function getRates($currencies, \DateTime $date = null)
{
if ($date === null) {
$date = new \DateTime('now');
}
$client = new \SoapClient("http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?WSDL");
$curs = $client->GetCursOnDate(array("On_date" => $date->format('Y-m-d')));
$ratesXml = new \SimpleXMLElement($curs->GetCursOnDateResult->any);
$result = array();
foreach ($currencies as $currency) {
$rateCbr = $ratesXml->xpath('ValuteData/ValuteCursOnDate/VchCode[.="' . $currency->getCode() . '"]/parent::*');
if (empty($rateCbr)) {
continue;
}
$rate = $this->currencyRateManager->getNewInstance($this->currencyManager->getCurrency($currency->getCode()), $this, $date, (double) $rateCbr[0]->Vcurs, (int) $rateCbr[0]->Vnom);
$result[$currency->getCode()] = $rate;
}
return $result;
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getContainer()->get('doctrine')->getEntityManager();
$client = new \SoapClient("http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?WSDL");
if (!isset($date)) {
$date = date("Y-m-d");
}
$curs = $client->GetCursOnDate(array("On_date" => $date));
$this->rates = new \SimpleXMLElement($curs->GetCursOnDateResult->any);
$currencies = $em->getRepository('ChewbaccaExchangeRatesBundle:Currency')->createQueryBuilder('c')->getQuery()->getResult();
foreach ($currencies as $cur) {
$rate = $this->GetRate($cur->getMnemo());
$cur->setRate($rate);
$output->write($cur->getMnemo() . ' rate is: ' . $cur->getRate(), true);
$em->persist($cur);
}
$em->flush();
$output->write('all rates updated', true);
return 0;
}
示例5: init
public function init()
{
parent::init();
if (!isset($date)) {
$date = date("Y-m-d");
}
$this->soapUrl = Yii::$app->params['cbrfSOAPURL'];
$client = new \SoapClient($this->soapUrl);
$curs = $client->GetCursOnDate(array("On_date" => $date));
$rates = new \SimpleXMLElement($curs->GetCursOnDateResult->any);
foreach ($rates->ValuteData->ValuteCursOnDate as $rate) {
$rateArray = [];
$rateArray['name'] = (string) $rate->Vname;
$rateArray['code'] = (int) $rate->Vcode;
$rateArray['chCode'] = (string) $rate->VchCode;
$this->currency[] = $rateArray;
$r = (double) $rate->Vcurs / (int) $rate->Vnom;
$this->rates['byChCode'][(string) $rate->VchCode] = ['rate' => $r, 'curs' => (double) $rate->Vcurs, 'nom' => (int) $rate->Vnom];
$this->rates['byCode'][(int) $rate->Vcode] = ['rate' => $r, 'curs' => (double) $rate->Vcurs, 'nom' => (int) $rate->Vnom];
}
// Adding an exchange rate of Russian Ruble
$this->rates['byChCode']['RUB'] = 1;
$this->rates['byCode'][643] = 1;
}
示例6: getRates
public function getRates($otherCurrencyCode, $dateParam, $cron = false)
{
$db = PearDatabase::getInstance();
$moduleModel = Settings_CurrencyUpdate_Module_Model::getCleanInstance();
$selectedBank = $moduleModel->getActiveBankId();
$yesterday = date('Y-m-d', strtotime('-1 day'));
// check if data is correct, currency rates can be retrieved only for working days
$lastWorkingDay = Vtiger_Functions::getLastWorkingDay($yesterday);
$today = date('Y-m-d');
$mainCurrency = Vtiger_Functions::getDefaultCurrencyInfo()['currency_code'];
$dateCur = $dateParam;
$source = $this->getSource();
$client = new \SoapClient($source[0]);
$curs = $client->GetCursOnDate(array('On_date' => $dateCur));
$ratesXml = new \SimpleXMLElement($curs->GetCursOnDateResult->any);
$datePublicationOfFile = $dateCur;
$exchangeRate = 1.0;
// if currency is diffrent than RUB we need to calculate rate for converting other currencies to this one from RUB
if ($mainCurrency != $this->getMainCurrencyCode()) {
foreach ($ratesXml->ValuteData[0] as $currencyRate) {
if ($currencyRate->VchCode == $mainCurrency) {
echo $currencyRate->VchCode . ' == ' . $mainCurrency . ' = ' . $currencyRate->Vcurs;
$exchangeRate = $currencyRate->Vcurs;
}
}
}
foreach ($ratesXml->ValuteData[0] as $currencyRate) {
$currency = (string) $currencyRate->VchCode;
foreach ($otherCurrencyCode as $key => $currId) {
if ($key == $currency && $currency != $mainCurrency) {
$curs = (string) $currencyRate->Vcurs;
$nom = (string) $currencyRate->Vnom;
$exchange = $curs / $nom;
$exchangeVtiger = $exchangeRate / $exchange;
$exchange = $exchange / $exchangeRate;
if ($cron == true || (strtotime($dateParam) == strtotime($today) || strtotime($dateParam) == strtotime($lastWorkingDay))) {
$moduleModel->setCRMConversionRate($currency, $exchangeVtiger);
}
$existingId = $moduleModel->getCurrencyRateId($currId, $datePublicationOfFile, $selectedBank);
if ($existingId > 0) {
$moduleModel->updateCurrencyRate($existingId, $exchange);
} else {
$moduleModel->addCurrencyRate($currId, $datePublicationOfFile, $exchange, $selectedBank);
}
}
}
}
// currency diffrent than RUB, we need to add manually RUB rates
if ($mainCurrency != $this->getMainCurrencyCode()) {
$exchange = 1.0 / $exchangeRate;
$mainCurrencyId = false;
foreach ($otherCurrencyCode as $code => $id) {
if ($code == $this->getMainCurrencyCode()) {
$mainCurrencyId = $id;
}
}
if ($mainCurrencyId) {
if ($cron == true || (strtotime($dateParam) == strtotime($today) || strtotime($dateParam) == strtotime($lastWorkingDay))) {
$moduleModel->setCRMConversionRate($this->getMainCurrencyCode(), $exchangeRate);
}
$existingId = $moduleModel->getCurrencyRateId($mainCurrencyId, $datePublicationOfFile, $selectedBank);
if ($existingId > 0) {
$moduleModel->updateCurrencyRate($existingId, $exchange);
} else {
$moduleModel->addCurrencyRate($mainCurrencyId, $datePublicationOfFile, $exchange, $selectedBank);
}
}
}
}