76 lines
3.0 KiB
PHP
76 lines
3.0 KiB
PHP
<?php
|
|
require_once ('giant/Config.php');
|
|
require_once ('giant/Client.php');
|
|
require_once ('giant/modulesGiants/Functions.php');
|
|
require_once ('dbbootstrap.php');
|
|
|
|
set_time_limit(60);
|
|
|
|
setDbConn('giantclient');
|
|
$OrderExists = Doctrine_Query::create()
|
|
->select('InternalOrderId')
|
|
->from('commande')
|
|
->where('CompanyId = '. $_GET['company'])
|
|
->andWhere('DataSetType ="'.$_GET['type'].'"')
|
|
->fetchOne();
|
|
$InternalOrderId = $OrderExists->InternalOrderId;
|
|
|
|
if (empty($InternalOrderId))
|
|
{
|
|
$soap_client = getClient($_GET['pays'], 'OrderDataSet');
|
|
$OrderDataSet = new CreditDataPortType();
|
|
|
|
$params = $OrderDataSet->OrderDataSet();
|
|
$params->OrderDataSet->CompanyId = $_GET['company'];
|
|
$params->OrderDataSet->DataSetType = new stdClass();
|
|
$params->OrderDataSet->DataSetType->_ = $_GET['type'];
|
|
$params->OrderDataSet->LanguageCode = $_GET['lang'];
|
|
$params->OrderDataSet->DataSetVersion = "1.0";
|
|
$informations = SwitchWSDLFunction('OrderDataSet', $params->OrderDataSet, $soap_client);
|
|
|
|
$request = new commande();
|
|
$request->Login = $_SESSION['tabInfo']['login'];
|
|
$request->Ip = $_SESSION['tabInfo']['ip'];
|
|
$request->ProviderOrderId = $informations->Order->ProviderOrderId;
|
|
$request->InternalOrderId = $informations->Order->InternalOrderId;
|
|
$request->ConsumerId = $informations->Order->ConsumerId;
|
|
$request->ProviderId = $informations->Order->ProviderId;
|
|
$request->CountryCode = $informations->Order->CountryCode;
|
|
$request->CompanyId = $informations->Order->CompanyId;
|
|
$request->DataSetType = $informations->Order->DataSetType->_;
|
|
$request->OrderDateTime = $informations->Order->OrderDateTime;
|
|
$request->save();
|
|
$InternalOrderId = $informations->Order->InternalOrderId;
|
|
}
|
|
|
|
$rapportExists = Doctrine_Query::create()
|
|
->select('CompanyId, UrlObjectRapportFile')
|
|
->from('rapport')
|
|
->where('CompanyId = '. $_GET['company'])
|
|
->andWhere('DataSetType = "'. $_GET['type'].'"')
|
|
->fetchOne();
|
|
|
|
if (empty($rapportExists->CompanyId)) {
|
|
|
|
$nameFileRapport = 'rapport-'.date('Y-m-d').'-'.$_GET['pays'].'-'.$_GET['company'].'-'.$_GET['type'];
|
|
$soap_client2 = getClient($_GET['pays'], 'RetrieveDataSet');
|
|
|
|
$RetrieveDataSet = new CreditDataPortType();
|
|
$params = $RetrieveDataSet->RetrieveDataSet();
|
|
|
|
$params->RetrieveDataSet->InternalOrderId = $InternalOrderId;
|
|
$rapport = SwitchWSDLFunction('RetrieveDataSet', $params->RetrieveDataSet, $soap_client2);
|
|
|
|
$directory = _ifDirectoryExist(PATH_DATA.'/giant/'.$_GET['company'].'/');
|
|
$saveRapport = new rapport();
|
|
$saveRapport->CompanyId = $_GET['company'];
|
|
$saveRapport->DataSetType = $_GET['type'];
|
|
$saveRapport->UrlObjectRapportFile = $directory.$nameFileRapport;
|
|
(file_put_contents($directory.$nameFileRapport, serialize($rapport->DataSet))) ? true : EXIT_FAILURE;
|
|
$saveRapport->DateTimeSave = date('Y-m-d');
|
|
$saveRapport->save();
|
|
$rapport = $rapport->DataSet;
|
|
} else {
|
|
($rapport = unserialize(file_get_contents($rapportExists->UrlObjectRapportFile))) ? true : EXIT_FAILURE;
|
|
}
|
|
?>
|