extranet/includes/graydon/graydon_wsfunctions.php

747 lines
27 KiB
PHP
Raw Normal View History

2009-06-08 09:14:28 +00:00
<?php
/**
* Retourne les identifiants disponible.
* @param string $pays
2009-06-18 09:48:03 +00:00
* Le pays Graydon
* @return string
* .
2009-06-18 09:48:03 +00:00
*/
2009-10-28 14:18:22 +00:00
function getCompanyMatchIdentifiers($pays)
{
global $page, $mode, $firephp, $graydon, $authentication;
2009-06-08 09:14:28 +00:00
$firephp->info('M<>thode getCompanyMatchIdentifiers');
2009-06-08 09:14:28 +00:00
setDbConn('graydon');
$q = Doctrine_Query::create()
->from('Matchidentifiers')
->where('country = ?', $pays);
2009-06-18 09:48:03 +00:00
$matchidentifiers = new Matchidentifiers();
$matchidentifiers = $q->fetchOne();
2009-06-18 09:48:03 +00:00
/** Recup des types d'identifiants pour le pays **/
2009-10-28 14:18:22 +00:00
if($matchidentifiers == FALSE)
{
2009-06-18 09:48:03 +00:00
//R<>cup<75>ration des intitul<75>s identifiant
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->Country = $pays;
$firephp->log($request,'REQUETE CompanyMatchIdentifier');
try
2009-06-18 09:48:03 +00:00
{
$result = $graydon->getCompanyMatchIdentifiers($request);
2009-10-28 14:18:22 +00:00
$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;
2009-06-18 09:48:03 +00:00
$log->mode = $mode;
$log->save();
2009-10-28 14:18:22 +00:00
$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();
2009-06-18 09:48:03 +00:00
}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{
2009-06-18 09:48:03 +00:00
$tabIdentifiers = graydon_processSoapFault($graydon,$fault,$_SESSION['tabInfo']);
}
2009-06-18 09:48:03 +00:00
}
}else{
$firephp->info('tabIdentifiers pris dans la bdd');
$tabIdentifiers = unserialize($matchidentifiers->identifiers);
}
return $tabIdentifiers;
}
2009-06-08 09:14:28 +00:00
2009-10-28 14:18:22 +00:00
function getCompanyProducts($identifier)
{
2009-06-18 09:58:41 +00:00
global $page, $mode, $firephp, $graydon, $authentication;
2009-06-18 09:48:03 +00:00
setDbConn('graydon');
$q = Doctrine_Query::create()
->from('Companyproducts')
->where('identifiers = ?', $identifier);
2009-06-18 09:48:03 +00:00
$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();
2009-06-18 09:58:41 +00:00
$request->Authentication_Parameters = $authentication;
$request->CompanyMatchIdentifier = $identifier;
2009-06-18 09:48:03 +00:00
try {
// Make a request on the web service
$result = $graydon->getCompanyProducts($request);
2009-06-18 09:48:03 +00:00
//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);
2009-06-18 09:48:03 +00:00
//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;
2009-06-18 09:48:03 +00:00
$log->mode = $mode;
$log->save();
2009-06-18 09:48:03 +00:00
//Sauvegarde dans la bdd
$companyproducts = new Companyproducts();
$companyproducts->identifiers = $identifier;
$companyproducts->company = serialize($result->Company);
$companyproducts->products = serialize($result->Products);
2009-10-09 13:25:07 +00:00
$companyproducts->save();
2009-06-18 09:48:03 +00:00
//Extraction
2009-06-18 09:48:03 +00:00
$company = $result->Company;
$products = $result->Products->Product;
2009-06-18 09:48:03 +00:00
}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){
2009-06-08 15:36:41 +00:00
graydon_processSoapFault($graydon,$fault,$_SESSION['tabInfo']);
}
2009-06-18 09:48:03 +00:00
}
}else{
2009-06-18 09:48:03 +00:00
$company = unserialize($companyproducts->company);
$products = unserialize($companyproducts->products);
2009-06-18 09:48:03 +00:00
$products = $products->Product;
}
return array('Company' => $company, 'Products' => $products);
}
2009-06-08 09:14:28 +00:00
2009-10-28 14:18:22 +00:00
function getCompanyMatches($pays)
{
global $page, $mode, $firephp, $graydon, $authentication;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
// Create the request parameters
$request = new StdClass();
// Initialise the request object
$request->Authentication_Parameters = $authentication;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
// Create a new country parameters object
$company = new StdClass();
// Initialise the country object
$company->Country = $pays;
$company->ClientReference = '';
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$request->CompanyMatches_Parameters = $company;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
if($_REQUEST['method'] == 'keyword'){
$request->Keyword = $_REQUEST['frmRecherche']['Keywords'];
$request->City = isset($_REQUEST['frmRecherche']['City']) ? $_REQUEST['frmRecherche']['City'] : '' ;
2009-06-18 09:48:03 +00:00
$request->PostCode = isset($_REQUEST['frmRecherche']['PostCode']) ? $_REQUEST['frmRecherche']['PostCode'] : '' ;
}elseif($_REQUEST['method'] == 'identifier'){
2009-06-08 15:36:41 +00:00
$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
2009-06-18 09:48:03 +00:00
{
// Make a request on the webservice
2009-06-08 15:36:41 +00:00
if($_REQUEST['method'] == 'keyword'){
$result = $graydon->getCompanyMatchesByKeyword($request);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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;
2009-06-18 09:48:03 +00:00
$log->mode = 'normal';
2009-06-08 15:36:41 +00:00
$log->save();
2009-06-18 09:48:03 +00:00
}elseif($_REQUEST['method'] == 'identifier'){
2009-06-08 15:36:41 +00:00
$result = $graydon->getCompanyMatchesByIdentifier($request);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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;
2009-06-18 09:48:03 +00:00
$log->mode = 'normal';
2009-06-08 15:36:41 +00:00
$log->save();
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
}elseif($_REQUEST['method'] == 'name'){
$result = $graydon->getCompanyMatchesByName($request);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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;
2009-06-18 09:48:03 +00:00
$log->mode = 'normal';
2009-06-08 15:36:41 +00:00
$log->save();
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
}elseif($_REQUEST['method'] == 'postcode'){
$result = $graydon->getCompanyMatchesByPostCode($request);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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;
2009-06-18 09:48:03 +00:00
$log->mode = 'normal';
2009-06-08 15:36:41 +00:00
$log->save();
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
}
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$_SESSION['graydon']['SessionID'] = $result->Service_Log->SessionID;
$_SESSION['graydon']['TransactionIdentifier'] = $result->Service_Log->TransactionIdentifier;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
return $result;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
}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']);
2009-06-18 09:48:03 +00:00
}elseif($error['Code'] == 'CWS5000'){
2009-06-08 15:36:41 +00:00
return array();
}
}
2009-06-18 09:48:03 +00:00
}
2009-06-08 15:36:41 +00:00
}
2009-10-28 14:18:22 +00:00
function getCountryAvailability($pays)
{
global $page, $mode, $firephp, $graydon, $authentication;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
setDbConn('graydon');
$q = Doctrine_Query::create()
->from('Countryavailability')
->where('country = ?', $pays);
$countryavailability = new Countryavailability();
$countryavailability = $q->fetchOne();
2009-10-28 14:18:22 +00:00
if($countryavailability == FALSE)
{
2009-06-08 15:36:41 +00:00
// Create the request parameters
$request = new StdClass();
// Initialise the request object
2009-06-18 09:48:03 +00:00
$request->Authentication_Parameters = $authentication;
2009-06-08 15:36:41 +00:00
$request->Country = $pays;
2009-10-28 14:18:22 +00:00
$firephp->log($request, 'request');
2009-06-08 15:36:41 +00:00
try
2009-06-18 09:48:03 +00:00
{
2009-06-08 15:36:41 +00:00
$result = $graydon->getCountryAvailability($request);
2009-10-28 14:18:22 +00:00
$firephp->log($result,'CountryAvailability');
2009-06-08 15:36:41 +00:00
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
2009-06-18 09:48:03 +00:00
graydonRequeteLog( $_SESSION['tabInfo']['login'], $page, 'getCountryAvailability', $transactionIdentifier, $sessionID);
2009-06-08 15:36:41 +00:00
//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;
2009-06-18 09:48:03 +00:00
$log->mode = $mode;
2009-06-08 15:36:41 +00:00
$log->save();
2009-06-18 09:48:03 +00:00
2009-10-28 14:18:22 +00:00
$availability = $result->CountryAvailablity->CountryAndProduct[0]->Products->Product;
2009-06-08 15:36:41 +00:00
//Stockage du r<>sultat de la m<>thode en cache
$countryavailability = new Countryavailability();
$countryavailability->country = $pays;
$countryavailability->availability = serialize($availability);
2009-06-18 09:48:03 +00:00
$countryavailability->replace();
2009-06-08 15:36:41 +00:00
}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']);
2009-06-08 15:36:41 +00:00
}else{
$availability = FALSE;
2009-06-08 15:36:41 +00:00
}
}
}else{
$availability = unserialize($countryavailability->availability);
}
return $availability;
2009-06-08 15:36:41 +00:00
}
2009-10-28 14:18:22 +00:00
function getCompanyMatchMethods($pays)
{
global $page, $mode, $firephp, $graydon, $authentication;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
setDbConn('graydon');
$q = Doctrine_Query::create()
->from('Matchmethods')
->where('country = ?', $pays);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$matchmethods = new Matchmethods();
$matchmethods = $q->fetchOne();
2009-06-18 09:48:03 +00:00
2009-10-28 14:18:22 +00:00
if($matchmethods == FALSE)
{
2009-06-08 15:36:41 +00:00
// Create the request parameters
$request = new StdClass();
// Initialise the request object
$request->Authentication_Parameters = $authentication;
$request->Country = $pays;
try
2009-06-18 09:48:03 +00:00
{
2009-06-08 15:36:41 +00:00
$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;
2009-06-18 09:48:03 +00:00
$log->mode = $mode;
2009-06-08 15:36:41 +00:00
$log->save();
2009-10-28 14:18:22 +00:00
$methods = $result->CompanyMatchMethods->CompanyMatchMethod[0]->MatchMethods->MatchMethod;
2009-06-08 15:36:41 +00:00
//Stockage du r<>sultat de la m<>thode en cache
$matchmethods = new Matchmethods();
$matchmethods->country = $pays;
$matchmethods->methods = serialize($methods);
$matchmethods->replace();
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
}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');
2009-06-08 15:36:41 +00:00
$matchmethods->replace();
$methods = 'nomethods';
2009-06-08 15:36:41 +00:00
}
}else{
$methods = graydon_processSoapFault($graydon,$fault,$_SESSION['tabInfo']);
2009-06-08 15:36:41 +00:00
}
}
2009-06-08 15:36:41 +00:00
}else{
$methods = unserialize($matchmethods->methods);
}
return $methods;
2009-06-08 15:36:41 +00:00
}
2009-10-28 14:18:22 +00:00
function getIdentite($identifier, $CompanyProductIdentifier, $file, $format = 'xml')
{
global $page, $mode, $firephp, $graydon, $authentication, $pays;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->OrderCreatorEmail = 'mricois@scores-decisions.com';
$request->CompanyProductIdentifier = $CompanyProductIdentifier;
$request->PartnerData = '';
$firephp->log($request, 'request');
2009-06-08 15:36:41 +00:00
try
2009-06-18 09:48:03 +00:00
{
2009-06-08 15:36:41 +00:00
$placeOrderResult = $graydon->placeOrder($request);
2009-10-28 14:18:22 +00:00
2009-06-08 15:36:41 +00:00
//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);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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;
2009-06-18 09:48:03 +00:00
$log->mode = $mode;
2009-06-08 15:36:41 +00:00
$log->save();
$firephp->log($pays,'pays');
2009-10-28 14:18:22 +00:00
2009-06-08 15:36:41 +00:00
//Optention du prix du service
$prix = Doctrine_Query::create()
2009-06-08 15:36:41 +00:00
->select('p.immediate')
->from('Price p')
->leftJoin('p.Country c')
->where('c.graydon_country = ?', $pays)
->fetchOne();
2009-10-28 14:18:22 +00:00
//Obtention du libelle pays Graydon
$country = Doctrine_Query::create()
->from('Country')
->where('graydon_country = ?', $pays)
->fetchOne();
2009-06-08 15:36:41 +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 = $_SESSION['tabInfo']['login'];
$commandes->mode = $_SESSION['graydon']['mode'];
$commandes->Country = $country;
$commandes->save();
2009-10-28 14:18:22 +00:00
$mailcommandes = $commandes->toString();
$firephp->log($mailcommandes,'dataCommandes');
2009-06-08 15:36:41 +00:00
$commandes_id = $commandes->id;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//Pas d'enregistrement des d<>tails de la commande car elle est imm<6D>diate
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//Envoi d'un mail pour le passage de la commande
require_once 'phpmailer/class.phpmailer.php';
2009-06-18 09:48:03 +00:00
$mail = new PHPMailer();
2009-06-08 15:36:41 +00:00
$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 ".$_SESSION['tabInfo']['login']."\n";
2009-10-28 14:18:22 +00:00
$body .= $mailcommandes;
2009-06-08 15:36:41 +00:00
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
$mail->Send();
}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;
}
}
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//On v<>rifie l'<27>tat de le demande
2009-10-28 14:18:22 +00:00
if (isset($placeOrderResult) && $placeOrderResult->OrderStatus->OrderState == 'Completed')
{
2009-06-08 15:36:41 +00:00
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->LanguageCode = 'E'; //Sp<53>cifier la langue du rapport
$request->OrderReference = $placeOrderResult->OrderStatus->OrderReference;
2009-10-28 14:18:22 +00:00
$request->MimeType = $format;
2009-06-08 15:36:41 +00:00
try
2009-06-18 09:48:03 +00:00
{
2009-06-08 15:36:41 +00:00
$reportResult = $graydon->getCompanyReport($request);
2009-10-28 14:18:22 +00:00
$firephp->log($reportResult, 'CompanyReport');
2009-06-08 15:36:41 +00:00
//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);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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;
2009-06-18 09:48:03 +00:00
$log->mode = $mode;
2009-06-08 15:36:41 +00:00
$log->save();
2009-10-28 14:18:22 +00:00
//Suivant le format, on recupere le bon objet
2009-06-08 15:36:41 +00:00
$firephp->log($reportResult,'reportResult');
2009-10-28 14:18:22 +00:00
if($format == 'xml') $content = $reportResult->ReportXML->any;
if($format == 'html') $content = $reportResult->ReportText;
//Enregistrement du contenu dans un fichier
file_put_contents($file, $content);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//Mise en cache dans la bdd
$report = new Report();
$report->identifier = $identifier;
$report->name = $_SESSION['graydon']['name'];
2009-10-28 14:18:22 +00:00
$report->content = $content;
$report->format = $format;
2009-06-08 15:36:41 +00:00
$report->order_id = $commandes_id;
$report->save();
2009-06-18 09:48:03 +00:00
2009-10-28 14:18:22 +00:00
return $content;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
}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;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$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 = '';
2009-06-18 09:48:03 +00:00
//$commandes->dateordered =
//$commandes->datecompleted =
//$commandes->datedue =
2009-06-08 15:36:41 +00:00
//$commandes->companyproductidentifier = ;
//$commandes->sessionid = $sessionID;
//$commandes->transactionidentifier = $transactionIdentifier;
$commandes->user = $_SESSION['tabInfo']['login'];
$commandes->mode = $_SESSION['graydon']['mode'];
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$commandes->Country = $pays;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$commandes->save();
$firephp->log($commandes->toArray(),'dataCommandes');
$commandes_id = $commandes->id;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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();
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//Passage de la commande chez graydon
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
if(!isset($_REQUEST['pidentifier'])){
2009-10-09 13:25:07 +00:00
$request->OrderCreatorEmail = EMAIL_SUPPORTDEV;
2009-06-08 15:36:41 +00:00
$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'];
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
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;
}
}
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$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'];
2009-06-18 09:48:03 +00:00
$request->PartnerData = '';
2009-06-08 15:36:41 +00:00
}
$requet->PartnerData = '';
try
2009-06-18 09:48:03 +00:00
{
2009-06-08 15:36:41 +00:00
$placeOrderResult = $graydon->placeOrder($request);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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);
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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;
2009-06-18 09:48:03 +00:00
$log->mode = $mode;
2009-06-08 15:36:41 +00:00
$log->save();
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//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'];
2009-06-08 15:46:57 +00:00
$commandes->Country = $country;
2009-06-08 15:36:41 +00:00
$commandes->save();
$firephp->log($commandes->toArray(),'dataCommandes');
$commandes_id = $commandes->id;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//Enregistrement des d<>tails de la commande
//D<>j<EFBFBD> fait avant le passage de la commande chez graydon
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
//Envoi d'un mail pour le passage de la commande
require_once 'phpmailer/class.phpmailer.php';
2009-06-18 09:48:03 +00:00
$mail = new PHPMailer();
2009-06-08 15:36:41 +00:00
$mail->From = "contact@scores-decisions.com";
$mail->FromName = "Commandes International";
$mail->Host = "mail.scores-decisions.com";
$mail->Mailer = "smtp";
$mail->Subject = "[International] - Commande - (Date :".date("d")."/".date("m")."/".date("Y").")";
$body = "Commande effectu<74> par ".$_SESSION['tabInfo']['login'].", ref : ".$commandes->reference;
2009-06-18 09:48:03 +00:00
$body .= " ";
2009-06-08 15:36:41 +00:00
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
$mail->Send();
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$commandeOk = TRUE;
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
}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 'phpmailer/class.phpmailer.php';
2009-06-18 09:48:03 +00:00
$mail = new PHPMailer();
2009-06-08 15:36:41 +00:00
$mail->From = "contact@scores-decisions.com";
$mail->FromName = "Commandes International";
$mail->Host = "mail.scores-decisions.com";
$mail->Mailer = "smtp";
$mail->Subject = "[International] - Commande Erreur - (Date :".date("d")."/".date("m")."/".date("Y").")";
$body = "Commande effectu<74> par ".$_SESSION['tabInfo']['login'].", identifiant : ".$commandes_id;
2009-06-18 09:48:03 +00:00
$body .= " ";
2009-06-08 15:36:41 +00:00
$mail->MsgHTML($body);
$mail->AddAddress(EMAIL_SUPPORTDEV, "Support");
$mail->Send();
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
$commandeOk = FALSE;
}
2009-06-18 09:48:03 +00:00
2009-06-08 15:36:41 +00:00
if($commandeOk === FALSE){ return $commandes_id; }
else{ return $commandeOK; }
}
2009-06-08 09:14:28 +00:00
?>