select('InternalOrderId') ->from('commande') ->where('CompanyId = '. $_GET['company']) ->andWhere('DataSetType ="'.$_GET['type'].'"') ->fetchOne(); $InternalOrderId = $OrderExists->InternalOrderId; $rapportExists = Doctrine_Query::create() ->select('CompanyId, UrlObjectRapportFile, DateTimeSave') ->from('rapport') ->where('CompanyId = '. $_GET['company']) ->andWhere('DataSetType = "'. $_GET['type'].'"') ->fetchOne(); $dateTime = new DateTime(); $dateTimeBDD = new DateTime($rapportExists->DateTimeSave); $daysOfRapport = $dateTime->diff($dateTimeBDD); if (!file_exists($rapportExists->UrlObjectRapportFile)) { $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; $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))) ? $saveRapport->Delivred = true : $saveRapport->Delivred = EXIT_FAILURE; $saveRapport->DateTimeSave = date('Y-m-d'); $saveRapport->save(); $rapport = $rapport->DataSet; } else ($rapport = unserialize(file_get_contents($rapportExists->UrlObjectRapportFile))) ? true : EXIT_FAILURE; ?>