#!/usr/bin/php -q 1) { foreach($argv as $value) { switch($value) { case 'availability': $availability = TRUE; break; case 'matchidentifiers': $matchidentifiers = TRUE; break; case 'matchmethods': $matchmethods = TRUE; break; case 'commandes': $checkCommandes = FALSE; break; case 'all': $checkCommandes = TRUE; $matchidentifiers = TRUE; $matchmethods = TRUE; $checkCommandes = FALSE; break; default: break; } } }else{ print $argv[0]." version : ".$version."\n\n"; print "Lancer le script ".$argv[0]." sans paramètres permet de charger toutes les méthodes graydon et vérifier les commandes\n\n"; print "Les services disponibles sont :\n"; print "\t-Disponibilité des pays graydon (availability).\n"; print "\t-Types d'identifiant disponible par pays (matchidentifiers).\n"; print "\t-Méthodes de recherche (matchmethods).\n"; print "\t-Vérification des commandes (commandes).\n"; exit; } require_once '../config/prepend.php'; //Inclure la base de données require_once 'dbbootstrap.php'; //Inclure la config graydon require_once 'graydon/graydon.php'; setDbConn('graydon'); if($availability === TRUE) { //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; foreach($result->CountryAvailablity->CountryAndProduct as $item) { $availability = array(); $availability = $item->Products->Product; //Enregistrement pour chaque pays de la disponibilité des services $countryavailability = new Countryavailability(); $countryavailability->country = $item->Country; $countryavailability->availability = serialize($availability); $countryavailability->replace(); } }catch( SoapFault $fault ){} } if($matchidentifiers === TRUE) { //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; foreach($result->CompanyMatchIdentifiers->CompanyMatchIdentifier as $item){ $tabIdentifiers = array(); $tabIdentifiers = $item->CompanyIdentifier; //Stockage du résultat de la méthode en caches $matchidentifiers = new Matchidentifiers(); $matchidentifiers->country = $item->Country; $matchidentifiers->identifiers = serialize($tabIdentifiers); $matchidentifiers->replace(); } }catch( SoapFault $fault ){ $code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode; $text = $fault->detail->GraydonCompanyData_Fault->FaultMessage; $firephp->log($text,'texterror'); require_once 'graydon/graydon_error.php'; if(graydon_error($code, $text)!=FALSE){ if($code=='CWS0112'){ //Stockage du résultat de la méthode en cache $matchidentifiers = new Matchidentifiers(); $matchidentifiers->country = $pays; $matchidentifiers->identifiers = serialize('noidentifiers'); $matchidentifiers->replace(); } }else{ graydon_processSoapFault($graydon,$fault,$tabInfo); } } } if($matchmethods === TRUE) { //matchmethods $request = new StdClass(); $request->Authentication_Parameters = $authentication; try { $result = $graydon->getCompanyMatchMethods($request); $transactionIdentifier = $result->Service_Log->TransactionIdentifier; $sessionID = $result->Service_Log->SessionID; foreach($result->CompanyMatchMethods->CompanyMatchMethod as $item){ $methods = array(); $methods = $item->MatchMethods->MatchMethod; //Stockage du résultat de la méthode en cache $matchmethods = new Matchmethods(); $matchmethods->country = $item->Country; $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('nomethods'); $matchmethods->replace(); } }else{ graydon_processSoapFault($graydon,$fault,''); } } } if($checkCommandes === TRUE) { //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é, on a été la chercher //On ne fait rien break; case 'ReCompleted': case 'Completed': //Si serviceSpeed est différent de immediate //alors c'est une commande passé en mode normal ou superflash //getCompanyReport => On récupère le rapport //Si le format est en HMTL //Si le format est en XML //Si le format est en DOC break; case 'InError': //Problème dans la commande break; case 'Notified': break; case 'Initialised': //Commande prise en compte $orderstart = 'Initialised'; case 'Assigned': //Assigné chez graydon $orderstart = 'Assigned'; case '': // Pas d'é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; } } } } ?>