2009-02-17 13:14:53 +00:00
< ?
/*
include_once ( FWK_PATH . 'sphinx/recherche.php' );
include_once ( INCLUDE_PATH . 'bodacc/classMBodacc.php' );
include_once ( INCLUDE_PATH . 'bodacc/classMBalo.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMTva.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMMap.php' );
*/
class MInsee {
private static $tabFct = array ( 'ADM' => 'Administrateur' ,
'ASS' => 'Associ<63> ' ,
'COG' => 'Co-g<> rant' ,
'CON' => 'Contr<74> leur de gestion' ,
'DID' => 'Directeur G<> n<EFBFBD> ral D<> l<EFBFBD> gu<67> ' ,
'DIR' => 'Directeur' ,
'GER' => 'G<> rant' ,
'PCS' => 'Pr<50> sident du Conseil de Surveillance' ,
'PDG' => 'Pr<50> sident Directeur G<> n<EFBFBD> ral' ,
'PP' => 'Personne Physique' ,
'PRD' => 'Pr<50> sident du directoire' ,
'PRE' => 'Pr<50> sident du Conseil d\'Administration' ,
'VIC' => 'Vice pr<70> sident du CA ou Surv.' ,
);
private static $tabDep = array ( '01' => 'Ain' ,
'1' => 'Ain' ,
'02' => 'Aisne' ,
'2' => 'Aisne' ,
'03' => 'Allier' ,
'3' => 'Allier' ,
'04' => 'Alpes-de-Haute-Provence' ,
'4' => 'Alpes-de-Haute-Provence' ,
'05' => 'Hautes-Alpes' ,
'5' => 'Hautes-Alpes' ,
'06' => 'Alpes-Maritimes' ,
'6' => 'Alpes-Maritimes' ,
'07' => 'Ard<72> che' ,
'7' => 'Ard<72> che' ,
'08' => 'Ardennes' ,
'8' => 'Ardennes' ,
'09' => 'Ari<72> ge' ,
'9' => 'Ari<72> ge' ,
'10' => 'Aube' ,
'11' => 'Aude' ,
'12' => 'Aveyron' ,
'13' => 'Bouches-du-Rh<52> ne' ,
'14' => 'Calvados' ,
'15' => 'Cantal' ,
'16' => 'Charente' ,
'17' => 'Charente-Maritime' ,
'18' => 'Cher' ,
'19' => 'Corr<72> ze' ,
'20' => 'Corse' ,
'2A' => 'Corse-du-Sud' ,
'20A' => 'Corse-du-Sud' ,
'2B' => 'Haute-Corse' ,
'20B' => 'Haute-Corse' ,
'21' => 'C<> te-d\'Or' ,
'22' => 'C<> tes-d\'Armor' ,
'23' => 'Creuse' ,
'24' => 'Dordogne' ,
'25' => 'Doubs' ,
'26' => 'Dr<44> me' ,
'27' => 'Eure' ,
'28' => 'Eure-et-Loir' ,
'29' => 'Finist<73> re' ,
'30' => 'Gard' ,
'31' => 'Haute-Garonne' ,
'32' => 'Gers' ,
'33' => 'Gironde' ,
'34' => 'H<> rault' ,
'35' => 'Ille-et-Vilaine' ,
'36' => 'Indre' ,
'37' => 'Indre-et-Loire' ,
'38' => 'Is<49> re' ,
'39' => 'Jura' ,
'40' => 'Landes' ,
'41' => 'Loir-et-Cher' ,
'42' => 'Loire' ,
'43' => 'Haute-Loire' ,
'44' => 'Loire-Atlantique' ,
'45' => 'Loiret' ,
'46' => 'Lot' ,
'47' => 'Lot-et-Garonne' ,
'48' => 'Loz<6F> re' ,
'49' => 'Maine-et-Loire' ,
'50' => 'Manche' ,
'51' => 'Marne' ,
'52' => 'Haute-Marne' ,
'53' => 'Mayenne' ,
'54' => 'Meurthe-et-Moselle' ,
'55' => 'Meuse' ,
'56' => 'Morbihan' ,
'57' => 'Moselle' ,
'58' => 'Ni<4E> vre' ,
'59' => 'Nord' ,
'60' => 'Oise' ,
'61' => 'Orne' ,
'62' => 'Pas-de-Calais' ,
'63' => 'Puy-de-D<> me' ,
'64' => 'Pyr<79> n<EFBFBD> es-Atlantiques' ,
'65' => 'Hautes-Pyr<79> n<EFBFBD> es' ,
'66' => 'Pyr<79> n<EFBFBD> es-Orientales' ,
'67' => 'Bas-Rhin' ,
'68' => 'Haut-Rhin' ,
'69' => 'Rh<52> ne' ,
'70' => 'Haute-Sa<53> ne' ,
'71' => 'Sa<53> ne-et-Loire' ,
'72' => 'Sarthe' ,
'73' => 'Savoie' ,
'74' => 'Haute-Savoie' ,
'75' => 'Paris' ,
'76' => 'Seine-Maritime' ,
'77' => 'Seine-et-Marne' ,
'78' => 'Yvelines' ,
'79' => 'Deux-S<> vres' ,
'80' => 'Somme' ,
'81' => 'Tarn' ,
'82' => 'Tarn-et-Garonne' ,
'83' => 'Var' ,
'84' => 'Vaucluse' ,
'85' => 'Vend<6E> e' ,
'86' => 'Vienne' ,
'87' => 'Haute-Vienne' ,
'88' => 'Vosges' ,
'89' => 'Yonne' ,
'90' => 'Territoire de Belfort' ,
'91' => 'Essonne' ,
'92' => 'Hauts-de-Seine' ,
'93' => 'Seine-Saint-Denis' ,
'94' => 'Val-de-Marne' ,
'95' => 'Val-d\'Oise' ,
'971' => 'Guadeloupe' ,
'972' => 'Martinique' ,
'973' => 'Guyane' ,
'974' => 'R<> union' ,
'975' => 'Saint-Pierre-et-Miquelon' ,
'976' => 'Mayotte' ,
'986' => 'Wallis-et-Futuna' ,
'987' => 'Polyn<79> sie-Fran<61> aise' ,
'988' => 'Nouvelle-Cal<61> donie' ,
);
/**Nature d'<27> tablissements*/
private static $tabNature = array ( '20' => 'Petit magasin (moins de 300m<30> )' ,
'21' => 'Magasin (de 300m<30> <20> 400m<30> )' ,
'22' => 'Grande surface (de 400 <20> 2500m<30> )' ,
'23' => 'Tr<54> s grande surface (plus de 2500m<30> )' ,
'91' => 'Base d\'activit<69> sur chantiers' ,
'92' => 'Base d\'activit<69> sur march<63> s' ,
'93' => 'Base d\'activit<69> en client<6E> le' ,
'99' => 'Autre' );
/**R<> gions du code officiel g<> ographique*/
private static $tabRegion = array ( '1' => 'Guadeloupe' ,
'2' => 'Martinique' ,
'3' => 'Guyane' ,
'4' => 'R<> union' ,
'11' => 'Ile-de-France' ,
'21' => 'Champagne-Ardenne' ,
'22' => 'Picardie' ,
'23' => 'Haute-Normandie' ,
'24' => 'Centre' ,
'25' => 'Basse-Normandie' ,
'26' => 'Bourgogne' ,
'31' => 'Nord-Pas-de-Calais' ,
'41' => 'Lorraine' ,
'42' => 'Alsace' ,
'43' => 'Franche-Comt<6D> ' ,
'52' => 'Pays de la Loire' ,
'53' => 'Bretagne' ,
'54' => 'Poitou-Charentes' ,
'72' => 'Aquitaine' ,
'73' => 'Midi-Pyr<79> n<EFBFBD> es' ,
'74' => 'Limousin' ,
'82' => 'Rh<52> ne-Alpes' ,
'83' => 'Auvergne' ,
'91' => 'Languedoc-Roussillon' ,
'93' => 'Provence Alpes C<> te d Azur' ,
'94' => 'Corse' ,
'98' => 'Territoire d outre-mer (TOM)' ,
'99' => 'Etranger' );
/** Tranches de Chiffre d ' Affaires INSEE
**/
private static $tabTCA = array ( '0' => 'N/C' ,
'1' => 'de 500 000 <20> 1 M<> ' ,
'2' => 'de 1 <20> 2 M<> ' ,
'3' => 'de 2 <20> 5 M<> ' ,
'4' => 'de 5 <20> 10 M<> ' ,
'5' => 'de 10 <20> 20 M<> ' ,
'6' => 'de 20 <20> 50 M<> ' ,
'7' => 'de 50 <20> 100 M<> ' ,
'8' => 'de 100 <20> 200 M<> ' ,
'9' => 'plus de 200 M<> '
);
/**Tranche d'habitants de commune d<> taill<6C> e*/
private static $tabTCD = array ( '1' => 'Commune de moins de 50 habitants' ,
'2' => 'Commune de 50 <20> 99 habitants' ,
'3' => 'Commune de 100 <20> 149 habitants' ,
'4' => 'Commune de 150 <20> 199 habitants' ,
'5' => 'Commune de 200 <20> 249 habitants' ,
'6' => 'Commune de 250 <20> 299 habitants' ,
'7' => 'Commune de 300 <20> 399 habitants' ,
'8' => 'Commune de 400 <20> 499 habitants' ,
'11' => 'Commune de 500 <20> 699 habitants' ,
'12' => 'Commune de 700 <20> 999 habitants' ,
'13' => 'Commune de 1000 <20> 1499 habitants' ,
'14' => 'Commune de 1500 <20> 1999 habitants' ,
'15' => 'Commune de 2000 <20> 2499 habitants' ,
'16' => 'Commune de 2500 <20> 2999 habitants' ,
'17' => 'Commune de 3000 <20> 3999 habitants' ,
'18' => 'Commune de 4000 <20> 4999 habitants' ,
'21' => 'De 5 000 <20> 6 999 habitants' ,
'22' => 'De 7 000 <20> 9 999 habitants' ,
'31' => 'De 10 000 <20> 14 999 habitants' ,
'32' => 'De 15 000 <20> 19 999 habitants' ,
'41' => 'De 20 000 <20> 24 999 habitants' ,
'42' => 'De 25 000 <20> 29 999 habitants' ,
'43' => 'De 30 000 <20> 39 999 habitants' ,
'44' => 'De 40 000 <20> 49 999 habitants' ,
'51' => 'De 50 000 <20> 69 999 habitants' ,
'52' => 'De 70 000 <20> 99 999 habitants' ,
'61' => 'De 100 000 <20> 149 999 habitants' ,
'62' => 'De 150 000 <20> 199 999 habitants' ,
'71' => 'De 200 000 <20> 299 999 habitants' ,
'72' => 'De 300 000 <20> 499 999 habitants' ,
'73' => 'De 500 000 <20> 1 499 999 habitants' ,
'80' => 'Plus de 1 500 000 habitants' );
/**Tranches d'effectifs INSEE*/
private static $tabEffectif = array ( 0 => 'N/C' ,
1 => 'de 1 <20> 2 salari<72> (s)' ,
2 => 'de 3 <20> 5 salari<72> s' ,
3 => 'de 6 <20> 9 salari<72> s' ,
11 => 'de 10 <20> 19 salari<72> s' ,
12 => 'de 20 <20> 49 salari<72> s' ,
21 => 'de 50 <20> 99 salari<72> s' ,
22 => 'de 100 <20> 199 salari<72> s' ,
31 => 'de 200 <20> 249 salari<72> s' ,
32 => 'de 250 <20> 499 salari<72> s' ,
41 => 'de 500 <20> 999 salari<72> s' ,
42 => 'de 1 000 <20> 1 999 salari<72> s' ,
51 => 'de 2 000 <20> 4 999 salari<72> s' ,
52 => 'de 5 000 <20> 9 999 salari<72> s' ,
53 => 'plus de 10 000 salari<72> s' );
/**Libell<6C> des singularit<69> s INSEE*/
private static $tabSingularite = array ( '1' => 'Propi<70> taire Exploitant direct' ,
'2' => 'Locataire G<> rant' ,
'10' => 'Loueur de fonds' ,
'30' => 'Unit<69> singuli<6C> re de premi<6D> re esp<73> ce: avocats assoc<6F> s, stations services sous mandat..' ,
'31' => 'Associ<63> d\'exploitation en commun; ce groupe comprend notamment: associ<63> de soci<63> t<EFBFBD> de fait, associ<63> d\'indivision' ,
'33' => 'Employeur non exploitant: prestataire de personnel, g<> rant mandataire' ,
'34' => 'Membre d\'une soci<63> t<EFBFBD> civile professionnelle' ,
'40' => 'Si<53> ge d\'une unit<69> SIREN de droit priv<69> sans activit<69> ' ,
'41' => 'Si<53> ge d\'un organisme public sans activit<69> ' ,
'42' => 'Si<53> ge d\'un <20> tablissement public local non dot<6F> de l\'autonomie comptable: une partie des centres communaux d\'action sociale, une partie des caisses des <20> coles' ,
'43' => 'Si<53> ges de domiciliation' ,
'52' => 'Sans domicile fixe' ,
'60' => 'Activit<69> occasionnelle ou accessoire: Expert aupr<70> s des tribunaux, m<> decin, infirmier, pharmacien rempl<70> ant, avocat stagiaire, sportif amateur' ,
'70' => 'Activit<69> en location (autre que le fond de commerce): Exploitant de terrain de camping, location de garage ou parking, locations de meubl<62> s, location de terres agricoles' ,
'80' => 'Gestion immobili<6C> re de biens propres: syndicats de copropri<72> taires' ,
'90' => 'Unit<69> singuli<6C> re de seconde esp<73> ce: <20> tablissement d\'une entreprise install<6C> e <20> Monaco, si<73> ge <20> l\'etranger de soci<63> t<EFBFBD> s, associ<63> g<> rant de soci<63> t<EFBFBD> s' );
/**Libell<6C> des origines de cr<63> ation INSEE*/
private static $tabOrigine = array ( '0' => 'non renseign<67> ' ,
'1' => 'Cr<43> ation pure' ,
'2' => 'R<> installation apr<70> s transfert' ,
'3' => 'Achat' ,
'4' => 'Donation' ,
'5' => 'Reprise au conjoint ou apport re<72> u' ,
'6' => 'Reprise <20> un locataire g<> rant' ,
'7' => 'Prise en location-g<> rance' ,
'8' => 'Autre modalit<69> d\'acquisition aupr<70> s d\'une autre unit<69> SIREN' );
private $tabCodeVoie = array ();
private $tabCodesNaf = array ();
private $body = '' ;
private $codeRetour = 0 ;
private $header = array ();
private $iDb ;
private $iDbInsee ;
private $iDbSD ;
private $iBodacc ;
public function __construct () {
// $this->iDb=new WDB();
//$this->iDb->setCharSet('UTF-8');
// $this->iDbInsee=new WDB('insee');
//$this->iDbInsee->setCharSet('UTF-8');
// $this->iDbSD=new WDB('sdv1');
//$this->iDbSD->setCharSet('UTF-8');
$this -> tabCodeVoie = $this -> getTabCodeVoie ();
// $this->iBodacc=new MBodacc();
}
/** Test de la validit<EFBFBD> du siren demand<EFBFBD>
* @ param int SIREN <EFBFBD> tester
* @ param int NIC ( facultatif )
* @ param mixed Message textuel d 'erreur <20> afficher en cas d' erreur ou false
* @ return mixed true , false ou Message d ' erreur pass<EFBFBD> en param<EFBFBD> tre
*/
function valideSiren ( $siren , $nic = '' , $erreur = false ) {
$lenSIREN = strlen ( $siren );
if ( ! valideData ( $siren , 9 , 9 , 'N' )) //Siren non pr<70> cis<69> ou incorrect.
return $erreur ;
else
{
if ( ! isset ( $nic ) || trim ( $nic ) == '' )
{
$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 )));
$som_tmp = 0 ;
for ( $j = 0 ; $j < strlen ( $var_tmp ); $j ++ )
$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?!)
return $erreur ;
}
} 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 )
{ // Traitement PAIR
$var_tmp = ( string )( 2 * (( integer ) substr ( $SIRET , $i , 1 )));
$som_tmp = 0 ;
for ( $j = 0 ; $j < strlen ( $var_tmp ); $j ++ )
$som_tmp += ( integer ) substr ( $var_tmp , $j , 1 );
$somme += $som_tmp ;
}
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 ;
}
}
return true ;
}
/** Test de la validit<EFBFBD> du siren demand<EFBFBD>
**
** @ param int $siren SIREN <EFBFBD> tester
** @ param int $numEtab N<EFBFBD> d ' <EFBFBD> tablissement dont ont fdoit calculer le NIC
** @ return int
**/
function getNic ( $siren , $numEtab = 1 ) {
if ( ! $this -> valideSiren ( $siren ))
return - 1 ;
elseif ( ! valideData ( $numEtab , 1 , 4 , 'N' )) // Nic de format incorrect.
return - 1 ;
else {
for ( $cle = 0 ; $cle < 10 ; $cle ++ ) {
if ( $this -> valideSiren ( $siren , '' . $nic . '' . $cle ))
return $cle ;
}
}
return - 1 ;
}
/** V<EFBFBD> rifie si le n<EFBFBD> de d<EFBFBD> partement est un d<EFBFBD> partement fran<EFBFBD> ais valide
** @ param int Num<EFBFBD> ro de d<EFBFBD> partement Fran<EFBFBD> ais
** @ return bool
**/
public function isDepartement ( $dept ) {
return array_key_exists ( $dept , self :: $tabDep );
}
/** Retourne le libell<EFBFBD> du d<EFBFBD> partement si d<EFBFBD> partement fran<EFBFBD> ais valide
** @ param int Num<EFBFBD> ro de d<EFBFBD> partement Fran<EFBFBD> ais
** @ return string Libell<EFBFBD> d<EFBFBD> partement
**/
public function getDepartement ( $dept ) {
return self :: $tabDep [ $dept ];
}
public function getEffectifMoyen ( $trancheEffectif ) {
$trancheEffectif = $trancheEffectif * 1 ;
if ( $trancheEffectif == 0 ) return 0 ;
elseif ( $trancheEffectif == 53 ) return 10000 ;
else {
$libEffectif = self :: $tabEffectif [ $trancheEffectif ];
$tabTmp = explode ( '<27> ' , $libEffectif );
$eff_min = trim ( str_replace ( ' ' , '' , $tabTmp [ 0 ]));
$tabTmp = explode ( 'salari' , $tabTmp [ 1 ]);
$eff_max = trim ( str_replace ( ' ' , '' , $tabTmp [ 0 ]));
return floor (( $eff_min + $eff_max ) / 2 );
}
}
/** Retourne le code forme juridique d ' une entreprise .
** @ param int Num<EFBFBD> ro de SIREN ( 9 chiffres ) ou SIRET ( 14 chiffres )
** @ return string Forme Juridique sur 4 caract<EFBFBD> res ou < b > false </ b > en cas d ' erreur ou si inexistant
**/
function getFJInsee ( $siren_siret ) {
$len = strlen ( $siren_siret );
if ( $len == 9 )
$siren = $siren_siret ;
elseif ( $len == 14 )
$siren = $siren_siret ;
else
return false ;
$rep = $this -> iDb -> select ( 'identite' , 'CJ' , " SIREN=' $siren ' " );
return $rep [ 0 ][ 0 ];
}
/**
* Enter description here ...
*
* @ param unknown_type $raisonSociale
* @ param unknown_type $adresse
* @ param unknown_type $codePostal
* @ param unknown_type $ville
* @ param unknown_type $siege
* @ param unknown_type $nbRep
* @ param unknown_type $pertinence
* @ param bool $uniquementAvecSiren
* @ return unknown
*/
public function rechercheEtab ( $raisonSociale , $adresse = '' , $codePostal = '' , $ville = '' , $siege = '' , $actif = '' , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false , $uniquementAvecSiren = '' ) {
debugLog ( 'I' , " rechercheEtab de $raisonSociale , $adresse , $codePostal $ville (Si<53> ge= $siege / Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
// $raisonSociale=trim(strtoupper(trimAccent($raisonSociale))); //)("/^(scp |s c p |me )/i", '',
// $adresse=trim(/*strtr(*/strtoupper(trimAccent($adresse))/*, array('RUE '=>''))*/);
//$raisonSociale=$raisonSociale)); //)("/^(scp |s c p |me )/i", '',
//$raisonSociale=strtr(strtolower($raisonSociale), '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ',
// 'aaaaaaaceeeeiiiionooooouuuuyy');
$raisonSociale = trim ( strtoupper ( trimAccent ( $raisonSociale )));
$tabAdr = $this -> structureVoie ( strtoupper ( $adresse ));
/*
[ num ] => 6
[ typeVoie ] => R
[ libVoie ] => RONDELET
*/
$numAdresse = $tabAdr [ 'num' ] * 1 ;
$adresse = trimAccent ( $tabAdr [ 'libVoie' ]);
$ville = trim ( strtoupper ( trimAccent ( $ville ))); //)("/^(scp |s c p |me )/i", '',
$tabFiltres = $tabFiltresCP = array ();
if ( trim ( $codePostal ) <> '' && ( $codePostal * 1 ) > 0 ) {
$cp = $codePostal * 1 ;
$dep = false ;
if ( $cp > 0 && $cp < 96 ) { $dep = $cp ; $cp = false ; }
elseif ( $cp > 970 && $cp < 977 ) { $dep = $cp ; $cp = false ; }
elseif ( $cp > 999 && $cp < 10000 ) { $dep = '0' . substr ( $cp , 0 , 1 ); $cp = '0' . $cp ; }
elseif ( $cp >= 10000 && $cp < 96000 ) $dep = substr ( $cp , 0 , 2 );
elseif ( $cp >= 99000 ) { $dep = substr ( $cp , 0 , 3 ); $cp = false ; }
elseif ( $cp >= 98000 ) { $dep = substr ( $cp , 0 , 3 ); $cp = false ; }
elseif ( $cp >= 97100 && $cp < 97700 ) $dep = substr ( $cp , 0 , 3 );
else $cp = false ;
if ( isset ( $cp ) && $cp ) $tabFiltresCP = array ( 'adr_cp' => $cp );
elseif ( isset ( $dep ) && $dep ) $tabFiltresCP = array ( 'adr_dep' => $dep );
}
if ( $siege == true ) $tabFiltresSiege = array ( 'siege' => 1 );
else $tabFiltresSiege = array ();
if ( $actif == true ) $tabFiltresActif = array ( 'actif' => 1 );
else $tabFiltresActif = array ();
if ( $numAdresse > 0 ) $tabFiltresNumAdr = array ( 'adr_num' => $numAdresse );
else { $tabFiltresNumAdr = array ();
$numAdresse = '' ;
}
if ( $uniquementAvecSiren == true ) $tabFiltresAvecSiren = array ( 'sirenValide' => 1 );
// elseif ($uniquementAvecSiren==false) $tabFiltresAvecSiren=array('sirenValide'=>0);
else $tabFiltresAvecSiren = array ();
debugLog ( 'I' , " Je recherche avec tous les filtres $raisonSociale , $adresse , $codePostal $ville (Si<53> ge= $siege / Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$ret = search ( 'etab' , " @nom $raisonSociale @adresse $adresse @ville $ville " , array_merge ( $tabFiltresCP , $tabFiltresSiege , $tabFiltresActif , $tabFiltresNumAdr , $tabFiltresAvecSiren ), $deb , $nbRep , $maxRep , $pertinence );
$liste = $ret [ 'results' ];
$nbTot = $ret [ 'nbTot' ];
$duree = $ret [ 'duration' ];
//$liste=search('etab', $raisonSociale.' '.$adresse.' '.$ville, array_merge($tabFiltresCP, $tabFiltresSiege, $tabFiltresActif, $tabFiltresNumAdr), $deb, $nbRep, $maxRep, $pertinence);
if ( $liste === false ) die ();
if ( count ( $liste ) == 0 ) {
// echo "Je recherche dans le D<> partement entier\n";
debugLog ( 'I' , " Je recherche dans le D<> partement entier $raisonSociale , $adresse , $codePostal $ville (Si<53> ge= $siege / Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( isset ( $dep ) && $dep ) $tabFiltresCP = array ( 'adr_dep' => $dep );
$ret = search ( 'etab' , $raisonSociale . ' ' . $adresse . ' ' . $ville , array_merge ( $tabFiltresCP , $tabFiltresSiege , $tabFiltresActif , $tabFiltresNumAdr , $tabFiltresAvecSiren ), $deb , $nbRep , $maxRep , $pertinence );
$liste = $ret [ 'results' ];
$nbTot = $ret [ 'nbTot' ];
$duree = $ret [ 'duration' ];
}
if ( count ( $liste ) == 0 ) {
debugLog ( 'I' , " Je recherche en soundex dans le CP $raisonSociale , $adresse , $codePostal $ville (Si<53> ge= $siege / Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
// echo "Je recherche en soundex dans le CP\n";
if ( isset ( $cp ) && $cp ) $tabFiltresCP = array ( 'adr_cp' => $cp );
$ret = search ( 'etab_shx' , $raisonSociale . ' ' . $adresse . ' ' . $ville , array_merge ( $tabFiltresCP , $tabFiltresSiege , $tabFiltresActif , $tabFiltresNumAdr , $tabFiltresAvecSiren ), $deb , $nbRep , $maxRep , $pertinence );
$liste = $ret [ 'results' ];
$nbTot = $ret [ 'nbTot' ];
$duree = $ret [ 'duration' ];
}
if ( count ( $liste ) == 0 ) {
// echo "Je recherche en soundex dans le d<> partement entier\n";
debugLog ( 'I' , " Je recherche en soundex dans le d<> partement entier $raisonSociale , $adresse , $codePostal $ville (Si<53> ge= $siege / Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( isset ( $dep ) && $dep ) $tabFiltresCP = array ( 'adr_dep' => $dep );
$ret = search ( 'etab_shx' , $raisonSociale . ' ' . $adresse . ' ' . $ville , array_merge ( $tabFiltresCP , $tabFiltresSiege , $tabFiltresActif , $tabFiltresNumAdr , $tabFiltresAvecSiren ), $deb , $nbRep , $maxRep , $pertinence );
$liste = $ret [ 'results' ];
$nbTot = $ret [ 'nbTot' ];
$duree = $ret [ 'duration' ];
}
$tabRet = array ();
$tabMotsRsIn = explode ( ' ' , $raisonSociale );
$tabMotsAdrIn = explode ( ' ' , $adresse );
$tabMotsVilleIn = explode ( ' ' , $ville );
$k = 0 ;
$rsOK = $adrOK = $vilOK = true ;
//$nbTot=count($liste);
foreach ( $liste as $n => $etab ) {
//print_r($etab);
//die();
/*
if ( $raisonSociale <> '' ) {
$tabMotsRSout = explode ( ' ' , $etab [ 'Nom' ] . ' ' . $etab [ 'Nom2' ] . ' ' . $etab [ 'Sigle' ] . ' ' . $etab [ 'Enseigne' ]);
$rsOK = false ;
foreach ( $tabMotsRSout as $motOut ) {
foreach ( $tabMotsRsIn as $motIn ) {
if ( strlen ( $motOut ) >= 3 && strlen ( $motIn ) >= 3 ) {
$levMin = levenshtein ( $motOut , $motIn );
if ( $levMin < 5 ) {
$rsOK = true ;
break ( 2 );
}
}
}
}
}
if ( $adresse <> '' ) {
$tabMotsAdrOut = explode ( ' ' , $adresse );
$adrOK = false ;
foreach ( $tabMotsAdrOut as $motOut ) {
foreach ( $tabMotsAdrIn as $motIn ) {
if ( strlen ( $motOut ) >= 3 && strlen ( $motIn ) >= 3 ) {
$levMin = levenshtein ( $motOut , $motIn );
if ( $levMin < 5 ) {
$adrOK = true ;
break ( 2 );
}
}
}
}
}
if ( $adresse <> '' && $numAdresse > 0 ) {
$adrOK = false ;
$tabTmp = explode ( ' ' , $etab [ 'Adresse' ]);
$numAdresseIn = $tabTmp [ 0 ] * 1 ;
if ( $numAdresseIn == $numAdresse ) $adrOK = true ;
// die($adresse.' '.$codePostal.' '.$ville);
}
if ( $ville <> '' ) {
$tabMotsVilleOut = explode ( ' ' , $ville );
$vilOK = false ;
foreach ( $tabMotsVilleOut as $motOut ) {
foreach ( $tabMotsVilleIn as $motIn ) {
if ( strlen ( $motOut ) >= 3 && strlen ( $motIn ) >= 3 ) {
$levMin = levenshtein ( $motOut , $motIn );
if ( $levMin < 5 ) {
$vilOK = true ;
break ( 2 );
}
}
}
}
}
if ( $rsOK && $adrOK && $vilOK ) { */
$tabRet [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => $etab [ 'Nom' ],
'Nom2' => $etab [ 'Nom2' ],
'Sigle' => $etab [ 'Sigle' ],
'Enseigne' => $etab [ 'Enseigne' ],
'Adresse' => $etab [ 'Adresse' ],
'CP' => $etab [ 'CP' ],
'Ville' => $etab [ 'Ville' ],
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
'FJLib' => $this -> getLibelleFJ ( $etab [ 'FJ' ]),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => $this -> getLibelleNaf ( $etab [ 'NafEtab' ]), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => $this -> getLibelleNaf ( $etab [ 'NafEnt' ]),
);
$k ++ ;
// if ($k==$nbRep) break;
}
return array ( 'criteres' => array ( 'rs' => $raisonSociale , 'adresse' => trim ( $numAdresse . ' ' . $adresse ), 'cp' => $codePostal , 'ville' => $ville ,),
'nbReponses' => count ( $tabRet ),
'nbReponsesTotal' => $nbTot ,
'duree' => $duree ,
'reponses' => $tabRet );
}
public function rechercheDir ( $nom , $prenom = '' , $fonction = '' , $dateNaiss = '' , $villeNaiss = '' , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false ) {
debugLog ( 'I' , " rechercheDir de $nom , $prenom , $fonction , $dateNaiss , $villeNaiss (Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$nom = trim ( strtoupper ( trimAccent ( $nom )));
$prenom = trim ( strtoupper ( trimAccent ( $prenom )));
//$dirDateNaiss JJ/MM/AAAA
$tabFiltresMois = $tabFiltresAnnee = array ();
if ( $dateNaiss <> '' && $dateNaiss <> '//' && $dateNaiss <> '0/0/0' ) {
$tabDateNaiss = explode ( '/' , $dateNaiss );
$mois = $tabDateNaiss [ 1 ] * 1 ;
if ( $mois > 0 && $mois < 12 ) $tabFiltresMois = array ( 'naiss_mois' => $mois );
$annee = $tabDateNaiss [ 2 ] * 1 ;
if ( $annee < 100 ) $annee = ( '19' . $annee ) * 1 ;
if ( $annee >= 1900 && $annee <= date ( 'Y' ) * 1 ) $tabFiltresAnnee = array ( 'naiss_annee' => $annee );
}
$dateNaiss = preg_replace ( '/^00/' , '0' , " 0 $mois / $annee " );
$dateNaiss = preg_replace ( '/^0\//' , '' , $dateNaiss );
/*
$dateNaiss = preg_replace ( '/\/0$/' , '' , $dateNaiss );
*/
//$ret=search('dirigeants', $nom.' '.$prenom, array(), $deb, $nbRep, $maxRep, $pertinence);
$ret = search ( 'dirigeants_rncs' , " @nom $nom @prenom $prenom @naissance_lieu $villeNaiss " , array_merge ( $tabFiltresMois , $tabFiltresAnnee ), $deb , $nbRep , $maxRep , $pertinence );
//=search('etab', $raisonSociale.' '.$adresse.' '.$ville, array_merge($tabFiltresCP, $tabFiltresSiege, $tabFiltresActif, $tabFiltresNumAdr), $deb, $nbRep, $maxRep, $pertinence);
//print_r($ret);die();
$liste = $ret [ 'results' ];
$nbTot = $ret [ 'nbTot' ];
$duree = $ret [ 'duration' ];
if ( count ( $liste ) == 0 ) {
debugLog ( 'I' , " rechercheDir en soundex de $nom , $prenom , $fonction , $dateNaiss , $villeNaiss (Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
//$ret=search('dirigeants_shx', $nom.' '.$prenom, array(), $deb, $nbRep, $maxRep, $pertinence);
$ret = search ( 'dirigeants_rncs_shx' , " @nom $nom @prenom $prenom @naissance_lieu $villeNaiss " , array_merge ( $tabFiltresMois , $tabFiltresAnnee ), $deb , $nbRep , $maxRep , $pertinence );
$liste = $ret [ 'results' ];
$nbTot = $ret [ 'nbTot' ];
$duree = $ret [ 'duration' ];
}
$tabRet = array ();
$tabMotsNomIn = explode ( ' ' , $nom );
$tabMotsPrenomIn = explode ( ' ' , $prenom );
$k = 0 ;
// $nomOK=$prenomOK=true;
// $nbTot=count($liste);
foreach ( $liste as $n => $etab ) {
/* if ( $nom <> '' ) {
$tabMotsNomOut = explode ( ' ' , $etab [ 'nomD' ] . ' ' . $etab [ 'nomUsage' ] . ' ' . $etab [ 'rs' ]);
$nomOK = false ;
foreach ( $tabMotsNomOut as $motOut ) {
foreach ( $tabMotsNomIn as $motIn ) {
if ( strlen ( $motOut ) >= 3 && strlen ( $motIn ) >= 3 ) {
$levMin = levenshtein ( $motOut , $motIn );
if ( $levMin < 5 ) {
$nomOK = true ;
break ( 2 );
}
}
}
}
}
if ( $prenom <> '' ) {
$tabMotsPrenomOut = explode ( ' ' , $etab [ 'prenom' ]);
$prenomOK = false ;
foreach ( $tabMotsPrenomOut as $motOut ) {
foreach ( $tabMotsPrenomIn as $motIn ) {
if ( strlen ( $motOut ) >= 3 && strlen ( $motIn ) >= 3 ) {
$levMin = levenshtein ( $motOut , $motIn );
if ( $levMin < 5 ) {
$prenomOK = true ;
break ( 2 );
}
}
}
}
}
if ( $nomOK && $prenomOK ) { */
$tabRet [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => $etab [ 'Nom' ],
'Nom2' => $etab [ 'Nom2' ],
'Sigle' => $etab [ 'Sigle' ],
'Enseigne' => $etab [ 'Enseigne' ],
'Adresse' => $etab [ 'Adresse' ],
'CP' => $etab [ 'CP' ],
'Ville' => $etab [ 'Ville' ],
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
'FJLib' => $this -> getLibelleFJ ( $etab [ 'FJ' ]),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => $this -> getLibelleNaf ( $etab [ 'NafEtab' ]), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => $this -> getLibelleNaf ( $etab [ 'NafEnt' ]),
// Dirigeant
'DirRs' => $etab [ 'rs' ],
'DirNom' => $etab [ 'nomD' ],
'DirPrenom' => $etab [ 'prenom' ],
'DirNomUsage' => $etab [ 'nomUsage' ],
'DirDateEffet' => $etab [ 'dateEffet' ],
'DirFonction' => $etab [ 'fonction' ],
'DirDepart' => $etab [ 'depart' ],
);
$k ++ ;
//if ($k==$nbRep) break;
//}
}
return array ( 'criteres' => array ( 'nom' => $nom , 'prenom' => $prenom , 'dateNaissance' => $dateNaiss , 'lieuNaissance' => $villeNaiss ),
'nbReponses' => count ( $tabRet ),
'nbReponsesTotal' => $nbTot ,
'duree' => $duree ,
'reponses' => $tabRet );
}
private function getTabCodeVoie () {
$row = 1 ;
$handle = fopen ( realpath ( dirname ( __FILE__ ) . '/voies.csv' ), 'r' );
if ( ! $handle ) die ( 'Impossible d\'ouvrir le fichier de configuration des voies INSEE' );
$tabTmp = array ();
while (( $data = fgetcsv ( $handle , 1000 , ';' )) !== FALSE )
if ( substr ( $data [ 0 ], 0 , 1 ) <> '#' ) // Ligne en commentaires CSV
$tabTmp [ $data [ 0 ]] = $data [ 1 ];
fclose ( $handle );
return $tabTmp ;
}
/** V<EFBFBD> rifie si le code voie est une abr<EFBFBD> viation autoris<EFBFBD> e ( selon la Norme AFNOR XP Z 10 - 011 )
** @ param string Code voie
** @ return bool
**/
public function isCodeVoie ( $codeVoie ) {
return array_key_exists ( $codeVoie , $this -> tabCodeVoie );
}
/** Retourne le libell<EFBFBD> du code voie selon les abr<EFBFBD> viations autoris<EFBFBD> es pour les types de voie ( Norme AFNOR XP Z 10 - 011 )
** @ param string Code voie
** @ return string Libell<EFBFBD> de la voie
**/
public function getCodeVoie ( $codeVoie ) {
return $this -> tabCodeVoie [ $codeVoie ];
}
/** Initialise la table des codes NAF 4 et 5 positions
**/
private function setTabCodesNaf () {
if ( count ( $this -> tabCodesNaf ) == 0 ) {
$tabNafs = array ();
$tabTmp = $this -> iDb -> select ( 'tabNaf4' , 'codNaf700 AS naf, libNaf700 AS LibNaf' , 1 , true , MYSQL_ASSOC );
foreach ( $tabTmp as $i => $tabNaf )
$tabNafs [ $tabNaf [ 'naf' ]] = $tabNaf [ 'LibNaf' ];
$tabTmp = $this -> iDb -> select ( 'tabNaf5' , 'codNaf5 AS naf, libNaf5 AS LibNaf' , 1 , true , MYSQL_ASSOC );
foreach ( $tabTmp as $i => $tabNaf )
$tabNafs [ $tabNaf [ 'naf' ]] = $tabNaf [ 'LibNaf' ];
$this -> tabCodesNaf = $tabNafs ;
}
}
public function getLibelleNaf ( $code_naf ) {
$this -> setTabCodesNaf ();
return $this -> tabCodesNaf [ $code_naf ];
}
public function getLibelleFJ ( $code_forme_juridique ) {
$tmp = $this -> iDb -> select ( 'tabFJur' , 'libelle AS LibFJ' , " code= $code_forme_juridique " );
return @ $tmp [ 0 ][ 0 ];
}
/** D<EFBFBD> coupe une ligne d 'adresse textuelle en un tableau contenant les diff<66> rentes composantes de l' adresse
** < pre > Array (
** [ adrComp0 ] => Maison des associations
** [ num ] => 33
** [ typeVoie ] => R
** [ libVoie ] => Louis Blanc
** [ cp ] => ...
** [ ville ] => ... Si contenu dans l ' adresse
** ) </ pre >
**
** @ param string $strLigneDAdresse La ligne d ' adresse textuelle ( ex : Maison des associations , 33 rue Louis Blanc
** @ return array tableau contenant l ' adresse structur<EFBFBD> e ici
**/
public function structureVoie ( $strLigneDAdresse ) {
$tabRet = $tabAdr = array ();
$strLigneDAdresse = trim ( $strLigneDAdresse );
if ( $strLigneDAdresse == '' ) return $tabRet ;
$tabLignes = explode ( ',' , preg_replace ( '/,$/' , '' , $strLigneDAdresse ));
foreach ( $tabLignes as $strLigneDAdresse ) {
$strLigneDAdresse = trimAccent ( $strLigneDAdresse );
$strLigneDAdresse = preg_replace ( '/[^0-9a-zA-Z]/' , ' ' , $strLigneDAdresse );
$strLigneDAdresse = trim ( preg_replace ( '/ +/' , ' ' , $strLigneDAdresse ));
//echo "1. Adresse nettoy<6F> es = $strLigneDAdresse".EOL;
$adrAvecCP = preg_match ( " /(.*)([0-9] { 5,5}|[0-9][0-9] [0-9] { 3,3})([ \ D]*)/ " , $strLigneDAdresse , $tabAdrTmp );
if ( $adrAvecCP ) {
//echo "Adresse avec Code Postal\n";
//print_r($tabAdrTmp);
$strLigneDAdresse = trim ( $tabAdrTmp [ 1 ]);
$tabRet [ 'cp' ] = $tabAdrTmp [ 2 ];
$tabRet [ 'ville' ] = trim ( strtoupper ( $tabAdrTmp [ 3 ]));
} // else echo "Adresse sans Code Postal\n";
$adrAvecNum = preg_match ( " /^([0-9] { 1,4})(.*)/ " , $strLigneDAdresse , $tabAdrTmp );
if ( $adrAvecNum ) {
//echo "Adresse avec Num<75> ro de voie\n";
//print_r($tabAdrTmp);
$tabRet [ 'num' ] = $tabAdrTmp [ 1 ];
if ( preg_match ( " /^( B | BIS | T | TER | Q | a | c | d | e | f | g | h | i | j | k | l | m | n | o | p | r | s )(.*)/i " , $tabAdrTmp [ 2 ], $tabAdrTmp2 ))
{ //echo "Adresse avec Bis, Ter, Q...\n";
//print_r($tabAdrTmp2);
$tabRet [ 'indRep' ] = trim ( $tabAdrTmp2 [ 1 ]); $typeVoie = trim ( $tabAdrTmp2 [ 2 ]);}
else $typeVoie = trim ( $tabAdrTmp [ 2 ]);
} else $typeVoie = trim ( $strLigneDAdresse );
// On r<> cup<75> re le type de voie si possible et le libell<6C> de la voie
$voieTrouvee = false ;
foreach ( $this -> tabCodeVoie as $code => $voie ) {
if ( preg_match ( " /^( $voie | $voie " . 's ' . " | $code )(.*)/i " , $typeVoie , $tabAdrTmp )) {
//echo "Adresse avec type de voie\n";
//print_r($tabAdrTmp);
$tabRet [ 'typeVoie' ] = $code ;
$tabRet [ 'libVoie' ] = trim ( strtoupper ( $tabAdrTmp [ 2 ]));
$voieTrouvee = true ;
break ;
}
}
if ( ! $voieTrouvee ) $tabAdr [] = $typeVoie ;
}
foreach ( $tabAdr as $k => $ligne )
$tabRet [ 'adrComp' . $k ] = trim ( strtoupper ( $ligne ));
if ( ! isset ( $tabRet [ 'libVoie' ])) { $tabRet [ 'libVoie' ] = strtoupper ( $ligne ); unset ( $tabRet [ 'adrComp' . $k ]); }
/** Si indRep=r et pas de voie ==> correction **/
if ( $tabRet [ 'indRep' ] == 'r' && $tabRet [ 'typeVoie' ] == '' ) {
$tabRet [ 'indRep' ] = '' ;
$tabRet [ 'typeVoie' ] = 'R' ;
}
return $tabRet ;
}
public function getEtablissements ( $siren , $nic = '' , $deb = 0 , $nbRep = 20 , $maxRep = 200 ) {
$this -> setTabCodesNaf ();
$deb = $deb * 1 ;
$nbRep = $nbRep * 1 ;
$limit = " LIMIT $deb , $nbRep " ;
if ( $nic == '' ) {
$tabTmp = $this -> iDb -> select ( 'etablissements' , 'count(*)' , " siren= $siren " );
$nbTot = $tabTmp [ 0 ][ 0 ];
$listeEtab = $this -> iDb -> select ( 'etablissements e' ,
" 'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, " .
" e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, " .
" e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, " .
" CONCAT(e.siren, e.nic) as siret, e.actif " ,
" e.siren= $siren ORDER BY e.siege DESC, e.actif DESC $limit " , true , MYSQL_ASSOC );
} else {
$listeEtab = $this -> iDb -> select ( 'etablissements e' ,
" 'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, " .
" e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, " .
" e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, " .
" CONCAT(e.siren, e.nic) as siret, e.actif " ,
" siren= $siren AND (nic= $nic OR siege=1) ORDER BY e.siege , e.actif DESC $limit " , true , MYSQL_ASSOC );
$nbTot = count ( $listeEtab );
}
foreach ( $listeEtab as $etab ) {
$tabRet [] = array ( 'Localisation' => $etab [ 'Loc' ],
'id' => $etab [ 'id' ],
'Pertinence' => 100 ,
'Siret' => $etab [ 'siret' ],
'Siege' => $etab [ 'siege' ],
'Nom' => $etab [ 'raisonSociale' ],
'Sigle' => $etab [ 'sigle' ],
'Enseigne' => $etab [ 'enseigne' ],
'Adresse' => trim ( preg_replace ( '/ +/' , ' ' , trim ( $etab [ 'adr_num' ] . ' ' . $etab [ 'adr_btq' ] . ' ' .
$etab [ 'adr_typeVoie' ] . ' ' . $etab [ 'adr_libVoie' ]))),
'Adresse2' => trim ( preg_replace ( '/ +/' , ' ' , $etab [ 'adr_comp' ])),
'CP' => $etab [ 'adr_cp' ],
'Ville' => $etab [ 'adr_ville' ],
'Tel' => $etab [ 'tel' ],
'Fax' => $etab [ 'fax' ],
'FJ' => $etab [ 'cj' ],
'FJLib' => $this -> getLibelleFJ ( $etab [ 'cj' ]),
'Siren' => $etab [ 'siren' ],
'Nic' => $etab [ 'nic' ],
'Actif' => $etab [ 'actif' ],
'NafEtab' => $etab [ 'ape_etab' ], // Etablissement
'NafEnt' => $etab [ 'ape_entrep' ], // Entreprise
'NafEtabLib' => $this -> getLibelleNaf ( $etab [ 'ape_etab' ]),
'NafEntLib' => $this -> getLibelleNaf ( $etab [ 'ape_entrep' ]),
);
}
return array ( 'criteres' => array ( 'siren' => $siren , 'nic' => $nic ),
'nbReponses' => count ( $tabRet ),
'nbReponsesTotal' => $nbTot ,
'reponses' => $tabRet );
}
public function getEtablissementsParId ( $typeId , $id , $deb = 0 , $nbRep = 20 , $maxRep = 200 ) {
$this -> setTabCodesNaf ();
$deb = $deb * 1 ;
$nbRep = $nbRep * 1 ;
$limit = " LIMIT $deb , $nbRep " ;
if ( $typeId == 'TEL' ) {
debugLog ( 'I' , " Recherche par TEL de $id avec un maximum de $nbRep r<> ponses " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabTmp = $this -> iDb -> select ( 'etablissements' , 'count(*)' , " TEL= $id OR FAX= $id " );
$nbTot = $tabTmp [ 0 ][ 0 ];
$listeEtab = $this -> iDb -> select ( 'etablissements e' ,
" 'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, " .
" e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, " .
" e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, " .
" CONCAT(e.siren, e.nic) as siret, e.actif " ,
" TEL= $id OR FAX= $id ORDER BY e.siege DESC, e.actif DESC $limit " , false , MYSQL_ASSOC );
} elseif ( $typeId == 'AUTRE' ) {
$tabTmp = $this -> iDb -> select ( 'etablissements' , 'count(*)' , " autre_id=' $id ' " );
$nbTot = $tabTmp [ 0 ][ 0 ];
$listeEtab = $this -> iDb -> select ( 'etablissements e' ,
" 'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, " .
" e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, " .
" e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, " .
" CONCAT(e.siren, e.nic) as siret, e.actif " ,
" autre_id=' $id ' ORDER BY siege DESC $limit " , false , MYSQL_ASSOC );
}
foreach ( $listeEtab as $etab ) {
$tabRet [] = array ( 'Localisation' => $etab [ 'Loc' ],
'id' => $etab [ 'id' ],
'Pertinence' => 100 ,
'Siret' => $etab [ 'siret' ],
'Siege' => $etab [ 'siege' ],
'Nom' => $etab [ 'raisonSociale' ],
'Sigle' => $etab [ 'sigle' ],
'Enseigne' => $etab [ 'enseigne' ],
'Adresse' => trim ( preg_replace ( '/ +/' , ' ' , trim ( $etab [ 'adr_num' ] . ' ' . $etab [ 'adr_btq' ] . ' ' .
$etab [ 'adr_typeVoie' ] . ' ' . $etab [ 'adr_libVoie' ]))),
'Adresse2' => trim ( preg_replace ( '/ +/' , ' ' , $etab [ 'adr_comp' ])),
'CP' => $etab [ 'adr_cp' ],
'Ville' => $etab [ 'adr_ville' ],
'Tel' => $etab [ 'tel' ],
'Fax' => $etab [ 'fax' ],
'FJ' => $etab [ 'cj' ],
'FJLib' => $this -> getLibelleFJ ( $etab [ 'cj' ]),
'Siren' => $etab [ 'siren' ],
'Nic' => $etab [ 'nic' ],
'Actif' => $etab [ 'actif' ],
'NafEtab' => $etab [ 'ape_etab' ], // Etablissement
'NafEnt' => $etab [ 'ape_entrep' ], // Entreprise
'NafEtabLib' => $this -> getLibelleNaf ( $etab [ 'ape_etab' ]),
'NafEntLib' => $this -> getLibelleNaf ( $etab [ 'ape_entrep' ]),
);
}
return array ( 'criteres' => array ( 'autreId' => $id ),
'nbReponses' => count ( $tabRet ),
'nbReponsesTotal' => $nbTot ,
'reponses' => $tabRet );
}
/** Retourne juste si un siren existe
**
** @ param integer $siren
** @ return bool
**/
function sirenExiste ( $siren ) {
$siren = $siren * 1 ;
$listeEtab = $this -> iDb -> select ( 'etablissements' , 'id' , " siren= $siren LIMIT 0,1 " , false , MYSQL_ASSOC );
if ( @ count ( $etabs ) > 0 )
return true ;
return false ;
}
/** Retourne la liste des devise
**
** @ param string $codeDevise Code ISO devise
** @ return Devise ou liste des devises ( si pas de code ISO en entr<EFBFBD> e )
**/
function getDevises ( $codeIso = '' ) {
if ( trim ( $codeIso ) <> '' ) $strWhere = " devIso=' $codeIso ' " ;
else $strWhere = '1' ;
$liste = $this -> iDb -> select ( 'tabDevises' , 'devIso, devNom' , $strWhere , false , MYSQL_ASSOC );
$tabRet = array ();
foreach ( $liste as $ligne )
$tabRet [ $ligne [ 'devIso' ]] = $ligne [ 'devNom' ];
return $tabRet ;
}
/** Retourne la liste des mandataires / administrateurs d 'un ou plusieurs cours d' appel
**
** @ param array $arrIdCA Id S & D de la cour d ' appel
** @ param bool $condense Par d<EFBFBD> faut retourne un tableau concatenant Nom , prenom , adresse compl<EFBFBD> te
** @ return Liste des Mandataires / Administrateurs de la cours d ' appel
**/
function getMandataires ( $arrIdCA = array (), $condense = true ) {
if ( count ( $arrIdCA ) > 0 )
$strIdCA = 'AND coursAppel in (' . implode ( ',' , $arrIdCA ) . ')' ;
else $strIdCA = '' ;
if ( ! $condense )
$fields = 'id,sirenGrp,sirenMand,Nom,Prenom,type,tribunal,Statut,adresse,adresseComp,cp,ville,tel,fax,email,web,contact' ;
else
$fields = " id, CONCAT(Nom,' ',Prenom,' ',adresse,' ',adresseComp,' ',cp,' ',ville) as Mand " ;
$liste = $this -> iDb -> select ( 'tabMandataires' , $fields , " 1 $strIdCA ORDER BY sirenGrp " , true , MYSQL_ASSOC );
$tabRet = array ();
if ( ! $condense ) foreach ( $liste as $ligne ) $tabRet [] = $ligne ;
else foreach ( $liste as $ligne ) $tabRet [ $ligne [ 'id' ]] = preg_replace ( '/ +/' , ' ' , $ligne [ 'Mand' ]);
return $tabRet ;
}
/** Retourne l 'identite Textuelle d' un mandataires / administrateurs
**
** @ param integer $idMand Id S & d du mandataire
** @ return string Mandataire
**/
function getMandatairesParId ( $idMand ) {
$liste = $this -> iDb -> select ( 'tabMandataires' , " CONCAT(Nom,' ',Prenom,' ',adresse,' ',adresseComp,' ',cp,' ',ville) as Mand " , " id= $idMand " , false );
return $liste [ 0 ][ 0 ];
}
function getNaf4 ( $siren , $nic = 0 , $id = 0 ) {
$tabRet = array ();
$siren = $siren * 1 ;
if ( $siren == 0 ) return false ;
$nic = $nic * 1 ;
$id = $id * 1 ;
/* if ( $id > 0 && $siren == 0 ) $where = " id= $id " ;
else */ if ( $nic <> 0 ) $where = " siren= $siren AND nic= $nic " ;
else $where = " siren= $siren AND siege=1 " ;
$insee = $this -> iDbInsee -> select ( 'bascule' , 'siren, nic, apen5, apen4, apet5, apet4' , $where , false , MYSQL_ASSOC );
$tabRet = $insee [ 0 ];
$tabRet [ 'apen4_lib' ] = $this -> getLibelleNaf ( $tabRet [ 'apen4' ]);
$tabRet [ 'apet4_lib' ] = $this -> getLibelleNaf ( $tabRet [ 'apet4' ]);
return $tabRet ;
}
function getIdentiteEntreprise ( $siren , $nic = 0 , $id = 0 , $forceVerif = false ) {
$siren = $siren * 1 ;
$nic = $nic * 1 ;
$id = $id * 1 ;
if ( $id > 0 && $siren == 0 ) $where = " id= $id " ;
elseif ( $nic <> 0 ) $where = " siren= $siren AND nic= $nic " ;
else $where = " siren= $siren AND siege=1 " ;
$listeEtab = $this -> iDb -> select ( 'etablissements e' ,
" e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, e.autre_id, " .
" e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, " .
" e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, " .
" CONCAT(e.siren, e.nic) as siret, e.actif " ,
" $where ORDER BY siege DESC, actif DESC $limit " , false , MYSQL_ASSOC );
$etab =@ $listeEtab [ 0 ];
if ( $siren <> 0 ) {
$info = $this -> iDb -> select ( 'infos_entrep' , 'raisonSociale, isin, nscrl, tel, fax, web, mail, latitude, longitude, precis, dateCreation, dateFermeture, naf, naf_lib, ca, effectif, nbEtab, activite' , " siren= $siren " , false , MYSQL_ASSOC );
$tab = $info [ 0 ];
$insee = $this -> iDbInsee -> select ( 'identite' , 'CONCAT(SIREN,NIC)' , " SIREN= $siren AND SIEGE=1 ORDER BY ACTIF%10 DESC, NIC DESC " , false );
$siretSiege = $insee [ 0 ][ 0 ];
}
if ( $nic > 0 ) $strNic = " AND NIC= $nic " ;
else $strNic = 'AND SIEGE=1' ;
if ( $siren <> 0 ) {
$insee = $this -> iDbInsee -> select ( 'identite' , 'ACTIF%10 AS ACTIF, NOM, NOM2, SIGLE, ENSEIGNE, ADR_NUMVOIE, ADR_BTQ, ADR_TYPVOIE, ADR_LIBVOIE, ADR_LIBCOM, ADR_CP, ADR_COMP, ADR_DISTSP, PAYS, DCREN, SIEGE, AUXILT, SAISONAT, CJ, CIVILITE, NBETAB, APE_ENT, APE_ETAB, PROCOL, PROCOL_TYPE, PROCOL_DATE, CAPITAL, EFF_ENT, NUMRC, TEL, FAX, DIR_FCT, DIR_IDEN, DIR_DATEN, DIR_LIEUN, CAPITAL_DATE, CAPITAL_DEV, DCRET, TEFF_ENT, ADR_DEP, ADR_COM, TCA, TCAEXP, EFF_ET, TEFF_ET, CODEVOIE, DATE_MAJ' ,
" SIREN= $siren $strNic ORDER BY SIEGE DESC, ACTIF DESC " , false , MYSQL_ASSOC );
$tabInsee = $insee [ 0 ];
$tabTmp = $this -> iDb -> select ( 'etablissements' , 'count(*)' , " siren= $siren AND actif<>0 " );
$nbEtab = $tabTmp [ 0 ][ 0 ];
}
else {
$tabInsee = array (
'CIVILITE' => 0 ,
'NBETAB' => 1 ,
'TEL' => $etab [ 'tel' ], /** @todo Prendre sur les pages jaunes **/
'FAX' => $etab [ 'fax' ], /** @todo idem **/
'Web' => '' , /** @todo Prendre sur les pages jaunes et/ou google **/
'Mail' => '' , /** @todo idem **/
'CJ' => $etab [ 'cj' ],
'CJ_lib' => $this -> getLibelleFJ ( $etab [ 'cj' ]),
'ACTIF' => $etab [ 'actif' ],
// e.source, e.source_id,
'APE_ETAB' => $etab [ 'ape_etab' ] ? $etab [ 'ape_etab' ] : $etab [ 'ape_entrep' ],
'APE_ENT' => $etab [ 'ape_entrep' ] ? $etab [ 'ape_entrep' ] : $etab [ 'ape_etab' ],
'CAPITAL' => '' ,
'CAPITAL_DEV' => '' ,
'ADR_DEP' => $tabInsee [ 'adr_dep' ],
//'codeCommune'=>$tabInsee['ADR_COM'],
/* 'TrancheCA' => $tabInsee [ 'TCA' ],
'TrancheCALib' => self :: $tabTCA [ $tabInsee [ 'TCA' ]],
'dir1Titre' => self :: $tabFct [ $tabInsee [ 'DIR_FCT' ]],
'dir1NomPrenom' => $tabInsee [ 'DIR_IDEN' ],
'Rivoli' => substr ( $tabInsee [ 'CODEVOIE' ], 0 , 4 ) . ' ' . substr ( $tabInsee [ 'CODEVOIE' ], - 1 ), */
);
// tel fax cj ape_etab ape_entrep
$nbEtab = 'N/C' ;
}
if ( count ( $info ) == 0 ) {
$idComp = $this -> getIdentitePart ( $siren , $etab [ 'raisonSociale' ], $etab [ 'enseigne' ], $etab [ 'sigle' ]);
if ( $idComp [ 'web' ] <> 'http://' ) $web = $idComp [ 'web' ];
else $web = '' ;
$tabUpdate = array ( 'raisonSociale' => $idComp [ 'raisonSociale' ],
'isin' => $idComp [ 'bourseIsin' ],
'nscrl' => $idComp [ 'nscrl' ],
'tel' => $idComp [ 'tel' ],
'fax' => $idComp [ 'fax' ],
'web' => $web ,
'mail' => $idComp [ 'mail' ],
'dateCreation' => $idComp [ 'dateCreation' ],
'dateFermeture' => $idComp [ 'dateFermeture' ],
'naf' => $idComp [ 'naf' ],
'naf_lib' => $this -> getLibelleNaf ( $idComp [ 'naf' ]),
'ca' => str_replace ( '€' , '<27> ' , $idComp [ 'ca' ]),
'nbEtab' => $idComp [ 'nbEtab' ],
'effectif' => $idComp [ 'effectif' ],
);
$tabInsert = array_merge ( $tabUpdate , array ( 'siren' => $siren ));
if ( ! $this -> iDb -> insert ( 'infos_entrep' , $tabInsert ))
$this -> iDb -> update ( 'infos_entrep' , $tabUpdate , " siren= $siren " );
$tab = $tabUpdate ;
}
if ( $tab [ 'precis' ] == 0 ) {
$mMap = new MMap ( $etab [ 'adr_num' ] . ' ' . $this -> getCodeVoie ( $etab [ 'adr_typeVoie' ]) . ' ' . $etab [ 'adr_libVoie' ], $etab [ 'adr_cp' ], $etab [ 'adr_ville' ]);
$tabUpdate = array ( 'latitude' => $mMap -> latitudeDec ,
'longitude' => $mMap -> longitudeDec ,
'precis' => $mMap -> precision ,
);
$this -> iDb -> update ( 'infos_entrep' , $tabUpdate , " siren= $siren " );
$tab = array_merge ( $tab , $tabUpdate );
}
if ( $siren * 1 > 0 ) {
$iTva = new MTva ( $siren );
$vatNumber = $iTva -> vatNumber ;
$vatDefined = $iTva -> vatDefined ;
} else {
$vatNumber = 'FR00000000000' ;
$vatDefined = false ;
}
if ( strlen ( $etab [ 'raisonSociale' ]) > 40 )
$nom = trim ( $etab [ 'raisonSociale' ] . $tabInsee [ 'NOM2' ]);
else
$nom = $etab [ 'raisonSociale' ];
$tel = $fax = '' ;
if ( trim ( $tab [ 'tel' ]) <> '' ) $tel = trim ( $tab [ 'tel' ]);
elseif ( $tabInsee [ 'TEL' ] <> '' ) $tel = implode ( '.' , str_split ( $tabInsee [ 'TEL' ], 2 ));
if ( trim ( $tab [ 'fax' ]) <> '' ) $fax = trim ( $tab [ 'fax' ]);
elseif ( $tabInsee [ 'FAX' ] <> '' ) $fax = implode ( '.' , str_split ( $tabInsee [ 'FAX' ], 2 ));
$tabRet = array ( 'id' => $etab [ 'id' ],
'Siret' => $etab [ 'siret' ],
'SiretSiege' => $siretSiege ,
'Siege' => $etab [ 'siege' ],
'Nom' => $nom ,
'Sigle' => $etab [ 'sigle' ],
'Enseigne' => $etab [ 'enseigne' ],
'Adresse' => trim ( preg_replace ( '/ +/' , ' ' , trim ( $etab [ 'adr_num' ] . ' ' . $etab [ 'adr_btq' ] . ' ' .
$etab [ 'adr_typeVoie' ] . ' ' . $etab [ 'adr_libVoie' ]))),
'Adresse2' => trim ( preg_replace ( '/ +/' , ' ' , $etab [ 'adr_comp' ])),
'AdresseNum' => $etab [ 'adr_num' ],
'AdresseBtq' => $etab [ 'adr_btq' ],
'AdresseVoie' => $etab [ 'adr_typeVoie' ],
'AdresseRue' => $etab [ 'adr_libVoie' ],
'CP' => $etab [ 'adr_cp' ],
'Ville' => $etab [ 'adr_ville' ],
'Pays' => $tabInsee [ 'PAYS' ],
'Civilite' => $tabInsee [ 'CIVILITE' ], // Prendre sur score3
'NbEtab' => $nbEtab , //$tab['nbEtab']*1, // Prendre sur score3
'Tel' => $tel ,
'Fax' => $fax ,
'Web' => $tab [ 'web' ], // CofaceRating
'Mail' => $tab [ 'mail' ], // CofaceRating
'GeoLat' => $tab [ 'latitude' ],
'GeoLon' => $tab [ 'longitude' ],
'GeoPrecis' => $tab [ 'precis' ],
'TvaNumero' => $vatNumber ,
'TvaAttribue' => $vatDefined ,
'FJ' => $tabInsee [ 'CJ' ],
'FJ_lib' => $this -> getLibelleFJ ( $tabInsee [ 'CJ' ]),
'Siren' => $etab [ 'siren' ],
'Nic' => $etab [ 'nic' ],
'Actif' => $tabInsee [ 'ACTIF' ],
'NafEtab' => $tabInsee [ 'APE_ETAB' ],
'NafEnt' => $tabInsee [ 'APE_ENT' ],
'NafEntLib' => $this -> getLibelleNaf ( $tabInsee [ 'APE_ENT' ]),
'NafEtabLib' => $this -> getLibelleNaf ( $tabInsee [ 'APE_ETAB' ]),
'AutreId' => $etab [ 'autre_id' ],
'Source' => $etab [ 'source' ],
'SourceId' => $etab [ 'source_id' ],
'Isin' => $tab [ 'isin' ],
'Capital' => $tabInsee [ 'CAPITAL' ],
'CapitalDev' => $tabInsee [ 'CAPITAL_DEV' ],
// 'Singularite'=>'',
'DateCreaEt' => $tabInsee [ 'DCRET' ],
'DateCreaEn' => $tabInsee [ 'DCREN' ],
// 'DateClotEn'=>$tabInsee[''],
// 'DateClotEt'=>$tabInsee[''],
'SitJur_lib' => $tabInsee [ 'PROCOL_TYPE' ],
'SitJur_date' => $tabInsee [ 'PROCOL_DATE' ],
'EffEnTr' => $tabInsee [ 'TEFF_ENT' ],
'EffEnTrLib' => self :: $tabEffectif [ $tabInsee [ 'TEFF_ENT' ]],
'Effectif' => $tabInsee [ 'EFF_ENT' ],
'Dept' => $tabInsee [ 'ADR_DEP' ],
'codeCommune' => $tabInsee [ 'ADR_COM' ],
'TrancheCA' => $tabInsee [ 'TCA' ],
'TrancheCALib' => self :: $tabTCA [ $tabInsee [ 'TCA' ]],
'dir1Titre' => self :: $tabFct [ $tabInsee [ 'DIR_FCT' ]],
'dir1NomPrenom' => $tabInsee [ 'DIR_IDEN' ],
'Rivoli' => substr ( $tabInsee [ 'CODEVOIE' ], 0 , 4 ) . ' ' . substr ( $tabInsee [ 'CODEVOIE' ], - 1 ),
);
if ( $siren <> 0 ) {
if ( count ( $this -> getAnnoncesLegales ( $siren , 0 , 'P' , $forceVerif )) > 0 )
$tabRet [ 'SituationJuridique' ] = 'P' ;
/* elseif ( count ( $this -> getAnnoncesLegales ( $siren , 0 , 'R' )) > 0 )
$tabRet [ 'SituationJuridique' ] = 'R' ;
elseif ( count ( $this -> getAnnoncesLegales ( $siren , 0 , 'A' )) > 0 )
$tabRet [ 'SituationJuridique' ] = 'A' ; */
}
if (( $tabInsee [ 'CJ' ] > 0 && $tabInsee [ 'CJ' ] < 20 ||
$tabInsee [ 'CJ' ] > 999 && $tabInsee [ 'CJ' ] < 2000 ) && $tabInsee [ 'DIR_FCT' ] == '' )
$tabRet [ 'dir1Titre' ] = self :: $tabFct [ 'PP' ];
if ( $tabInsee [ 'CIVILITE' ] > 0 && $tabRet [ 'dir1NomPrenom' ] == '' ) {
if ( $tabInsee [ 'CIVILITE' ] == 1 ) $tabRet [ 'dir1NomPrenom' ] = 'M. ' ;
elseif ( $tabInsee [ 'CIVILITE' ] == 2 ) $tabRet [ 'dir1NomPrenom' ] = 'Mme ' ;
$tabRet [ 'dir1NomPrenom' ] .= $tabInsee [ 'NOM' ];
}
if ( $tabInsee [ 'ACTIF' ] == 0 && $siren <> 0 ) {
$tmp = $this -> iDbInsee -> select ( 'insee_even' , 'insDATEVE' , " insSIREN= $siren AND insNIC= " . $etab [ 'nic' ] . " AND ( insEVE LIKE '%F' OR insEVE LIKE '4%' OR insDESTINAT<>'') ORDER BY insDATEVE DESC LIMIT 0,1 " , true );
$tabRet [ 'DateClotEn' ] =@ $tmp [ 0 ][ 0 ];
}
if ( $tabRet [ 'TrancheCALib' ] == '' ) $tabRet [ 'TrancheCALib' ] = 'N/C' ;
if ( $tabRet [ 'EffEnTrLib' ] == '' ) $tabRet [ 'EffEnTrLib' ] = 'N/C' ;
$tabRet [ 'CapitalLib' ] = '' ;
if ( $siren <> 0 ) {
/** Recherche du n<> RC, de la Forme Juridique et du Capital au Bodacc **/
$bodacc = $this -> iDb -> select ( 'bodacc_detail' , 'RC, Capital, CapitalDev, FJ' ,
" siren= $siren AND capital<>0 ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1 " , true , MYSQL_ASSOC );
$annCap =@ $bodacc [ 0 ];
if ( $tabRet [ 'Capital' ] == 0 || $tabRet [ 'CapitalDev' ] == '' ) {
$tabRet [ 'Capital' ] = $annCap [ 'Capital' ];
$tabRet [ 'CapitalDev' ] = $annCap [ 'CapitalDev' ];
}
if ( $tabRet [ 'Capital' ] == 0 || $tabRet [ 'CapitalDev' ] == '' ) {
$iDbHisto = new WDB ( 'historiques' );
$bodaccHisto = $iDbHisto -> select (
'entrep e, texte x' , //.codEven Code <20> v<EFBFBD> nement du mouvement Bodacc libEven ',
'e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, x.annonceNum, x.annonceTxt' ,
" e.SIREN= $siren AND e.ANBASE=x.annonceNum AND e.DATE<20050101 AND x.annonceTxt LIKE '%capital%' /*AND (e.CODEVE BETWEEN 10 AND 19 OR e.CODEVE BETWEEN 30 AND 41 OR e.CODEVE BETWEEN 51 AND 79 ) */ GROUP BY e.ANBASE ORDER BY e.DATE DESC " , true , MYSQL_ASSOC );
if ( count ( $bodaccHisto ) > 0 ) {
foreach ( $bodaccHisto as $ann ) {
if ( ( $ann [ 'CODEVE' ] >= 10 && $ann [ 'CODEVE' ] < 20 ) ||
( $ann [ 'CODEVE' ] >= 30 && $ann [ 'CODEVE' ] < 42 ) ||
( $ann [ 'CODEVE' ] >= 51 && $ann [ 'CODEVE' ] < 80 ) ) {
if ( preg_match ( '/Capital(?:.|)\:(.*)(eur.|f)/Uis' , $ann [ 'annonceTxt' ], $matches ))
$tabRet [ 'Capital' ] = trim ( $matches [ 1 ]);
if ( substr ( strtoupper ( $matches [ 1 ]), 0 , 1 ) == 'E' )
$tabRet [ 'CapitalDev' ] = 'EUR' ;
else
$tabRet [ 'CapitalDev' ] = 'FRF' ;
break ;
}
}
}
}
if ( $tabRet [ 'CapitalDev' ] <> '' && $tabRet [ 'CapitalDev' ] <> 'EUR' ) {
$dev = $tabRet [ 'CapitalDev' ];
$devise = $this -> iDbSD -> select ( 'devise_liste l, devise_cours c' , 'c.devise, c.valeur, c.date, l.devNom, l.devNomPays, l.devPaysIso' , " c.devise=' $dev ' and l.devIso=' $dev ' ORDER BY c.date DESC LIMIT 0,1 " , true , MYSQL_ASSOC );
$dev =@ $devise [ 0 ];
//die(print_r($dev));
$devise = $tabRet [ 'Capital' ] * $dev [ 'valeur' ] * 1 ;
$tabRet [ 'CapitalLib' ] = '' . $dev [ 'devNom' ] . ' soit ' . number_format ( round ( $devise ), null , null , ' ' ) . ' EUR' ;
}
if ( $tabRet [ 'AutreId' ] == '' ) {
if ( $annCap [ 'RC' ] == '' ) {
$bodacc = $this -> iDb -> select ( 'bodacc_detail' , 'RC, FJ' ,
" siren= $siren AND RC<>'' ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1 " , true , MYSQL_ASSOC );
$annCap [ 'RC' ] =@ $bodacc [ 0 ][ 'RC' ];
}
$tabRet [ 'AutreId' ] = $annCap [ 'RC' ];
}
if ( $tabRet [ 'FJ_lib' ] == '' ) {
if ( $annCap [ 'FJ' ] == '' ) {
$bodacc = $this -> iDb -> select ( 'bodacc_detail' , 'FJ' ,
" siren= $siren AND FJ<>'' ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1 " , true , MYSQL_ASSOC );
$annCap [ 'FJ' ] =@ $bodacc [ 0 ][ 'FJ' ];
}
$tabRet [ 'FJ_lib' ] = $annCap [ 'FJ' ];
}
/** Recherche de l'activit<69> r<> elle **/
$bodacc = $this -> iDb -> select ( 'bodacc_detail' , 'Activite, FJ' , " siren= $siren AND Activite<>'' AND Activite NOT LIKE 'non precis%' ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1 " , true , MYSQL_ASSOC );
$annCap =@ $bodacc [ 0 ];
if ( $tabInsee [ 'CJ' ] <> 7210 )
$tabRet [ 'Activite' ] = trim ( /*preg_replace("/Adjonction.{1,7}activit(?:e|<7C> )(?:.|)\:", '', */ $annCap [ 'Activite' ]); //);
if ( $tabRet [ 'FJ_lib' ] == '' )
$tabRet [ 'FJ_lib' ] = $annCap [ 'FJ' ];
if ( $tabRet [ 'Activite' ] == '' && trim ( $tab [ 'activite' ]) <> '' )
$tabRet [ 'Activite' ] = trim ( $tab [ 'activite' ]);
elseif ( $tabRet [ 'Activite' ] == '' && ( $tabInsee [ 'CJ' ] > 90 && $tabInsee [ 'CJ' ] < 94 ||
$tabInsee [ 'CJ' ] > 9000 && $tabInsee [ 'CJ' ] < 9400 ) ) {
$siretMin = ( '' . $siren . '00000' ) * 1 ;
$siretMax = ( '' . $siren . '99999' ) * 1 ;
$bodacc = $this -> iDb -> select ( 'asso' , 'Assoc_Web, Assoc_Mail, Assoc_Objet, Assoc_NObjet' , " Siret BETWEEN $siretMin AND $siretMax AND (Assoc_Objet<>'' OR Assoc_NObjet<>'') ORDER BY Date_Parution DESC LIMIT 0,1 " , true , MYSQL_ASSOC );
$annCap =@ $bodacc [ 0 ];
$tabRet [ 'Activite' ] = trim ( $annCap [ 'Assoc_NObjet' ]);
if ( $tabRet [ 'Activite' ] == '' ) $tabRet [ 'Activite' ] = trim ( $annCap [ 'Assoc_Objet' ]);
if ( $tabRet [ 'Web' ] == '' ) $tabRet [ 'Web' ] = trim ( $annCap [ 'Assoc_Web' ]);
if ( $tabRet [ 'Mail' ] == '' ) $tabRet [ 'Mail' ] = trim ( $annCap [ 'Assoc_Mail' ]);
} elseif ( $tabRet [ 'Activite' ] == '' && $tabInsee [ 'CJ' ] <> 7210 ) {
$iDbHisto = new WDB ( 'historiques' );
//10 <20> 19// Cr<43> ation d'entreprise
//30 <20> 41
//51 <20> 79=>'1503', // Cloture insuf.Actif
$bodaccHisto = $iDbHisto -> select (
'entrep e, texte x' , //.codEven Code <20> v<EFBFBD> nement du mouvement Bodacc libEven ',
'e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, x.annonceNum, x.annonceTxt' ,
" e.SIREN= $siren AND e.ANBASE=x.annonceNum AND e.DATE<=20041231 AND x.annonceTxt LIKE '%ctivit%' GROUP BY e.ANBASE ORDER BY e.DATE DESC " , true , MYSQL_ASSOC );
if ( count ( $bodaccHisto ) > 0 ) {
foreach ( $bodaccHisto as $idx => $ann ) {
//if ($siren==403119431) $tabRet['Activite'].="$idx(".$ann['CODEVE'].'):'.$ann['annonceTxt'].' / ';
if ( ( $ann [ 'CODEVE' ] < 20 ) ||
( $ann [ 'CODEVE' ] >= 30 && $ann [ 'CODEVE' ] < 42 ) ||
( $ann [ 'CODEVE' ] >= 51 && $ann [ 'CODEVE' ] < 80 ) ) {
//Activite: r
if ( preg_match ( '/Activit(?:e|<7C> )(?:.|)\:(.*)(?:Adresse.*|Commentaires?|Administration|Etablissement principal|Date d\'effet|Date.de.d.but d.activit.)(?:.|)\:/Uis' , $ann [ 'annonceTxt' ], $matches ))
$tabRet [ 'Activite' ] = $matches [ 1 ];
break ;
}
/* $bodaccHisto = $iDbHisto -> select (
'entrep e, texte x, tribunaux t' , //.codEven Code <20> v<EFBFBD> nement du mouvement Bodacc libEven ',
'e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, x.annonceNum, x.annonceTxt, t.triNom, t.triSiret' ,
" e.SIREN= $siren AND e.ANBASE=x.annonceNum AND e.CODTRI=t.triCode $strIdAnn AND e.DATE BETWEEN 19920101 AND 20041231 GROUP BY e.ANBASE ORDER BY e.DATE DESC " , true , MYSQL_ASSOC ); */
}
}
}
$bodacc = $this -> iDb -> select ( 'bodacc_dirigeants d, bodacc_detail b, bodacc_fonctions f' ,
'd.num, d.dateEffet, d.Rubrique, d.fonction, d.rs, d.nom, d.prenom, d.nomUsage, d.depart, d.dateInsert, f.libelle' ,
" 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 AND d.depart<>1 AND f.triCode IN ('ASS','COG','DID','DIR','GER','PCS','PDG','PRD','PRE','PRT','VIC') GROUP BY d.fonction, d.rs, d.nom, d.prenom ORDER BY d.dateEffet DESC " , true , MYSQL_ASSOC );
//$annCap=@$bodacc[0];
if ( count ( $bodacc ) > 0 ) {
$k = 1 ;
foreach ( $bodacc as $ann ) {
$tabRet [ 'dir' . $k . 'Titre' ] = $ann [ 'libelle' ];
$tabRet [ 'dir' . $k . 'NomPrenom' ] = $ann [ 'rs' ] . ' ' . $ann [ 'nom' ] . ' ' . $ann [ 'prenom' ];
$tabRet [ 'dir' . $k . 'DateFct' ] = $ann [ 'dateEffet' ];
if ( $k == 2 ) break ;
$k ++ ;
}
}
/** Recherche du site Web ou Email dans le JO ASSO
**/
if ( ( $tabRet [ 'Web' ] == '' || $tabRet [ 'Mail' ] == '' ) &&
( $tabInsee [ 'CJ' ] > 90 && $tabInsee [ 'CJ' ] < 94 ||
$tabInsee [ 'CJ' ] > 9000 && $tabInsee [ 'CJ' ] < 9400 ) ) {
$siretMin = ( '' . $siren . '00000' ) * 1 ;
$siretMax = ( '' . $siren . '99999' ) * 1 ;
$bodacc = $this -> iDb -> select ( 'asso' , 'Assoc_Web, Assoc_Mail' , " Siret BETWEEN $siretMin AND $siretMax AND (Assoc_Web<>'' OR Assoc_Mail<>'') ORDER BY Date_Parution DESC LIMIT 0,1 " , true , MYSQL_ASSOC );
$annCap =@ $bodacc [ 0 ];
if ( $tabRet [ 'Web' ] == '' ) $tabRet [ 'Web' ] = trim ( $annCap [ 'Assoc_Web' ]);
if ( $tabRet [ 'Mail' ] == '' ) $tabRet [ 'Mail' ] = trim ( $annCap [ 'Assoc_Mail' ]);
}
} else {
if ( $etab [ 'source' ] == 3 ) {
$id = $etab [ 'source_id' ];
$bodacc = $this -> iDb -> select ( 'asso' , 'Activite, Sous_Prefecture, Assoc_Web, Assoc_Mail, Assoc_Objet, Assoc_Fusion, Assoc_Date_Declaration2' , " id= $id " , true , MYSQL_ASSOC );
$annCap =@ $bodacc [ 0 ];
$tabRet [ 'Activite' ] = $annCap [ 'Assoc_Objet' ];
$tabRet [ 'Web' ] = $annCap [ 'Assoc_Web' ];
$tabRet [ 'Mail' ] = $annCap [ 'Assoc_Mail' ];
$tabRet [ 'VilleDecl' ] = $annCap [ 'Sous_Prefecture' ];
if ( $tabRet [ 'Actif' ] == 0 ) {
$tabRet [ 'DateClotEn' ] = $annCap [ 'Assoc_Date_Declaration2' ];
$tabRet [ 'DateClotEt' ] = $annCap [ 'Assoc_Date_Declaration2' ];
} else {
$tabRet [ 'DateCreaEt' ] = $annCap [ 'Assoc_Date_Declaration2' ];
$tabRet [ 'DateCreaEn' ] = $annCap [ 'Assoc_Date_Declaration2' ];
}
}
}
return $tabRet ;
}
function getDirigeants ( $siren , $histo = true ) {
$siren = $siren * 1 ;
$tabRet = array ();
if ( $histo ) {
$bodacc = $this -> iDb -> select (
'bodacc_dirigeants d, bodacc_detail b, bodacc_fonctions f' ,
'd.num, d.dateEffet, d.Rubrique, d.fonction, d.rs, d.nom, d.prenom, d.nomUsage, d.depart, d.dateInsert, f.libelle' ,
" 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' ],
);
}
}
$iDbHisto = new WDB ( 'historiques' );
$iBodacc = new MBodacc ();
$bodaccHisto = $iDbHisto -> select (
'entrep e, texte x' ,
'e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, x.annonceNum, x.annonceTxt' ,
" e.SIREN= $siren AND e.ANBASE=x.annonceNum AND e.DATE BETWEEN 19920101 AND 20050101 AND x.annonceTxt LIKE '%Administration%' GROUP BY e.ANBASE ORDER BY e.DATE DESC " , true , MYSQL_ASSOC );
if ( count ( $bodaccHisto ) > 0 ) {
foreach ( $bodaccHisto as $ann ) {
if ( ( $ann [ 'CODEVE' ] < 20 ) ||
( $ann [ 'CODEVE' ] >= 30 && $ann [ 'CODEVE' ] < 42 ) ||
( $ann [ 'CODEVE' ] >= 51 && $ann [ 'CODEVE' ] < 80 ) ) {
if ( preg_match ( '/Administration(?:.|)\:(.*)(?:Adresse.*|Commentaires?|Activit(?:e|<7C> )|Etablissement principal|Date d\'effet|Date.de.d.but d.activit.)(?:.|)\:/Uis' , $ann [ 'annonceTxt' ], $matches )) {
$tabAdministration = $iBodacc -> getDirigeants ( $matches [ 1 ]);
foreach ( $tabAdministration as $tabDir ) {
/* $tabDir [ 'num' ] = $numDir ;
$tabDir [ 'dateEffet' ] = $dateEffet ;
$tabDir [ 'id' ] = $idAnnRet ;
$tabDir [ 'Rubrique' ] = 'mmd' ;
$tabDir [ 'dateInsert' ] = $dateInsert ;
//'fonction'=>$numFonction, 'rs'=>trim(str_replace(',','',$raisonSociale)), 'nom'=>$nom, 'prenom'=>$prenom, 'nomUsage'=>$usage, 'depart'=>$oldFonction);
*/
$nom = trim ( strtr ( preg_replace ( '/ +/' , ' ' , $tabDir [ 'nom' ]),
array ( " Modification d' " => '' ,
" Modification " => '' ,
" Modification de " => '' ,
" Nomination d'un " => '' ,
" Nomination en qualit<69> d' " => '' ,
" Nomination en qualit<69> de " => '' ,
" dont le est " => '' ,
" nouvel " => '' ,
" partant " => '' ,
" ancien d'honneur " => '' ,
" nouveaux " => '' ,
" nouveau " => '' ,
" ancien " => '' ,
" Nouveau " => '' ,
" Cette soci<63> t<EFBFBD> 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' ]),
);
}
//break;
}
}
}
}
}
if ( ! $histo || ( $histo && count ( $tabRet ) == 0 ) ) {
$dirs = $this -> iDb -> select (
'rncs_dirigeants/* d, bodacc_fonctions f*/' ,
'siren, raisonSociale, civilite, nom, prenom, naissance_nom, naissance_date, naissance_lieu, fonction_code, fonction_lib /*f.libelle*/' ,
" siren= $siren /*AND d.fonction_code=f.codeFct*/ AND actif=1 " , true , MYSQL_ASSOC );
foreach ( $dirs as $k => $dir ) {
if ( $dir [ 'naissance_date' ] <> '0000-00-00' )
$dateNaiss = Wdate :: dateT ( 'Y-m-d' , 'd/m/Y' , $dir [ 'naissance_date' ]);
else
$dateNaiss = '' ;
$tabRet [] = array ( 'Titre' => $dir [ 'fonction_lib' ],
'Societe' => '' , //utf8_encode($dir['Societe']),
'Nom' => trim ( $dir [ 'civilite' ] . ' ' . $dir [ 'nom' ]),
'Prenom' => $dir [ 'prenom' ],
'NaissDate' => $dateNaiss ,
'NaissVille' => $dir [ 'naissance_lieu' ],
'NaissDepPays' => '' , // 25
'Ancien' => 0 ,
'DateFct' => '' ,
);
}
}
if ( count ( $tabRet ) == 0 ) {
$rncs = new MEuridile ();
$tab = $rncs -> getInfosDisponbiles ( $siren );
if ( $tab [ 'erreur' ] == '' ) {
$tabTmp = $rncs -> getIdentite ( $siren );
$etab = $this -> getIdentiteEntreprise ( $siren );
if ( $tabTmp [ 'sexe' ] <> '' ) {
$civilite = '' ;
if ( $tabTmp [ 'sexe' ] == 'Masculin' ) { $genre = 'Monsieur ' ; $civilite = 'M' ; }
elseif ( $tabTmp [ 'sexe' ] == 'F<> minin' ) { $genre = 'Madame ' ; $civilite = 'MME' ; }
else $genre = $tabTmp [ 'sexe' ]; //, 'MLLE'
$tabRet [] = array ( 'Titre' => 'Personne physique' ,
'Societe' => '' , //utf8_encode($dir['Societe']),
'Nom' => $genre . $tabTmp [ 'nom' ],
'Prenom' => '' ,
'NaissDate' => $tabTmp [ 'naiss_date' ], // 07/09/1961
'NaissVille' => $tabTmp [ 'naiss_ville' ], // LE RUSSEY
'NaissDepPays' => '' , // 25
'Ancien' => 0 ,
'DateFct' => $tabTmp [ 'date_imma' ],
);
$this -> iDb -> insert ( 'rncs_dirigeants' , array ( 'siren' => $siren ,
'raisonSociale' => $etab [ 'Nom' ],
'civilite' => $civilite ,
'nom' => $tabTmp [ 'nom' ],
'prenom' => '' ,
'naissance_nom' => '' ,
'naissance_date' => Wdate :: dateT ( 'd/m/Y' , 'Y-m-d' , $tabTmp [ 'naiss_date' ]), // 07/09/1961
'naissance_lieu' => $tabTmp [ 'naiss_ville' ],
'fonction_code' => 1050 ,
'fonction_lib' => 'Personne physique' ,
'actif' => 1 ,
'dateInsert' => date ( 'YmdHis' ),
), true );
}
else {
foreach ( $tabTmp [ 'dirigeants' ] as $nb => $dir ) { /*
[] => Associ ? - g ? rant */
//debugLog('I', "Siren/Siret $siren trouv<75> : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$tabRet [] = array ( 'Titre' => $dir [ 'fonction' ], //utf8
'Societe' => '' , //utf8_encode($dir['Societe']),
'Nom' => trim ( strtr ( $dir [ 'nom' ],
array ( " Modification d' " => '' , " Modification de " => '' , '.' => '' ))),
'Prenom' => $dir [ 'prenom' ],
'NaissDate' => $dir [ 'naiss_date' ], // 07/09/1961
'NaissVille' => $dir [ 'naiss_ville' ], // LE RUSSEY
'NaissDepPays' => '' , //$dir['naiss_depPays'], // 25
'Ancien' => 0 ,
'DateFct' => '' ,
);
$this -> iDb -> insert ( 'rncs_dirigeants' , array ( 'siren' => $siren ,
'raisonSociale' => $etab [ 'Nom' ],
'civilite' => '' ,
'nom' => $dir [ 'nom' ],
'prenom' => $dir [ 'prenom' ],
'naissance_nom' => $dir [ 'naiss_nom' ],
'naissance_date' => Wdate :: dateT ( 'd/m/Y' , 'Y-m-d' , $dir [ 'naiss_date' ]), // 07/09/1961
'naissance_lieu' => $dir [ 'naiss_ville' ],
'fonction_code' => 0 ,
'fonction_lib' => $dir [ 'fonction' ],
'actif' => 1 ,
'dateInsert' => date ( 'YmdHis' ),
), true );
}
}
}
}
return $tabRet ;
}
function getAnnoncesLegales ( $siren , $idAnnonce = 0 , $rubrique = '' , $forceVerif = false ) { // rubrique = P R A (Procol Rad ou Absorb<72> e / A venir Vendue)
$siren = $siren * 1 ;
$strIdAnn = '' ;
$tabRet = array ();
$procol = false ; // Par d<> faut, on ne trouve pas de proc<6F> dure collective !
if ( $idAnnonce > 0 ) $strIdAnn = " AND d.id= $idAnnonce " ;
if ( $rubrique == 'P' ) $strIdAnn = " AND d.Rubrique='procol' AND d.typeEven NOT LIKE '%1550%' " ;
//elseif ($rubrique=='R') $strIdAnn=" AND d.Rubrique='radiations' ";
//elseif ($rubrique=='V') $strIdAnn=" AND d.Rubrique='ventes' ";
//elseif ($rubrique=='A') $strIdAnn=" AND d.typeEven='%2720%' ";
if ( $rubrique <> '' && $rubrique <> 'P' ) // && $rubrique<>'R' && $rubrique<>'A')
return false ;
if ( $idAnnonce == 0 || $idAnnonce >= 1 ) { /** On recherche dans les annonces r<> centes **/
$groupBy = ' ' ;
$strCle = '1 ' ;
if ( $siren <> 0 ) $strCle = " d.siren= $siren " ;
else $groupBy = ' GROUP BY d.id ' ;
$bodacc = $this -> iDb -> select (
'bodacc_detail d, bodacc b, tribunaux t' , //.codEven Code <20> v<EFBFBD> nement du mouvement Bodacc libEven ',
'b.id, b.Bodacc_Code, b.Bodacc_Annee_Parution, b.Bodacc_Num, b.Num_Annonce, b.Bodacc_Date_Parution, b.Tribunal_Dept, b.Tribunal_Code, d.Rubrique, b.typeAnnonce, b.corrNum_Annonce, b.corrBodacc_Date_Parution, b.corrPage, b.corrNumParution, b.corrTexteRectificatif, b.annonce, b.dateInsert, t.triCode, t.triNom, t.triSiret, d.typeEven, d.dateEffet, d.dateDebutActivite, d.dateCessationActivite, d.dateJugement' ,
" $strCle AND d.id=b.id AND b.Tribunal_Code=t.triCode $strIdAnn $groupBy ORDER BY b.Bodacc_Date_Parution DESC " , true , MYSQL_ASSOC );
$k = 0 ;
if ( count ( $bodacc ) > 0 ) {
foreach ( $bodacc as $k => $ann ) {
$tabEven = explode ( ';' , $ann [ 'typeEven' ]);
$tabRetEven = array ();
if ( $ann [ 'typeAnnonce' ] <> 'Insertion' ) //BODACC n<> 002 A du 04/01/2006.
$tabRetEven [] = array ( 'CodeEven' => '0000' ,
'LibEven' => $ann [ 'typeAnnonce' ] . ' de l\'annonce ' ./* n<EFBFBD> ' .
$ann [ 'corrNum_Annonce' ] . ' BODACC n<> ' .
$ann [ 'corrNumParution' ] .*/ ' du ' .
WDate :: dateT ( 'Y-m-d' , 'd/m/Y' , $ann [ 'corrBodacc_Date_Parution' ]) /*. ' (page ' .
$ann [ 'corrPage' ] . ')' */ );
else {
if ( trim ( $ann [ 'typeEven' ]) <> '' ) {
foreach ( $tabEven as $even )
$tabRetEven [] = array ( 'CodeEven' => $even , 'LibEven' => $this -> iBodacc -> getEvenement ( $even ));
}
else {
switch ( $ann [ 'Rubrique' ]) {
case 'mmd' : $codeEven = '2313' ; $libEven = 'Modification(s) diverse(s)' ; break ;
case 'comptes' : $codeEven = '3999' ; $libEven = 'D<> p<EFBFBD> t des comptes' ; break ;
case 'creations' : $codeEven = '4999' ; $libEven = 'Cr<43> ation d\'entreprise' ; break ;
case 'procol' : $codeEven = '1999' ; $libEven = 'Proc<6F> dure collective' ; break ;
case 'radiations' : $codeEven = '6700' ; $libEven = 'Radiation' ; break ;
case 'ventes' : $codeEven = '5999' ; $libEven = 'Vente/Cession' ; break ;
default : $codeEven = '0000' ; $libEven = $ann [ 'Rubrique' ]; break ;
}
$tabRetEven [] = array ( 'CodeEven' => $codeEven , 'LibEven' => $libEven );
}
}
if ( $ann [ 'Rubrique' ] == 'procol' ) $procol = true ;
$tabRet [ $k ] = array ( 'id' => $ann [ 'id' ],
'BodaccCode' => 'BOD' . $ann [ 'Bodacc_Code' ],
'BodaccNum' => $ann [ 'Bodacc_Num' ],
'NumAnnonce' => $ann [ 'Num_Annonce' ],
'DateParution' => $ann [ 'Bodacc_Date_Parution' ],
'Departement' => $ann [ 'Tribunal_Dept' ],
'Tribunal' => $ann [ 'triNom' ],
'TribunalSiret' => $ann [ 'triSiret' ],
'Rubrique' => $ann [ 'Rubrique' ],
'typeAnnonce' => $ann [ 'typeAnnonce' ],
'texteRectificatif' => $ann [ 'corrTexteRectificatif' ],
// 'texteAnnonce'=>$ann['annonce'],
'dateEffet' => $ann [ 'dateEffet' ],
'dateJugement' => $ann [ 'dateJugement' ],
/// d.dateDebutActivite, d.dateCessationActivite, d.dateJugement',
'dateInsertionSD' => $ann [ 'dateInsert' ],
'evenements' => $tabRetEven ,
);
if ( $idAnnonce <> 0 ) $tabRet [ $k ][ 'texteAnnonce' ] = $ann [ 'annonce' ];
}
}
}
if ( $idAnnonce == 0 || $idAnnonce < 0 ) { /** On recherche dans les annonces pass<73> es **/
$iDbHisto = new WDB ( 'historiques' );
$tabTmp = array ( 10 => '4000' , // Cr<43> ation d'entreprise
11 => '4000' ,
13 => '4000' ,
14 => '4000' ,
15 => '4000' ,
16 => '4000' ,
17 => '4200' , // Cr<43> ation d'<27> tablissement
18 => '4200' ,
19 => '4200' ,
20 => '5999' , // ou 5700 en fonction du code xxx
21 => '5999' ,
22 => '5999' ,
24 => '5999' ,
25 => '5999' ,
30 => '2500' , // Confirmation Ets
31 => '2318' ,
32 => '2318' ,
33 => '2318' ,
34 => '2318' ,
35 => '2318' ,
36 => '2318' ,
37 => '2800' , // Loc. G<> rance recue
38 => '2860' , // Loc. G<> rance donn<6E> e
39 => '2318' ,
40 => '6700' , // Radiation
41 => '2202' , // Dissolution
42 => '2885' , // Fin location g<> rance
51 => '1209' , // R<> glement Judiciaire
52 => '1200' , // Redressement Judiciaire
53 => '1207' , // R<> glemement amiable
//53=> Conciliation ????????????????????????????????????????
56 => '1310' , // Proc<6F> dure d'Insolvabilit<69> Europ<6F> enne
57 => '1100' , // Jugement de sauvegarde
58 => '1101' , // Plan de sauvegarde
59 => '1506' , // Rectif ou Annulation RJ
60 => '1305' , // Redr.& liq.Judiciaire
61 => '1603' , // Liquidation de Biens
62 => '1305' ,
63 => '1600' , // Faillite personnelle
64 => '1601' , // Interdiction de g<> rer
65 => '1305' ,
66 => '1306' , // Liquidation Judiciaire Simplifi<66> e
69 => '1506' , //Rectif ou Annul.LJ
70 => '1550' , // Suites de jugements
71 => '1550' , // Suite reglement/L
72 => '1550' , // Suite redressement/L
73 => '1550' , // Susp.Provis.pours. ?????????????????????????????????????????
74 => '1505' , // Appel de jugement
75 => '1407' , // Modif. de Plan
76 => '1502' , // Extinction Passif
77 => '1210' , // Production
78 => '1204' , // D<> p<EFBFBD> t des cr<63> ances
79 => '1503' , // Cloture insuf.Actif
92 => '1450' , //Cessation paiement ??
);
if ( $idAnnonce < 0 ) {
$idAnnonce = abs ( $idAnnonce );
$strIdAnn = " AND e.ANBASE= $idAnnonce " ;
}
if ( $rubrique == 'P' ) $strIdAnn = " AND e.CODEVE BETWEEN 50 AND 79 " ;
//elseif ($rubrique=='R') $strIdAnn=" AND e.CODEVE BETWEEN 40 AND 42 ";
//elseif ($rubrique=='A') return $tabRet;
$bodaccHisto = $iDbHisto -> select (
'entrep e, texte x, tribunaux t' , //.codEven Code <20> v<EFBFBD> nement du mouvement Bodacc libEven ',
'e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, x.annonceNum, x.annonceTxt, t.triNom, t.triSiret' ,
" e.SIREN= $siren AND e.ANBASE=x.annonceNum AND e.CODTRI=t.triCode $strIdAnn AND e.DATE BETWEEN 19920101 AND 20041231 GROUP BY e.ANBASE ORDER BY e.DATE DESC " , true , MYSQL_ASSOC );
if ( count ( $bodaccHisto ) > 0 ) {
foreach ( $bodaccHisto as $ann ) {
$k ++ ;
//if ($ann['DATE']<19920101) break;
//if ($ann['DATE']>20051231) continue;
if ( $ann [ 'JAL' ] == 1 ) $Bodacc_Code = 'BODA' ;
elseif ( $ann [ 'JAL' ] == 200 ) $Bodacc_Code = 'BODB' ;
if ( $ann [ 'CODEVE' ] > 49 && $ann [ 'CODEVE' ] < 80 ) $procol = true ;
if ( $ann [ 'CODEVE' ] < 20 ) $rub = 'creations' ; // 4xxx
elseif ( $ann [ 'CODEVE' ] <= 25 ) $rub = 'ventes' ; // 5xxx
elseif ( $ann [ 'CODEVE' ] < 40 ) $rub = 'mmd' ; // 2xxx
elseif ( $ann [ 'CODEVE' ] < 42 ) $rub = 'radiations' ; // 6xxx
elseif ( $ann [ 'CODEVE' ] < 50 ) $rub = 'mmd' ; // 2xxx
elseif ( $ann [ 'CODEVE' ] < 80 ) $rub = 'procol' ; // 1xxx
$tabRet [ $k ] = array ( 'id' =>- $ann [ 'ANBASE' ],
'BodaccCode' => $Bodacc_Code ,
'BodaccNum' => $ann [ 'NOBOD' ],
'NumAnnonce' => $ann [ 'NOANN' ],
'DateParution' => substr ( $ann [ 'DATE' ], 0 , 4 ) . '-' . substr ( $ann [ 'DATE' ], 4 , 2 ) . '-' . substr ( $ann [ 'DATE' ], 6 , 2 ),
'Departement' => $ann [ 'DEPT' ],
'Tribunal' => $ann [ 'triNom' ],
'TribunalSiret' => $ann [ 'triSiret' ],
'Rubrique' => $rub ,
'typeAnnonce' => 'Insertion' , /** @todo <20> GERER $ann['SSCODE'],**/
//'texteRectificatif'=>$ann['corrTexteRectificatif'],
// 'texteAnnonce'=>$ann['annonceTxt'],
'dateEffet' => $ann [ 'DATE' ],
'dateJugement' => $ann [ 'DATE' ],
'dateInsertionSD' => '' ,
'evenements' => array ( array ( 'CodeEven' => $tabTmp [ $ann [ 'CODEVE' ]], 'LibEven' => $this -> iBodacc -> getEvenement ( $tabTmp [ $ann [ 'CODEVE' ]]))),
);
if ( $idAnnonce <> 0 ) $tabRet [ $k ][ 'texteAnnonce' ] = $ann [ 'NOANN' ] . ' - ' . $ann [ 'annonceTxt' ];
}
}
}
// On ne cherche pas de PROCOL + r<> cente si on est en visualisation d'annonce Bodacc Classique
if ( $idAnnonce >= 1 || $idAnnonce < 0 ) return $tabRet ;
// Si je n'ai pas d'annonce Bodacc de procol on v<> rifie dans la table de collecte
// Si annonce Bodacc de Procol et pas de V<> rif Forc<72> e chez un partenaire alors on affiche la collecte
if ( ! $procol || ( $procol && ! $forceVerif )) {
$tabTmp = $this -> getProColPart ( $siren , $forceVerif );
$tabRet = array_merge ( $tabTmp , $tabRet );
}
return $tabRet ;
}
function getAnnoncesBalo ( $siren , $idAnnonce = 0 ) {
$siren = $siren * 1 ;
$strIdAnn = '' ;
$tabRet = array ();
if ( $idAnnonce > 0 ) {
//$idBalo=//.$tabBalo['Num_Affaire'].','.$tabBalo['Num_Parution'];
$tmp = explode ( '.' , $idAnnonce );
//if (strlen($tmp[0])==9 && is_numeric($tmp[0])) $rcs=$tmp[0];
if ( is_numeric ( $tmp [ 0 ])) $num = $tmp [ 0 ];
if ( is_numeric ( $tmp [ 1 ])) $par = $tmp [ 1 ];
//$idBaloPdf=basename($tabBalo['Url_Annonce_Pdf']);
$strIdAnn = " AND Num_Affaire=' $num ' AND Num_Parution=' $par ' " ;
//$idAnnonce
}
$mBalo = new MBalo ();
$bodacc = $this -> iDb -> select ( 'balo' , " Societe_Rcs, Categorie, Num_Affaire, Date_Parution, Num_Parution, Url_Annonce_Html, Url_Annonce_Pdf, Annonce_Html, dateInsert " , " Societe_Rcs=' $siren ' AND Date_Parution>='2004-01-01' $strIdAnn ORDER BY Date_Parution DESC, Num_Affaire " , true , MYSQL_ASSOC );
// $RP=mysql_select('balo', " ", "Societe_Rcs='$rcs' ");
$k = 0 ;
if ( count ( $bodacc ) > 0 ) {
foreach ( $bodacc as $k => $ann ) {
$tabRetEven = array ();
$tabRetEven [] = array ( 'CodeEven' => $mBalo -> getLibEven ( $ann [ 'Categorie' ]),
'LibEven' => $ann [ 'Categorie' ]);
$tabRet [ $k ] = array ( 'id' => $ann [ 'Num_Affaire' ] . '.' . $ann [ 'Num_Parution' ],
'BodaccCode' => 'BALO' ,
'BodaccNum' => $ann [ 'Num_Parution' ],
'NumAnnonce' => $ann [ 'Num_Affaire' ],
'DateParution' => $ann [ 'Date_Parution' ],
//'Departement'=>'',$ann['Tribunal_Dept'],
//'Tribunal'=>$ann['triNom'],
//'TribunalSiret'=>$ann['triSiret'],
//'Rubrique'=>$ann['Rubrique'],
'typeAnnonce' => 'Insertion' ,
'dateInsertionSD' => $ann [ 'dateInsert' ],
'evenements' => $tabRetEven ,
'Lien_Annonce_Pdf' => basename ( $ann [ 'Url_Annonce_Pdf' ]),
);
if ( $idAnnonce <> 0 ) $tabRet [ $k ][ 'texteAnnonce' ] = strtr ( preg_replace ( '/<html.*<body.*>/Uis' , '' ,
preg_replace ( '/( class=".*")/ie' , ' ' , $ann [ 'Annonce_Html' ])), array ( ' ' => ' ' , '</html>' => '' , '</body>' => '' ));
}
}
return $tabRet ;
}
function getAnnoncesAsso ( $siren , $idAnnonce = 0 ) {
$siretMin = $siren . '00000' ;
$siretMax = $siren . '99999' ;
$strIdAnn = '' ;
$tabRet = array ();
if ( $idAnnonce > 0 ){
$strIdAnn = " AND id= $idAnnonce " ;
//$mAsso=new MAsso();
if ( $siren == 0 ) {
$bodacc = $this -> iDb -> select ( 'asso' , " Waldec " , " Siret BETWEEN $siretMin AND $siretMax $strIdAnn AND Waldec<>'' " );
if ( @ $bodacc [ 0 ][ 0 ] <> '' ) $strIdAnn = " AND Waldec=' " . $bodacc [ 0 ][ 0 ] . " ' " ;
}
}
$bodacc = $this -> iDb -> select ( 'asso' , " id, Assoc_Nom, Siret, Waldec, Activite, Num_Annonce, Date_Parution, Num_Parution, Departement, Sous_Prefecture, Type_Annonce, Annonce_Html, Assoc_Objet, Assoc_Adresse, Assoc_NObjet, Assoc_AObjet, Assoc_NAdresse, Assoc_Fusion, Assoc_Annulation, Assoc_ANom, Assoc_NNom, Assoc_Date_Declaration, Assoc_Date_Declaration2, dateInsert " , " Siret BETWEEN $siretMin AND $siretMax $strIdAnn ORDER BY Date_Parution DESC " , true , MYSQL_ASSOC );
// $RP=mysql_select('balo', " ", "Societe_Rcs='$rcs' ");
$k = 0 ;
if ( count ( $bodacc ) > 0 ) {
foreach ( $bodacc as $k => $ann ) {
$tabRetEven = array ();
$tabRetEven [] = array ( 'CodeEven' => 0000 , //$mAsso->getLibEven($ann['Categorie']),
'LibEven' => $ann [ 'Type_Annonce' ]);
// Rubrique
if ( preg_match ( '/cr(<28> |e)ation/i' , $ann [ 'Type_Annonce' ]))
$rub = 'creations' ;
elseif ( preg_match ( '/Dissolution/i' , $ann [ 'Type_Annonce' ]))
$rub = 'radiations' ;
else
$rub = 'mmd' ;
// typeAnnonce
if ( preg_match ( '/Annulation/i' , $ann [ 'Type_Annonce' ]))
$type = 'Suppression' ;
elseif ( preg_match ( '/Rectif/i' , $ann [ 'Type_Annonce' ]))
$type = 'Rectificatif' ;
else
$type = 'Insertion' ;
if ( str_replace ( '-' , '' , $ann [ 'Date_Parution' ]) * 1 >= 20070401 ) $dateInsert = $ann [ 'Date_Parution' ];
else $dateInsert = '' ;
$tabRet [ $k ] = array ( 'id' => $ann [ 'id' ],
'BodaccCode' => 'ASSO' ,
'BodaccNum' => $ann [ 'Num_Parution' ],
'NumAnnonce' => $ann [ 'Num_Annonce' ],
'DateParution' => $ann [ 'Date_Parution' ],
'Departement' => $ann [ 'Departement' ],
'Tribunal' => $ann [ 'Sous_Prefecture' ],
//'TribunalSiret'=>$ann['triSiret'],
'Rubrique' => $rub ,
'typeAnnonce' => $type ,
'dateInsertionSD' => $dateInsert ,
'evenements' => $tabRetEven ,
//'Lien_Annonce_Pdf'=>basename($ann['Url_Annonce_Pdf']),
);
if ( $idAnnonce <> 0 )
/* if ( preg_match ( " ~( \x00 [ \x80 - \xff ]|[ \x00 - \x07 ][ \x00 - \xff ]~ " , $ann [ 'Annonce_Html' ] ) )
$tabRet [ $k ][ 'texteAnnonce' ] = 'utf8 : ' . $ann [ 'Annonce_Html' ];
else */
$tabRet [ $k ][ 'texteAnnonce' ] = strip_tags ( strtr ( htmlentities ( $ann [ 'Annonce_Html' ]), array ( '>' => '>' , '&' => '&' , '<' => '<' )));
}
}
return $tabRet ;
}
function getIdentitePart ( $siren , $rs , $enseigne , $sigle ) {
$referer = '' ;
$url = 'http://www.cofacerating.fr/portail/entreprise_identite/identite.asp?ip=pagespro&lg=fr&nsiren=' . $siren ;
$page = getUrl ( $url , '' , '' , $referer , false , 'www.cofacerating.fr' , '' , 5 );
$this -> body = $page [ 'body' ];
$this -> codeRetour = $page [ 'code' ];
$this -> header = $page [ 'header' ];
$tabRet = array ();
$tabRet [ 'nscrl' ] =@ getTextInHtml ( $this -> body , '&nscrl=' , '=' , '&' );
$strTmp = trim ( str_replace ( chr ( 160 ), ' ' , html_entity_decode ( utf8_encode ( @ getTextInHtml ( $this -> body , '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne"> <b> Raison sociale<br>' , '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval"><b>' , '</tr>' )))));
$tmp = explode ( '<br>' , $strTmp );
$tabRet [ 'raisonSociale' ] = trim ( $tmp [ 0 ]);
unset ( $tmp [ 0 ]);
$tabRet [ 'adresse' ] = trim ( strip_tags ( implode ( ',' , $tmp )));
$tabRet [ 'tel' ] = trim ( @ getTextInHtml ( $this -> body , '<td bgcolor="#F3E5CC" class="tabligne"><b>T<> l<EFBFBD> phone<br>' , '<td bgcolor="#FFF3DE" class="tabval" valign="top">' , '<br>' ));
$tabRet [ 'fax' ] = trim ( @ getTextInHtml ( $this -> body , 'T<> l<EFBFBD> copie</b></td>' , '<br>' , '</td>' ));
$tabRet [ 'web' ] = trim ( @ getTextInHtml ( $this -> body , '><b>Adresse internet <br>' , '<a class="tabval" HREF="' , '" target="_new">' ));
$tabRet [ 'mail' ] = trim ( @ getTextInHtml ( $this -> body , '<a class="tabval" href="mailto:' , ':' , '">' ));
$bourse = trim ( @ getTextInHtml ( $this -> body , 'Ville Bourse</b></td>' , 'class="tabval">' , '</td>' ));
$tmp = explode ( '<br>' , $bourse );
$tabRet [ 'bourseIsin' ] = trim ( $tmp [ 0 ]);
$tabRet [ 'bourseMarche' ] = trim ( $tmp [ 1 ]);
$tabRet [ 'bourseVille' ] = trim ( $tmp [ 2 ]);
/*
$infosDispo = trim ( @ getTextInHtml ( $this -> body , '<b>Liste Produits</b><br></td>' , '<br></td><td class="menu3"><img src="../images/vide.gif" border="0"><br></td><td colspan="2" class="menu3">' , 'Un secteur ou une r<> gion en France</a><br></td>' ));
$tabTmp = explode ( '<a href="' , $infosDispo );
foreach ( $tabTmp as $k => $lien ) {
preg_match ( '/^(.*)">(.*)<\/a>/i' , $lien , $matches );
if ( $matches [ 2 ] <> '' ) $this -> tabInfos [ $matches [ 2 ]] = $matches [ 1 ];
if ( substr ( $matches [ 2 ], 0 , 12 ) == 'rapport <20> co.' ) $this -> infoEco = 'http://www.cofacerating.fr/portail/entreprise_identite/' . $matches [ 1 ];
elseif ( substr ( $matches [ 2 ], 0 , 6 ) == 'bilan ' ) $this -> tabBilans [] = substr ( $matches [ 2 ], 6 , strlen ( $matches [ 2 ]) - 6 );
} */
$tabRet [ 'activite' ] = trim ( str_replace ( chr ( 160 ), ' ' , html_entity_decode ( utf8_encode ( @ getTextInHtml ( $this -> body , '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne" valign="top"><b>Libell<6C> code activit<69> </b></td>' , '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval">' , '</td>' )))));
$tabRet [ 'naf' ] = trim ( @ getTextInHtml ( $this -> body , '<a href="../chaineeco_dynaeco/DynaEco.asp?cnaf=' , 'cnaf=' , '&' ));
if ( $tabRet [ 'web' ] == '' || $tabRet [ 'web' ] == 'http://' ) {
$tabRet [ 'web' ] = trim ( $this -> findSiteWeb ( $rs ));
}
if ( $tabRet [ 'web' ] == '' && $enseigne <> '' ) {
$tabRet [ 'web' ] = trim ( $this -> findSiteWeb ( $enseigne ));
}
if ( $tabRet [ 'web' ] == '' && $sigle <> '' ) {
$tabRet [ 'web' ] = trim ( $this -> findSiteWeb ( $sigle ));
}
return $tabRet ;
}
function getProColPart ( $siren , $forceVerif = false ) {
$tabRet = array ();
$tabInter = array ( 'A' => 'Administrateur' ,
'M' => 'Mandataire' ,
'H' => 'Huissier' ,
'L' => 'Liquidateur' ,
'R' => 'Repr<70> sentant des Cr<43> anciers' ,
);
/** Date la plus ancienne accept<70> e pour les jugements collect<63> s **/
$debutForclusion = date ( 'Ymd' , mktime ( 0 , 0 , 0 , date ( 'm' ) - 14 , date ( 'd' ), date ( 'Y' )));
/** Recherche des jugements enregistr<74> s en base S&D **/
$collecte = $this -> iDb -> select ( 'annonces a, tribunaux t, etablissements e' ,
'a.id, a.siren, a.typeEven, a.dateJugement, a.dateCessationPaiement, a.inter1type, a.inter1id, a.inter1nom, a.inter2type, a.inter2id, a.inter2nom, a.inter3type, a.inter3id, a.inter3nom, a.tribunal, a.complement, a.dateInsert, t.triNom, t.triSiret, t.triCP, e.raisonSociale, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, e.adr_comp, e.adr_cp, e.adr_ville' ,
" a.siren= $siren AND a.tribunal=t.triCode AND a.siren=e.siren GROUP BY e.siren, a.dateJugement ORDER BY e.siege DESC, e.actif DESC, a.dateJugement DESC " , true , MYSQL_ASSOC );
if ( count ( $collecte ) > 0 ) {
foreach ( $collecte as $ann ) {
$dept = substr ( $ann [ 'triCP' ], 0 , 2 ) * 1 ;
if ( $dept == 97 ) $dept = substr ( $ann [ 'triCP' ], 0 , 3 ) * 1 ;
$adresse = '' ;
if ( $ann [ 'adr_num' ] * 1 <> 0 ) $adresse .= ( $ann [ 'adr_num' ] * 1 ) . ' ' . strtolower ( $ann [ 'adr_btq' ]);
$adresse .= strtolower ( $ann [ 'adr_typeVoie' ]) . ' ' . ucfirst ( strtolower ( $ann [ 'adr_libVoie' ]));
if ( trim ( $ann [ 'adr_comp' ]) <> '' ) $adresse .= ', ' . $ann [ 'adr_comp' ] . ', ' ;
$adresse = preg_replace ( '/ +/' , ' ' , $adresse );
$texteAnnonce = 'Date : ' . strtolower ( WDate :: dateT ( 'Y-m-d' , 'd M Y' , $ann [ 'dateJugement' ])) . '. ' . $this -> iBodacc -> getEvenement ( $ann [ 'typeEven' ]) . '. ' .
$ann [ 'siren' ] . ' RCS ' . ucfirst ( strtolower ( strtr ( $ann [ 'triNom' ], array ( 'TGIcc ' => '' , 'TGI ' => '' , 'TC ' => '' , 'TI ' => '' ,)))) . '. ' .
trim ( $ann [ 'raisonSociale' ]) . '. Adresse : ' . $adresse . ' ' . $ann [ 'adr_cp' ] . ' ' . $ann [ 'adr_ville' ] . '. ' ;
// Nom
// Activit<69> , Adresse
if ( $ann [ 'dateCessationPaiement' ] * 1 <> 0 ) $texteAnnonce .= 'Cessation des paiements le ' . strtolower ( WDate :: dateT ( 'Y-m-d' , 'd M Y' , $ann [ 'dateCessationPaiement' ])) . '. ' ;
if ( trim ( $ann [ 'inter1type' ]) <> '' && ( $ann [ 'inter1id' ] > 0 || trim ( $ann [ 'inter1nom' ]) <> '' ) ) {
$texteAnnonce .= $tabInter [ $ann [ 'inter1type' ]] . ' : ' . $ann [ 'inter1nom' ];
if ( $ann [ 'inter1id' ] <> 0 ) {
$tabTmp = $this -> iDb -> select ( 'tabMandataires' , 'sirenGrp, sirenMand, tel, fax, email' , 'id=' . $ann [ 'inter1id' ], true , MYSQL_ASSOC );
$mand = $tabTmp [ 0 ];
if ( $mand [ 'sirenGrp' ] <> 0 ) $texteAnnonce .= ', Siren SCP ' . $mand [ 'sirenGrp' ];
if ( $mand [ 'sirenMand' ] <> 0 ) $texteAnnonce .= ', Siren ' . $mand [ 'sirenMand' ];
if ( $mand [ 'tel' ] <> '' ) $texteAnnonce .= ', Telephone ' . $mand [ 'tel' ];
if ( $mand [ 'fax' ] <> '' ) $texteAnnonce .= ', Telecopie ' . $mand [ 'fax' ];
if ( $mand [ 'email' ] <> '' ) $texteAnnonce .= ', E-mail : ' . $mand [ 'email' ];
}
$texteAnnonce .= '. ' ;
}
if ( trim ( $ann [ 'inter2type' ]) <> '' && ( $ann [ 'inter2id' ] > 0 || trim ( $ann [ 'inter2nom' ]) <> '' ) ) {
$texteAnnonce .= $tabInter [ $ann [ 'inter2type' ]] . ' : ' . $ann [ 'inter2nom' ];
if ( $ann [ 'inter2id' ] <> 0 ) {
$tabTmp = $this -> iDb -> select ( 'tabMandataires' , 'sirenGrp, sirenMand, tel, fax, email' , 'id=' . $ann [ 'inter2id' ], true , MYSQL_ASSOC );
$mand = $tabTmp [ 0 ];
if ( $mand [ 'sirenGrp' ] <> 0 ) $texteAnnonce .= ', Siren SCP ' . $mand [ 'sirenGrp' ];
if ( $mand [ 'sirenMand' ] <> 0 ) $texteAnnonce .= ', Siren ' . $mand [ 'sirenMand' ];
if ( $mand [ 'tel' ] <> '' ) $texteAnnonce .= ', Telephone ' . $mand [ 'tel' ];
if ( $mand [ 'fax' ] <> '' ) $texteAnnonce .= ', Telecopie ' . $mand [ 'fax' ];
if ( $mand [ 'email' ] <> '' ) $texteAnnonce .= ', E-mail : ' . $mand [ 'email' ];
}
$texteAnnonce .= '. ' ;
}
if ( trim ( $ann [ 'inter3type' ]) <> '' && ( $ann [ 'inter3id' ] > 0 || trim ( $ann [ 'inter3nom' ]) <> '' ) ) {
$texteAnnonce .= $tabInter [ $ann [ 'inter3type' ]] . ' : ' . $ann [ 'inter3nom' ];
if ( $ann [ 'inter3id' ] <> 0 ) {
$tabTmp = $this -> iDb -> select ( 'tabMandataires' , 'sirenGrp, sirenMand, tel, fax, email' , 'id=' . $ann [ 'inter3id' ], true , MYSQL_ASSOC );
$mand = $tabTmp [ 0 ];
if ( $mand [ 'sirenGrp' ] <> 0 ) $texteAnnonce .= ', Siren SCP ' . $mand [ 'sirenGrp' ];
if ( $mand [ 'sirenMand' ] <> 0 ) $texteAnnonce .= ', Siren ' . $mand [ 'sirenMand' ];
if ( $mand [ 'tel' ] <> '' ) $texteAnnonce .= ', Telephone ' . $mand [ 'tel' ];
if ( $mand [ 'fax' ] <> '' ) $texteAnnonce .= ', Telecopie ' . $mand [ 'fax' ];
if ( $mand [ 'email' ] <> '' ) $texteAnnonce .= ', E-mail : ' . $mand [ 'email' ];
}
$texteAnnonce .= '. ' ;
}
if ( trim ( $ann [ 'complement' ]) <> '' ) $texteAnnonce .= ' Observations : ' . trim ( $ann [ 'complement' ]) . '.' ;
/** Si la proc<6F> dure <20> moins de 4 mois on l'affiche **/
if (( str_replace ( '-' , '' , $ann [ 'dateJugement' ]) * 1 ) >= $debutForclusion )
$tabRet [] = array ( 'id' => '0.' . $ann [ 'id' ],
'BodaccCode' => 0 ,
'BodaccNum' => 0 ,
'NumAnnonce' => 0 ,
'DateParution' => $ann [ 'dateInsert' ],
'Departement' => $dept ,
'Tribunal' => $ann [ 'triNom' ],
'TribunalSiret' => $ann [ 'triSiret' ],
'Rubrique' => 'procol' ,
'typeAnnonce' => 'insertion' ,
'dateEffet' => $ann [ 'dateCessationPaiement' ],
'dateJugement' => $ann [ 'dateJugement' ],
'dateInsertionSD' => $ann [ 'dateInsert' ],
'evenements' => array ( array ( 'CodeEven' => $ann [ 'typeEven' ], 'LibEven' => $this -> iBodacc -> getEvenement ( $ann [ 'typeEven' ]))),
'texteAnnonce' => $texteAnnonce ,
);
}
} elseif ( $forceVerif ) {
/** INTEROGATION DIRECTE DES PARTENAIRES RNCS
**
** Si la demande <EFBFBD> d<EFBFBD> j<EFBFBD> <EFBFBD> t<EFBFBD> faite ce jour aupr<EFBFBD> s du partenaire , on ne la refait pas !!!
**/
$deja = $this -> iDb -> select ( 'rncs_procol' , 'count(siren)' , " siren= $siren AND dateDemande=CURDATE() " );
if ( $deja [ 0 ][ 0 ] != 0 ) return $tabRet ;
$refererP = 'http://www.score3.fr/' ;
$urlP = 'http://www.score3.fr/entreprise.shtml?siren=' . $siren ;
$page = getUrl ( $urlP , '' , '' , $refererP , false , 'www.score3.fr' , '' , 20 );
$pou = $page [ 'body' ];
$strTmp = trim ( @ getTextInHtml ( $pou , 'Proc<6F> dures collectives</td>' , '</table></td></tr><tr>' , '</td></tr></table>' ));
if ( preg_match ( '/Aucune proc.dure collective n.est enregistr/i' , $strTmp )) {
$ligne = date ( 'YmdHis' ) . " ; $siren ; " . $page [ 'code' ] . ';NO;' ;
2009-02-20 09:40:39 +00:00
$fp = fopen ( realpath ( dirname ( __FILE__ )) . '/../../../log/pouey.log' , 'a' );
2009-02-17 13:14:53 +00:00
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
return $tabRet ;
}
$tabTmp = explode ( '</tr><tr>' , $strTmp );
foreach ( $tabTmp AS $strTmp ) {
$tabTmp2 = explode ( '</td><td class="ligne2_2">' , $strTmp );
$dateJ = strip_tags ( $tabTmp2 [ 0 ]);
$libEven = strip_tags ( $tabTmp2 [ 1 ]);
if ( $libEven == 'Plan De Sauvegarde' ) $typeEven = '1101' ;
elseif ( $libEven == 'Procedure De Sauvegarde' ) $typeEven = '1100' ;
elseif ( $libEven == 'Liquidation Judiciaire' ) $typeEven = '1305' ;
elseif ( $libEven == 'Liquid.juduciaire Simplifiee' ) $typeEven = '1306' ;
elseif ( $libEven == 'Liquid.judiciaire Simplifiee' ) $typeEven = '1306' ;
elseif ( $libEven == 'Plan De Cession' ) $typeEven = '1411' ;
elseif ( $libEven == 'Redressement Judiciaire' ) $typeEven = '1200' ;
elseif ( $libEven == 'Plan De Redressement' ) $typeEven = '1414' ;
else $typeEven = '1999' ;
/* */
$refererP = 'http://www.societe.com/cgi-bin/recherche?rncs=' . $siren ;
$urlP = 'http://www.societe.com/cgi-bin/recherche?rncs=' . $siren . '&vu=4' ;
$page = getUrl ( $urlP , '' , '' , $refererP , false , 'www.societe.com' , '' , 10 );
$soc = $page [ 'body' ];
$tribunal = 'INCONU' ;
if ( preg_match ( '/<strong class="soustitre">RCS (.*) B (\d\d\d) (\d\d\d) (\d\d\d)<\/strong>/Ui' , $soc , $matches )) {
$sirenT = $matches [ 2 ] . $matches [ 3 ] . $matches [ 4 ];
if ( $sirenT <> $siren ) return array ();
$tribunal = strtoupper ( trim ( substr ( $matches [ 1 ], 0 , 5 ))) . 'C' ; // Creteil
if ( ! $this -> iBodacc -> isTribunal ( $tribunal )) {
$libTri = strtoupper ( $matches [ 1 ]); // Creteil
$tribunal = $this -> iBodacc -> getTribunalCode ( " TC $libTri " );
if ( ! $this -> iBodacc -> isTribunal ( $tribunal )) {
$tribunal = 'INCONU' ;
}
}
if ( preg_match ( '/<td width="150" height="20" align="right" valign="top">(.*) <\/td>(?:.*)<td width="250" align="left" valign="top" class="medium">(.*)<\/td>/Uis' , $soc , $matches )) {
if ( $matches [ 1 ] == 'Liquidateur' ) $inter1type = 'L' ;
else $inter1type = '' ;
$inter1nom = str_replace ( '<br>' , ', ' , $matches [ 2 ]);
}
}
$tabInsert = array ( 'siren' => $siren ,
'typeEven' => $typeEven ,
'dateJugement' => WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , $dateJ ),
'dateCessationPaiement' => 0 ,
'inter1type' => $inter1type ,
'inter1id' => '' ,
'inter1nom' => $inter1nom ,
'inter2type' => '' ,
'inter2id' => '' ,
'inter2nom' => '' ,
'inter3type' => '' ,
'inter3id' => '' ,
'inter3nom' => '' ,
'tribunal' => $tribunal ,
'pagePou' => $pou ,
'pageSoc' => $soc ,
);
$this -> iDb -> insert ( 'annonces' , $tabInsert );
$ligne = date ( 'YmdHis' ) . " ; $siren ; " . $page [ 'code' ] . " ;YES; $dateJ ; $typeEven ; $libEven " ;
2009-02-20 09:40:39 +00:00
$fp = fopen ( realpath ( dirname ( __FILE__ )) . '/../../../log/pouey.log' , 'a' );
2009-02-17 13:14:53 +00:00
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
}
if ( trim ( $tabRet [ 0 ][ 'dateJugement' ]) == '' && $typeEven == '1999' ) return array ();
/** Insertion de la notification de demande pour la journ<72> e **/
$this -> iDb -> insert ( 'rncs_procol' , array ( 'siren' => $siren , 'dateDemande' => date ( 'Ymd' )));
/** R<> cup<75> ration du jugement enregistr<74> en base S&D **/
$collecte = $this -> iDb -> select ( 'annonces a, tribunaux t, etablissements e' ,
'a.id, a.siren, a.typeEven, a.dateJugement, a.dateCessationPaiement, a.inter1type, a.inter1id, a.inter1nom, a.inter2type, a.inter2id, a.inter2nom, a.inter3type, a.inter3id, a.inter3nom, a.tribunal, a.complement, a.dateInsert, t.triNom, t.triSiret, t.triCP, e.raisonSociale, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, e.adr_comp, e.adr_cp, e.adr_ville' ,
" a.siren= $siren AND a.tribunal=t.triCode AND a.siren=e.siren GROUP BY e.siren ORDER BY e.siege DESC, e.actif DESC, a.dateJugement DESC " , true , MYSQL_ASSOC );
if ( count ( $collecte ) > 0 ) {
foreach ( $collecte as $ann ) {
$dept = substr ( $ann [ 'triCP' ], 0 , 2 ) * 1 ;
if ( $dept == 97 ) $dept = substr ( $ann [ 'triCP' ], 0 , 3 ) * 1 ;
$adresse = '' ;
if ( $ann [ 'adr_num' ] * 1 <> 0 ) $adresse .= ( $ann [ 'adr_num' ] * 1 ) . ' ' . strtolower ( $ann [ 'adr_btq' ]);
$adresse .= strtolower ( $ann [ 'adr_typeVoie' ]) . ' ' . ucfirst ( strtolower ( $ann [ 'adr_libVoie' ]));
if ( trim ( $ann [ 'adr_comp' ]) <> '' ) $adresse .= ', ' . $ann [ 'adr_comp' ] . ', ' ;
$adresse = preg_replace ( '/ +/' , ' ' , $adresse );
$texteAnnonce = 'Date : ' . strtolower ( WDate :: dateT ( 'Y-m-d' , 'd M Y' , $ann [ 'dateJugement' ])) . '. ' . $this -> iBodacc -> getEvenement ( $ann [ 'typeEven' ]) . '. ' .
$ann [ 'siren' ] . ' RCS ' . ucfirst ( strtolower ( strtr ( $ann [ 'triNom' ], array ( 'TGIcc ' => '' , 'TGI ' => '' , 'TC ' => '' , 'TI ' => '' ,)))) . '. ' .
trim ( $ann [ 'raisonSociale' ]) . '. Adresse : ' . $adresse . ' ' . $ann [ 'adr_cp' ] . ' ' . $ann [ 'adr_ville' ] . '. ' ;
// Nom
// Activit<69> , Adresse
if ( $ann [ 'dateCessationPaiement' ] * 1 <> 0 ) $texteAnnonce .= 'Cessation des paiements le ' . strtolower ( WDate :: dateT ( 'Y-m-d' , 'd M Y' , $ann [ 'dateCessationPaiement' ])) . '. ' ;
if ( trim ( $ann [ 'inter1type' ]) <> '' && ( $ann [ 'inter1id' ] > 0 || trim ( $ann [ 'inter1nom' ]) <> '' ) ) {
$texteAnnonce .= $tabInter [ $ann [ 'inter1type' ]] . ' : ' . $ann [ 'inter1nom' ];
if ( $ann [ 'inter1id' ] <> 0 ) {
$tabTmp = $this -> iDb -> select ( 'tabMandataires' , 'sirenGrp, sirenMand, tel, fax, email' , 'id=' . $ann [ 'inter1id' ], true , MYSQL_ASSOC );
$mand = $tabTmp [ 0 ];
if ( $mand [ 'sirenGrp' ] <> 0 ) $texteAnnonce .= ', Siren SCP ' . $mand [ 'sirenGrp' ];
if ( $mand [ 'sirenMand' ] <> 0 ) $texteAnnonce .= ', Siren ' . $mand [ 'sirenMand' ];
if ( $mand [ 'tel' ] <> '' ) $texteAnnonce .= ', Telephone ' . $mand [ 'tel' ];
if ( $mand [ 'fax' ] <> '' ) $texteAnnonce .= ', Telecopie ' . $mand [ 'fax' ];
if ( $mand [ 'email' ] <> '' ) $texteAnnonce .= ', E-mail : ' . $mand [ 'email' ];
}
$texteAnnonce .= '. ' ;
}
if ( trim ( $ann [ 'inter2type' ]) <> '' && ( $ann [ 'inter2id' ] > 0 || trim ( $ann [ 'inter2nom' ]) <> '' ) ) {
$texteAnnonce .= $tabInter [ $ann [ 'inter2type' ]] . ' : ' . $ann [ 'inter2nom' ];
if ( $ann [ 'inter2id' ] <> 0 ) {
$tabTmp = $this -> iDb -> select ( 'tabMandataires' , 'sirenGrp, sirenMand, tel, fax, email' , 'id=' . $ann [ 'inter2id' ], true , MYSQL_ASSOC );
$mand = $tabTmp [ 0 ];
if ( $mand [ 'sirenGrp' ] <> 0 ) $texteAnnonce .= ', Siren SCP ' . $mand [ 'sirenGrp' ];
if ( $mand [ 'sirenMand' ] <> 0 ) $texteAnnonce .= ', Siren ' . $mand [ 'sirenMand' ];
if ( $mand [ 'tel' ] <> '' ) $texteAnnonce .= ', Telephone ' . $mand [ 'tel' ];
if ( $mand [ 'fax' ] <> '' ) $texteAnnonce .= ', Telecopie ' . $mand [ 'fax' ];
if ( $mand [ 'email' ] <> '' ) $texteAnnonce .= ', E-mail : ' . $mand [ 'email' ];
}
$texteAnnonce .= '. ' ;
}
if ( trim ( $ann [ 'inter3type' ]) <> '' && ( $ann [ 'inter3id' ] > 0 || trim ( $ann [ 'inter3nom' ]) <> '' ) ) {
$texteAnnonce .= $tabInter [ $ann [ 'inter3type' ]] . ' : ' . $ann [ 'inter3nom' ];
if ( $ann [ 'inter3id' ] <> 0 ) {
$tabTmp = $this -> iDb -> select ( 'tabMandataires' , 'sirenGrp, sirenMand, tel, fax, email' , 'id=' . $ann [ 'inter3id' ], true , MYSQL_ASSOC );
$mand = $tabTmp [ 0 ];
if ( $mand [ 'sirenGrp' ] <> 0 ) $texteAnnonce .= ', Siren SCP ' . $mand [ 'sirenGrp' ];
if ( $mand [ 'sirenMand' ] <> 0 ) $texteAnnonce .= ', Siren ' . $mand [ 'sirenMand' ];
if ( $mand [ 'tel' ] <> '' ) $texteAnnonce .= ', Telephone ' . $mand [ 'tel' ];
if ( $mand [ 'fax' ] <> '' ) $texteAnnonce .= ', Telecopie ' . $mand [ 'fax' ];
if ( $mand [ 'email' ] <> '' ) $texteAnnonce .= ', E-mail : ' . $mand [ 'email' ];
}
$texteAnnonce .= '. ' ;
}
if ( trim ( $ann [ 'complement' ]) <> '' ) $texteAnnonce .= ' Observations : ' . trim ( $ann [ 'complement' ]) . '.' ;
/** Si la proc<6F> dure <20> moins de 4 mois on l'affiche **/
if (( str_replace ( '-' , '' , $ann [ 'dateJugement' ]) * 1 ) >= $debutForclusion )
$tabRet [] = array ( 'id' => '0.' . $ann [ 'id' ],
'BodaccCode' => 0 ,
'BodaccNum' => 0 ,
'NumAnnonce' => 0 ,
'DateParution' => $ann [ 'dateInsert' ],
'Departement' => $dept ,
'Tribunal' => $ann [ 'triNom' ],
'TribunalSiret' => $ann [ 'triSiret' ],
'Rubrique' => 'procol' ,
'typeAnnonce' => 'insertion' ,
'dateEffet' => $ann [ 'dateCessationPaiement' ],
'dateJugement' => $ann [ 'dateJugement' ],
'dateInsertionSD' => $ann [ 'dateInsert' ],
'evenements' => array ( array ( 'CodeEven' => $ann [ 'typeEven' ], 'LibEven' => $this -> iBodacc -> getEvenement ( $ann [ 'typeEven' ]))),
'texteAnnonce' => $texteAnnonce ,
);
}
}
}
return $tabRet ;
}
function listeConventions ( $naf4 , $dep = 0 ) {
$dep = $dep * 1 ;
if ( $dep > 0 ) {
if ( $dep < 10 ) $dep = 'Dep0' . $dep ;
else $dep = 'Dep' . $dep ;
$strDep = " AND (n.territoire='' OR n.territoire LIKE '% $dep %') " ;
}
$listeCC = $this -> iDb -> select ( 'conv_naf n, conventions c' ,
'n.`id CC`, n.`nom CC`, n.`editeur CC`, n.`nb page CC`, n.`isbn CC`, n.`date edition CC`, c.infoCC, joCCmaj' ,
" n.naf=' $naf4 ' AND substring(n.`id CC`,1,4)=c.numBrochure $strDep GROUP BY n.`id CC` " , false , MYSQL_ASSOC );
return $listeCC ;
}
/* $tabRet [ 'nbEtab' ] = trim ( strip_tags ( str_replace ( 'afficher la liste...' , '' , @ getTextInHtml ( $pou , '<tr><td class="ligne1_2">Etablissements' , '<td class="ligne2_2">' , '</td></tr>' ))));
/* $urlPEtab = 'http://www.score3.fr/etablissements.shtml?page=1&siren=' . $siren ;
$refererPEtab = $urlP ;
}
$tabRet [ 'effectif' ] = trim ( @ getTextInHtml ( $pou , '<tr><td class="ligne1_2">Effectifs</td>' , '<td class="ligne2_2">' , '</td></tr>' ));
$strTmp = trim ( str_replace ( '/' , '' , @ getTextInHtml ( $pou , '<tr><td class="ligne1_2">Date d\'immatriculation</td>' , '<td class="ligne2_2">' , '</td></tr>' )));
if ( strlen ( $strTmp ) == 4 )
$strTmp = '0101' . $strTmp ;
elseif ( strlen ( $strTmp ) == 6 )
$strTmp = '01' . $strTmp ;
$tabRet [ 'dateCreation' ] = WDate :: dateT ( 'dmY' , 'Y-m-d' , $strTmp );
$strTmp = trim ( str_replace ( '/' , '' , @ getTextInHtml ( $pou , '<tr><td class="ligne1_2">Date de fin d\'exploitation</td>' , '<td class="ligne2_2">' , '</td></tr>' )));
if ( strlen ( $strTmp ) == 4 )
$strTmp = '0101' . $strTmp ;
elseif ( strlen ( $strTmp ) == 6 )
$strTmp = '01' . $strTmp ;
$tabRet [ 'dateFermeture' ] = WDate :: dateT ( 'dmY' , 'Y-m-d' , $strTmp );
if ( $tabRet [ 'tel' ] == '' || $tabRet [ 'tel' ] == '0' )
$tabRet [ 'tel' ] = trim ( @ getTextInHtml ( $pou , '<tr><td class="ligne1_2">T<> l<EFBFBD> phone</td>' , '<td class="ligne2_2">' , '</td></tr>' ));
if ( $tabRet [ 'fax' ] == '' || $tabRet [ 'fax' ] == '0' )
$tabRet [ 'fax' ] = trim ( @ getTextInHtml ( $pou , '<tr><td class="ligne1_2">Fax</td>' , '<td class="ligne2_2">' , '</td></tr>' ));
$strTmp = trim ( @ getTextInHtml ( $pou , '<tr><td class="ligne1_2">Activit<69> principale</td>' , '<td class="ligne2_2">' , '</td></tr>' ));
$tabRet [ 'naf_lib' ] = trim ( strtr ( substr ( $strTmp , 0 , strlen ( $strTmp ) - 6 ), '()' , ' ' ));
if ( $tabRet [ 'naf' ] == '' )
$tabRet [ 'naf' ] = trim ( strtr ( substr ( $strTmp , - 6 ), '()' , ' ' ));
$strTmp = trim ( @ getTextInHtml ( $pou , '<tr><td class="ligne1_2">Chiffre d\'affaires</td>' , '<td class="ligne2_2">' , '</td></tr>' ));
$tabRet [ 'ca' ] = $strTmp ;
$tabRet [ 'score_pouey' ] = trim ( @ getTextInHtml ( $pou , '<param name="movie" value="cadran.swf?rotation=' , '&type=pouey&valeur=' , '">' ));
$tabRet [ 'score_conan' ] = trim ( @ getTextInHtml ( $pou , '<param name="movie" value="cadran.swf?rotation=' , '&type=ch&valeur=' , '">' ));
$tabRet [ 'score_afdcc' ] = trim ( @ getTextInHtml ( $pou , '<param name="movie" value="cadran.swf?rotation=' , '&type=afdcc&valeur=' , '">' ));
$tabRet [ 'vigilance' ] = trim ( @ getTextInHtml ( $pou , '<param name="movie" value="vigilance.swf' , 'degre=' , '">' ));
return $tabRet ;
}
*/
private function findSiteWeb ( $rs )
{
$referer = 'http://www.google.fr/' ;
$url = 'http://www.google.fr/search?hl=fr&q=' . urlencode ( $rs ) . '&btnG=Rechercher&meta=cr%3DcountryFR' ;
$page = getUrl ( $url , '' , '' , $referer , false , 'www.google.fr' , '' , 5 );
$fp = fopen ( './findSiteWeb.log' , 'a+' );
if ( $page [ 'code' ] == 200 ) {
$levMin = 100 ;
$pctMin = 0 ;
$urlLev = $urlPct = '' ;
$body = $page [ 'body' ];
preg_match_all ( '/<a href="(.*)"/iU' , $body , $matches );
$urlapprox = " http:// $rs . " ;
foreach ( $matches [ 1 ] as $i => $url )
{
$lev =@ levenshtein ( $urlapprox , $url );
if ( $lev > 0 && $lev < $levMin ) {
$levMin = $lev ;
$urlLev = $url ;
}
$sim = similar_text ( $urlapprox , $url , $pct );
if ( $pct > $pctMin && strpos ( $url , 'zonebourse' ) === false ) {
$pctMin = $pct ;
$urlPct = $url ;
}
fwrite ( $fp , date ( 'Y-m-d H:i:s' ) . ' - ' . $page [ 'code' ] . " - $rs - $i - $lev - $pct - $urlLev - $urlPct - $url\n " );
//2008-05-20 20:01:08 - 200- ARKEMA FRANCE - 53 - 20 - 10 - http://www.arkema.fr/ - http://www.zonebourse.com/ARKEMA-17031/ - /intl/fr/about.html
}
fclose ( $fp );
if ( $pctMin > 70 && $levMin < 13 & $urlLev == $urlPct )
return $urlLev ;
return false ;
}
fclose ( $fp );
return false ;
}
}
?>