2010-04-27 08:09:23 +00:00
< ? php
if ( ! page_checkParams ()) die ( 'Paramètres incorrects !' );
2009-02-17 13:14:53 +00:00
define ( 'CREDITSAFE_WS_URL' , 'https://www.creditsafe.fr/getdata/service/CSFRServices.asmx' );
define ( 'CREDITSAFE_WS_URI' , 'https://www.creditsafe.fr/getdata/service/' );
define ( 'CREDITSAFE_WS_USER' , 'scores_decisions' );
define ( 'CREDITSAFE_WS_PASS' , 'yoann1306' );
define ( 'CREDITSAFE_WS_REF' , 'ref' );
function formatPct ( $pct ) {
$pct = round ( $pct / 10 , 0 ) * 10 ;
if ( $pct == 0 ) $pct = 10 ;
return $pct ;
}
2009-04-01 12:45:45 +00:00
$tabInfo = $_SESSION [ 'tabInfo' ];
2009-02-17 13:14:53 +00:00
if ( strlen ( $siret ) == 9 ) $siret = $tabInfo [ 'entrep' ][ 'siret' ];
$action = $_REQUEST [ 'action' ];
2010-02-10 17:27:03 +00:00
if ( $action <> '' && $action <> 'commande' ) die ( 'Paramètres incorrects !' );
2009-02-17 13:14:53 +00:00
2009-07-20 16:17:33 +00:00
require_once 'partenaires/classMTva.php' ;
require_once 'partenaires/classMMap.php' ;
require_once 'partenaires/classMCoface.php' ;
require_once 'common/dates.php' ;
2009-02-17 13:14:53 +00:00
2010-02-12 14:46:31 +00:00
$req = '<xmlrequest>' .
'<header>' .
'<username>' . CREDITSAFE_WS_USER . '</username>' .
'<password>' . CREDITSAFE_WS_PASS . '</password>' .
//'<operation>getcompanyinformation</operation>'.
'<operation>getratinglimit</operation>' .
'<country>FR</country>' .
'<language>FR</language>' .
'<chargereference>' . CREDITSAFE_WS_REF . '</chargereference>' .
'</header>' .
'<body>' .
//'<package>standard</package>'.
'<package>ratinglimit</package>' .
" <companynumber> $siret </companynumber> " .
'</body>' .
'</xmlrequest>' ;
2009-07-20 16:17:33 +00:00
2009-02-17 13:14:53 +00:00
$success = true ;
$date = date ( 'Ymd' );
2009-03-02 11:27:23 +00:00
$fichier = $siret . '-' . $date . '.xml' ;
2009-07-20 16:17:33 +00:00
2010-03-18 14:57:23 +00:00
if ( ! file_exists ( PATH_DATA . '/creditsafe/xml/' . $fichier ) )
2010-02-12 14:46:31 +00:00
{
$url = 'https://www.creditsafe.fr/getdata/service/CSFRServices.asmx/GetData?RequestXmlStr=' . $req ;
2009-02-17 13:14:53 +00:00
$referer = $cookie = '' ;
2009-02-27 18:29:19 +00:00
$page = getUrl ( $url , $cookie , '' , $referer , false , '' , '' );
2009-02-17 13:14:53 +00:00
$referer = $url ;
2010-02-12 14:46:31 +00:00
$xml = html_entity_decode ( $page [ 'body' ], ENT_QUOTES , 'UTF-8' );
/** Enregistrement du fichier XML en provenance des greffes **/
2009-03-02 11:27:23 +00:00
$fp =@ fopen ( PATH_DATA . '/creditsafe/xml/' . $fichier , 'w' );
2009-02-17 13:14:53 +00:00
@ fwrite ( $fp , $xml );
@ fclose ( $fp );
$O = $client -> setLog ( 'scorecsf' , $siret );
} else {
2010-02-12 14:46:31 +00:00
/** Lecture du fichier XML en provenance des greffes **/
$xml = file_get_contents ( PATH_DATA . '/creditsafe/xml/' . $fichier );
2009-02-17 13:14:53 +00:00
$O = $client -> setLog ( 'scorecsf' , $siret , 0 , 'local' );
}
2009-07-20 16:17:33 +00:00
2009-02-17 13:14:53 +00:00
$dom_object = new DomDocument2 ();
//TODO : Chemin !!
2009-03-02 11:27:23 +00:00
$dom_object -> load ( PATH_DATA . '/creditsafe/xml/' . $fichier );
2009-02-17 13:14:53 +00:00
$companyname = $dom_object -> getValueFromTag ( 'companyname' );
$rating = $dom_object -> getValueFromTag ( 'rating' );
$ratingdesc1 = str_replace ( '?' , " ' " , $dom_object -> getValueFromTag ( 'ratingdesc1' ));
$ratingdesc2 = str_replace ( '?' , " ' " , $dom_object -> getValueFromTag ( 'ratingdesc2' ));
$creditlimit = $dom_object -> getValueFromTag ( 'creditlimit' );
$libelle = '' ;
if ( strtoupper ( $creditlimit ) <> strtolower ( $creditlimit ) || $creditlimit == '' )
$strCreditlimit = $creditlimit ;
2009-07-20 16:17:33 +00:00
else
2009-02-17 13:14:53 +00:00
$strCreditlimit = number_format ( $creditlimit , null , null , ' ' ) . ' €' ;
2009-07-20 16:17:33 +00:00
2009-02-17 13:14:53 +00:00
if ( $rating >= 40 ) {
$fontColor = 'green' ;
2009-03-02 11:27:23 +00:00
$imgFeux = '<img src="./img/creditsafe/feux_vert.png"/>' ;
2010-02-10 17:27:03 +00:00
if ( $rating >= 71 ) $libelle = 'Très bonne cote de crédit/solvabilité' ;
elseif ( $rating >= 51 ) $libelle = 'Bonne cote de crédit/solvabilité' ;
2009-02-17 13:14:53 +00:00
else $libelle = 'Solvable' ;
2009-07-20 16:17:33 +00:00
2009-02-17 13:14:53 +00:00
} elseif ( $rating >= 20 ) {
$fontColor = 'yellow' ; //#f2be2c';
2009-03-02 11:27:23 +00:00
$imgFeux = '<img src="./img/creditsafe/feux_orange.png"/>' ;
2010-02-10 17:27:03 +00:00
$libelle = 'Précautions recommandées' ;
2009-02-17 13:14:53 +00:00
} elseif ( strtoupper ( $rating ) <> strtolower ( $rating )) {
$fontColor = 'black' ;
$imgFeux = ' ' ;
}
elseif ( $rating == '' ) {
$fontColor = 'black' ;
$imgFeux = ' ' ;
}
else {
$fontColor = 'red' ;
2009-03-02 11:27:23 +00:00
$imgFeux = '<img src="./img/creditsafe/feux_rouge.png"/>' ;
2010-02-10 17:27:03 +00:00
if ( $rating == 0 ) $libelle = 'Entreprise en situation de défaillance et ayant un très fort risque de radiation' ;
else $libelle = 'Avertissement - Crédit à votre discrétion' ;
2009-02-17 13:14:53 +00:00
}
2009-07-20 16:17:33 +00:00
2009-08-27 07:28:00 +00:00
?>
< div id = " center " >
< h1 class = " titre " >& Eacute ; VALUATION </ h1 >
< table >
< tr >
2009-02-17 13:14:53 +00:00
< td width = " 30 " >& nbsp ; </ td >
< td width = " 200 " class = " StyleInfoLib " > Num & eacute ; ro identifiant Siren </ td >
< td width = " 350 " class = " StyleInfoData " >< ? = substr ( $siret , 0 , 3 ) . ' ' . substr ( $siret , 3 , 3 ) . ' ' . substr ( $siret , 6 , 3 ) ?> </td>
2009-08-27 07:28:00 +00:00
</ tr >
< tr >
2009-02-17 13:14:53 +00:00
< td width = " 30 " >& nbsp ; </ td >
< td width = " 200 " class = " StyleInfoLib " > Raison Sociale </ td >
< td width = " 350 " class = " StyleInfoData " >< ? if ( $companyname <> '' ) echo $companyname ;
else echo $raisonSociale ;
?> </td>
2009-08-27 07:28:00 +00:00
</ tr >
2009-02-17 13:14:53 +00:00
< ? if ( $etab [ 'NumRC' ] * 1 <> 0 ) { ?>
2009-08-27 07:28:00 +00:00
< tr >
2009-02-17 13:14:53 +00:00
< td width = " 30 " >& nbsp ; </ td >
< td width = " 200 " class = " StyleInfoLib " > Num & eacute ; ro R . C .</ td >
< td width = " 350 " class = " StyleInfoData " >< ? = $etab [ 'NumRC' ] ?> </td>
2009-08-27 07:28:00 +00:00
</ tr >
2009-02-17 13:14:53 +00:00
< ? } ?>
2009-08-27 07:28:00 +00:00
< tr >
</ table >
2009-07-20 16:17:33 +00:00
2009-08-27 07:28:00 +00:00
< h2 > Scoring partenaire : Creditsafe & reg ; </ h2 >
< table >
< tr >< td colspan = " 3 " >
2009-02-17 13:14:53 +00:00
< table cellspacing = " 0 " >
< tr >
< td width = " 20 " >& nbsp ; </ td >
< td width = " 10 " bgcolor = " #bebebe " >& nbsp ; </ td >
< td width = " 200 " bgcolor = " #bebebe " >< font size = " 2 " >< b > Note & agrave ; ce jour [ 0 - 100 ] </ b ></ font ></ td >
< td width = " 250 " bgcolor = " #bebebe " >< font color = " <?= $fontColor ?> " size = " 2 " >< ? = $rating ; ?> </font></td>
< td width = " 100 " bgcolor = " #bebebe " >< ? = $imgFeux ?> </td>
</ tr >
< tr >
< td width = " 20 " >& nbsp ; </ td >
< td width = " 10 " bgcolor = " #e7e7e7 " >& nbsp ; </ td >
< td width = " 200 " bgcolor = " #e7e7e7 " >< font size = " 2 " >< b > Limite & agrave ; ce jour [ & euro ;] </ b ></ font ></ td >
< td width = " 350 " colspan = " 2 " bgcolor = " #e7e7e7 " >< font size = " 2 " >< ? = $strCreditlimit ?> </font></td>
</ tr >
< tr >
< td width = " 20 " >& nbsp ; </ td >
< td width = " 10 " bgcolor = " #bebebe " >& nbsp ; </ td >
< td width = " 200 " bgcolor = " #bebebe " >< font size = " 2 " >< b > Informations compl & eacute ; mentaires </ b ></ font ></ td >
< td width = " 350 " colspan = " 2 " bgcolor = " #bebebe " >< font color = " <?= $fontColor ?> " size = " 2 " >< ? = $libelle . '<br/>' . $ratingdesc1 ; if ( trim ( $ratingdesc2 ) <> '' ) echo '<br/>' . $ratingdesc2 ; ?> </font></td>
</ tr >
</ table >
</ td >
</ tr >
2009-08-27 07:28:00 +00:00
< ? php
if ( $action <> 'commande' ) {
?>
< tr >
2009-02-17 13:14:53 +00:00
< td width = " 30 " >& nbsp ; </ td >
2009-03-11 07:51:18 +00:00
< td width = " 550 " colspan = " 2 " class = " StyleInfoData " >< br />< br />< form action = " ./?page=scorescf&action=commande&siret=<?= $siret ?>&idEntreprise=<?= $idEntreprise ?> " method = " POST " >< input type = " checkbox " /> Mettre cette entreprise sous surveillance scoring partenaire < br />< br /> Adresse email du destinataire < input name = " email " type = " text " value = " <? if ( $_SESSION['tabInfo'] ['login']<>'testreunica' && $_SESSION['tabInfo'] ['login']<>'reunicacsf') echo $tabInfo['email'] ?> " size = " 20 " />& nbsp ; & nbsp ; & nbsp ; < input class = " imgButton " type = " image " src = " ./img/boutton_valider_off.gif " name = " submit " onmouseover = " this.src='./img/boutton_valider_on.gif' " onmouseout = " this.src='./img/boutton_valider_off.gif' " title = " Surveiller le score partenaire de cette entreprise... " ></ form ></ td >
2009-08-27 07:28:00 +00:00
</ tr >
2009-02-17 13:14:53 +00:00
< ?
} else {
if ( preg_match ( '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#' , $_REQUEST [ 'email' ])) {
$message = 'Entreprise mise sous surveillance scoring partenaire !' ;
2010-03-18 14:57:23 +00:00
2010-03-01 11:47:37 +00:00
require_once 'mail/mail.php' ;
2010-03-18 14:57:23 +00:00
sendMail (
" Demande de surveillance score CreditSafe pour $siren à " . $_REQUEST [ 'email' ],
2010-03-01 11:47:37 +00:00
'REQUEST=' . EOL . print_r ( $_REQUEST , true ) . 'EOL' .
'SERVER=' . EOL . print_r ( $_SERVER , true ) . 'EOL' .
'SESSION=' . EOL . print_r ( $_SESSION , true ) . 'EOL' .
'ENV=' . EOL . print_r ( $_ENV , true ) . 'EOL' .
2010-03-18 14:57:23 +00:00
'tabInfo=' . print_r ( $tabInfo , true ),
2010-03-01 11:47:37 +00:00
//From
2010-03-18 14:57:23 +00:00
array (
2010-03-01 11:47:37 +00:00
'email' => 'contact@scores-decisions.com' ,
'name' => 'Contact' ,
2010-03-18 14:57:23 +00:00
),
2010-03-01 11:47:37 +00:00
//TO
array (
0 => array (
'email' => 'contact@scores-decisions.com' ,
'name' => 'Contact' ,
)
)
);
2010-03-18 14:57:23 +00:00
2009-02-17 13:14:53 +00:00
$fp = fopen ( PATH_LOGS . 'surveillance_scf.csv' , 'a' );
fwrite ( $fp , date ( 'Y/m/d H:i:s' ) . " ; $siren ; " . $_REQUEST [ 'email' ] . ';' . $tabInfo [ 'login' ] . ';' . $tabInfo [ 'email' ] . ';' . $tabInfo [ 'ip' ] . " \n " );
fclose ( $fp );
} else {
$message = " ERREUR : Veuillez saisir une adresse email valide pour la mise sous surveillance " ;
}
?>
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td width = " 550 " colspan = " 2 " class = " StyleInfoData " >< br />< br />< h3 >< ? = $message ; ?> </h3></td>
</ tr >
< ? php
}
2009-07-20 16:17:33 +00:00
2009-02-17 13:14:53 +00:00
class DomDocument2 extends DOMDocument {
2009-07-20 16:17:33 +00:00
2009-02-17 13:14:53 +00:00
function getValueFromTag ( $tagName ) {
$items = $this -> getElementsByTagName ( $tagName );
foreach ( $items as $item ) {
2009-07-20 16:17:33 +00:00
2010-02-12 14:46:31 +00:00
return $item -> nodeValue ;
2009-02-17 13:14:53 +00:00
}
}
}
2009-08-27 07:28:00 +00:00
?>
</ table >
2010-04-12 14:49:55 +00:00
< p class = " confidentiel blockh2 " >
< ? php
require_once 'cgu/cgu.php' ;
echo afficheCgu ();
?>
</ p >
2009-08-27 07:28:00 +00:00
</ div >