extranet/www/pages/international_identitec.php
2009-04-09 17:10:02 +00:00

197 lines
5.9 KiB
PHP

<?php
if (!$_SESSION['connected']) die();
$identifier = $_REQUEST['identifier'];
$CompanyProductIdentifier = $_REQUEST['pidentifier'];
require_once 'graydon/functions.php';
require_once 'graydon/graydonws.php';
$path = PATH_DATA.'/graydon';
$fileName = str_replace(':', '-', $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);
$firephp->log($placeOrderResult,'placeOrder');
}catch( SoapFault $exception ){
// Print the exception
print "\n Exception ";
var_dump($exception->detail);
}
//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);
$firephp->log($reportResult,'reportResult');
$xml = $reportResult->ReportXML;
//Enregistrement du fichier xml
$xml = $reportResult->ReportXML->any;
file_put_contents($path.'/'.$fileName, $xml);
}catch( SoapFault $exception ){
// Print the exception
print "\n Exception ";
var_dump($exception->detail);
}
}
//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!=''){
?>
<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>
<?php
$tabCompany = array();
//Création du DOM
$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$doc->loadxml($xml);
//XPATH Method
$xpath = new DOMXPath($doc);
//Raison sociale
$query = '//GraydonUKCompanySchema/CompanyReportPage/CompanyReport/Company[@Type="Subject"]/Name';
$items = $xpath->query($query);
$tabCompany['RaisonSociale'] = $items->item(0)->nodeValue;
//Date de création de l'entreprise
$query = '//GraydonUKCompanySchema/CompanyReportPage/CompanyReport/Company[@Type="Subject"]/Date[@Type="Age_of_Company"]';
$items = $xpath->query($query);
if ($items->length>0){
foreach ($items->item(0)->attributes as $attrName => $attrNode) {
if($attrName == 'Format'){
}
}
$tabCompany['DateCreation'] = $items->item(0)->nodeValue;
}
//Forme légale
$query = '//GraydonUKCompanySchema/CompanyReportPage/CompanyReport/Legal_Form';
$items = $xpath->query($query);
foreach ($items as $item) {
$tabCompany['FormeLegale'][] = $item->nodeValue;
}
//Adresse
$query = '//GraydonUKCompanySchema/CompanyReportPage/CompanyReport/Address[@Type="Registered"]';
$items = $xpath->query($query);
foreach ($items as $item) {
$tabCompany['AddressRegistered']['EntireAddress'] = $item->getElementsByTagName('EntireAddress')->item(0)->nodeValue;
$tabCompany['AddressRegistered']['Building'] = $item->getElementsByTagName('Building')->item(0)->nodeValue;
$tabCompany['AddressRegistered']['Street'] = $item->getElementsByTagName('Street')->item(0)->nodeValue;
$tabCompany['AddressRegistered']['Street'] = $item->getElementsByTagName('Town')->item(0)->nodeValue;
$tabCompany['AddressRegistered']['City'] = $item->getElementsByTagName('City')->item(0)->nodeValue;
$tabCompany['AddressRegistered']['County'] = $item->getElementsByTagName('County')->item(0)->nodeValue;
$tabCompany['AddressRegistered']['PostCode'] = $item->getElementsByTagName('PostCode')->item(0)->nodeValue;
$tabCompany['AddressRegistered']['Country'] = $item->getElementsByTagName('Country')->item(0)->nodeValue;
}
//Adresse Commerciale
$query = '//GraydonUKCompanySchema/CompanyReportPage/CompanyReport/Address[@Type="Trading"]';
$items = $xpath->query($query);
foreach ($items as $item) {
$tabCompany['AddressTrading']['EntireAddress'] = $item->getElementsByTagName('EntireAddress')->item(0)->nodeValue;
$tabCompany['AddressTrading']['Building'] = $item->getElementsByTagName('Building')->item(0)->nodeValue;
$tabCompany['AddressTrading']['Street'] = $item->getElementsByTagName('Street')->item(0)->nodeValue;
$tabCompany['AddressTrading']['Street'] = $item->getElementsByTagName('Town')->item(0)->nodeValue;
$tabCompany['AddressTrading']['City'] = $item->getElementsByTagName('City')->item(0)->nodeValue;
$tabCompany['AddressTrading']['County'] = $item->getElementsByTagName('County')->item(0)->nodeValue;
$tabCompany['AddressTrading']['PostCode'] = $item->getElementsByTagName('PostCode')->item(0)->nodeValue;
$tabCompany['AddressTrading']['Country'] = $item->getElementsByTagName('Country')->item(0)->nodeValue;
}
//Telephone
$query = '//GraydonUKCompanySchema/CompanyReportPage/CompanyReport/Communication[@Type="Telephone"]';
$items = $xpath->query($query);
foreach ($items as $item) {
$tabCompany['Telephone'][] = $item->nodeValue;
}
//Fax
$query = '//GraydonUKCompanySchema/CompanyReportPage/CompanyReport/Communication[@Type="Fax"]';
$items = $xpath->query($query);
foreach ($items as $item) {
$tabCompany['Fax'][] = $item->nodeValue;
}
$firephp->log($tabCompany, 'tabCompany');
?>
<tr>
<td colspan="3">
<?php print $html;?>
</td>
</tr>
<?php
}else{
?>
<tr>
<td width="30">&nbsp;</td>
<td width="500" class="StyleInfoLib">Aucune information disponible.</td>
</tr>
</table>
<?php
}
?>
</table>