from('Countryavailability') ->where('country = ?', $pays); $countryavailability = new Countryavailability(); $countryavailability = $q->fetchOne(); $nbResult = $q->count(); if($nbResult == 0){ // 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($_SESSION['tabInfo']['login'], $page, 'getCountryAvailability', $transactionIdentifier, $sessionID); $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){ require_once 'soaperror.php'; 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(); $nbResult = $q->count(); if($nbResult == 0){ // 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($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchMethods', $transactionIdentifier, $sessionID); $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/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 = 'Effectuer un 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 'Il n\'est pas possible de faire une recherche dans la base de ce pays. Pour commander une enquête sur ce pays rendez-vous sur cette page.'; } ?>