extranet/www/pages/international_identitec.php
2009-04-24 16:52:30 +00:00

160 lines
3.8 KiB
PHP

<?php
session_start();
if (!$_SESSION['connected']) die();
$tabInfo = $_SESSION['tabInfo'];
$identifier = $_REQUEST['identifier'];
$CompanyProductIdentifier = $_REQUEST['pidentifier'];
require_once 'i18n/cleanchar.php';
require_once 'graydon/graydonws.php';
require_once 'graydon/log.php';
function dVal($value){
if($value == '' || $value == NULL){
print 'NC';
}else{
print $value;
}
}
?>
<div id="center">
<?php
$path = PATH_DATA.'/graydon';
$fileName = strtolower(str_replace( array(':',' '), '-', $identifier).'.xml');
if(!file_exists($path.'/'.$fileName)){
/*
placeOrder
CompanyProductIdentifier
Language
CreditOpinionCurrency
Country
getCompanyReport
OrderReference
MimeType
*/
//placeOrder
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->OrderCreatorEmail = 'mricois@scores-decisions.com';
$request->CompanyProductIdentifier = $CompanyProductIdentifier;
$request->PartnerData = '';
$firephp->log($request,'requete');
try
{
$placeOrderResult = $graydon->placeOrder($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $placeOrderResult->Service_Log->TransactionIdentifier;
$sessionID = $placeOrderResult->Service_Log->SessionID;
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'placeOrder', $transactionIdentifier, $sessionID);
$firephp->log($placeOrderResult,'placeOrder');
}catch( SoapFault $fault ){
require_once 'soaperror.php';
processSoapFault($graydon,$fault,$tabInfo);
}
//On vérifie l'état de le demande
if (isset($placeOrderResult) && $placeOrderResult->OrderStatus->OrderState == 'Completed'){
//getCompanyReport
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->LanguageCode = 'E'; //Spécifier la langue du rapport
$request->OrderReference = $placeOrderResult->OrderStatus->OrderReference;
$request->MimeType = 'xml';
$firephp->log($request,'requete');
try
{
$reportResult = $graydon->getCompanyReport($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $reportResult->Service_Log->TransactionIdentifier;
$sessionID = $reportResult->Service_Log->SessionID;
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyReport', $transactionIdentifier, $sessionID);
$firephp->log($reportResult,'reportResult');
$xml = $reportResult->ReportXML;
//Enregistrement du fichier xml
$xml = $reportResult->ReportXML->any;
file_put_contents($path.'/'.$fileName, $xml);
}catch( SoapFault $fault ){
require_once 'soaperror.php';
processSoapFault($graydon,$fault,$tabInfo);
die();
}
}
//On prend les données du fichier
}else{
$firephp->log('Data depuis fichier XML');
$xml = file_get_contents($path.'/'.$fileName);
}
//========= Affichage des informations =========
if(isset($xml) && $xml!=''){
$tabReport = array();
require_once 'graydon/functions.php';
require_once 'graydon/format.php';
//Création du DOM
$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$doc->loadxml($xml);
$xpath = new DOMXPath($doc);
$tabReport = parseReportXML($xml);
$firephp->log($tabReport, 'tabReport');
function utf8decode_deep($value)
{
$value = is_array($value) ?
array_map('utf8decode_deep', $value) :
cleanutf8($value);
return $value;
}
?>
<h1 class="titre">IDENTIT&Eacute; INTERNATIONALE DE L'ENTREPRISE</h1>
<?php dIdentifiant($tabReport); ?>
<h2>Raison sociale et coordonnées : </h2>
<?php dIdentite($tabReport);?>
<h2>Activité(s) et chiffre d'affaire de l'entreprise : </h2>
<?php dActivite($tabReport); ?>
<h2> Résumé financier : </h2>
<?php dResume($tabReport); ?>
<h2> Credit : </h2>
<?php dCredit($tabReport); ?>
<?php
}else{
?>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="500" class="StyleInfoLib">Aucune information disponible.</td>
</tr>
</table>
<?php
}
?>
</table>
</div>