extranet/www/pages/international_identite.php

485 lines
15 KiB
PHP
Raw Normal View History

2009-04-07 17:44:17 +00:00
<?php
session_start();
2009-04-07 17:44:17 +00:00
if (!$_SESSION['connected']) die();
$tabInfo = $_SESSION['tabInfo'];
2009-04-07 17:44:17 +00:00
$identifier = $_REQUEST['identifier'];
$pays = $_SESSION['graydon']['pays'];
2009-05-11 09:52:19 +00:00
$mode = $_SESSION['graydon']['mode'];
2009-04-07 17:44:17 +00:00
/*
getCompanyProduct
Afficher les informations de getCompanyProduct (Identifiant, Activit<EFBFBD>, t<EFBFBD>l<EFBFBD>phone )
Si product.type=database alors on r<EFBFBD>cup<EFBFBD>re un rapport
on traite suivant le mimetype
on affiche les informations
getCompanyMatchIdentifier
*/
require_once 'i18n/cleanchar.php';
2009-04-07 17:44:17 +00:00
require_once 'graydon/graydonws.php';
require_once 'graydon/pays.php';
require_once 'graydon/graydon_log.php';
require_once 'dbbootstrap.php';
/** Recherche des identifiants et mise en cache **/
$q = Doctrine_Query::create()
->from('Matchidentifiers')
->where('country = ?', $pays);
2009-04-07 17:44:17 +00:00
$matchidentifiers = new Matchidentifiers();
$matchidentifiers = $q->fetchOne();
$nbResult = $q->count();
2009-04-07 17:44:17 +00:00
/** Recup des types d'identifiants pour le pays **/
if($nbResult == 0){
//R<>cup<75>ration des intitul<75>s identifiant
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->Country = $pays;
$firephp->log($request,'REQUETE CompanyMatchIdentifier');
try
{
$result = $graydon->getCompanyMatchIdentifiers($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
2009-05-11 09:52:19 +00:00
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
2009-05-11 09:52:19 +00:00
//Log de la requete dans la bdd
$log = new Requetelog();
$log->login = $_SESSION['tabInfo']['login'];
$log->action = 'getCompanyMatchIdentifiers';
$log->request = serialize($request);
$log->transactionIdentifier = $transactionIdentifier;
$log->sessionID = $sessionID;
$log->mode = $mode;
$log->save();
$count = count($result->CompanyMatchIdentifiers);
if ($count>1){
$tabIdentifiers = $result->CompanyMatchIdentifiers->CompanyMatchIdentifier->CompanyIdentifier;
}elseif($count==1){
$tabIdentifiers[] = $result->CompanyMatchIdentifiers->CompanyMatchIdentifier->CompanyIdentifier;
}
//Stockage du r<>sultat de la m<>thode en cache
$matchidentifiers = new Matchidentifiers();
$matchidentifiers->country = $pays;
$matchidentifiers->identifiers = serialize($tabIdentifiers);
$matchidentifiers->replace();
}catch( SoapFault $fault ){
$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);
}
}
}else{
$tabIdentifiers = unserialize($matchidentifiers->identifiers);
}
$firephp->log($tabIdentifiers,'tabIdentifiers');
/** Recup des produits de la company **/
$q = Doctrine_Query::create()
->from('Companyproducts')
->where('identifiers = ?', $identifier);
$companyproducts = new Companyproducts();
$companyproducts = $q->fetchOne();
$firephp->log($companyproducts->updated_at,'date');
$nbResult = $q->count();
$now = mktime(date('G'), date('i'), date('s'), date("m") , date("d"), date("Y"));
if($nbResult == 0){
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->CompanyMatchIdentifier = $identifier;
$firephp->log($request,'requete');
try {
// Make a request on the web service
$result = $graydon->getCompanyProducts($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyProducts', $transactionIdentifier, $sessionID);
2009-05-11 09:52:19 +00:00
//Log de la requete dans la bdd
$log = new Requetelog();
$log->login = $_SESSION['tabInfo']['login'];
$log->action = 'getCompanyProducts';
$log->request = serialize($request);
$log->transactionIdentifier = $transactionIdentifier;
$log->sessionID = $sessionID;
$log->mode = $mode;
$log->save();
$firephp->log($result,'result');
//Sauvegarde dans la bdd
$companyproducts = new Companyproducts();
$companyproducts->identifiers = $identifier;
$companyproducts->company = serialize($result->Company);
$companyproducts->products = serialize($result->Products);
$companyproducts->replace();
//Extraction
$company = $result->Company;
$products = $result->Products->Product;
}catch( SoapFault $fault ){
$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);
}
}
}else{
$company = unserialize($companyproducts->company);
$products = unserialize($companyproducts->products);
$products = $products->Product;
}
if(isset($company)){
$firephp->log($products,'products');
?>
<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<EFBFBD> simplifi<EFBFBD><br/></td>
<td>
<?php
2009-04-07 17:44:17 +00:00
$count = count($products);
if($count==1){
$products[] = $products;
}
$noReport = TRUE;
2009-04-23 06:53:26 +00:00
?>
<u><b>Acc<EFBFBD>s <EFBFBD> la fiche identit<EFBFBD> approfondie :</b></u>
<?php
$tabReport = array();
$tabProductIdentifier = array();
$countProducts = 0;
2009-04-07 17:44:17 +00:00
foreach($products as $product){
2009-04-23 06:53:26 +00:00
//Rapport en mode normal
if ($product->ServiceSpeed == 'Normal' && $product->Type == 'Investigation' && $product->Level == 4 ){
$tabReport[$countProducts] = 'Normal';
$tabProducts[$countProducts]['identifier'] = $product->CompanyProductIdentifier;
$tabProducts[$countProducts]['DaysFrom'] = $product->DaysFrom;
$tabProducts[$countProducts]['DaysTo'] = $product->DaysTo;
$countProducts++;
}
//Rapport en mode normal
if ($product->ServiceSpeed == 'Superflash' && $product->Type == 'Investigation' && $product->Level == 4 ){
$tabReport[] = 'Superflash';
$tabProducts[$countProducts]['identifier'] = $product->CompanyProductIdentifier;
$tabProducts[$countProducts]['DaysFrom'] = $product->DaysFrom;
$tabProducts[$countProducts]['DaysTo'] = $product->DaysTo;
$countProducts++;
}
//Rapport disponible avec mise <20> jour
if ($product->ServiceSpeed == 'ImmediateWithUpdate' && $product->Type == 'Database' && $product->Level == 3 ){
2009-04-27 15:16:02 +00:00
require_once '/phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->From = "contact@scores-decisions.com";
$mail->FromName = "Serveur SD-13408";
$mail->Host = "mail.scores-decisions.com";
$mail->Mailer = "smtp";
$mail->Subject = "Rapport International";
$body = "ImmediateWithUpdate disponible\n";
$body .= "Identifiant : ".$identifier."";
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
$mail->Send();
//Don't display ImmediateWithUpdate
/*
$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 ){
2009-04-23 06:53:26 +00:00
$tabReport[] = 'ImmediateWithUpdate';
$tabProducts[$countProducts]['identifier'] = $product->CompanyProductIdentifier;
$tabProducts[$countProducts]['DaysFrom'] = $product->DaysFrom;
$tabProducts[$countProducts]['DaysTo'] = $product->DaysTo;
$countProducts++;
}
2009-04-27 15:16:02 +00:00
*/
2009-04-07 17:44:17 +00:00
}
2009-04-23 06:53:26 +00:00
//Rapport disponible en ligne
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;}
2009-04-27 15:16:02 +00:00
else {
require_once 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->From = "contact@scores-decisions.com";
$mail->FromName = "Serveur SD-13408";
$mail->Host = "mail.scores-decisions.com";
$mail->Mailer = "smtp";
$mail->Subject = "Rapport International";
$body = "Le rapport international disponible dans un autre format que le XML\n";
$body .= "Identifiant : ".$identifier."";
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
$mail->Send();
}
2009-04-23 06:53:26 +00:00
}else{
if ($product->MimeTypes->MimeType == 'xml' ){$mimetype = TRUE;}
2009-04-27 15:16:02 +00:00
else {
require_once 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->From = "contact@scores-decisions.com";
$mail->FromName = "Serveur SD-13408";
$mail->Host = "mail.scores-decisions.com";
$mail->Mailer = "smtp";
$mail->Subject = "Rapport International";
$body = "Le rapport international disponible dans un autre format que le XML\n";
$body .= "Identifiant : ".$identifier."";
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
$mail->Send();
}
2009-04-23 06:53:26 +00:00
}
if ($mimetype == TRUE ){
$tabReport[] = 'Immediate';
$tabProducts[$countProducts]['identifier'] = $product->CompanyProductIdentifier;
$countProducts++;
}
}
2009-04-07 17:44:17 +00:00
}
$firephp->log($tabProducts,'tabProducts');
2009-04-23 06:53:26 +00:00
if(count($tabReport)==0){
?>
2009-04-23 06:53:26 +00:00
(Aucun rapport disponible pour cette soci<EFBFBD>t<EFBFBD>)
<?php
2009-04-23 06:53:26 +00:00
}else{
//Affichage des diff<66>rents rapports dans l'ordre
if(in_array('Normal',$tabReport)){
$key = array_search('Normal', $tabReport);
$pidentifier = $tabProducts[$key]['identifier'];
$daysFrom = $tabProducts[$key]['DaysFrom'];
$daysTo = $tabProducts[$key]['DaysTo'];
print '<br/><br/>Commander le rapport en mode normal <br/><i>(D<>lais : '.$daysFrom.' <20> '.$daysTo.' Jours, Tarif : '.$tabPaysPrix['Normal'][$pays].' &euro;)</i>';
}
if(in_array('Superflash',$tabReport)){
$key = array_search('Superflash', $tabReport);
$pidentifier = $tabProducts[$key]['identifier'];
$daysFrom = $tabProducts[$key]['DaysFrom'];
$daysTo = $tabProducts[$key]['DaysTo'];
print '<br/><br/>Commander le rapport en mode superflash <br/><i>(D<>lais : '.$daysFrom.' <20> '.$daysTo.' Jours, Tarif : '.$tabPaysPrix['Superflash'][$pays].' &euro;)</i>';
}
if(in_array('Immediate',$tabReport)){
$key = array_search('Immediate', $tabReport);
$pidentifier = $tabProducts[$key]['identifier'];
print '<br/><br/><a href="./?page=international_identitec&identifier='.$identifier.'&pidentifier='.$pidentifier.'"> Consutler le rapport disponible</a><br/><i>(D<>lais : Imm<6D>diat, Tarif : '.$tabPaysPrix['Immediate'][$pays].' &euro;)</i>';
}
}
?>
2009-04-07 17:44:17 +00:00
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<?php
$count = count($company->CompanyIdentifiers->CompanyIdentifier);
if ($count>1){
$identifiers = $company->CompanyIdentifiers->CompanyIdentifier;
}elseif($count==1){
$identifiers[] = $company->CompanyIdentifiers->CompanyIdentifier;
}
foreach($identifiers as $identifier){
if($identifier->Type != 'Internal'){
?>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">
<?php
$identifierDescription = FALSE;
foreach($tabIdentifiers as $tabIdentifier){
if($tabIdentifier->Type == $identifier->Type){
print $tabIdentifier->Description;
2009-04-07 17:44:17 +00:00
$identifierDescription = TRUE;
}
}
if ($identifierDescription==FALSE){
print $identifier->Type;
}
//@TODO : Tester si la condition <20> bien <20>t<EFBFBD> remplie
?>
</td>
<td width="350" class="StyleInfoData">
<?php print $identifier->Identifier; ?></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<?php
}
}
?>
</table>
<h2>Raison sociale et coordonn<EFBFBD>es : </h2>
<table>
2009-04-07 17:44:17 +00:00
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Raison Sociale</td>
2009-05-11 15:55:28 +00:00
<td width="350" class="StyleInfoData">
<?php
$_SESSION['graydon']['name'] = $company->name;
print cleanutf8($company->Name);
?>
</td>
2009-04-07 17:44:17 +00:00
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Adresse Compl<EFBFBD>te</td>
<td width="350" class="StyleInfoData"><?php print cleanutf8($company->RegisteredAddress->EntireAddress); ?></td>
2009-04-07 17:44:17 +00:00
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Adresse</td>
<td width="350" class="StyleInfoData"><?php print cleanutf8($company->RegisteredAddress->Building.', '.$company->RegisteredAddress->Street); ?></td>
2009-04-07 17:44:17 +00:00
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Code Postal</td>
<td width="350" class="StyleInfoData"><?php print $company->RegisteredAddress->PostCode; ?></td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Ville</td>
<td width="350" class="StyleInfoData"><?php print cleanutf8($company->RegisteredAddress->City); ?></td>
2009-04-07 17:44:17 +00:00
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Pays</td>
<td width="350" class="StyleInfoData">
<?php
if(isset($company->RegisteredAddress->Country)){
print $company->RegisteredAddress->Country;
}else{
print $pays;
}
?>
</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">T<EFBFBD>l<EFBFBD>phone</td>
<td width="350" class="StyleInfoData"><?php print $company->Telephone; ?></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</table>
<h2>Activit<EFBFBD>(s) de l'entreprise : </h2>
<table>
2009-04-07 17:44:17 +00:00
<?php
$count = count($company->Activites->Activity);
if ($count>1){
$activites = $company->Activites->Activity;
}elseif($count==1){
$activites[] = $company->Activites->Activity;
}
if ($count>0){
foreach($activites as $activity){
?>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Code <?php print $activity->Type;?></td>
<td width="350" class="StyleInfoData"><?php print $activity->Code;?> - <?php print cleanutf8($activity->Description);?></td>
2009-04-07 17:44:17 +00:00
</tr>
<?php
}
}else{
?>
<tr>
2009-04-07 17:44:17 +00:00
<td width="30">&nbsp;</td>
<td colspan="2" class="StyleInfoData">Aucune information disponible</td>
</tr>
<?php
}
?>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</table>
<h2>G<EFBFBD>olocalisation : </h2>
<?php
/*
$adresse = $company->RegisteredAddress->Building;
$codePostal = $company->RegisteredAddress->PostCode;
$ville = $company->RegisteredAddress->City;
*/
/*
try {
$geoCodeResult = $client->geoCode('19 rue de saulnier', '75009', 'paris', 'france');
$firephp->log($geoCodeResult, 'geocode');
}catch(SoapFault $fault){
print '<pre>';
print $client->__getLastResponse();
print '</pre>';
}
*/
/*
* R<EFBFBD>cup<EFBFBD>ration du geoCode
* La page est charg<EFBFBD> alors par javascript on load en ajax
* Chargement de la carte (nouvelle page loadMap.php ??)
* loadMap => On v<EFBFBD>rifie la session
* => On envoi le geocode ?? les markers suppl<EFBFBD>mentaires
*/
?>
2009-04-07 17:44:17 +00:00
<?php
}else{
?>
<table>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2" class="StyleInfoData">Aucune information disponible</td>
</tr>
</table>
<?php
}
2009-04-07 17:44:17 +00:00
?>
</div>