extranet/batch/graydon.php

215 lines
6.1 KiB
PHP
Raw Normal View History

#!/usr/bin/php -q
2009-05-07 16:08:45 +00:00
<?php
2009-10-28 14:18:22 +00:00
$version = '0.3';
$argc = $_SERVER['argc'];
$argv = $_SERVER['argv'];
2009-10-28 14:18:22 +00:00
if($argc > 1)
{
foreach($argv as $value)
{
switch($value)
{
case 'availability':
2009-10-28 14:18:22 +00:00
$availability = TRUE;
break;
case 'matchidentifiers':
2009-10-28 14:18:22 +00:00
$matchidentifiers = TRUE;
break;
case 'matchmethods':
2009-10-28 14:18:22 +00:00
$matchmethods = TRUE;
break;
case 'commandes':
$checkCommandes = FALSE;
break;
2009-06-08 09:22:59 +00:00
case 'all':
$checkCommandes = TRUE;
$matchidentifiers = TRUE;
$matchmethods = TRUE;
$checkCommandes = FALSE;
break;
default:
2009-06-08 09:22:59 +00:00
break;
}
}
2009-06-08 09:22:59 +00:00
}else{
print $argv[0]." version : ".$version."\n\n";
print "Lancer le script ".$argv[0]." sans param<61>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<69> 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-07 16:08:45 +00:00
require_once '../config/prepend.php';
//Inclure la base de donn<6E>es
require_once 'dbbootstrap.php';
//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
setDbConn('graydon');
2009-05-07 16:08:45 +00:00
2009-10-28 14:18:22 +00:00
if($availability === TRUE)
2009-10-09 13:25:07 +00:00
{
//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;
2009-10-28 14:18:22 +00:00
foreach($result->CountryAvailablity->CountryAndProduct as $item)
{
$availability = array();
2009-10-28 14:18:22 +00:00
$availability = $item->Products->Product;
//Enregistrement pour chaque pays de la disponibilit<69> des services
$countryavailability = new Countryavailability();
$countryavailability->country = $item->Country;
$countryavailability->availability = serialize($availability);
$countryavailability->replace();
2009-05-07 16:08:45 +00:00
}
}catch( SoapFault $fault ){}
2009-05-07 16:08:45 +00:00
}
2009-10-28 14:18:22 +00:00
if($matchidentifiers === TRUE)
2009-10-09 13:25:07 +00:00
{
//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();
2009-10-28 14:18:22 +00:00
$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();
2009-05-07 16:08:45 +00:00
}
2009-06-08 09:22:59 +00:00
}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;
2009-10-28 14:18:22 +00:00
$matchidentifiers->identifiers = serialize('noidentifiers');
2009-06-08 09:22:59 +00:00
$matchidentifiers->replace();
}
}else{
graydon_processSoapFault($graydon,$fault,$tabInfo);
}
}
2009-05-07 16:08:45 +00:00
}
2009-10-28 14:18:22 +00:00
if($matchmethods === TRUE)
2009-10-09 13:25:07 +00:00
{
//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();
2009-10-28 14:18:22 +00:00
$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;
2009-10-28 14:18:22 +00:00
$matchmethods->methods = serialize('nomethods');
$matchmethods->replace();
}
}else{
graydon_processSoapFault($graydon,$fault,'');
}
}
}
2009-05-07 16:08:45 +00:00
2009-10-28 14:18:22 +00:00
if($checkCommandes === TRUE)
2009-10-09 13:25:07 +00:00
{
//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;
2009-10-09 13:25:07 +00:00
case 'ReCompleted':
case 'Completed':
//Si serviceSpeed est diff<66>rent de immediate
//alors c'est une commande pass<73> en mode normal ou superflash
//getCompanyReport => On r<>cup<75>re le rapport
//Si le format est en HMTL
//Si le format est en XML
//Si le format est en DOC
break;
2009-05-07 16:08:45 +00:00
case 'InError': //Probl<62>me dans la commande
break;
2009-05-07 16:08:45 +00:00
case 'Notified':
break;
case 'Initialised': //Commande prise en compte
2009-10-09 13:25:07 +00:00
$orderstart = 'Initialised';
case 'Assigned': //Assign<67> chez graydon
2009-10-09 13:25:07 +00:00
$orderstart = 'Assigned';
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;
2009-05-07 16:08:45 +00:00
}
2009-05-07 16:08:45 +00:00
}
}
}
?>