2009-05-15 14:19:13 +00:00
|
|
|
#!/usr/bin/php -q
|
2009-05-07 16:08:45 +00:00
|
|
|
<?php
|
2009-10-28 14:18:22 +00:00
|
|
|
$version = '0.3';
|
2009-05-15 14:19:13 +00:00
|
|
|
$argc = $_SERVER['argc'];
|
|
|
|
$argv = $_SERVER['argv'];
|
|
|
|
|
2010-03-22 12:50:08 +00:00
|
|
|
if ($argc > 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 = true; break;
|
|
|
|
case 'all':
|
|
|
|
$checkCommandes = true;
|
|
|
|
$matchidentifiers = true;
|
|
|
|
$matchmethods = true;
|
|
|
|
$checkCommandes = true;
|
|
|
|
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;
|
2009-05-15 14:19:13 +00:00
|
|
|
}
|
|
|
|
|
2009-05-07 16:08:45 +00:00
|
|
|
require_once '../config/prepend.php';
|
2010-03-22 12:50:08 +00:00
|
|
|
// Inclure la base de données
|
2009-05-07 16:08:45 +00:00
|
|
|
require_once 'dbbootstrap.php';
|
2010-03-22 12:50:08 +00:00
|
|
|
// Inclure la config graydon
|
2009-10-28 14:18:22 +00:00
|
|
|
require_once 'graydon/graydon.php';
|
2009-05-07 16:08:45 +00:00
|
|
|
|
2009-05-15 14:19:13 +00:00
|
|
|
setDbConn('graydon');
|
2009-05-07 16:08:45 +00:00
|
|
|
|
2010-03-22 12:50:08 +00:00
|
|
|
if (isset($availability) == true && $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) {
|
|
|
|
}
|
2009-05-07 16:08:45 +00:00
|
|
|
}
|
|
|
|
|
2010-03-22 12:50:08 +00:00
|
|
|
if (isset($matchidentifiers) == true && $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);
|
|
|
|
}
|
|
|
|
}
|
2009-05-07 16:08:45 +00:00
|
|
|
}
|
|
|
|
|
2010-03-22 12:50:08 +00:00
|
|
|
if (isset($matchmethods) == true && $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,'');
|
|
|
|
}
|
|
|
|
}
|
2009-05-15 14:19:13 +00:00
|
|
|
}
|
2009-05-07 16:08:45 +00:00
|
|
|
|
2010-03-22 12:50:08 +00:00
|
|
|
if (isset($checkCommandes) == true && $checkCommandes === true) {
|
|
|
|
$q = Doctrine_Query::create()->select('*')->from('Commandes');
|
|
|
|
$tabCommandes = $q->execute();
|
|
|
|
foreach ($tabCommandes as $commande) {
|
|
|
|
if ($commande->servicespeed == 'Immediate' ||
|
|
|
|
$commande->reference == '') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
print 'Commande:'.
|
|
|
|
' servicespeed='.$commande->servicespeed.
|
|
|
|
' orderstate=' .$commande->orderstate.
|
|
|
|
' reference=' .$commande->reference.
|
|
|
|
"\n";
|
|
|
|
switch ($commande->orderstate) {
|
|
|
|
case 'Delivered':
|
|
|
|
case 'InError':
|
|
|
|
break;
|
|
|
|
// Mise à jour pour 'Notified', 'Initialised', 'Assigned', et ''
|
|
|
|
case 'Notified':
|
|
|
|
case 'Initialised':
|
|
|
|
case 'Assigned':
|
|
|
|
case '':
|
|
|
|
$requete = new StdClass();
|
|
|
|
$requete->Authentication_Parameters = $authentication;
|
|
|
|
$requete->OrderReference = $commande->reference;
|
|
|
|
try {
|
|
|
|
$checkOrderResult = $graydon->checkOrders($requete);
|
|
|
|
//print_r($checkOrderResult);
|
|
|
|
} catch (SoapFault $e) {
|
|
|
|
print 'erreur soap'."\n";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$orderstate =
|
|
|
|
$checkOrderResult->CheckOrders->OrderStatus[0]->OrderState;
|
|
|
|
print 'orderstate='.$orderstate."\n";
|
|
|
|
if ($orderstate != $commande->orderstate) {
|
|
|
|
$q = Doctrine_Query::create()
|
|
|
|
->update('Commandes')
|
|
|
|
->set('orderstate', '?', $orderstate)
|
|
|
|
->where('reference = ?', array($commande->reference));
|
|
|
|
$q->execute();
|
|
|
|
}
|
|
|
|
if (isset($checkOrderResult->CheckOrders->OrderStatus[0]->DateDue)) {
|
|
|
|
$datedue =
|
|
|
|
$checkOrderResult->CheckOrders->OrderStatus[0]->DateDue;
|
|
|
|
if ($datedue != $commande->datedue) {
|
|
|
|
$q = Doctrine_Query::create()
|
|
|
|
->update('Commandes')
|
|
|
|
->set('datedue', '?', $datedue)
|
|
|
|
->where('reference = ?', array($commande->reference));
|
|
|
|
$q->execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($orderstate != 'Completed' &&
|
|
|
|
$orderstate != 'ReCompleted') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Récupération pour 'Completed', 'CompletedwithUpdate',
|
|
|
|
// 'Delivered', et 'ReCompleted'
|
|
|
|
case 'Completed':
|
|
|
|
case 'CompletedwithUpdate':
|
|
|
|
//case 'Delivered':
|
|
|
|
case 'ReCompleted':
|
|
|
|
$requete = new StdClass();
|
|
|
|
$requete->Authentication_Parameters = $authentication;
|
|
|
|
$requete->LanguageCode = 'F';
|
|
|
|
$requete->OrderReference = $commande->reference;
|
|
|
|
// Récupération des MimeTypes
|
|
|
|
$pays = Doctrine_Query::create()
|
|
|
|
->from('Country')
|
|
|
|
->where('id = ?', $commande->country_id)
|
|
|
|
->fetchOne();
|
|
|
|
$pays = $pays->graydon_country;
|
|
|
|
$availability = getCountryAvailability($pays);
|
|
|
|
foreach($availability as $a) {
|
|
|
|
if ($a->ServiceSpeed == $commande->servicespeed) {
|
|
|
|
$mime_types = $a->MimeTypes->MimeType;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Récupération des documents
|
|
|
|
foreach ($mime_types as $m) {
|
|
|
|
$requete->MimeType = $m; // 'html', 'xml', 'pdf', 'doc'
|
|
|
|
try {
|
|
|
|
$checkOrderResult = $graydon->getCompanyReport($requete);
|
|
|
|
print_r($checkOrderResult);
|
|
|
|
} catch (SoapFault $e) {
|
|
|
|
print 'erreur soap'."\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Si le format est en HMTL
|
|
|
|
|
|
|
|
// Si le format est en XML
|
|
|
|
|
|
|
|
// Si le format est en DOC
|
|
|
|
|
|
|
|
// Delivered ?
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
print 'état inconnu\n';
|
|
|
|
}
|
|
|
|
}
|
2009-05-07 16:08:45 +00:00
|
|
|
}
|
|
|
|
?>
|