extranet/www/pages/graydon/methodfield.php

165 lines
6.2 KiB
PHP
Raw Normal View History

2009-04-06 17:05:03 +00:00
<?php
2009-04-07 17:44:17 +00:00
if(!isset($method)){
$pays = $_REQUEST['pays'];
}
2009-04-06 17:05:03 +00:00
2009-05-04 13:45:12 +00:00
$tabInfo = $_SESSION['tabInfo'];
2009-04-06 17:05:03 +00:00
require_once 'graydon/graydonws.php';
require_once 'graydon/graydon_log.php';
2009-05-04 16:59:52 +00:00
require_once 'dbbootstrap.php';
Doctrine::loadModels(realpath(dirname(__FILE__)).'/../../dashboard/models');
2009-05-04 16:59:52 +00:00
//Disponibilit<69> des pays
$q = Doctrine_Query::create()
->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;
2009-05-04 13:45:12 +00:00
try
2009-05-04 16:59:52 +00:00
{
2009-05-04 13:45:12 +00:00
$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){
2009-05-06 17:03:57 +00:00
$availability[] = $result->CountryAvailablity->CountryAndProduct->Products->Product;
2009-05-04 13:45:12 +00:00
}
2009-05-04 16:59:52 +00:00
//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));
2009-05-04 13:45:12 +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){
graydon_processSoapFault($graydon,$fault,$tabInfo);
}
2009-05-04 13:45:12 +00:00
}
}else{
2009-05-04 16:59:52 +00:00
$availability = unserialize($countryavailability->availability);
2009-05-04 13:45:12 +00:00
}
2009-05-04 16:59:52 +00:00
//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){
2009-05-04 13:45:12 +00:00
// 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;
}
2009-05-04 16:59:52 +00:00
//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 ){
2009-05-04 13:45:12 +00:00
$code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode;
$text = $fault->detail->GraydonCompanyData_Fault->FaultMessage;
$firephp->log($text,'texterror');
require_once 'graydon/graydon_error.php';
2009-05-04 13:45:12 +00:00
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();
}
2009-05-04 13:45:12 +00:00
}else{
graydon_processSoapFault($graydon,$fault,$tabInfo);
}
}
}else{
2009-05-04 16:59:52 +00:00
$methods = unserialize($matchmethods->methods);
}
if (isset($methods) && $methods!='false'){
2009-04-06 17:05:03 +00:00
$firephp->log($methods,'methods');
//Affichage de la meilleur m<>thode de recherche OU la premi<6D>re
$lien = 'Effectuer un recherche : ';
$flagBestMethod = false;
2009-04-20 12:54:22 +00:00
$countMethods = 0;
2009-04-09 17:10:02 +00:00
foreach($methods as $item){
$WithCity = $item->WithCity;
$WithPostCode = $item->WithPostCode;
if( ($item->BestMethod==TRUE && $item->MatchingMethod=='Keyword') && !isset($method) || $method=='keyword' ){
2009-04-06 17:05:03 +00:00
$flagBestMethod = TRUE;
require_once realpath(dirname(__FILE__)).'/method_keyword.php';
2009-04-09 17:10:02 +00:00
}elseif( ($item->BestMethod==TRUE && $item->MatchingMethod=='Identifier') && !isset($method) || $method=='identifier' ){
2009-04-06 17:05:03 +00:00
$flagBestMethod = TRUE;
require_once realpath(dirname(__FILE__)).'/method_identifier.php';
2009-04-09 17:10:02 +00:00
}elseif( ($item->BestMethod==TRUE && $item->MatchingMethod=='Name') && !isset($method) || $method=='name' ){
2009-04-06 17:05:03 +00:00
$flagBestMethod = TRUE;
require_once realpath(dirname(__FILE__)).'/method_name.php';
2009-04-09 17:10:02 +00:00
}elseif( ($item->BestMethod==TRUE && $item->MatchingMethod=='PostCode') && !isset($method) || $method=='postcode' ){
2009-04-06 17:05:03 +00:00
$flagBestMethod = TRUE;
2009-04-09 17:10:02 +00:00
require_once realpath(dirname(__FILE__)).'/method_postcode.php';
2009-04-06 17:05:03 +00:00
}
2009-04-20 12:54:22 +00:00
$countMethods++;
2009-04-06 17:05:03 +00:00
//Affichage des propostions des m<>thodes de recherche
if($item->MatchingMethod=='Keyword'){ $lien .= '<a href="?page=international_recherche&mode=normal&method=keyword&pays='.$pays.'">Par mots cl<63>s</a>'; }
if($item->MatchingMethod=='Identifier'){ $lien .= '<a href="?page=international_recherche&mode=normal&method=identifier&pays='.$pays.'">Par identifiant</a>'; }
if($item->MatchingMethod=='Name'){ $lien .= '<a href="?page=international_recherche&mode=normal&method=name&pays='.$pays.'">Par nom</a>'; }
if($item->MatchingMethod=='PostCode'){ $lien .= '<a href="?page=international_recherche&mode=normal&method=postcode&pays='.$pays.'">Par Post Code</a>'; }
2009-04-20 12:54:22 +00:00
if($countMethods>=count($methods)){ $separator=''; break; }else{ $separator=' - '; }
2009-04-20 12:54:22 +00:00
$lien = $lien.$separator;
2009-04-06 17:05:03 +00:00
}
print '<span class="left">'.$lien.'</span>';
2009-05-04 13:45:12 +00:00
}else{
print 'Il n\'est pas possible de faire une recherche dans la base de ce pays. Pour commander une enqu<71>te sur ce pays rendez-vous sur cette <a href="/?page=international_enquete&pays='.$pays.'">page</a>.';
}
2009-04-06 17:05:03 +00:00
?>