extranet/www/pages/international_identitec.php
2009-09-25 15:57:59 +00:00

146 lines
4.0 KiB
PHP

<?php
if (!$_SESSION['connected']) die();
$tabInfo = $_SESSION['tabInfo'];
$identifier = $_REQUEST['identifier'];
$CompanyProductIdentifier = $_REQUEST['pidentifier'];
$pays = $_SESSION['graydon']['pays'];
$mode = $_SESSION['graydon']['mode'];
require_once 'i18n/cleanchar.php';
require_once 'graydon/graydonws.php';
require_once 'graydon/graydon_log.php';
require_once 'dbbootstrap.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');
//Vérifier si le rapport n'est pas disponible en base depuis une autre commandes
setDbConn('graydon');
$q = Doctrine_Query::create()
->from('Report')
->where('identifier = ?', $_REQUEST['identifier']);
$report = new Report();
$report = $q->fetchOne();
//@TODO : si le rapport existe déjà ou que la date n'est pas très éloigné
if($report==FALSE){
$firephp->info('Pas en cache');
//Vérifier si le rapport en ligne à déjà été demandé
$q = Doctrine_Query::create()
->from('Commandes')
->where('companyproductidentifier = ?', $CompanyProductIdentifier);
$commandes = new Commandes();
$commandes = $q->fetchOne();
$report = new Report();
$report = $commandes->Report;
if($commandes == FALSE && !isset($report->id)){
$xml = getIdentite($CompanyProductIdentifier, $path.'/'.$fileName);
//La commande à déjà été demandé
}else{
$xml = $report->content;
}
//Le rapport est disponible
}else{
$country = Doctrine_Query::create()
->from('Country')
->where('graydon_country = ?', $pays)
->fetchOne();
//Enregistrement d'une fausse commande dans la bdd
$commandes = new Commandes();
$commandes->reference = $placeOrderResult->OrderStatus->OrderReference;
$commandes->servicespeed = $placeOrderResult->OrderStatus->Order->ServiceSpeed;
$commandes->prix = 0;
$commandes->orderstate = $placeOrderResult->OrderStatus->OrderState;
$commandes->dateordered = $placeOrderResult->OrderStatus->DateOrdered;
$commandes->datecompleted = $placeOrderResult->OrderStatus->DateCompleted;
$commandes->datedue = $placeOrderResult->OrderStatus->DateDue;
$commandes->companyproductidentifier = $CompanyProductIdentifier;
$commandes->sessionid = $sessionID;
$commandes->transactionidentifier = $transactionIdentifier;
$commandes->user = $tabInfo['login'];
$commandes->mode = $_SESSION['graydon']['mode'];
$commandes->Country = $country;
$commandes->save();
$firephp->log($commandes->toArray(),'dataCommandes');
$commandes_id = $commandes->id;
//Assignation du contenu
$xml = $report->content;
}
//========= Affichage des informations =========
if(isset($xml) && $xml!='' && $xml!==FALSE){
$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;
}
?>
<style type="text/css">
.bilans { margin-left:35px; }
div.bilans { margin-top:15px; font:bold 16px Verdana, Arial, Sans-serif; }
span.bilans { font-style:italic; }
table.bilans { width:545px; }
table.bilans .right {text-align:right;}
</style>
<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); ?>
<h2> Actionariat / Participation : </h2>
<?php dLiens($tabReport); ?>
<h2> Bilans : </h2>
<?php dBilans($tabReport); ?>
<?php
}else{
?>
<table>
<tr>
<td width="30">&nbsp;</td>
<td width="500" class="StyleInfoLib">Aucune information disponible.</td>
</tr>
</table>
<?php
}
?>
</div>