2009-02-17 13:14:53 +00:00
< ?
$login = strtolower ( $_SESSION [ 'tabInfo' ][ 'login' ]);
$siret = $_REQUEST [ 'siret' ];
$siren = substr ( $siret , 0 , 9 );
$id = $_REQUEST [ 'id' ];
$vue = $_REQUEST [ 'vue' ] * 1 ;
if ( ! $_SESSION [ 'connected' ])
echo ( 'Vous devez <20> tre connect<63> afin de pouvoir utiliser cette fonctionnalit<69> ' );
elseif ( ! preg_match ( '/KBIS/i' , $_SESSION [ 'tabInfo' ][ 'droits' ]))
echo ( 'Vous n\'avez pas les droits n<> cessaires pour utiliser cette fonctionnalit<69> (2)' );
else {
$raisonSociale = $tabInfo [ 'entrep' ][ 'raisonSociale' ];
$cj = $tabInfo [ 'entrep' ][ 'fj' ];
$dep = substr ( '' . $tabInfo [ 'entrep' ][ 'codeCommune' ], 0 , 2 );
$errCJ = $errDep = $errNum = false ;
if ( ( $cj >= 91 && $cj <= 93 ) || ( $cj >= 9110 && $cj <= 9300 ) )
$errCJ = true ;
elseif ( $dep == '00' || $dep == '57' || $dep == '67' || $dep == '68' || $dep == '97' || $dep == '98' )
$errDep = true ;
else {
$client = new SoapClient ( null , array ( 'location' => INFOGREFFE_WS_URL ,
'uri' => INFOGREFFE_WS_URI ,
'soap_version' => SOAP_1_1 ,
'trace' => 1 ,
'style' => SOAP_RPC ,
'use' => SOAP_ENCODED ,
));
$type = 'AC' ;
$req = '<demande>' .
'<emetteur>' .
'<code_abonne>' . INFOGREFFE_WS_USER . '</code_abonne>' .// 85009006
'<mot_passe>' . INFOGREFFE_WS_PASS . '</mot_passe>' .//
'<reference_client>' . INFOGREFFE_WS_REF . '</reference_client>' .
'<code_requete>' .
'<type_profil>A</type_profil>' .
'<origine_emetteur>IC</origine_emetteur>' .
'<nature_requete>C</nature_requete>' .
'<type_document>' . $type . '</type_document>' .// KB = Kbis , HQ = Histo , ST = Statut , AC = Acte , LE = Liste <EFBFBD> tab
'<type_requete>S</type_requete>' .
'<media>WS</media>' .
'<mode_diffusion>' .
'<mode type="T"/>' .
'</mode_diffusion>' .
'</code_requete>' .
'</emetteur>' .
'<commande>' .
'<num_siren>' . $siren . '</num_siren>' .
'</commande></demande>' ;
$fichier = " $type - $siren .xml " ;
$perisable = true ;
2009-02-20 09:40:39 +00:00
2009-02-17 13:14:53 +00:00
if ( // Le fichier n'existe pas en cache
2009-02-20 09:40:39 +00:00
! file_exists ( realpath ( dirname ( __FILE__ ) . '/../infogreffe/xml/' . $fichier )) ||
2009-02-17 13:14:53 +00:00
// Le fichier existe en cache mais est p<> risable (liste)
2009-02-20 09:40:39 +00:00
( file_exists ( realpath ( dirname ( __FILE__ ) . '/../infogreffe/xml/' . $fichier )) && $perisable && date ( 'Ymd' , filemtime ( realpath ( dirname ( __FILE__ ) . '/../infogreffe/xml/' . $fichier ))) <> date ( 'Ymd' )) ||
2009-02-17 13:14:53 +00:00
// Le fichier existe en cache, n'est pas p<> risable (acte) mais contient un message d'erreur
// (file_exists('/var/www/site_extranet/www/infogreffe/xml/'.$fichier) && !$perisable && date('Ymd', filemtime(('/var/www/site_extranet/www/infogreffe/xml/'.$fichier)))<>date('Ymd')) &&
// filesize('/var/www/site_extranet/www/infogreffe/xml/'.$fichier)<=200
2009-02-20 09:40:39 +00:00
( file_exists ( realpath ( dirname ( __FILE__ ) . '/../infogreffe/xml/' . $fichier )) && ! $perisable && date ( 'Ymd' , filemtime ( realpath ( dirname ( __FILE__ ) . '/../infogreffe/xml/' . $fichier ))) <> date ( 'Ymd' ) &&
filesize ( realpath ( dirname ( __FILE__ ) . '/../infogreffe/xml/' . $fichier )) <= 200 )
2009-02-17 13:14:53 +00:00
) {
try {
$O = $client -> getProduitsWebServicesXML ( utf8_encode ( $req ));
$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 );
}
/** Enregistrement du fichier XML en provenance des greffes
**/
if ( strlen ( $xml ) <> 0 ) {
2009-02-23 17:19:09 +00:00
$fp =@ fopen ( realpath ( dirname ( __FILE__ ) . '/../infogreffe/xml/' ) . '/' . $fichier , 'w' );
2009-02-17 13:14:53 +00:00
@ fwrite ( $fp , $xml );
@ fclose ( $fp );
}
} else {
/** Lecture du fichier XML en provenance des greffes
**/
2009-02-20 09:40:39 +00:00
$xml = file_get_contents ( realpath ( dirname ( __FILE__ ) . '/../infogreffe/xml/' . $fichier ));
2009-02-17 13:14:53 +00:00
}
/** Affichage des erreurs Infogreffe **/
if ( strlen ( $xml ) < 200 ) {
$tmp = explode ( '-' , $xml );
$errNum = $tmp [ 0 ] * 1 ;
$errMsg = $xml ;
if ( $errNum == 0 ) $errNum =- 1 ;
elseif ( $errNum == 45 ||
$errNum == 14
) $errNum = false ;
}
}
if ( $errCJ || $errDep || $errNum ) {
?> <table width="580" border="0" align="left" bgcolor="#FFFFFF">
< tr >
< td colspan = " 3 " align = " center " >< img src = " ./img/rub_pieces.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 ( $siren , 0 , 3 ) . ' ' . substr ( $siren , 3 , 3 ) . ' ' . substr ( $siren , 6 , 3 ) ?> </td>
</ tr >
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td width = " 200 " class = " StyleInfoLib " > Raison Sociale </ td >
< td width = " 350 " class = " StyleInfoData " >< ? = $raisonSociale ?> </td>
</ tr >
< tr >
< td colspan = " 3 " >& nbsp ; </ td >
</ tr >
< tr >
< td colspan = " 3 " >< img src = " ./img/srub_actes.png " width = " 576 " height = " 27 " /></ td >
</ tr >
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td width = " 550 " colspan = " 2 " class = " StyleInfoData " >< h3 >< ?
if ( $errCJ ) echo 'K-Bis inexistant pour cette forme juridique.' ;
elseif ( $errDep ) echo 'K-Bis inexistant dans ce d<> partement.' ;
else echo 'Retour Greffe : ' . $errMsg . '<!--' . $req . '-->' ;
?> </h3></td>
</ tr >
< ?
} else {
if ( $action == 'commande' ) {
if ( preg_match ( '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#' , $_REQUEST [ 'email' ])) {
$message = 'Commande de K-Bis prise en compte' ;
mail ( 'contact@scores-decisions.com' , " Commande de KBIS pour $siren <20> " . $_REQUEST [ 'email' ],
'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 . 'commande_kbis.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 commande de K-Bis " ;
}
}
2009-02-23 13:48:18 +00:00
if ( file_exists ( realpath ( dirname ( __FILE__ ) . '/../pdf/kbis-' . $siren . '.pdf' )) &&
date ( 'Ymd' , filemtime ( realpath ( dirname ( __FILE__ ) . '/../pdf/kbis-' . $siren . '.pdf' ))) == date ( 'Ymd' ) &&
filesize ( realpath ( dirname ( __FILE__ ) . '/../pdf/kbis-' . $siren . '.pdf' )) > 500 )
2009-02-17 13:14:53 +00:00
$vue = 2 ;
if ( $vue == 0 ) { ?>
< iframe src = " /?page=kbis&vue=1&siret=<?= $siren ?> " width = 0 height = 0 marginheight = " 0 " marginwidth = " 0 " scrolling = " No " frameborder = 0 ></ iframe >
< ? php
}
2009-02-20 13:04:46 +00:00
include_once ( FWK_PATH . '/common/dates.php' );
include_once ( FWK_PATH . '/common/curl.php' );
2009-02-17 13:14:53 +00:00
if ( $vue == 1 /*&& $login=='ylenaour'*/ ) {
set_time_limit ( 410 );
/** 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' ]));
try {
$O = $client -> getKbis ( $siren , 1 , 0 );
$kbis = $O [ 'result' ];
2009-02-26 10:40:45 +00:00
sleep ( 5 );
2009-02-17 13:14:53 +00:00
} catch ( SoapFault $fault ) {
echo '<pre>' . $client -> __getLastResponse () . '</pre>' ;
echo 'ERREUR SOAP :' . EOL ;
print_r ( $fault );
die ();
}
$page = getUrl ( $kbis [ 'Url' ], '' , '' , '' , false );
$body = $page [ 'body' ];
2009-02-24 11:07:12 +00:00
$fp =@ fopen ( realpath ( dirname ( __FILE__ ) . '/../pdf/' ) . '/kbis-' . $siren . '.pdf' , 'w' );
2009-02-17 13:14:53 +00:00
@ fwrite ( $fp , $body );
@ fclose ( $fp );
2009-02-26 10:40:45 +00:00
$message = 'Commande de K-Bis en cours' ;
mail ( 'ylenaour@scores-decisions.com' , " KBIS en cours pour $login ( $siren , vue= $vue ) " ,
'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 ) . EOL .
'O=' . print_r ( $O , true ) . EOL );
2009-02-17 13:14:53 +00:00
}
$raisonSociale = $tabInfo [ 'entrep' ][ 'raisonSociale' ];
?> <table width="580" border="0" align="left" bgcolor="#FFFFFF">
< ? php
if ( $message <> '' ) {
?>
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td width = " 550 " colspan = " 2 " class = " StyleInfoData " >< h3 >< ? = $message ; ?> </h3></td>
</ tr >
< ? php
}
?>
< tr >
< td colspan = " 3 " align = " center " >< img src = " ./img/rub_pieces.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 ( $siren , 0 , 3 ) . ' ' . substr ( $siren , 3 , 3 ) . ' ' . substr ( $siren , 6 , 3 ) ?> </td>
</ tr >
< tr >
< td width = " 30 " >& nbsp ; </ td >
< td width = " 200 " class = " StyleInfoLib " > Raison Sociale </ td >
< td width = " 350 " class = " StyleInfoData " >< ? = $raisonSociale ?> </td>
</ tr >
< tr >
< td colspan = " 3 " >& nbsp ; </ td >
</ tr >
< tr >
< td colspan = " 3 " >< img src = " ./img/srub_actes.png " width = " 576 " height = " 27 " /></ td >
</ tr >
< tr >
< td colspan = " 3 " align = " center " >< ?
if ( $vue == 0 ) {
?> <script src="/nonimg/jquery.js" type="text/javascript"></script>
< script src = " /nonimg/jqueryprogressbar.js " type = " text/javascript " ></ script >
< script type = " text/javascript " >
$ ( " #progressbar " ) . reportprogress ( 0 );
var pct = 0 ;
var handle = 0 ;
function update (){
$ ( " #progressbar " ) . reportprogress ( ++ pct );
if ( pct == 100 ){
clearInterval ( handle );
$ ( " #run " ) . val ( " start " );
pct = 0 ;
window . location . href = " /?page=kbis&vue=2&siret=<?= $siren ?> " ;
}
}
handle = setInterval ( " update() " , 700 );
</ script >< div id = " progressbar " ></ div >< ?
2009-02-26 10:40:45 +00:00
$message = 'Commande de K-Bis en cours' ;
mail ( 'ylenaour@scores-decisions.com' , " KBIS en cours pour $login ( $siren , vue= $vue ) " ,
'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 ) . EOL .
'O=' . print_r ( $O , true ) . EOL );
2009-02-20 09:40:39 +00:00
} elseif ( ! ( file_exists ( realpath ( dirname ( __FILE__ ) . " /../pdf/kbis- $siren .pdf " ))
&& date ( 'Ymd' , filemtime ( realpath ( dirname ( __FILE__ ) . " /../pdf/kbis- $siren .pdf " ))) == date ( 'Ymd' )
&& filesize ( realpath ( dirname ( __FILE__ ) . " /../pdf/kbis- $siren .pdf " )) > 500 )) {
2009-02-26 10:40:45 +00:00
$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' ]));
try {
$O = $client -> getKbis ( $siren , 1 , 0 );
$kbis = $O [ 'result' ];
sleep ( 5 );
} catch ( SoapFault $fault ) {
echo '<pre>' . $client -> __getLastResponse () . '</pre>' ;
echo 'ERREUR SOAP :' . EOL ;
print_r ( $fault );
die ();
}
$page = getUrl ( $kbis [ 'Url' ], '' , '' , '' , false );
$body = $page [ 'body' ];
$fp =@ fopen ( realpath ( dirname ( __FILE__ ) . '/../pdf/' ) . '/kbis-' . $siren . '.pdf' , 'w' );
@ fwrite ( $fp , $body );
@ fclose ( $fp );
if ( file_exists ( realpath ( dirname ( __FILE__ ) . " /../pdf/kbis- $siren .pdf " ))
&& date ( 'Ymd' , filemtime ( realpath ( dirname ( __FILE__ ) . " /../pdf/kbis- $siren .pdf " ))) == date ( 'Ymd' )
&& filesize ( realpath ( dirname ( __FILE__ ) . " /../pdf/kbis- $siren .pdf " )) > 500 ) {
echo '<u><a title="Cliquez ici pour visualiser le kbis" target="_blank" href="/?page=actes&siret=' . $siret . '&ref=kbis">Visualiser le Kbis <img src="/img/icone_pdf.gif"></a></u>' ;
$message = 'Commande de K-Bis prise en compte' ;
mail ( 'ylenaour@scores-decisions.com' , " Commande de KBIS pour $login ( $siren ) " ,
'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 ) . EOL .
'O=' . print_r ( $O , true ) . EOL );
} else {
2009-02-20 09:40:39 +00:00
?>
< script src = " /nonimg/jquery.js " type = " text/javascript " ></ script >
2009-02-17 13:14:53 +00:00
< script src = " /nonimg/jqueryprogressbar.js " type = " text/javascript " ></ script >
< script type = " text/javascript " >
$ ( " #progressbar " ) . reportprogress ( 0 );
var pct = 0 ;
var handle = 0 ;
function update (){
$ ( " #progressbar " ) . reportprogress ( ++ pct );
if ( pct == 100 ){
clearInterval ( handle );
$ ( " #run " ) . val ( " start " );
pct = 0 ;
window . location . href = " /?page=kbis&vue=2&siret=<?= $siren ?> " ;
}
}
handle = setInterval ( " update() " , 700 );
</ script >< div id = " progressbar " ></ div >< ?
2009-02-26 10:40:45 +00:00
$message = 'Commande de K-Bis en cours' ;
mail ( 'ylenaour@scores-decisions.com' , " KBIS en cours pour $login ( $siren , vue= $vue ) " ,
'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 ) . EOL .
'O=' . print_r ( $O , true ) . EOL );
}
2009-02-17 13:14:53 +00:00
} else {
echo '<u><a title="Cliquez ici pour visualiser le kbis" target="_blank" href="/?page=actes&siret=' . $siret . '&ref=kbis">Visualiser le Kbis <img src="/img/icone_pdf.gif"></a></u>' ;
$message = 'Commande de K-Bis prise en compte' ;
2009-02-26 10:40:45 +00:00
mail ( 'ylenaour@scores-decisions.com' , " Commande de KBIS pour $login ( $siren , vue= $vue ) " ,
2009-02-17 13:14:53 +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' .
2009-02-26 10:40:45 +00:00
'tabInfo=' . print_r ( $tabInfo , true ) . EOL .
'O=' . print_r ( $O , true ) . EOL );
2009-02-17 13:14:53 +00:00
}
?>
</ td >
</ tr >
< ?
}
?>
</ table >
< ?
}
?>