MAJ Graydon : Amélioration parsing XML + cache

This commit is contained in:
Michael RICOIS 2009-04-20 12:41:56 +00:00
parent 384334e497
commit 0669ad8ee8
6 changed files with 229 additions and 140 deletions

View File

@ -210,8 +210,15 @@ function parseAmount($nodeList, $currency = ''){
return $amount;
}
function parseFreeText($query){
global $xpath;
$tab = array();
$items = $xpath->query($query);
foreach ($items as $item){
$tab[] = $item->nodeValue;
}
return $tab;
}
function formatName($node){

View File

@ -5,7 +5,7 @@ $tabInfo = $_SESSION['tabInfo'];
//$list_international = unserialize(gzuncompress($_SESSION['list_international']));
$identifier = $_REQUEST['identifier'];
$pays = $_SESSION['pays'];
$pays = $_SESSION['graydon']['pays'];
/*
getCompanyProduct
@ -22,6 +22,7 @@ require_once 'graydon/graydonws.php';
$path = PATH_DATA.'/graydon/method';
$fileName = strtolower('CompanyMatchIdentifiers-'.$pays);
/** Recup des types d'identifiants pour le pays **/
if(!file_exists($path.'/'.$fileName)){
//Récupération des intitulés identifiant
$request = new StdClass();
@ -46,19 +47,27 @@ if(!file_exists($path.'/'.$fileName)){
require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo);
}
exit;
}else{
$tabIdentifiers = unserialize(file_get_contents($path.'/'.$fileName));
}
// Create the request parameters
$request = new StdClass();
// Initialise the request object
$request->Authentication_Parameters = $authentication;
$request->CompanyMatchIdentifier = $identifier;
$firephp->log($request,'requete');
try
{
/** Recup des produits de la company **/
$path = PATH_DATA.'/graydon';
$fileName = strtolower('CompanyProducts-'.$identifier);
$fileName = str_replace(':', '-', $fileName);
$now = mktime(date('G'), date('i'), date('s'), date("m") , date("d"), date("Y"));
if(!file_exists($path.'/'.$fileName) || filemtime($path.'/'.$fileName)>$now+16 ){
// Create the request parameters
$request = new StdClass();
// Initialise the request object
$request->Authentication_Parameters = $authentication;
$request->CompanyMatchIdentifier = $identifier;
$firephp->log($request,'requete');
try
{
// Make a request on the web service
$result = $graydon->getCompanyProducts($request);
// Print out the result
@ -72,30 +81,62 @@ try
$firephp->log($result,'result');
file_put_contents($path.'/'.$fileName, serialize($result));
}catch( SoapFault $fault ){
require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo);
die();
}
}else{
$result = unserialize(file_get_contents($path.'/'.$fileName));
}
if(isset($result)){
$company = $result->Company;
$products = $result->Products->Product;
?>
<table width="580" border="0" align="left" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><img src="./img/rub_identite.png" width="577" height="36"></td>
</tr>
<tr>
<div id="center">
<h1 class="titre">IDENTIT&Eacute; INTERNATIONALE DE L'ENTREPRISE</h1>
<table >
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Fiche identité simplifié<br/></td>
<td>
<?php
<?php
$count = count($products);
if($count==1){
$products[] = $products;
}
foreach($products as $product){
if($product->ServiceSpeed == 'Immediate' && $product->Type == 'Database'){
?>
<a href="./?page=international_identitec&identifier=<?php print $identifier;?>&pidentifier=<?php print $product->CompanyProductIdentifier;?>">Accéder à la fiche identité approfondie (payant).</a>
<?php
if ($product->ServiceSpeed == 'Immediate' && $product->Type == 'Database' && $product->Level == 3 ){
$mimetype = FALSE;
if (is_array($product->MimeTypes->MimeType)){
if (in_array('xml', $product->MimeTypes->MimeType)){$mimetype = TRUE;}
}else{
if ($product->MimeTypes->MimeType == 'xml' ){$mimetype = TRUE;}
}
if ($mimetype == TRUE ){
$pidentifier = $product->CompanyProductIdentifier;
$position = strpos($pidentifier,':');
$TransactionIdentifier = $_SESSION['graydon']['TransactionIdentifier'];
$SessionID = $_SESSION['graydon']['SessionID'];
$pidentifier = substr($pidentifier,0,$position).':'.$SessionID.':'.$TransactionIdentifier;
?>
<a href="./?page=international_identitec&identifier=<?php print $identifier;?>&pidentifier=<?php print $pidentifier;?>">Accéder à la fiche identité approfondie (payant).</a>
<?php
}else{
?>
(Rapport immédiat indisponible)
<?php
}
}
?>
}
?>
</td>
</td>
</tr>
@ -140,9 +181,12 @@ try
}
}
?>
<tr>
<td colspan="3"><img src="./img/srub_id.png" width="576" height="27"></td>
</tr>
</table>
<h2>Raison sociale et coordonnées : </h2>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Raison Sociale</td>
@ -194,9 +238,11 @@ try
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td colspan="3"><img src="./img/srub_activite.png" width="576" height="27"></td>
</tr>
</table>
<h2>Activité(s) de l'entreprise : </h2>
<table>
<?php
$count = count($company->Activites->Activity);
if ($count>1){
@ -228,8 +274,15 @@ try
</tr>
</table>
<?php
}catch( SoapFault $fault ){
require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo);
}else{
?>
<table>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2" class="StyleInfoData">Aucune information disponible</td>
</tr>
</table>
<?php
}
?>
</div>

View File

@ -9,8 +9,19 @@ $CompanyProductIdentifier = $_REQUEST['pidentifier'];
require_once 'graydon/functions.php';
require_once 'graydon/graydonws.php';
function dVal($value){
if($value == '' || $value == NULL){
print 'NC';
}else{
print $value;
}
}
?>
<div id="center">
<?php
$path = PATH_DATA.'/graydon';
$fileName = str_replace(':', '-', $identifier).'.xml';
$fileName = strtolower(str_replace( array(':',' '), '-', $identifier).'.xml');
if(!file_exists($path.'/'.$fileName)){
/*
@ -26,6 +37,7 @@ if(!file_exists($path.'/'.$fileName)){
*/
//placeOrder
$request = new StdClass();
$firephp->log($authetication,'authentication');
$request->Authentication_Parameters = $authentication;
$request->OrderCreatorEmail = 'mricois@scores-decisions.com';
$request->CompanyProductIdentifier = $CompanyProductIdentifier;
@ -43,7 +55,6 @@ if(!file_exists($path.'/'.$fileName)){
//On vérifie l'état de le demande
if (isset($placeOrderResult) && $placeOrderResult->OrderStatus->OrderState == 'Completed'){
//getCompanyReport
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
@ -77,13 +88,10 @@ if(!file_exists($path.'/'.$fileName)){
//========= Affichage des informations =========
if(isset($xml) && $xml!=''){
?>
<h1 class="titre">IDENTIT&Eacute; INTERNATIONALE DE L'ENTREPRISE</h1>
<table width="580" border="0" align="left" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><img src="./img/rub_identite.png" width="577" height="36"></td>
</tr>
<table>
<?php
$tabCompany = array();
//Création du DOM
$doc = new DOMDocument;
@ -96,13 +104,12 @@ $tabCompany['Identite']['Address'] = parseCompanyAddress();
$tabCompany['Identite']['Communication'] = parseCommunication();
$tabCompany['Identite']['Dirigeants'] = parseDirectorDetails();
$tabCompany['Identite']['Activite'] = parseTaxonomy('Nace');
$tabCompany['Identite']['Activite']['Text'] = parseFreeText('//GraydonUKCompanySchema/CompanyReportPage/CompanyReport/FreeText[@Type="Activities"]');
$tabCompany['Identite']['Effectif'] = parseEmployees('Staff_Employed');
$tabCompany['Identite']['Capital'] = parseShare_Capital();
$tabCompany['Identite']['ResumeFinance'] = parseFinancial_Summary();
$firephp->log($tabCompany,'tabCompany');
?>
<?php foreach($tabCompany['Identite']['Subject']['CompanyId'] as $identifiant => $value){ ?>
<tr>
<td width="30">&nbsp;</td>
@ -110,30 +117,26 @@ $firephp->log($tabCompany,'tabCompany');
<td width="350" class="StyleInfoData"><?php print $value;?></td>
</tr>
<?php }?>
</table>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2"></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2">Raison sociale et coordonnées : </td>
</tr>
<h2>Raison sociale et coordonnées : </h2>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Raison Sociale : </td>
<td width="350" class="StyleInfoData"><?php print $tabCompany['Identite']['Subject']['Name'];?></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Forme légale : </td>
<td width="350" class="StyleInfoData">
<?php
if(count($tabCompany['Identite']['FormeLegale'])==0){print 'NC';}
else{
foreach($tabCompany['Identite']['FormeLegale'] as $item => $value){
print $value.' - ('.$item.')';
print $value.' - ('.$item.')<br/>';
}
}
?>
</td>
@ -144,57 +147,58 @@ $firephp->log($tabCompany,'tabCompany');
<td width="200" class="StyleInfoLib">Date de création : </td>
<td width="350" class="StyleInfoData">
<?php
print $tabCompany['Identite']['Subject']['Date']['Age_of_Company'];
dVal($tabCompany['Identite']['Subject']['Date']['Age_of_Company']);
?>
</td>
</tr>
<?php
foreach($tabCompany['Identite']['Address'] as $type => $elements){
if(count($tabCompany['Identite']['Address'])==0){print 'Aucune adresse définie';}
else{
foreach($tabCompany['Identite']['Address'] as $type => $elements){
?>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib"><?php print $type;?></td>
<td width="350" class="StyleInfoData"></td>
<td width="350" class="StyleInfoData"><?php print $elements['EntireAddress'];?></td>
</tr>
<?php
foreach($elements as $item => $value){
if($value!=''){
?>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib"><?php print $item;?></td>
<td width="350" class="StyleInfoData"><?php print $value;?></td>
</tr>
<?php
}
}
}
?>
</table>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2"></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2">Activité et chiffre d'affaire de l'entreprise : </td>
</tr>
<h2>Activité(s) et chiffre d'affaire de l'entreprise : </h2>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Activité : </td>
<td width="350" class="StyleInfoData">
<?php
foreach($tabCompany['Identite']['Activite'] as $item => $value){
if($item != 'Text'){
print $item.' : '.$value['Code'].' - '.$value['Value'];
}
}
if(count($tabCompany['Identite']['Activite']['Text'])!=0){
?>
<br/><br>
<u>Informations complémentaires :</u><br/>
<?php
foreach($tabCompany['Identite']['Activite']['Text'] as $value){
print $value.'<br/>';
}
}
?>
</td>
</tr>
<?php
foreach($tabCompany['Identite']['Dirigeants'] as $element){
?>
@ -214,14 +218,30 @@ foreach($tabCompany['Identite']['Dirigeants'] as $element){
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Effectif :</td>
<td width="350" class="StyleInfoData">
<?php print $tabCompany['Identite']['Effectif']?>
<?php dVal($tabCompany['Identite']['Effectif']);?>
</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Capital :</td>
<td width="350" class="StyleInfoData">
<?php dVal($tabCompany['Identite']['Capital']['Issued_Capital']);?>
</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Chiffre d'affaire:</td>
<td width="350" class="StyleInfoData">
<?php dVal($tabCompany['Identite']['ResumeFinance']['Working Capital']);?>
</td>
</tr>
<?php
}else{
?>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="500" class="StyleInfoLib">Aucune information disponible.</td>
@ -231,7 +251,7 @@ foreach($tabCompany['Identite']['Dirigeants'] as $element){
}
?>
</table>
</div>

View File

@ -10,14 +10,15 @@ 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"});
}
$('#mode').change(function(){
var mode = $('#mode :selected').val();
document.location.href='http://extranet.devlocal.com/?page=international_recherche&mode='+mode;
});
$('#pays').change(function(){
var pays = $('#pays :selected').val();
$('#method').html('<p><img src="./img/ajax/19-1.gif" /></p>');
$('#method').load('./pages/graydon/methodfield.php', {'pays': pays});
});
});
</script>
@ -26,11 +27,19 @@ $(document).ready(function(){
<h2 class="StyleRechercheTitre">RECHERCHE INTERNATIONALE</h2>
<form name="recherche" class="frm" method="post" action="index.php?page=international_recherche">
<form name="recherche" 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 class="fieldgrp">
<label>Mode : </label>
<div class="field">
<select id="mode" name="mode">
<option value="demo" <?php $_REQUEST['mode']=='demo' ? print ' selected' : '' ;?>>Démonstration</option>
<option value="normal" <?php $_REQUEST['mode']=='normal' ? print ' selected' : '' ;?>>Normal</option>
</select>
</div>
</div>
<div id="recherche">
<div id="subsearch">
<?php
//Si les paramètres mode, method sont dans l'url alors on force la méthode de recherche
if(isset($_REQUEST['method']))
@ -42,6 +51,7 @@ require_once 'international_rechercheform.php';
?>
</div>
</form>
</div>
<?php
}elseif($vue=='list'){
@ -49,7 +59,7 @@ require_once 'international_rechercheform.php';
if($_REQUEST['mode']=='demo'){
?>
<div id="internationallist">
<span>Résultat de la recherche de démonstration :</span>
<span class="StyleInfoLib">Résultat de la recherche de démonstration :</span>
<?php
require_once 'graydon/graydonws.php';
// Create the request parameters
@ -72,11 +82,13 @@ require_once 'international_rechercheform.php';
// Get the list of companies
$demoCompaniesCountry = $result->DemoCompanies->CountryAndCompany;
$_SESSION['pays'] = $result->Service_Log->Country;
$_SESSION['graydon']['pays'] = $result->Service_Log->Country;
$_SESSION['graydon']['SessionID'] = $result->Service_Log->SessionID;
$_SESSION['graydon']['TransactionIdentifier'] = $result->Service_Log->TransactionIdentifier;
?>
<br/>
<span>Pays : <?php print $demoCompaniesCountry->Country; ?></span>
<span class="StyleInfoLib">Pays :</span> <span><?php print $demoCompaniesCountry->Country; ?></span>
<ol>
<?php
$demoCompanies = array();
@ -114,7 +126,7 @@ require_once 'international_rechercheform.php';
}elseif($_REQUEST['mode']=='normal'){
?>
<div id="internationallist">
<span>Résultat de la recherche :</span>
<span class="StyleInfoLib">Résultat de la recherche :</span>
<?php
require_once 'graydon/graydonws.php';
// Create the request parameters
@ -169,9 +181,12 @@ require_once 'international_rechercheform.php';
print "-->";
$_SESSION['pays'] = $result->Service_Log->Country;
$_SESSION['graydon']['SessionID'] = $result->Service_Log->SessionID;
$_SESSION['graydon']['TransactionIdentifier'] = $result->Service_Log->TransactionIdentifier;
?>
<br/>
<span>Pays : <?php print $result->Service_Log->Country; ?></span>
<span class="StyleInfoLib">Pays :</span> <span><?php print $result->Service_Log->Country; ?></span>
<ol>
<?php
$count = count($result->CompanyMatches->Company);

View File

@ -5,22 +5,14 @@ if(!isset($mode)){
if($mode=='normal'){
?>
<script type="text/javascript">
$(document).ready(function(){
$('#pays').change(function(){
$('#method').html('<p><img src="./img/ajax/19-1.gif" /></p>');
var pays = $('#pays :selected').val();
$('#method').load('./pages/graydon/methodfield.php', {'pays':pays});
});
});
</script>
<input type="hidden" name="mode" value="normal">
<label class="StyleInfoLib">Pays :</label>
<select id="pays" name="frmRecherche[Country]">
<option value="">Sélectionner un pays</option>
<div class="fieldgrp">
<label class="StyleInfoLib">Pays : </label>
<div class="field">
<select id="pays" name="frmRecherche[Country]" size="10">
<?php require_once 'graydon/pays.php';?>
</select>
</div>
</div>
<div id="method">
<?php
if(isset($method)){
@ -28,17 +20,17 @@ if(isset($method)){
}
?>
</div>
<label>&nbsp;</label><input type="submit" value="Rechercher" />
<div class="submit"><p class="submit-button"><input type="submit" value="Rechercher" /></p></div>
</form>
<?php
}elseif($mode=='demo'){
?>
<input type="hidden" name="mode" value="demo">
<label>Pays :</label>
<select name="frmDemo[Country]">
<div class="fieldgrp">
<label>Pays : </label>
<div class="field">
<select name="frmDemo[Country]" size="10">
<option value="Austria">Austria</option>
<option value="Belgium">Belgium</option>
<option value="Bulgaria">Bulgaria</option>
@ -69,7 +61,9 @@ if(isset($method)){
<option value="United Kingdom">United Kingdom</option>
<option value="USA">USA</option>
</select>
<label>&nbsp;</label><input type="submit" value="Rechercher" />
</div>
</div>
<div class="submit"><p class="submit-button"><input type="submit" class="submit" value="Rechercher" /></p></div>
</form>
<?php
}

View File

@ -18,7 +18,7 @@ require_once(realpath(dirname(__FILE__).'/../../includes/siren.php'));
<link rel="stylesheet" type="text/css" href="./css/menu.css" />
<link rel="stylesheet" type="text/css" href="./css/jquery.autocomplete.css" />
<?php
if($page=='international_recherche'){
if($page=='international_recherche' || $page=='international_identite' || $page=='international_identitec'){
?>
<link rel="stylesheet" type="text/css" href="./css/international.css" />
<?php
@ -39,8 +39,8 @@ if($page2=='saisie.php'){
?>
<script type="text/javascript" src="./js/saisieajax.js"></script>
<link rel="stylesheet" type="text/css" href="./css/jquery.autocomplete2.css" />
<link rel="stylesheet" href="./css/saisie.css" type="text/css" media="screen" />
<link rel="stylesheet" href="./css/thickbox.css" type="text/css" media="screen" />
<link rel="stylesheet" href="./css/saisie.css" type="text/css" />
<link rel="stylesheet" href="./css/thickbox.css" type="text/css" />
<?php
}
}
@ -83,7 +83,7 @@ if ($sortie<>'pdf' && $sortie<>'prt') {
<td valign="top">
<?include($page2)?>
</td>
</tr><
</tr>
</table>
</td>
<?php } ?>