extranet/www/pages/international_identitec.php

290 lines
9.2 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'];
$CompanyProductIdentifier = $_REQUEST['pidentifier'];
$pays = $_SESSION['graydon']['pays'];
2009-05-11 09:52:19 +00:00
$mode = $_SESSION['graydon']['mode'];
2009-04-07 17:44:17 +00:00
require_once 'i18n/cleanchar.php';
2009-04-07 17:44:17 +00:00
require_once 'graydon/graydonws.php';
require_once 'graydon/graydon_log.php';
require_once 'dbbootstrap.php';
2009-04-07 17:44:17 +00:00
function dVal($value){
if($value == '' || $value == NULL){
print 'NC';
}else{
print $value;
}
}
?>
<div id="center">
<?php
2009-04-09 17:10:02 +00:00
$path = PATH_DATA.'/graydon';
$fileName = strtolower(str_replace( array(':',' '), '-', $identifier).'.xml');
2009-05-11 15:55:28 +00:00
2009-05-12 16:57:43 +00:00
//V<>rifier si le rapport n'est pas disponible en base depuis une autre commandes
setDbConn('graydon');
2009-05-12 16:57:43 +00:00
$q = Doctrine_Query::create()
->from('Report')
->where('identifier = ?', $_REQUEST['identifier']);
$report = new Report();
$report = $q->fetchOne();
2009-05-11 15:55:28 +00:00
2009-05-12 16:57:43 +00:00
//@TODO : si le rapport existe d<>j<EFBFBD> ou que la date n'est pas tr<74>s <20>loign<67>
if($report==FALSE){
2009-05-12 16:57:43 +00:00
//V<>rifier si le rapport en ligne <20> d<>j<EFBFBD> <20>t<EFBFBD> demand<6E>
$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)){
2009-05-12 16:57:43 +00:00
//placeOrder
2009-04-09 17:10:02 +00:00
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
2009-05-12 16:57:43 +00:00
$request->OrderCreatorEmail = 'mricois@scores-decisions.com';
$request->CompanyProductIdentifier = $CompanyProductIdentifier;
$request->PartnerData = '';
2009-04-09 17:10:02 +00:00
try
{
2009-05-12 16:57:43 +00:00
$placeOrderResult = $graydon->placeOrder($request);
//Enregistrement de l'action dans les logs
2009-05-12 16:57:43 +00:00
$transactionIdentifier = $placeOrderResult->Service_Log->TransactionIdentifier;
$sessionID = $placeOrderResult->Service_Log->SessionID;
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'placeOrder', $transactionIdentifier, $sessionID);
2009-05-12 16:57:43 +00:00
//Log de la requete dans la bdd
$log = new Requetelog();
$log->login = $_SESSION['tabInfo']['login'];
2009-05-12 16:57:43 +00:00
$log->action = 'placeOrder';
2009-05-11 09:52:19 +00:00
$log->request = serialize($request);
$log->transactionIdentifier = $transactionIdentifier;
$log->sessionID = $sessionID;
2009-05-11 09:52:19 +00:00
$log->mode = $mode;
$log->save();
2009-05-12 16:57:43 +00:00
//Optention du prix du service
$prix = Doctrine_Query::create($conn)
->select('p.immediate')
->from('Price p')
->leftJoin('p.Country c')
->where('c.graydon_country = ?', $pays)
->fetchOne();
2009-04-09 17:10:02 +00:00
2009-05-12 16:57:43 +00:00
//Enregistrement des commandes dans la bdd
$commandes = new Commandes();
$commandes->reference = $placeOrderResult->OrderStatus->OrderReference;
$commandes->servicespeed = $placeOrderResult->OrderStatus->Order->ServiceSpeed;
$commandes->prix = $prix->immediate;
$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'];
2009-05-12 16:57:43 +00:00
$country = Doctrine_Query::create()
->from('Country')
->where('graydon_country = ?', $pays)
->fetchOne();
2009-04-09 17:10:02 +00:00
2009-05-12 16:57:43 +00:00
$commandes->Country = $country;
$commandes->save();
$firephp->log($commandes->toArray(),'dataCommandes');
$commandes_id = $commandes->id;
//Pas d'enregistrement des d<>tails de la commande car elle est imm<6D>diate
2009-05-13 16:05:50 +00:00
//Envoi d'un mail pour le passage de la commande
require_once 'phpmailer/class.phpmailer.php';
$mail = new PHPMailer();
$mail->From = "contact@scores-decisions.com";
$mail->FromName = "Commandes International";
$mail->Host = "mail.scores-decisions.com";
$mail->Mailer = "smtp";
$mail->Subject = "[International] - (Date :".date("d")."/".date("m")."/".date("Y").") - Commandes";
$body = "Commande effectu<74> par ".$tabInfo['login'];
$body .= "";
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
$mail->Send();
2009-05-12 16:57:43 +00:00
//$firephp->log($placeOrderResult,'placeOrder');
}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);
}
2009-04-09 17:10:02 +00:00
}
2009-05-12 16:57:43 +00:00
//On v<>rifie l'<27>tat de le demande
if (isset($placeOrderResult) && $placeOrderResult->OrderStatus->OrderState == 'Completed'){
//getCompanyReport
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->LanguageCode = 'E'; //Sp<53>cifier la langue du rapport
$request->OrderReference = $placeOrderResult->OrderStatus->OrderReference;
$request->MimeType = 'xml';
$firephp->log($request,'requete');
try
{
$reportResult = $graydon->getCompanyReport($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $reportResult->Service_Log->TransactionIdentifier;
$sessionID = $reportResult->Service_Log->SessionID;
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyReport', $transactionIdentifier, $sessionID);
//Enregistrement dans la bdd
$log = new Requetelog();
$log->login = $_SESSION['tabInfo']['login'];
$log->action = 'getCompanyReport';
$log->request = serialize($request);
$log->transactionIdentifier = $transactionIdentifier;
$log->sessionID = $sessionID;
$log->mode = $mode;
$log->save();
$firephp->log($reportResult,'reportResult');
$xml = $reportResult->ReportXML->any;
//Enregistrement du fichier xml
file_put_contents($path.'/'.$fileName, $xml);
//Mise en cache dans la bdd
$report = new Report();
$report->identifier = $identifier;
$report->name = $_SESSION['graydon']['name'];
$report->content = $xml;
$report->format = 'xml';
$report->order_id = $commandes_id;
$report->save();
}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);
}
}
}
//La commande <20> d<>j<EFBFBD> <20>t<EFBFBD> demand<6E>
}else{
//Assignation du contenu
$xml = $report->content;
2009-04-09 17:10:02 +00:00
}
2009-05-12 16:57:43 +00:00
//Le rapport est disponible
2009-04-09 17:10:02 +00:00
}else{
/*
//Enregistrement d'une fausse commande dans la bdd
$commandes = new Commandes();
$commandes->reference = $placeOrderResult->OrderStatus->OrderReference;
$commandes->servicespeed = $placeOrderResult->OrderStatus->Order->ServiceSpeed;
$commandes->prix = $prix->immediate;
$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'];
$country = Doctrine_Query::create()
->from('Country')
->where('graydon_country = ?', $pays)
->fetchOne();
$commandes->Country = $country;
$commandes->save();
$firephp->log($commandes->toArray(),'dataCommandes');
$commandes_id = $commandes->id;
*/
//Assignation du contenu
$xml = $report->content;
2009-04-09 17:10:02 +00:00
}
//========= Affichage des informations =========
if(isset($xml) && $xml!=''){
$tabReport = array();
2009-04-24 09:52:30 +00:00
require_once 'graydon/functions.php';
require_once 'graydon/format.php';
2009-04-27 15:16:02 +00:00
2009-04-09 17:10:02 +00:00
//Cr<43>ation du DOM
$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$doc->loadxml($xml);
$xpath = new DOMXPath($doc);
2009-04-23 06:53:26 +00:00
$tabReport = parseReportXML($xml);
$firephp->log($tabReport, 'tabReport');
function utf8decode_deep($value)
{
$value = is_array($value) ?
array_map('utf8decode_deep', $value) :
cleanutf8($value);
return $value;
}
?>
2009-04-09 17:10:02 +00:00
2009-04-27 15:16:02 +00:00
<style type="text/css">
2009-04-27 16:29:57 +00:00
.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;}
2009-04-27 15:16:02 +00:00
</style>
<h1 class="titre">IDENTIT&Eacute; INTERNATIONALE DE L'ENTREPRISE</h1>
<?php dIdentifiant($tabReport); ?>
<h2>Raison sociale et coordonn<EFBFBD>es : </h2>
<?php dIdentite($tabReport);?>
<h2>Activit<EFBFBD>(s) et chiffre d'affaire de l'entreprise : </h2>
<?php dActivite($tabReport); ?>
<h2> R<EFBFBD>sum<EFBFBD> financier : </h2>
<?php dResume($tabReport); ?>
<h2> Credit : </h2>
<?php dCredit($tabReport); ?>
2009-04-27 15:16:02 +00:00
<h2> Actionariat / Participation : </h2>
<?php dLiens($tabReport); ?>
<h2> Bilans : </h2>
<?php dBilans($tabReport); ?>
2009-04-07 17:44:17 +00:00
<?php
}else{
?>
<table>
2009-04-07 17:44:17 +00:00
<tr>
<td width="30">&nbsp;</td>
<td width="500" class="StyleInfoLib">Aucune information disponible.</td>
</tr>
</table>
<?php
}
?>
</div>