Merge branch 'develop' into 'master'

Develop into master : logger + avis situations staging spécifique + SD 30

See merge request !3
This commit is contained in:
potier 2017-04-13 12:43:25 +00:00
commit 5eb4e10abe
7 changed files with 106 additions and 99 deletions

View File

@ -123,9 +123,9 @@ 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);
$log->pushHandler(new StreamHandler($logFile, $level));
// Processor
$log->pushProcessor(new IntrospectionProcessor());

View File

@ -124,10 +124,9 @@ class IdentiteController extends Zend_Controller_Action
);
$datemajTexte = $dateDerMaj = '';
$datemajTexte.= '<table>';
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');
@ -365,10 +364,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 +390,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 +698,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 +724,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 +747,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 +1232,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();
}
}
/**

View File

@ -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);

View File

@ -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 <?=$surveillance['source']?>">
<img src="/themes/default/images/interfaces/supprimer.png"/>
</a>

View File

@ -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);
}

View File

@ -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,17 +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
if ($response == '') {
$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
@ -196,13 +201,13 @@ 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(__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);
}
}

View File

@ -1,6 +1,10 @@
<?php
return array(
'0.6' => array(
'getIdentiteLight' => array(
'debug' => true,
'log' => 'mail',
),
'getRncsEven' => array(
'debug' => true,
'log' => 'mail',