extranet/www/pages/international_identite.php
2010-04-26 14:46:13 +00:00

384 lines
11 KiB
PHP

<?php
$tabInfo = $_SESSION['tabInfo'];
$identifier = $_REQUEST['identifier'];
$pays = $_SESSION['graydon']['pays'];
$mode = $_SESSION['graydon']['mode'];
require_once 'i18n/cleanchar.php';
require_once 'graydon/graydon.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 $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;
if (isset($product->DaysFrom) == true) {
$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 'mail/mail.php';
sendMail('Rapport International',
"ImmediateWithUpdate disponible\n" .
"Identifiant : ".$identifier,
array('email' => 'contact@scores-decisions.com',
'name' => 'Serveur SD-13408'),
array(0 => array('email' => EMAIL_SUPPORTDEV,
'name' => 'Support'), ));
//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)){ $productMimeTypes = array($product->MimeTypes->MimeType); }
else{ $productMimeTypes = $product->MimeTypes->MimeType; }
foreach( reportFormat() as $format )
{
if (in_array($format, $product->MimeTypes->MimeType))
{
$mimetype = TRUE;
break;
}
else
{
require_once 'mail/mail.php';
sendMail(
'Rapport International',
"Rapport international disponible dans un autre format que le XML\n" .
"Identifiant : ".$identifier,
array(
'email'=>'contact@scores-decisions.com',
'name'=>'Serveur SD-13408'),
array(
0 => array(
'email'=>EMAIL_SUPPORTDEV,
'name'=>'Support'),
)
);
}
}
if ($mimetype == TRUE )
{
$tabReport[] = 'Immediate';
$tabProducts[$countProducts]['identifier'] = $product->CompanyProductIdentifier;
$tabProducts[$countProducts]['format'] = $format;
$countProducts++;
}
}
} // Fin boucle d'affichage des produits
// --------------------------------------------------------------------------- //
// Affichage des differents rapports
// --------------------------------------------------------------------------- //
if (count($tabReport) == 0) {
print '(Aucun rapport disponible pour cette société)';
} else {
// Récupération des tarifs propre au pays
setDbConn('graydon');
$tabPaysPrix = Doctrine_Query::create()
->from('Price p')
->leftJoin('p.Country c')
->where('c.graydon_country = ?', $pays)
->fetchArray();
foreach (array('normal' => 'normal',
'superflash' => 'rapide',
'immediate' => 'immédiat') as $mode_en => $mode_fr) {
print '<br/><br/>';
if (in_array(ucfirst($mode_en), $tabReport) == false) {
print '<a href="#">Rapport en mode '.$mode_fr.' indisponible</a>';
continue;
}
$key = array_search(ucfirst($mode_en), $tabReport);
$pidentifier = $tabProducts[$key]['identifier'];
// Verification des droits
if (preg_match('/\binternational\b/i', $_SESSION['tabInfo']['droits'])) {
print '<a href="./?page=international_enquete'.
'&speed='.$mode_en.
'&identifier='.$identifier.
'&pidentifier='.$pidentifier.
'">'.
'Commander le rapport en mode '.$mode_fr.'</a>';
} else {
print '<a href="#">Vous n\'avez pas les droits nécessaires'.
' pour commander un rapport international</a>';
}
if ($mode_fr != 'immédiat') {
$daysFrom = (isset($tabProducts[$key]['DaysFrom']) == true) ?
$tabProducts[$key]['DaysFrom'] : '';
$daysTo = $tabProducts[$key]['DaysTo'];
print '<br/><i>(Délais : '.$daysFrom.' à '.$daysTo.' Jours'.
', Tarif : '.$tabPaysPrix[0][$mode_en].' &euro;)</i>';
}
}
}
?>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<?php
$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 $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
if ($company->Name != '') {
$name = $company->Name;
} else {
$name = $_REQUEST['name'];
}
$_SESSION['graydon']['name'] = $name;
print cleanutf8($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);
if (isset($company->RegisteredAddress->Street) == true) {
print cleanutf8(', '.$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) == true) {
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
if (isset($company->Telephone) == true) {
print $company->Telephone;
}
?>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</table>
<h2>Activité(s) de l'entreprise : </h2>
<table>
<?php
if (count($company->Activites) > 0) {
foreach($company->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.' - '.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
*/
?>
</div>
<?php
}else{
?>
<div id="center">
<table>
<tr>
<td width="30">&nbsp;</td>
<td colspan="2" class="StyleInfoData">Aucune information disponible</td>
</tr>
</table>
</div>
<?php
}
?>