765 lines
27 KiB
PHP
765 lines
27 KiB
PHP
<?php
|
|
/**
|
|
* Retourne les identifiants disponible.
|
|
* @param string $pays
|
|
* Le pays Graydon
|
|
* @return string
|
|
* .
|
|
*/
|
|
function getCompanyMatchIdentifiers($pays)
|
|
{
|
|
global $page, $mode, $firephp, $graydon, $authentication;
|
|
|
|
$firephp->info('Méthode getCompanyMatchIdentifiers');
|
|
|
|
setDbConn('graydon');
|
|
$q = Doctrine_Query::create()
|
|
->from('Matchidentifiers')
|
|
->where('country = ?', $pays);
|
|
|
|
$matchidentifiers = new Matchidentifiers();
|
|
$matchidentifiers = $q->fetchOne();
|
|
|
|
/** Recup des types d'identifiants pour le pays **/
|
|
if($matchidentifiers == FALSE)
|
|
{
|
|
//Récupération des intitulés identifiant
|
|
$request = new StdClass();
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->Country = $pays;
|
|
$firephp->log($request,'REQUETE CompanyMatchIdentifier');
|
|
try
|
|
{
|
|
$result = $graydon->getCompanyMatchIdentifiers($request);
|
|
$firephp->log($result,'CompanyMatchIdentifiers');
|
|
//Enregistrement de l'action dans les logs
|
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|
$sessionID = $result->Service_Log->SessionID;
|
|
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
|
|
//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();
|
|
|
|
$tabIdentifiers = $result->CompanyMatchIdentifiers->CompanyMatchIdentifier[0]->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){
|
|
if($code=='CWS0112'){
|
|
//Stockage du résultat de la méthode en cache
|
|
$matchidentifiers = new Matchidentifiers();
|
|
$matchidentifiers->country = $pays;
|
|
$matchidentifiers->identifiers = serialize('noidentifiers');
|
|
$matchidentifiers->replace();
|
|
$tabIdentifiers = 'noidentifiers';
|
|
}
|
|
}else{
|
|
$tabIdentifiers = graydon_processSoapFault($graydon,$fault,$_SESSION['tabInfo']);
|
|
}
|
|
}
|
|
}else{
|
|
$firephp->info('tabIdentifiers pris dans la bdd');
|
|
$tabIdentifiers = unserialize($matchidentifiers->identifiers);
|
|
}
|
|
return $tabIdentifiers;
|
|
}
|
|
|
|
function getCompanyProducts($identifier)
|
|
{
|
|
global $page, $mode, $firephp, $graydon, $authentication;
|
|
|
|
setDbConn('graydon');
|
|
$q = Doctrine_Query::create()
|
|
->from('Companyproducts')
|
|
->where('identifiers = ?', $identifier);
|
|
|
|
$companyproducts = new Companyproducts();
|
|
$companyproducts = $q->fetchOne();
|
|
$now = mktime(date('G'), date('i'), date('s'), date("m") , date("d"), date("Y"));
|
|
if($companyproducts == FALSE){
|
|
$request = new StdClass();
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->CompanyMatchIdentifier = $identifier;
|
|
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);
|
|
|
|
//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();
|
|
|
|
//Sauvegarde dans la bdd
|
|
$companyproducts = new Companyproducts();
|
|
$companyproducts->identifiers = $identifier;
|
|
$companyproducts->company = serialize($result->Company);
|
|
$companyproducts->products = serialize($result->Products);
|
|
$companyproducts->save();
|
|
|
|
//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,$_SESSION['tabInfo']);
|
|
}
|
|
}
|
|
}else{
|
|
$company = unserialize($companyproducts->company);
|
|
$products = unserialize($companyproducts->products);
|
|
$products = $products->Product;
|
|
}
|
|
|
|
return array('Company' => $company, 'Products' => $products);
|
|
}
|
|
|
|
|
|
function getCompanyMatches($pays)
|
|
{
|
|
global $page, $mode, $firephp, $graydon, $authentication;
|
|
|
|
// Create the request parameters
|
|
$request = new StdClass();
|
|
// Initialise the request object
|
|
$request->Authentication_Parameters = $authentication;
|
|
|
|
// Create a new country parameters object
|
|
$company = new StdClass();
|
|
// Initialise the country object
|
|
$company->Country = $pays;
|
|
$company->ClientReference = '';
|
|
|
|
$request->CompanyMatches_Parameters = $company;
|
|
|
|
if($_REQUEST['method'] == 'keyword'){
|
|
$request->Keyword = $_REQUEST['frmRecherche']['Keywords'];
|
|
$request->City = isset($_REQUEST['frmRecherche']['City']) ? $_REQUEST['frmRecherche']['City'] : '' ;
|
|
$request->PostCode = isset($_REQUEST['frmRecherche']['PostCode']) ? $_REQUEST['frmRecherche']['PostCode'] : '' ;
|
|
}elseif($_REQUEST['method'] == 'identifier'){
|
|
$request->Identifier = $_REQUEST['frmRecherche']['Identifier'];
|
|
}elseif($_REQUEST['method'] == 'name'){
|
|
$request->Name = $_REQUEST['frmRecherche']['Name'];
|
|
$request->City = isset($_REQUEST['frmRecherche']['City']) ? $_REQUEST['frmRecherche']['City'] : '' ;
|
|
$request->PostCode = isset($_REQUEST['frmRecherche']['PostCode']) ? $_REQUEST['frmRecherche']['PostCode'] : '' ;
|
|
}elseif($_REQUEST['method'] == 'postcode'){
|
|
$request->PostCode = isset($_REQUEST['frmRecherche']['PostCode']) ? $_REQUEST['frmRecherche']['PostCode'] : '' ;
|
|
}
|
|
|
|
try
|
|
{
|
|
// Make a request on the webservice
|
|
if($_REQUEST['method'] == 'keyword'){
|
|
$result = $graydon->getCompanyMatchesByKeyword($request);
|
|
|
|
//Enregistrement de l'action dans les logs
|
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|
$sessionID = $result->Service_Log->SessionID;
|
|
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchesByKeyword', $transactionIdentifier, $sessionID);
|
|
|
|
//Log de la requete dans la bdd
|
|
setDbConn('graydon');
|
|
$log = new Requetelog();
|
|
$log->login = $_SESSION['tabInfo']['login'];
|
|
$log->action = 'getCompanyMatchesByKeyword';
|
|
$log->request = serialize($request);
|
|
$log->transactionIdentifier = $transactionIdentifier;
|
|
$log->sessionID = $sessionID;
|
|
$log->mode = 'normal';
|
|
$log->save();
|
|
|
|
}elseif($_REQUEST['method'] == 'identifier'){
|
|
$result = $graydon->getCompanyMatchesByIdentifier($request);
|
|
|
|
//Enregistrement de l'action dans les logs
|
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|
$sessionID = $result->Service_Log->SessionID;
|
|
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchesByIdentifier', $transactionIdentifier, $sessionID);
|
|
|
|
//Log de la requete dans la bdd
|
|
setDbConn('graydon');
|
|
$log = new Requetelog();
|
|
$log->login = $_SESSION['tabInfo']['login'];
|
|
$log->action = 'getCompanyMatchByIdentifier';
|
|
$log->request = serialize($request);
|
|
$log->transactionIdentifier = $transactionIdentifier;
|
|
$log->sessionID = $sessionID;
|
|
$log->mode = 'normal';
|
|
$log->save();
|
|
|
|
}elseif($_REQUEST['method'] == 'name'){
|
|
$result = $graydon->getCompanyMatchesByName($request);
|
|
|
|
//Enregistrement de l'action dans les logs
|
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|
$sessionID = $result->Service_Log->SessionID;
|
|
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchesByName', $transactionIdentifier, $sessionID);
|
|
|
|
//Log de la requete dans la bdd
|
|
setDbConn('graydon');
|
|
$log = new Requetelog();
|
|
$log->login = $_SESSION['tabInfo']['login'];
|
|
$log->action = 'getCompanyMatchesByName';
|
|
$log->request = serialize($request);
|
|
$log->transactionIdentifier = $transactionIdentifier;
|
|
$log->sessionID = $sessionID;
|
|
$log->mode = 'normal';
|
|
$log->save();
|
|
|
|
}elseif($_REQUEST['method'] == 'postcode'){
|
|
$result = $graydon->getCompanyMatchesByPostCode($request);
|
|
|
|
//Enregistrement de l'action dans les logs
|
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|
$sessionID = $result->Service_Log->SessionID;
|
|
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchesByPostCode', $transactionIdentifier, $sessionID);
|
|
|
|
//Log de la requete dans la bdd
|
|
setDbConn('graydon');
|
|
$log = new Requetelog();
|
|
$log->login = $_SESSION['tabInfo']['login'];
|
|
$log->action = 'getCompanyMatchesByPostCode';
|
|
$log->request = serialize($request);
|
|
$log->transactionIdentifier = $transactionIdentifier;
|
|
$log->sessionID = $sessionID;
|
|
$log->mode = 'normal';
|
|
$log->save();
|
|
|
|
}
|
|
|
|
$_SESSION['graydon']['SessionID'] = $result->Service_Log->SessionID;
|
|
$_SESSION['graydon']['TransactionIdentifier'] = $result->Service_Log->TransactionIdentifier;
|
|
|
|
return $result;
|
|
|
|
}catch( SoapFault $fault ){
|
|
if(isset($fault->faultstring) && $fault->faultcode = 'HTTP'){
|
|
print '<br/>Le service partenaire n\'est pas disponible.';
|
|
}else{
|
|
$code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode;
|
|
$text = $fault->detail->GraydonCompanyData_Fault->FaultMessage;
|
|
$firephp->log($text,'texterror');
|
|
require_once 'graydon/graydon_error.php';
|
|
$error = graydon_error($code, $text);
|
|
if($error==FALSE){
|
|
return graydon_processSoapFault($graydon,$fault,$_SESSION['tabInfo']);
|
|
}elseif($error['Code'] == 'CWS5000'){
|
|
return array();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function getCountryAvailability($pays)
|
|
{
|
|
global $page, $mode, $firephp, $graydon, $authentication;
|
|
|
|
setDbConn('graydon');
|
|
$q = Doctrine_Query::create()
|
|
->from('Countryavailability')
|
|
->where('country = ?', $pays);
|
|
|
|
$countryavailability = new Countryavailability();
|
|
$countryavailability = $q->fetchOne();
|
|
if($countryavailability == FALSE)
|
|
{
|
|
// Create the request parameters
|
|
$request = new StdClass();
|
|
// Initialise the request object
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->Country = $pays;
|
|
$firephp->log($request, 'request');
|
|
try
|
|
{
|
|
$result = $graydon->getCountryAvailability($request);
|
|
$firephp->log($result,'CountryAvailability');
|
|
//Enregistrement de l'action dans les logs
|
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|
$sessionID = $result->Service_Log->SessionID;
|
|
graydonRequeteLog( $_SESSION['tabInfo']['login'], $page, 'getCountryAvailability', $transactionIdentifier, $sessionID);
|
|
//Log de la requete dans la bdd
|
|
$log = new Requetelog();
|
|
$log->login = $_SESSION['tabInfo']['login'];
|
|
$log->action = 'getCountryAvailability';
|
|
$log->request = serialize($request);
|
|
$log->transactionIdentifier = $transactionIdentifier;
|
|
$log->sessionID = $sessionID;
|
|
$log->mode = $mode;
|
|
$log->save();
|
|
|
|
$availability = $result->CountryAvailablity->CountryAndProduct[0]->Products->Product;
|
|
|
|
//Stockage du résultat de la méthode en cache
|
|
$countryavailability = new Countryavailability();
|
|
$countryavailability->country = $pays;
|
|
$countryavailability->availability = serialize($availability);
|
|
$countryavailability->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){
|
|
$availability = graydon_processSoapFault($graydon,$fault,$_SESSION['tabInfo']);
|
|
}else{
|
|
$availability = FALSE;
|
|
}
|
|
}
|
|
}else{
|
|
$availability = unserialize($countryavailability->availability);
|
|
}
|
|
return $availability;
|
|
}
|
|
|
|
|
|
function getCompanyMatchMethods($pays)
|
|
{
|
|
global $page, $mode, $firephp, $graydon, $authentication;
|
|
|
|
setDbConn('graydon');
|
|
$q = Doctrine_Query::create()
|
|
->from('Matchmethods')
|
|
->where('country = ?', $pays);
|
|
|
|
$matchmethods = new Matchmethods();
|
|
$matchmethods = $q->fetchOne();
|
|
|
|
if($matchmethods == FALSE)
|
|
{
|
|
// Create the request parameters
|
|
$request = new StdClass();
|
|
// Initialise the request object
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->Country = $pays;
|
|
try
|
|
{
|
|
$result = $graydon->getCompanyMatchMethods($request);
|
|
//Enregistrement de l'action dans les logs
|
|
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
|
|
$sessionID = $result->Service_Log->SessionID;
|
|
graydonRequeteLog( $_SESSION['tabInfo']['login'], $page, 'getCompanyMatchMethods', $transactionIdentifier, $sessionID);
|
|
//Log de la requete dans la bdd
|
|
$log = new Requetelog();
|
|
$log->login = $_SESSION['tabInfo']['login'];
|
|
$log->action = 'getCompanyMatchMethods';
|
|
$log->request = serialize($request);
|
|
$log->transactionIdentifier = $transactionIdentifier;
|
|
$log->sessionID = $sessionID;
|
|
$log->mode = $mode;
|
|
$log->save();
|
|
|
|
$methods = $result->CompanyMatchMethods->CompanyMatchMethod[0]->MatchMethods->MatchMethod;
|
|
|
|
//Stockage du résultat de la méthode en cache
|
|
$matchmethods = new Matchmethods();
|
|
$matchmethods->country = $pays;
|
|
$matchmethods->methods = serialize($methods);
|
|
$matchmethods->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){
|
|
if($code=='CWS0112'){
|
|
//Stockage du résultat de la méthode en cache
|
|
$matchmethods = new Matchmethods();
|
|
$matchmethods->country = $pays;
|
|
$matchmethods->methods = serialize('nomethods');
|
|
$matchmethods->replace();
|
|
$methods = 'nomethods';
|
|
}
|
|
}else{
|
|
$methods = graydon_processSoapFault($graydon,$fault,$_SESSION['tabInfo']);
|
|
}
|
|
}
|
|
}else{
|
|
$methods = unserialize($matchmethods->methods);
|
|
}
|
|
return $methods;
|
|
}
|
|
|
|
|
|
function getIdentite($identifier, $CompanyProductIdentifier, $file, $format = 'xml')
|
|
{
|
|
global $page, $mode, $firephp, $graydon, $authentication, $pays;
|
|
|
|
$request = new StdClass();
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->OrderCreatorEmail = 'mricois@scores-decisions.com';
|
|
$request->CompanyProductIdentifier = $CompanyProductIdentifier;
|
|
$request->PartnerData = '';
|
|
$firephp->log($request, 'request');
|
|
try
|
|
{
|
|
$placeOrderResult = $graydon->placeOrder($request);
|
|
|
|
//Enregistrement de l'action dans les logs
|
|
$transactionIdentifier = $placeOrderResult->Service_Log->TransactionIdentifier;
|
|
$sessionID = $placeOrderResult->Service_Log->SessionID;
|
|
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'placeOrder', $transactionIdentifier, $sessionID);
|
|
|
|
//Log de la requete dans la bdd
|
|
$log = new Requetelog();
|
|
$log->login = $_SESSION['tabInfo']['login'];
|
|
$log->action = 'placeOrder';
|
|
$log->request = serialize($request);
|
|
$log->transactionIdentifier = $transactionIdentifier;
|
|
$log->sessionID = $sessionID;
|
|
$log->mode = $mode;
|
|
$log->save();
|
|
$firephp->log($pays,'pays');
|
|
|
|
//Optention du prix du service
|
|
$prix = Doctrine_Query::create()
|
|
->select('p.immediate')
|
|
->from('Price p')
|
|
->leftJoin('p.Country c')
|
|
->where('c.graydon_country = ?', $pays)
|
|
->fetchOne();
|
|
|
|
//Obtention du libelle pays Graydon
|
|
$country = Doctrine_Query::create()
|
|
->from('Country')
|
|
->where('graydon_country = ?', $pays)
|
|
->fetchOne();
|
|
|
|
//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 = $_SESSION['tabInfo']['login'];
|
|
$commandes->mode = $_SESSION['graydon']['mode'];
|
|
$commandes->Country = $country;
|
|
$commandes->save();
|
|
|
|
$mailcommandes = $commandes->toString();
|
|
$firephp->log($mailcommandes,'dataCommandes');
|
|
$commandes_id = $commandes->id;
|
|
|
|
//Pas d'enregistrement des détails de la commande car elle est immédiate
|
|
|
|
//Envoi d'un mail pour le passage de la commande
|
|
require_once 'mail/mail.php';
|
|
sendMail(
|
|
"[International] - (Date :".date("d")."/".date("m")."/".date("Y").") - Commandes",
|
|
"Commande effectué par ".$_SESSION['tabInfo']['login']."\n" .
|
|
$mailcommandes,
|
|
//From
|
|
array(
|
|
'email' => 'contact@scores-decisions.com',
|
|
'name' => 'Commandes International',
|
|
),
|
|
//TO
|
|
array(
|
|
0 => array(
|
|
'email'=> EMAIL_SUPPORTDEV,
|
|
'name' => 'Support'
|
|
)
|
|
)
|
|
);
|
|
|
|
}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){
|
|
return graydon_processSoapFault($graydon,$fault,$_SESSION['tabInfo']);
|
|
exit;
|
|
}else{
|
|
return false;
|
|
exit;
|
|
}
|
|
}
|
|
|
|
//On vérifie l'état de le demande
|
|
if (isset($placeOrderResult) && $placeOrderResult->OrderStatus->OrderState == 'Completed')
|
|
{
|
|
$request = new StdClass();
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->LanguageCode = 'E'; //Spécifier la langue du rapport
|
|
$request->OrderReference = $placeOrderResult->OrderStatus->OrderReference;
|
|
$request->MimeType = $format;
|
|
try
|
|
{
|
|
$reportResult = $graydon->getCompanyReport($request);
|
|
$firephp->log($reportResult, 'CompanyReport');
|
|
//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();
|
|
|
|
//Suivant le format, on recupere le bon objet
|
|
$firephp->log($reportResult,'reportResult');
|
|
if($format == 'xml') $content = $reportResult->ReportXML->any;
|
|
if($format == 'html') $content = $reportResult->ReportText;
|
|
|
|
//Enregistrement du contenu dans un fichier
|
|
file_put_contents($file, $content);
|
|
|
|
//Mise en cache dans la bdd
|
|
$report = new Report();
|
|
$report->identifier = $identifier;
|
|
$report->name = $_SESSION['graydon']['name'];
|
|
$report->content = $content;
|
|
$report->format = $format;
|
|
$report->order_id = $commandes_id;
|
|
$report->save();
|
|
|
|
return $content;
|
|
|
|
}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){
|
|
return graydon_processSoapFault($graydon,$fault,$_SESSION['tabInfo']);
|
|
exit;
|
|
}else{
|
|
return FALSE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function setEnquete($pays){
|
|
global $page, $mode, $firephp, $graydon, $authentication;
|
|
|
|
$serviceSpeed = strtolower($_REQUEST['InfoEnq']['Servicespeed']);
|
|
//Optention du prix du service
|
|
$prix = Doctrine_Query::create($conn)
|
|
->select('p.'.$serviceSpeed)
|
|
->from('Price p')
|
|
->leftJoin('p.Country c')
|
|
->where('c.graydon_country = ?', $pays)
|
|
->fetchOne();
|
|
|
|
//Sauvegarde des infos dans la base avant le passage de la commande
|
|
$commandes = new Commandes();
|
|
//$commandes->reference = '';
|
|
$commandes->servicespeed = $serviceSpeed;
|
|
$commandes->prix = $prix->$serviceSpeed;
|
|
//$commandes->orderstate = '';
|
|
//$commandes->dateordered =
|
|
//$commandes->datecompleted =
|
|
//$commandes->datedue =
|
|
//$commandes->companyproductidentifier = ;
|
|
//$commandes->sessionid = $sessionID;
|
|
//$commandes->transactionidentifier = $transactionIdentifier;
|
|
$commandes->user = $_SESSION['tabInfo']['login'];
|
|
$commandes->mode = $_SESSION['graydon']['mode'];
|
|
|
|
$commandes->Country = $pays;
|
|
|
|
$commandes->save();
|
|
$firephp->log($commandes->toArray(),'dataCommandes');
|
|
$commandes_id = $commandes->id;
|
|
|
|
//Enregistrement des détails de la commande
|
|
$commandesDetail = new CommandesDetail();
|
|
$commandesDetail->dIdentite = $_REQUEST['InfoUser']['Identite'];
|
|
$commandesDetail->dTelephone = $_REQUEST['InfoUser']['Tel'];
|
|
$commandesDetail->dEmail = $_REQUEST['InfoUser']['Email'];
|
|
$commandesDetail->dFax = $_REQUEST['InfoUser']['Fax'];
|
|
$commandesDetail->eLanguageCode = 'E';
|
|
$commandesDetail->eName = $_REQUEST['InfoEnq']['Name'];
|
|
$commandesDetail->eIdentifiers = serialize($_REQUEST['InfoEnq']['Identifiers']);
|
|
$commandesDetail->eAdresse = $_REQUEST['InfoEnq']['Adresse'];
|
|
$commandesDetail->eTelephone = $_REQUEST['InfoEnq']['Telephone'];
|
|
$commandesDetail->ePays = $_REQUEST['InfoEnq']['Pays'];
|
|
$commandesDetail->eCreditOpinionCurrency = 'EUR';
|
|
//$commandesDetail->eCreditOpinionPeriod = '';
|
|
$commandesDetail->eBankers = $_REQUEST['InfoEnq']['Bankers'];
|
|
$commandesDetail->eAttentionOf = $_REQUEST['InfoEnq']['AttentionOf'];
|
|
$commandesDetail->eSpecialRemarks = $_REQUEST['InfoEnq']['SpecialRemarks'];
|
|
$commandesDetail->commandes_id = $commandes_id;
|
|
$commandesDetail->save();
|
|
|
|
//Passage de la commande chez graydon
|
|
$request = new StdClass();
|
|
$request->Authentication_Parameters = $authentication;
|
|
if(!isset($_REQUEST['pidentifier'])){
|
|
$request->OrderCreatorEmail = EMAIL_SUPPORTDEV;
|
|
$request->Order->LanguageCode = 'F';
|
|
$request->Order->Name = $_REQUEST['InfoEnq']['Name'];
|
|
$request->Order->ServiceSpeed = $_REQUEST['InfoEnq']['Servicespeed'];
|
|
$request->Order->Country = $_REQUEST['InfoEnq']['Pays'];
|
|
$request->Order->Address->EntireAddress = $_REQUEST['InfoEnq']['Adresse'];
|
|
|
|
if (count($_REQUEST['InfoEnq']['Identifiers'])>1){
|
|
$count = 0;
|
|
foreach($_REQUEST['InfoEnq']['Identifiers'] as $key => $value){
|
|
$request->Order->CompanyIdentifier[$count]->Identifier = $value;
|
|
$request->Order->CompanyIdentifier[$count]->Type = $key;
|
|
$count++;
|
|
}
|
|
}else{
|
|
foreach($_REQUEST['InfoEnq']['Identifiers'] as $key => $value){
|
|
$request->Order->CompanyIdentifier->Identifier = $value;
|
|
$request->Order->CompanyIdentifier->Type = $key;
|
|
}
|
|
}
|
|
|
|
$request->Order->AttentionOf = $_REQUEST['InfoEnq']['AttentionOf'];
|
|
$request->Order->Bankers = $_REQUEST['InfoEnq']['Bankers'];
|
|
$request->Order->SpecialRemarks = $_REQUEST['InfoEnq']['SpecialRemarks'];
|
|
$request->Order->Telephone = $_REQUEST['InfoEnq']['Telephone'];
|
|
}else{
|
|
$request->Authentication_Parameters = $authentication;
|
|
$request->OrderCreatorEmail = 'mricois@scores-decisions.com';
|
|
$request->CompanyProductIdentifier = $_REQUEST['pidentifier'];
|
|
$request->PartnerData = '';
|
|
}
|
|
$requet->PartnerData = '';
|
|
try
|
|
{
|
|
$placeOrderResult = $graydon->placeOrder($request);
|
|
|
|
//Enregistrement de l'action dans les logs
|
|
$transactionIdentifier = $placeOrderResult->Service_Log->TransactionIdentifier;
|
|
$sessionID = $placeOrderResult->Service_Log->SessionID;
|
|
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'placeOrder', $transactionIdentifier, $sessionID);
|
|
|
|
//Log de la requete dans la bdd
|
|
$log = new Requetelog();
|
|
$log->login = $_SESSION['tabInfo']['login'];
|
|
$log->action = 'placeOrder';
|
|
$log->request = serialize($request);
|
|
$log->transactionIdentifier = $transactionIdentifier;
|
|
$log->sessionID = $sessionID;
|
|
$log->mode = $mode;
|
|
$log->save();
|
|
|
|
//Enregistrement des commandes dans la bdd
|
|
$commandes = new Commandes();
|
|
$commandes->assignIdentifier($commandes_id);
|
|
$commandes->reference = $placeOrderResult->OrderStatus->OrderReference;
|
|
$commandes->servicespeed = $placeOrderResult->OrderStatus->Order->ServiceSpeed;
|
|
$commandes->prix = $prix->$serviceSpeed;
|
|
$commandes->orderstate = $placeOrderResult->OrderStatus->OrderState;
|
|
$commandes->dateordered = $placeOrderResult->OrderStatus->DateOrdered;
|
|
$commandes->datecompleted = $placeOrderResult->OrderStatus->DateCompleted;
|
|
$commandes->datedue = $placeOrderResult->OrderStatus->DateDue;
|
|
$commandes->companyproductidentifier = '';
|
|
$commandes->sessionid = $sessionID;
|
|
$commandes->transactionidentifier = $transactionIdentifier;
|
|
$commandes->user = $_SESSION['tabInfo']['login'];
|
|
$commandes->mode = $_SESSION['graydon']['mode'];
|
|
$commandes->Country = $country;
|
|
$commandes->save();
|
|
$firephp->log($commandes->toArray(),'dataCommandes');
|
|
$commandes_id = $commandes->id;
|
|
|
|
//Enregistrement des détails de la commande
|
|
//Déjà fait avant le passage de la commande chez graydon
|
|
|
|
//Envoi d'un mail pour le passage de la commande
|
|
require_once 'mail/mail.php';
|
|
sendMail(
|
|
"[International] - (Date :".date("d")."/".date("m")."/".date("Y").") - Commandes",
|
|
"Commande effectué par ".$_SESSION['tabInfo']['login']."\n".
|
|
", ref : ".$commandes->reference,
|
|
//From
|
|
array(
|
|
'email' => 'contact@scores-decisions.com',
|
|
'name' => 'Commandes International',
|
|
),
|
|
//TO
|
|
array(
|
|
0 => array(
|
|
'email'=> EMAIL_SUPPORTDEV,
|
|
'name' => 'Support'
|
|
)
|
|
)
|
|
);
|
|
$commandeOk = TRUE;
|
|
|
|
}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,$_SESSION['tabInfo']);
|
|
}
|
|
//Envoi d'un mail pour le passage de la commande en erreur
|
|
require_once 'mail/mail.php';
|
|
sendMail(
|
|
"[International] - (Date :".
|
|
date("d")."/".date("m")."/".date("Y").") - Commandes",
|
|
"Commande effectué par ".$_SESSION['tabInfo']['login']."\n".
|
|
", identifiant : ".$commandes_id,
|
|
//From
|
|
array(
|
|
'email' => 'contact@scores-decisions.com',
|
|
'name' => 'Commandes International',
|
|
),
|
|
//TO
|
|
array(
|
|
0 => array(
|
|
'email'=> EMAIL_SUPPORTDEV,
|
|
'name' => 'Support'
|
|
)
|
|
)
|
|
);
|
|
|
|
$commandeOk = FALSE;
|
|
}
|
|
|
|
if($commandeOk === FALSE){ return $commandes_id; }
|
|
else{ return $commandeOK; }
|
|
}
|
|
?>
|