152 lines
4.5 KiB
PHP
152 lines
4.5 KiB
PHP
|
<?php
|
|||
|
require_once '../config/prepend.php';
|
|||
|
//Inclure la base de donn<6E>es
|
|||
|
require_once 'dbbootstrap.php';
|
|||
|
//Inclure la config graydon
|
|||
|
require_once 'graydon/graydonws.php';
|
|||
|
|
|||
|
//Country Availability
|
|||
|
$request = new StdClass();
|
|||
|
$request->Authentication_Parameters = $authentication;
|
|||
|
try
|
|||
|
{
|
|||
|
$result = $graydon->getCountryAvailability($request);
|
|||
|
//Enregistrement de l'action dans les logs
|
|||
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|||
|
$sessionID = $result->Service_Log->SessionID;
|
|||
|
graydonRequeteLog('batch', 'batch', 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
|
|||
|
foreach($result->CountryAvailablity->CountryAndProduct as $item){
|
|||
|
//Enregistrement pour chaque pays de la disponibilit<69> des services
|
|||
|
$countryavailability = new Countryavailability();
|
|||
|
$countryavailability->country = $item->Country;
|
|||
|
$count = count($item->Products->Product);
|
|||
|
if ($count>1){
|
|||
|
$availability = $item->Products->Product;
|
|||
|
}elseif($count==1){
|
|||
|
$availability[] = $item->Products->Product;
|
|||
|
}
|
|||
|
$countryavailability->availability = serialize($availability);
|
|||
|
$countryavailability->replace();
|
|||
|
}
|
|||
|
}catch( SoapFault $fault ){
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//matchidentifiers
|
|||
|
$request = new StdClass();
|
|||
|
$request->Authentication_Parameters = $authentication;
|
|||
|
try
|
|||
|
{
|
|||
|
$result = $graydon->getCompanyMatchIdentifiers($request);
|
|||
|
//Enregistrement de l'action dans les logs
|
|||
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|||
|
$sessionID = $result->Service_Log->SessionID;
|
|||
|
graydonRequeteLog('batch', 'batch', 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
|
|||
|
|
|||
|
foreach($result->CompanyMatchIdentifiers->CompanyMatchIdentifier as $item){
|
|||
|
$count = count($item->CompanyIdentifier);
|
|||
|
if ($count>1){
|
|||
|
$tabIdentifiers = $item->CompanyIdentifier;
|
|||
|
}elseif($count==1){
|
|||
|
$tabIdentifiers[] = $item->CompanyIdentifier;
|
|||
|
}
|
|||
|
//Stockage du r<>sultat de la m<>thode en cache
|
|||
|
$matchidentifiers = new Matchidentifiers();
|
|||
|
$matchidentifiers->country = $item->Country;
|
|||
|
$matchidentifiers->identifiers = serialize($tabIdentifiers);
|
|||
|
$matchidentifiers->replace();
|
|||
|
}
|
|||
|
}catch( SoapFault $fault ){
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//matchmethods
|
|||
|
$request = new StdClass();
|
|||
|
$request->Authentication_Parameters = $authentication;
|
|||
|
try
|
|||
|
{
|
|||
|
$result = $graydon->getCompanyMatchMethods($request);
|
|||
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|||
|
$sessionID = $result->Service_Log->SessionID;
|
|||
|
graydonRequeteLog('batch', 'batch', 'getCompanyMatchMethods', $transactionIdentifier, $sessionID);
|
|||
|
|
|||
|
foreach($result->CompanyMatchMethods->CompanyMatchMethod as $item){
|
|||
|
$count = count($item->MatchMethods->MatchMethod);
|
|||
|
//Stockage du r<>sultat de la m<>thode en cache
|
|||
|
$matchmethods = new Matchmethods();
|
|||
|
$matchmethods->country = $item->Country;
|
|||
|
if ($count>1){
|
|||
|
$methods = $item->MatchMethods->MatchMethod;
|
|||
|
}elseif($count==1){
|
|||
|
$methods[] = $item->MatchMethods->MatchMethod;
|
|||
|
}
|
|||
|
$matchmethods->methods = serialize($methods);
|
|||
|
$matchmethods->replace();
|
|||
|
}
|
|||
|
|
|||
|
}catch( SoapFault $fault ){
|
|||
|
$code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode;
|
|||
|
$text = $fault->detail->GraydonCompanyData_Fault->FaultMessage;
|
|||
|
$firephp->log($text,'texterror');
|
|||
|
require_once 'graydon/error.php';
|
|||
|
if(graydon_error($code, $text)!=FALSE){
|
|||
|
if($code=='CWS0112'){
|
|||
|
//Stockage du r<>sultat de la m<>thode en cache
|
|||
|
$matchmethods = new Matchmethods();
|
|||
|
$matchmethods->country = $pays;
|
|||
|
$matchmethods->methods = serialize('false');
|
|||
|
$matchmethods->replace();
|
|||
|
}
|
|||
|
}else{
|
|||
|
graydon_processSoapFault($graydon,$fault,'');
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//V<>rification des commandes
|
|||
|
$q = Doctrine_Query::create()
|
|||
|
->select('*')
|
|||
|
->from('Commandes');
|
|||
|
|
|||
|
$tabCommandes = $q->Execute();
|
|||
|
|
|||
|
//Pour chaque commande ('Completed','Assigned','InError','Initialised','Delivered','Notified','ReCompleted')
|
|||
|
foreach($tabCommandes as $commande){
|
|||
|
|
|||
|
//Si servicespeed = immediate alors on ne g<>re pas
|
|||
|
if($commande->servicespeed != 'Immediate'){
|
|||
|
switch($commande->orderstate){
|
|||
|
case 'Delivered': //D<>livr<76>, on a <20>t<EFBFBD> la chercher
|
|||
|
//On ne fait rien
|
|||
|
break;
|
|||
|
|
|||
|
case 'Completed': //Commande pr<70>te <20> t<>l<EFBFBD>charger
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
case 'InError': //Probl<62>me dans la commande
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
case 'Notified':
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
case 'Initialised': //Commande prise en compte
|
|||
|
case 'Assigned': //Assign<67> chez graydon
|
|||
|
case ''; // Pas d'<27>tat, commande pas encore v<>rifier
|
|||
|
case 'default':
|
|||
|
|
|||
|
|
|||
|
$q = Doctrine_Query::create()
|
|||
|
->update('Commandes')
|
|||
|
->set('orderstate', $orderstate)
|
|||
|
->where('reference = ?', array($commande->reference));
|
|||
|
|
|||
|
$q->execute();
|
|||
|
|
|||
|
break;
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
?>
|