2009-02-17 13:14:53 +00:00
< ?
2009-04-02 15:09:39 +00:00
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' ]))
2009-06-30 13:25:28 +00:00
echo ( 'Vous n\'avez pas les droits n<> cessaires pour utiliser cette fonctionnalit<69> ' );
2009-04-02 15:09:39 +00:00
else {
2009-06-30 13:25:28 +00:00
2009-07-06 15:11:11 +00:00
$login = strtolower ( $_SESSION [ 'tabInfo' ][ 'login' ]);
$siret = $_REQUEST [ 'siret' ];
$siren = substr ( $siret , 0 , 9 );
$id = $_REQUEST [ 'id' ];
$vue = $_REQUEST [ 'vue' ] * 1 ;
2009-04-01 12:45:45 +00:00
$tabInfo = $_SESSION [ 'tabInfo' ];
2009-06-30 13:25:28 +00:00
2009-02-17 13:14:53 +00:00
$raisonSociale = $tabInfo [ 'entrep' ][ 'raisonSociale' ];
$cj = $tabInfo [ 'entrep' ][ 'fj' ];
$dep = substr ( '' . $tabInfo [ 'entrep' ][ 'codeCommune' ], 0 , 2 );
2009-06-30 13:25:28 +00:00
$errCJ = $errDep = $errNum = false ;
2009-02-17 13:14:53 +00:00
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 {
2009-04-02 15:09:39 +00:00
$client2 = new SoapClient ( null , array ( 'location' => INFOGREFFE_WS_URL ,
2009-02-17 13:14:53 +00:00
'uri' => INFOGREFFE_WS_URI ,
'soap_version' => SOAP_1_1 ,
'trace' => 1 ,
'style' => SOAP_RPC ,
'use' => SOAP_ENCODED ,
));
2009-06-30 13:25:28 +00:00
$type = 'AC' ;
$req = '<demande>' .
2009-02-17 13:14:53 +00:00
'<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>' ;
2009-06-30 13:25:28 +00:00
2009-02-17 13:14:53 +00:00
$fichier = " $type - $siren .xml " ;
$perisable = true ;
2009-06-30 13:25:28 +00:00
2009-02-17 13:14:53 +00:00
if ( // Le fichier n'existe pas en cache
2009-06-30 13:25:28 +00:00
! file_exists ( PATH_DATA . '/infogreffe/xml/' . $fichier ) ||
2009-02-17 13:14:53 +00:00
// Le fichier existe en cache mais est p<> risable (liste)
2009-03-02 11:27:23 +00:00
( file_exists ( PATH_DATA . '/infogreffe/xml/' . $fichier ) && $perisable && date ( 'Ymd' , filemtime ( PATH_DATA . '/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
2009-06-30 13:25:28 +00:00
( file_exists ( PATH_DATA . '/infogreffe/xml/' . $fichier ) && ! $perisable && date ( 'Ymd' , filemtime ( PATH_DATA . '/infogreffe/xml/' . $fichier )) <> date ( 'Ymd' ) &&
2009-03-02 11:27:23 +00:00
filesize ( PATH_DATA . '/infogreffe/xml/' . $fichier ) <= 200 )
2009-07-06 15:11:11 +00:00
){
2009-02-17 13:14:53 +00:00
try {
2009-07-06 15:11:11 +00:00
$O = $client2 -> getProduitsWebServicesXML ( utf8_encode ( $req ));
$xml = implode ( '' , ( array ) $O );
} catch ( SoapFault $soapFault ) { // echo "ERROR :\n", var_dump($soapFault), "\n"; echo "Request :\n", $client->__getLastRequest(), "\n";
//require_once 'soaperror.php';
//processSoapFault($client2,$fault,$tabInfo);
$success = false ;
$response = $client2 -> __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 );
2009-02-17 13:14:53 +00:00
}
2009-06-30 13:25:28 +00:00
2009-07-06 15:11:11 +00:00
/** Enregistrement du fichier XML en provenance des greffes **/
if ( strlen ( $xml ) <> 0 ) {
$fp =@ fopen ( PATH_DATA . '/infogreffe/xml/' . $fichier , 'w' );
@ fwrite ( $fp , $xml );
@ fclose ( $fp );
2009-02-17 13:14:53 +00:00
}
2009-07-06 15:11:11 +00:00
} else {
/** Lecture du fichier XML en provenance des greffes **/
$xml = file_get_contents ( PATH_DATA . '/infogreffe/xml/' . $fichier );
}
/** 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 ;
2009-02-17 13:14:53 +00:00
}
2009-07-06 15:11:11 +00:00
}
2009-06-30 13:25:28 +00:00
2009-07-06 15:11:11 +00:00
if ( $errCJ || $errDep || $errNum ) {
2009-06-30 13:25:28 +00:00
?>
< table width = " 580 " border = " 0 " align = " left " bgcolor = " #FFFFFF " >
2009-02-17 13:14:53 +00:00
< 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 >
2009-07-06 15:11:11 +00:00
< td width = " 550 " colspan = " 2 " class = " StyleInfoData " >
< h3 >
< ?
2009-02-17 13:14:53 +00:00
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 . '-->' ;
2009-07-06 15:11:11 +00:00
?>
</ h3 >
</ td >
2009-02-17 13:14:53 +00:00
</ tr >
< ?
} else {
2009-07-06 15:11:11 +00:00
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-17 13:14:53 +00:00
}
2009-06-30 13:25:28 +00:00
if ( file_exists ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' )
&& date ( 'Ymd' , filemtime ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' )) == date ( 'Ymd' )
&& filesize ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' ) > 500
) $vue = 2 ;
2009-02-17 13:14:53 +00:00
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-07-21 07:17:54 +00:00
require_once 'common/dates.php' ;
require_once 'common/curl.php' ;
2009-02-17 13:14:53 +00:00
2009-07-06 15:11:11 +00:00
if ( $vue == 1 ) {
2009-02-17 13:14:53 +00:00
set_time_limit ( 410 );
2009-07-06 15:11:11 +00:00
ini_set ( 'default_socket_timeout' , 160 );
2009-03-25 14:38:22 +00:00
2009-02-17 13:14:53 +00:00
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 ) {
2009-07-06 15:11:11 +00:00
require_once 'soaperror.php' ;
processSoapFault ( $client , $fault , $tabInfo );
//echo '<pre>'.$client->__getLastResponse().'</pre>';
//echo 'ERREUR SOAP :'.EOL;
//print_r($fault);
//die();
2009-02-17 13:14:53 +00:00
}
$page = getUrl ( $kbis [ 'Url' ], '' , '' , '' , false );
$body = $page [ 'body' ];
2009-03-02 11:27:23 +00:00
$fp =@ fopen ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' , 'w' );
2009-02-17 13:14:53 +00:00
@ fwrite ( $fp , $body );
@ fclose ( $fp );
2009-06-30 13:25:28 +00:00
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' .
2009-06-30 13:25:28 +00:00
'SERVER=' . EOL . print_r ( $_SERVER , true ) . 'EOL' .
2009-02-26 10:40:45 +00:00
'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' ];
2009-07-06 15:11:11 +00:00
?>
< table width = " 580 " border = " 0 " align = " left " bgcolor = " #FFFFFF " >
2009-02-17 13:14:53 +00:00
< ? 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 >
2009-07-06 15:11:11 +00:00
< td colspan = " 3 " align = " center " >
< ?
2009-02-17 13:14:53 +00:00
if ( $vue == 0 ) {
2009-07-06 15:11:11 +00:00
?>
2009-03-02 14:25:00 +00:00
< script src = " ./js/jqueryprogressbar.js " type = " text/javascript " ></ script >
2009-02-17 13:14:53 +00:00
< script type = " text/javascript " >
$ ( " #progressbar " ) . reportprogress ( 0 );
2009-06-30 13:25:28 +00:00
2009-02-17 13:14:53 +00:00
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 );
2009-03-02 14:25:00 +00:00
</ 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' .
2009-06-30 13:25:28 +00:00
'SERVER=' . EOL . print_r ( $_SERVER , true ) . 'EOL' .
2009-02-26 10:40:45 +00:00
'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-07-06 15:11:11 +00:00
2009-06-30 13:25:28 +00:00
} elseif ( ! ( file_exists ( PATH_DATA . '/../pdf/kbis-' . $siren . '.pdf' )
&& date ( 'Ymd' , filemtime ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' )) == date ( 'Ymd' )
2009-07-06 15:11:11 +00:00
&& filesize ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' ) > 500 )){
2009-02-26 10:40:45 +00:00
try {
$O = $client -> getKbis ( $siren , 1 , 0 );
$kbis = $O [ 'result' ];
sleep ( 5 );
} catch ( SoapFault $fault ) {
2009-07-06 15:11:11 +00:00
require_once 'soaperror.php' ;
processSoapFault ( $client , $fault , $tabInfo );
//echo '<pre>'.$client->__getLastResponse().'</pre>';
//echo 'ERREUR SOAP :'.EOL;
//print_r($fault);
//die();
2009-02-26 10:40:45 +00:00
}
$page = getUrl ( $kbis [ 'Url' ], '' , '' , '' , false );
$body = $page [ 'body' ];
2009-03-02 11:27:23 +00:00
$fp =@ fopen ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' , 'w' );
2009-02-26 10:40:45 +00:00
@ fwrite ( $fp , $body );
@ fclose ( $fp );
2009-06-30 13:25:28 +00:00
if ( file_exists ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' )
&& date ( 'Ymd' , filemtime ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' )) == date ( 'Ymd' )
&& filesize ( PATH_DATA . '/pdf/kbis-' . $siren . '.pdf' ) > 500 )
2009-03-02 11:27:23 +00:00
{
2009-02-26 10:40:45 +00:00
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>' ;
2009-06-30 13:25:28 +00:00
2009-02-26 10:40:45 +00:00
$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' .
2009-06-30 13:25:28 +00:00
'SERVER=' . EOL . print_r ( $_SERVER , true ) . 'EOL' .
2009-02-26 10:40:45 +00:00
'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
?>
2009-03-02 14:25:00 +00:00
< script src = " ./js/jqueryprogressbar.js " type = " text/javascript " ></ script >
2009-02-17 13:14:53 +00:00
< script type = " text/javascript " >
$ ( " #progressbar " ) . reportprogress ( 0 );
2009-06-30 13:25:28 +00:00
2009-02-17 13:14:53 +00:00
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 );
2009-07-06 15:11:11 +00:00
</ 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' .
2009-06-30 13:25:28 +00:00
'SERVER=' . EOL . print_r ( $_SERVER , true ) . 'EOL' .
2009-02-26 10:40:45 +00:00
'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-07-06 15:11:11 +00:00
2009-02-17 13:14:53 +00:00
} else {
2009-06-30 13:25:28 +00:00
2009-02-17 13:14:53 +00:00
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>' ;
2009-06-30 13:25:28 +00:00
2009-02-17 13:14:53 +00:00
$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' .
2009-06-30 13:25:28 +00:00
'SERVER=' . EOL . print_r ( $_SERVER , true ) . 'EOL' .
2009-02-17 13:14:53 +00:00
'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 >
< ?
}
?>