2009-04-06 17:05:03 +00:00
< ? php
2009-05-14 16:44:01 +00:00
session_start ();
$firephp -> log ( $_SESSION , 'SESSION' );
if ( ! isset ( $_REQUEST [ 'method' ])){
$paysCode = $_REQUEST [ 'pays' ];
} else {
$paysCode = $_SESSION [ 'graydon' ][ 'paysCode' ];
2009-04-07 17:44:17 +00:00
}
2009-05-04 13:45:12 +00:00
$tabInfo = $_SESSION [ 'tabInfo' ];
2009-05-11 09:52:19 +00:00
$mode = $_SESSION [ 'graydon' ][ 'mode' ];
2009-05-04 13:45:12 +00:00
2009-05-14 16:44:01 +00:00
require_once 'dbbootstrap.php' ;
2009-04-06 17:05:03 +00:00
require_once 'graydon/graydonws.php' ;
2009-05-07 16:06:00 +00:00
require_once 'graydon/graydon_log.php' ;
2009-05-13 16:05:50 +00:00
setDbConn ( 'graydon' );
$q = Doctrine_Query :: Create ()
-> select ( 'graydon_country' )
-> from ( 'Country' )
-> where ( 'code = ?' , $paysCode );
2009-05-14 16:44:01 +00:00
$firephp -> log ( $q -> getSql (), 'SQL' );
2009-05-13 16:05:50 +00:00
$result = $q -> fetchOne ();
$pays = $result -> graydon_country ;
2009-05-14 16:44:01 +00:00
$firephp -> log ( $pays , 'pays' );
$_SESSION [ 'graydon' ][ 'paysCode' ] = $paysCode ;
$_SESSION [ 'graydon' ][ 'pays' ] = $pays ;
2009-04-16 16:34:13 +00:00
2009-05-04 16:59:52 +00:00
//Disponibilit<69> des pays
$q = Doctrine_Query :: create ()
-> from ( 'Countryavailability' )
-> where ( 'country = ?' , $pays );
2009-05-14 16:44:01 +00:00
$firephp -> log ( $q -> getSql (), 'SQL' );
2009-05-04 16:59:52 +00:00
$countryavailability = new Countryavailability ();
$countryavailability = $q -> fetchOne ();
2009-05-14 16:44:01 +00:00
if ( $countryavailability == FALSE ){
2009-05-04 16:59:52 +00:00
// 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 ;
2009-05-14 16:44:01 +00:00
graydonRequeteLog ( $tabInfo [ 'login' ], $page , 'getCountryAvailability' , $transactionIdentifier , $sessionID );
2009-05-04 13:45:12 +00:00
2009-05-11 09:52:19 +00:00
//Log de la requete dans la bdd
$log = new Requetelog ();
2009-05-14 16:44:01 +00:00
$log -> login = $tabInfo [ 'login' ];
2009-05-11 09:52:19 +00:00
$log -> action = 'getCountryAvailability' ;
$log -> request = serialize ( $request );
$log -> transactionIdentifier = $transactionIdentifier ;
$log -> sessionID = $sessionID ;
$log -> mode = $mode ;
$log -> save ();
2009-05-04 13:45:12 +00:00
$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 ){
2009-05-07 16:06:00 +00:00
$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 ();
2009-05-14 16:44:01 +00:00
if ( $matchmethods == FALSE ){
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 ;
2009-04-16 16:34:13 +00:00
try
{
$result = $graydon -> getCompanyMatchMethods ( $request );
2009-04-24 14:14:48 +00:00
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result -> Service_Log -> TransactionIdentifier ;
$sessionID = $result -> Service_Log -> SessionID ;
2009-05-14 16:44:01 +00:00
graydonRequeteLog ( $tabInfo [ 'login' ], $page , 'getCompanyMatchMethods' , $transactionIdentifier , $sessionID );
2009-04-24 14:14:48 +00:00
2009-05-11 09:52:19 +00:00
//Log de la requete dans la bdd
$log = new Requetelog ();
2009-05-14 16:44:01 +00:00
$log -> login = $tabInfo [ 'login' ];
2009-05-11 09:52:19 +00:00
$log -> action = 'getCompanyMatchMethods' ;
$log -> request = serialize ( $request );
$log -> transactionIdentifier = $transactionIdentifier ;
$log -> sessionID = $sessionID ;
$log -> mode = $mode ;
$log -> save ();
2009-04-16 16:34:13 +00:00
$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 ();
2009-04-16 16:34:13 +00:00
} catch ( SoapFault $fault ){
2009-05-04 13:45:12 +00:00
$code = $fault -> detail -> GraydonCompanyData_Fault -> FaultReturnCode ;
$text = $fault -> detail -> GraydonCompanyData_Fault -> FaultMessage ;
2009-05-05 08:53:45 +00:00
$firephp -> log ( $text , 'texterror' );
2009-05-07 16:06:00 +00:00
require_once 'graydon/graydon_error.php' ;
2009-05-04 13:45:12 +00:00
if ( graydon_error ( $code , $text ) != FALSE ){
2009-05-05 08:53:45 +00:00
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 );
}
2009-04-16 16:34:13 +00:00
}
} else {
2009-05-04 16:59:52 +00:00
$methods = unserialize ( $matchmethods -> methods );
2009-04-16 16:34:13 +00:00
}
2009-05-05 08:53:45 +00:00
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
2009-05-15 16:29:29 +00:00
$lien = 'La meilleure m<> thode de recherche vous est affich<63> par d<> fault.<br/> Effectuer un autre type recherche : ' ;
2009-04-06 17:05:03 +00:00
$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 ;
2009-04-16 16:34:13 +00:00
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
2009-05-14 16:44:01 +00:00
if ( $item -> MatchingMethod == 'Keyword' ){ $lien .= '<a href="?page=international_recherche&mode=normal&method=keyword">Par mots cl<63> 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>' ; }
2009-04-20 12:54:22 +00:00
2009-04-27 08:29:26 +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
}
2009-04-16 16:34:13 +00:00
print '<span class="left">' . $lien . '</span>' ;
2009-05-04 13:45:12 +00:00
} else {
2009-05-13 16:05:50 +00:00
print '<div>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>.</div>' ;
}
//Intersud
2009-05-15 16:29:29 +00:00
/*
2009-05-13 16:05:50 +00:00
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<EFBFBD> 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.' <20> '.$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.' <20> '.$delais->rapideA.' jours'; } ?></td></tr>
</ table >
Cliquer ici pour acc<EFBFBD> der au formulaire .
</ div >
< ? php
2009-04-16 16:34:13 +00:00
}
2009-05-15 16:29:29 +00:00
*/
2009-04-06 17:05:03 +00:00
?>