Mise à jour suite à mise à niveau webservice v1
This commit is contained in:
parent
b9c0167034
commit
73943c026f
302
library/Metier/common/ICotation.inc
Normal file
302
library/Metier/common/ICotation.inc
Normal file
@ -0,0 +1,302 @@
|
||||
<?php
|
||||
|
||||
class ICotation {
|
||||
|
||||
var $reTrtAuto;
|
||||
var $tabBilan;
|
||||
|
||||
var $tabNotation;
|
||||
var $tabLibActivite;
|
||||
var $tabActivite;
|
||||
var $tabR;
|
||||
|
||||
|
||||
function ICotation ($tabBilan, $retraitementAutomatique=true) {
|
||||
$this->reTrtAuto = $retraitementAutomatique;
|
||||
$this->tabBilan = $tabBilan;
|
||||
|
||||
include ('paramCotation.inc');
|
||||
}
|
||||
|
||||
function calculProvisionsPourRisque () {
|
||||
if ( !$this->reTrtAuto )
|
||||
return $this->tabBilan['DP'] + $this->tabBilan['DQ'] - $this->tabBilan['X04'];
|
||||
else
|
||||
return (1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ']);
|
||||
}
|
||||
|
||||
function calculEBE () {
|
||||
return $this->tabBilan['FC'] + $this->tabBilan['FF'] + $this->tabBilan['FI'] + $this->tabBilan['FOB']
|
||||
+ $this->tabBilan['FM'] + $this->tabBilan['FN'] - $this->tabBilan['FC'] + $this->tabBilan['FC']
|
||||
- ( $this->tabBilan['FS'] + $this->tabBilan['FT'] + $this->tabBilan['FU'] + $this->tabBilan['FV'] )
|
||||
- ( $this->tabBilan['FW'] - $this->tabBilan['HP'] - $this->tabBilan['HQ'] - $this->tabBilan['HP2'] - $this->tabBilan['HQ2'] )
|
||||
- $this->tabBilan['FX'] - ( $this->tabBilan['FY'] + $this->tabBilan['FZ'] ) + ( $this->tabBilan['FO'] - $this->tabBilan['FOB'] ) ;
|
||||
}
|
||||
|
||||
function calculChiffreAffaires () {
|
||||
return $this->tabBilan['FC']
|
||||
+ $this->tabBilan['FF']
|
||||
+ $this->tabBilan['FI']
|
||||
+ $this->tabBilan['FO']
|
||||
- $this->tabBilan['FOB'] ;
|
||||
}
|
||||
|
||||
function calculMargeCommerciale () {
|
||||
return $this->tabBilan['FC'] - ( $this->tabBilan['FS'] + $this->tabBilan['FT'] ) ;
|
||||
}
|
||||
|
||||
function calculProduction () {
|
||||
return $this->tabBilan['FF'] + $this->tabBilan['FI'] + $this->tabBilan['FM'] + $this->tabBilan['FN'] ;
|
||||
}
|
||||
|
||||
function calculValeurAjoutee () {
|
||||
return $this->calculMargeCommerciale() + $this->calculProduction()
|
||||
- ( $this->tabBilan['FU'] + $this->tabBilan['FV'] + $this->tabBilan['FW'] ) ;
|
||||
}
|
||||
|
||||
function calculEBEnonCASA () {
|
||||
return $this->calculValeurAjoutee() + $this->tabBilan['FO'] - $this->tabBilan['FX'] - ( $this->tabBilan['FY'] + $this->tabBilan['FZ'] ) ;
|
||||
}
|
||||
|
||||
function calculFondsPropresNetsCorriges() {
|
||||
return $this->tabBilan['DA'] + $this->tabBilan['DC'] + $this->tabBilan['DB'] + $this->tabBilan['DD'] + $this->tabBilan['DE'] + $this->tabBilan['DF'] + $this->tabBilan['DG'] + $this->tabBilan['DK'] - (1/3*$this->tabBilan['X01'])
|
||||
+ $this->tabBilan['DH'] + $this->tabBilan['DI'] + $this->tabBilan['DJ']
|
||||
- $this->tabBilan['CL'] - $this->tabBilan['AB'] + $this->tabBilan['AC'] - $this->tabBilan['AA'] - $this->tabBilan['CB'] + $this->tabBilan['CC'] - $this->tabBilan['X02'] - $this->tabBilan['CM'] - $this->tabBilan['CN']
|
||||
+ $this->tabBilan['DM'] + $this->tabBilan['DN']
|
||||
- $this->tabBilan['X03'] + $this->calculProvisionsPourRisque() - $this->tabBilan['RAD'] ;
|
||||
}
|
||||
|
||||
function calculDettesFinancieresBancairesBrutes () {
|
||||
return $this->tabBilan['DS'] - $this->tabBilan['CM1'] + $this->tabBilan['EI'] - $this->tabBilan['CM2']
|
||||
+ $this->tabBilan['DT'] - $this->tabBilan['CM3'] + $this->tabBilan['DU'] - $this->tabBilan['EH']
|
||||
+ (3/4*$this->tabBilan['YQ']) + (2/3*$this->tabBilan['YR'])
|
||||
+ (3/4*$this->tabBilan['YQ2']) + (2/3*$this->tabBilan['YR2'])
|
||||
+ $this->tabBilan['DV'] - $this->tabBilan['EI'] - $this->tabBilan['DVI1'] - $this->tabBilan['CM2']
|
||||
+ $this->tabBilan['YS'] + $this->tabBilan['X08']
|
||||
+ $this->tabBilan['EH'] + $this->tabBilan['VI1'] - ( $this->tabBilan['X20'] + $this->tabBilan['X21'] ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function noteCapitalisation () {
|
||||
if ( !$this->reTrtAuto ) {
|
||||
$autresDettesExploit = $this->tabBilan['EA'] - $this->tabBilan['EAVI1'] - $this->tabBilan['EAB'] + $this->tabBilan['EB'] + $this->tabBilan['X01'] + $this->tabBilan['X04'] ;
|
||||
$dettesFiscalesSociales = $this->tabBilan['DY'] - $this->tabBilan['DYA'];
|
||||
} else {
|
||||
$autresDettesExploit = $this->tabBilan['EA'] - $this->tabBilan['EAVI1'] - $this->tabBilan['EAB'] + $this->tabBilan['EB'] + $this->tabBilan['X01'] + 2/3*((1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ']));
|
||||
$dettesFiscalesSociales = $this->tabBilan['DY'] + 1/3*((1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ'])) - $this->tabBilan['DYA'] ;
|
||||
}
|
||||
|
||||
$numerateur = $this->calculFondsPropresNetsCorriges();
|
||||
|
||||
$denominateur = $numerateur + $this->tabBilan['DS'] - $this->tabBilan['CM1'] + $this->tabBilan['EI'] - $this->tabBilan['CM2'] + $this->tabBilan['DU'] - $this->tabBilan['EH']
|
||||
+ $this->tabBilan['DV'] - $this->tabBilan['DVI1'] - $this->tabBilan['EI'] + $this->tabBilan['DT'] - $this->tabBilan['CM3'] + 3/4*$this->tabBilan['YQ'] + 2/3*$this->tabBilan['YR']
|
||||
+ 3/4*$this->tabBilan['YQ2'] + 2/3*$this->tabBilan['YR2']
|
||||
+ $this->tabBilan['DW'] + $this->tabBilan['DX'] + $dettesFiscalesSociales
|
||||
+ $autresDettesExploit + $this->tabBilan['DZ'] + $this->tabBilan['DIA'] + $this->tabBilan['ED'] + $this->tabBilan['EAB'] + $this->tabBilan['DYA']
|
||||
+ $this->tabBilan['EH'] + $this->tabBilan['YS'] + $this->tabBilan['VI1'];
|
||||
// + $this->tabBilan['X08']
|
||||
// - $this->tabBilan['X20'] + $this->tabBilan['YS'] - $this->tabBilan['X08'];
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur* 100,'DENOMINATEUR'=>$denominateur,'NOTE'=>($numerateur* 100)/$denominateur);
|
||||
}
|
||||
|
||||
function noteLevierEndettement () {
|
||||
|
||||
$numerateur = $this->calculDettesFinancieresBancairesBrutes();
|
||||
|
||||
$denominateur = $this->calculFondsPropresNetsCorriges();
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
|
||||
}
|
||||
|
||||
function noteCapaciteRemboursement () {
|
||||
|
||||
$numerateur = $this->calculDettesFinancieresBancairesBrutes();
|
||||
|
||||
$denominateur = $this->calculEBE();
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
|
||||
}
|
||||
|
||||
function noteCouvChargesFi () {
|
||||
|
||||
$numerateur = $this->calculEBE();
|
||||
|
||||
$denominateur = $this->tabBilan['GR'] + ( 1/4*$this->tabBilan['HP'] + 1/3*$this->tabBilan['HQ'] )
|
||||
+ ( 1/4*$this->tabBilan['HP2'] + 1/3*$this->tabBilan['HQ2'] )
|
||||
+ $this->tabBilan['GS']
|
||||
+ $this->tabBilan['GT']
|
||||
- $this->tabBilan['GJ']
|
||||
- $this->tabBilan['GK']
|
||||
- $this->tabBilan['GL']
|
||||
- $this->tabBilan['GN']
|
||||
- $this->tabBilan['GO']
|
||||
- $this->tabBilan['GH']
|
||||
+ $this->tabBilan['GI'] ;
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
|
||||
}
|
||||
|
||||
function noteTresorerie () {
|
||||
|
||||
$numerateur = $this->tabBilan['CD'] - $this->tabBilan['CE'] + $this->tabBilan['CF'] - $this->tabBilan['CG']
|
||||
- $this->tabBilan['EH'] - ( $this->tabBilan['YS'] + $this->tabBilan['X08'] ) ;
|
||||
|
||||
$denominateur = $this->calculChiffreAffaires();
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur*360,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur*360,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur*360/$denominateur);
|
||||
|
||||
}
|
||||
|
||||
function noteMargeExploitation () {
|
||||
|
||||
$numerateur = $this->calculEBE();
|
||||
|
||||
$denominateur = $this->calculChiffreAffaires();
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur*100/$denominateur);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getSecteurActivite($naf) {
|
||||
|
||||
$nbSecteurs=count($this->tabActivite);
|
||||
|
||||
while (strlen($naf) > 1)
|
||||
{
|
||||
for ($i=1; $i<$nbSecteurs; $i++)
|
||||
{
|
||||
for ($j=0; isset($this->tabActivite[$i][$j]); $j++)
|
||||
{
|
||||
if ($this->tabActivite[$i][$j]==$naf)
|
||||
// echo 'NAF '.$naf.' TROUVÉ !<br>';
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
// echo 'NAF '.$naf.' non trouvé !<br>';
|
||||
$naf=substr($naf,0,strlen($naf)-1);
|
||||
}
|
||||
return 17; // Secteur d'activité par défaut si non trouvé
|
||||
}
|
||||
|
||||
function getBorne($note, $borne, $secteur) {
|
||||
|
||||
// print_array($this->tabR[$borne][$secteur],0);
|
||||
for ($j=0; $j<10; $j++)
|
||||
{
|
||||
$tabMinMax=explode(':',$this->tabR[$borne][$secteur][$j]);
|
||||
if ($tabMinMax[0]!='') $min=$tabMinMax[0];
|
||||
else $min=-1E99;
|
||||
if ($tabMinMax[1]!='') $max=$tabMinMax[1];
|
||||
else $max=1E99;
|
||||
|
||||
if ( ( $note>$min && $note<=$max ) )
|
||||
{
|
||||
// echo "TROUVE ++++ $note > ".$tabMinMax[0]." et $note <= ". $tabMinMax[1].'<br/>';
|
||||
if ($j==0) return 3;
|
||||
elseif ($j<4) return $j+4;
|
||||
else return $j*2+1;
|
||||
}
|
||||
// echo "NOK $note < ".$tabMinMax[0]." ou $note > ". $tabMinMax[1].'<br/>';
|
||||
}
|
||||
return 3; // On retourne la plus basse note par défaut
|
||||
}
|
||||
|
||||
|
||||
function getNoteBorne($note, $borne, $secteur, $numerateur, $denominateur) {
|
||||
|
||||
$noteBorneBrute=$this->getBorne($note, $borne, $secteur);
|
||||
|
||||
switch($borne)
|
||||
{
|
||||
case 1:
|
||||
if ($numerateur<0) return 3;
|
||||
else return $noteBorneBrute;
|
||||
break;
|
||||
case 2:
|
||||
if ($numerateur==0) return 19;
|
||||
else return $noteBorneBrute;
|
||||
break;
|
||||
case 3:
|
||||
if ($numerateur==0 && $denominateur>0) return 19;
|
||||
elseif ($denominateur<0) return 3;
|
||||
else return $noteBorneBrute;
|
||||
break;
|
||||
case 4:
|
||||
if ($note<0) return 19;
|
||||
else return $noteBorneBrute;
|
||||
break;
|
||||
default:
|
||||
return $noteBorneBrute;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getNotationFin ($coteMoy) {
|
||||
if( $coteMoy > 18.5 )
|
||||
return 'A';
|
||||
elseif( $coteMoy > 16 )
|
||||
return 'B+';
|
||||
elseif( $coteMoy > 14 )
|
||||
return 'B';
|
||||
elseif( $coteMoy > 12.5 )
|
||||
return 'C+';
|
||||
elseif( $coteMoy > 11 )
|
||||
return 'C';
|
||||
elseif( $coteMoy > 10 )
|
||||
return 'C-';
|
||||
elseif( $coteMoy > 9 )
|
||||
return 'D+';
|
||||
elseif( $coteMoy > 8 )
|
||||
return 'D';
|
||||
elseif( $coteMoy > 7 )
|
||||
return 'D-';
|
||||
elseif( $coteMoy > 6 )
|
||||
return 'E+';
|
||||
elseif( $coteMoy > 4.5 )
|
||||
return 'E';
|
||||
elseif( $coteMoy > 3 )
|
||||
return 'E-';
|
||||
else
|
||||
return 'E--';
|
||||
}
|
||||
|
||||
|
||||
function getInfosNotation ($notation, $csv=false) {
|
||||
if ($csv) {
|
||||
$str =$this->tabNotation[$notation][1].';'.
|
||||
$this->tabNotation[$notation][2].';'.
|
||||
$this->tabNotation[$notation][3].';'.
|
||||
$this->tabNotation[$notation][4].';';
|
||||
return $str;
|
||||
} else {
|
||||
$str ='Notation : '. $this->tabNotation[$notation][0]."\r\n";
|
||||
$str.='Equivalence BDF : '. $this->tabNotation[$notation][1]."\r\n";
|
||||
$str.='Grades Moody\'s : '. $this->tabNotation[$notation][2]."\r\n";
|
||||
$str.='Grades S&P : '. $this->tabNotation[$notation][3]."\r\n";
|
||||
$str.='Probabilité de défaillance : '. $this->tabNotation[$notation][4]." %\r\n";
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
47
library/Metier/common/controles.php
Normal file
47
library/Metier/common/controles.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?
|
||||
|
||||
function isinPoidsLettre($lettre) {
|
||||
$ascii=ord($lettre);
|
||||
if ($ascii>64 && $ascii<91 )
|
||||
/* En ASCII : A=65 et Z=90
|
||||
En ISIN... A=10 et Z=35 */
|
||||
return ($ascii-55);
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Test si un code ISIN donné est valable à partir de son algo de contrôle.
|
||||
** @param string $isin Code ISIN à vérifier
|
||||
** @return bool
|
||||
**/
|
||||
function isValidIsin($isin) {
|
||||
|
||||
$pays=substr($isin, 0,2);
|
||||
$nsin=''.substr($isin, 2,9);
|
||||
$clef=substr($isin,11,1)*1;
|
||||
|
||||
$calcul=''.isinPoidsLettre($pays[0]).isinPoidsLettre($pays[1]).$nsin;
|
||||
//echo "Etape 1 = $calcul".EOL;
|
||||
|
||||
$sommeImpair=$sommePair=0;
|
||||
for ($impair=0; $impair<12; $impair=$impair+2) {
|
||||
$strImpair=''.$calcul[$impair]*2;
|
||||
if (isset($strImpair[1])) $reste=$strImpair[1]*1;
|
||||
else $reste=0;
|
||||
$sommeImpair+=$strImpair[0]*1+$reste;
|
||||
}
|
||||
|
||||
for ($pair=1; $pair<12; $pair=$pair+2)
|
||||
$sommePair+=$calcul[$pair]*1;
|
||||
|
||||
$totalcalcul=$sommeImpair+$sommePair;
|
||||
//echo "Etape 3 = $sommeImpair + $sommePair = $totalcalcul".EOL;
|
||||
|
||||
$dizSuperieur=ceil($totalcalcul/10)*10;
|
||||
$delta=$dizSuperieur-$totalcalcul;
|
||||
//echo "Etape 4 = $dizSuperieur - $totalcalcul = $delta".EOL;
|
||||
|
||||
if ($delta==$clef) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
?>
|
339
library/Metier/common/fonctions.php
Normal file
339
library/Metier/common/fonctions.php
Normal file
@ -0,0 +1,339 @@
|
||||
<?
|
||||
/** Parse une page Html et retourne son contenu dans un tableau :
|
||||
** "code" => Code réponse Serveur
|
||||
** "header" => Headers du serveur
|
||||
** "body" => Page HTML
|
||||
**/
|
||||
function parse_response($this_response) {
|
||||
|
||||
|
||||
// Split response into header and body sections
|
||||
list($response_headers, $response_body) = explode("\r\n\r\n", $this_response, 2);
|
||||
$response_header_lines = explode("\r\n", $response_headers);
|
||||
|
||||
// First line of headers is the HTTP response code
|
||||
$http_response_line = array_shift($response_header_lines);
|
||||
if(preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@',$http_response_line, $matches)) { $response_code = $matches[1]; }
|
||||
|
||||
// put the rest of the headers in an array
|
||||
$response_header_array = array();
|
||||
$nbRMID=0;
|
||||
foreach($response_header_lines as $header_line)
|
||||
{
|
||||
list($header,$value) = explode(': ', $header_line, 2);
|
||||
|
||||
if ($header=='Set-cookie' && substr($value,0,5)=='RMID=' && $nbRMID<5)//{
|
||||
$nbRMID++;
|
||||
// echo ("Je gicle le RMID n°$nbRMID\r\n");}
|
||||
else
|
||||
$response_header_array[$header] .= $value."\n";
|
||||
}
|
||||
return array('code' => $response_code, 'header' => $response_header_array, 'body' => $response_body);
|
||||
}
|
||||
|
||||
/** Récupère une page HTML en fonction des paramètres :
|
||||
** $url Url distante de la page à récupérer
|
||||
** $strCookies Chaine de caractère contenant les cookies
|
||||
** $postData Tableau des données à passer en POST uniquement
|
||||
** $referer Referer à indiquer lors de l'appel de la page
|
||||
** $debug Activer le débogage (True/False)
|
||||
**
|
||||
** ... et retourne son contenu dans un tableau :
|
||||
** "code" => Code réponse Serveur
|
||||
** "header" => Headers du serveur
|
||||
** "body" => Page HTML
|
||||
**/
|
||||
function getUrl($url, $strCookies='', $postData='', $referer='', $debug=false, $host='') {
|
||||
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
if ($host=='')
|
||||
$this_header = array('Host: '. HOST_INSEE);
|
||||
else
|
||||
$this_header = array('Host: '. $host);
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
//curl_setopt($ch, CURLOPT_PROXY, '10.142.10.254:80');
|
||||
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'username:password'); // Pas nécessaire en authentification NT
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
//curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
|
||||
|
||||
$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
|
||||
curl_setopt($ch, CURLOPT_REFERER, $referer);
|
||||
|
||||
// Add each cookie that has been returned in the response
|
||||
// If cookies need to be added/deleted or value changed, then add code here
|
||||
if ($strCookies!='') {
|
||||
//die('"'.$strCookies.'"');
|
||||
//echo $strCookies."\r\n";
|
||||
$cookies = explode("\n", $strCookies);
|
||||
// Create the basic header
|
||||
foreach($cookies as $this_cookie) {
|
||||
if (trim($this_cookie)<>'')
|
||||
array_push($this_header, 'Cookie: '.$this_cookie);
|
||||
}
|
||||
}
|
||||
|
||||
if ($postData!='') {
|
||||
if (is_array($postData))
|
||||
$post_data=$postData;
|
||||
|
||||
$o="";
|
||||
foreach ($post_data as $k=>$v)
|
||||
{
|
||||
$o.= "$k=".utf8_encode($v)."&";
|
||||
}
|
||||
$post_data=substr($o,0,-1);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
||||
//if in_array('',$this_header
|
||||
/*array_push($this_header, "Content-type: application/x-www-form-urlencoded");
|
||||
array_push($this_header, "Content-Length: 44");*/
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
|
||||
//print_r($this_header);
|
||||
|
||||
$page=curl_exec($ch);
|
||||
$response = parse_response($page);
|
||||
if ($debug){
|
||||
$url2=str_replace('http://', '', $url);
|
||||
$url2=str_replace('/', '_', $url2);
|
||||
$url2=str_replace('?', '(param)', $url2);
|
||||
$url2=str_replace('&', '(et)', $url2);
|
||||
|
||||
|
||||
$fp=fopen('/var/www/_includes/partenaires/insee/'. date('Ymd-His') .'-'. microtime_float(true) .'-'. $url2 . '.html', 'a');
|
||||
fwrite($fp, $url."\r\n");
|
||||
fwrite($fp, $page);
|
||||
fclose($fp);
|
||||
//echo strip_tags(html_entity_decode($response['body']), '<td>');
|
||||
}
|
||||
//print_r(curl_getinfo($ch));
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
function rechercheTelephone($raisonSociale='', $adresse='', $localite='', $departement='', $activite='') {
|
||||
|
||||
$response1=getUrl(SITE_PJ.'pj.cgi?', '', '', '', true, HOST_PJ);
|
||||
//print_r($response1['header']['Set-cookie']);
|
||||
$pageHtml=$response1['body'];
|
||||
$SESSION_ID=getTextInHtml($pageHtml, '<input type="hidden" name="SESSION_ID" value="', ' value="', '">');
|
||||
$VID=getTextInHtml($pageHtml, '<input type="hidden" name="VID" value="', ' value="', '">');
|
||||
$e_cookie=getTextInHtml($pageHtml, '<noscript><img ALT="" src="http://e.pagesjaunes.fr/m/web/', 'src="', '" BORDER=0 width=1 height=1></noscript>');
|
||||
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/pji.css', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/pji_PJ.css', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/script_open.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/alerte.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/script_VED.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'sitecrm/popup.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/AUTOPROMO_PJ_banniere_activite/hotel_pj.swf?clickTAG=http://sbx.pagesjaunes.fr/RealMedia/ads/click_lx.ads/www.pagesjaunes.fr/GENERAL/GENERAL/PJ/1238513556/Top/OasDefault/AUTOPROMO_PJ_banniere_activite/hotel_pj.html/61633130323433353434346339306330?', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/script_VED.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/anim_HP_v2-04-2006.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/visuels_webcam.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/visuels_photo.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/visuels_trafic.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/Edito_webcams/new_04-2006.jpg', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://e.pagesjaunes.fr/js/m.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
|
||||
$response2=getUrl($e_cookie, $response1['header']['Set-cookie'], '', SITE_PJ, true, HOST_PJ);
|
||||
|
||||
$cookies=$response1['header']['Set-cookie'] . $response2['header']['Set-Cookie'];
|
||||
|
||||
$input_image=$VALID_ARR=$NUM_RUE=$NEW_DEPARTEMENT=$OBJ_GEO='';
|
||||
|
||||
// Requête d'interrogation
|
||||
$postData=array(
|
||||
'ACTIVITE_VALIDATED_ASCII'=>'',
|
||||
'ID_THEME_SDE'=>'',
|
||||
'LISTE_RUB_AVEC_THEME'=>'',
|
||||
'input_image'=>$input_image,
|
||||
|
||||
'FRM_ACTIVITE'=>$activite,
|
||||
'FRM_NOM'=>$raisonSociale,
|
||||
'FRM_ADRESSE'=>$adresse,
|
||||
'FRM_LOCALITE'=>$localite,
|
||||
'FRM_DEPARTEMENT'=>$departement,
|
||||
|
||||
'JF_INSCRIPTIONS_REQ.x'=>'25',
|
||||
'JF_INSCRIPTIONS_REQ.y'=>'4',
|
||||
'faire'=>'decode_input_image',
|
||||
'DEFAULT_ACTION'=>'jf_inscriptions_req',
|
||||
'SESSION_ID'=>$SESSION_ID,
|
||||
'VID'=>$VID,
|
||||
'INFO_VILLE'=>'non',
|
||||
'CODE_LOC_INFO_VILLE'=>'00000000',
|
||||
'IV_ACTIVATION'=>'oui',
|
||||
'lang'=>'FR',
|
||||
'pays'=>'FR',
|
||||
'srv'=>'PJ',
|
||||
'TYPE_RECHERCHE'=>'ZZZ');
|
||||
//print_r($postData);//die();
|
||||
sleep(1);
|
||||
$response=getUrl(SITE_PJ, $cookies, $postData, SITE_PJ, true, HOST_PJ);
|
||||
$pageHtml=$response['body'];
|
||||
|
||||
if (count($tabNT=getTabListeNonTrouve($pageHtml))>0)
|
||||
{
|
||||
// Pas de réponses pour ces critères
|
||||
// Il faut élargir la recherche !
|
||||
$tabNTk=array_keys($tabNT);
|
||||
$input_image=$tabNT[0];
|
||||
$DEFAULT_ACTION='inscriptions_req';
|
||||
$NEW_DEPARTEMENT=getTextInHtml($pageHtml, '<input type="hidden" name="NEW_DEPARTEMENT" value="', 'value="', '">');
|
||||
$OBJ_GEO=getTextInHtml($pageHtml, '<input type=hidden name=OBJ_GEO value="', 'value="', '">');
|
||||
}
|
||||
elseif (count($tabGU=getTabListeGU($pageHtml))>0)
|
||||
{
|
||||
// Plusieurs Adresses possibles pour l'adresse donnée
|
||||
// print_r($tabGU);
|
||||
$input_image=getBonneAdresse($adresse, $tabGU);
|
||||
$DEFAULT_ACTION='jf_inscriptions_req';
|
||||
$VALID_ARR=getTextInHtml($pageHtml, '<input type=hidden name=VALID_ARR value="', 'value="', '">');
|
||||
$NUM_RUE=getTextInHtml($pageHtml, '<input type=hidden name=NUM_RUE value="', 'value="', '">');
|
||||
}
|
||||
|
||||
if ($input_image<>'') {
|
||||
$CODE_LOC_INFO_VILLE=getTextInHtml($pageHtml, '<input type="hidden" name="CODE_LOC_INFO_VILLE" value="', 'value="', '">');
|
||||
|
||||
$postData=array(
|
||||
'GEO_DEP'=>'', // New
|
||||
'faire'=>'decode_input_image',
|
||||
'DEFAULT_ACTION'=>$DEFAULT_ACTION,
|
||||
'input_image'=>$input_image,// diff
|
||||
'SESSION_ID'=>$SESSION_ID,
|
||||
'VID'=>$VID,
|
||||
'INFO_VILLE'=>'oui', // non dans la recherche préc.
|
||||
'CODE_LOC_INFO_VILLE'=>$CODE_LOC_INFO_VILLE, // diff
|
||||
'IV_ACTIVATION'=>'oui',
|
||||
'lang'=>'FR',
|
||||
'pays'=>'FR',
|
||||
'srv'=>'PJ',
|
||||
'TYPE_RECHERCHE'=>'CLOC', // ZZZ
|
||||
'SAV_ADRESSE'=>$adresse, //
|
||||
'SAV_LOCALITE'=>$localite, // New
|
||||
'SAV_DEPARTEMENT'=>$departement, //
|
||||
'FRM_NOM'=>$raisonSociale,
|
||||
'FRM_ADRESSE'=>$adresse,
|
||||
'FRM_LOCALITE'=>$localite,
|
||||
'FRM_DEPARTEMENT'=>$departement,
|
||||
|
||||
'FRM_TYPE_PUB'=>'TOUS',
|
||||
'RP_FORM'=>'',
|
||||
'VALID_LOC'=>$CODE_LOC_INFO_VILLE,
|
||||
'VALID_ARR'=>$VALID_ARR,
|
||||
'NUM_RUE'=>$NUM_RUE,
|
||||
'test_flash'=>'',
|
||||
'ESPLUS'=>'',
|
||||
'NEW_DEPARTEMENT'=>$NEW_DEPARTEMENT,
|
||||
'OBJ_GEO'=>$OBJ_GEO,
|
||||
);
|
||||
print_r($postData);
|
||||
sleep(1);
|
||||
$response=getUrl(SITE_PJ, $cookies, $postData, SITE_PJ, true, HOST_PJ);
|
||||
$pageHtml=$response['body'];
|
||||
}
|
||||
|
||||
$nbReponses=trim(getTextInHtml($pageHtml, '<tr><td align="left" class=txtrequetetotal valign=middle nowrap><b>', '<b>', 'réponse(s)</b></td>'));
|
||||
$tabRep=getTabResponses($pageHtml);
|
||||
|
||||
if (count($tabRep)==$nbReponses)
|
||||
return $tabRep;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function getTabResponses($pageHtml) {
|
||||
|
||||
$tabRepTmp=explode ('class=fdinscr', $pageHtml);
|
||||
$tabRep=array();
|
||||
foreach($tabRepTmp as $key => $value)
|
||||
{
|
||||
if ($key>0) {
|
||||
$raisonSociale=getTextInHtml($value, 'class=fdrsinscr', '<b>', '</b>');
|
||||
$ligneAdresse=html_entity_decode(getTextInHtml($value, '<td align="left" class=txtinscr ><b>', '<b>', '|'));
|
||||
$tabligneAdresse=explode('<br>', $ligneAdresse);
|
||||
$ligneAdresse1=strip_tags($tabligneAdresse[0]);
|
||||
$ligneAdresse2=strip_tags($tabligneAdresse[1]);
|
||||
$dispoPlan =(bool)(strpos($value, '<b>Plan</b>'));
|
||||
$dispoIti =(bool)(strpos($value, '<b>Itinéraire</b>'));
|
||||
$dispoPhoto =(bool)(strpos($value, '<b>Photo</b>'));
|
||||
$dispoWeb =(bool)(strpos($value, '<b>Site</b></a> '));
|
||||
$lienWeb=getTextInHtml($value, '<a target="_blank" href="http://www.pagesjaunes.fr/CGI/MOD?', 'href="', '" ');
|
||||
$page=getUrl($lienWeb, '', '', '', true);
|
||||
$lienWeb=$page['header']['Location'];
|
||||
|
||||
/*echo "Enreg n°$key : RS='$raisonSociale'\r\n";
|
||||
echo "Enreg n°$key : Adresse1='$ligneAdresse1'\r\n";
|
||||
echo "Enreg n°$key : Adresse2='$ligneAdresse2'\r\n";
|
||||
echo "Enreg n°$key : Plan ?='$dispoPlan'\r\n";
|
||||
echo "Enreg n°$key : Itineraire ?='$dispoIti'\r\n";
|
||||
echo "Enreg n°$key : Photo ?='$dispoPhoto'\r\n";
|
||||
echo "Enreg n°$key : Web ?='$dispoWeb'\r\n";
|
||||
echo "Enreg n°$key : Site WEB='$lienWeb'\r\n\r\n";*/
|
||||
array_push($tabRep, array( 'raisonSociale' =>$raisonSociale,
|
||||
'AdresseLigne1' =>$ligneAdresse1,
|
||||
'AdresseLigne2' =>$ligneAdresse2,
|
||||
'Dispo_Plan' =>$dispoPlan,
|
||||
'Dispo_Iti' =>$dispoIti,
|
||||
'Dispo_Photo' =>$dispoPhoto,
|
||||
'Dispo_Web' =>$dispoWeb,
|
||||
'LienWeb' =>$lienWeb));
|
||||
}
|
||||
}
|
||||
return $tabRep;
|
||||
}
|
||||
|
||||
function getBonneAdresse($adresse, $tabGU) {
|
||||
|
||||
// tableau de mots à vérifier
|
||||
$words = array_keys($tabGU);
|
||||
|
||||
// aucune distance de trouvée pour le moment
|
||||
$shortest = -1;
|
||||
|
||||
// boucle sur les des mots pour trouver le plus près
|
||||
foreach ($words as $word) {
|
||||
|
||||
// calcule la distance avec le mot mis en entrée,
|
||||
// et le mot courant
|
||||
$lev = levenshtein($adresse, $word);
|
||||
|
||||
// cherche une correspondance exacte
|
||||
if ($lev == 0) {
|
||||
|
||||
// le mot le plus près est celui-ci (correspondance exacte)
|
||||
$closest = $word;
|
||||
$shortest = 0;
|
||||
|
||||
// on sort de la boucle ; nous avons trouvé une correspondance exacte
|
||||
break;
|
||||
}
|
||||
|
||||
// Si la distance est plus petite que la prochaine distance trouvée
|
||||
// OU, si le prochain mot le plus près n'a pas encore été trouvé
|
||||
if ($lev <= $shortest || $shortest < 0) {
|
||||
// définission du mot le plus près ainsi que la distance
|
||||
$closest = $word;
|
||||
$shortest = $lev;
|
||||
}
|
||||
}
|
||||
/*
|
||||
echo "Mot entré : $adresse\n";
|
||||
if ($shortest == 0) {
|
||||
echo "Correspondance exacte trouvée : $closest\n";
|
||||
} else {
|
||||
echo "Vous voulez dire : $closest ?\n";
|
||||
}*/
|
||||
return $tabGU[$closest];
|
||||
}
|
||||
?>
|
548
library/Metier/common/insee.class.php
Normal file
548
library/Metier/common/insee.class.php
Normal file
@ -0,0 +1,548 @@
|
||||
<?
|
||||
class Insee {
|
||||
}
|
||||
|
||||
function getDataEtablissement($pageHtml)
|
||||
{
|
||||
global $libelleErreur;
|
||||
|
||||
$responseSiege=$pageHtml;
|
||||
$tabRet=array();
|
||||
|
||||
// On recherche si on est sur un établissement siège ou secondaire
|
||||
$pos=strpos($pageHtml, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Etablissement</B>');
|
||||
if ($pos>0)
|
||||
$tabRet['typeEtablissement']='secondaire';
|
||||
|
||||
$pos=strpos($pageHtml, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche siège</B>');
|
||||
if ($pos>0)
|
||||
$tabRet['typeEtablissement']='siège';
|
||||
|
||||
// Recherche Dernière MAJ / Activité
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="2">(dernière mise à jour :');
|
||||
if ($pos>0) {
|
||||
$tabRet['dateMAJ']=substr($responseSiege, $pos+51, 10);
|
||||
$tabRet['dateAbsActivite']='';
|
||||
$tabRet['active']='O';
|
||||
} else {
|
||||
$tabRet['active']='N';
|
||||
$tabRet['dateMAJ']='';
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="2">Absence d\'activité notée le : ');
|
||||
if ($pos>0) $tabRet['dateAbsActivite']=substr($responseSiege, $pos+78, 10);
|
||||
else {
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="2">Absence d\'activité');
|
||||
if ($pos>0) $tabRet['dateAbsActivite']='';
|
||||
}
|
||||
}
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>n° SIRET :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
$tabRet['siret']=str_replace(' ', '', html_entity_decode(substr($responseSiege, $pos+97, 32)));
|
||||
|
||||
$pos=strpos($responseSiege, 'size="-1"> <B>Date de création :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseSiege, '</font>', $pos+109);
|
||||
$tabRet['dateCreation']=str_replace(' ', '', html_entity_decode(substr($responseSiege, $pos+109, $posFin-($pos+109))));
|
||||
}
|
||||
else $tabRet['dateCreation']='';
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$len=127;
|
||||
if ($pos==0){
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$len=122;
|
||||
if ($pos==0){
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$len=126;
|
||||
$libelleErreur='Informations INSEE non diffusables';
|
||||
}
|
||||
}
|
||||
if ($libelleErreur=='') {
|
||||
//LARGE*DOMINIQUE MICHEL/ <BR>GERANT SARL BIMAGIQUE </font>
|
||||
$posFin=strpos($responseSiege, '</font>', $pos+$len);
|
||||
$raisonSocialeStr=trim(substr($responseSiege, $pos+$len, $posFin-($pos+$len)));
|
||||
$raisonSocialeTabLigne=explode('<BR>', $raisonSocialeStr);
|
||||
$tabRet['raisonSociale']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[0])));
|
||||
$tabRet['Enseigne']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[1])));
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Activité principale :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$tabRet['NafCode']=substr($responseSiege, $pos+120, 4);
|
||||
$tabRet['NafLib']=trim(substr($responseSiege, $pos+137, 70));
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Adresse :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$posFin=strpos($responseSiege, '</font>', $pos+103);
|
||||
$AdresseStr=substr($responseSiege, $pos+103, $posFin-($pos+103));
|
||||
$AdresseTabLigne=explode('<BR>', $AdresseStr);//'
|
||||
$tabRet['AdresseLigne1']=str_replace(' ', '/', $AdresseTabLigne[0]);
|
||||
$tabRet['AdresseLigne2']=str_replace(' ', '/', $AdresseTabLigne[1]);
|
||||
$tabRet['AdresseLigne3']=str_replace(' ', '/', $AdresseTabLigne[2]);
|
||||
/*
|
||||
$AdresseNum=$AdresseTabLigne1[0];
|
||||
$AdresseVoi=$AdresseTabLigne1[1];
|
||||
$AdresseRue=$AdresseTabLigne1[2];
|
||||
$AdresseCP=$AdresseTabLigne2[0];
|
||||
$AdresseVille=$AdresseTabLigne2[1];
|
||||
*/
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="-1"><b>L\'entreprise est connue au répertoire comme ');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseSiege, '</b>', $pos+106);
|
||||
$tabRet['etatJuridique']=html_entity_decode(substr($responseSiege, $pos+106, $posFin-($pos+106)));
|
||||
$tabRet['dateEtatJuridique']='';
|
||||
} else {
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="-1"><b>L\'entreprise est cessée le : ');
|
||||
$tabRet['dateEtatJuridique']=substr($responseSiege, $pos+86, 10);
|
||||
$tabRet['etatJuridique']='cessée';
|
||||
}
|
||||
//echo 'GetDataEtab="'.$libelleErreur."\"\r\n";
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getDataEntreprise($pageHtml)
|
||||
{
|
||||
global $libelleErreur;
|
||||
|
||||
$responseEntreprise=$pageHtml;
|
||||
$tabRet=array();
|
||||
|
||||
if ($libelleErreur=='') {
|
||||
|
||||
$pos=strpos($responseEntreprise, 'size="-1"> <B>Date de création :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
if ($pos>0)
|
||||
$tabRet['dateCreationEntrep']=substr($responseEntreprise, $pos+109, 10);
|
||||
else
|
||||
$tabRet['dateCreationEntrep']='';
|
||||
|
||||
// Raison sociale et Sigle
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Raison sociale et Sigle :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$posFin=strpos($responseEntreprise, '</font>', $pos+123);
|
||||
$raisonSocialeStr=trim(substr($responseEntreprise, $pos+123, $posFin-($pos+123)));
|
||||
$raisonSocialeTabLigne=explode('<BR>', $raisonSocialeStr);
|
||||
$tabRet['raisonSocialeEntrep']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[0])));
|
||||
$tabRet['sigle']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[1])));
|
||||
|
||||
// Activité prinicpale Entrep
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Activité principale :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$tabRet['NafCodeEntrep']=substr($responseEntreprise, $pos+120, 4);
|
||||
$tabRet['NafLibEntrep']=trim(substr($responseEntreprise, $pos+137, 70));
|
||||
|
||||
// Forme Juridique
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Forme juridique :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$tabRet['FJCodeEntrep']=substr($responseEntreprise, $pos+116, 4);
|
||||
$tabRet['FJLibEntrep']=trim(substr($responseEntreprise, $pos+133, 70));
|
||||
|
||||
// Nb Etab Actifs
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Nb établissements actifs :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
$posFin=strpos($responseEntreprise, '</font>', $pos+118);
|
||||
$tabRet['nbEtabActifs']=trim(str_replace(' ', '', html_entity_decode(substr($responseEntreprise, $pos+118, $posFin-($pos+118)))));
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
/*
|
||||
* parseHtml.php
|
||||
* Author: Carlos Costa Jordao
|
||||
* Email: carlosjordao@yahoo.com
|
||||
*
|
||||
* My notation of variables:
|
||||
* i_ = integer, ex: i_count
|
||||
* a_ = array, a_html
|
||||
* b_ = boolean,
|
||||
* s_ = string
|
||||
*
|
||||
* What it does:
|
||||
* - parses a html string and get the tags
|
||||
* - exceptions: html tags like <br> <hr> </a>, etc
|
||||
* - At the end, the array will look like this:
|
||||
* ["IMG"][0]["SRC"] = "xxx"
|
||||
* ["IMG"][1]["SRC"] = "xxx"
|
||||
* ["IMG"][1]["ALT"] = "xxx"
|
||||
* ["A"][0]["HREF"] = "xxx"
|
||||
*
|
||||
*/
|
||||
function parseHtml( $s_str )
|
||||
{
|
||||
$i_indicatorL = 0;
|
||||
$i_indicatorR = 0;
|
||||
$s_tagOption = '';
|
||||
$i_arrayCounter = 0;
|
||||
$a_html = array();
|
||||
// Search for a tag in string
|
||||
while( is_int(($i_indicatorL=strpos($s_str,'<',$i_indicatorR))) ) {
|
||||
// Get everything into tag...
|
||||
$i_indicatorL++;
|
||||
$i_indicatorR = strpos($s_str,'>', $i_indicatorL);
|
||||
$s_temp = substr($s_str, $i_indicatorL, ($i_indicatorR-$i_indicatorL) );
|
||||
$a_tag = explode( ' ', $s_temp );
|
||||
// Here we get the tag's name
|
||||
list( ,$s_tagName,, ) = each($a_tag);
|
||||
$s_tagName = strtoupper($s_tagName);
|
||||
// Well, I am not interesting in <br>, </font> or anything else like that...
|
||||
// So, this is false for tags without options.
|
||||
$b_boolOptions = is_array(($s_tagOption=each($a_tag))) && $s_tagOption[1];
|
||||
if( $b_boolOptions ) {
|
||||
// Without this, we will mess up the array
|
||||
$i_arrayCounter = (int)count($a_html[$s_tagName]);
|
||||
// get the tag options, like src="htt://". Here, s_tagTokOption is 'src' and s_tagTokValue is '"http://"'
|
||||
|
||||
do {
|
||||
$s_tagTokOption = strtoupper(strtok($s_tagOption[1], "="));
|
||||
$s_tagTokValue = trim(strtok("="));
|
||||
$a_html[$s_tagName][$i_arrayCounter][$s_tagTokOption] =
|
||||
$s_tagTokValue;
|
||||
$b_boolOptions = is_array(($s_tagOption=each($a_tag))) &&
|
||||
$s_tagOption[1];
|
||||
} while( $b_boolOptions );
|
||||
}
|
||||
}
|
||||
return $a_html;
|
||||
}
|
||||
|
||||
function getDataEntrepriseRNCS($pageHtml) {
|
||||
|
||||
global $libelleErreur;
|
||||
|
||||
$tabRet=array();
|
||||
|
||||
// Liste et liens vers les Bilans
|
||||
$tabRet['tabListeBilans']=getTabListeBilans($pageHtml);
|
||||
$tabRet['raisonSociale']=getTextInHtml($pageHtml, '<td align="left" valign="top"><span class="boldred"><br>', '<br>', '</span>');
|
||||
$tabRet['RCS']=getTextInHtml($pageHtml, '<span class="textarial">RCS ', 'RCS ', '</span>', true);
|
||||
$tabRet['activite']=getTextInHtml($pageHtml, '<td width="185" align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Activité</td>', 'class="basictext">', '</td>');
|
||||
$tabRet['adresseSiege']=getTextInHtml($pageHtml, '<td align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Siège
|
||||
social</td>', 'class="basictext">', '</td>');
|
||||
print_r($tabRet);
|
||||
die();
|
||||
// Capital social
|
||||
|
||||
// Chiffre d'affaires
|
||||
|
||||
// Date CA
|
||||
|
||||
// Effectif
|
||||
|
||||
// Forme Juridique
|
||||
|
||||
// Nationalité
|
||||
|
||||
// Activité
|
||||
|
||||
// Siège social
|
||||
/*
|
||||
<tr>
|
||||
<td bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Siège
|
||||
social</td>
|
||||
<td bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
|
||||
<td align="left" valign="top" bgcolor="#EBF0F5" class="basictext">75 Avenue la Grande Armee<br>
|
||||
75116 PARIS 16 </td>
|
||||
</tr>
|
||||
</table>
|
||||
<div align="center"><img src="../images/degrade580grey.jpg" width="580" height="12"><br>
|
||||
<br>
|
||||
</div>
|
||||
<table width="600" border="0" cellspacing="0" cellpadding="0">
|
||||
|
||||
<tr>
|
||||
<td align="left" valign="top"><img src="../images/arrowsmallblue.gif" width="9" height="10"><span class="boldtextarialblue15">Renseignements
|
||||
juridiques</span></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="580" border="0" align="center" cellpadding="1" cellspacing="2">
|
||||
|
||||
|
||||
<tr align="left" valign="top">
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
|
||||
<td width="185" bgcolor="#FFFFFF" class="boldtextarial">Forme
|
||||
juridique</td>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="385" bgcolor="#EBF0F5" class="basictext">SA à conseil d'administration</td>
|
||||
</tr>
|
||||
|
||||
<tr align="left" valign="top">
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="185" bgcolor="#FFFFFF" class="boldtextarial">Capital social</td>
|
||||
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="385" bgcolor="#EBF0F5" class="basictext">171.285.000,00
|
||||
EURO</td>
|
||||
</tr>
|
||||
|
||||
<tr align="left" valign="top">
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="185" bgcolor="#FFFFFF" class="boldtextarial">Nationalité</td>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td bgcolor="#EBF0F5" class="basictext">France</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<div align="center"><img src="../images/degrade580grey.jpg" width="580" height="12"><br>
|
||||
<br>
|
||||
</div>
|
||||
<div align="center">
|
||||
<table width="588" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="210" align="left" valign="top"><img src="../images/arrowsmallblue.gif" width="9" height="10"><span class="boldtextarialblue15">Chiffres
|
||||
clés</span></td>
|
||||
|
||||
<td width="378" align="left" valign="top" class="smalltext">au 31-12-2004</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="580" border="0" align="center" cellpadding="1" cellspacing="2">
|
||||
<tr>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="185" align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Chiffre
|
||||
d'affaires</td>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
|
||||
<td width="385" align="left" valign="top" bgcolor="#EBF0F5" class="basictext">18.049.000.000
|
||||
EU</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="185" align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Effectif</td>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="385" align="left" valign="top" bgcolor="#EBF0F5" class="basictext">De 5150 à 5720</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<div align="center"><img src="../images/degrade580grey.jpg" width="580" height="12"><br>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
<table width="600" border="0" cellspacing="2" cellpadding="0">*/
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getDataEcoCoface($pageHtml) {
|
||||
|
||||
global $libelleErreur;
|
||||
|
||||
$tabRet=array();
|
||||
|
||||
// SIREN
|
||||
$pos=strpos($pageHtml, '<b><font class="nota">La forme juridique ou la date de création trop récente de l\'entreprise ne nous permettant pas d\'obtenir suffisamment d\'informations, nous vous offrons ce produit.</font></b>');
|
||||
if ($pos>0) {
|
||||
$tabRet['infoEco']='OUI';
|
||||
$tabRet['societeInactive']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Société inactive</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$strCapital=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Capital   (', '(', '</tr><tr>');
|
||||
$tabTmp=explode('</td>', $strCapital);
|
||||
$tabRet['capital_source']=str_replace(')', '', $tabTmp[0]);
|
||||
$tabTmp=explode(' ', $tabTmp[1]);
|
||||
$tabRet['capital_montant']=str_replace(chr(160), '', trim(strip_tags($tabTmp[0])));
|
||||
$tabRet['capital_devise']=trim(strip_tags($tabTmp[1]));
|
||||
$tabRet['dateCreation']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Date de création</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['formeJuridique']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Forme juridique</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['cotationBourse']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Cotation en bourse</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['effectifSociete']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Effectif société</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['activite']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Activité</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
|
||||
$tabRet['sigle']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Sigle</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['enseigne']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Enseigne</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
|
||||
// Dirigeants
|
||||
$strDir=@getTextInHtml($pageHtml, '<td class="tabtot">IDENTITE</td>', '<td> </td>', '</table>');
|
||||
$tabDir=explode('</tr>', $strDir);
|
||||
$nbDir=1;
|
||||
foreach ($tabDir as $key => $dir)
|
||||
{
|
||||
$tabTmp=explode('<td bgcolor="#FFF3DE" class="tabval" > ', $dir);
|
||||
$typeDir=trim(strip_tags($tabTmp[0]));
|
||||
$nomDir=trim(strip_tags($tabTmp[1]));
|
||||
if ($typeDir<>'' && $typeDir<>'Date de création' && $typeDir<>'Forme juridique' && $typeDir<>'Cotation en bourse'
|
||||
&& $typeDir<>'Effectif société' && $typeDir<>'Société inactive' && $typeDir<>'Activité'
|
||||
&& $typeDir<>'Sigle' && $typeDir<>'Enseigne'
|
||||
&& substr($typeDir, 0, 8) <>'Capital ' )
|
||||
{
|
||||
//$tabDir['Produits'].=$produit.'/';
|
||||
//$produit=str_replace(' ','_',$produit);
|
||||
$tabRet['Dirigeant'.$nbDir.'Type']=trim($typeDir);
|
||||
$tabTmp=explode(' ', $nomDir);
|
||||
$tabRet['Dirigeant'.$nbDir.'Genre']=trim($tabTmp[0]);
|
||||
$tabRet['Dirigeant'.$nbDir.'Prenom']=trim($tabTmp[1]);
|
||||
$tabRet['Dirigeant'.$nbDir.'Nom']=trim($tabTmp[2]);
|
||||
$nbDir++;
|
||||
}
|
||||
}
|
||||
$tabRet['NbDirigeants']=$nbDir-1;
|
||||
|
||||
// Liens Financiers
|
||||
$strTmp=@getTextInHtml($pageHtml, '<td class="tabtot">LIENS FINANCIERS</td>', '<td> </td>', '</table>');
|
||||
if (strpos($strTmp, 'Néant')>0)
|
||||
$tabRet['LiensFinanciers']='Néant';
|
||||
else
|
||||
$tabRet['LiensFinanciers']='Présence liens';
|
||||
|
||||
// ELEMENTS FINANCIERS
|
||||
$strTmp=@getTextInHtml($pageHtml, '<td class="tabtot">ELEMENTS FINANCIERS</td>', '<td> </td>', '</table>');
|
||||
if (strpos($strTmp, 'Néant')>0)
|
||||
$tabRet['ElementsFinanciers']='Néant';
|
||||
else
|
||||
$tabRet['ElementsFinanciers']='Présence El.Fi.';
|
||||
}
|
||||
else
|
||||
$tabRet['infoEco']='NON';
|
||||
|
||||
//echo $pageHtml;
|
||||
//print_r($tabRet);
|
||||
//die();
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
|
||||
function getDataEntrepriseCoface($pageHtml) {
|
||||
|
||||
global $libelleErreur;
|
||||
|
||||
$tabRet=array();
|
||||
|
||||
// SIREN
|
||||
$tabRet['siren']=@getTextInHtml($pageHtml, 'portail/entreprise_identite/identite.asp?nsiren=', '?nsiren=', '&IMPRESSION=OUI');
|
||||
//$tabRet['siren']=@getTextInHtml($pageHtml, '<a href="http://www.coface.fr" target="_blank"> Qui sommes nous </a>-<a href="javascript:;" onClick="MM_openBrWindow(\'../mod_cofacescrl/part_recherche.asp?nscrl=18452&metier=ALL&geo=ALL&idnav=168d25840396c5f38f4
|
||||
$tabRet['nscrl']=@getTextInHtml($pageHtml, 'Plan du site </a>-<a href="http://www.coface.fr" target="_blank"> Qui sommes nous </a>-<a href="javascript:;" onClick="MM_openBrWindow(\'../mod_cofacescrl/part_recherche.asp?nscrl=', '?nscrl=', '&metier=ALL&geo=ALL&idnav=');
|
||||
|
||||
// Raison Sociale, Adresse et lien vers Géoloc
|
||||
$strRS_Adr=@getTextInHtml($pageHtml, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne"> <b> Raison sociale<br>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval"><b>', '</b></td>');
|
||||
$tabRS_Adr=explode('<br>', $strRS_Adr);
|
||||
$tabRet['raisonSociale']=trim($tabRS_Adr[0]);
|
||||
$tabRS_Adr1=explode(' ', $tabRS_Adr[1]);
|
||||
$tabRet['AdresseLigne1']=trim($tabRS_Adr1[0]);
|
||||
$tabRet['AdresseLigne2']=trim($tabRS_Adr1[1]);
|
||||
$tabRS_Adr1=explode(' ', $tabRS_Adr[2]);
|
||||
$tabRet['codePostal']=trim($tabRS_Adr1[0]);
|
||||
$tabRet['ville']=trim($tabRS_Adr1[1]);
|
||||
$tabRet['UrlGeoLoc']=@getTextInHtml($pageHtml, '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval"><a href="javascript:;" onClick="MM_openBrWindow(\'', 'onClick="MM_openBrWindow(\'', '\',\'Planfax');
|
||||
|
||||
// Téléphone / Fax
|
||||
$strTelFax=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne"><b>Téléphone<br>', '<td bgcolor="#FFF3DE" class="tabval" valign="top">', '</td>');
|
||||
$tabTelFax=explode('<br>', $strTelFax);
|
||||
$tabRet['tel']=trim($tabTelFax[0]);
|
||||
$tabRet['fax']=trim($tabTelFax[1]);
|
||||
|
||||
// Adresse Internet / Email
|
||||
$strInet=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne"><b>Adresse internet <br>', '<td bgcolor="#FFF3DE" class="tabval"><a class="tabval" HREF="', '</a></td>');
|
||||
$tabInet=explode('<br>', $strInet);
|
||||
$tabRet['web']=trim( @getTextInHtml($tabInet[0], ' target="_new">', '>', '</a>') );
|
||||
$tabRet['mail']=trim( @getTextInHtml($tabInet[1], ' href="mailto:', ':', '">') );
|
||||
|
||||
// Bourse
|
||||
$strBourse=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne"> <b>'."\r\n".' Code Sicovam<br>', '<td bgcolor="#FFF3DE" class="tabval">', '</td>');
|
||||
$tabBourse=explode('<br>', $strBourse);
|
||||
$tabRet['bourse_isin']=trim($tabBourse[0]);
|
||||
$tabRet['bourse_marche']=trim($tabBourse[1]);
|
||||
$tabRet['bourse_ville']=trim($tabBourse[2]);
|
||||
|
||||
// Activité
|
||||
$tabRet['activite']=trim(str_replace(' ', ' ', @getTextInHtml($pageHtml, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne" valign="top"><b>Libellé code activité </b></td>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval">', '</td>')));
|
||||
|
||||
// Produits disponibles
|
||||
$strDispos=@getTextInHtml($pageHtml, '<table border="0" cellpadding="0" cellspacing="0" width="98%"><tr><td class="normal"><b>Produits disponibles</b></td></tr><tr><td bgcolor="#E1D0B6"><img src="../images/vide.gif" border="0" height="1"><br></td></tr><tr><td><img src="../images/vide.gif" border="0" height="5"><br></td></tr></table>', '<table border="0" cellpadding="5" cellspacing="0" width="100%">', '</table>');
|
||||
$tabDispos=explode('<td align="left" width="25%"', $strDispos);
|
||||
$tabRet['Produits']='';
|
||||
foreach ($tabDispos as $key => $produit)
|
||||
{
|
||||
$produit=trim(str_replace('>', '', str_replace('nowrap>', '', strip_tags($produit))));
|
||||
if ($produit<>'' && $produit<>' ') {
|
||||
$tabRet['Produits'].=$produit.'/';
|
||||
$produit=str_replace(' ','_',$produit);
|
||||
$tabRet['Produit_'.$produit]='Oui';
|
||||
}
|
||||
}
|
||||
// print_r($tabRet);
|
||||
// die();
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
|
||||
function getTabListeBilans($pageHtml) {
|
||||
$tabUrl=array();
|
||||
$deb=$fin=0;
|
||||
while( is_int(($deb=strpos($pageHtml,'<a href="http://www.societe.com/cgi-bin/bilan?bil=',$fin))) ) {
|
||||
$deb=$deb+9;
|
||||
$fin = strpos($pageHtml,'</a>', $deb);
|
||||
$s_temp = substr($pageHtml, $deb, ($fin-$deb));
|
||||
//echo $s_temp."\r\n";
|
||||
$a_temp = explode('" class="basic">', $s_temp);
|
||||
$tabUrl[$a_temp[1]]=$a_temp[0];
|
||||
}
|
||||
return $tabUrl;
|
||||
}
|
||||
|
||||
function getTabListeGU($pageHtml) {
|
||||
$tabGU=array();
|
||||
$deb=$fin=0;
|
||||
/* <tr><td><img alt="" src="b.gi onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_PDR_SUP_LOC_REQ')">Lancer la recherche dans toute la localité</td></tr>
|
||||
<tr><td><img src="b.gif" alt="" border=0></td><td align="left" onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_INSCRIPTIONS_REQ')">Lancer la recherche sans l'adresse</td></tr>
|
||||
*/
|
||||
while( is_int(($deb=strpos($pageHtml,'<td onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class="txt9px" href="javascript:ChoixGeo(\'',$fin))) ) {
|
||||
$deb=$deb+122;
|
||||
$fin = strpos($pageHtml,'</td></tr>', $deb);
|
||||
$s_temp = substr($pageHtml, $deb, ($fin-$deb));
|
||||
//echo $s_temp."\r\n";
|
||||
$a_temp = explode('\')">', $s_temp);
|
||||
$tabGU[$a_temp[1]]=$a_temp[0];
|
||||
}
|
||||
return $tabGU;
|
||||
}
|
||||
|
||||
function getTabListeNonTrouve($pageHtml) {
|
||||
$tabGU=array();
|
||||
$deb=$fin=0;
|
||||
/* onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_PDR_SUP_LOC_REQ')">Lancer la recherche dans toute la localité</td></tr>
|
||||
onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_INSCRIPTIONS_REQ')">Lancer la recherche sans l'adresse</td></tr>
|
||||
*/
|
||||
while( is_int(($deb=strpos($pageHtml,'onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo(\'',$fin))) ) {
|
||||
$deb=$deb+116;
|
||||
$fin = strpos($pageHtml,'</td></tr>', $deb);
|
||||
$s_temp = substr($pageHtml, $deb, ($fin-$deb));
|
||||
//echo $s_temp."\r\n";
|
||||
$a_temp = explode('\')">', $s_temp);
|
||||
$tabGU[$a_temp[1]]=$a_temp[0];
|
||||
}
|
||||
return $tabGU;
|
||||
}
|
||||
/** Recherche un texte dans une page HTML
|
||||
**
|
||||
**/
|
||||
function getTextInHtml($pageHtml, $strToFind, $strDeb, $strEnd, $include_strDeb=false, $include_strEnd=false, $ltrim=true, $rtrim=true, &$fin, $nbOcc=1) {
|
||||
$tabRet=array();
|
||||
$deb=$nbOccTrouve=0;
|
||||
while( is_int(($deb=strpos($pageHtml,$strToFind,$fin))) ) {
|
||||
$deb++;
|
||||
$deb2 = strpos($pageHtml,$strDeb, $deb);
|
||||
$fin = strpos($pageHtml,$strEnd, $deb2);
|
||||
if (!$include_strDeb)
|
||||
$deb2+=strlen($strDeb);
|
||||
$s_temp = substr($pageHtml, $deb2, ($fin-$deb2));
|
||||
|
||||
if ($ltrim) $s_temp=ltrim($s_temp);
|
||||
if ($rtrim) $s_temp=rtrim($s_temp);
|
||||
|
||||
if ($nbOcc==1) return $s_temp;
|
||||
//echo $s_temp."\r\n";
|
||||
//$a_temp = explode('" class="basic">', $s_temp);
|
||||
$tabUrl[$nbOccTrouve]=$s_temp;
|
||||
$nbOccTrouve++;
|
||||
|
||||
if ($nbOcc==$nbOccTrouve) {
|
||||
// echo "j'ai trouvé le nb demandé, je sort\r\n";
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
return $tabUrl;
|
||||
/*<span class="mongrasvert">
|
||||
<li>Le type de voie a été modifié<br>
|
||||
<li>L'orthographe du mot directeur a été modifiée<br>
|
||||
<li>Le code postal a été forcé à partir du département et de la localité<br> </span>
|
||||
*/
|
||||
}
|
||||
?>
|
89
library/Metier/common/normad.class.php
Normal file
89
library/Metier/common/normad.class.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?
|
||||
//include('fonctions.php');
|
||||
//include('insee.class.php');
|
||||
define('HOST_NORMAD', 'www.normad.fr');
|
||||
define('SITE_NORMAD', 'http://'. HOST_NORMAD .'/');
|
||||
|
||||
//$normad2=new Normad('SCI BRYGE', 'Kervegant', '', '', '', '29', 'SCAER');
|
||||
|
||||
class Normad {
|
||||
/** Normalise l'adresse postale donnée en paramètre. Seule la ligne 1 qui devrait comporter la Raison Sociale ou le nom de l'expéditeur reste inchangée !
|
||||
** @param $adrL1 Obligatoirement le Nom ou la Raison Sociale du destinataire
|
||||
** @param $adrL2 Normalisation = Appart.,Bâtiment...
|
||||
** @param $adrL3 Normalisation = Résidence,Cité...
|
||||
** @param $adrL4 Normalisation = Num./Bis/Type voie/Nom voie
|
||||
** @param $adrL5 Normalisation = BP,TSA,Lieu-dit...
|
||||
** @param $codPos Code Postal (ou département)
|
||||
** @param $ville Ville (orthographe correcte si possible si pas de CP)
|
||||
** @return array
|
||||
**/
|
||||
function Normad ($adrL1, $adrL2, $adrL3, $adrL4, $adrL5, $codPos, $ville) {
|
||||
$adrL1 =substr(trim($adrL1) , 0, 40);
|
||||
$adrL2 =substr(trim($adrL2) , 0, 40);
|
||||
$adrL3 =substr(trim($adrL3) , 0, 40);
|
||||
$adrL4 =substr(trim($adrL4) , 0, 40);
|
||||
$adrL5 =substr(trim($adrL5) , 0, 40);
|
||||
$codPos=substr(trim($codPos), 0, 5);
|
||||
$ville =substr(trim($ville) , 0, 33);
|
||||
$postData=array( 'ad1'=>$adrL2, //htmlentities($adrL2),
|
||||
'ad2'=>$adrL3, //htmlentities($adrL3),
|
||||
'ad3'=>$adrL4, //htmlentities($adrL4),
|
||||
'ad4'=>$adrL5, //htmlentities($adrL5),
|
||||
'cod'=>$codPos,
|
||||
'loc'=>htmlentities($ville),
|
||||
'hiddenField'=>'GEN',);
|
||||
$tabHtml=getUrl(SITE_NORMAD.'traiter_adresse.php', '', $postData, SITE_NORMAD.'validez.php', true, HOST_NORMAD);
|
||||
$page=$tabHtml['body'];
|
||||
$posInHtml=0;
|
||||
$tabRet=array();
|
||||
|
||||
$retour=trim(str_replace(chr(173), '', getTextInHtml($page, '<td colspan=2><font face="Arial" size="2" color="#3F5A80"><b>', '<b>', '</b></font>', false, true, true, true, $posInHtml)));
|
||||
$retour=explode('[*', $retour);
|
||||
$tabRet['retour_code']=str_replace(']','',$retour[1]);
|
||||
$tabRet['retour_libelle']=trim($retour[0]);
|
||||
$tabRet['retour_messages']=getTextInHtml($page, '<li>', 'i>', '<br>', false, false, true, true, $posInHtml, 0);
|
||||
|
||||
// Récupération des Lignes d'adresse
|
||||
$tabRet['ligne1']=$adrL1;
|
||||
$tabRet['ligne2']=getTextInHtml($page, '<td class="gris2"><span class=grasnoir>Adresse en sortie :</span>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ligne3']=getTextInHtml($page, '<td class=pet align=right nowrap> Volet 2 : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ligne4']=getTextInHtml($page, '<td class=pet align=right nowrap> Volet ', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ligne5']=getTextInHtml($page, '<td class=pet align=right nowrap> Volet 4 : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['CP']=getTextInHtml($page, '<td class=pet align=right nowrap> CP : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ville']=getTextInHtml($page, '<td class=pet align=right nowrap> Localité : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ligne6']=$tabRet['CP'] .' '. $tabRet['ville'];
|
||||
|
||||
// Découpage de la rue
|
||||
$tabRet['voie_num']=getTextInHtml($page, '<span class=pet>Numéro ', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_btq']=getTextInHtml($page, '<span class=pet>Bis/Ter/Quater/...', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_type']=getTextInHtml($page, '<span class=pet>Type', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_denom']=getTextInHtml($page, '<span class=pet>Dénomination', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_motDir']=getTextInHtml($page, 'directeur :</span> ', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_matric']=getTextInHtml($page, '<span class=pet>Matricule voie :</span>', '</span>', '<br>', false, true, true, true, $posInHtml);
|
||||
$tabRet['code_insee_commune']=getTextInHtml($page, '<span class=pet>Code INSEE commune :</span>', '</span>', '<br>', false, true, true, true, $posInHtml);
|
||||
|
||||
print_r($tabRet);
|
||||
//echo "$voie_num\r\n$voie_btq\r\n$voie_type\r\n$voie_denom\r\n$voie_motDir\r\n$voie_matric\r\n$code_insee_commune\r\n";
|
||||
}
|
||||
|
||||
/*
|
||||
<td class="gris2" valign=top><span class=grasnoir>Détails :</span><br>
|
||||
|
||||
00441644 <br>
|
||||
|
||||
28074 <br>
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr size=1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=3><p class="gris2" align="justify"> </p>
|
||||
<p class="mongrasvert" align="right"> Référentiels
|
||||
d'avril 2006 </p>
|
||||
*/
|
||||
|
||||
} ?>
|
170
library/Metier/common/paramCotation.inc
Normal file
170
library/Metier/common/paramCotation.inc
Normal file
@ -0,0 +1,170 @@
|
||||
<?PHP
|
||||
|
||||
$this->tabNotation['A+']=array('Exceptionnel', 'A3++', 'Aaa' ,'AAA' ,'0.001');
|
||||
$this->tabNotation['A'] =array('Excellent', 'A3+', 'Aa1 Aa2 Aa3' ,'AA+ AA AA-' ,'0.01');
|
||||
$this->tabNotation['B+']=array('Très bon', '3++', 'A1' ,'A+' ,'0.02');
|
||||
$this->tabNotation['B'] =array('Bon', '3+', 'A2 A3' ,'A A-' ,'0.04');
|
||||
$this->tabNotation['C+']=array('Assez bon', '3', 'Baa1' ,'BBB+' ,'0.15');
|
||||
$this->tabNotation['C'] =array('Acceptable', '3', 'Baa2' ,'BBB' ,'0.30');
|
||||
$this->tabNotation['C-']=array('Moyen', '3', 'Baa3' ,'BBB-' ,'0.60');
|
||||
$this->tabNotation['D+']=array('Passable', '4+', 'Ba1' ,'BB+' ,'0.90');
|
||||
$this->tabNotation['D'] =array('Médiocre', '4', 'Ba2' ,'BB' ,'1.25');
|
||||
$this->tabNotation['D-']=array('Très médiocre', '4', 'Ba3' ,'BB-' ,'1.60');
|
||||
$this->tabNotation['E+']=array('Mauvais (sous surveillance)', '5', 'B1 B2 B3', 'B+ B B-', '5.00');
|
||||
$this->tabNotation['E'] =array('Très mauvais (sensible, sans incident)', '6', 'Caa', 'CCC', '14.00');
|
||||
$this->tabNotation['E-']=array('Très mauvais (sensible avec incidents)', '8', 'Ca C', 'CC C', '17.00');
|
||||
$this->tabNotation['F'] =array('En défaut, hors procédures judiciaires (douteux)', '8 9', 'D', 'D', 'Défaut');
|
||||
$this->tabNotation['Z'] =array('En défaut, avec procédures judiciaires ou contentieuses (douteux)', 'P', '', '', 'Défaut');
|
||||
|
||||
$this->tabLibActivite[0]='';
|
||||
$this->tabLibActivite[15]='Industries Alimentaires : Collecte Appro';
|
||||
$this->tabLibActivite[3]='Industries Alimentaires : Collecte et 1ère transformation';
|
||||
$this->tabLibActivite[5]='Industries Alimentaires : Eaux de vie et Champagne';
|
||||
$this->tabLibActivite[2]='Industries Alimentaires : Autres activités';
|
||||
$this->tabLibActivite[6]='Industries extractives / Production Distribution : Énergie Eau';
|
||||
$this->tabLibActivite[7]='Construction - BTP';
|
||||
$this->tabLibActivite[1]='Industries Manufacturières';
|
||||
$this->tabLibActivite[8]='Négoce';
|
||||
$this->tabLibActivite[4]='Commerce de Gros';
|
||||
$this->tabLibActivite[9]='Commerce Distribution';
|
||||
$this->tabLibActivite[10]='Grande Distribution';
|
||||
$this->tabLibActivite[12]='Transports';
|
||||
$this->tabLibActivite[13]='Media Technologie de l\'information';
|
||||
$this->tabLibActivite[14]='Services';
|
||||
$this->tabLibActivite[11]='Hôtellerie et Loisirs / Activités immobilières';
|
||||
$this->tabLibActivite[16]='Banques. Assurances. Activités financières';
|
||||
$this->tabLibActivite[17]='Agriculture. Sylviculture. Pêche. Aquaculture';
|
||||
|
||||
$this->tabActivite[15]=array('512A');
|
||||
$this->tabActivite[3]=array('151A','151C','152','153E','155','157','159G','159J','159N','159Q');
|
||||
$this->tabActivite[5]=array('159A','159F');
|
||||
$this->tabActivite[2]=array('151E','151F','153A','153C','153F','154','156','158','159B','159D','159L','159S','159T');
|
||||
$this->tabActivite[6]=array('11','10','12','13','14','401','402','403','410');
|
||||
$this->tabActivite[7]=array('451','452','453','454','455');
|
||||
$this->tabActivite[1]=array('251','252','241','242','243','245','246','247','261','262','263','264','265','266','267','268','244','297','300','311','312','313','314','315','316','321','322','323','17','18','19','20','21','271','272','273','274','275','281','282','283','284','285','286','287','291','292','293','294','295','296','341','342','343','353','351','352','354','355','223','331','332','333','334','335','361','362','363','364','365','366','231','232','233','222','371','372');
|
||||
$this->tabActivite[8]=array();
|
||||
$this->tabActivite[4]=array('511A','511N','511P','512C','512E','512G','512J','513','511C','515A','515C','511E','511G','511J','511L','511R','511T','511U','514','515E','515F','515H','515J','515L','515N','515Q','516','517');
|
||||
$this->tabActivite[9]=array('501','502','503','504','505','521A','521B','521C','521J','522','523','524A','524C','524E','524F','524H','524J','524L','524N','524R','524T','524U','524V','524W','524X','524Y','524Z','525','526');
|
||||
$this->tabActivite[10]=array('521D','521E','521F','521H','524P');
|
||||
$this->tabActivite[12]=array('621','622','623','611','612','602','603','631','632','634','634B','634C','634A','641');
|
||||
$this->tabActivite[13]=array('221','722','721','723','724','725','726','924','642','922','921');
|
||||
$this->tabActivite[14]=array('703','712E','711','712A','713','714','712C','741A','741C','741E','741G','742','743','741J','744','745','746','747','748','900','633','801','802','803','804','851','852','853','930','911','912','913','527','950');
|
||||
$this->tabActivite[11]=array('923','925','926','927','551','552','553','554','555','702');
|
||||
$this->tabActivite[16]=array('651','660','672','652E','652A','652C','652F','671');
|
||||
$this->tabActivite[17]=array('751','990','752','990','701');
|
||||
|
||||
$this->tabR[1][0]=array();
|
||||
$this->tabR[1][1]=array('0:15.5','15.5:21.7','21.7:25','25:29.1','29.1:33.4','33.4:37','37:40','40:42.6','42.6:44.9','44.9:100');
|
||||
$this->tabR[1][2]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][3]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][4]=array('0:8.7','8.7:12.8','12.8:15','15:17.7','17.7:20.6','20.6:23','23:25','25:26.7','26.7:28.3','28.3:100');
|
||||
$this->tabR[1][5]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][6]=array('0:20.5','20.5:26.7','26.7:30','30:34.1','34.1:38.4','38.4:42','42:45','45:47.6','47.6:49.9','49.9:100');
|
||||
$this->tabR[1][7]=array('0:13.7','13.7:17.8','17.8:20','20:22.7','22.7:25.6','25.6:28','28:30','30:31.7','31.7:33.3','33.3:100');
|
||||
$this->tabR[1][8]=array('0:3.7','3.7:7.8','7.8:10','10:12.7','12.7:15.6','15.6:18','18:20','20:21.7','21.7:23.3','23.3:100');
|
||||
$this->tabR[1][9]=array('0:13.7','13.7:17.8','17.8:20','20:22.7','22.7:25.6','25.6:28','28:30','30:31.7','31.7:33.3','33.3:100');
|
||||
$this->tabR[1][10]=array('0:5.7','5.7:9.8','9.8:12','12:14.7','14.7:17.6','17.6:20','20:22','22:23.7','23.7:25.3','25.3:100');
|
||||
$this->tabR[1][11]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][12]=array('0:13.7','13.7:17.8','17.8:20','20:22.7','22.7:25.6','25.6:28','28:30','30:31.7','31.7:33.3','33.3:100');
|
||||
$this->tabR[1][13]=array('0:23.7','23.7:27.8','27.8:30','30:32.7','32.7:35.6','35.6:38','38:40','40:41.7','41.7:43.3','43.3:100');
|
||||
$this->tabR[1][14]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][15]=array('0:15.5','15.5:21.7','21.7:25','25:29.1','29.1:33.4','33.4:37','37:40','40:42.6','42.6:44.9','44.9:100');
|
||||
$this->tabR[1][16]=array('0:6.8','6.8:8.9','8.9:10','10:11.4','11.4:12.8','12.8:14','14:15','15:15.9','15.9:16.6','16.6:100');
|
||||
$this->tabR[1][17]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
|
||||
$this->tabR[2][0]=array();
|
||||
$this->tabR[2][1]=array('1.8:','1.6:1.8','1.5:1.6','1.4:1,5','1.2:1.4','1.0:1.2','0.9:1.0','0.8:0,9','0.7:0,8','0:0.7');
|
||||
$this->tabR[2][2]=array('2.2:','1.9:2.2','1.8:1.9','1.6:1.8','1.4:1.6','1.2:1.4','1.0:1.2','0.9:1.0','0.7:0.9','0:0.7');
|
||||
$this->tabR[2][3]=array('2.2:','1.9:2.2','1.8:1.9','1.6:1.8','1.4:1.6','1.2:1.4','1.0:1.2','0.9:1.0','0.7:0.9','0:0.7');
|
||||
$this->tabR[2][4]=array('3.0:','2.7:3.0','2.5:2.7','2.3:2.5','2.0:2.3','1.7:2.0','1.5:1.7','1.3:1.5','1.1:1.3','0:1.1');
|
||||
$this->tabR[2][5]=array('2.6:','2.4:2.6','2.2:2.4','2.0:2.2','1.7:2.0','1.5:1.7','1.3:1.5','1.1:1.3','1.0:1.1','0:1');
|
||||
$this->tabR[2][6]=array('1.7:','1.6:1.7','1.5:1.6','1.4:1.5','1.2:1.4','1.1:1.2','1.0:1.1','0.9:1.0','0.8:0.9','0:0.8');
|
||||
$this->tabR[2][7]=array('1.5:','1.4:1.5','1.3:1.4','1.1:1.3','1.0:1.2','0.9:1.0','0.8:0.9','0.7:0.8','0.6:0.7','0:0.6');
|
||||
$this->tabR[2][8]=array('10.1:','8.8:10.1','8:8.8','7:8','5.8:7','4.8:5.8','4:4.8','3.3:4','2.8:3.3','0:2.8');
|
||||
$this->tabR[2][9]=array('3:','2.7:3','2.5:2.7','2.3:2.5','2:2.3','1.7:2','1.5:1.7','1.3:1.5','1.1:1.3','0:1.1');
|
||||
$this->tabR[2][10]=array('3.8:','3.3:3.8','3.0:3.3','2.6:3.0','2.2:2.6','1.8:2.2','1.5:1.8','1.2:1.5','1.0:1.2','0:1');
|
||||
$this->tabR[2][11]=array('2.3:','2.1:2.3','2:2.1','1.8:2','1.6:1.8','1.5:1.6','1.3:1.5','1.2:1.3','1:1.2','0:1');
|
||||
$this->tabR[2][12]=array('2.3:','2.1:2.3','2:2.1','1.8:2','1.6:1.8','1.5:1.6','1.3:1.5','1.2:1.3','1:1.2','0:1');
|
||||
$this->tabR[2][13]=array('1.8:','1.6:1.8','1.5:1.6','1.4:1.5','1.2:1.4','1:1.2','0.9:1','0.8:0.9','0.7:0.8','0:0.7');
|
||||
$this->tabR[2][14]=array('1.8:','1.6:1.8','1.5:1.6','1.4:1.5','1.2:1.4','1:1.2','0.9:1','0.8:0.9','0.7:0.8','0:0.7');
|
||||
$this->tabR[2][15]=array('2.2:','1.9:2.2','1.7:1.9','1.5:1.7','1.2:1.5','1.0:1.2','0.8:1.0','0.7:0.8','0.5:0.7','0:0.5');
|
||||
$this->tabR[2][16]=array('10.1:','8.8:10.1','8:8.8','7:8','5.8:7','4.8:5.8','4:4.8','3.3:4','2.8:3.3','0:2.8');
|
||||
$this->tabR[2][17]=array('2.2:','1.9:2.2','1.8:1.9','1.6:1.8','1.4:1.6','1.2:1.4','1:1.2','0.9:1','0.7:0.9','0:0.7');
|
||||
|
||||
$this->tabR[3][0]=array();
|
||||
$this->tabR[3][1]=array('4.4:','4:4.4','3.8:4','3.5:3.8','3.1:3.5','2.8:3.1','2.5:2.8','2.2:2.5','2:2.2','0:2');
|
||||
$this->tabR[3][2]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][3]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][4]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][5]=array('8.6:','7.9:8.6','7.5:7.9','6.9:7.5','6.2:6.9','5.6:6.2','5:5.6','4.5:5','4:4.5','0:4');
|
||||
$this->tabR[3][6]=array('4.4:','4:4.4','3.8:4','3.5:3.8','3.1:3.5','2.8:3.1','2.5:2.8','2.2:2.5','2:2.2','0:2');
|
||||
$this->tabR[3][7]=array('4.4:','4:4.4','3.8:4','3.5:3.8','3.1:3.5','2.8:3.1','2.5:2.8','2.2:2.5','2:2.2','0:2');
|
||||
$this->tabR[3][8]=array('10.9:','9.7:10.9','9:9.7','8:9','6.8:8','5.8:6.8','5:5.8','4.3:5','3.7:4.3','0:3.7');
|
||||
$this->tabR[3][9]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][10]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][11]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][12]=array('5.9:','5.4:5.9','5:5.4','4.5:5','3.9:4.5','3.4:3.9','3:3.4','2.6:3','2.3:2.6','0:2.3');
|
||||
$this->tabR[3][13]=array('4.2:','3.8:4.2','3.5:3.8','3.1:3.5','2.7:3.1','2.3:2.7','2:2.3','1.7:2','1.5:1.7','0:1.5');
|
||||
$this->tabR[3][14]=array('4.2:','3.8:4.2','3.5:3.8','3.1:3.5','2.7:3.1','2.3:2.7','2:2.3','1.7:2','1.5:1.7','0:1.5');
|
||||
$this->tabR[3][15]=array('6.9:','6.3:6.9','6.0:6.3','5.5:6.0','5.0:5.5','4.5:5.0','4.0:4.5','3.6:4.0','3.2:3.6','0:3.2');
|
||||
$this->tabR[3][16]=array('10.9:','9.7:10.9','9:9.7','8:9','6.8:8','5.8:6.8','5:5.8','4.3:5','3.7:4.3','0:3.7');
|
||||
$this->tabR[3][17]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
|
||||
$this->tabR[4][0]=array();
|
||||
$this->tabR[4][1]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][2]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][3]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][4]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][5]=array('0:1.36','1.36:1.44','1.44:1.5','1.5:1.58','1.58:1.71','1.71:1.85','1.85:2','2:2.16','2.16:2.33','2.33:');
|
||||
$this->tabR[4][6]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][7]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][8]=array('0:1.1','1.1:1.2','1.2:1.3','1.3:1.4','1.4:1.6','1.6:1.8','1.8:2','2:2.2','2.2:2.5','2.5:');
|
||||
$this->tabR[4][9]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][10]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][11]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][12]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][13]=array('0:2.4','2.4:2.7','2.7:3','3:3.4','3.4:4.1','4.1:5','5:6','6:7.2','7.2:8.7','8.7:');
|
||||
$this->tabR[4][14]=array('0:2.4','2.4:2.7','2.7:3','3:3.4','3.4:4.1','4.1:5','5:6','6:7.2','7.2:8.7','8.7:');
|
||||
$this->tabR[4][15]=array('0:2.9','2.9:3.4','3.4:3.7','3.7:4.3','4.3:5.2','5.2:6.2','6.2:7.5','7.5:9.1','9.1:10.9','10.9:');
|
||||
$this->tabR[4][16]=array('0:1.1','1.1:1.2','1.2:1.3','1.3:1.4','1.4:1.6','1.6:1.8','1.8:2','2:2.2','2.2:2.5','2.5:');
|
||||
$this->tabR[4][17]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
|
||||
$this->tabR[5][0]=array();
|
||||
$this->tabR[5][1]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
|
||||
$this->tabR[5][2]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
|
||||
$this->tabR[5][3]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
|
||||
$this->tabR[5][4]=array('-99:-16.7','-16.7:-12.7','-12.7:-10','-10:-6','-6:-0.7','-0.7:4.7','4.7:10','10:15.3','15.3:20.7','20.7:');
|
||||
$this->tabR[5][5]=array('-999:-420','-420:-384','-384:-360','-360:-324','-324:-276','-276:-228','-228:-180','-180:-132','-132:-84','-84:');
|
||||
$this->tabR[5][6]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
|
||||
$this->tabR[5][7]=array('-99:-30','-30:-24','-24:-20','-20:-14','-14:-6','-6:2','2:10','10:18','18:26','26:');
|
||||
$this->tabR[5][8]=array('-99:-41.7','-41.7:-34.7','-34.7:-30','-30:-23','-23:-13.7','-13.7:-4.3','-4.3:5','5:14.3','14.3:23.7','23.7:');
|
||||
$this->tabR[5][9]=array('-99:-16.7','-16.7:-12.7','-12.7:-10','-10:-6','-6:-0.7','-0.7:4.7','4.7:10','10:15.3','15.3:20.7','20.7:');
|
||||
$this->tabR[5][10]=array('-99:-5','-5:-2','-2:0','0:3','3:7','7:11','11:15','15:19','19:23','23:');
|
||||
$this->tabR[5][11]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
|
||||
$this->tabR[5][12]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
|
||||
$this->tabR[5][13]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
|
||||
$this->tabR[5][14]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
|
||||
$this->tabR[5][15]=array('-99:-38.3','-38.3:-36.3','-36.3:-35.0','-35:-33','-33.0:-30','-30:-27.7','-27.7:-25.0','-25.0:-22.3','-22.3:-19.7','-19.7:');
|
||||
$this->tabR[5][16]=array('-99:-41.7','-41.7:-34.7','-34.7:-30','-30:-23','-23:-13.7','-13.7:-4.3','-4.3:5','5:14.3','14.3:23.7','23.7:');
|
||||
$this->tabR[5][17]=array(':-58.3','-58.3:53.3','-53.3:-50','-50:-45','-45:-38.3','-38.3:-31.7','-31.7:-25','-25:-18.3','-18.3:-11.7','-11.7:');
|
||||
|
||||
$this->tabR[6][0]=array();
|
||||
$this->tabR[6][1]=array('0:6','6:6.6','6.6:7','7:7.6','7.6:8.4','8.4:9.2','9.2:10','10:10.8','10.8:11.6','11.6:');
|
||||
$this->tabR[6][2]=array('0:6','6:6.6','6.6:7','7:7.6','7.6:8.4','8.4:9.2','9.2:10','10:10.8','10.8:11.6','11.6:');
|
||||
$this->tabR[6][3]=array('0:1.5','1.5:2.1','2.1:2.5','2.5:3.1','3.1:3.9','3.9:4.7','4.7:5.5','5.5:6.3','6.3:7.1','7.1:');
|
||||
$this->tabR[6][4]=array('0:1.8','1.8:2.2','2.2:2.5','2.5:2.9','2.9:3.4','3.4:4','4:4.5','4.5:5','5:5.6','5.6:');
|
||||
$this->tabR[6][5]=array('0:6.7','6.7:7.5','7.5:8','8:8.8','8.8:9.9','9.9:10.9','10.9:12','12:13.1','13.1:14.1','14.1:');
|
||||
$this->tabR[6][6]=array('0:7.7','7.7:8.5','8.5:9','9:9.8','9.8:10.9','10.9:11.9','11.9:13','13:14.1','14.1:15.1','15.1:');
|
||||
$this->tabR[6][7]=array('0:3','3:3.6','3.6:4','4:4.6','4.6:5.4','5.4:6.2','6.2:7','7:7.8','7.8:8.6','8.6:');
|
||||
$this->tabR[6][8]=array('0:1.3','1.3:1.7','1.7:2','2:2.4','2.4:2.9','2.9:3.5','3.5:4','4:4.5','4.5:5.1','5.1:');
|
||||
$this->tabR[6][9]=array('0:1.8','1.8:2.2','2.2:2.5','2.5:2.9','2.9:3.4','3.4:4','4:4.5','4.5:5','5:5.6','5.6:');
|
||||
$this->tabR[6][10]=array('0:1.3','1.3:1.7','1.7:2','2:2.4','2.4:2.9','2.9:3.5','3.5:4','4:4.5','4.5:5.1','5.1:');
|
||||
$this->tabR[6][11]=array('0:8.3','8.3:9.3','9.3:10','10:11','11:12.3','12.3:13.7','13.7:15','15:16.3','16.3:17.7','17.7:');
|
||||
$this->tabR[6][12]=array('0:4.7','4.7:5.5','5.5:6','6:6.8','6.8:7.9','7.9:8.9','8.9:10','10:11.1','11.1:12.1','12.1:');
|
||||
$this->tabR[6][13]=array('0:3','3:4.8','4.8:6','6:7.8','7.8:10.2','10.2:12.6','12.6:15','15:17.4','17.4:19.8','19.8:');
|
||||
$this->tabR[6][14]=array('0:3','3:4.8','4.8:6','6:7.8','7.8:10.2','10.2:12.6','12.6:15','15:17.4','17.4:19.8','19.8:');
|
||||
$this->tabR[6][15]=array('0:2','2:2.3','2.3:2.5','2.5:2.8','2.8:3.2','3.2:3.6','3.6:4.0','4.0:4.4','4.4:4.8','4.8:');
|
||||
$this->tabR[6][16]=array('0:1.7','1.7:1.9','1.9:2','2:2.2','2.2:2.5','2.5:2.7','2.7:3','3:3.3','3.3:3.5','3.5:');
|
||||
$this->tabR[6][17]=array('0:4.7','4.7:5.5','5.5:6','6:6.8','6.8:7.9','7.9:8.9','8.9:10','10:11.1','11.1:12.1','12.1:');
|
||||
|
||||
?>
|
9
library/Metier/common/rncs.class.php
Normal file
9
library/Metier/common/rncs.class.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?
|
||||
class Rncs {
|
||||
|
||||
function Rncs () {}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
@ -1,5 +1,6 @@
|
||||
<?
|
||||
global $tabEvenInsee;
|
||||
global $timer;
|
||||
$tabEvenInsee=array(
|
||||
// Anciens évènements de la quotidienne Insee
|
||||
'i00'=>'Modification de l\'établissement',
|
||||
@ -80,7 +81,7 @@ $tabDestinat=array( 'i3'=>'Etablissement vendu',
|
||||
'iRP'=>'Suppression partielle d\'activité par reprise par le propriétaire',
|
||||
);
|
||||
global $tabTypEtab;
|
||||
$tabTypEtab=array( 'i00'=>'Rappel des données de l’établissement du siège en cas de modification exclusive de l\'entreprise',
|
||||
$tabTypEtab=array( 'i00'=>'Rappel des données de létablissement du siège en cas de modification exclusive de l\'entreprise',
|
||||
'i08'=>'Siège avant transfert non fermé',
|
||||
'i09'=>'Siège après transfert non créé',
|
||||
'i10'=>'Siège avant transfert fermé',
|
||||
@ -100,7 +101,7 @@ $tabTypEtab=array( 'i00'=>'Rappel des données de l’établissement du siège e
|
||||
'i25'=>'Établissement modifié (hors transfert) : modification de l\'activité principale avec désactivation économique',
|
||||
'i26'=>'Établissement modifié (hors transfert) : autre modification de l\'activité principale de l\'établissement',
|
||||
'i27'=>'Établissement modifié (hors transfert) : modification de l\'identification de l\'établissement',
|
||||
'i29'=>'Établissement modifié (hors transfert) : modification d’une autre variable de l\'établissement',
|
||||
'i29'=>'Établissement modifié (hors transfert) : modification dune autre variable de l\'établissement',
|
||||
'i30'=>'Établissement avant transfert non fermé',
|
||||
'i31'=>'Établissement après transfert non créé',
|
||||
'i32'=>'Établissement supprimé',
|
||||
@ -299,15 +300,15 @@ class MInsee {
|
||||
/**Tranches de Chiffre d'Affaires INSEE
|
||||
**/
|
||||
private static $tabTCA = array( '0'=>'N/C',
|
||||
'1'=>'de 500 000 à 1 M€',
|
||||
'2'=>'de 1 à 2 M€',
|
||||
'3'=>'de 2 à 5 M€',
|
||||
'4'=>'de 5 à 10 M€',
|
||||
'5'=>'de 10 à 20 M€',
|
||||
'6'=>'de 20 à 50 M€',
|
||||
'7'=>'de 50 à 100 M€',
|
||||
'8'=>'de 100 à 200 M€',
|
||||
'9'=>'plus de 200 M€'
|
||||
'1'=>'de 500 000 à 1 M',
|
||||
'2'=>'de 1 à 2 M',
|
||||
'3'=>'de 2 à 5 M',
|
||||
'4'=>'de 5 à 10 M',
|
||||
'5'=>'de 10 à 20 M',
|
||||
'6'=>'de 20 à 50 M',
|
||||
'7'=>'de 50 à 100 M',
|
||||
'8'=>'de 100 à 200 M',
|
||||
'9'=>'plus de 200 M'
|
||||
);
|
||||
|
||||
/** Tranche de CA Export **/
|
||||
@ -986,16 +987,65 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
if ($nic*1>0) $strNic=" AND insNIC=$nic ";
|
||||
|
||||
$insee=$this->iDbInsee->select('insee_even', 'id, insSIREN, siretValide, insNIC, insLIBCOM, insSIEGE, insAUXILT, insORIGINE, insTEFET, insAPET700, insAPRM, insMODET, insMARCHET, insSAISONAT, insACTIVNAT, insENSEIGNE, insL1_NOMEN, insL2_COMP, insL4_VOIE, insL3_CADR, insNUMVOIE, insINDREP, insTYPVOIE, insLIBVOIE, insL5_DISP, insL6_POST, insCODPOS, insL7_ETRG, insRPET, insDEPCOM, insCODEVOIE, insDREACTET, insEXPLET, insDAPET, insLIEUACT, insACTISURF, insDEFET, insTEL, insCJ, insCIVILITE, insTEFEN, insAPEN700, insMODEN, insMARCHEN, insNOMEN, insTYPCREH, insEVE, insDATEVE, insTRAN, insNICTRAN, insMNICSIEGE, insMNOMEN, insMCJ, insMAPEN, insFiller1, insFiller2, insMMARCHEN, insMORDIN, insEFENCENT, insSIGLE, insNBETEXPL, insNICSIEGE, insDEPCOMEN, insFiller3, insMENSEIGNE, insMAPET, insMNATURE, insMADRESSE, insMEFET, insMSINGT, insMTELT, insMMARCHET, insMAUXILT, insSINGT, insEFETCENT, insSIRETPS, insDESTINAT, insDATEMAJ, idFlux, dirNom, dirNomUsage, dirPrenom, insDCRET, insDCREN, insPRODPART, insSIRETASS, insDREACTEN, insEXPLEN, insFiller4, insDEFEN, insMONOREG, insREGIMP, insMONOACT, insMSIGLE, insMEXPLEN, insRPEN, insMEXPLET, insTYPETAB, insDAPEN', "insSIREN=$siren $strNic ORDER BY insDATEMAJ DESC LIMIT $iDeb, $iMax",false, MYSQL_ASSOC);
|
||||
foreach ($insee as $i=>$even) {
|
||||
$tabSiren[$even['insDATEVE']]=array('rs'=>$even['insNOMEN'],
|
||||
'sigle'=>$even['insSIGLE'],
|
||||
'ape'=>$even['insAPEN700'],
|
||||
'nic'=>$even['insNICSIEGE'],
|
||||
'cj'=>$even['insCJ'],
|
||||
);
|
||||
$tabSiret[$even['insNIC']][$even['insDATEVE']]
|
||||
= array('ens'=>$even['insENSEIGNE'],
|
||||
'ape'=>$even['insAPET700'],
|
||||
'adresse'=>$even['insL2_COMP'].' '.$even['insL3_CADR'].' '.$even['insL4_VOIE'].' '.$even['insL5_DISP'].' '.$even['insL6_POST'].' '.$even['insL7_ETRG'],
|
||||
'effectif'=>$even['insEFENCENT'].' (Tranche '.$even['insTEFET'].')',
|
||||
);
|
||||
}
|
||||
foreach ($insee as $i=>$even) {
|
||||
$tabId[]=$even['id'];
|
||||
$libDet='';
|
||||
if ($even['insMNOMEN']==1) $libDet.='Modification de la raison sociale : '.$even['insNOMEN'].', ';
|
||||
if ($even['insMENSEIGNE']==1) $libDet.='Modification de l\'enseigne : '.$even['insENSEIGNE'].', ';
|
||||
if ($even['insMSIGLE']==1) $libDet.='Modification du sigle : '.$even['insSIGLE'].', ';
|
||||
if ($even['insMAPEN']==1) $libDet.='Modification de l\'activité de l\'entreprise : '.$even['insAPEN700'].', ';
|
||||
if ($even['insMAPET']==1) $libDet.='Modification de l\'activité de l\'établissement : '.$even['insAPET700'].', ';
|
||||
if ($even['insMNICSIEGE']==1) $libDet.='Modification du nic du siège : '.$even['insNICSIEGE'].', ';
|
||||
if ($even['insMADRESSE']==1) $libDet.='Modification de l\'adresse : '.$even['insL2_COMP'].' '.$even['insL3_CADR'].' '.$even['insL4_VOIE'].' '.$even['insL5_DISP'].' '.$even['insL6_POST'].' '.$even['insL7_ETRG'].', ';
|
||||
if ($even['insMNOMEN']==1) {
|
||||
$libDet.='Modification de la raison sociale : '.$even['insNOMEN'];
|
||||
$strPre=getInfoPrecedente($tabSiren, $even['insDATEVE'], 'rs');
|
||||
if ($strPre<>'' && $strPre<>$even['insNOMEN']) $libDet.=" (Précédent : $strPre)";
|
||||
$libDet.=', ';
|
||||
}
|
||||
if ($even['insMENSEIGNE']==1) {
|
||||
$libDet.='Modification de l\'enseigne : '.$even['insENSEIGNE'];
|
||||
$strPre=getInfoPrecedente($tabSiret[$even['insNIC']], $even['insDATEVE'], 'ens');
|
||||
if ($strPre<>'' && $strPre<>$even['insENSEIGNE']) $libDet.=" (Précédent : $strPre)";
|
||||
$libDet.=', ';
|
||||
}
|
||||
if ($even['insMSIGLE']==1) {
|
||||
$libDet.='Modification du sigle : '.$even['insSIGLE'];
|
||||
$strPre=getInfoPrecedente($tabSiren, $even['insDATEVE'], 'sigle');
|
||||
if ($strPre<>'' && $strPre<>$even['insSIGLE']) $libDet.=" (Précédent : $strPre)";
|
||||
$libDet.=', ';
|
||||
}
|
||||
if ($even['insMAPEN']==1) {
|
||||
$libDet.='Modification de l\'activité de l\'entreprise : '.$even['insAPEN700'].' - '.$this->getLibelleNaf($even['insAPEN700']);
|
||||
$strPre=getInfoPrecedente($tabSiren, $even['insDATEVE'], 'ape');
|
||||
if ($strPre<>'' && $strPre<>$even['insAPEN700']) $libDet.=" (Précédent : $strPre - ".$this->getLibelleNaf($strPre).')';
|
||||
$libDet.=', ';
|
||||
}
|
||||
if ($even['insMAPET']==1) {
|
||||
$libDet.='Modification de l\'activité de l\'établissement : '.$even['insAPET700'].' - '.$this->getLibelleNaf($even['insAPET700']);
|
||||
$strPre=getInfoPrecedente($tabSiret[$even['insNIC']], $even['insDATEVE'], 'ape');
|
||||
if ($strPre<>'' && $strPre<>$even['insAPET700']) $libDet.=" (Précédent : $strPre - ".$this->getLibelleNaf($strPre).')';
|
||||
$libDet.=', ';
|
||||
}
|
||||
if ($even['insMNICSIEGE']==1) {
|
||||
$libDet.='Modification du nic du siège : '.$even['insNICSIEGE'];
|
||||
$strPre=getInfoPrecedente($tabSiren, $even['insDATEVE'], 'nic');
|
||||
if ($strPre<>'' && $strPre<>$even['insNICSIEGE']) $libDet.=" (Précédent : $strPre)";
|
||||
$libDet.=', ';
|
||||
}
|
||||
if ($even['insMADRESSE']==1) {
|
||||
$libDet.='Modification de l\'adresse : '.$even['insL2_COMP'].' '.$even['insL3_CADR'].' '.$even['insL4_VOIE'].' '.$even['insL5_DISP'].' '.$even['insL6_POST'].' '.$even['insL7_ETRG'];
|
||||
$strPre=getInfoPrecedente($tabSiret[$even['insNIC']], $even['insDATEVE'], 'adresse');
|
||||
if ($strPre<>'' && $strPre<>$even['insL2_COMP'].' '.$even['insL3_CADR'].' '.$even['insL4_VOIE'].' '.$even['insL5_DISP'].' '.$even['insL6_POST'].' '.$even['insL7_ETRG']) $libDet.=" (Précédent : $strPre)";
|
||||
$libDet.=', ';
|
||||
}
|
||||
if ($even['insMEFET']==1) $libDet.='Modification de l\'effectif : '.$even['insEFENCENT'].' (Tranche '.$even['insTEFET'].'), ';
|
||||
if ($even['insEXPLET']=='O') $strTmp='Exploitant';
|
||||
elseif ($even['insEXPLET']=='N')$strTmp='Non exploitant participant au système productif';
|
||||
@ -1005,7 +1055,12 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
elseif ($even['insEXPLEN']=='N')$strTmp='Non exploitant participant au système productif';
|
||||
elseif ($even['insEXPLEN']=='X')$strTmp='Non exploitant ne participant pas au système productif';
|
||||
if ($even['insMEXPLEN']==1) $libDet.='Modification du caractère exploitant de l\'entreprise : '.$strTmp.', ';
|
||||
if ($even['insMCJ']==1) $libDet.='Modification de la forme juridique : '.$even['insCJ'].', ';
|
||||
if ($even['insMCJ']==1) {
|
||||
$libDet.='Modification de la forme juridique : '.$even['insCJ'].' - '.$this->getLibelleFJ($even['insCJ']);
|
||||
$strPre=getInfoPrecedente($tabSiret[$even['insNIC']], $even['insDATEVE'], 'cj');
|
||||
if ($strPre<>'' && $strPre<>$even['insCJ']) $libDet.=" (Précédent : $strPre - ".$this->getLibelleFJ($even['insCJ']).')';
|
||||
$libDet.=', ';
|
||||
}
|
||||
if ($even['insAUXILT']==1) $strTmp='Auxiliaire';
|
||||
else $strTmp='Non auxiliaire';
|
||||
if ($even['insMAUXILT']==1) $libDet.='Modification du caractère auxiliaire de l\'établissement : '.$strTmp.', ';
|
||||
@ -1663,10 +1718,12 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
}
|
||||
|
||||
function getIdentiteEntreprise($siren, $nic=0, $id=0, $forceVerif=false, $accesDist=true) {
|
||||
global $timer;
|
||||
$timer=array('debutIdentite'=>microtime(true));
|
||||
//$accesDist=false;
|
||||
$tdebIni=microtime(1);
|
||||
$ligne=date('YmdHis').";$siren;getIdentiteEntreprise Début ---";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
|
||||
@ -1687,6 +1744,8 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
|
||||
$etab=@$listeEtab[0];
|
||||
$nic=@$etab['nic'];
|
||||
$timer['tableEtablissements']=microtime(true);
|
||||
|
||||
/** Si le siren est valide, on part chez Infogreffe **/
|
||||
if (count($listeEtab)==0 && $this->valideSiren($siren) && $accesDist) {
|
||||
$iGeffes=new MGreffes();
|
||||
@ -1727,6 +1786,7 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
'dateMAJ' => WDate::DateT('Ymd','Y-m-d',$lastMaj),
|
||||
);
|
||||
}
|
||||
$timer['accesInfogreffeCarInconnu']=microtime(true);
|
||||
}
|
||||
unset($listeEtab);
|
||||
|
||||
@ -1742,6 +1802,7 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
|
||||
$insee=$this->iDb->select('etablissements', 'CONCAT(SIREN,NIC) AS siret', "SIREN=$siren AND SIEGE=1 ORDER BY ACTIF%10 DESC, NIC DESC",false,MYSQL_ASSOC);
|
||||
$siretSiege=$insee[0]['siret'];
|
||||
$timer['infosEntrep']=microtime(true);
|
||||
}
|
||||
|
||||
if ($nic>0) $strNic="AND NIC=$nic";
|
||||
@ -1790,6 +1851,7 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
$nbEtab=$tabTmp[0]['nbEtabs'];
|
||||
$inseeND=$this->iDbInsee->select('insee_nondiff', 'siren, mois, dateInsert',"siren=$siren",false,MYSQL_ASSOC);
|
||||
$moisNonDiff=@$tabTmp[0]['mois'];
|
||||
$timer['tableIdentite']=microtime(true);
|
||||
}
|
||||
else {
|
||||
$tabInsee=array(
|
||||
@ -1814,29 +1876,31 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
if (count($info)==0) {
|
||||
$idComp=$this->getIdentitePart($siren, $etab['raisonSociale'], $etab['enseigne'], $etab['sigle'], 0, $accesDist);
|
||||
$tab=$idComp;
|
||||
$timer['getIdentitePart']=microtime(true);
|
||||
}
|
||||
|
||||
/** Géocodage de l'adresse
|
||||
**/
|
||||
$ligne=date('YmdHis').";$siren;MMap AVANT";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
$mMap=new MMap(true);//$etab['adr_num'].' '.$this->getCodeVoie($etab['adr_typeVoie']).' '.$etab['adr_libVoie'], $etab['adr_cp'], $etab['adr_ville']);
|
||||
$mMap->geoCodeAdresse($etab['adr_num'],'',$etab['adr_typeVoie'],$this->getCodeVoie($etab['adr_typeVoie']), $etab['adr_libVoie'], $etab['adr_cp'], $etab['adr_ville'], 'France', trim($tabInsee['ADR_DEP'].$tabInsee['ADR_COM'].$tabInsee['CODEVOIE']));
|
||||
$ligne=date('YmdHis').";$siren;MMap APRES ($duree s)";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
$tab['latitude']=$mMap->latitudeDec;
|
||||
$tab['longitude']=$mMap->longitudeDec;
|
||||
$tab['precis']=$mMap->precision;
|
||||
$timer['geoCodage']=microtime(true);
|
||||
|
||||
/** Accès provisoire à AMABIS
|
||||
**/
|
||||
if ($accesDist) {
|
||||
$ligne=date('YmdHis').";$siren;MAmabis Avant";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
$tdeb=microtime(1);
|
||||
@ -1844,17 +1908,19 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
$repAmabis=$iAmabis->getZonage($etab['adr_num'],$etab['adr_btq'],$etab['adr_typeVoie'],$etab['adr_libVoie'], $etab['adr_cp'], $etab['adr_ville'], trim($tabInsee['ADR_DEP'].$tabInsee['ADR_COM'].$tabInsee['CODEVOIE']), false, 'TEST', false);
|
||||
$duree=round(microtime(1)-$tdeb,3);
|
||||
$ligne=date('YmdHis').";$siren;MAmabis APRES ($duree s)";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
$timer['zonesPrioritaires']=microtime(true);
|
||||
} else
|
||||
$repAmabis=array();
|
||||
|
||||
|
||||
/** N° de TVA Intracommunautaire
|
||||
**/
|
||||
if ($siren*1>100) {
|
||||
$ligne=date('YmdHis').";$siren;MTva Avant";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
$tdeb=microtime(1);
|
||||
@ -1863,9 +1929,10 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
$vatDefined=$iTva->vatDefined;
|
||||
$duree=round(microtime(1)-$tdeb,3);
|
||||
$ligne=date('YmdHis').";$siren;MTva APRES ($duree s)";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
$timer['tvaIntra']=microtime(true);
|
||||
} else {
|
||||
$vatNumber='FR00000000000';
|
||||
$vatDefined=false;
|
||||
@ -1890,16 +1957,16 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
)
|
||||
) */
|
||||
$ligne=date('YmdHis').";$siren;MTel Avant";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
$tdeb=microtime(1);
|
||||
$iTel=new MTel($accesDist);
|
||||
$iTel=new MTel(false);//$accesDist);
|
||||
$iTel->getTel($siren);
|
||||
$tmp=$iTel->getTel($siren, $nic);
|
||||
$duree=round(microtime(1)-$tdeb,3);
|
||||
$ligne=date('YmdHis').";$siren;MTel APRES ($duree s)";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
$activitePJ_An8='';
|
||||
@ -1912,6 +1979,7 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
if ($tmp2['typeTel']=='mail' && $tab['mail']=='') $tab['mail']=$tmp2['infoTel'];
|
||||
if ($tmp2['typeTel']=='an8') $activitePJ_An8=$tmp2['infoTel'];
|
||||
}
|
||||
$timer['telFax']=microtime(true);
|
||||
//}
|
||||
|
||||
/** Type d'exploitation
|
||||
@ -1976,6 +2044,7 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
break;
|
||||
}
|
||||
}
|
||||
$timer['typeExploitation']=microtime(true);
|
||||
|
||||
$codePaysIso2='FR';
|
||||
if ($tabInsee['ADR_DEP']>98) {
|
||||
@ -2003,6 +2072,7 @@ print_r($tabTmp, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
$timer['codePays']=microtime(true);
|
||||
|
||||
$tabRet=array( 'id'=>$etab['id'],
|
||||
'Siret'=>$etab['siret'],
|
||||
@ -2059,6 +2129,7 @@ print_r($tabTmp, true));
|
||||
'Capital'=>$etab['capital'],
|
||||
'CapitalDev'=>$etab['capitalDev'],
|
||||
'CapitalSrc'=>$etab['capitalSrc'],
|
||||
|
||||
// 'Singularite'=>'',
|
||||
'DateCreaEt'=>$tabInsee['DCRET'],
|
||||
'DateCreaEn'=>$tabInsee['DCREN'],
|
||||
@ -2112,11 +2183,12 @@ print_r($tabTmp, true));
|
||||
/** Nombre d'actions du capital si disponible **/
|
||||
if ($etab['capital']>0) {
|
||||
$insee=$this->iDbInsee->select(
|
||||
'capitalActions',
|
||||
'sdv1.capitalActions',
|
||||
'capital, deviseCapital, nbActions, actionNominale, dateInfo',
|
||||
"siren=$siren AND capital>0 ORDER BY dateInfo DESC LIMIT 0,1",false,MYSQL_ASSOC);
|
||||
$tabRet['CapitalNbActions']=0;
|
||||
$tabRet['CapitalMtActions']=0;
|
||||
$tabRet['CapitalMtActions']=0;
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getIdentite sur $siren", print_r($insee, true).EOL.mysql_error());
|
||||
if (count($insee)>0) {
|
||||
if ($etab['capital']==$insee[0]['capital']) {
|
||||
$tabRet['CapitalNbActions']=$insee[0]['nbActions'];
|
||||
@ -2124,7 +2196,8 @@ print_r($tabTmp, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$timer['nbActionsCapital']=microtime(true);
|
||||
|
||||
/** Numéro de TVA non défini
|
||||
**/
|
||||
if (!$vatDefined) {
|
||||
@ -2159,6 +2232,7 @@ print_r($tmp, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
$timer['dateDebutActivite']=microtime(true);
|
||||
|
||||
|
||||
/** Adresse de domiciliation
|
||||
@ -2183,6 +2257,7 @@ print_r($tmp, true));
|
||||
'nom'=>prepareString($dom['nom']),
|
||||
);
|
||||
}
|
||||
$timer['adresseDom']=microtime(true);
|
||||
|
||||
|
||||
/** Siren en Doublon ?
|
||||
@ -2224,6 +2299,7 @@ print_r($tmp, true));
|
||||
rsort($tabDates);
|
||||
$tabRet['dateMajANN']=WDate::dateT('Y-m-d','Y-m-d',$tabDates[0]);
|
||||
if ($tabRet['dateMajANN']=='--') $tabRet['dateMajANN']='';
|
||||
$timer['getAnnoncesLegales']=microtime(true);
|
||||
}
|
||||
if (($tabInsee['CJ']>0 && $tabInsee['CJ']<20 ||
|
||||
$tabInsee['CJ']>999 && $tabInsee['CJ']<2000) && $tabInsee['DIR_FCT']=='')
|
||||
@ -2243,6 +2319,7 @@ print_r($tmp, true));
|
||||
$tmp=$this->iDbInsee->select( 'insee_even', 'insDATEVE', "insSIREN=$siren $strNic AND ( insEVE LIKE 'FF' OR insEVE LIKE 'TF' OR insEVE LIKE '0F' OR insEVE LIKE 'TD' OR insEVE LIKE '0D' OR insEVE LIKE '410' OR insEVE LIKE '420' OR insEVE LIKE '425' OR insEVE LIKE '400' OR insEVE LIKE '430' OR insEVE LIKE '435' OR insDESTINAT<>'') ORDER BY insDATEVE DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
$tabRet['DateClotEt']=@$tmp[0]['insDATEVE'];
|
||||
unset($tmp);
|
||||
$timer['dateClotureInsee']=microtime(true);
|
||||
}
|
||||
|
||||
if ($tabRet['TrancheCALib']=='') $tabRet['TrancheCALib']='N/C';
|
||||
@ -2300,6 +2377,7 @@ print_r($tmp, true));
|
||||
$devise=$tabRet['Capital']*$dev['valeur']*1;
|
||||
$tabRet['CapitalLib']=''.$dev['devNom'].' soit '.number_format(round($devise),null,null,' ').' EUR';
|
||||
}
|
||||
$timer['capital']=microtime(true);
|
||||
|
||||
/** Recherche du code Tribunal du siège **/
|
||||
if ($tabRet['CapitalSrc']<>5) {
|
||||
@ -2370,6 +2448,7 @@ print_r($tmp, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
$timer['activiteReelle']=microtime(true);
|
||||
|
||||
$bodacc=$this->iDb->select('rncs_dirigeants',
|
||||
"nom, prenom, fonction_code as code, fonction_lib as libelle, naissance_date AS dateNaiss, naissance_lieu AS lieuNaiss, dirRS as rs, '' as dateEffet",
|
||||
@ -2419,6 +2498,8 @@ print_r($tmp, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
$timer['dirigeants']=microtime(true);
|
||||
|
||||
/** Recherche du site Web ou Email dans le JO ASSO
|
||||
**/
|
||||
if ( ($tabRet['Web']=='' || $tabRet['Mail']=='') &&
|
||||
@ -2451,6 +2532,8 @@ print_r($tmp, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
$timer['association']=microtime(true);
|
||||
|
||||
|
||||
if (@count($etabG)>0) {
|
||||
// On initialise les dernères variables en prov. d'Infogreffes
|
||||
@ -2574,6 +2657,7 @@ print_r($tmp, true));
|
||||
*/
|
||||
}
|
||||
}
|
||||
$timer['infosRNCS']=microtime(true);
|
||||
}
|
||||
|
||||
if ( $accesDist &&
|
||||
@ -2597,7 +2681,7 @@ print_r($tmp, true));
|
||||
)
|
||||
) {
|
||||
$ligne=date('YmdHis').";$siren;MGreffes Avant";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
$tdeb=microtime(1);
|
||||
@ -2606,7 +2690,7 @@ print_r($tmp, true));
|
||||
$etabG=$iGeffes->getIdentite($siren);
|
||||
$duree=round(microtime(1)-$tdeb,3);
|
||||
$ligne=date('YmdHis').";$siren;MGreffes APRES ($duree s)";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
if ($etabG) {
|
||||
@ -2621,6 +2705,7 @@ print_r($tmp, true));
|
||||
if (preg_match('/[A-Z]/i',substr($tabRet['AutreId'],2,2)) || $tabRet['AutreId']=='')
|
||||
$tabRet['AutreId'] = $etabG['NumRC2'];
|
||||
}
|
||||
$timer['infosInfogreffes']=microtime(true);
|
||||
}
|
||||
|
||||
/** Si il n'y a aucun établissement actif et qu'on est radié au RCS :
|
||||
@ -2644,6 +2729,7 @@ print_r($tmp, true));
|
||||
elseif ($datePar>0)
|
||||
$tabRet['dateRad']=$datePar;
|
||||
}
|
||||
$timer['infosRadiation']=microtime(true);
|
||||
}
|
||||
|
||||
/** Eléments Financiers en provenance du dernier Bilan
|
||||
@ -2691,6 +2777,7 @@ print_r($tmp, true));
|
||||
$tabRet['bilanPU'] = $tabBilan['PU'];
|
||||
$tabRet['bilanPY'] = $tabBilan['PY'];
|
||||
$tabRet['bilanQC'] = $tabBilan['QC'];
|
||||
$timer['infosBilan']=microtime(true);
|
||||
}
|
||||
|
||||
/** CA Estimé si aucune info Bilan au TCA Insee
|
||||
@ -2816,7 +2903,7 @@ print_r($tmp, true));
|
||||
$tabRet['TribunalLib']=$this->iBodacc->getTribunalNom($tabRet['Tribunal']);
|
||||
$duree=round(microtime(1)-$tdebIni,3);
|
||||
$ligne=date('YmdHis').";$siren;getIdentiteEntreprise Fin ($duree s) ===";
|
||||
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
||||
$fp=fopen('/var/www/log/accesDistant.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
|
||||
@ -2842,6 +2929,7 @@ print_r($tmp, true));
|
||||
'capitalisation'=>$bourse['close']*$bourse['nombreTitres'],
|
||||
'derCoursDate'=>$bourse['date'],
|
||||
'derCoursCloture'=>$bourse['close']);
|
||||
$timer['infosBoursieres']=microtime(true);
|
||||
|
||||
/** Date de dernière mise à jour **/
|
||||
$lastMaj=str_replace('-','',$tabRet['DateMajINSEE'])*1;
|
||||
@ -2853,6 +2941,24 @@ print_r($tmp, true));
|
||||
$lastMaj=str_replace('-','',$tabRet['dateMajANN'])*1;
|
||||
$tabRet['dateMajIdentite']=WDate::dateT('Ymd','Y-m-d',$lastMaj);
|
||||
|
||||
$i=0;$strTime='';
|
||||
foreach ($timer as $lib=>$time) {
|
||||
$strTime.="$lib : ";
|
||||
$duree=round($time-$timePre,3);
|
||||
if ($i==0) { $strTime.="0 s"; $timeDeb=$time; }
|
||||
else $strTime.="$duree s";
|
||||
$strTime.="\n";
|
||||
$timePre=$time;
|
||||
$i++;
|
||||
}
|
||||
$duree=round($time-$timeDeb,3);
|
||||
$strTime.="---------------------
|
||||
TOTAL : $duree secondes\n";
|
||||
global $tabInfoUser;
|
||||
|
||||
if(ENV<>'PRD' && $tabInfoUser['login']=='ylenaour')
|
||||
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Identite sur $siren : Durées ".ENV, $strTime.EOL.print_r($tabRet,true));
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
@ -2894,15 +3000,16 @@ print_r($tmp, true));
|
||||
"b.SIREN=$siren AND b.id=d.id AND b.typeEven NOT BETWEEN 5000 AND 5700 AND b.typeEven NOT BETWEEN 2700 AND 2900 AND d.fonction=f.codeFct GROUP BY d.fonction, d.rs, d.nom, d.prenom ORDER BY d.dateEffet DESC, d.fonction DESC", true, MYSQL_ASSOC);
|
||||
if (count($bodacc)>0) {
|
||||
foreach ($bodacc as $k=>$ann) {
|
||||
$tabRet[]=array( 'Titre'=>$ann['libelle'],
|
||||
'Societe'=>$ann['rs'],
|
||||
'Nom'=>trim(strtr($ann['nom'], array( "Modification d'"=>'',
|
||||
"Modification de"=>'',
|
||||
"Nomination d'un"=>'',
|
||||
))),
|
||||
'Prenom'=>$ann['prenom'],
|
||||
'Ancien'=>$ann['depart'],
|
||||
'DateFct'=>$ann['dateEffet'],
|
||||
$tabRet[]=array( 'Fonction' => $ann['fonction'],
|
||||
'Titre' => $ann['libelle'],
|
||||
'Societe' => $ann['rs'],
|
||||
'Nom' => trim(strtr($ann['nom'], array( "Modification d'"=>'',
|
||||
"Modification de"=>'',
|
||||
"Nomination d'un"=>'',
|
||||
))),
|
||||
'Prenom' => $ann['prenom'],
|
||||
'Ancien' => $ann['depart'],
|
||||
'DateFct' => $ann['dateEffet'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -2948,12 +3055,13 @@ print_r($tmp, true));
|
||||
"Cette société se constitue Date de début d'"=>'',
|
||||
)));
|
||||
if ($nom<>'') {
|
||||
$tabRet[]=array( 'Titre'=>$iBodacc->getFctDir($tabDir['fonction']),//.' ('.$tabDir['fonction'].')',
|
||||
'Societe'=>$tabDir['rs'],
|
||||
'Nom'=>$nom,
|
||||
'Prenom'=>$tabDir['prenom'],
|
||||
'Ancien'=>$tabDir['depart'],
|
||||
'DateFct'=>Wdate::dateT('Ymd','Y-m-d', $ann['DATE']),
|
||||
$tabRet[]=array( 'Fonction' => $tabDir['fonction'],
|
||||
'Titre' => $iBodacc->getFctDir($tabDir['fonction']),//.' ('.$tabDir['fonction'].')',
|
||||
'Societe' => $tabDir['rs'],
|
||||
'Nom' => $nom,
|
||||
'Prenom' => $tabDir['prenom'],
|
||||
'Ancien' => $tabDir['depart'],
|
||||
'DateFct' => Wdate::dateT('Ymd','Y-m-d', $ann['DATE']),
|
||||
);
|
||||
$this->iDb->insert('bodacc_dirigeants_histo',
|
||||
array( 'siren' => $siren,
|
||||
@ -3048,7 +3156,7 @@ print_r($tmp, true));
|
||||
elseif ($siren<010000000) $siren='00'.$siren;
|
||||
elseif ($siren<100000000) $siren='0'.$siren;
|
||||
|
||||
require_once 'Metier/partenaires/classMRncsFlux.php';
|
||||
include_once(INCLUDE_PATH.'partenaires/classMRncsFlux.php');
|
||||
|
||||
$rncs=new MRncsFlux();
|
||||
$tabIdentite=$rncs->getIdentite($siren);
|
||||
@ -3689,8 +3797,9 @@ print_r($tmp, true));
|
||||
$strIdAnn='';
|
||||
$idA=0;
|
||||
$tabRet=array();
|
||||
//return $tabRet;
|
||||
|
||||
$mBoamp=new MBoamp();
|
||||
/** Recherche dans les avis d'attribution **/
|
||||
if ($idAnnonce<>'') {
|
||||
$tmp=explode('.', $idAnnonce);
|
||||
$idA=$tmp[1];
|
||||
@ -3761,6 +3870,100 @@ print_r($tmp, true));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Recherche dans les avis de marchés **/
|
||||
if ($idAnnonce<>'') {
|
||||
$tmp=explode('.', $idAnnonce);
|
||||
$idA=$tmp[1];
|
||||
//if (strlen($tmp[0])==9 && is_numeric($tmp[0])) $rcs=$tmp[0];
|
||||
if ($tmp[0]=='A') $strIdAnn=" AND d.id='$idA' ";
|
||||
elseif ($tmp[0]=='O') $strIdAnn="";
|
||||
}
|
||||
|
||||
$bodacc=$this->iDb->select( 'boamp b, boamp_detail d',
|
||||
"d.id, d.Boamp_Code, d.Boamp_Rubrique, b.Boamp_Rubrique_Lib, b.typeAnnonce, d.Boamp_Date_Parution, b.Boamp_Num, b.Boamp_Annee_Parution, b.Num_AnnoncePre, b.Num_Annonce, b.Boamp_Dept, b.annonce, titre AS description, d.raisonSociale, d.estimValeur AS montantTxt, d.estimValeurMin AS montantAnMin, d.estimValeurMax AS montantAnMax, objet, cpv_obj, cpv_comp, d.dateInsert",
|
||||
"d.siren='$siren' AND d.id=b.id $strIdAnn GROUP BY b.id ORDER BY d.Boamp_Date_Parution DESC", true, MYSQL_ASSOC);
|
||||
if (count($bodacc)>0) {
|
||||
foreach ($bodacc as $k=>$ann) {
|
||||
$id=$ann['id'];
|
||||
$rub=$ann['Boamp_Rubrique'];
|
||||
$tabRetEven=array();
|
||||
$strMontant='';
|
||||
if ($ann['objet']<>'') $strMontant.=' "'.$ann['objet'].'"';
|
||||
|
||||
if ($rub=='6' || // Avis d'attribution
|
||||
$rub=='7' || // Avis en cas de transparence ex ante volontaire
|
||||
$rub=='77' || // Avis d'attribution
|
||||
$rub=='8' || // Avis d'attribution
|
||||
$rub=='82' || // Rectificatif
|
||||
$rub=='83' || // Rectificatif
|
||||
$rub=='84' || // Avis d'attribution comportant des lots infructueux
|
||||
$rub=='9' || // Résultat de marché
|
||||
$rub=='92' || // Rectificatif
|
||||
$rub=='93' || // Résultat de marché / Infructueux - Sans suite
|
||||
$rub=='94' || // Résultat de marché / Résultat de marché comportant des lots infructueux
|
||||
$rub=='96' || // Annulation - Rectificatif - Sans suite - Infructueux
|
||||
$rub=='977' // Annulation - Rectificatif / Avis en cas de transparence ex ante volontaire
|
||||
) {
|
||||
$tabTmp=$this->iDb->select( 'boamp_lots l',
|
||||
"l.id, l.idAnn, l.Boamp_Code, l.Boamp_Rubrique, l.Boamp_Date_Parution, l.num, l.`desc` AS description, l.nom, l.montantTxt, l.montant, l.montantAnMin, l.montantAnMax, l.trancheCond, l.trancheFerme, l.dateAttrib, l.intitule, l.nomenclature, l.objets, l.cpv, l.cpvComp, l.volume, l.execution, l.livraison, l.dureeJours, l.dureeMois, l.dateDeb, l.dateFin",
|
||||
"l.idAnn=$id", true, MYSQL_ASSOC);
|
||||
foreach ($tabTmp as $k2=>$ann2) {
|
||||
if ($ann2['nom']<>'') $strMontant.=' "'.strtoupper($ann2['nom']).'"';
|
||||
if ($ann2['montant']*1>0) $strMontant.=' ('.number_format($ann2['montant'], 2, ',', ' ').' EUR)';
|
||||
elseif ($ann2['montantTxt']<>'') $strMontant.=' ('.$ann2['montantTxt'].')';
|
||||
elseif ($ann2['montantAnMin']<>'' && $ann2['montantAnMax'])
|
||||
$strMontant.=' ('.$ann2['montantAnMin'].' à '.
|
||||
$ann2['montantAnMax'].')';
|
||||
elseif ($ann2['trancheCond']<>'' && $ann2['trancheFerme'])
|
||||
$strMontant.=' ('.$ann['trancheCond'].' / '.
|
||||
$ann['trancheFerme'].')';
|
||||
else $strMontant.='';
|
||||
}
|
||||
}
|
||||
$tabRetEven[]=array('CodeEven'=>$mBoamp->getCodEvenSd($ann['Boamp_Rubrique']),
|
||||
'LibEven'=>$mBoamp->getLibEvenBoamp($ann['Boamp_Rubrique'], $ann['Boamp_Rubrique_Lib']).$strMontant);
|
||||
// Axxx pour lot attribué ou Oxxx pour Organisation
|
||||
if ($ann['Num_AnnoncePre']<>0) $numAnn=$ann['Num_AnnoncePre'].'-'.$ann['Num_Annonce'];
|
||||
else $numAnn=$ann['Num_Annonce'];
|
||||
if ($ann['Boamp_Code']=='MAPA')
|
||||
$lienMapa='http://www.boamp.fr/index.php?action=avis&num_parution=MAPA&num_annonce='.$ann['Num_AnnoncePre'].'-'.$ann['Num_Annonce'].'&total=500&_s=0&indice=0';//&affichage_avis=officiel';
|
||||
else {
|
||||
$lettre = substr($ann['Boamp_Code'],-1);
|
||||
$annee = $ann['Boamp_Annee_Parution'];
|
||||
$num = sprintf("%04d",$ann['Boamp_Num']);
|
||||
$numPar=$lettre.$annee.$num;
|
||||
$lienMapa='http://www.boamp.fr/index.php?action=avis&num_parution='.$numPar.'&num_annonce='.$ann['Num_Annonce'].'&total=500&_s=0&indice=0';
|
||||
}
|
||||
$infosComp='';
|
||||
$tabRet[$k]=array( 'id'=>'O.'.$id,
|
||||
'BodaccCode'=>$ann['Boamp_Code'],
|
||||
'BodaccNum'=>$ann['Boamp_Num'],
|
||||
'NumAnnonce'=>$numAnn,
|
||||
'DateParution'=>$ann['Boamp_Date_Parution'],
|
||||
'Departement'=>$ann['Boamp_Dept'],
|
||||
//'Tribunal'=>$ann['triNom'],
|
||||
//'TribunalSiret'=>$ann['triSiret'],
|
||||
//'Rubrique'=>$ann['Boamp_Rubrique_Lib'],
|
||||
'typeAnnonce'=>$ann['typeAnnonce'],
|
||||
'dateInsertionSD'=>$ann['dateInsert'],
|
||||
'evenements'=>$tabRetEven,
|
||||
'infosComp'=>$infosComp, // Non géré
|
||||
'Lien_Annonce_Html'=>$lienMapa, // Non géré
|
||||
);
|
||||
/**/
|
||||
if ($idA<>0)
|
||||
if ($ann['Boamp_Code']=='MAPA')
|
||||
$tabRet[$k]['texteAnnonce']=$ann['annonce'];
|
||||
else
|
||||
$tabRet[$k]['texteAnnonce']=
|
||||
strtr( preg_replace('/<html.*<body.*>/Uis', '',
|
||||
preg_replace('/<p\s+.*>/Uis', '',
|
||||
preg_replace('/( class=".*")/ie', ' ', $ann['annonce']))),
|
||||
array(' '=>' ', '</html>'=>'', '</body>'=>'', '</p>'=>'<br/>')
|
||||
);
|
||||
}
|
||||
}
|
||||
debugLog('I', "getAnnoncesBoamp(siren=$siren, idAnnonce=$idAnnonce, $idA)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
return $tabRet;
|
||||
}
|
||||
@ -4219,7 +4422,7 @@ function getProColPart($siren, $rubrique='', $forceVerif=false, $idAnnonce=0) {
|
||||
|
||||
if (preg_match('/Aucune proc.dure collective n.est enregistr/i',$strTmp)) {
|
||||
$ligne=date('YmdHis').";$siren;".$page['code'].';NO;';
|
||||
$fp=fopen(LOG_PATH.'/pouey.log', 'a');
|
||||
$fp=fopen('/var/www/log/pouey.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
return $tabRet;
|
||||
@ -4295,7 +4498,7 @@ function getProColPart($siren, $rubrique='', $forceVerif=false, $idAnnonce=0) {
|
||||
$this->iDb->insert('annonces', $tabInsert);
|
||||
|
||||
$ligne=date('YmdHis').";$siren;".$page['code'].";YES;$dateJ;$typeEven;$libEven";
|
||||
$fp=fopen(LOG_PATH.'/pouey.log', 'a');
|
||||
$fp=fopen('/var/www/log/pouey.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);
|
||||
}
|
||||
@ -5031,4 +5234,28 @@ function getProColPart($siren, $rubrique='', $forceVerif=false, $idAnnonce=0) {
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
/*$tabSiren[$even['insDATEVE']]=array('rs'=>$even['insNOMEN'],
|
||||
'sigle'=>$even['insSIGLE'],
|
||||
'ape'=>$even['insAPEN700'],
|
||||
'nic'=>$even['insNICSIEGE'],
|
||||
'cj'=>$even['insCJ'],
|
||||
);
|
||||
$tabSiret[$even['insNIC']][$even['insDATEVE']]
|
||||
= array('ens'=>$even['insENSEIGNE'],
|
||||
'ape'=>$even['insAPET700'],
|
||||
'adresse'=>$even['insL2_COMP'].' '.$even['insL3_CADR'].' '.$even['insL4_VOIE'].' '.$even['insL5_DISP'].' '.$even['insL6_POST'].' '.$even['insL7_ETRG'],
|
||||
'effectif'=>$even['insEFENCENT'].' (Tranche '.$even['insTEFET'].')',
|
||||
);
|
||||
*/
|
||||
|
||||
function getInfoPrecedente($tabSir, $dateEven, $even) {
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMInsee, getInfoPrecedente avant le $dateEven pour '$even'", print_r($tabSir, true));
|
||||
foreach ($tabSir as $date=>$tabInfo) {
|
||||
if ($date>$dateEven) continue;
|
||||
return $tabInfo[$even];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
?>
|
@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
require_once 'framework/common/curl.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
//require_once 'Metier/partenaires/classMEuridile.php';
|
||||
@ -6,17 +6,17 @@ require_once 'framework/common/dates.php';
|
||||
require_once 'Metier/partenaires/classMGreffes.php';
|
||||
|
||||
class MBilans {
|
||||
|
||||
|
||||
public $siren;
|
||||
public $dernierExerciceDepose=0;
|
||||
public $dernierExerciceDeposeLe=0;
|
||||
// public $rncs;
|
||||
public $igreffe;
|
||||
|
||||
|
||||
function __construct($siren) {
|
||||
$this->siren=$siren;
|
||||
//$this->rncs=new MRncsFlux();
|
||||
$this->igreffe=new MGreffes();
|
||||
//$this->rncs=new MRncsFlux();
|
||||
$this->igreffe=new MGreffes();
|
||||
}
|
||||
|
||||
function __destruct() {}
|
||||
@ -39,13 +39,13 @@ class MBilans {
|
||||
$dateDerExercice=$ret[0]['dateExercice']*1;
|
||||
if ($dateDerDepot<>0) {
|
||||
$this->dernierExerciceDepose = WDate::dateT('Y-m-d','d/m/Y',@$ret2[0]['dateEffet']);
|
||||
$this->dernierExerciceDeposeLe = WDate::dateT('Y-m-d','d/m/Y',@$ret2[0]['Bodacc_Date_Parution']);
|
||||
$this->dernierExerciceDeposeLe = WDate::dateT('Y-m-d','d/m/Y',@$ret2[0]['Bodacc_Date_Parution']);
|
||||
}
|
||||
if ($accesPartenaire)
|
||||
$tabRet=$tabRet2=$this->igreffe->getListeBilans($this->siren);
|
||||
else
|
||||
$tabRet=$tabRet2=array();
|
||||
|
||||
|
||||
$tabTri=array();
|
||||
foreach ($tabRet as $millesime=>$bil) {
|
||||
$typeBilan=substr($millesime,0,1);
|
||||
@ -53,7 +53,7 @@ class MBilans {
|
||||
$tabTri[''.$dateExercice.'-'.$typeBilan]=$millesime;
|
||||
}
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après accès partenaire", print_r($tabRet2, true));
|
||||
|
||||
|
||||
foreach ($ret as $i=>$bil) {
|
||||
$millesime=WDate::dateT('Ymd','d/m/Y',$bil['dateExercice']);
|
||||
$tabRet[''.$bil['typeBilan'].$millesime]=array(
|
||||
@ -72,27 +72,43 @@ class MBilans {
|
||||
$tabTri[''.$bil['dateExercice'].'-'.$bil['typeBilan']]=$bil['typeBilan'].$millesime;
|
||||
}
|
||||
krsort($tabTri);
|
||||
$exercicePre=false;
|
||||
$typePre=false;
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren avant le tri", print_r($tabTri, true));
|
||||
$exercicePre=$typePre=$tmpPre=false;
|
||||
$refPre='';
|
||||
$strInfos='';
|
||||
foreach ($tabTri as $tmp=>$typeMillesime) {
|
||||
$exercice=substr($typeMillesime,0,8);
|
||||
$type=substr($typeMillesime,9,1);
|
||||
if ($exercice==$exercicePre && $type=='N' && $typePre=='S') unset($tabTri[$tmp]);
|
||||
$exercice=substr($tmp,0,8);
|
||||
$type=substr($tmp,9,1);
|
||||
$ref=$tabRet[''.$typeMillesime]['ref'];
|
||||
if ($exercice==$exercicePre && $type=='N' && $typePre=='S' && $refPre=='') {
|
||||
// Suppression du bilan RN de la liste si Réel Normal et Réel Simplifiés présents en base
|
||||
unset($tabTri[$tmp]);
|
||||
$strInfos.="Suppression de '$tmp'".EOL;
|
||||
}
|
||||
elseif ($exercice==$exercicePre && $type=='N' && $typePre=='S' && $refPre<>'') {
|
||||
// Suppression du bilan RS de la liste si Réel Normal Présent en base et réel simplifié non encore en base
|
||||
if ($tmpPre<>false) {
|
||||
unset($tabTri[$tmpPre]);
|
||||
$strInfos.="Suppression de '$tmpPre'".EOL;
|
||||
}
|
||||
}
|
||||
$exercicePre=$exercice;
|
||||
$typePre=$type;
|
||||
$refPre=@trim($ref);
|
||||
$tmpPre=$tmp;
|
||||
}
|
||||
krsort($tabTri);
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après le tri", print_r($tabTri, true).EOL.$strInfos.EOL);
|
||||
$tabRet3=array();
|
||||
foreach ($tabTri as $tmp=>$typeMillesime)
|
||||
$tabRet3[''.$typeMillesime]=$tabRet[''.$typeMillesime];
|
||||
|
||||
$tabRet3[''.$typeMillesime]=$tabRet[''.$typeMillesime];
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après le tri / retour", print_r($tabRet3, true));
|
||||
|
||||
|
||||
return $tabRet3;
|
||||
}
|
||||
|
||||
|
||||
function getBilan($millesime='', $typeBilan='N', $refPart=0, $accesPartenaire=false) {
|
||||
$millesimeDB=WDate::dateT('d/m/Y','Ymd',$millesime);
|
||||
$iDb2=new WDB();
|
||||
@ -119,10 +135,10 @@ class MBilans {
|
||||
// $tabBilan=$rncs->getBilan($refPart);
|
||||
$tabBilan=$this->igreffe->getBilan($this->siren, $refPart);
|
||||
//getBilan(479974115,'2008_sociaux-20081231-7803-04-B-03876-0013849'));
|
||||
|
||||
|
||||
// print_r($tabBilan);
|
||||
// die ("On veut le bilan $millesime $typeBilan $refPart");
|
||||
$fp=fopen(LOG_PATH.'/bilans.log', 'a');
|
||||
$fp=fopen('/var/www/log/bilans.log', 'a');
|
||||
fwrite($fp, "Bilan pour ".$this->siren." :\n".print_r($tabBilan,true)."\n\n\n");
|
||||
fclose($fp);
|
||||
if ($tabBilan) {
|
||||
@ -141,7 +157,7 @@ class MBilans {
|
||||
'unite' =>$tabBilan['MONNAIE_LIV_UNITE'],
|
||||
'postes' =>$strPostes,
|
||||
'partenaire' =>$tabBilan['SOURCE'],
|
||||
);
|
||||
);
|
||||
if (!$iDb2->insert('bilans', $tabInsert, true))
|
||||
$iDb2->update('bilans', $tabInsert, "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'");
|
||||
$ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'", true);
|
||||
@ -160,7 +176,7 @@ class MBilans {
|
||||
$tabBilan['MONNAIE_ORI'] = $bilan['monnaieOrigine'];
|
||||
$tabBilan['MONNAIE_LIV_UNITE'] = $bilan['unite'];
|
||||
$tabBilan['SOURCE'] = $bilan['partenaire'];
|
||||
|
||||
|
||||
// Devise et Unité
|
||||
if ($bilan['monnaie']=='EUR') $monnaie='€'; else $monnaie=$bilan['monnaie'];
|
||||
switch (strtoupper($bilan['unite'])) {
|
||||
@ -172,7 +188,7 @@ class MBilans {
|
||||
default: die('Unite Bilan ('. $bilan['unite'] .') non prise en charge !'); break;
|
||||
}
|
||||
$tabBilan['devise'] = /*$unite.*/$monnaie;
|
||||
|
||||
|
||||
/** Remplissage du tableau des postes du Bilan avec prise en compte de l'unité de la monnaie
|
||||
**/
|
||||
$tabTmp=explode(';', $bilan['postes']);
|
||||
@ -183,17 +199,17 @@ class MBilans {
|
||||
&& $tabTmp2[0]<>'M2G' && $tabTmp2[0]<>'M2H' // Autres effectifs
|
||||
&& $tabTmp2[0]<>'ZK' && $tabTmp2[0]<>'ZK1' // Taux
|
||||
&& $tabTmp2[0]<>'IJ' && $tabTmp2[0]<>'JH' && $tabTmp2[0]<>'ZR' // pour holding/ste mere
|
||||
)
|
||||
)
|
||||
$tabBilan[$tabTmp2[0]]=$tabTmp2[1]*1000;
|
||||
elseif ($unite=='M' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1' && $tabTmp2[0]<>'376' // Effectifs 2033 et 2050
|
||||
&& $tabTmp2[0]<>'M2G' && $tabTmp2[0]<>'M2H' // Autres effectifs
|
||||
&& $tabTmp2[0]<>'ZK' && $tabTmp2[0]<>'ZK1' // Taux
|
||||
&& $tabTmp2[0]<>'IJ' && $tabTmp2[0]<>'JH' && $tabTmp2[0]<>'ZR' // pour holding/ste mere
|
||||
)
|
||||
)
|
||||
$tabBilan[$tabTmp2[0]]=$tabTmp2[1]*1000000;
|
||||
else $tabBilan[$tabTmp2[0]]=$tabTmp2[1];
|
||||
}
|
||||
|
||||
|
||||
/** Calcul des valeures NET si l'information est absente en base
|
||||
**/
|
||||
if ($tabBilan['CONSOLIDE']=='N' || $tabBilan['CONSOLIDE']=='C') {
|
||||
@ -230,11 +246,11 @@ class MBilans {
|
||||
if (!isset($tabBilan['CG1']) && (isset($tabBilan['CF'])||isset($tabBilan['CG']))) $tabBilan['CG1']=$tabBilan['CF']-$tabBilan['CG'];
|
||||
if (!isset($tabBilan['CI1']) && (isset($tabBilan['CH'])||isset($tabBilan['CI']))) $tabBilan['CI1']=$tabBilan['CH']-$tabBilan['CI'];
|
||||
if (!isset($tabBilan['CK1']) && (isset($tabBilan['CJ'])||isset($tabBilan['CK']))) $tabBilan['CK1']=$tabBilan['CJ']-$tabBilan['CK'];
|
||||
|
||||
|
||||
if (!isset($tabBilan['CL2']) && isset($tabBilan['CL'])) $tabBilan['CL2']=$tabBilan['CL'];
|
||||
if (!isset($tabBilan['CM2']) && isset($tabBilan['CM'])) $tabBilan['CM2']=$tabBilan['CM'];
|
||||
if (!isset($tabBilan['CN2']) && isset($tabBilan['CN'])) $tabBilan['CN2']=$tabBilan['CN'];
|
||||
|
||||
|
||||
if (!isset($tabBilan['1A1']) && (isset($tabBilan['CO'])||isset($tabBilan['1A']))) $tabBilan['1A1']=$tabBilan['CO']-$tabBilan['1A'];
|
||||
} elseif ($tabBilan['CONSOLIDE']=='S') {
|
||||
//if (!isset($tabBilan['AC1']) && (isset($tabBilan['AB'])||isset($tabBilan['AC']))) $tabBilan['AC1']=$tabBilan['AB']-$tabBilan['AC'];
|
||||
@ -257,7 +273,7 @@ class MBilans {
|
||||
}
|
||||
/** Y a t'il suffisament d'informations sur le bilan précédent
|
||||
**/
|
||||
if ($bilan['dateExercicePre']*1==0 || $bilan['dureeExercicePre']*1==0 ||
|
||||
if ($bilan['dateExercicePre']*1==0 || $bilan['dureeExercicePre']*1==0 ||
|
||||
(($tabBilan['FL1']*1==0 || $tabBilan['EE1']*1==0) && ($tabBilan['CONSOLIDE']=='N' || $tabBilan['CONSOLIDE']=='C')) || // Réel Normal ou Consolidé
|
||||
(($tabBilan['NA3']*1==0 || $tabBilan['NP3']*1==0) && ($tabBilan['CONSOLIDE']=='A' || $tabBilan['CONSOLIDE']=='B')) || // Banque ou Assurance
|
||||
(($tabBilan['N15']*1==0 || $tabBilan['N32']*1==0) && $tabBilan['CONSOLIDE']=='S') // Réel Simplifié
|
||||
@ -267,7 +283,7 @@ class MBilans {
|
||||
$ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice<'$millesimeDB' ORDER BY dateExercice DESC LIMIT 0,1", true);
|
||||
$bilanPre=$ret[0];
|
||||
$tabBilan['DATE_CLOTURE_PRE'] = $bilanPre['dateExercice']; // SSAAMMJJ
|
||||
$tabBilan['DUREE_MOIS_PRE'] = $bilanPre['dureeExercice'];
|
||||
$tabBilan['DUREE_MOIS_PRE'] = $bilanPre['dureeExercice'];
|
||||
if ($bilanPre['monnaie']=='EUR') $monnaiePre='€'; else $monnaiePre=$bilanPre['monnaie'];
|
||||
switch (strtoupper($bilanPre['unite'])) {
|
||||
case 'K': $unitePre='K'; break;
|
||||
@ -278,7 +294,7 @@ class MBilans {
|
||||
default: die('Unite Bilan ('. $bilanPre['unite'] .') non prise en charge !'); break;
|
||||
}
|
||||
$tabBilanPre['devise'] = /*$unite.*/$monnaiePre;
|
||||
|
||||
|
||||
$tabTmp=explode(';', $bilanPre['postes']);
|
||||
/* foreach ($tabTmp as $i=>$strTmp) {
|
||||
$tabTmp2=explode('=', $strTmp);
|
||||
@ -295,16 +311,16 @@ class MBilans {
|
||||
if ($unite=='K' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1' && $tabTmp2[0]<>'376' // Effectifs 2033 et 2050
|
||||
&& $tabTmp2[0]<>'M2G' && $tabTmp2[0]<>'M2H' // Autres effectifs
|
||||
&& $tabTmp2[0]<>'ZK' && $tabTmp2[0]<>'ZK1' && $tabTmp2[0]<>'ZR' // Taux et infos Filliales
|
||||
)
|
||||
)
|
||||
$tabBilanPre[$tabTmp2[0]]=$tabTmp2[1]*1000;
|
||||
elseif ($unite=='M' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1' && $tabTmp2[0]<>'376' // Effectifs 2033 et 2050
|
||||
&& $tabTmp2[0]<>'M2G' && $tabTmp2[0]<>'M2H' // Autres effectifs
|
||||
&& $tabTmp2[0]<>'ZK' && $tabTmp2[0]<>'ZK1' && $tabTmp2[0]<>'ZR' // Taux et infos Filliales
|
||||
)
|
||||
)
|
||||
$tabBilanPre[$tabTmp2[0]]=$tabTmp2[1]*1000000;
|
||||
else $tabBilanPre[$tabTmp2[0]]=$tabTmp2[1];
|
||||
}
|
||||
|
||||
|
||||
/** Calcul des valeures NET N-1 si l'information est absente du bilan N-1 en base **/
|
||||
if ($tabBilan['CONSOLIDE']=='N' || $tabBilan['CONSOLIDE']=='C') {
|
||||
if (!isset($tabBilanPre['AA2']) && isset($tabBilanPre['AA'])) $tabBilanPre['AA2']=$tabBilanPre['AA'];
|
||||
@ -340,13 +356,13 @@ class MBilans {
|
||||
if (!isset($tabBilanPre['CG1']) && (isset($tabBilanPre['CF'])||isset($tabBilanPre['CG']))) $tabBilanPre['CG1']=$tabBilanPre['CF']-$tabBilanPre['CG'];
|
||||
if (!isset($tabBilanPre['CI1']) && (isset($tabBilanPre['CH'])||isset($tabBilanPre['CI']))) $tabBilanPre['CI1']=$tabBilanPre['CH']-$tabBilanPre['CI'];
|
||||
if (!isset($tabBilanPre['CK1']) && (isset($tabBilanPre['CJ'])||isset($tabBilanPre['CK']))) $tabBilanPre['CK1']=$tabBilanPre['CJ']-$tabBilanPre['CK'];
|
||||
|
||||
|
||||
if (!isset($tabBilanPre['CL2']) && isset($tabBilanPre['CL'])) $tabBilanPre['CL2']=$tabBilanPre['CL'];
|
||||
if (!isset($tabBilanPre['CM2']) && isset($tabBilanPre['CM'])) $tabBilanPre['CM2']=$tabBilanPre['CM'];
|
||||
if (!isset($tabBilanPre['CN2']) && isset($tabBilanPre['CN'])) $tabBilanPre['CN2']=$tabBilanPre['CN'];
|
||||
|
||||
|
||||
if (!isset($tabBilanPre['1A1']) && (isset($tabBilanPre['CO'])||isset($tabBilanPre['1A']))) $tabBilanPre['1A1']=$tabBilanPre['CO']-$tabBilanPre['1A'];
|
||||
|
||||
|
||||
/** Reprises des valeures N-1 si l'information est absente en base
|
||||
**/
|
||||
// Actif
|
||||
@ -600,10 +616,10 @@ class MBilans {
|
||||
}
|
||||
return $tabBilan;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function bilanSimplifie2Normal($bilanRS) {
|
||||
|
||||
|
||||
$tabBS2BN=array('AH'=>'010',
|
||||
'AI'=>'012',
|
||||
'AJ'=>'014',
|
||||
@ -651,7 +667,7 @@ class MBilans {
|
||||
'EB'=>'174',
|
||||
'EC'=>'176',
|
||||
'EE'=>'180',
|
||||
'EH'=>'156-195',
|
||||
'EH'=>'156-195',
|
||||
'FA'=>'210-209',
|
||||
'FB'=>'209',
|
||||
'FC'=>'210',
|
||||
@ -693,7 +709,7 @@ class MBilans {
|
||||
'YZ'=>'378',
|
||||
'YP'=>'376',
|
||||
);
|
||||
|
||||
|
||||
$bilanRN=array();
|
||||
foreach ($tabBS2BN as $posteRN => $formule) {
|
||||
if (preg_match('/\+|\-/', $formule)) {
|
||||
@ -724,12 +740,12 @@ class MBilans {
|
||||
$bilanRN['BN']=$bilanRS['050'];
|
||||
$bilanRN['BO']=$bilanRS['052'];
|
||||
}
|
||||
|
||||
|
||||
if ($bilanRS['070']<>0 || $bilanRS['074']<>0 || $bilanRS['052']<>0 || $bilanRS['062']<>0)
|
||||
$bilanRN['GC']=$bilanRS['256'];
|
||||
elseif ($bilanRS['070']==0 && $bilanRS['074']==0 && $bilanRS['052']==0 && $bilanRS['062']==0 && $bilanRS['254']<>0)
|
||||
$bilanRN['GD']=$bilanRS['256'];
|
||||
|
||||
|
||||
if ($bilanRS['584']<>0) {
|
||||
$bilanRN['HB']=$bilanRS['584'];
|
||||
$bilanRN['HA']=$bilanRS['290']-$bilanRS['584'];
|
||||
@ -741,8 +757,8 @@ class MBilans {
|
||||
$bilanRN['HE']=$bilanRS['582']-$bilanRS['300'];
|
||||
} else
|
||||
$bilanRN['HE']=$bilanRS['300'];
|
||||
|
||||
|
||||
return $bilanRN;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
@ -284,5 +284,4 @@ class MBilans {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@ -105,21 +105,25 @@ class MBourse {
|
||||
** @return unknown
|
||||
**/
|
||||
function getInfosBourse($siren=false) {
|
||||
global $timer;
|
||||
$iDb=new WDB('sdv1');
|
||||
|
||||
if (!$siren)
|
||||
$siren=$this->siren;
|
||||
|
||||
$isin=$this->getCodeIsin($siren);
|
||||
$timer['infosBoursieres-getCodeIsin']=microtime(true);
|
||||
$tabRet=array();
|
||||
if ($isin<>'') {
|
||||
$datePre=date('Y-m').'-01';
|
||||
$tabRes=$iDb->select( 'bourse_isin b, bourse_cours c',
|
||||
'siren, raisonSociale, adresse, effectif, code_sicovam, code_mnemo, code_bloomberg, code_datastream, code_isin, logo, code_ric, '.
|
||||
'dateIntroduction, dateDerAG, dateRadiation, autre_isin, eligibleSRD, eligiblePEA, nombreTitres, tel1, tel2, fax1, fax2, web, mail, '.
|
||||
'marche, placeCotation, description, secteur, activite, activiteDet, dirigeants, actionnaires, chiffresTrim, '.
|
||||
'c.autre, c.`date`, c.`heure`, c.`open` , c.`high` , c.`low` , c.`close` , c.`volume`',
|
||||
"(code_isin='$isin' OR siren=$siren) AND b.code_isin=c.isin AND c.autre IN('','e','f','g','m','s','u') AND c.`date`>'2008-03-01' ORDER BY b.dateUpdate DESC, c.dateInsert DESC ", false, MYSQL_ASSOC);
|
||||
"(code_isin='$isin' OR siren=$siren) AND b.code_isin=c.isin AND c.autre IN('','e','f','g','m','s','u') AND c.`date`>='$datePre' ORDER BY b.dateUpdate DESC, c.dateInsert DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
$tabRet=$tabRes[0];
|
||||
$timer['infosBoursieres-infosIsin']=microtime(true);
|
||||
|
||||
$tabRes=$iDb->select( 'bourse_cours',
|
||||
'min(close) AS coursMin, avg(close) AS coursMoy, max(close) AS coursMax',
|
||||
@ -128,6 +132,7 @@ class MBourse {
|
||||
$tabRet['coursMin']=$tabTmp['coursMin'];
|
||||
$tabRet['coursMoy']=$tabTmp['coursMoy'];
|
||||
$tabRet['coursMax']=$tabTmp['coursMax'];
|
||||
$timer['infosBoursieres-derniersCours']=microtime(true);
|
||||
/*
|
||||
$tabRes=$iDb->select( 'bourse_cours',
|
||||
'`date`, close',
|
||||
@ -197,4 +202,4 @@ Plus bas 10 ans (18/04/2005) 41.12*/
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
/*
|
||||
2. Concernant la date de fin de CS, devons nous comprendre les cas suivants de la sorte :
|
||||
A. 026 820 043 I 2009-10-31 La CS était valide jusq'au 31/10/2009... L'entreprise n'a plus de CS ? ou la CS est encore à prendre en compte ?
|
||||
@ -15,18 +15,18 @@ D. 067 200 329 I 2010-06-30 La CS est valide jusq'au 30/06/2010... Quid
|
||||
La cs privilège a une durée de 27 mois ( sauf bien sur les cs manuelles qui sont à la convenance de l'analyste, en général 12 mois ).
|
||||
*/
|
||||
class MFacto {
|
||||
|
||||
|
||||
public $risqueImpaye=false; // Y a t'il un risque d'impayé ?
|
||||
public $risqueImpayeMois=0;
|
||||
public $profilPayeur=0; // 0:N/D, 1:Excellent, 2=Bon, 3=Normal, 4=Lent, 5=Mauvais ou Défaut
|
||||
|
||||
|
||||
private $typeFlux = 0; // Type de flux en chargement 0:Acheteur, 1=CS, 2=Paiements
|
||||
private $iDb;
|
||||
|
||||
|
||||
public $DELAIPAY=0;
|
||||
public $DELAIPAYp='';
|
||||
public $DELAIPAY_MMAA='';
|
||||
|
||||
|
||||
private $tabInfoCS=array(
|
||||
'_00'=>array('risque'=>0,'type'=>'OK', 'libInt'=>'Néant', 'libExt'=>'Aucune difficulté significative ne nous a été signalée'),
|
||||
'_10'=>array('risque'=>3,'type'=>'IP', 'libInt'=>'Impayé BDF', 'libExt'=>"A surveiller. Présence d'impayé(s)"),
|
||||
@ -61,18 +61,18 @@ class MFacto {
|
||||
'_I' =>array('risque'=>3,'type'=>'IP', 'libInt'=>'Impayés', 'libExt'=>"A surveiller. Présence d'impayé(s) dans les 12 derniers mois"),
|
||||
'_P' =>array('risque'=>3,'type'=>'PR', 'libInt'=>'PRIVILEGES', 'libExt'=>'A surveiller. Présence de privilèges dans les 24 derniers mois'),
|
||||
'_D' =>array('risque'=>2,'type'=>'DEF', 'libInt'=>'PREVISIONS NEGATIVES', 'libExt'=>'A suivre. Informations terrain récentes négatives'),
|
||||
'_T' =>array('risque'=>2,'type'=>'LC', 'libInt'=>'LC Quelconque', 'libExt'=>"Nombreuses demandes d'avis de crédit"),
|
||||
'_T' =>array('risque'=>2,'type'=>'LC', 'libInt'=>'LC Quelconque', 'libExt'=>"Nombreuses demandes d'avis de crédit"),
|
||||
);
|
||||
// private $siren=0;
|
||||
// private $tabPaiements=array();
|
||||
|
||||
|
||||
function __construct() {
|
||||
$this->iDb=new WDB('sdv1');
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
}
|
||||
|
||||
|
||||
public function setTypeFic($typeFic) {
|
||||
$this->typeFlux=$typeFic;
|
||||
}
|
||||
@ -117,8 +117,8 @@ class MFacto {
|
||||
}
|
||||
return $tab;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getCoteSpeciale($siren) {
|
||||
$ret=$this->iDb->select( 'ge_cs2',
|
||||
'siren, cs, dateFin, dateInsert, dateConf',
|
||||
@ -126,7 +126,7 @@ class MFacto {
|
||||
$tabRet=array();
|
||||
foreach ($ret as $i=>$tabCS) {
|
||||
$dateEven=$tabCS['dateConf'];
|
||||
if ($dateEven=='0000-00-00') $dateEven=$tabCS['dateInsert'];
|
||||
if ($dateEven=='0000-00-00') $dateEven=$tabCS['dateInsert'];
|
||||
$tabRet[]=array('DateEven' => $dateEven,
|
||||
'DateFin' => $tabCS['dateFin'],
|
||||
'CoteCS' => $tabCS['cs'],
|
||||
@ -140,7 +140,7 @@ class MFacto {
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
|
||||
public function getCoteSpecialeOld($siren) {
|
||||
$ret=$this->iDb->select( 'ge_cs c LEFT JOIN ge_acheteurs a ON a.NUMACH=c.NUMGFH',
|
||||
'DATMAJ1, NUMGFH, CSAVAN, CSAPRE, SIRENE',
|
||||
@ -161,7 +161,7 @@ class MFacto {
|
||||
}
|
||||
|
||||
public function getPaiements($siren, $echelle='mois') {
|
||||
|
||||
|
||||
if ($echelle=='jour')
|
||||
$strGroupBy="GROUP BY p.DATPIE ";
|
||||
elseif ($echelle=='' || $echelle=='mois')
|
||||
@ -170,15 +170,15 @@ class MFacto {
|
||||
$strGroupBy="GROUP BY trimestre HAVING nbPieces>2 ";
|
||||
else // En mois par défaut
|
||||
$strGroupBy="GROUP BY mois HAVING nbPieces>2 ";
|
||||
|
||||
|
||||
$ret=$this->iDb->select( 'ge_paiements p LEFT JOIN ge_acheteurs a ON a.NUMACH=p.NUMACH',
|
||||
"p.NUMACH, DATE_FORMAT(p.DATPIE, '%Y-%m') AS mois,
|
||||
"p.NUMACH, DATE_FORMAT(p.DATPIE, '%Y-%m') AS mois,
|
||||
CONCAT(DATE_FORMAT(p.DATPIE,'%Y'),'-',IF(DATE_FORMAT(p.DATPIE,'%m')<4,1,IF(DATE_FORMAT(p.DATPIE,'%m')<7,2,IF(DATE_FORMAT(p.DATPIE,'%m')<10,3,4)))) AS trimestre,
|
||||
count(*) AS nbPieces,
|
||||
AVG(DATEDIFF(NOW(), p.DATECH)) AS nbJourRetard, AVG(DATEDIFF(p.DATPAI, p.DATECH)) AS nbJourPaiement,
|
||||
ROUND(AVG(DATEDIFF(NOW(), p.DATECH) - DATEDIFF(p.DATPAI, p.DATECH))) AS nbJourMoyens,
|
||||
IF(AVG(DATEDIFF(NOW(), p.DATECH) - DATEDIFF( p.DATPAI, p.DATECH ) ) <6, 0, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <36, 30, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <66, 60, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <96, 90, 120 ) ) ) ) AS nbJours,
|
||||
SUM(p.MNTPIE) AS mtPieces, SUM(p.MNTFRF) AS mtPaiements, SUM(p.MNTLIT) AS mtLitiges,
|
||||
IF(AVG(DATEDIFF(NOW(), p.DATECH) - DATEDIFF( p.DATPAI, p.DATECH ) ) <6, 0, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <36, 30, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <66, 60, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <96, 90, 120 ) ) ) ) AS nbJours,
|
||||
SUM(p.MNTPIE) AS mtPieces, SUM(p.MNTFRF) AS mtPaiements, SUM(p.MNTLIT) AS mtLitiges,
|
||||
p.CODDEV, a.SIRENE, a.RAISOC, a.CODPOS, a.VILLE",
|
||||
"a.SIRENE=$siren AND DATEDIFF(NOW(),p.DATECH)<736 AND p.DATECH<NOW() $strGroupBy ORDER BY p.DATPIE DESC", false, MYSQL_ASSOC);
|
||||
$tabRet=array();
|
||||
@ -191,7 +191,7 @@ class MFacto {
|
||||
elseif ($nbJoursMoyen<126) $tranche=120;
|
||||
elseif ($nbJoursMoyen<156) $tranche=150;
|
||||
else $tranche=180;
|
||||
|
||||
|
||||
$tabRet[]=array('trimestre' => $tabPai['trimestre'],
|
||||
'mois' => $tabPai['mois'],
|
||||
'nbPieces' => $tabPai['nbPieces'],
|
||||
@ -200,7 +200,7 @@ class MFacto {
|
||||
'nbJourMoyen' => $nbJoursMoyen,
|
||||
'nbJourMoyen2' => $tabPai['nbJourMoyens'],
|
||||
'tranchePaiement'=>$tranche,
|
||||
'tranchePaie90' =>$tabPai['nbJours'],
|
||||
'tranchePaie90' =>$tabPai['nbJours'],
|
||||
'mtPieces' => $tabPai['mtPieces'],
|
||||
'mtPaiements' => $tabPai['mtPaiements'],
|
||||
'mtLitiges' => $tabPai['mtLitiges'],
|
||||
@ -208,9 +208,20 @@ class MFacto {
|
||||
);
|
||||
}
|
||||
//$this->tabPaiements=$tabRet;
|
||||
return $tabRet;
|
||||
/*@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Paiements", "SELECT p.NUMACH, DATE_FORMAT(p.DATPIE, '%Y-%m') AS mois,
|
||||
CONCAT(DATE_FORMAT(p.DATPIE,'%Y'),'-',IF(DATE_FORMAT(p.DATPIE,'%m')<4,1,IF(DATE_FORMAT(p.DATPIE,'%m')<7,2,IF(DATE_FORMAT(p.DATPIE,'%m')<10,3,4)))) AS trimestre,
|
||||
count(*) AS nbPieces,
|
||||
AVG(DATEDIFF(NOW(), p.DATECH)) AS nbJourRetard, AVG(DATEDIFF(p.DATPAI, p.DATECH)) AS nbJourPaiement,
|
||||
ROUND(AVG(DATEDIFF(NOW(), p.DATECH) - DATEDIFF(p.DATPAI, p.DATECH))) AS nbJourMoyens,
|
||||
IF(AVG(DATEDIFF(NOW(), p.DATECH) - DATEDIFF( p.DATPAI, p.DATECH ) ) <6, 0, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <36, 30, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <66, 60, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <96, 90, 120 ) ) ) ) AS nbJours,
|
||||
SUM(p.MNTPIE) AS mtPieces, SUM(p.MNTFRF) AS mtPaiements, SUM(p.MNTLIT) AS mtLitiges,
|
||||
p.CODDEV, a.SIRENE, a.RAISOC, a.CODPOS, a.VILLE
|
||||
FROM ge_paiements p LEFT JOIN ge_acheteurs a ON a.NUMACH=p.NUMACH
|
||||
WHERE a.SIRENE=$siren AND DATEDIFF(NOW(),p.DATECH)<736 AND p.DATECH<NOW() $strGroupBy ORDER BY p.DATPIE DESC".EOL.EOL.print_r($tabRet, true).EOL);**/
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
|
||||
public function getProfilPayeur($siren) {
|
||||
if ($siren<1000) return '';
|
||||
$libProfil='';
|
||||
@ -238,11 +249,11 @@ class MFacto {
|
||||
if ($tabPai['tranchePaiement']>$paie_max) $paie_max=$tabPai['tranchePaiement'];
|
||||
}
|
||||
$tauxLitige=$totLitiges/$totFactures;
|
||||
|
||||
|
||||
if ($tauxLitige>=0.5) $libProfil.='Litiges très importants. ';
|
||||
elseif ($tauxLitige>0.25) $libProfil.='Litiges importants. ';
|
||||
elseif ($tauxLitige>0.05) $libProfil.='Présence de litiges. ';
|
||||
|
||||
|
||||
if ($tabProfil[0]==$tabProfil[1] && $tabProfil[1]==$tabProfil[2]) {
|
||||
if ($tranche=0) { $libProfil.='Paiements à échéance'; $this->profilPayeur=1; }
|
||||
elseif ($tranche<=30) { $libProfil.='Paiements à 30 jours maximum'; $this->profilPayeur=2; }
|
||||
@ -258,7 +269,7 @@ class MFacto {
|
||||
if ($tranche<$tr_prec) $libProfil.='Amélioration des délais. ';
|
||||
elseif ($tranche==$tr_prec && $tr_prec<$tr_prec2) $libProfil.='Amélioration des délais. ';
|
||||
else { $this->risqueImpaye=true; $libProfil.='Allongement des délais. '; }
|
||||
|
||||
|
||||
if ($tranche=0) { $libProfil.='Paiements à échéance'; $this->profilPayeur=1; }
|
||||
elseif ($tranche<=30) { $libProfil.='Paiements à 30 jours maximum'; $this->profilPayeur=2; }
|
||||
elseif ($tranche<=60) { $libProfil.='Paiements à 60 jours maximum'; $this->profilPayeur=3; }
|
||||
@ -272,13 +283,13 @@ class MFacto {
|
||||
$libProfil.="Paiements entre $paie_min et $paie_max jour(s)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (trim($libProfil)=='' && $siren<>552100554 && $siren<>552144503 && $siren<>479974115
|
||||
&& $siren<>0 && $siren<>494967938 ) {
|
||||
$ret=$this->iDb->select('jo.surveillances_listes',
|
||||
'ref, dateAjout, dateConf, dateSuppr, dateDerEnvoi',
|
||||
"idClient='SURBODPRDFTSRECOCASH' AND siren=$siren AND dateSuppr=0
|
||||
AND ABS(DATEDIFF(dateAjout, NOW()))<365
|
||||
AND ABS(DATEDIFF(dateAjout, NOW()))<365
|
||||
ORDER BY dateConf DESC, dateAjout DESC", false, MYSQL_ASSOC);
|
||||
foreach ($ret as $i=>$tabCS) {
|
||||
$dateMAJ=WDate::dateT('Y-m-d', 'M Y', $tabCS['dateAjout']);
|
||||
@ -289,54 +300,62 @@ class MFacto {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Paiements", $libProfil.EOL.'Profil payeur = '. $this->profilPayeur .EOL.print_r($tabPaie, true).EOL);
|
||||
|
||||
|
||||
return $libProfil;
|
||||
}
|
||||
|
||||
|
||||
public function getTabPaiements($siren) {
|
||||
if ($siren<1000) return false;
|
||||
|
||||
$tabNbr=array(); // Tableau de travail du nombre de factures par trimestre et par tranches de délais de paiements
|
||||
$tabMtAn=array(); // Tableau de travail du nombre de factures par montant et par tranches de délais de paiements
|
||||
|
||||
$tabNbr2=array(); // Tableau retour du nombre de factures par trimestre et par tranches de délais de paiements
|
||||
$tabMtAn2=array(); // Tableau retour du nombre de factures par montant et par tranches de délais de paiements
|
||||
|
||||
$tabPaie=$this->getPaiements($siren, 'jour');
|
||||
foreach ($tabPaie as $i=>$tabPai) {
|
||||
@$tabNbr[$tabPai['trimestre']][$tabPai['tranchePaiement']]+=$tabPai['nbPieces'];
|
||||
@$tabNbr[$tabPai['trimestre']]['d='.$tabPai['tranchePaiement']]+=$tabPai['nbPieces'];
|
||||
@$tabNbr[$tabPai['trimestre']]['all']+=$tabPai['nbPieces'];
|
||||
$mt=$tabPai['mtPieces']/$tabPai['nbPieces'];
|
||||
// echo "$i\t".$tabPai['trimestre']." (".$tabPai['tranchePaiement']." j)\t$mt=".$tabPai['mtPieces'].'/'.$tabPai['nbPieces'].EOL;
|
||||
if ($mt<500) { @$tabMtAn[1][$tabPai['tranchePaiement']]++; @$tabMtAn[1]['all']++; }
|
||||
elseif ($mt<2000) { @$tabMtAn[2][$tabPai['tranchePaiement']]++; @$tabMtAn[2]['all']++; }
|
||||
elseif ($mt<10000) { @$tabMtAn[10][$tabPai['tranchePaiement']]++; @$tabMtAn[10]['all']++; }
|
||||
elseif ($mt<20000) { @$tabMtAn[20][$tabPai['tranchePaiement']]++; @$tabMtAn[20]['all']++; }
|
||||
elseif ($mt<50000) { @$tabMtAn[50][$tabPai['tranchePaiement']]++; @$tabMtAn[50]['all']++; }
|
||||
elseif ($mt<100000) { @$tabMtAn[100][$tabPai['tranchePaiement']]++; @$tabMtAn[100]['all']++; }
|
||||
elseif ($mt<200000) { @$tabMtAn[200][$tabPai['tranchePaiement']]++; @$tabMtAn[200]['all']++; }
|
||||
else { @$tabMtAn[999][$tabPai['tranchePaiement']]++; @$tabMtAn[999]['all']++; }
|
||||
// echo "$i\t".$tabPai['trimestre']." (".$tabPai['tranchePaiement']." j)\t$mt=".$tabPai['mtPieces'].'/'.$tabPai['nbPieces'].EOL;
|
||||
if ($mt<500) { @$tabMtAn[1]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[1]['all']++; }
|
||||
elseif ($mt<2000) { @$tabMtAn[2]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[2]['all']++; }
|
||||
elseif ($mt<10000) { @$tabMtAn[10]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[10]['all']++; }
|
||||
elseif ($mt<20000) { @$tabMtAn[20]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[20]['all']++; }
|
||||
elseif ($mt<50000) { @$tabMtAn[50]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[50]['all']++; }
|
||||
elseif ($mt<100000) { @$tabMtAn[100]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[100]['all']++; }
|
||||
elseif ($mt<200000) { @$tabMtAn[200]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[200]['all']++; }
|
||||
else { @$tabMtAn[999]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[999]['all']++; }
|
||||
//@$tabMtAn['all'][$tabPai['tranchePaiement']]++;
|
||||
}
|
||||
|
||||
// Recalcul des délais par Trimestre
|
||||
foreach ($tabNbr as $trim=>$tabTranche) {
|
||||
ksort($tabTranche);
|
||||
foreach ($tabTranche as $tranche=>$mt) {
|
||||
if ($tranche=='all') $tabNbr2[$trim]['nb']=$mt;
|
||||
else $tabNbr2[$trim]['d='.$tranche]=round(($mt/$tabNbr2[$trim]['nb'])*100,1);
|
||||
foreach ($tabTranche as $tranche=>$mt3) {
|
||||
$tranche=str_replace('d=','',$tranche);
|
||||
if ($tranche=='all') $tabNbr2[$trim]['nb']=$mt3;
|
||||
else $tabNbr2[$trim]['d='.$tranche]=round(($mt3/$tabNbr2[$trim]['nb'])*100,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Recalcul des délais par Montants
|
||||
ksort($tabMtAn );
|
||||
ksort($tabMtAn);
|
||||
foreach ($tabMtAn as $mt=>$tabTranche) {
|
||||
ksort($tabTranche);
|
||||
foreach ($tabTranche as $tranche=>$mt2) {
|
||||
if ($tranche=='all') $tabMtAn2[$mt]['nb']=$mt2;
|
||||
else $tabMtAn2[$mt]['d='.$tranche]=round(($mt2/$tabMtAn2[$mt]['nb'])*100,1);
|
||||
$tranche=str_replace('d=','',$tranche);
|
||||
if ($tranche=='all') $tabMtAn2['_'.$mt]['nb']=$mt2;
|
||||
else $tabMtAn2['_'.$mt]['d='.$tranche]=round(($mt2/$tabMtAn2['_'.$mt]['nb'])*100,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Tableaux des Paiements", 'Paiements par montants :'.EOL.print_r($tabMtAn2, true).EOL.EOL.'Paiements par trimestres :'.EOL.print_r($tabNbr2, true).EOL.print_r($tabNbr, true).EOL.print_r($tabMtAn, true).EOL);
|
||||
return array('parMont'=>$tabMtAn2,
|
||||
'parTrim'=>$tabNbr2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
<?
|
||||
|
||||
<?php
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
class MMarques {
|
||||
@ -31,6 +30,59 @@ class MMarques {
|
||||
//$this->partSaveSession();
|
||||
}
|
||||
|
||||
|
||||
/** Liste des marques pour un siren donné ou détail d'une marque d'une entreprise
|
||||
* @param $siren int
|
||||
* @param $idDepot int Numéro de la marque ou Néant/0 si liste des marques
|
||||
*/
|
||||
function getMarques($siren, $idDepot=0) {
|
||||
//SELECT `id`, `typeMarque`, ``, `rayonMarque`, `urlImage`, `idMarque`, `deposantMarque`, `numeroMarque`, `classesMarque`, `idObjetPdf`, `periMarque`, `idObjetImg`, `detailDeposant`, `sirenDeposant`, `sirenValide`, `idSirenage`, `detailMandataire`, `detailNumero`, `detailStatut`, `dateDepot`, `lieuDepot`, `infoMarque`, `adresseCorresp`, `dateExpir`, `dateInsert` FROM `marques`
|
||||
$marques=array();
|
||||
$strSql="1 ";
|
||||
if ($siren>0) $strSql.="AND sirenDeposant=$siren ";
|
||||
if ($idDepot>0) $strSql.="AND numeroMarque=$idDepot ";
|
||||
$res=$this->iDb->select('marques', 'nomMarque, detailDeposant, sirenDeposant, dateDepot, numeroMarque, classesMarque, periMarque, dateExpir, idObjetImg, idObjetPdf', "$strSql ORDER BY dateDepot DESC");
|
||||
if (count($res)>0) {
|
||||
foreach ($res as $i=>$marque) {
|
||||
if ($marque['nomMarque']==' ') $nomMarque='(figurative)';
|
||||
else $nomMarque=$marque['nomMarque'];
|
||||
$marques[$i]=array( 'nomMarque' =>$nomMarque,
|
||||
'detailDeposant'=>$marque['detailDeposant'],
|
||||
'sirenDeposant' =>$marque['sirenDeposant'],
|
||||
'dateDepot' =>$marque['dateDepot'],
|
||||
'classesMarque' =>$marque['classesMarque'],
|
||||
'periMarque' =>$marque['periMarque'],
|
||||
'dateExpir' =>$marque['dateExpir'],
|
||||
'numeroMarque' =>$marque['numeroMarque'],
|
||||
'imgLink' =>$marque['idObjetImg'],
|
||||
'pdfLink' =>$marque['idObjetPdf'],
|
||||
);
|
||||
if ($idDepot<>0) {
|
||||
if ($marque['numeroMarque']==$idDepot) {
|
||||
if (file_exists(DOC_WEB_LOCAL."marques/$idDepot.jpeg") &&
|
||||
filesize(DOC_WEB_LOCAL."marques/$idDepot.jpeg")>42)
|
||||
$marques[$i]['UrlLien']=DOC_WEB_URL."marques/$idDepot.jpeg";
|
||||
elseif (file_exists(DOC_WEB_LOCAL."marques/$idDepot.gif") &&
|
||||
filesize(DOC_WEB_LOCAL."marques/$idDepot.gif")>42)
|
||||
$marques[$i]['UrlLien']=DOC_WEB_URL."marques/$idDepot.gif";
|
||||
else
|
||||
$marques[$i]['UrlLien']='';
|
||||
/*if (!file_exists(DOC_WEB_LOCAL."marques/$siren-$idDepot.jpg") ||
|
||||
filesize(DOC_WEB_LOCAL."marques/$siren-$idDepot.jpg")<43) {
|
||||
$fp=@fopen(DOC_WEB_LOCAL."marques/$siren-$idDepot.jpg", 'w');
|
||||
$fp=@fopen("/var/www/log/marques.log", "a");
|
||||
*/
|
||||
//return end($marques);
|
||||
return array($marques[$i]);;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $marques;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getListeMarques($numMarque, $raisonSociale='', $objet='', $detail=false) {
|
||||
|
||||
$nbResultatsTot=false;
|
||||
@ -416,6 +468,8 @@ class MMarques {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getInfosDisponbiles($siren) {
|
||||
$this->siren=$siren;
|
||||
$this->partConnection();
|
||||
@ -1730,7 +1784,4 @@ class MMarques {
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
}
|
@ -1,28 +1,28 @@
|
||||
<?
|
||||
<?php
|
||||
|
||||
//ini_set('soap.wsdl_cache_enabled', 1); // 0 en dév
|
||||
|
||||
class MTvaOld {
|
||||
|
||||
|
||||
public $vatNumber=''; // Numéro de TVA retourné
|
||||
public $vatDefined=false; // Le numéro de TVA est il validé ?
|
||||
public $errnum=0; // Numéro de l'erreur en cas d'erreur
|
||||
public $errmsg=''; // Message de l'erreur en cas d'erreur
|
||||
|
||||
private $siren;
|
||||
|
||||
private $siren;
|
||||
|
||||
function __construct($siren, $accesDist=true) {
|
||||
//$accesDist=false;
|
||||
if ($accesDist==true) {
|
||||
|
||||
/*$fp=fopen(LOG_PATH.'/infoVat.log', 'a');
|
||||
|
||||
/*$fp=fopen('/var/www/log/infoVat.log', 'a');
|
||||
fwrite($fp, "MTva->__construct pour $siren $accesDist\n");
|
||||
fclose($fp);
|
||||
*/
|
||||
$this->siren=$siren;
|
||||
$client = new SoapClient('http://ws1.scores-decisions.com/entreprise/vat.wsdl',
|
||||
array( 'trace' => 1, 'soap_version' => SOAP_1_1,
|
||||
'login' => 'TESTTVA', 'password' => 'TVATESTPW'));
|
||||
'login' => 'TESTTVA', 'password' => 'TVATESTPW'));
|
||||
try {
|
||||
$O = $client->getCompanyVat($this->siren);
|
||||
if ($O->error->errnum) {
|
||||
@ -57,14 +57,14 @@ class MTvaOld {
|
||||
|
||||
|
||||
class MTva {
|
||||
|
||||
|
||||
public $vatNumber=''; // Numéro de TVA retourné
|
||||
public $vatDefined=false; // Le numéro de TVA est il validé ?
|
||||
public $errnum=0; // Numéro de l'erreur en cas d'erreur
|
||||
public $errmsg=''; // Message de l'erreur en cas d'erreur
|
||||
|
||||
private $siren;
|
||||
|
||||
private $siren;
|
||||
|
||||
function __construct($siren, $accesDist=true) {
|
||||
|
||||
$sirenIn=$siren*1;
|
||||
@ -85,10 +85,10 @@ class MTva {
|
||||
elseif ($sirenIn<010000000) $siren='00'.$sirenIn;
|
||||
elseif ($sirenIn<100000000) $siren='0'.$sirenIn;
|
||||
else $siren=''.$sirenIn;
|
||||
|
||||
|
||||
$this->siren=$siren;
|
||||
$cleAlgo=$this->genereCleFr();
|
||||
|
||||
|
||||
if ($cleAlgo<10) $cleAlgo='0'.$cleAlgo;
|
||||
else $cleAlgo=''.$cleAlgo;
|
||||
$tabRep=array();
|
||||
@ -97,10 +97,11 @@ class MTva {
|
||||
$this->errmsg='Siren invalide';
|
||||
return false;
|
||||
}
|
||||
$iDb=new WDB('sdv1');
|
||||
$iDb=new WDB('sdv1');
|
||||
$info=$iDb->select('siren_tva', "cle, DATE_FORMAT(dateMod,'%Y%m%d') as DateMAJ", "siren=$siren", false, MYSQL_ASSOC);
|
||||
$tab=$info[0];
|
||||
if (count($tab)>0) {
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMTva sur $siren en cache", print_r($tab, true));
|
||||
if ( $tab['cle']<>NULL || ( $tab['cle']==NULL && $tab['DateMAJ']>=date('Ymd',mktime(0,0,0,date('m')-6,date('d'),date('Y'))) )) {
|
||||
$cle=$tab['cle'];
|
||||
if ($cle==NULL) { $attribue=false; $cle=$cleAlgo; }
|
||||
@ -109,6 +110,7 @@ class MTva {
|
||||
$this->vatDefined=$attribue;
|
||||
return true;
|
||||
}
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMTva sur $siren REVALIDATION", print_r($tab, true));
|
||||
}
|
||||
$cle=$cleAlgo;
|
||||
$nbIndispo=0;
|
||||
@ -128,9 +130,11 @@ class MTva {
|
||||
// $referer='http://ec.europa.eu/taxation_customs/vies/fr/vieshome.htm';
|
||||
$url='http://ec.europa.eu/taxation_customs/vies/viesquer.do';
|
||||
$referer='http://ec.europa.eu/taxation_customs/vies/';
|
||||
|
||||
|
||||
$page=getUrl($url, '', $postData, $referer, false, 'ec.europa.eu', '', 15);
|
||||
$duree = round(microtime_float()-$tdeb, 3);
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMTva sur $siren en $duree", print_r($page, true));
|
||||
|
||||
if ($page['err_num']<>0) {
|
||||
debugLog('W', 'TVA Erreur CURL n°'. $page['err_num'] .', '. $page['err_msg'] ." sur le Siren $siren, numéro de TVA = FR $cle $siren. Durée = $duree s !", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
@ -145,14 +149,14 @@ class MTva {
|
||||
$tabUpdate=array('cle'=>$cle, 'duree'=>$duree);
|
||||
if (!$iDb->insert('siren_tva', $tabInsert))
|
||||
if (!$iDb->update('siren_tva', $tabUpdate, "siren=$siren"))
|
||||
echo '';//date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .') : '. mysql_error() . $eol;
|
||||
debugLog('W', "Siren $siren, numéro de TVA = FR $cle $siren, impossible de MAJ la clef ($duree s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
//echo date ('Y/m/d - H:i:s') ." - Ligne $k/$nbk, N°TVA FR $cle $siren validé .".$eol;
|
||||
debugLog('I', "Siren $siren, numéro de TVA = FR $cle $siren ($duree s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=true;
|
||||
return true;
|
||||
//return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>array('siren'=>$siren, 'vatNumber'=>"FR$cle$siren", 'vatDefined'=>true));
|
||||
} elseif (strpos($body, 'Service non disponible')>0 ||
|
||||
} elseif (strpos($body, 'Service non disponible')>0 ||
|
||||
strpos($body, 'ponse trop long.')>0) {
|
||||
$nbIndispo++;
|
||||
if ($nbIndispo<3) {
|
||||
@ -163,10 +167,10 @@ class MTva {
|
||||
//echo date ('Y/m/d - H:i:s') .' - Reprise du Siren = '. $siren . $eol;
|
||||
} else {
|
||||
$tabInsert=array('siren'=>$siren,'cle'=>'NULL', 'duree'=>$duree);
|
||||
//$tabUpdate=array('cle'=>'NULL');
|
||||
$tabUpdate=array('cle'=>'NULL', 'duree'=>$duree);
|
||||
if (!$iDb->insert('siren_tva', $tabInsert))
|
||||
//if (!mysql_update('siren_tva', $tabUpdate, "siren=$siren"))
|
||||
echo '';//date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .') : '. mysql_error() . $eol;
|
||||
if (!$iDb->update('siren_tva', $tabUpdate, "siren=$siren"))
|
||||
debugLog('W', "Siren $siren, numéro de TVA = FR $cle $siren, impossible de MAJ la clef ($duree s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
debugLog('I', "Siren $siren, numéro de TVA = FR $cle $siren vérification non disponible ($duree s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
@ -175,15 +179,14 @@ class MTva {
|
||||
//echo date ('Y/m/d - H:i:s') .' - Temporisation n°'.$nbIndispo . $eol;
|
||||
} else {
|
||||
$tabInsert=array('siren'=>$siren,'cle'=>'NULL', 'duree'=>$duree);
|
||||
//$tabUpdate=array('cle'=>'NULL');
|
||||
$tabUpdate=array('cle'=>'NULL', 'duree'=>$duree);
|
||||
if (!$iDb->insert('siren_tva', $tabInsert))
|
||||
//if (!mysql_update('siren_tva', $tabUpdate, "siren=$siren"))
|
||||
echo '';//date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .') : '. mysql_error() . $eol;
|
||||
if (!$iDb->update('siren_tva', $tabUpdate, "siren=$siren"))
|
||||
debugLog('W', "Siren $siren, numéro de TVA = FR $cle $siren, impossible de MAJ la clef ($duree s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
debugLog('I', "Siren $siren, numéro de TVA = FR $cle $siren non attribué ($duree s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
return true;
|
||||
//return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>array('siren'=>$siren, 'vatNumber'=>"FR$cle$siren", 'vatDefined'=>false));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -206,7 +209,7 @@ class MTva {
|
||||
** @return La clé du numéro de TVA
|
||||
**/
|
||||
private function genereCleFr() {
|
||||
|
||||
|
||||
$siren=$this->siren;
|
||||
|
||||
// Position du chiffre SIREN (1 à 9)
|
||||
@ -221,7 +224,7 @@ class MTva {
|
||||
$tabFirst[7]=array(65,57,95,60,08,61,76,29,34);
|
||||
$tabFirst[8]=array(17,91,79,39,35,54,85,59,37);
|
||||
$tabFirst[9]=array(66,28,63,18,62,47,94,89,40);
|
||||
|
||||
|
||||
// Chiffre 0 à 9
|
||||
$tabPoids=array(1,34,-16,-21,27,-7,9,30,3);
|
||||
$cle=$first=0;
|
||||
@ -233,7 +236,7 @@ class MTva {
|
||||
$cle+=$tabPoids[$pos]*$chiffre;
|
||||
}
|
||||
}
|
||||
while(true) {
|
||||
while(true) {
|
||||
if ($cle>96) $cle=$cle-97;
|
||||
elseif ($cle<0) $cle=$cle+97;
|
||||
else break;
|
||||
@ -241,8 +244,8 @@ class MTva {
|
||||
if ($cle==0) return 96;
|
||||
return ($cle-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** Test de la validité du siren demandé
|
||||
** @param int SIREN à tester
|
||||
** @param int NIC (facultatif)
|
||||
@ -262,7 +265,7 @@ class MTva {
|
||||
case 7: $siren='00'.$siren; break;
|
||||
case 8: $siren='0'.$siren; break;
|
||||
}
|
||||
|
||||
|
||||
if (strlen($nic)>0) {
|
||||
switch (strlen($nic)) {
|
||||
case 1: $nic='0000'.$nic; break;
|
||||
@ -271,7 +274,7 @@ class MTva {
|
||||
case 4: $nic='0'.$nic; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!valideData($siren, 9, 9,'N')) //Siren non précisé ou incorrect.
|
||||
return $erreur;
|
||||
elseif ($siren*1==0) // Siren vide
|
||||
@ -283,7 +286,7 @@ class MTva {
|
||||
$somme=0;
|
||||
for ($i=0; $i<=8; $i+=2) // Traitement IMPAIR
|
||||
$somme+=(integer)substr($siren,$i,1);
|
||||
|
||||
|
||||
for ($i=1; $i<=7; $i+=2)
|
||||
{ // Traitement PAIR
|
||||
$var_tmp=(string)(2*((integer)substr($siren,$i,1)));
|
||||
@ -292,7 +295,7 @@ class MTva {
|
||||
$som_tmp+=(integer)substr($var_tmp,$j,1);
|
||||
$somme+=$som_tmp;
|
||||
}
|
||||
|
||||
|
||||
if ((integer)($somme/10)!=($somme/10))
|
||||
{ // Le Siren est faux
|
||||
if (substr($siren,0,3)!='200') // Les siren débutant par 200 sont toujours valides (sirens provisoires de la BDF?!)
|
||||
@ -301,7 +304,7 @@ class MTva {
|
||||
} else {
|
||||
if (!valideData($nic,1,5,'N')) // Nic de format incorrect.
|
||||
return $erreur;
|
||||
|
||||
|
||||
$SIRET=$siren.$nic;
|
||||
$somme=0;
|
||||
for ($i=0; $i<=12; $i+=2)
|
||||
@ -314,7 +317,7 @@ class MTva {
|
||||
}
|
||||
for ($i=1; $i<=13; $i+=2) // Traitement IMPAIR
|
||||
$somme+=(integer)substr($SIRET,$i,1);
|
||||
|
||||
|
||||
if ((integer)($somme/10)!=($somme/10))// Le Siret est faux
|
||||
return $erreur;
|
||||
}
|
||||
@ -323,5 +326,4 @@ class MTva {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,57 +0,0 @@
|
||||
<?
|
||||
|
||||
ini_set('soap.wsdl_cache_enabled', 1); // 0 en dév
|
||||
|
||||
class MTva {
|
||||
|
||||
public $vatNumber=''; // Numéro de TVA retourné
|
||||
public $vatDefined=false; // Le numéro de TVA est il validé ?
|
||||
public $errnum=0; // Numéro de l'erreur en cas d'erreur
|
||||
public $errmsg=''; // Message de l'erreur en cas d'erreur
|
||||
|
||||
private $siren;
|
||||
|
||||
function __construct($siren, $accesDist=true) {
|
||||
//$accesDist=false;
|
||||
if ($accesDist==true) {
|
||||
|
||||
/*$fp=fopen(LOG_PATH.'/infoVat.log', 'a');
|
||||
fwrite($fp, "MTva->__construct pour $siren $accesDist\n");
|
||||
fclose($fp);
|
||||
*/
|
||||
$this->siren=$siren;
|
||||
$client = new SoapClient('http://ws1.scores-decisions.com/entreprise/vat.wsdl',
|
||||
array( 'trace' => 1, 'soap_version' => SOAP_1_1,
|
||||
'login' => 'TESTTVA', 'password' => 'TVATESTPW'));
|
||||
try {
|
||||
$O = $client->getCompanyVat($this->siren);
|
||||
if ($O->error->errnum) {
|
||||
//echo 'Erreur : '. $O->error->errmsg .' ('. $O->error->errnum .")\n";
|
||||
//echo $client->__getLastResponse()."\n";
|
||||
$this->errnum=$O->error->errnum;
|
||||
$this->errmsg=$O->error->errmsg;
|
||||
return false;
|
||||
} else {
|
||||
$val=$O->result;
|
||||
$this->vatNumber=$val->vatNumber;
|
||||
$this->vatDefined=$val->vatDefined;
|
||||
}
|
||||
} catch (SoapFault $fault) {
|
||||
//echo $client->__getLastResponse()."\n";
|
||||
//echo 'ERREUR SOAP :'.EOL;
|
||||
//print_r($fault);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->errnum=999;
|
||||
$this->errmsg="Pas d'accès à la base TVA";
|
||||
$this->vatNumber='';
|
||||
$this->vatDefined=false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
/*
|
||||
class MScores {
|
||||
|
||||
@ -89,7 +89,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2) {
|
||||
set_time_limit(300);
|
||||
$reCompile=false;
|
||||
$version=''; // PROD
|
||||
$version='_325'; // RECETTE
|
||||
$version='_329'; // RECETTE
|
||||
|
||||
if ($cycleClient==1 || $cycleClient==2 || $cycleClient==3 || $cycleClient==4 || $cycleClient==5)
|
||||
$genereComment=true;
|
||||
@ -256,6 +256,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2) {
|
||||
|
||||
$mBil=new MBilans($siren);
|
||||
$tabBilans=$mBil->listeBilans(true);
|
||||
// @sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Liste des Bilans",print_r($tabBilans,true));
|
||||
$NBBILAN=count($tabBilans);
|
||||
$tabBilan=$tabBil=array();
|
||||
if ($NBBILAN>0)
|
||||
@ -312,6 +313,16 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2) {
|
||||
if ($tabIdentite['Saisonnalite']==1) $SAISONAT='S';
|
||||
else $SAISONAT='P';
|
||||
$CAPITAL=$tabIdentite['Capital'];
|
||||
$CAPITAL_NBACTION=$tabIdentite['CapitalNbActions'];
|
||||
$CAPITAL_MTACTION=$tabIdentite['CapitalMtActions'];
|
||||
if ($CAPITAL>0) {
|
||||
switch ($tabIdentite['CapitalType']) {
|
||||
case 'V': $CAPITAL_TYPE='variable'; break;
|
||||
case 'S': $CAPITAL_TYPE='fixe'; break;
|
||||
default: $CAPITAL_TYPE=''; break;
|
||||
}
|
||||
} else $CAPITAL_TYPE='';
|
||||
|
||||
$TCAEXP=$tabIdentite['TrancheCAexp'];
|
||||
|
||||
// Formes Juridique de l'entreprise
|
||||
@ -1617,7 +1628,7 @@ AltmanCote=$scoreAltmanB".EOL.print_r($tabInfosNotation,true);
|
||||
$ANNONCEINTERDIT=0;
|
||||
$dirs=$iInsee->getDirigeants($siren, false);
|
||||
debugLog('I', 'SCOREDIR = '. print_r($dirs,1));
|
||||
$DIR_NB=0;
|
||||
$DIR_NB=$NBDIRLIENS=$NBDIRSCI=$NBDIRSCIADR=0;
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Dirigeants", print_r($dirs, true));
|
||||
foreach ($dirs as $nb=>$dir) {
|
||||
if ($dir['Ancien']==0 && preg_match('/G.rant|Personne|Pr.sident|Directeur|Repr.sentant/Uis', $dir['Titre'])) {
|
||||
@ -1633,7 +1644,37 @@ AltmanCote=$scoreAltmanB".EOL.print_r($tabInfosNotation,true);
|
||||
$DIR2_FONC=$dir['Titre'];
|
||||
$DIR2_TYPE='PP';
|
||||
}
|
||||
//GERANTMAJ
|
||||
$tabDir=$iInsee->rechercheDir($dir['Nom'], $dir['Prenom'], '', $dir['NaissDate'], '', 0, 200, 200);
|
||||
$tabDir=$tabDir['reponses'];
|
||||
$nbFctDir=$nbFctDirSci=$nbFctDirSciAdr=0;
|
||||
foreach($tabDir as $iDir=>$tabDiri) {
|
||||
if ($tabDiri['Actif']==1 && $tabDiri['Siege']==1) {
|
||||
$nbFctDir++;
|
||||
if ($tabDiri['FJ']==6540) {
|
||||
$nbFctDirSci++;
|
||||
if ($tabDiri['FJ']==6540) {
|
||||
/* [Adresse] => 0001 RUE DU CHAMP FLEURI
|
||||
[Adresse2] =>
|
||||
[CP] => 49770
|
||||
[Ville] => LA MEIGNANNE
|
||||
*/
|
||||
$nbFctDirSciAdr++;
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Dirigeant $DIR_NB", print_r($tabDiri, true).EOL.print_r($tabIdentite,true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nombre d'entreprises maximum dirigé par un des dirigeants
|
||||
if ($nbFctDir>$NBDIRLIENS) $NBDIRLIENS=$nbFctDir;
|
||||
|
||||
// Nombre de SCI maximum dirigé par un des dirigeants (inclus dans NBDIRLIENS)
|
||||
if ($nbFctDirSci>$NBDIRSCI) $NBDIRSCI=$nbFctDirSci;
|
||||
|
||||
// Nombre de SCI maximum dirigé par un des dirigeants à l'adresse (inclus dans les autres NBDIR...)
|
||||
if ($nbFctDirSciAdr>$NBDIRSCIADR) $NBDIRSCIADR=$nbFctDirSciAdr;
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Dirigeant $DIR_NB", print_r($tabDir, true));
|
||||
}
|
||||
|
||||
switch ($dir['Cinf']) {
|
||||
@ -1731,6 +1772,7 @@ AltmanCote=$scoreAltmanB".EOL.print_r($tabInfosNotation,true);
|
||||
$timer['factoCS']=microtime(true);
|
||||
|
||||
$libProfilPayeur=trim($iFacto->getProfilPayeur($siren));
|
||||
$profilPayeur=$iFacto->profilPayeur;
|
||||
$timer['factoProfil']=microtime(true);
|
||||
|
||||
$DELAIPAY=$iFacto->DELAIPAY;
|
||||
@ -1749,10 +1791,12 @@ AltmanCote=$scoreAltmanB".EOL.print_r($tabInfosNotation,true);
|
||||
case 'IP': $IMPAYE=true;
|
||||
$IMPAYE_MMAA=$CSFACTO_MMAA=WDate::dateT('Y-m-d', 'Ym', $infoFacto[0]['DateEven']);
|
||||
$CSFACTO='I';
|
||||
$profilPayeur=5;
|
||||
break;
|
||||
case 'PR': $PRIVILEGES=true;
|
||||
$PRIVILEGES_MMAA=$CSFACTO_MMAA=WDate::dateT('Y-m-d', 'Ym', $infoFacto[0]['DateEven']);
|
||||
$CSFACTO='P';
|
||||
$profilPayeur=5;
|
||||
break;
|
||||
case 'RG': $RISQUEGROUPE=true;
|
||||
$RISQUEGROUPE_MMAA=$CSFACTO_MMAA=WDate::dateT('Y-m-d', 'Ym', $infoFacto[0]['DateEven']);
|
||||
@ -2380,6 +2424,33 @@ AltmanCote=$scoreAltmanB".EOL.print_r($tabInfosNotation,true);
|
||||
}
|
||||
}
|
||||
|
||||
/** Population commune **/
|
||||
$codeCommuneInsee=$tabIdentite['Dept'].$tabIdentite['codeCommune'];
|
||||
$tabTmp=$iDb->select( 'insee.insee_tabVilles',
|
||||
'Pop_mun_2007, popMunZFU, popMunZUS',
|
||||
"CODGEO='$codeCommuneInsee'", false, MYSQL_ASSOC);
|
||||
// Nombre d'habitants de la commune du siège
|
||||
$POPULATION=$tabTmp[0]['Pop_mun_2007'];
|
||||
// % d'effectif salarié sur la population communale
|
||||
$EFFECTIF_POPU=($EFFECTIF/$POPULATION)*100;
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Popu", "SELECT Pop_mun_2007, popMunZFU, popMunZUS FROM insee.insee_tabVilles WHERE CODGEO='".$tabIdentite['codeCommune']."'".EOL.print_r($tabTmp, true));
|
||||
|
||||
/** RPS : Entreprise avec négociations ou accord sur les RPS ? **/
|
||||
$tabTmp=$iDb->select( 'sdv1.gouv_rps',
|
||||
'idfent, dateMAJ, negotiations, nbreunions, accordsigne, accorddate, absenceEchec',
|
||||
"siren='$SIREN'", false, MYSQL_ASSOC);
|
||||
if (isset($tabTmp[0]) && $tabTmp[0]['idfent']>0) {
|
||||
$RPS_NEGO=$RPS_PLAN=false;
|
||||
// Date de dernière MAJ dans le répertoire RPS
|
||||
$RPS_INFODATE=$tabTmp[0]['dateMAJ'];
|
||||
// Négotiations
|
||||
if ($tabTmp[0]['negotiations']=='oui') $RPS_NEGO=true;
|
||||
// Date de signature de l'accord des RPS qui peut être à 0
|
||||
$RPS_ACCORDDATE=$tabTmp[0]['accorddate'];
|
||||
// Présence du libellé Plan d'action
|
||||
if (!$RPS_NEGO && $RPS_ACCORDDATE*1==0) $RPS_PLAN=true;
|
||||
}
|
||||
|
||||
/** Recherche de la liste des Produits / NAF **/
|
||||
$LISTEPRODUIT=implode(', ', $iInsee->listeProduits($naf));
|
||||
|
||||
@ -2674,7 +2745,7 @@ Pevol[xxx,n] Valeur du taux de progression au terme des N années Projection li
|
||||
case 'ET NON': $strFormule.=" && $strParentDeb !($tmpFormule) $strParentFin"; break;
|
||||
case 'OU': $strFormule.=" || $strParentDeb $tmpFormule $strParentFin"; break;
|
||||
case 'OU NON': $strFormule.=" || $strParentDeb !($tmpFormule) $strParentFin"; break;
|
||||
case 'ACTION': $strAction =str_replace('==','=', " $tmpFormule; "); break;
|
||||
case 'ACTION': $strAction.=str_replace('==','=', " $tmpFormule; "); break;
|
||||
case 'ECHANGE': $ECHANGE[]=$tmpFormule; break;
|
||||
default:
|
||||
debugLog('W', 'Indiscore '.$id.' OPERANDE INCONNUE '.$operande, __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
@ -2731,7 +2802,7 @@ asort($tabTriAff);
|
||||
$tabCommentairesATrier=array();
|
||||
$tabCommentairesTmp=array();
|
||||
global $idx;
|
||||
$fp=@fopen(LOG_PATH.'/debugFmt.log', 'w');
|
||||
$fp=@fopen('/var/www/log/debugFmt.log', 'w');
|
||||
fclose($fp);
|
||||
global $tabVariables;
|
||||
$tabVariables=unserialize(file_get_contents(DOC_WEB_LOCAL.'tables/tables.bin'));
|
||||
@ -2857,8 +2928,6 @@ $timer['finIndiscore']=microtime(true);
|
||||
|
||||
$NOMFUSION Nom de l'entrep concernée par la fusion
|
||||
|
||||
$NBDIRLIENS Nombre d'entreprises maximum dirigé par un des dirigeants
|
||||
$NBDIRSCI Nombre de SCI maximum dirigé par un des dirigeants (inclus dans NBDIRLIENS)
|
||||
$GERANTMAJ
|
||||
|
||||
$ANNONCELIM Annonce en cours
|
||||
@ -2915,7 +2984,7 @@ $debugFormule.EOL.'-----------------------'.EOL.*
|
||||
//"Détail des postes Bilans :\n".print_r($tabBilan, true).EOL.
|
||||
//
|
||||
//"Liste des Formules Ratios :\n".print_r($tabFormulesRatios, true).EOL.
|
||||
//"Debug variables :\n".file_get_contents(LOG_PATH.'/debugFmt.log').EOL.
|
||||
//"Debug variables :\n".file_get_contents('/var/www/log/debugFmt.log').EOL.
|
||||
"\$tabBil=\n".print_r($tabBil,true).EOL
|
||||
);*/
|
||||
}
|
||||
@ -3012,6 +3081,7 @@ $debugFormule.EOL.'-----------------------'.EOL.*
|
||||
'encoursStat' =>$encoursEstime,
|
||||
'infoEncours' =>prepareString(/*utf8_encode(*/$libEncours),
|
||||
'infoPaiement' =>prepareString(/*utf8_encode(*/$libInfoPaiement),
|
||||
'profilPayeur' =>$profilPayeur,
|
||||
'classeRisque' =>$classeRisque,
|
||||
'AdresseDom' =>$tabIdentite['AdresseDom'],
|
||||
'scores' =>array('ConanH'=> $scoreConanH,
|
||||
@ -3320,6 +3390,10 @@ function formatValeur($variable, $longeur=0, $fonction='') {
|
||||
return number_format($CAPITAL,0,',',chr(160)).' €';
|
||||
} elseif (preg_match('/CAPITAL_PRE$/',$nomVar)) {
|
||||
return number_format($CAPITAL_PRE,0,',',chr(160)).' €';
|
||||
} elseif (preg_match('/CAPITAL_MTACTION$/',$nomVar)) {
|
||||
return number_format($CAPITAL_MTACTION,0,',',chr(160)).' €';
|
||||
} elseif (preg_match('/CAPITAL_NBACTION$/',$nomVar)) {
|
||||
return number_format($CAPITAL_NBACTION,0,',',chr(160));
|
||||
} elseif (preg_match('/^CAESTIME$/',$nomVar)) {
|
||||
return number_format($CAESTIME/1000,0,',',chr(160)).' k€';
|
||||
} elseif (preg_match('/^CABIOUES$/',$nomVar)) {
|
||||
@ -3478,4 +3552,4 @@ function format($matches)
|
||||
|
||||
return $strRetour.' '.$strUnite;
|
||||
}
|
||||
?>
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
$tabVar=array( 'ACTIFINSEE',
|
||||
'ACTIFRNCS',
|
||||
'ACTISURF',
|
||||
@ -149,6 +149,9 @@ $tabVar=array( 'ACTIFINSEE',
|
||||
'CAPITAL',
|
||||
'CAPITAL_CREA',
|
||||
'CAPITAL_PRE',
|
||||
'CAPITAL_NBACTION',
|
||||
'CAPITAL_MTACTION',
|
||||
'CAPITAL_TYPE',
|
||||
'CA_COEF',
|
||||
'CA_TAUX',
|
||||
'CA_Y',
|
||||
@ -182,6 +185,7 @@ $tabVar=array( 'ACTIFINSEE',
|
||||
'DOM_SIREN',
|
||||
'EFFBILAN',
|
||||
'EFFECTIF',
|
||||
'EFFECTIF_POPU',
|
||||
'ELIMINE',
|
||||
'ENCOURSDEM',
|
||||
'ENQUETE',
|
||||
@ -283,6 +287,7 @@ $tabVar=array( 'ACTIFINSEE',
|
||||
'ORIGINE',
|
||||
'PLAN',
|
||||
'PLANMODIF',
|
||||
'POPULATION',
|
||||
'PPNONDIFF',
|
||||
'PRESENTINSEE',
|
||||
'PRESENTRNCS',
|
||||
@ -319,6 +324,10 @@ $tabVar=array( 'ACTIFINSEE',
|
||||
'RJMERE',
|
||||
'ROUEDELARELANCE',
|
||||
'RPEN',
|
||||
'RPS_ACCORDDATE',
|
||||
'RPS_INFODATE',
|
||||
'RPS_NEGO',
|
||||
'RPS_PLAN',
|
||||
'Ra',
|
||||
'Rap',
|
||||
'Rdiff',
|
||||
@ -422,5 +431,5 @@ $tabVar=array( 'ACTIFINSEE',
|
||||
|
||||
foreach ($tabVar as $var)
|
||||
global $$var;
|
||||
|
||||
?>
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -113,10 +113,12 @@ class WsEntreprise extends WsScore
|
||||
'Nom' =>strtr($entrep['Nom'],'/*',' '),
|
||||
'Nom2' =>$entrep['Nom2'],
|
||||
'NomLong' =>$entrep['nomLong'], // Ajouté le 4 08 2009
|
||||
'NomCommercial' =>$entrep['NomCommercial'], // Ajouté le 16 11 2010
|
||||
'Siret' =>$entrep['Siret'],
|
||||
'Sigle' =>$entrep['Sigle'],
|
||||
'SigleLong' =>$entrep['sigleLong'], // Ajouté le 4 08 2009
|
||||
'Enseigne' =>$entrep['Enseigne'],
|
||||
'EnseigneLong' =>$entrep['enseigneLong'], // Ajouté le 16 11 2010
|
||||
'Adresse' =>$entrep['Adresse'],
|
||||
'Adresse2' =>$entrep['Adresse2'],
|
||||
'AdresseNum' =>$entrep['AdresseNum'],
|
||||
@ -594,6 +596,12 @@ class WsEntreprise extends WsScore
|
||||
$annonce->codFJ = $ann['codFJ'];
|
||||
$annonce->capital = $ann['capital'];
|
||||
$annonce->capitalDev = $ann['capitalDev'];
|
||||
|
||||
$annonce->raisonSociale = $ann['raisonSociale'];
|
||||
$annonce->nomCommercial = $ann['nomCommercial'];
|
||||
$annonce->sigle = $ann['sigle'];
|
||||
$annonce->adresse = $ann['adresse'];
|
||||
|
||||
$annonce->dateEffet = $ann['dateEffet'];
|
||||
$annonce->dateJugement = $ann['dateJugement'];
|
||||
$annonce->dateInsertionSD = $ann['dateInsertionSD'];
|
||||
|
@ -2181,64 +2181,28 @@ class WsInterne extends WsScore
|
||||
$marques=array();
|
||||
$iDb=new WDB();
|
||||
|
||||
$res=$iDb->select('marques', 'count(*)', "Siren=$siren AND DATEDIFF(NOW(),dateUpdate)<30");
|
||||
if ($res[0][0]==0 ||
|
||||
($idDepot>0 && (!file_exists(DOC_WEB_LOCAL."marques/$siren-$idDepot.jpg") || filesize(DOC_WEB_LOCAL."marques/$siren-$idDepot.jpg")<1) )
|
||||
) {
|
||||
if ($idDepot==0) $url="http://www.societe.com/marques/-$siren.html";
|
||||
else $url="http://www.societe.com/cgi-bin/consultcgi?en=$idDepot";
|
||||
|
||||
$referer=$cookie='';
|
||||
$tdeb=microtime(true);
|
||||
$page=getUrl($url, $cookie, '', $referer, false, '', '', 21);
|
||||
$tfin=microtime(true);
|
||||
$duree=$tfin-$tdeb;
|
||||
$referer=$url;
|
||||
$body=$page['body'];
|
||||
|
||||
if ($idDepot==0) $fp=@fopen("/tmp/marques-$siren.html", "a");
|
||||
else $fp=@fopen(DOC_WEB_LOCAL."marques/$siren-$idDepot.jpg", "a");
|
||||
@fwrite($fp, $body);
|
||||
@fclose($fp);
|
||||
|
||||
$fp=@fopen("/var/www/log/marques.log", "a");
|
||||
@fwrite($fp, date('Y-m-d H:i:s').";$siren;$idDepot;$duree\n");
|
||||
@fclose($fp);
|
||||
}
|
||||
|
||||
if ($idDepot==0) {
|
||||
if (preg_match_all('/<tr>.*<td width="80" align="left" height="20" valign="middle">(.*)<\/td>.*<td width="240" align="left" valign="middle" ><a href="(.*)">(.*)<\/a><\/td>.*<td width="80" align="center" valign="middle".*>(.*)<\/td>.*<\/tr>/Uis',$body, $matches)) {
|
||||
$fp=@fopen("/tmp/marques-$siren-$date.log", "a");
|
||||
@fwrite($fp, print_r($matches,true));
|
||||
@fclose($fp);
|
||||
|
||||
foreach ($matches[3] as $i=>$marqueNom) {
|
||||
preg_match('/\/cgi-bin\/consultcgi\?en=(.*)\'\);"/Uis', $matches[4][$i], $matches2);
|
||||
$lien=$matches2[1];
|
||||
preg_match('/\/cgi-bin\/v(?:erif|)cpte\?no=(.*)$/Ui', $matches[2][$i], $matches2);
|
||||
$depot=$matches2[1];
|
||||
$rs=trim(str_replace('(semi-figurative)','',$marqueNom));
|
||||
if (substr($rs,-1,1)=='.') $rs=substr($rs,0,strlen($rs)-1);
|
||||
$tabUpdate=array( 'Marques'=>$rs,
|
||||
'Date' =>WDate::dateT('d-m-Y', 'Y-m-d', $matches[1][$i]),
|
||||
'Depot' =>$depot,//$matches[2][$i],
|
||||
'IdLien' =>$lien, // http://www.societe.com/cgi-bin/consultcgi?en= 3173102
|
||||
);
|
||||
|
||||
if (!$iDb->insert('marques', array_merge($tabUpdate, array('Siren'=>$siren)), true))
|
||||
$iDb->update('marques', $tabUpdate, "Siren=$siren AND Depot=$depot", true);
|
||||
|
||||
//$marques[$i]=$tabUpdate;
|
||||
$marques[$i]['Marques'] = prepareString($rs);
|
||||
$marques[$i]['Date'] = WDate::dateT('d-m-Y', 'Y-m-d', $matches[1][$i]);
|
||||
$marques[$i]['Depot'] = $depot;
|
||||
$marques[$i]['IdLien'] = $lien;
|
||||
}
|
||||
require_once 'Metier/partenaires/classMMarques.php';
|
||||
$iMarque=new MMarques();
|
||||
$ret=$iMarque->getMarques($siren, $idDepot);
|
||||
foreach ($ret as $i=>$marque) {
|
||||
if (trim($marque['imgLink'])<>'') $idLien=$marque['numeroMarque'];
|
||||
else $idLien='';
|
||||
$marques[$i]=array( 'Marques' => prepareString($marque['nomMarque']),
|
||||
'Date' => $marque['dateDepot'],
|
||||
'Depot' => $marque['numeroMarque'],
|
||||
'IdLien' => $idLien,
|
||||
'UrlLien' => $marque['UrlLien'], // Rempli que si $idDepot<>0
|
||||
'PdfDispo' => $marque['pdfLink'], // Nouveau
|
||||
);
|
||||
if ($idDepot==$marque['numeroMarque']) {
|
||||
$marques[$i]['Classes'] = $marque['classesMarque']; // Nouveau
|
||||
$marques[$i]['Perimetre'] = prepareString($marque['periMarque']); // Nouveau
|
||||
$marques[$i]['DateExpir'] = $marque['dateExpir']; // Nouveau
|
||||
return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>array(end($marques)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$res=$iDb->select('marques', 'Marques,Date,Depot,IdLien, DATEDIFF(NOW(),dateUpdate) AS nbJourLastUpdate', "Siren=$siren ORDER BY `Date` DESC");
|
||||
/* $res=$iDb->select('marques', 'Marques,Date,Depot,IdLien, DATEDIFF(NOW(),dateUpdate) AS nbJourLastUpdate', "Siren=$siren ORDER BY `Date` DESC");
|
||||
if (count($res)>0) {
|
||||
foreach ($res as $i=>$marque) {
|
||||
$marques[$i]=array( 'Marques'=>prepareString($marque['Marques']),
|
||||
@ -2272,7 +2236,7 @@ class WsInterne extends WsScore
|
||||
}
|
||||
return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>$marques);
|
||||
}
|
||||
|
||||
*/
|
||||
wsLog('marques',$siren);
|
||||
return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>$marques);
|
||||
}
|
||||
@ -2406,7 +2370,7 @@ class WsInterne extends WsScore
|
||||
|
||||
if (preg_match('/Votre commande est enregistr/i',$body))
|
||||
{
|
||||
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com',
|
||||
@sendMail('production@scores-decisions.com', 'asso@scores-decisions.com',
|
||||
"Commande de statuts association pour $assoNom ($siren)",
|
||||
"Association :".EOL.print_r($infoAsso, true).EOL.EOL.
|
||||
"Demandeur:".EOL.print_r($infoDemande, true).EOL.EOL.
|
||||
@ -2425,7 +2389,7 @@ class WsInterne extends WsScore
|
||||
wsLog('commandeAsso', $siren, 'i'.$ret.'-'.DATETIME);
|
||||
debugLog('I',"commandeAsso pour $assoNom ($siren) fin",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
} else {
|
||||
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com',
|
||||
@sendMail('production@scores-decisions.com', 'asso@scores-decisions.com',
|
||||
"ERREUR lors de lommande de statuts association pour $assoNom ($siren)", "Association :".EOL.print_r($infoAsso, true).EOL.EOL.
|
||||
"Demandeur:".EOL.print_r($infoDemande, true).EOL.EOL.
|
||||
"Réponse RefAsso en $duree secondes :".EOL.print_r($page, true));
|
||||
@ -3278,7 +3242,7 @@ class WsInterne extends WsScore
|
||||
{
|
||||
$detail='Non';
|
||||
//$strDetail=" AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page='indiscore' ) AND (params<>'' OR page='indiscore' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') ";
|
||||
$strDetail=" AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page='indiscore' OR page='privileges' OR page='commandeAsso') AND (params<>'' OR page='indiscore' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') ";
|
||||
$strDetail=" AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page LIKE 'indiscore%' OR page='privileges' OR page='commandeAsso') AND (params<>'' OR page LIKE 'indiscore%' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') ";
|
||||
} elseif($detail==1) {
|
||||
$detail='Oui';
|
||||
}
|
||||
@ -3414,19 +3378,26 @@ class WsInterne extends WsScore
|
||||
$cache=1;
|
||||
} else {
|
||||
@unlink($fichierCsv);
|
||||
if ($source=='score'){
|
||||
if ($source=='score')
|
||||
{
|
||||
if ($tabInfoUser['typeScore']*1==20) { $strScore='v.indiScore20 AS indiScore20'; $strScorePre='v.indiScore20Pre AS indiScore20Pre'; }
|
||||
else { $strScore='v.indiScore AS indiScore100'; $strScorePre='v.indiScorePre AS indiScore100Pre'; }
|
||||
/*v.scoreZ, v.scoreZPre, v.scoreCH, v.scoreCHPre,
|
||||
v.scoreAfdcc2, v.scoreAfdcc2Pre, v.situFi, v.situFiPre, v.infoNote, v.infoNotePre,
|
||||
v.noteStruct, v.noteStructPre, v.noteFin, v.noteFinPre, v.tendance, v.tendancePre, */
|
||||
$sql="SELECT LOWER(s.login) as loginUti, s.source, s.email, s.siren, s.nic, s.ref, s.dateAjout,
|
||||
s.rs, s.cp, s.ville, s.dateDerEnvoi, s.encoursClient, v.actif, v.procol, v.indiScore,
|
||||
v.indiScore20, v.encours, v.indiScoreDate, v.dateBilan, v.indiScorePre, v.indiScore20Pre,
|
||||
v.encoursPre, v.indiScoreDatePre, v.sourceModif, v.scoreSolv, v.scoreSolvPre, v.scoreDir,
|
||||
v.scoreDirPre, v.scoreConf, v.scoreConfPre, /*v.scoreZ, v.scoreZPre, v.scoreCH, v.scoreCHPre,
|
||||
v.scoreAfdcc2, v.scoreAfdcc2Pre, v.situFi, v.situFiPre, v.infoNote, v.infoNotePre,
|
||||
v.noteStruct, v.noteStructPre, v.noteFin, v.noteFinPre, v.tendance, v.tendancePre, */v.dateUpdate
|
||||
FROM surveillances_site s, sdv1.utilisateurs u, sdv1.clients c, scores_surveillance v
|
||||
WHERE s.source='score' $strClient $strLogin AND dateSuppr=0 AND s.login=u.login AND u.idClient=c.id AND s.siren=v.siren
|
||||
s.rs, s.cp, s.ville, s.dateDerEnvoi,
|
||||
s.encoursClient, v.actif, v.procol, $strScore, v.encours, v.indiScoreDate, v.dateBilan,
|
||||
$strScorePre, v.encoursPre, v.indiScoreDatePre, v.sourceModif, v.scoreSolv, v.scoreSolvPre, v.scoreDir,
|
||||
v.scoreDirPre, v.scoreConf, v.scoreConfPre,
|
||||
e.cj, e.capital, e.capitalDev, e.ape_entrep, e.tca, e.teff_entrep,
|
||||
v.dateUpdate
|
||||
FROM surveillances_site s, sdv1.utilisateurs u, sdv1.clients c, scores_surveillance v, etablissements e
|
||||
WHERE s.source='score' $strClient $strLogin AND dateSuppr=0 AND s.login=u.login AND u.idClient=c.id AND s.siren=v.siren AND s.siren=e.siren
|
||||
GROUP BY loginUti, s.siren, s.nic, s.source, s.ref
|
||||
ORDER BY loginUti ASC, s.siren ASC, s.nic ASC, s.source ASC, s.ref ASC";
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeSurveillancesCsv($source, $login, $idClient)", $sql);
|
||||
} else {
|
||||
|
||||
$sql="SELECT LOWER(s.login) as loginUti, s.source, s.email, s.siren, s.nic, s.ref, s.dateAjout,
|
||||
s.rs, s.cp, s.ville, s.dateDerEnvoi
|
||||
FROM surveillances_site s, sdv1.utilisateurs u, sdv1.clients c
|
||||
@ -3489,13 +3460,7 @@ class WsInterne extends WsScore
|
||||
*/
|
||||
protected function getListeFichierSurv($login, $ref='*', $nomFic='')
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
//Initialisation
|
||||
$error = new ErrorType();
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, $nomFic", 'vide');
|
||||
debugLog('I',"getListeFichierSurv pour $login, $ref, $nomFic",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
//debugLog('I',"getListeFichierSurv pour $login, $ref, $nomFic",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
$tabFichier=$tabDates=array();
|
||||
$numAbo=substr($ref, 0,5);
|
||||
@ -3503,11 +3468,19 @@ class WsInterne extends WsScore
|
||||
$repClient='volkswagen bank';
|
||||
$ficClient='surveillanceBodacc_SURBODPRDCFTVWBANK';
|
||||
$numAbo=$ref='19300';
|
||||
} elseif (substr($login,0,6)=='apicil') {
|
||||
$repClient='apicil';
|
||||
$ficClient='surveillanceBodacc_SURBODPRDCFTAPICIL';
|
||||
$numAbo=$ref='';
|
||||
} else {
|
||||
$repClient='cnasea';
|
||||
$ficClient='surveillanceBodacc_SURBODTSTFTSCNASEA';
|
||||
}
|
||||
$dh = opendir("/home/data/clients/$repClient/");
|
||||
$dh = opendir("/home/data/clients/$repClient/");
|
||||
if (!$dh) {
|
||||
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, $nomFic", "Impossible d'ouvrir le dossier '/home/data/clients/$repClient/'");
|
||||
return array('error'=>array('errnum'=>354659, 'errmsg'=>"Impossible d'ouvrir le dossier client"), 'results'=>array());
|
||||
}
|
||||
|
||||
while (false !== ($filename = readdir($dh))) {
|
||||
if ($filename<>'.' && $filename<>'..' && substr($filename, -4)=='.csv' && substr($filename,0,42)==$ficClient.$numAbo) {
|
||||
@ -3520,6 +3493,12 @@ class WsInterne extends WsScore
|
||||
$tabDates[]=substr($filename,43,8);
|
||||
$tabClients[]=substr($filename,0,42);
|
||||
}
|
||||
elseif ($filename<>'.' && $filename<>'..' && substr($filename, -4)=='.csv' && substr($filename,0,37)==$ficClient && substr($filename,37,1)=='_' && $repClient=='apicil') {
|
||||
$tabFichier[] = $filename;
|
||||
$tabDates[]=substr($filename,38,8);
|
||||
$tabClients[]=substr($filename,0,37);
|
||||
}
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, $nomFic : fichier lu '$filename'", "Fichier lu '$filename'");
|
||||
}
|
||||
/** Tableau des noms de fichier **/
|
||||
sort($tabFichier);
|
||||
@ -3531,6 +3510,15 @@ class WsInterne extends WsScore
|
||||
sort($tabClients);
|
||||
//return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'results'=>$tabDates);
|
||||
|
||||
/*@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, $nomFic",
|
||||
"Fichiers :".EOL.
|
||||
print_r($tabFichier, true).
|
||||
"Dates:".EOL.
|
||||
print_r($tabDates, true).
|
||||
"Clients :".EOL.
|
||||
print_r($tabClients, true)
|
||||
);*/
|
||||
|
||||
if ($ref=='*') {
|
||||
$tabFichier = array();
|
||||
// Boucle sur les dates de livraison
|
||||
@ -3586,6 +3574,7 @@ class WsInterne extends WsScore
|
||||
}
|
||||
}
|
||||
}
|
||||
debugLog('I',"getListeFichierSurv pour $login, $ref, $nomFic : nb fichiers=".count($tabFichier),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'results'=>$tabFichier);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user