237 lines
7.5 KiB
PHP
237 lines
7.5 KiB
PHP
<?php
|
|
if (!$_SESSION['connected']) die();
|
|
$vue = isset($_REQUEST['vue']) ? $_REQUEST['vue'] : 'recherche';
|
|
/* Affichage du formulaire de recherche */
|
|
|
|
if($vue=='recherche'){
|
|
?>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
$('#demo').change(function(){
|
|
$('#recherche').empty().html('<p><img src="./img/ajax/19-1.gif" /></p>');
|
|
var check = $(this).attr("checked");
|
|
if(check == true){ //Chargement du mode démonstration
|
|
$("#recherche").empty().load("./pages/international_rechercheform.php", {'mode': "demo"});
|
|
}else{ //Chargement du mode normal
|
|
$("#recherche").empty().load("./pages/international_rechercheform.php", {'mode': "normal"});
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<div id="international">
|
|
|
|
<h2 class="StyleRechercheTitre">RECHERCHE INTERNATIONALE</h2>
|
|
|
|
<form name="recherche" class="frm" method="post" action="index.php?page=international_recherche">
|
|
<input type="hidden" name="vue" value="list">
|
|
<label>Mode Démonstration : </label><input type="checkbox" id="demo" name="demo" <?php $_REQUEST['mode']=='normal' ? '' : print ' checked="check"' ;?>>
|
|
|
|
<div id="recherche">
|
|
<?php
|
|
//Si les paramètres mode, method sont dans l'url alors on force la méthode de recherche
|
|
if(isset($_REQUEST['method']))
|
|
{
|
|
$method = $_REQUEST['method'];
|
|
$pays = $_REQUEST['pays'];
|
|
}
|
|
require_once 'international_rechercheform.php';
|
|
?>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
}elseif($vue=='list'){
|
|
//*********** Mode démonstration
|
|
if($_REQUEST['mode']=='demo'){
|
|
?>
|
|
<div id="internationallist">
|
|
<span>Résultat de la recherche de démonstration :</span>
|
|
<?php
|
|
require_once 'graydon/graydonws.php';
|
|
// Create the request parameters
|
|
$request = new StdClass();
|
|
// Initialise the request object
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->Country = $_REQUEST['frmDemo']['Country'];
|
|
try
|
|
{
|
|
// Make a request on the web service
|
|
$result = $graydon->getDemoCompanies($request);
|
|
// Print out the result
|
|
print "<!--";
|
|
print "Transaction Identifier : ".$result->Service_Log->TransactionIdentifier;
|
|
print "\n";
|
|
print "Partner User Id : ".$result->Service_Log->PartnerUserId;
|
|
print "\n";
|
|
print_r($result);
|
|
print "-->";
|
|
// Get the list of companies
|
|
$demoCompaniesCountry = $result->DemoCompanies->CountryAndCompany;
|
|
|
|
$_SESSION['pays'] = $result->Service_Log->Country;
|
|
|
|
?>
|
|
<br/>
|
|
<span>Pays : <?php print $demoCompaniesCountry->Country; ?></span>
|
|
<ol>
|
|
<?php
|
|
$demoCompanies = array();
|
|
//Enregitrement de la liste en session
|
|
$count = count($demoCompaniesCountry->Companies->Company);
|
|
if ($count>1){
|
|
$demoCompanies = $demoCompaniesCountry->Companies->Company;
|
|
}elseif($count==1){
|
|
$demoCompanies[] = $demoCompaniesCountry->Companies->Company;
|
|
}
|
|
$firephp->log($demoCompanies,'demoCompanies');
|
|
|
|
$counterCompany = 1;
|
|
foreach($demoCompanies as $company){
|
|
?>
|
|
<li class="StyleInfoData" type="1" value="<?php print $counterCompany++; ?>">
|
|
<b><a title="Voir la fiche d'identité de cet établissement" href="index.php?page=international_identite&mode=demo&identifier=<?php print $company->CompanyMatchIdentifier;?>">
|
|
<?php print utf8_decode($company->Name); ?></a></b><br />
|
|
Adresse :
|
|
<?php
|
|
print utf8_decode($company->RegisteredAddress->EntireAddress);
|
|
?><br/><br/>
|
|
</li>
|
|
<?php
|
|
}
|
|
?>
|
|
</ol>
|
|
</div>
|
|
<?php
|
|
}catch( SoapFault $exception ){
|
|
// Print the exception
|
|
print "\n Exception ";
|
|
var_dump($exception->detail);
|
|
}
|
|
//*********** Mode normal
|
|
}elseif($_REQUEST['mode']=='normal'){
|
|
?>
|
|
<div id="internationallist">
|
|
<span>Résultat de la recherche :</span>
|
|
<?php
|
|
require_once 'graydon/graydonws.php';
|
|
// Create the request parameters
|
|
$request = new StdClass();
|
|
// Initialise the request object
|
|
$request->Authentication_Parameters = $authentication;
|
|
|
|
// Create a new country parameters object
|
|
$company = new StdClass();
|
|
// Initialise the country object
|
|
$company->Country = $_REQUEST['frmRecherche']['Country'];
|
|
$company->ClientReference = '';
|
|
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->CompanyMatches_Parameters = $company;
|
|
|
|
if($_REQUEST['method'] == 'keyword'){
|
|
$request->Keyword = $_REQUEST['frmRecherche']['Keywords'];
|
|
$request->City = isset($_REQUEST['frmRecherche']['City']) ? $_REQUEST['frmRecherche']['City'] : '' ;
|
|
$request->PostCode = isset($_REQUEST['frmRecherche']['PostCode']) ? $_REQUEST['frmRecherche']['PostCode'] : '' ;
|
|
}elseif($_REQUEST['method'] == 'identifier'){
|
|
$request->Identifier = $_REQUEST['frmRecherche']['Identifier'];
|
|
}elseif($_REQUEST['method'] == 'name'){
|
|
$request->Name = $_REQUEST['frmRecherche']['Name'];
|
|
$request->City = isset($_REQUEST['frmRecherche']['City']) ? $_REQUEST['frmRecherche']['City'] : '' ;
|
|
$request->PostCode = isset($_REQUEST['frmRecherche']['PostCode']) ? $_REQUEST['frmRecherche']['PostCode'] : '' ;
|
|
}elseif($_REQUEST['method'] == 'postcode'){
|
|
$request->PostCode = isset($_REQUEST['frmRecherche']['PostCode']) ? $_REQUEST['frmRecherche']['PostCode'] : '' ;
|
|
}
|
|
|
|
$firephp->log($request,'requete');
|
|
try
|
|
{
|
|
// Make a request on the webservice
|
|
if($_REQUEST['method'] == 'keyword'){
|
|
$result = $graydon->getCompanyMatchesByKeyword($request);
|
|
}elseif($_REQUEST['method'] == 'identifier'){
|
|
$result = $graydon->getCompanyMatchesByIdentifier($request);
|
|
}elseif($_REQUEST['method'] == 'name'){
|
|
$result = $graydon->getCompanyMatchesByName($request);
|
|
}elseif($_REQUEST['method'] == 'postcode'){
|
|
$result = $graydon->getCompanyMatchesByPostCode($request);
|
|
}
|
|
|
|
// Print out the result
|
|
print "<!--";
|
|
print "Transaction Identifier : ".$result->Service_Log->TransactionIdentifier;
|
|
print "\n";
|
|
print "Partner User Id : ".$result->Service_Log->PartnerUserId;
|
|
print "\n";
|
|
print_r($result);
|
|
print "-->";
|
|
|
|
$_SESSION['pays'] = $result->Service_Log->Country;
|
|
?>
|
|
<br/>
|
|
<span>Pays : <?php print $result->Service_Log->Country; ?></span>
|
|
<ol>
|
|
<?php
|
|
$count = count($result->CompanyMatches->Company);
|
|
if ($count>1){
|
|
$companies = $result->CompanyMatches->Company;
|
|
}elseif($count==1){
|
|
$companies[] = $result->CompanyMatches->Company;
|
|
}
|
|
$firephp->log($companies,'companies');
|
|
|
|
$counterCompany = 1;
|
|
foreach($companies as $company){
|
|
?>
|
|
<li class="StyleInfoData" type="1" value="<?php print $counterCompany++; ?>">
|
|
<b><a title="Voir la fiche d'identité de cet établissement" href="index.php?page=international_identite&identifier=<?php print $company->CompanyMatchIdentifier;?>">
|
|
<?php print utf8_decode($company->Name); ?></a></b><br />
|
|
Addresse :
|
|
<?php
|
|
print utf8_decode($company->RegisteredAddress->EntireAddress);
|
|
?><br />
|
|
<?php
|
|
if($company->LegalForm != NULL){
|
|
?>
|
|
Forme légale :
|
|
<?php
|
|
print utf8_decode($company->LegalForm->LocalCode." - ".$company->LegalForm->Description);
|
|
?><br />
|
|
<?php
|
|
}
|
|
if($company->Acivites != NULL){
|
|
?>
|
|
Activité :
|
|
<?php
|
|
$count = count($company->Activites);
|
|
if ($count>1){
|
|
$activites = $company->Activites;
|
|
}elseif($count==1){
|
|
$activites[] = $company->Activites;
|
|
}
|
|
if(isset($company->Activites) && count($company->Activites>0) ){
|
|
$activite = $company->Activites[0]->activity;
|
|
print $activite->Type." - ".$activite->Code." - ".$activite->Description;
|
|
}
|
|
?><br />
|
|
<?php
|
|
}
|
|
?>
|
|
</li>
|
|
<?php
|
|
}
|
|
?>
|
|
</ol>
|
|
</div>
|
|
<?php
|
|
}catch( SoapFault $exception ){
|
|
// Print the exception
|
|
print "\n Exception ";
|
|
var_dump($exception->detail);
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
|