intégration envoi mail lors d'une erreur de paramètres ou de réponse avec infogreffe, issue #0000251

This commit is contained in:
Michael RICOIS 2010-04-16 06:56:21 +00:00
parent cfc8c42beb
commit 040aed2e3c
2 changed files with 70 additions and 47 deletions

View File

@ -644,6 +644,12 @@ function getGreffeActes($siren, $typeCommande = '', $ref = '', $idCommande = 0)
else else
{ {
//Paramètres incorrect //Paramètres incorrect
sendMail(
"Erreur : getGreffeActes",
"getGreffeActes($siren, $typeCommande , $ref, $idCommande )",
array('email' => EMAIL_SUPPORTDEV, 'name' => 'Support'),
array('email' => EMAIL_SUPPORTDEV, 'name' => 'Support')
);
} }
//Gestion du retour infogreffe //Gestion du retour infogreffe
if(infogreffe_erreur($xmlReponse)) if(infogreffe_erreur($xmlReponse))
@ -675,10 +681,20 @@ function infogreffe_filetimeover($fichier)
*/ */
function infogreffe_erreur($xml) function infogreffe_erreur($xml)
{ {
$doc = new DOMDocument(); if (!empty($xml)){
$load = $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING); $doc = new DOMDocument();
$output = false; $load = $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING);
if (!$load){ $output = true;} $output = false;
if (!$load){ $output = true;}
}else{
sendMail(
"Erreur : infogreffe_erreur",
"Pas de reponse xml infogreffe",
array('email' => EMAIL_SUPPORTDEV, 'name' => 'Support'),
array('email' => EMAIL_SUPPORTDEV, 'name' => 'Support')
);
$output = true;
}
return $output; return $output;
} }
@ -689,42 +705,46 @@ function infogreffe_erreur($xml)
*/ */
function infogreffe_erreur_msg($xml) function infogreffe_erreur_msg($xml)
{ {
global $tabErrInfoGref; $errNum = '';
$doc = new DOMDocument(); $errMsg = '';
$load = $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING); if (!empty($xml)){
FB::log($load, 'erreur_msg'); global $tabErrInfoGref;
if (!$load){ $doc = new DOMDocument();
FB::info('Test erreur infogreffe'); $load = $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING);
$tmp = explode('-', $xml); FB::log($load, 'erreur_msg');
$errNum = $tmp[0]*1; FB::log($errNum, 'errNum'); if (!$load) {
$errMsg = $tabErrInfoGref[$errNum]; FB::log($errMsg, 'errMsg'); FB::info('Test erreur infogreffe');
if ($errNum == '23'){ $tmp = explode('-', $xml);
$fj = $_SESSION['tabInfo']['entrep']['fj']; $errNum = $tmp[0]*1;
$nafEn = $_SESSION['tabInfo']['entrep']['nafEn']; $errMsg = $tabErrInfoGref[$errNum];
if ( (substr($fj,0,2)=='53' || if ($errNum == '23'){
substr($fj,0,2)=='54' || $fj = $_SESSION['tabInfo']['entrep']['fj'];
substr($fj,0,2)=='55' || $nafEn = $_SESSION['tabInfo']['entrep']['nafEn'];
substr($fj,0,2)=='56' || if ( (substr($fj,0,2)=='53' ||
substr($fj,0,2)=='57' ) && $fj!=5306 && $fj!=5307 && substr($fj,0,2)=='54' ||
( $nafEn!='6411Z' || substr($fj,0,2)=='55' ||
$nafEn!='6419Z' || substr($fj,0,2)=='56' ||
$nafEn!='6621Z' || substr($fj,0,2)=='57' ) && $fj!=5306 && $fj!=5307 &&
$nafEn!='6622Z' || ( $nafEn!='6411Z' ||
$nafEn!='6629Z' || $nafEn!='6419Z' ||
$nafEn!='6512Z' || $nafEn!='6621Z' ||
$nafEn!='6520Z' || $nafEn!='6622Z' ||
$nafEn!='6530Z' || $nafEn!='6629Z' ||
$nafEn!='6512Z' || $nafEn!='6512Z' ||
$nafEn!='8430A' || $nafEn!='6520Z' ||
$nafEn!='8430B' || $nafEn!='6530Z' ||
$nafEn!='6420Z' || $nafEn!='6512Z' ||
$nafEn!='6430Z' || $nafEn!='8430A' ||
$nafEn!='6611Z' || $nafEn!='8430B' ||
$nafEn!='8430B' || $nafEn!='6420Z' ||
$nafEn!='6612Z' || $nafEn!='6430Z' ||
$nafEn!='6630Z') ){ $nafEn!='6611Z' ||
$errMsg = 'Aucun bilan disponible.'; $nafEn!='8430B' ||
} $nafEn!='6612Z' ||
$nafEn!='6630Z') ){
$errMsg = 'Aucun bilan disponible.';
}
}
} }
} }
return array( 'errNum' => $errNum , 'errMsg' => $errMsg ); return array( 'errNum' => $errNum , 'errMsg' => $errMsg );
@ -816,6 +836,12 @@ function getGreffeBilans($siren, $typeCommande = '', $ref = '', $idCommande = 0)
else else
{ {
//Paramètres incorrect //Paramètres incorrect
sendMail(
"Erreur : getGreffeBilans",
"getGreffeBilans($siren, $typeCommande, $ref, $idCommande )",
array('email' => EMAIL_SUPPORTDEV, 'name' => 'Support'),
array('email' => EMAIL_SUPPORTDEV, 'name' => 'Support')
);
} }
//Gestion du retour infogreffe //Gestion du retour infogreffe
if(infogreffe_erreur($xmlReponse)) if(infogreffe_erreur($xmlReponse))

View File

@ -513,8 +513,8 @@ else
break; break;
} }
} }
if( isset($reponse) && !empty($reponse['error']) && $reponse['error']['errNum']!=17) if( isset($reponse) && !empty($reponse['error']) &&
{ $reponse['error']['errNum']!=17 ){
if(in_array($erreurStop, $reponse['error'])) if(in_array($erreurStop, $reponse['error']))
{ {
$message = $reponse['error']['errNum'].' - '. $message = $reponse['error']['errNum'].' - '.
@ -526,9 +526,7 @@ else
if(!INFOGREFFE_DEBUG) if(!INFOGREFFE_DEBUG)
$client->setLog('greffe_'.$vue, $siren, 0, $client->setLog('greffe_'.$vue, $siren, 0,
'Erreur '.$reponse['error']['errNum']); 'Erreur '.$reponse['error']['errNum']);
} } else {
else
{
//Mise à jour de la commande dans la bdd //Mise à jour de la commande dans la bdd
mysql_update('commandes', array('statutCommande'=>0), mysql_update('commandes', array('statutCommande'=>0),
'idCommande = '.$idCommande); 'idCommande = '.$idCommande);
@ -540,8 +538,7 @@ else
' sous la référence '.$type.$idCommande; ' sous la référence '.$type.$idCommande;
//Envoi mail de commande courrier //Envoi mail de commande courrier
if($type=='C') if($type=='C'){
{
sendCmdMail( sendCmdMail(
'[COMMANDE PIECES] - '.'COMMANDE DE '.strtoupper($vue), '[COMMANDE PIECES] - '.'COMMANDE DE '.strtoupper($vue),
'COMMANDE DE '.strtoupper($vue). 'COMMANDE DE '.strtoupper($vue).