log($_SESSION, 'SESSION');
if(isset($_REQUEST['paysCode'])){
$paysCode = $_REQUEST['paysCode'];
}else{
$paysCode = $_SESSION['graydon']['paysCode'];
}
$firephp->log($paysCode, 'paysCode');
$tabInfo = $_SESSION['tabInfo'];
$mode = $_SESSION['graydon']['mode'];
require_once 'dbbootstrap.php';
require_once 'graydon/graydonws.php';
require_once 'graydon/graydon_log.php';
setDbConn('graydon');
$q = Doctrine_Query::Create()
->select('graydon_country')
->from('Country')
->where('code = ?', $paysCode);
$result = $q->fetchOne();
$pays = $result->graydon_country;
$firephp->log($pays, 'pays');
$_SESSION['graydon']['paysCode'] = $paysCode;
$_SESSION['graydon']['pays'] = $pays;
//Disponibilité des pays
$q = Doctrine_Query::create()
->from('Countryavailability')
->where('country = ?', $pays);
$firephp->log($q->getSql(),'SQL');
$countryavailability = new Countryavailability();
$countryavailability = $q->fetchOne();
if($countryavailability == FALSE){
// Create the request parameters
$request = new StdClass();
// Initialise the request object
$request->Authentication_Parameters = $authentication;
$request->Country = $pays;
try
{
$result = $graydon->getCountryAvailability($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
graydonRequeteLog( $tabInfo['login'], $page, 'getCountryAvailability', $transactionIdentifier, $sessionID);
//Log de la requete dans la bdd
$log = new Requetelog();
$log->login = $tabInfo['login'];
$log->action = 'getCountryAvailability';
$log->request = serialize($request);
$log->transactionIdentifier = $transactionIdentifier;
$log->sessionID = $sessionID;
$log->mode = $mode;
$log->save();
$count = count($result->CountryAvailablity->CountryAndProduct->Products->Product);
if ($count>1){
$availability = $result->CountryAvailablity->CountryAndProduct->Products->Product;
}elseif($count==1){
$availability[] = $result->CountryAvailablity->CountryAndProduct->Products->Product;
}
//Stockage du résultat de la méthode en cache
$countryavailability = new Countryavailability();
$countryavailability->country = $pays;
$countryavailability->availability = serialize($availability);
$countryavailability->replace();
//file_put_contents($path.'/'.$fileName, serialize($availability));
}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){
graydon_processSoapFault($graydon,$fault,$tabInfo);
}
}
}else{
$availability = unserialize($countryavailability->availability);
}
//Méthodes de recherche disponible pour les pays
$q = Doctrine_Query::create()
->from('Matchmethods')
->where('country = ?', $pays);
$matchmethods = new Matchmethods();
$matchmethods = $q->fetchOne();
if($matchmethods == FALSE){
// Create the request parameters
$request = new StdClass();
// Initialise the request object
$request->Authentication_Parameters = $authentication;
$request->Country = $pays;
try
{
$result = $graydon->getCompanyMatchMethods($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
graydonRequeteLog( $tabInfo['login'], $page, 'getCompanyMatchMethods', $transactionIdentifier, $sessionID);
//Log de la requete dans la bdd
$log = new Requetelog();
$log->login = $tabInfo['login'];
$log->action = 'getCompanyMatchMethods';
$log->request = serialize($request);
$log->transactionIdentifier = $transactionIdentifier;
$log->sessionID = $sessionID;
$log->mode = $mode;
$log->save();
$count = count($result->CompanyMatchMethods->CompanyMatchMethod->MatchMethods->MatchMethod);
if ($count>1){
$methods = $result->CompanyMatchMethods->CompanyMatchMethod->MatchMethods->MatchMethod;
}elseif($count==1){
$methods[] = $result->CompanyMatchMethods->CompanyMatchMethod->MatchMethods->MatchMethod;
}
//Stockage du résultat de la méthode en cache
$matchmethods = new Matchmethods();
$matchmethods->country = $pays;
$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/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,$tabInfo);
}
}
}else{
$methods = unserialize($matchmethods->methods);
}
if (isset($methods) && $methods!='false'){
$firephp->log($methods,'methods');
//Affichage de la meilleur méthode de recherche OU la première
$lien = 'La meilleure méthode de recherche vous est affiché par défault.
Effectuer un autre type recherche : ';
$flagBestMethod = false;
$countMethods = 0;
foreach($methods as $item){
$WithCity = $item->WithCity;
$WithPostCode = $item->WithPostCode;
if( ($item->BestMethod==TRUE && $item->MatchingMethod=='Keyword') && !isset($method) || $method=='keyword' ){
$flagBestMethod = TRUE;
require_once realpath(dirname(__FILE__)).'/method_keyword.php';
}elseif( ($item->BestMethod==TRUE && $item->MatchingMethod=='Identifier') && !isset($method) || $method=='identifier' ){
$flagBestMethod = TRUE;
require_once realpath(dirname(__FILE__)).'/method_identifier.php';
}elseif( ($item->BestMethod==TRUE && $item->MatchingMethod=='Name') && !isset($method) || $method=='name' ){
$flagBestMethod = TRUE;
require_once realpath(dirname(__FILE__)).'/method_name.php';
}elseif( ($item->BestMethod==TRUE && $item->MatchingMethod=='PostCode') && !isset($method) || $method=='postcode' ){
$flagBestMethod = TRUE;
require_once realpath(dirname(__FILE__)).'/method_postcode.php';
}
$countMethods++;
//Affichage des propostions des méthodes de recherche
if($item->MatchingMethod=='Keyword'){ $lien .= 'Par mots clés'; }
if($item->MatchingMethod=='Identifier'){ $lien .= 'Par identifiant'; }
if($item->MatchingMethod=='Name'){ $lien .= 'Par nom'; }
if($item->MatchingMethod=='PostCode'){ $lien .= 'Par Post Code'; }
if($countMethods>=count($methods)){ $separator=''; break; }else{ $separator=' - '; }
$lien = $lien.$separator;
}
print ''.$lien.'';
}else{
print '
Mode normal : | normal; ?> | , Délais : | normalDe==0){ print $delais->normalA.' jours'; }else{ print $delais->normalDe.' à '.$delais->normalA.' jours'; } ?> |
Mode rapide : | rapide; ?> | , Délais : | rapideDe==0){ print $delais->rapideA.' jours'; }else{ print $delais->rapideDe.' à '.$delais->rapideA.' jours'; } ?> |