247 lines
8.5 KiB
PHP
247 lines
8.5 KiB
PHP
<?php
|
|
session_start();
|
|
$firephp->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éfaut.<br/> 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 .= '<a href="?page=international_recherche&mode=normal&method=keyword">Par mots clés</a>'; }
|
|
if($item->MatchingMethod=='Identifier'){ $lien .= '<a href="?page=international_recherche&mode=normal&method=identifier">Par identifiant</a>'; }
|
|
if($item->MatchingMethod=='Name'){ $lien .= '<a href="?page=international_recherche&mode=normal&method=name">Par nom</a>'; }
|
|
if($item->MatchingMethod=='PostCode'){ $lien .= '<a href="?page=international_recherche&mode=normal&method=postcode">Par Post Code</a>'; }
|
|
|
|
if($countMethods>=count($methods)){ $separator=''; break; }else{ $separator=' - '; }
|
|
|
|
$lien = $lien.$separator;
|
|
}
|
|
|
|
print '<span class="left">'.$lien.'</span>';
|
|
}else{
|
|
print '<div>Il n\'est pas possible de faire une recherche dans la base de ce pays.';
|
|
|
|
//Vérification des droits
|
|
if(preg_match('/international/i', $_SESSION['tabInfo']['droits'])){
|
|
print 'Pour commander une enquête sur ce pays rendez-vous sur cette <a href="/?page=international_enquete&pays='.$pays.'">page</a>.';
|
|
}else{
|
|
print 'Vous n\'avez pas les droits nécessaires pour commander un enquête sur ce pays.';
|
|
}
|
|
print '</div>';
|
|
}
|
|
|
|
//Intersud
|
|
/*
|
|
setDbConn('intersud');
|
|
$q = Doctrine_Query::Create()
|
|
->select('id, intersud_country')
|
|
->from('Country')
|
|
->where('code = ?', $paysCode);
|
|
$result = $q->fetchOne();
|
|
|
|
$idPays = $result->id;
|
|
|
|
$q = Doctrine_Query::Create()
|
|
->from('Price')
|
|
->where('country_id = ?', $idPays);
|
|
$price = $q->fetchOne();
|
|
|
|
$q = Doctrine_Query::Create()
|
|
->from('Delais')
|
|
->where('country_id = ?', $idPays);
|
|
$delais = $q->fetchOne();
|
|
|
|
if($result && $price && $delais){
|
|
$pays = $result->intersud_country;
|
|
?>
|
|
<br/>
|
|
<div>
|
|
<h3>Commander une enquête terrain</h3>
|
|
Tarifs :
|
|
<table>
|
|
<tr><td>Mode normal : </td><td><?php print $price->normal; ?></td><td>, Délais : </td><td><?php if($delais->normalDe==0){ print $delais->normalA.' jours'; }else{ print $delais->normalDe.' à '.$delais->normalA.' jours'; } ?></td></tr>
|
|
<tr><td>Mode rapide : </td><td><?php print $price->rapide; ?></td><td>, Délais : </td><td><?php if($delais->rapideDe==0){ print $delais->rapideA.' jours'; }else{ print $delais->rapideDe.' à '.$delais->rapideA.' jours'; } ?></td></tr>
|
|
</table>
|
|
Cliquer ici pour accéder au formulaire.
|
|
</div>
|
|
<?php
|
|
}
|
|
*/
|
|
?>
|