From b63addf2a47d5bcec77be8537ae7b0eb46ebf5bb Mon Sep 17 00:00:00 2001 From: Claire DELBOS Date: Fri, 7 Apr 2017 11:20:55 +0200 Subject: [PATCH 1/7] SD-30+SD-33 --- .../modules/default/controllers/SurveillanceController.php | 7 +++++-- .../default/views/default/scripts/surveillance/liste.phtml | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/application/modules/default/controllers/SurveillanceController.php b/application/modules/default/controllers/SurveillanceController.php index 1eeb847a0..20963e00d 100644 --- a/application/modules/default/controllers/SurveillanceController.php +++ b/application/modules/default/controllers/SurveillanceController.php @@ -118,6 +118,7 @@ class SurveillanceController extends Zend_Controller_Action $page = $request->getParam('page'); $from = $request->getParam('from'); + $q = $request->getParam('q'); $siret = $request->getParam('siret', ''); $email = $request->getParam('email', ''); @@ -136,6 +137,8 @@ class SurveillanceController extends Zend_Controller_Action } } elseif (isset($page)) { $this->redirect('surveillance/liste/page/'.$page); + } elseif (isset($q)) { + $this->redirect('surveillance/liste/q/'.$q); } else { $this->redirect('surveillance/liste'); } @@ -424,8 +427,8 @@ class SurveillanceController extends Zend_Controller_Action $pageTotal = $pageCurrent = 1; } $this->view->assign('PageTotal', $pageTotal); - $this->view->assign('PagePrev', $pagePrev); - $this->view->assign('PageNext', $pageNext); + $this->view->assign('PagePrev', isset($pagePrev)?$pagePrev:1); + $this->view->assign('PageNext', isset($pageNext)?$pageNext:1); $this->view->assign('PageCurrent', $pageCurrent); $this->view->assign('nbReponses', empty($nbReponses) ? 0 : $nbReponses); diff --git a/application/modules/default/views/default/scripts/surveillance/liste.phtml b/application/modules/default/views/default/scripts/surveillance/liste.phtml index 65a9a8c76..dca262ac1 100644 --- a/application/modules/default/views/default/scripts/surveillance/liste.phtml +++ b/application/modules/default/views/default/scripts/surveillance/liste.phtml @@ -152,7 +152,8 @@ par 'siret' => $item['siren'].$item['nic'], 'ref' => urlencode($surveillance['ref']), 'email' => $surveillance['email'], - 'source' => $surveillance['source'] + 'source' => $surveillance['source'], + 'q' => $this->q, ))?>" title="Supprimer la surveillance "> From c709e9c65937ebcfe546489487675c425573d348 Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Wed, 12 Apr 2017 11:32:28 +0200 Subject: [PATCH 2/7] =?UTF-8?q?suppression=20specificit=C3=A9=20staging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/IdentiteController.php | 154 +++++++++--------- 1 file changed, 74 insertions(+), 80 deletions(-) diff --git a/application/modules/default/controllers/IdentiteController.php b/application/modules/default/controllers/IdentiteController.php index 34d453765..275f51afc 100644 --- a/application/modules/default/controllers/IdentiteController.php +++ b/application/modules/default/controllers/IdentiteController.php @@ -365,10 +365,10 @@ class IdentiteController extends Zend_Controller_Action $user = new Scores_Utilisateur(); //Pagination - $request = $this->getRequest(); - $page = $request->getParam('page', 1); - if ( $page <= 0 ) $page = 1; - $nbAffichage = 50; + $request = $this->getRequest(); + $page = $request->getParam('page', 1); + if ( $page <= 0 ) $page = 1; + $nbAffichage = 50; $position = ($page - 1 ) * $nbAffichage; $ws = new WsScores(); @@ -391,26 +391,26 @@ class IdentiteController extends Zend_Controller_Action } } - //Calcul pagination - $nbReponses = count($infos->result->item); - $nbReponsesTotal = $infos->nbReponses; - if ($nbReponses < $nbReponsesTotal) { - $pageTotal = ceil( $nbReponsesTotal / $nbAffichage ); - $pageCurrent = $page; - $pagePrev = $page - 1; - if ($pagePrev < 1) { - $pagePrev = 1; - } - $pageNext = $page + 1; - if( $pageNext > $pageTotal ) { - $pageNext = $pageTotal; - } - } else { - $pageTotal = $pageCurrent = 1; - } - $this->view->assign('PageTotal', $pageTotal); - $this->view->assign('PagePrev', $pagePrev); - $this->view->assign('PageNext', $pageNext); + //Calcul pagination + $nbReponses = count($infos->result->item); + $nbReponsesTotal = $infos->nbReponses; + if ($nbReponses < $nbReponsesTotal) { + $pageTotal = ceil( $nbReponsesTotal / $nbAffichage ); + $pageCurrent = $page; + $pagePrev = $page - 1; + if ($pagePrev < 1) { + $pagePrev = 1; + } + $pageNext = $page + 1; + if( $pageNext > $pageTotal ) { + $pageNext = $pageTotal; + } + } else { + $pageTotal = $pageCurrent = 1; + } + $this->view->assign('PageTotal', $pageTotal); + $this->view->assign('PagePrev', $pagePrev); + $this->view->assign('PageNext', $pageNext); $this->view->assign('PageCurrent', $pageCurrent); $this->view->assign('nbEtabActif', $nbEtabActif); @@ -699,7 +699,7 @@ class IdentiteController extends Zend_Controller_Action $session = new Scores_Session_Entreprise($siren, null, true); $this->view->assign('siren', $siren); $this->view->assign('siret', $session->getSiret()); - $this->view->assign('isin', $session->getIsin()); + $this->view->assign('isin', $session->getIsin()); $this->view->assign('surveillance', $user->checkPerm('survdirigeants')); } @@ -725,7 +725,7 @@ class IdentiteController extends Zend_Controller_Action $this->view->assign('isin', $session->getIsin()); $this->view->assign('siren', $siren); $this->view->assign('siret', $this->siret); - $this->view->assign('raisonSociale', $session->getRaisonSociale()); + $this->view->assign('raisonSociale', $session->getRaisonSociale()); $this->view->assign('surveillance', $user->checkPerm('liens')); //Check access to display group link @@ -748,18 +748,18 @@ class IdentiteController extends Zend_Controller_Action $this->view->assign('PP', true); //@todo : using this function is strange - How to get the id before ? - $result = $ws->searchLienRef($siren, 'siren'); - if (count($result->item)>0) { - foreach ($result->item as $item) { - $id = $item->id; - break; - } + $result = $ws->searchLienRef($siren, 'siren'); + if (count($result->item)>0) { + foreach ($result->item as $item) { + $id = $item->id; + break; + } } $result = $ws->getLienRef($id); - $this->view->assign('nom', $result->nom); - $this->view->assign('prenom', $result->prenom); - $this->view->assign('civilite', $result->civilite); + $this->view->assign('nom', $result->nom); + $this->view->assign('prenom', $result->prenom); + $this->view->assign('civilite', $result->civilite); $this->view->assign('naissanceDate', $result->naissance_Date); } @@ -1233,55 +1233,49 @@ class IdentiteController extends Zend_Controller_Action $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); - // --- En environement de preprod, on envoi sur le site - if (APPLICATION_ENV == 'staging') { - $this->redirect('http://avis-situation-sirene.insee.fr/'); - } // --- Téléchargement du fichier et distribution - else { - $avis = new Scores_Insee_AvisSituation($this->siret); - if ( !$avis->erreur() ) { - $avis->erreurcpt('raz'); - $file = $avis->get(); - if ($file === false) { - $avis->erreurcpt('plus'); - echo $avis->erreurmsg(); - } else { - // --- Envoi du fichier sur la sortie standard - $content_type = 'application/pdf'; - if ( file_exists($file) ) { - $ws = new WsScores(); - $ws->setLog('avis_situation', $this->siret, 0, ''); - $modules = array(); //apache_get_modules(); - if (in_array('mod_xsendfile', $modules)) { - header ('X-Sendfile: ' . $file); - header ('Content-Type: ' . $content_type); - header ('Content-Disposition: attachment; filename="' . $content_type . '"'); - exit; - } else { - ini_set('zlib.output_compression', '0'); - header('Content-Transfer-Encoding: none'); - header('Content-Type: ' . $content_type.''); - header('Content-Length: ' . filesize($file)); - header('Content-MD5: ' . base64_encode(md5_file($file))); - header('Content-Disposition: attachment; filename="' . basename($file) . '"'); - header('Cache-Control: private, max-age=0, must-revalidate'); - header('Pragma: public'); - readfile($file); - exit; - } + $avis = new Scores_Insee_AvisSituation($this->siret); + if ( !$avis->erreur() ) { + $avis->erreurcpt('raz'); + $file = $avis->get(); + if ($file === false) { + $avis->erreurcpt('plus'); + echo $avis->erreurmsg(); + } else { + // --- Envoi du fichier sur la sortie standard + $content_type = 'application/pdf'; + if ( file_exists($file) ) { + $ws = new WsScores(); + $ws->setLog('avis_situation', $this->siret, 0, ''); + $modules = array(); //apache_get_modules(); + if (in_array('mod_xsendfile', $modules)) { + header ('X-Sendfile: ' . $file); + header ('Content-Type: ' . $content_type); + header ('Content-Disposition: attachment; filename="' . $content_type . '"'); + exit; } else { - echo "Impossible de charger le fichier"; + ini_set('zlib.output_compression', '0'); + header('Content-Transfer-Encoding: none'); + header('Content-Type: ' . $content_type.''); + header('Content-Length: ' . filesize($file)); + header('Content-MD5: ' . base64_encode(md5_file($file))); + header('Content-Disposition: attachment; filename="' . basename($file) . '"'); + header('Cache-Control: private, max-age=0, must-revalidate'); + header('Pragma: public'); + readfile($file); + exit; } + } else { + echo "Impossible de charger le fichier"; } - } else { - if ($avis->nberreur()==5){ - $avis->mailerreur(); - } - $avis->erreurcpt('plus'); - echo $avis->erreurmsg(); - } - } + } + } else { + if ($avis->nberreur()==5){ + $avis->mailerreur(); + } + $avis->erreurcpt('plus'); + echo $avis->erreurmsg(); + } } /** From 1f90b825f45331d81205b95f2e7da84e01b3fa96 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 13 Apr 2017 10:41:18 +0200 Subject: [PATCH 3/7] Logger : Stop only at notice --- application/Bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 73bf37164..fd05a6f33 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -123,7 +123,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap if (APPLICATION_ENV == 'development') { $level = Logger::DEBUG; } else { - $level = Logger::INFO; + $level = Logger::NOTICE; } $log->pushHandler(new StreamHandler($logFile), $level); From d047c57d67e35f2968a4b9f3e8683e2436711f1e Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 13 Apr 2017 11:21:10 +0200 Subject: [PATCH 4/7] Session avec Scores_Ws_Client --- .../modules/default/controllers/IdentiteController.php | 7 +++---- library/Scores/Session/Entreprise.php | 9 +++++---- library/Scores/Ws/Client.php | 2 +- library/Scores/Ws/Client/Interne.php | 4 ++++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/application/modules/default/controllers/IdentiteController.php b/application/modules/default/controllers/IdentiteController.php index 275f51afc..b6ff19095 100644 --- a/application/modules/default/controllers/IdentiteController.php +++ b/application/modules/default/controllers/IdentiteController.php @@ -124,10 +124,9 @@ class IdentiteController extends Zend_Controller_Action ); $datemajTexte = $dateDerMaj = ''; $datemajTexte.= ''; - foreach ( $tabDate as $dateId => $dateLib ) { - if ( isset($infos->{$dateId}) - && !empty($infos->{$dateId}) - && $infos->{$dateId}!='0000-00-00') { + foreach ($tabDate as $dateId => $dateLib ) { + if (isset($infos->{$dateId}) && !empty($infos->{$dateId}) + && $infos->{$dateId}!='0000-00-00') { if ( $dateId == 'DateMajID') { $date = new Zend_Date($infos->DateMajID, 'yyyy-MM-dd'); diff --git a/library/Scores/Session/Entreprise.php b/library/Scores/Session/Entreprise.php index 19c5840ab..ceb912e7a 100644 --- a/library/Scores/Session/Entreprise.php +++ b/library/Scores/Session/Entreprise.php @@ -123,10 +123,11 @@ class Scores_Session_Entreprise protected function getInfoEntrep($siret, $id = 0) { - $this->logger->info('getInfoEntrep'); - require_once 'Scores/WsScores.php'; - $ws = new WsScores(); - $etab = $ws->getIdentiteLight($siret, $id); + $ws = new Scores_Ws_Client('interne', '0.6'); + $params = new stdClass(); + $params->siret = $this->siret; + $params->id = $this->id; + $etab= $ws->getIdentiteLight($params); $this->setSession($etab); } diff --git a/library/Scores/Ws/Client.php b/library/Scores/Ws/Client.php index 9af554e27..3018b1931 100644 --- a/library/Scores/Ws/Client.php +++ b/library/Scores/Ws/Client.php @@ -196,7 +196,7 @@ class Scores_Ws_Client extends Zend_Soap_Client // --- Debug if ( array_key_exists('debug', $methodConfig) ) { - $this->logger->info($fault->faultcode.' - '.$fault->faultstring); + $this->logger->error($fault->faultcode.' - '.$fault->faultstring); } // --- Gestion des SOAP fault diff --git a/library/Scores/Ws/Client/Interne.php b/library/Scores/Ws/Client/Interne.php index 7c7de6b5b..9b9f45171 100644 --- a/library/Scores/Ws/Client/Interne.php +++ b/library/Scores/Ws/Client/Interne.php @@ -1,6 +1,10 @@ array( + 'getIdentiteLight' => array( + 'debug' => true, + 'log' => 'mail', + ), 'getRncsEven' => array( 'debug' => true, 'log' => 'mail', From cf5d50ea2e3a3a11242041a72bb0c6afcfbbc432 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 13 Apr 2017 11:42:07 +0200 Subject: [PATCH 5/7] =?UTF-8?q?R=C3=A9organisation=20du=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/Scores/Ws/Client.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Scores/Ws/Client.php b/library/Scores/Ws/Client.php index 3018b1931..20c747b15 100644 --- a/library/Scores/Ws/Client.php +++ b/library/Scores/Ws/Client.php @@ -180,6 +180,11 @@ class Scores_Ws_Client extends Zend_Soap_Client $response = parent::__call($name, $arguments); + // Response vide + if ($response == '') { + $this->logger->error("$name : ".print_r($arguments, 1)); + } + // --- Debug if ( array_key_exists('debug', $methodConfig) ) { $this->logger->info(print_r($response,1)); From ef3842021fe642aeb83943e973a4660fd2e4050c Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 13 Apr 2017 12:11:34 +0200 Subject: [PATCH 6/7] Debug Level --- application/Bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Bootstrap.php b/application/Bootstrap.php index fd05a6f33..d0c3c686a 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -125,7 +125,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap } else { $level = Logger::NOTICE; } - $log->pushHandler(new StreamHandler($logFile), $level); + $log->pushHandler(new StreamHandler($logFile, $level)); // Processor $log->pushProcessor(new IntrospectionProcessor()); From 00b22c28e509f72c1d936a1e5ffd3e40dd56d07b Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 13 Apr 2017 14:23:16 +0200 Subject: [PATCH 7/7] Better debug --- library/Scores/Ws/Client.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/Scores/Ws/Client.php b/library/Scores/Ws/Client.php index 20c747b15..633dac05b 100644 --- a/library/Scores/Ws/Client.php +++ b/library/Scores/Ws/Client.php @@ -147,7 +147,7 @@ class Scores_Ws_Client extends Zend_Soap_Client } $methodConfig = $this->config[$name]; - $this->logger->info(print_r($methodConfig,1)); + // --- Cache $cacheEnable = false; if ( array_key_exists('cache', $methodConfig) ) { @@ -172,22 +172,22 @@ class Scores_Ws_Client extends Zend_Soap_Client // --- Debug if ( array_key_exists('debug', $methodConfig) ) { - $this->logger->info(__CLASS__.'->'.$name); - $this->logger->info(print_r($arguments,1)); + $this->logger->info(__CLASS__.'->'.$name.':'.print_r($arguments,1)); } try { $response = parent::__call($name, $arguments); - // Response vide + // --- Response vide if ($response == '') { - $this->logger->error("$name : ".print_r($arguments, 1)); + $this->logger->error(__CLASS__.'->'.$name.':'.print_r($arguments, 1)); + return false; } // --- Debug if ( array_key_exists('debug', $methodConfig) ) { - $this->logger->info(print_r($response,1)); + $this->logger->info(__CLASS__.'->'.$name.':'.print_r($response,1)); } // --- Cache @@ -201,13 +201,13 @@ class Scores_Ws_Client extends Zend_Soap_Client // --- Debug if ( array_key_exists('debug', $methodConfig) ) { - $this->logger->error($fault->faultcode.' - '.$fault->faultstring); + $this->logger->error(__CLASS__.'->'.$name.':'.$fault->faultcode.' - '.$fault->faultstring); } // --- Gestion des SOAP fault if ( array_key_exists('errorMsg', $methodConfig) ) { if ( in_array($fault->faultcode, $methodConfig['errorMsg']) ) { - $this->logger->info("Exception as error message : ".$fault->faultcode); + $this->logger->info(__CLASS__.'->'.$name.':'." Exception as error message : ".$fault->faultcode); throw new Exception($fault->faultstring); } }