From dfa2bbc33cd861a48de783f58316c21b15424af7 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 12 May 2009 16:57:43 +0000 Subject: [PATCH] Changement structure bdd --- .../graydon/generated/BaseCommandes.php | 4 + www/dashboard/index.php | 1 - www/dashboard/modules/graydon/graydon.php | 3 +- www/dashboard/modules/graydon/order.php | 15 +- www/pages/international_enquete.php | 26 +- www/pages/international_identite.php | 5 +- www/pages/international_identitec.php | 274 ++++++++++-------- www/pages/international_rechercheform.php | 10 +- 8 files changed, 200 insertions(+), 138 deletions(-) diff --git a/includes/models/graydon/generated/BaseCommandes.php b/includes/models/graydon/generated/BaseCommandes.php index 4131f4725..a28b04a9b 100644 --- a/includes/models/graydon/generated/BaseCommandes.php +++ b/includes/models/graydon/generated/BaseCommandes.php @@ -8,6 +8,7 @@ * @property integer $id * @property string $reference * @property enum $servicespeed + * @property string $prix * @property enum $orderstate * @property date $dateordered * @property date $datecompleted @@ -16,6 +17,7 @@ * @property string $sessionid * @property string $transactionidentifier * @property string $user + * @property string $mode * @property timestamp $created_at * @property timestamp $updated_at * @property integer $country_id @@ -33,6 +35,7 @@ abstract class BaseCommandes extends Doctrine_Record $this->hasColumn('id', 'integer', 4, array('type' => 'integer', 'length' => 4, 'primary' => true, 'autoincrement' => true)); $this->hasColumn('reference', 'string', 100, array('type' => 'string', 'length' => 100, 'notnull' => true)); $this->hasColumn('servicespeed', 'enum', 19, array('type' => 'enum', 'length' => 19, 'values' => array(0 => 'Normal', 1 => 'Express', 2 => 'Superflash', 3 => 'Immediate', 4 => 'ImmediateWithUpdate', 5 => 'Unknown', 6 => 'Delayed'), 'notnull' => true)); + $this->hasColumn('prix', 'string', 100, array('type' => 'string', 'length' => 100, 'notnull' => true)); $this->hasColumn('orderstate', 'enum', 11, array('type' => 'enum', 'length' => 11, 'values' => array(0 => 'Completed', 1 => 'Assigned', 2 => 'InError', 3 => 'Initialised', 4 => 'Delivered', 5 => 'Notified', 6 => 'ReCompleted'), 'notnull' => true)); $this->hasColumn('dateordered', 'date', null, array('type' => 'date', 'notnull' => true)); $this->hasColumn('datecompleted', 'date', null, array('type' => 'date', 'notnull' => true)); @@ -46,4 +49,5 @@ abstract class BaseCommandes extends Doctrine_Record $this->hasColumn('updated_at', 'timestamp', null, array('type' => 'timestamp', 'default' => '0000-00-00 00:00:00', 'notnull' => true)); $this->hasColumn('country_id', 'integer', 4, array('type' => 'integer', 'length' => 4, 'notnull' => true)); } + } \ No newline at end of file diff --git a/www/dashboard/index.php b/www/dashboard/index.php index 91822ad5e..d62d0d6a2 100644 --- a/www/dashboard/index.php +++ b/www/dashboard/index.php @@ -1,6 +1,5 @@ select('*') ->from('Country') ->where('status="actif"'); -$result = $q->execute(); -$tabPays = $result->toArray(); +$results = $q->execute(); +$tabPays = $results->toArray(); $q = Doctrine_Query::create() ->from('Commandes c') ->leftJoin('c.Country p, c.CommandesDetail cd') ->orderBy('c.dateordered'); - -$tabCommandes = $q->Execute(); + +$tabCommandes = $q->execute(); ?>
@@ -22,7 +21,7 @@ $tabCommandes = $q->Execute(); - + @@ -54,6 +53,7 @@ De Pays Reference Service commandé + Prix à la commande Status de la commande Date de la commande Date due @@ -63,9 +63,10 @@ De foreach($tabCommandes as $commande){ ?> - Country->country; ?> + Country->graydon_country; ?> reference; ?> servicespeed; ?> + prix; ?> orderstate; ?> dateordered; ?> datedue; ?> diff --git a/www/pages/international_enquete.php b/www/pages/international_enquete.php index e3e08675c..4474cefdd 100644 --- a/www/pages/international_enquete.php +++ b/www/pages/international_enquete.php @@ -12,6 +12,9 @@ if($_REQUEST['submit']){ print_r($_REQUEST['InfoUser']); print_r($_REQUEST['InfoEnq']); print ''; + + //Envoi d'un mail pour informé de la commande + }else{ @@ -81,7 +84,6 @@ div.submit p.required-note span{color:#4B911C;_color:#666;font-size:170%;vertica
- Authentication_Parameters = $authentication; + $request->Country = $pays; try { $result = $graydon->getCompanyMatchIdentifiers($request); @@ -127,29 +130,44 @@ if($nbResult == 0){ $matchidentifiers->country = $item->Country; $matchidentifiers->identifiers = serialize($tabIdentifiers); $matchidentifiers->replace(); + + $identifiers = $tabIdentifiers; } }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); + } } }else{ $identifiers = unserialize($matchidentifiers->identifiers); } //Affichage des identifiants //Ne pas afficher l'identifiant Internal - if(isset($identifiers)){ $firephp->log($identifiers,'identifiers'); $count = 0; foreach($identifiers as $identifier){ if($identifier->Type != 'Internal'){ - ?> +
+
+
+ +
Pas d'indentifiant.
+
+ diff --git a/www/pages/international_identite.php b/www/pages/international_identite.php index 8c5368cae..250137387 100644 --- a/www/pages/international_identite.php +++ b/www/pages/international_identite.php @@ -337,12 +337,11 @@ if(isset($company)){ if ($identifierDescription==FALSE){ print $identifier->Type; } - //@TODO : Tester si la condition à bien été remplie ?> - Identifier; ?> + Identifier; ?>   @@ -362,7 +361,7 @@ if(isset($company)){ Raison Sociale name; + $_SESSION['graydon']['name'] = $company->Name; print cleanutf8($company->Name); ?> diff --git a/www/pages/international_identitec.php b/www/pages/international_identitec.php index 5a56ef873..7c320b8dc 100644 --- a/www/pages/international_identitec.php +++ b/www/pages/international_identitec.php @@ -25,144 +25,93 @@ function dVal($value){ ?>
from('Commandes') - ->where('companyproductidentifier = ?', $CompanyProductIdentifier); - -$commandes = new Commandes(); -$commandes = $q->fetchOne(); -$nbReport = $q->count(); - -$report = new Report(); -$report = $commandes->Report; - $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 +$q = Doctrine_Query::create() + ->from('Report') + ->where('identifier = ?', $_REQUEST['identifier']); +$nbReports = $q->count(); +$report = new Report(); +$report = $q->fetchOne(); -if($nbReport==0){ - /* - placeOrder - CompanyProductIdentifier - Language - CreditOpinionCurrency - Country +//@TODO : si le rapport existe déjà ou que la date n'est pas très éloigné +if($nbReports==0){ - getCompanyReport - OrderReference - MimeType - */ - //placeOrder - $request = new StdClass(); - $request->Authentication_Parameters = $authentication; - $request->OrderCreatorEmail = 'mricois@scores-decisions.com'; - $request->CompanyProductIdentifier = $CompanyProductIdentifier; - $request->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->reference = $placeOrderResult->OrderStatus->OrderReference; - $commandes->orderstate = $placeOrderResult->OrderStatus->OrderState; - $commandes->dateordered = $placeOrderResult->OrderStatus->DateOrdered; - $commandes->datecompleted = $placeOrderResult->OrderStatus->DateCompleted; - $commandes->datedue = $placeOrderResult->OrderStatus->DateDue; - $commandes->servicespeed = $placeOrderResult->OrderStatus->Order->ServiceSpeed; - $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('country = ?', $pays) - ->fetchOne(); - - $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édiate - - //$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); - } - } - - //On vérifie l'état de le demande - if (isset($placeOrderResult) && $placeOrderResult->OrderStatus->OrderState == 'Completed'){ - //getCompanyReport + //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(); + $nbCommandes = $q->count(); + $report = new Report(); + $report = $commandes->Report; + if($nbCommandes == 0 && !isset($report->id)){ + + //placeOrder $request = new StdClass(); $request->Authentication_Parameters = $authentication; - $request->LanguageCode = 'E'; //Spécifier la langue du rapport - $request->OrderReference = $placeOrderResult->OrderStatus->OrderReference; - $request->MimeType = 'xml'; - - $firephp->log($request,'requete'); + $request->OrderCreatorEmail = 'mricois@scores-decisions.com'; + $request->CompanyProductIdentifier = $CompanyProductIdentifier; + $request->PartnerData = ''; try { - $reportResult = $graydon->getCompanyReport($request); + $placeOrderResult = $graydon->placeOrder($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); + $transactionIdentifier = $placeOrderResult->Service_Log->TransactionIdentifier; + $sessionID = $placeOrderResult->Service_Log->SessionID; + graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'placeOrder', $transactionIdentifier, $sessionID); - //Enregistrement dans la bdd + //Log de la requete dans la bdd $log = new Requetelog(); $log->login = $_SESSION['tabInfo']['login']; - $log->action = 'getCompanyReport'; + $log->action = 'placeOrder'; $log->request = serialize($request); $log->transactionIdentifier = $transactionIdentifier; $log->sessionID = $sessionID; $log->mode = $mode; $log->save(); - $firephp->log($reportResult,'reportResult'); - $xml = $reportResult->ReportXML->any; + //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(); - //Enregistrement du fichier xml - file_put_contents($path.'/'.$fileName, $xml); + //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']; - //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(); + $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; + + //Pas d'enregistrement des détails de la commande car elle est immédiate + + //$firephp->log($placeOrderResult,'placeOrder'); }catch( SoapFault $fault ){ $code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode; $text = $fault->detail->GraydonCompanyData_Fault->FaultMessage; @@ -172,10 +121,99 @@ if($nbReport==0){ graydon_processSoapFault($graydon,$fault,$tabInfo); } } - } -}else{ - if($nbReport>0){ + + //On vérifie l'état de le demande + if (isset($placeOrderResult) && $placeOrderResult->OrderStatus->OrderState == 'Completed'){ + //getCompanyReport + $request = new StdClass(); + $request->Authentication_Parameters = $authentication; + $request->LanguageCode = 'E'; //Spé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 à déjà été demandé + }else{ + //Assignation du contenu $xml = $report->content; + } +//Le rapport est disponible +}else{ + if($nbReports>0){ + /* + //Enregistrement du fausse 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']; + + $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; + }else{ $firephp->log('Data depuis fichier XML'); $xml = file_get_contents($path.'/'.$fileName); diff --git a/www/pages/international_rechercheform.php b/www/pages/international_rechercheform.php index 6b7e71688..0907e9411 100644 --- a/www/pages/international_rechercheform.php +++ b/www/pages/international_rechercheform.php @@ -16,9 +16,13 @@ if($mode=='normal'){