57 lines
1.9 KiB
PHP
57 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Permet de consulter Giant pour connaitre l'état d'une commande
|
|
* Mise a jour également des donnée celon le retour de Giant.
|
|
*
|
|
* @param $commande
|
|
*/
|
|
function EtatDesCommandes(&$commande)
|
|
{
|
|
$client = getClient($commande->CountryCode, 'RetrieveOrderStatus');
|
|
|
|
$order = new stdClass();
|
|
/*$order->ProviderOrderIdId = $commande->ProviderOrderId;*/
|
|
$order->InternalOrderId = $commande->InternalOrderId;
|
|
|
|
try {
|
|
$result = $client->RetrieveOrderStatus($order);
|
|
} catch (SoapFault $fault) {
|
|
getErreurSoap($result, $fault, true);
|
|
}
|
|
|
|
$status = $result->Order->OrderStatus;
|
|
if ($status == 'Undeliverable')
|
|
{
|
|
$commande->OrderStatus = $status;
|
|
$commande->save();
|
|
} else if ($status == 'Completed' && $commande->OrderStatus == 'Pending') {
|
|
try {
|
|
$dataSet = $client->RetrieveDataSet($order);
|
|
} catch (SoapFault $fault) {
|
|
getErreurSoap($dataSet, $fault, true);
|
|
}
|
|
// Mise a jour de la Table Rapport par rapport a la table Commande.
|
|
$rapport = new Rapport;
|
|
$rapport->ProviderId = $commande->ProviderId;
|
|
$rapport->CountryCode = $commande->CountryCode;
|
|
$rapport->CompanyId = $commande->CompanyId;
|
|
$rapport->ServiceLevelName = $commande->ServiceLevelName;
|
|
$rapport->DataSetType = $commande->DataSetType;
|
|
$rapport->LanguageCode = $commande->LanguageCode;
|
|
$rapport->DataSet = serialize($O->DataSet);
|
|
$rapport->OrderId = $commande->OrderId;
|
|
$rapport->User = $commande->User;
|
|
$rapport->DateTime = date('Y-m-d\TH:i:s');
|
|
$rapport->save();
|
|
|
|
//Mise a jour de la commande.
|
|
$commande->OrderStatus = 'Completed';
|
|
$commande->DateTimeCompleted = $rapport->DateTime;
|
|
$commande->ReportId = $rapport->ReportId;
|
|
$commande->save();
|
|
|
|
return ($status);
|
|
}
|
|
}
|
|
|
|
?>
|