2010-11-04 12:05:01 +01: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' );
if ( ! $_SESSION [ 'connected' ]) die ();
function formatPct ( $pct ) {
$pct = round ( $pct / 10 , 0 ) * 10 ;
if ( $pct == 0 ) $pct = 10 ;
return $pct ;
}
$siret = trim ( preg_replace ( '/[^0-9]/' , '' , $_REQUEST [ 'siret' ]));
2010-11-29 15:17:26 +01:00
if ( strlen ( $siret ) <> 9 && strlen ( $siret ) <> 14 ) die ( 'Param<61> tres incorrects !' );
2010-11-04 12:05:01 +01:00
if ( strlen ( $siret ) == 9 ) $siret = $tabInfo [ 'entrep' ][ 'siret' ];
2010-11-29 15:17:26 +01:00
$id = trim ( preg_replace ( '/[^0-9]/' , '' , $_REQUEST [ 'id' ])) * 1 ; // Si id=0 alors non communiqu<71>
if (( $siret * 1 ) == 0 && $id == 0 ) die ( 'Param<61> tres incorrects !' );
2010-11-04 12:05:01 +01:00
$siren = substr ( $siret , 0 , 9 );
$action = $_REQUEST [ 'action' ];
2010-11-29 15:17:26 +01:00
if ( $action <> '' && $action <> 'commande' ) die ( 'Param<61> tres incorrects !' );
2010-11-04 12:05:01 +01:00
$raisonSociale = $tabInfo [ 'entrep' ][ 'raisonSociale' ];
include_once ( INCLUDE_PATH . 'partenaires/classMTva.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMMap.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMCoface.php' );
include_once ( FWK_PATH . 'common/dates.php' );
/** Utilisation du WS **/
$client = new SoapClient ( null , array ( 'trace' => 1 ,
'soap_version' => SOAP_1_1 ,
'location' => WEBSERVICE_URL ,
'uri' => WEBSERVICE_URI ,
'login' => $_SESSION [ 'tabInfo' ][ 'login' ],
'password' => $_SESSION [ 'tabInfo' ][ 'password' ]));
/* $client = new SoapClient ( 'https://www.creditsafe.fr/getdata/service/CSFRServices.asmx?WSDL' ,
array ( 'location' => CREDITSAFE_WS_URL ,
'uri' => CREDITSAFE_WS_URI ,
'soap_version' => SOAP_1_1 ,
'trace' => 1 ,
//'style' => SOAP_RPC,
//'use' => SOAP_ENCODED,
));
*/
$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>' ;
$success = true ;
$date = date ( 'Ymd' );
$fichier = " $siret - $date .xml " ;
if ( ! file_exists ( '/var/www/site_extranet/www/creditsafe/xml/' . $fichier )) {
/* try {
$O = $client -> GetData ( '<RequestXmlString><xmlrequest>' .
'<header>' .
'<username>' . CREDITSAFE_WS_USER . '</username>' .
'<password>' . CREDITSAFE_WS_PASS . '</password>' .
'<operation>getcompanyinformation</operation>' .
'<country>FR</country>' .
'<language>FR</language>' .
'<chargereference>' . CREDITSAFE_WS_REF . '</chargereference>' .
'</header>' .
'<body>' .
'<package>standard</package>' .
" <companynumber> $siret </companynumber> " .
'</body>' .
'</xmlrequest></RequestXmlString>' );
//die(print_r($O));
$xml = implode ( '' , ( array ) $O );
}
catch ( SoapFault $soapFault ) { // echo "ERROR :\n", var_dump($soapFault), "\n"; echo "Request :\n", $client->__getLastRequest(), "\n";
$success = false ;
$response = $client -> __getLastResponse ();
$response = str_replace ( " <SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><SOAP-ENV:Body><ns0:getProduitsWebServicesXMLResponse xmlns:ns0='urn:local' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><return xsi:type='xsd:string'> " , '' , $response );
$xml = str_replace ( '</return></ns0:getProduitsWebServicesXMLResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>' , '' , $response );
} */
//https://www.creditsafe.fr/getdata/service/CSFRServices.asmx/GetData
//$url='https://www.creditsafe.fr/getdata/service/CSFRServices.asmx/GetData?RequestXmlString='.$req;
$url = 'https://www.creditsafe.fr/getdata/service/CSFRServices.asmx/GetData?RequestXmlStr=' . $req ; //.'&RequestXmlString='.$req;
//requestXmlStr.
$referer = $cookie = '' ;
$page = getUrl ( $url , $cookie , '' , $referer , false , '' , '' );
$referer = $url ;
$xml = html_entity_decode ( $page [ 'body' ], ENT_QUOTES , 'UTF-8' );
/** Enregistrement du fichier XML en provenance des greffes
**/
$fp =@ fopen ( '/var/www/site_extranet/www/creditsafe/xml/' . $fichier , 'w' );
@ fwrite ( $fp , $xml );
@ fclose ( $fp );
$O = $client -> setLog ( 'scorecsf' , $siret );
} else {
/** Lecture du fichier XML en provenance des greffes
**/
$xml = file_get_contents ( '/var/www/site_extranet/www/creditsafe/xml/' . $fichier );
$O = $client -> setLog ( 'scorecsf' , $siret , 0 , 'local' );
}
/*<> 100 </ rating >
2000000 </ creditlimit >*/
$dom_object = new DomDocument2 ();
$dom_object -> load ( '/var/www/site_extranet/www/creditsafe/xml/' . $fichier );
/* create DOMXPath object with our DOMObject
$xpath = new Domxpath ( $dom_object );
$result = $xpath -> query ( " //liste_depot_acte/depot_acte/. " );
foreach ( $result as $annonce ) {
2010-11-29 15:17:26 +01:00
// N<> Gestion
2010-11-04 12:05:01 +01:00
$title = $xpath -> query ( " num_gest/greffe " , $annonce );
$num_gest_greffe = $title -> item ( 0 ) -> nodeValue ;
*/
$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 ;
else
$strCreditlimit = number_format ( $creditlimit , null , null , ' ' ) . ' €' ;
if ( $rating >= 40 ) {
$fontColor = 'green' ;
$imgFeux = '<img src="/creditsafe/img/feux_vert.png"/>' ;
2010-11-29 15:17:26 +01:00
if ( $rating >= 71 ) $libelle = 'Tr<54> s bonne cote de cr<63> dit/solvabilit<69> ' ;
elseif ( $rating >= 51 ) $libelle = 'Bonne cote de cr<63> dit/solvabilit<69> ' ;
2010-11-04 12:05:01 +01:00
else $libelle = 'Solvable' ;
} elseif ( $rating >= 20 ) {
$fontColor = 'yellow' ; //#f2be2c';
$imgFeux = '<img src="/creditsafe/img/feux_orange.png"/>' ;
2010-11-29 15:17:26 +01:00
$libelle = 'Pr<50> cautions recommand<6E> es' ;
2010-11-04 12:05:01 +01:00
} elseif ( strtoupper ( $rating ) <> strtolower ( $rating )) {
$fontColor = 'black' ;
$imgFeux = ' ' ;
}
elseif ( $rating == '' ) {
$fontColor = 'black' ;
$imgFeux = ' ' ;
}
else {
$fontColor = 'red' ;
$imgFeux = '<img src="/creditsafe/img/feux_rouge.png"/>' ;
2010-11-29 15:17:26 +01:00
if ( $rating == 0 ) $libelle = 'Entreprise en situation de d<> faillance et ayant un tr<74> s fort risque de radiation' ;
else $libelle = 'Avertissement - Cr<43> dit <20> votre discr<63> tion' ;
2010-11-04 12:05:01 +01:00
}
?> <table width="580" border="0" align="left" bgcolor="#FFFFFF">
< tr >
< td colspan = " 3 " >< img src = " ./img/rub_evaluation.png " width = " 577 " height = " 36 " ></ td >
</ tr >
< tr >
< 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>
</ tr >
< tr >
< 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>
</ tr >
< ? if ( $etab [ 'NumRC' ] * 1 <> 0 ) { ?>
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td width = " 200 " class = " StyleInfoLib " > Num & eacute ; ro R . C .</ td >
< td width = " 350 " class = " StyleInfoData " >< ? = $etab [ 'NumRC' ] ?> </td>
</ tr >
< ? } ?>
< tr >
< td colspan = " 3 " >& nbsp ; </ td >
</ tr >
< tr >
< td colspan = " 3 " >< img src = " ./img/srub_scorescf.png " width = " 576 " height = " 27 " ></ td >
</ tr >
<!-- #a5a5a5; }
. grey_gradiant . v20 { background : #bcbcbc; }
. grey_gradiant . v10 { background : #c8c8c8;-->
< tr >< td colspan = " 3 " >
< 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 >
<!-- < tr >
< td colspan = " 5 " align = " right " >< img src = " /creditsafe/img/logo_creditsafe.png " /></ td >
</ tr >-->
</ table >
</ td >
</ tr >
< ?
if ( $action <> 'commande' ) {
?>
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td width = " 550 " colspan = " 2 " class = " StyleInfoData " >< br />< br />< form action = " ./?page=scorescf&action=commande&siret=<?= $siret ?>&id=<?= $id ?> " 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 >
</ tr >
</ table >
< ?
} else {
if ( preg_match ( '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#' , $_REQUEST [ 'email' ])) {
$message = 'Entreprise mise sous surveillance scoring partenaire !' ;
2010-11-29 15:17:26 +01:00
mail ( 'contact@scores-decisions.com' , " Demande de surveillance score CreditSafe pour $siren <20> " . $_REQUEST [ 'email' ],
2010-11-04 12:05:01 +01: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' .
'tabInfo=' . print_r ( $tabInfo , true ));
$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
}
class DomDocument2 extends DOMDocument {
function getValueFromTag ( $tagName ) {
$items = $this -> getElementsByTagName ( $tagName );
foreach ( $items as $item ) {
return utf8_decode ( $item -> nodeValue );
}
}
}
?>