extranet/www/pages/international_identite.php
2009-07-23 14:32:06 +00:00

387 lines
13 KiB
PHP

<?php
if (!$_SESSION['connected']) die();
$tabInfo = $_SESSION['tabInfo'];
$identifier = $_REQUEST['identifier'];
$pays = $_SESSION['graydon']['pays'];
$mode = $_SESSION['graydon']['mode'];
require_once 'i18n/cleanchar.php';
require_once 'graydon/graydonws.php';
require_once 'graydon/pays.php';
require_once 'graydon/graydon_log.php';
require_once 'dbbootstrap.php';
$tabIdentifiers = getCompanyMatchIdentifiers($pays);
$firephp->log($tabIdentifiers,'tabIdentifiers');
/** Recup des produits de la company **/
$Companyproducts = getCompanyProducts($identifier);
$company = $Companyproducts['Company'];
$products = $Companyproducts['Products'];
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é simplifié<br/></td>
<td>
<?php
$count = count($products);
if($count==1){
$products[] = $products;
}
$noReport = TRUE;
?>
<u><b>Accès à la fiche identité approfondie :</b></u>
<?php
$tabReport = array();
$tabProductIdentifier = array();
$countProducts = 0;
foreach($products as $product){
//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 Superflash
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 à jour
if ($product->ServiceSpeed == 'ImmediateWithUpdate' && $product->Type == 'Database' && $product->Level == 3 ){
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 ){
$tabReport[] = 'ImmediateWithUpdate';
$tabProducts[$countProducts]['identifier'] = $product->CompanyProductIdentifier;
$tabProducts[$countProducts]['DaysFrom'] = $product->DaysFrom;
$tabProducts[$countProducts]['DaysTo'] = $product->DaysTo;
$countProducts++;
}
*/
}
//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;}
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 = "Rapport international disponible dans un autre format que le XML\n";
$body .= "Identifiant : ".$identifier."";
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
$mail->Send();
}
}else{
if ($product->MimeTypes->MimeType == 'xml' ){$mimetype = TRUE;}
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 = "Rapport international disponible dans un autre format que le XML\n";
$body .= "Identifiant : ".$identifier."";
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
$mail->Send();
}
}
if ($mimetype == TRUE ){
$tabReport[] = 'Immediate';
$tabProducts[$countProducts]['identifier'] = $product->CompanyProductIdentifier;
$countProducts++;
}
}
}
$firephp->log($tabProducts,'tabProducts');
if(count($tabReport)==0){
?>
(Aucun rapport disponible pour cette société)
<?php
}else{
//Récupération des tarifs propre au pays
setDbConn('graydon');
$q = Doctrine_Query::create($conn)
->from('Price p')
->leftJoin('p.Country c')
->where('c.graydon_country = ?', $pays);
$tabPaysPrix = $q->fetchArray();
$firephp->log($tabPaysPrix, 'tableau');
if(in_array('Normal',$tabReport)){
$key = array_search('Normal', $tabReport);
$pidentifier = $tabProducts[$key]['identifier'];
$daysFrom = $tabProducts[$key]['DaysFrom'];
$daysTo = $tabProducts[$key]['DaysTo'];
//Vérification des droits
if(preg_match('/international/i', $_SESSION['tabInfo']['droits'])){
//print '<br/><br/><a href="./?page=international_enquete&identifier='.$identifier.'&pidentifier='.$pidentifier.'">Commander le rapport en mode normal</a><br/><i>(Délais : '.$daysFrom.' à '.$daysTo.' Jours, Tarif : '.$tabPaysPrix[0]['normal'].' &euro;)</i>';
print '<br/><br/><a href="#">Commander le rapport en mode normal</a><br/><i>(Délais : '.$daysFrom.' à '.$daysTo.' Jours, Tarif : '.$tabPaysPrix[0]['normal'].' &euro;)</i>';
}else{
print '<br/><br/><a href="#" title="Vous n\'avez pas les droits nécessaires pour commander un rapport international">Commander le rapport en mode normal</a><br/><i>(Délais : '.$daysFrom.' à '.$daysTo.' Jours, Tarif : '.$tabPaysPrix[0]['normal'].' &euro;)</i>';
}
}
//Affichage des différents rapports dans l'ordre
if(in_array('Superflash',$tabReport)){
$key = array_search('Superflash', $tabReport);
$pidentifier = $tabProducts[$key]['identifier'];
$daysFrom = $tabProducts[$key]['DaysFrom'];
$daysTo = $tabProducts[$key]['DaysTo'];
//Vérification des droits
if(preg_match('/international/i', $_SESSION['tabInfo']['droits'])){
//print '<br/><br/><a href="./?page=international_enquete&identifier='.$identifier.'&pidentifier='.$pidentifier.'">Commander le rapport en mode rapide</a><br/><i>(Délais : '.$daysFrom.' à '.$daysTo.' Jours, Tarif : '.$tabPaysPrix[0]['superflash'].' &euro;)</i>';
print '<br/><br/><a href="#">Commander le rapport en mode rapide</a><br/><i>(Délais : '.$daysFrom.' à '.$daysTo.' Jours, Tarif : '.$tabPaysPrix[0]['superflash'].' &euro;)</i>';
}else{
print '<br/><br/><a href="#" title="Vous n\'avez pas les droits nécessaires pour commander un rapport international">Commander le rapport en mode rapide</a><br/><i>(Délais : '.$daysFrom.' à '.$daysTo.' Jours, Tarif : '.$tabPaysPrix[0]['superflash'].' &euro;)</i>';
}
}
if(in_array('Immediate',$tabReport)){
$key = array_search('Immediate', $tabReport);
$pidentifier = $tabProducts[$key]['identifier'];
//Vérification des droits
if(preg_match('/international/i', $_SESSION['tabInfo']['droits'])){
print '<br/><br/><a href="./?page=international_identitec&identifier='.$identifier.'&pidentifier='.$pidentifier.'">Consutler le rapport disponible</a><br/><i>(Délais : Immédiat, Tarif : '.$tabPaysPrix[0]['immediate'].' &euro;)</i>';
}else{
print '<br/><br/><a href="#" title="Vous n\'avez pas les droits nécessaires pour commander un rapport international">Consutler le rapport disponible</a><br/><i>(Délais : Immédiat, Tarif : '.$tabPaysPrix[0]['immediate'].' &euro;)</i>';
}
}
}
?>
</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;
if(is_array($tabIdentifiers)){
foreach($tabIdentifiers as $tabIdentifier){
if($tabIdentifier->Type == $identifier->Type){
print $tabIdentifier->Description;
$identifierDescription = TRUE;
}
}
}
if ($identifierDescription==FALSE){
print $identifier->Type;
}
//@TODO : Tester si la condition à bien été remplie
?>
</td>
<td width="350" class="StyleInfoData">
<?php print "1".$identifier->Identifier; ?></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<?php
}
}
?>
</table>
<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
$_SESSION['graydon']['name'] = $company->Name;
print cleanutf8($company->Name);
?>
</td>
</tr>
<tr>
<td width="30">&nbsp;</td>
<td width="200" class="StyleInfoLib">Adresse Complète</td>
<td width="350" class="StyleInfoData"><?php print cleanutf8($company->RegisteredAddress->EntireAddress); ?></td>
</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>
</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>
</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éléphone</td>
<td width="350" class="StyleInfoData"><?php print $company->Telephone; ?></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</table>
<h2>Activité(s) de l'entreprise : </h2>
<table>
<?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>
</tr>
<?php
}
}else{
?>
<tr>
<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é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écupération du geoCode
* La page est chargé alors par javascript on load en ajax
* Chargement de la carte (nouvelle page loadMap.php ??)
* loadMap => On vérifie la session
* => On envoi le geocode ?? les markers supplémentaires
*/
?>
<?php
}else{
?>
<table>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2" class="StyleInfoData">Aucune information disponible</td>
</tr>
</table>
<?php
}
?>
</div>