From 273238d00b68e33f0b53901cd23a9fc1884ba79c Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 14 May 2009 16:44:01 +0000 Subject: [PATCH] =?UTF-8?q?Refactorisation=20pour=20meilleur=20int=C3=A9gr?= =?UTF-8?q?ation=20des=20pays?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/graydon/graydon_error.php | 5 +- www/pages/graydon/method_identifier.php | 7 +- www/pages/graydon/methodfield.php | 42 +-- www/pages/international_enquete.php | 10 +- www/pages/international_enquetet.php | 396 ++++++++++++++++++++++ www/pages/international_identite.php | 24 +- www/pages/international_identitec.php | 72 ++-- www/pages/international_recherche.php | 30 +- www/pages/international_rechercheform.php | 5 +- 9 files changed, 494 insertions(+), 97 deletions(-) create mode 100644 www/pages/international_enquetet.php diff --git a/includes/graydon/graydon_error.php b/includes/graydon/graydon_error.php index e440043e7..f139faff6 100644 --- a/includes/graydon/graydon_error.php +++ b/includes/graydon/graydon_error.php @@ -85,8 +85,9 @@ function graydon_logSoapFault($message){ function graydon_error($code, $text){ $tabError = array( - 0 => array( "Code" => "CWS0112", "Text" => "Country or Countries specified not valid"), - 1 => array( "Code" => "CWS0113", "Text" => "Country is not enabled for matchByIdentifier") + 0 => array( "Code" => "CWS0112", "Text" => "Country or Countries specified not valid" ), + 1 => array( "Code" => "CWS0113", "Text" => "Country is not enabled for matchByIdentifier" ), + 2 => array( "Code" => "CWS5000", "Text" => "No match results found for subject company" ), ); $returnError = FALSE; diff --git a/www/pages/graydon/method_identifier.php b/www/pages/graydon/method_identifier.php index 54785c905..38a019a6e 100644 --- a/www/pages/graydon/method_identifier.php +++ b/www/pages/graydon/method_identifier.php @@ -10,10 +10,9 @@ $q = Doctrine_Query::create() $matchidentifiers = new Matchidentifiers(); $matchidentifiers = $q->fetchOne(); -$nbResult = $q->count(); /** Recup des types d'identifiants pour le pays **/ -if($nbResult == 0){ +if($matchidentifiers == FALSE){ //Récupération des intitulés identifiant $request = new StdClass(); $request->Authentication_Parameters = $authentication; @@ -26,11 +25,11 @@ if($nbResult == 0){ $transactionIdentifier = $result->Service_Log->TransactionIdentifier; $sessionID = $result->Service_Log->SessionID; - graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID); + graydonRequeteLog( $tabInfo['login'], $page, 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID); //Log de la requete dans la bdd $log = new Requetelog(); - $log->login = $_SESSION['tabInfo']['login']; + $log->login = $tabInfo['login']; $log->action = 'getCompanyMatchIdentifiers'; $log->request = serialize($request); $log->transactionIdentifier = $transactionIdentifier; diff --git a/www/pages/graydon/methodfield.php b/www/pages/graydon/methodfield.php index 7c1b78dfd..3be5156bc 100644 --- a/www/pages/graydon/methodfield.php +++ b/www/pages/graydon/methodfield.php @@ -1,33 +1,39 @@ log($_SESSION, 'SESSION'); +if(!isset($_REQUEST['method'])){ + $paysCode = $_REQUEST['pays']; +}else{ + $paysCode = $_SESSION['graydon']['paysCode']; } - $tabInfo = $_SESSION['tabInfo']; $mode = $_SESSION['graydon']['mode']; +require_once 'dbbootstrap.php'; require_once 'graydon/graydonws.php'; require_once 'graydon/graydon_log.php'; -require_once 'dbbootstrap.php'; setDbConn('graydon'); $q = Doctrine_Query::Create() ->select('graydon_country') ->from('Country') ->where('code = ?', $paysCode); +$firephp->log($q->getSql(),'SQL'); $result = $q->fetchOne(); $pays = $result->graydon_country; +$firephp->log($pays, 'pays'); + +$_SESSION['graydon']['paysCode'] = $paysCode; +$_SESSION['graydon']['pays'] = $pays; //Disponibilité des pays $q = Doctrine_Query::create() ->from('Countryavailability') ->where('country = ?', $pays); - +$firephp->log($q->getSql(),'SQL'); $countryavailability = new Countryavailability(); $countryavailability = $q->fetchOne(); -$nbResult = $q->count(); - -if($nbResult == 0){ +if($countryavailability == FALSE){ // Create the request parameters $request = new StdClass(); // Initialise the request object @@ -40,11 +46,11 @@ if($nbResult == 0){ //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); + graydonRequeteLog( $tabInfo['login'], $page, 'getCountryAvailability', $transactionIdentifier, $sessionID); //Log de la requete dans la bdd $log = new Requetelog(); - $log->login = $_SESSION['tabInfo']['login']; + $log->login = $tabInfo['login']; $log->action = 'getCountryAvailability'; $log->request = serialize($request); $log->transactionIdentifier = $transactionIdentifier; @@ -80,7 +86,6 @@ if($nbResult == 0){ $availability = unserialize($countryavailability->availability); } - //Méthodes de recherche disponible pour les pays $q = Doctrine_Query::create() ->from('Matchmethods') @@ -88,9 +93,8 @@ $q = Doctrine_Query::create() $matchmethods = new Matchmethods(); $matchmethods = $q->fetchOne(); -$nbResult = $q->count(); -if($nbResult == 0){ +if($matchmethods == FALSE){ // Create the request parameters $request = new StdClass(); // Initialise the request object @@ -104,11 +108,11 @@ if($nbResult == 0){ //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); + graydonRequeteLog( $tabInfo['login'], $page, 'getCompanyMatchMethods', $transactionIdentifier, $sessionID); //Log de la requete dans la bdd $log = new Requetelog(); - $log->login = $_SESSION['tabInfo']['login']; + $log->login = $tabInfo['login']; $log->action = 'getCompanyMatchMethods'; $log->request = serialize($request); $log->transactionIdentifier = $transactionIdentifier; @@ -176,10 +180,10 @@ if (isset($methods) && $methods!='false'){ $countMethods++; //Affichage des propostions des méthodes de recherche - if($item->MatchingMethod=='Keyword'){ $lien .= 'Par mots clés'; } - if($item->MatchingMethod=='Identifier'){ $lien .= 'Par identifiant'; } - if($item->MatchingMethod=='Name'){ $lien .= 'Par nom'; } - if($item->MatchingMethod=='PostCode'){ $lien .= 'Par Post Code'; } + if($item->MatchingMethod=='Keyword'){ $lien .= 'Par mots clés'; } + if($item->MatchingMethod=='Identifier'){ $lien .= 'Par identifiant'; } + if($item->MatchingMethod=='Name'){ $lien .= 'Par nom'; } + if($item->MatchingMethod=='PostCode'){ $lien .= 'Par Post Code'; } if($countMethods>=count($methods)){ $separator=''; break; }else{ $separator=' - '; } diff --git a/www/pages/international_enquete.php b/www/pages/international_enquete.php index 4474cefdd..f8a1801e3 100644 --- a/www/pages/international_enquete.php +++ b/www/pages/international_enquete.php @@ -19,7 +19,6 @@ if($_REQUEST['submit']){ }else{ require_once 'dbbootstrap.php'; - require_once 'dbgraydon.php'; require_once 'graydon/graydonws.php'; require_once 'graydon/graydon_log.php'; @@ -86,16 +85,16 @@ div.submit p.required-note span{color:#4B911C;_color:#666;font-size:170%;vertica from('Matchidentifiers') ->where('country = ?', $pays); $matchidentifiers = new Matchidentifiers(); $matchidentifiers = $q->fetchOne(); -$nbResult = $q->count(); /** Recup des types d'identifiants pour le pays **/ -if($nbResult == 0){ +if($matchidentifiers != FALSE){ //matchidentifiers $request = new StdClass(); $request->Authentication_Parameters = $authentication; @@ -106,7 +105,7 @@ if($nbResult == 0){ //Enregistrement de l'action dans les logs $transactionIdentifier = $result->Service_Log->TransactionIdentifier; $sessionID = $result->Service_Log->SessionID; - graydonRequeteLog('batch', 'batch', 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID); + graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID); //Log de la requete dans la bdd $log = new Requetelog(); @@ -227,9 +226,6 @@ if(isset($identifiers)){

Enquête :

from('Price p') ->leftJoin('p.Country c') diff --git a/www/pages/international_enquetet.php b/www/pages/international_enquetet.php new file mode 100644 index 000000000..3858cacff --- /dev/null +++ b/www/pages/international_enquetet.php @@ -0,0 +1,396 @@ +getInfosLogin($tabInfo['login']); + $user = $O['result']; + $firephp->log($user,'user'); + } catch (SoapFault $fault) { + + } + +?> + + + +
+ +

ENQUÊTE TERRAIN

+ +
+ +

Entreprise concernée :

+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ / + +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ + +
+ +
+
+ +

Demandeur :

+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +

Enquête :

+ +
+ +
+select('id, intersud_country') + ->from('Country') + ->where('code = ?', $paysCode); +$result = $q->fetchOne(); + +$idPays = $result->id; + +$q = Doctrine_Query::Create() + ->from('Price') + ->where('country_id = ?', $idPays); +$price = $q->fetchOne(); + +$q = Doctrine_Query::Create() + ->from('Delais') + ->where('country_id = ?', $idPays); +$delais = $q->fetchOne(); + +if($result && $price && $delais){ +?> +Normal (normal; ?> €, Délais : normalDe==0){ print $delais->normalA.' jours'; }else{ print $delais->normalDe.' à '.$delais->normalA.' jours'; } ?>) +
+Rapide (rapide; ?> €, Délais : rapideDe==0){ print $delais->rapideA.' jours'; }else{ print $delais->rapideDe.' à '.$delais->rapideA.' jours'; } ?>) + +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ + +
+ +
+Mois +Années +
+
+ +
+ +
+Oui +Non +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
(Format : JJ/MM/AAAA)
+
+ +
+ +
+ +
+Oui +Non +
+
+ + +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
(Format : JJ/MM/AAAA)
+
+ +
+ +
+ +
+Oui +Non +
+
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +

+ +
+
+ + \ No newline at end of file diff --git a/www/pages/international_identite.php b/www/pages/international_identite.php index b5d52fa73..b69521266 100644 --- a/www/pages/international_identite.php +++ b/www/pages/international_identite.php @@ -32,10 +32,9 @@ $q = Doctrine_Query::create() $matchidentifiers = new Matchidentifiers(); $matchidentifiers = $q->fetchOne(); -$nbResult = $q->count(); /** Recup des types d'identifiants pour le pays **/ -if($nbResult == 0){ +if($matchidentifiers == FALSE){ //Récupération des intitulés identifiant $request = new StdClass(); $request->Authentication_Parameters = $authentication; @@ -96,9 +95,8 @@ $q = Doctrine_Query::create() $companyproducts = new Companyproducts(); $companyproducts = $q->fetchOne(); $firephp->log($companyproducts->updated_at,'date'); -$nbResult = $q->count(); $now = mktime(date('G'), date('i'), date('s'), date("m") , date("d"), date("Y")); -if($nbResult == 0){ +if($companyproducts == FALSE){ $request = new StdClass(); $request->Authentication_Parameters = $authentication; $request->CompanyMatchIdentifier = $identifier; @@ -178,7 +176,6 @@ if(isset($company)){ $tabProductIdentifier = array(); $countProducts = 0; foreach($products as $product){ - //Rapport en mode normal if ($product->ServiceSpeed == 'Normal' && $product->Type == 'Investigation' && $product->Level == 4 ){ $tabReport[$countProducts] = 'Normal'; @@ -187,8 +184,7 @@ if(isset($company)){ $tabProducts[$countProducts]['DaysTo'] = $product->DaysTo; $countProducts++; } - - //Rapport en mode normal + //Rapport en mode Superflash if ($product->ServiceSpeed == 'Superflash' && $product->Type == 'Investigation' && $product->Level == 4 ){ $tabReport[] = 'Superflash'; $tabProducts[$countProducts]['identifier'] = $product->CompanyProductIdentifier; @@ -290,6 +286,13 @@ if(isset($company)){ $tabPaysPrix = $q->fetchArray(); $firephp->log($tabPaysPrix, 'tableau'); + if(in_array('Normal',$tabReport)){ + $key = array_search('Normal', $tabReport); + $pidentifier = $tabProducts[$key]['identifier']; + $daysFrom = $tabProducts[$key]['DaysFrom']; + $daysTo = $tabProducts[$key]['DaysTo']; + print '

Commander le rapport en mode normal
(Délais : '.$daysFrom.' à '.$daysTo.' Jours, Tarif : '.$tabPaysPrix[0]['normal'].' €)'; + } //Affichage des différents rapports dans l'ordre if(in_array('Superflash',$tabReport)){ $key = array_search('Superflash', $tabReport); @@ -298,13 +301,6 @@ if(isset($company)){ $daysTo = $tabProducts[$key]['DaysTo']; print '

Commander le rapport en mode superflash
(Délais : '.$daysFrom.' à '.$daysTo.' Jours, Tarif : '.$tabPaysPrix[0]['superflash'].' €)'; } - if(in_array('Normal',$tabReport)){ - $key = array_search('Normal', $tabReport); - $pidentifier = $tabProducts[$key]['identifier']; - $daysFrom = $tabProducts[$key]['DaysFrom']; - $daysTo = $tabProducts[$key]['DaysTo']; - print '

Commander le rapport en mode normal
(Délais : '.$daysFrom.' à '.$daysTo.' Jours, Tarif : '.$tabPaysPrix[0]['normal'].' €)'; - } if(in_array('Immediate',$tabReport)){ $key = array_search('Immediate', $tabReport); $pidentifier = $tabProducts[$key]['identifier']; diff --git a/www/pages/international_identitec.php b/www/pages/international_identitec.php index c2a802d26..924bbc440 100644 --- a/www/pages/international_identitec.php +++ b/www/pages/international_identitec.php @@ -13,7 +13,6 @@ require_once 'i18n/cleanchar.php'; require_once 'graydon/graydonws.php'; require_once 'graydon/graydon_log.php'; require_once 'dbbootstrap.php'; -require_once 'dbgraydon.php'; function dVal($value){ if($value == '' || $value == NULL){ @@ -29,15 +28,15 @@ $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']); -$nbReports = $q->count(); $report = new Report(); $report = $q->fetchOne(); //@TODO : si le rapport existe déjà ou que la date n'est pas très éloigné -if($nbReports==0){ +if($report==FALSE){ //Vérifier si le rapport en ligne à déjà été demandé $q = Doctrine_Query::create() @@ -45,10 +44,9 @@ if($nbReports==0){ ->where('companyproductidentifier = ?', $CompanyProductIdentifier); $commandes = new Commandes(); $commandes = $q->fetchOne(); - $nbCommandes = $q->count(); $report = new Report(); $report = $commandes->Report; - if($nbCommandes == 0 && !isset($report->id)){ + if($commandes == FALSE && !isset($report->id)){ //placeOrder $request = new StdClass(); @@ -197,41 +195,35 @@ if($nbReports==0){ } //Le rapport est disponible }else{ - if($nbReports>0){ - /* - //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; - - }else{ - $firephp->log('Data depuis fichier XML'); - $xml = file_get_contents($path.'/'.$fileName); - } + /* + //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; } //========= Affichage des informations ========= diff --git a/www/pages/international_recherche.php b/www/pages/international_recherche.php index 57f6ceeb0..938afdac4 100644 --- a/www/pages/international_recherche.php +++ b/www/pages/international_recherche.php @@ -48,7 +48,7 @@ $(document).ready(function(){ if(isset($_REQUEST['method'])) { $method = $_REQUEST['method']; - $pays = $_REQUEST['pays']; + $pays = $_SESSION['graydon']['pays']; } require_once 'international_rechercheform.php'; ?> @@ -60,7 +60,10 @@ require_once 'international_rechercheform.php'; }elseif($vue=='list'){ //*********** Mode démonstration if($_REQUEST['mode']=='demo'){ + $pays = $_REQUEST['frmDemo']['Country']; + $_SESSION['graydon']['pays'] = $pays; $_SESSION['graydon']['mode'] = 'demo'; + ?>
Résultat de la recherche de démonstration : @@ -71,7 +74,7 @@ require_once 'international_rechercheform.php'; $request = new StdClass(); // Initialise the request object $request->Authentication_Parameters = $authentication; - $request->Country = $_REQUEST['frmDemo']['Country']; + $request->Country = $pays; try { // Make a request on the web service @@ -96,8 +99,6 @@ require_once 'international_rechercheform.php'; //Get the list of companies $demoCompaniesCountry = $result->DemoCompanies->CountryAndCompany; - $_SESSION['graydon']['pays'] = $result->Service_Log->Country; - ?>
Pays : Country; ?> @@ -141,16 +142,19 @@ require_once 'international_rechercheform.php'; } //*********** Mode normal }elseif($_REQUEST['mode']=='normal'){ - $_SESSION['graydon']['mode'] = 'normal'; - + $paysCode = $_REQUEST['frmDemo']['CountryCode']; //Lire le libélé du pays graydon en fonction du code setDbConn('graydon'); $q = Doctrine_Query::Create() ->select('graydon_country') ->from('Country') - ->where('code = ?', $_REQUEST['frmRecherche']['CountryCode']); + ->where('code = ?', $paysCode); $result = $q->fetchOne(); $pays = $result->graydon_country; + + $_SESSION['graydon']['pays'] = $pays; + $_SESSION['graydon']['paysCode'] = $paysCode; + $_SESSION['graydon']['mode'] = 'normal'; ?>
Résultat de la recherche : @@ -267,7 +271,6 @@ require_once 'international_rechercheform.php'; } - $_SESSION['graydon']['pays'] = $result->Service_Log->Country; $_SESSION['graydon']['SessionID'] = $result->Service_Log->SessionID; $_SESSION['graydon']['TransactionIdentifier'] = $result->Service_Log->TransactionIdentifier; @@ -308,8 +311,17 @@ require_once 'international_rechercheform.php'; $text = $fault->detail->GraydonCompanyData_Fault->FaultMessage; $firephp->log($text,'texterror'); require_once 'graydon/graydon_error.php'; - if(graydon_error($code, $text)==FALSE){ + $error = graydon_error($code, $text); + if($error==FALSE){ graydon_processSoapFault($graydon,$fault,$tabInfo); + }elseif($error['Code'] == 'CWS5000'){ + + ?> +
+

Aucun résultat n'a été trouvé. Cliquez-ici pour retourner au formulaire de recherche.

0 && in_array($kPays['codPays'], $tabPaysIntersud)){ $intersud = TRUE; } if($graydon || $intersud){ - if( isset($pays) && $pays==$kPays ){ $selected = ' selected'; } + if( isset($paysCode) && $paysCode==$kPays['codPays'] ){ $selected = ' selected'; } print '\n'; } }