2010-11-04 11:05:01 +00:00
< ? php
set_time_limit ( 90 );
ini_set ( 'soap.wsdl_cache_enabled' , 0 );
include_once ( INCLUDE_PATH . 'insee/classMInsee.php' );
include_once ( INCLUDE_PATH . 'insee/classMSirene.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMBilans.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMBourse.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMLiens.php' );
include_once ( INCLUDE_PATH . 'scores/classMFinancier.php' );
include_once ( INCLUDE_PATH . 'scores/classMSolvabilite.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMTva.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMMap.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMGreffes.php' );
include_once ( INCLUDE_PATH . 'partenaires/classMPrivileges.php' );
include_once ( INCLUDE_PATH . 'tmp/configMRatios.php' );
include_once ( FWK_PATH . 'mail/sendMail.php' );
class WsEntreprise {
var $iInsee ;
/** Constructeur de la classe
** @ nodoc
**/
function __construct (){
$this -> iInsee = new MInsee ();
}
/** Obtention automatique d ' un nouveau login pour un client
** @ nodoc
**/
function getNextLogin ( $login ) {
global $iDbCrm ;
global $tabInfoUser ;
if ( $tabInfoUser [ 'profil' ] == 'Administrateur' || $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) {
/** Un administrateur veut cr<63> er un nouveau login **/
$rep = $iDbCrm -> select ( 'utilisateurs u, clients c' , 'u.idClient, c.racineLogin, c.droits' , " u.login=' $login ' AND u.idClient=c.id " );
$racine = $rep [ 0 ][ 'racineLogin' ];
$idClient = $rep [ 0 ][ 'idClient' ];
$droitsClients = $rep [ 0 ][ 'droits' ];
$rep = $iDbCrm -> select ( 'utilisateurs' , 'login, length(login) as taille' , " login like ' $racine %' group by login order by taille desc, login desc LIMIT 0,1 " );
if ( count ( $rep ) == 0 ) $racine .= '1' ;
else {
$last_i = preg_replace ( " / \ D/ " , '' , $rep [ 0 ][ 'login' ]) * 1 ;
$racine .= $last_i + 1 ;
}
return array ( 'error' => array ( 'errnum' => $errnum , 'errmsg' => $errmsg ), 'result' => array ( 'racine' => $racine , 'idClient' => $idClient , 'droitsClients' => $droitsClients ));
}
}
/** R<EFBFBD> cup<EFBFBD> re les informations du profil connect<EFBFBD>
** @ nodoc
**/
function getInfosLogin ( $login , $ipUtilisateur ) {
global $iDbCrm ;
global $tabInfoUser ;
debugLog ( 'I' , " getInfosLogin pour $login (IP= $ipUtilisateur ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( $tabInfoUser [ 'login' ] <> $login && ( $tabInfoUser [ 'profil' ] == 'Administrateur' || $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) ) {
//debugLog('I',"getInfosLogin - Un administrateur veut il des infos sur un login",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
/** Un administrateur veut il des infos sur un login ? **/
$rep = $iDbCrm -> select (
'utilisateurs u, clients c' ,
'u.login, u.id, u.email, u.password, u.idClient, u.typeCompte, u.actif, u.filtre_ip, u.civilite, u.nom, u.prenom, u.tel, u.fax, u.mobile, u.profil, u.raisonSociale, u.siret, u.adrNum, u.adrIndRep, u.adrTypeVoie, u.adrLibVoie, u.adrCp, u.adrVille, u.adrComp, u.tel, u.fax, u.mobile, u.pref, u.profil, u.dateInscription, u.dateValidation, u.nombreConnexions, u.dateDerniereConnexion, u.droits, u.referenceParDefaut, u.nbReponses, u.formatMail, u.dateDebutCompte, u.dateFinCompte, u.maxFicheId, c.droits AS droitsClients, c.timeout' ,
" u.login=' $login ' AND u.idClient=c.id AND u.deleted=0 " ,
true , MYSQL_ASSOC );
$tabRep = $rep [ 0 ];
if ( count ( $rep ) > 0 ) {
$timeOutSec = $tabRep [ 'timeout' ] * 60 ;
if ( $timeOutSec == 0 ) $timeOutSec = 1800 ;
$rep = array ( 'login' => $login ,
'id' => $tabRep [ 'id' ],
'email' => $tabRep [ 'email' ],
'typeCompte' => $tabRep [ 'typeCompte' ],
'idClient' => $tabRep [ 'idClient' ],
'filtre_ip' => $tabRep [ 'filtre_ip' ],
'civilite' => $tabRep [ 'civilite' ],
'nom' => prepareString ( $tabRep [ 'nom' ]),
'prenom' => prepareString ( $tabRep [ 'prenom' ]),
'raisonSociale' => prepareString ( $tabRep [ 'raisonSociale' ]),
'siret' => $tabRep [ 'siret' ],
'adrNum' => $tabRep [ 'adrNum' ],
'adrIndRep' => $tabRep [ 'adrIndRep' ],
'adrTypeVoie' => $tabRep [ 'adrTypeVoie' ],
'adrLibVoie' => prepareString ( $tabRep [ 'adrLibVoie' ]),
'adrCp' => $tabRep [ 'adrCp' ],
'adrVille' => prepareString ( $tabRep [ 'adrVille' ]),
'adrComp' => prepareString ( $tabRep [ 'adrComp' ]),
'tel' => $tabRep [ 'tel' ],
'fax' => $tabRep [ 'fax' ],
'mobile' => $tabRep [ 'mobile' ],
'pref' => $tabRep [ 'pref' ],
'profil' => prepareString ( $tabRep [ 'profil' ]),
'dateInscription' => $tabRep [ 'dateInscription' ],
'dateValidation' => $tabRep [ 'dateValidation' ],
'nombreConnexions' => $tabRep [ 'nombreConnexions' ],
'dateDerniereConnexion' => $tabRep [ 'dateDerniereConnexion' ],
'droits' => $tabRep [ 'droits' ],
'droitsClients' => $tabRep [ 'droitsClients' ],
'timeout' => $timeOutSec ,
'nbReponses' => $tabRep [ 'nbReponses' ],
'formatMail' => $tabRep [ 'formatMail' ],
2010-11-29 14:17:26 +00:00
'reference' => prepareString ( $tabRep [ 'referenceParDefaut' ]),
2010-11-04 11:05:01 +00:00
'dateDebutCompte' => $tabRep [ 'dateDebutCompte' ],
'dateFinCompte' => $tabRep [ 'dateFinCompte' ],
'maxFicheId' => $tabRep [ 'maxFicheId' ],
);
$tabTmp = $iDbCrm -> select ( 'clients' , 'typeScore' , 'id=' . $tabRep [ 'idClient' ], true , MYSQL_ASSOC );
$tabRep = $tabTmp [ 0 ];
$rep [ 'typeScore' ] = $tabRep [ 'typeScore' ];
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug", print_r($tabMots,true).EOL.$motSignificatif.' trouv<75> en position '.$posMin) ;
}
return array ( 'error' => array ( 'errnum' => $errnum , 'errmsg' => $errmsg ), 'result' => $rep );
}
$connected = true ;
if ( trim ( $tabInfoUser [ 'filtre_ip' ]) <> '' ) {
//debugLog('I',"getInfosLogin test filtre IP",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$connected = checkPlagesIp ( $tabInfoUser [ 'filtre_ip' ], $ipUtilisateur );
if ( ! $connected ) {
debugLog ( 'I' , " getInfosLogin Adresse IP $ipUtilisateur non declaree pour le compte $login " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$errnum = 10818 ;
$errmsg = " Adresse IP $ipUtilisateur non declaree pour ce compte. Contactez votre administrateur ! " ;
}
}
$rep = array ( 'connected' => $connected ,
'login' => $tabInfoUser [ 'login' ],
'id' => $tabInfoUser [ 'id' ],
'idClient' => $tabInfoUser [ 'idClient' ],
'email' => $tabInfoUser [ 'email' ],
'typeCompte' => $tabInfoUser [ 'typeCompte' ],
'filtre_ip' => $tabInfoUser [ 'filtre_ip' ],
'ipPasserelle' => $tabInfoUser [ 'ipConnexion' ],
'ipConnexion' => $ipUtilisateur ,
'civilite' => $tabInfoUser [ 'civilite' ],
'nom' => prepareString ( $tabInfoUser [ 'nom' ]),
'prenom' => prepareString ( $tabInfoUser [ 'prenom' ]),
'raisonSociale' => prepareString ( $tabInfoUser [ 'raisonSociale' ]),
'siret' => $tabInfoUser [ 'siret' ],
'adrNum' => $tabInfoUser [ 'adrNum' ],
'adrIndRep' => $tabInfoUser [ 'adrIndRep' ],
'adrTypeVoie' => $tabInfoUser [ 'adrTypeVoie' ],
'adrLibVoie' => prepareString ( $tabInfoUser [ 'adrLibVoie' ]),
'adrCp' => $tabInfoUser [ 'adrCp' ],
'adrVille' => prepareString ( $tabInfoUser [ 'adrVille' ]),
'adrComp' => prepareString ( $tabInfoUser [ 'adrComp' ]),
'tel' => $tabInfoUser [ 'tel' ],
'fax' => $tabInfoUser [ 'fax' ],
'mobile' => $tabInfoUser [ 'mobile' ],
'pref' => $tabInfoUser [ 'pref' ],
'profil' => prepareString ( $tabInfoUser [ 'profil' ]),
'dateInscription' => $tabInfoUser [ 'dateInscription' ],
'dateValidation' => $tabInfoUser [ 'dateValidation' ],
'nombreConnexions' => $tabInfoUser [ 'nombreConnexions' ],
'dateDerniereConnexion' => $tabInfoUser [ 'dateDerniereConnexion' ],
'droits' => $tabInfoUser [ 'droits' ],
'droitsClients' => $tabInfoUser [ 'droitsClients' ],
'timeout' => $tabInfoUser [ 'timeout' ],
'nbReponses' => $tabInfoUser [ 'nbReponses' ],
'formatMail' => $tabInfoUser [ 'formatMail' ],
2010-11-29 14:17:26 +00:00
'reference' => prepareString ( $tabInfoUser [ 'referenceParDefaut' ]),
2010-11-04 11:05:01 +00:00
'dateDebutCompte' => $tabInfoUser [ 'dateDebutCompte' ],
'dateFinCompte' => $tabInfoUser [ 'dateFinCompte' ],
'maxFicheId' => $tabInfoUser [ 'maxFicheId' ],
'typeScore' => $tabInfoUser [ 'typeScore' ],
);
//debugLog('I',"getInfosLogin fin ".print_r($rep,true),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
return array ( 'error' => array ( 'errnum' => $errnum , 'errmsg' => $errmsg ), 'result' => $rep );
}
/** R<EFBFBD> cup<EFBFBD> re les informations du profil connect<EFBFBD>
** @ nodoc
**/
function getListeUtilisateurs ( $login , $idClient =- 1 ) {
global $iDbCrm ;
global $tabInfoUser ;
if ( $tabInfoUser [ 'profil' ] <> 'Administrateur' && $tabInfoUser [ 'profil' ] <> 'SuperAdministrateur' )
return array ( 'error' => array ( 'errnum' => 987684351 , 'errmsg' => 'Profil non administrateur' ), 'result' => array ());
$rep = $iDbCrm -> select ( 'utilisateurs' , 'idClient' , " login=' $login ' " );
$idClient = $rep [ 0 ][ 0 ];
if ( $idClient ==- 1 )
return array ( 'error' => array ( 'errnum' => 98684351 , 'errmsg' => 'idClient=0' ), 'result' => $rep );
$rep = $iDbCrm -> select ( 'utilisateurs' , 'id, idClient, login, email, actif, nom, prenom, referenceParDefaut' , " idClient=' $idClient ' AND deleted=0 ORDER BY login ASC " , true , MYSQL_ASSOC );
$tabRet = array ();
foreach ( $rep as $uti )
$tabRet [] = array ( 'idUti' => $uti [ 'id' ],
'idClient' => $uti [ 'idClient' ],
'login' => $uti [ 'login' ],
'email' => $uti [ 'email' ],
'actif' => $uti [ 'actif' ],
'nom' => prepareString ( $uti [ 'nom' ]),
'prenom' => prepareString ( $uti [ 'prenom' ]),
'reference' => prepareString ( $uti [ 'referenceParDefaut' ]),
);
return array ( 'error' => array ( 'errnum' => $errnum , 'errmsg' => $errmsg ), 'results' => $tabRet );
}
/** R<EFBFBD> cup<EFBFBD> re la liste des clients ou les informations d ' un client
** @ nodoc
**/
function getListeClients ( $idClient = 0 ) {
global $iDbCrm ;
global $tabInfoUser ;
$idClient = $idClient * 1 ;
if ( $tabInfoUser [ 'profil' ] == 'Administrateur' && ( $idClient == 0 || $idClient == $tabInfoUser [ 'idClient' ]))
$idClient = $tabInfoUser [ 'idClient' ];
elseif ( $tabInfoUser [ 'profil' ] <> 'SuperAdministrateur' )
return array ( 'error' => array ( 'errnum' => 987684351 , 'errmsg' => 'Profil non administrateur' ), 'result' => array ());
$strClient = '' ;
if ( $idClient > 0 )
$strClient .= " AND id=' $idClient ' " ;
$rep = $iDbCrm -> select ( 'clients' , 'id, nom, actif, test, racineLogin, siren, nic, tva, editerFacture, fact_detail, fac_dest, fac_adr1, fac_adr2, fac_adr3, fac_email, fac_tel, fact_rib, liv_dest, liv_adr1, liv_adr2, liv_adr3, liv_email, liv_tel, droits, filtres_ip, dateInsert, dateUpdate, respComSD, typeContrat, dateSignature, typeAcces, typeScore, accesPieces, accesKbis, accesInvestigations, accesInternationnal, accesEnquetes, miseSousSurveillance, forfaitExtranetPeriode, forfaitExtranetMontant, reconductionAuto, remarque, forfaitPiecesNb, forfaitPiecesMt, forfaitPiecesDep, forfaitInvestigNb, forfaitInvestigMt, forfaitInvestigDep, tarifIndiscore' , " 1 $strClient " , true , MYSQL_ASSOC );
$tabRet = array ();
foreach ( $rep as $uti )
$tabRet [] = array ( 'idClient' => $uti [ 'id' ],
'nom' => prepareString ( $uti [ 'nom' ]),
'actif' => $uti [ 'actif' ],
'test' => $uti [ 'test' ],
'racineLogin' => $uti [ 'racineLogin' ],
'siren' => $uti [ 'siren' ],
'nic' => $uti [ 'nic' ],
'tva' => $uti [ 'tva' ],
'editerFacture' => $uti [ 'editerFacture' ],
'fact_detail' => $uti [ 'fact_detail' ],
'fac_dest' => prepareString ( $uti [ 'fac_dest' ]),
'fac_adr1' => prepareString ( $uti [ 'fac_adr1' ]),
'fac_adr2' => prepareString ( $uti [ 'fac_adr2' ]),
'fac_adr3' => prepareString ( $uti [ 'fac_adr3' ]),
'fac_email' => prepareString ( $uti [ 'fac_email' ]),
'fac_tel' => prepareString ( $uti [ 'fac_tel' ]),
'fact_rib' => $uti [ 'fact_rib' ],
'liv_dest' => prepareString ( $uti [ 'liv_dest' ]),
'liv_adr1' => prepareString ( $uti [ 'liv_adr1' ]),
'liv_adr2' => prepareString ( $uti [ 'liv_adr2' ]),
'liv_adr3' => prepareString ( $uti [ 'liv_adr3' ]),
'liv_email' => prepareString ( $uti [ 'liv_email' ]),
'liv_tel' => prepareString ( $uti [ 'liv_tel' ]),
'droits' => $uti [ 'droits' ],
'timeout' => $uti [ 'timeout' ],
'filtres_ip' => $uti [ 'filtres_ip' ],
'dateInsert' => $uti [ 'dateInsert' ],
'dateUpdate' => $uti [ 'dateUpdate' ],
'respComSD' => $uti [ 'respComSD' ],
'typeContrat' => prepareString ( $uti [ 'typeContrat' ]),
'dateSignature' => $uti [ 'dateSignature' ],
'typeAcces' => $uti [ 'typeAcces' ],
'typeScore' => $uti [ 'typeScore' ],
'accesPieces' => $uti [ 'accesPieces' ],
'accesKbis' => $uti [ 'accesKbis' ],
'accesInvestigations' => $uti [ 'accesInvestigations' ],
'accesInternationnal' => $uti [ 'accesInternationnal' ],
'accesEnquetes' => $uti [ 'accesEnquetes' ],
'miseSousSurveillance' => $uti [ 'miseSousSurveillance' ],
'forfaitExtranetPeriode' => $uti [ 'forfaitExtranetPeriode' ],
'forfaitExtranetMontant' => $uti [ 'forfaitExtranetMontant' ],
'reconductionAuto' => $uti [ 'reconductionAuto' ],
'remarque' => prepareString ( $uti [ 'remarque' ]),
'forfaitPiecesNb' => $uti [ 'forfaitPiecesNb' ],
'forfaitPiecesMt' => $uti [ 'forfaitPiecesMt' ],
'forfaitPiecesDep' => $uti [ 'forfaitPiecesDep' ],
'forfaitInvestigNb' => $uti [ 'forfaitInvestigNb' ],
'forfaitInvestigMt' => $uti [ 'forfaitInvestigMt' ],
'forfaitInvestigDep' => $uti [ 'forfaitInvestigDep' ],
'tarifIndiscore' => $uti [ 'tarifIndiscore' ],
);
return array ( 'error' => array ( 'errnum' => $errnum , 'errmsg' => $errmsg ), 'results' => $tabRet );
}
/** Mise <EFBFBD> jour des informations du profil connect<EFBFBD>
** @ nodoc
**/
function setInfosLogin ( $login , $tabInfoUserWS ) {
global $iDbCrm ;
global $tabInfoUser ;
if ( $tabInfoUserWS [ 'delete' ] == 1 && ( $tabInfoUser [ 'profil' ] == 'Administrateur' || $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) )
$tabUpdate = array ( 'deleted' => 1 );
elseif ( isset ( $tabInfoUserWS [ 'actif' ]) && $tabInfoUserWS [ 'actif' ] == 0 && ( $tabInfoUser [ 'profil' ] == 'Administrateur' || $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) )
$tabUpdate = array ( 'actif' => 0 );
elseif ( isset ( $tabInfoUserWS [ 'actif' ]) && $tabInfoUserWS [ 'actif' ] == 1 && ( $tabInfoUser [ 'profil' ] == 'Administrateur' || $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) )
$tabUpdate = array ( 'actif' => 1 );
else {
$strPrefs =@ implode ( ' ' , $tabInfoUserWS [ 'pref' ]);
$strDroits =@ implode ( ' ' , $tabInfoUserWS [ 'droits' ]);
$tabUpdate = array ();
if ( isset ( $tabInfoUserWS [ 'email' ])) $tabUpdate [ 'email' ] = stripslashes ( $tabInfoUserWS [ 'email' ]);
if ( isset ( $tabInfoUserWS [ 'tel_fix' ])) $tabUpdate [ 'tel' ] = stripslashes ( $tabInfoUserWS [ 'tel_fix' ]);
if ( isset ( $tabInfoUserWS [ 'tel_fax' ])) $tabUpdate [ 'fax' ] = stripslashes ( $tabInfoUserWS [ 'tel_fax' ]);
if ( isset ( $tabInfoUserWS [ 'tel_mob' ])) $tabUpdate [ 'mobile' ] = stripslashes ( $tabInfoUserWS [ 'tel_mob' ]);
if ( isset ( $tabInfoUserWS [ 'rech_nbrep' ])) $tabUpdate [ 'nbReponses' ] = $tabInfoUserWS [ 'rech_nbrep' ];
if ( isset ( $tabInfoUserWS [ 'formatMail' ])) $tabUpdate [ 'formatMail' ] = $tabInfoUserWS [ 'formatMail' ];
if ( isset ( $tabInfoUserWS [ 'pref' ])) $tabUpdate [ 'pref' ] = $strPrefs ;
if ( isset ( $tabInfoUserWS [ 'changepwd' ]) && $tabInfoUserWS [ 'changepwd' ] == 1 &&
isset ( $tabInfoUserWS [ 'password' ]) && trim ( $tabInfoUserWS [ 'password' ]) <> '' )
$tabUpdate [ 'password' ] = stripslashes ( $tabInfoUserWS [ 'password' ]);
if ( $tabInfoUser [ 'profil' ] == 'Administrateur' || $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) {
$tabUpdate [ 'droits' ] = $strDroits ;
if ( isset ( $tabInfoUserWS [ 'nom' ])) $tabUpdate [ 'nom' ] = stripslashes ( $tabInfoUserWS [ 'nom' ]);
if ( isset ( $tabInfoUserWS [ 'prenom' ])) $tabUpdate [ 'prenom' ] = stripslashes ( $tabInfoUserWS [ 'prenom' ]);
if ( isset ( $tabInfoUserWS [ 'reference' ])) $tabUpdate [ 'referenceParDefaut' ] = stripslashes ( $tabInfoUserWS [ 'reference' ]);
}
}
if ( $tabInfoUserWS [ 'action' ] == 'new' ) {
$tabUpdate [ 'login' ] = $login ;
$tabUpdate [ 'idClient' ] = $tabInfoUserWS [ 'idClient' ];
if ( $iDbCrm -> insert ( 'utilisateurs' , $tabUpdate ))
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
else
return array ( 'error' => array ( 'errnum' => 76841 , 'errmsg' => 'Cr<43> ation impossible' ), 'result' => 0 );
}
if ( $iDbCrm -> update ( 'utilisateurs' , $tabUpdate , " login=' $login ' " ))
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
else
return array ( 'error' => array ( 'errnum' => 76840 , 'errmsg' => 'Mise a jour impossible' ), 'result' => 0 );
/*
[ rech_limites ] => Array
(
[ 0 ] => assocs
[ 1 ] => actifs
[ 2 ] => radies
[ 3 ] => sieges
)
'typeCompte' => $tabRep [ 'typeCompte' ],
'filtre_ip' => $tabRep [ 'filtre_ip' ],
'civilite' => $tabRep [ 'civilite' ],
'raisonSociale' => $tabRep [ 'raisonSociale' ],
'siret' => $tabRep [ 'siret' ],
'adrNum' => $tabRep [ 'adrNum' ],
'adrIndRep' => $tabRep [ 'adrIndRep' ],
'adrTypeVoie' => $tabRep [ 'adrTypeVoie' ],
'adrLibVoie' => $tabRep [ 'adrLibVoie' ],
'adrCp' => $tabRep [ 'adrCp' ],
'adrVille' => $tabRep [ 'adrVille' ],
'adrComp' => $tabRep [ 'adrComp' ],
'profil' => $tabRep [ 'profil' ],
'dateInscription' => $tabRep [ 'dateInscription' ],
'dateValidation' => $tabRep [ 'dateValidation' ],
'nombreConnexions' => $tabRep [ 'nombreConnexions' ],
'dateDerniereConnexion' => $tabRep [ 'dateDerniereConnexion' ],
'droits' => $tabRep [ 'droits' ],
'referenceParDefaut' => $tabRep [ 'referenceParDefaut' ],
'dateDebutCompte' => $tabRep [ 'dateDebutCompte' ],
'dateFinCompte' => $tabRep [ 'dateFinCompte' ],
'maxFicheId' => $tabRep [ 'maxFicheId' ],
*/
}
/** Recherche d 'une entreprise ou d' un <EFBFBD> tablissement par sa raison sociale , son enseigne , son sigle , son adresse .
**
** @ param string $raisonSociale Raison Sociale ou Enseigne ou Sigle
** @ param string $adresse Adresse de l ' entreprise , du type : 3 rue des Plantes
** @ param string $codePostal Code postal ( ex : 75014 )
** @ param string $ville Ville
** @ param bool $siege Limitation de la recherche au si<EFBFBD> ges ( si true )
** @ param bool $actif Limitation aux <EFBFBD> tablissements actifs ( si true )
** @ param integer $deb Position du curseur dans la liste des r<EFBFBD> ponses ( 0 par d<EFBFBD> faut )
** @ param integer $nbRep Nombre de r<EFBFBD> ponses retourn<EFBFBD> es au maximum par cette requete ( 20 par d<EFBFBD> faut )
** @ param integer $maxRep Nombre de r<EFBFBD> ponses recherch<EFBFBD> es au maximum ( 200 par d<EFBFBD> faut )
** @ param bool $pertinence Recherche orthographique stricte sur le nom , l ' adresse et la ville ( si true )
** @ param bool $avecSiren Ne proposer que les entit<EFBFBD> s sir<EFBFBD> n<EFBFBD> es
** @ return Tableau d 'entreprises ou d' <EFBFBD> tablissements
**/
function searchNomAdr ( $raisonSociale , $adresse = '' , $codePostal = '' , $ville = '' , $siege = '' , $actif = '' , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false , $avecSiren = false , $ape_etab = '' ) {
debugLog ( 'I' , " Recherche Entreprise de $raisonSociale , $adresse , $codePostal $ville (Si<53> ge= $siege / Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$etabs = $this -> iInsee -> rechercheEtab ( $raisonSociale , $adresse , $codePostal , $ville , $siege , $actif , $deb , $nbRep , $maxRep , $pertinence , $avecSiren , $ape_etab );
$tabRet2 = array ();
foreach ( $etabs [ 'reponses' ] as $etab )
$tabRet2 [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => prepareString ( strtr ( $etab [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $etab [ 'Nom2' ]),
'Sigle' => prepareString ( $etab [ 'Sigle' ]),
'Enseigne' => prepareString ( $etab [ 'Enseigne' ]),
'Adresse' => prepareString ( $etab [ 'Adresse' ]),
'Adresse2' => prepareString ( $etab [ 'Adresse2' ]),
'CP' => $etab [ 'CP' ],
'Ville' => prepareString ( $etab [ 'Ville' ]),
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
'FJLib' => prepareString ( $this -> iInsee -> getLibelleFJ ( $etab [ 'FJ' ])),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => prepareString ( $this -> iInsee -> getLibelleNaf ( $etab [ 'NafEtab' ])), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => prepareString ( $this -> iInsee -> getLibelleNaf ( $etab [ 'NafEnt' ])),
);
$tabRet = $etabs ;
$tabRet [ 'reponses' ] = $tabRet2 ;
$fp =@ fopen ( '/var/www/log/recherches.log' , 'a' );
$siretTrouve = 0 ;
if ( $tabRet [ 'nbReponses' ] == 0 ) {
$str = " NbRep=0, S= $raisonSociale , R= $adresse , L= $codePostal , V= $ville , A= $ape_etab , ( $deb , $nbRep , $maxRep , $siege , $actif , $pertinence , $avecSiren ), SiretTrouve= $siretTrouve " ;
@ fwrite ( $fp , $str . EOL );
@ fclose ( $fp );
debugLog ( 'I' , " rechercheEtab : AUCUN RESULTAT, S= $raisonSociale , R= $adresse , L= $codePostal , V= $ville , A= $ape_etab ( $siege , $actif , $deb , $nbRep , $maxRep , $pertinence , $avecSiren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 100 , 'errmsg' => 'Pas de reponse' ), 'results' => $tabRet );
}
else {
if ( $tabRet [ 'nbReponses' ] == 1 ) $siretTrouve = $tabRet [ 'reponses' ][ 0 ][ 'Siret' ];
$str = " NbRep= " . $tabRet [ 'nbReponses' ] . " , S= $raisonSociale , R= $adresse , L= $codePostal , V= $ville , A= $ape_etab , ( $deb , $nbRep , $maxRep , $siege , $actif , $pertinence , $avecSiren ), SiretTrouve= $siretTrouve " ;
@ fwrite ( $fp , $str . EOL );
@ fclose ( $fp );
debugLog ( 'I' , " rechercheEtab : " . $tabRet [ 'nbReponses' ] . " RESULTATS, S= $raisonSociale , R= $adresse , L= $codePostal , V= $ville , A= $ape_etab ( $siege , $actif , $deb , $nbRep , $maxRep , $pertinence , $avecSiren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
}
/** Recherche d 'entreprise ou d' <EFBFBD> tablissement par leur dirigeant
**
** @ param string $nom Nom du dirigeant ( obligatoire )
** @ param string $prenom Pr<EFBFBD> nom du dirigeant
** @ param date $dateNaiss Date de naissance de la SSAA - MM - JJ , SSAA - MM ou SSAA
** @ param string $lieuNaiss Lieu de naissance ( CP , Ville ou Pays )
** @ param integer $deb Position du curseur dans la liste des r<EFBFBD> ponses ( 0 par d<EFBFBD> faut )
** @ param integer $nbRep Nombre de r<EFBFBD> ponses retourn<EFBFBD> es au maximum par cette requete ( 20 par d<EFBFBD> faut )
** @ param integer $maxRep Nombre de r<EFBFBD> ponses recherch<EFBFBD> es au maximum ( 200 par d<EFBFBD> faut )
** @ param bool $pertinence Recherche orthographique stricte sur les noms et pr<EFBFBD> noms ( si true )
** @ return Liste des entreprises trouv<EFBFBD> es
**/
function searchDir ( $nom , $prenom = '' , $dateNaiss = '' , $lieuNaiss = '' , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false ) {
debugLog ( 'I' , " Recherche Dirigeant de $nom , $prenom , $dateNaiss , $lieuNaiss (Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$etabs = $this -> iInsee -> rechercheDir ( $nom , $prenom , /*$fonction=*/ '' , $dateNaiss , $lieuNaiss , $deb , $nbRep , $maxRep , $pertinence );
$tabRet2 = array ();
foreach ( $etabs [ 'reponses' ] as $etab )
$tabRet2 [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => prepareString ( strtr ( $etab [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $etab [ 'Nom2' ]),
'Sigle' => prepareString ( $etab [ 'Sigle' ]),
'Enseigne' => prepareString ( $etab [ 'Enseigne' ]),
'Adresse' => prepareString ( $etab [ 'Adresse' ]),
'Adresse2' => prepareString ( $etab [ 'Adresse2' ]),
'CP' => $etab [ 'CP' ],
'Ville' => prepareString ( $etab [ 'Ville' ]),
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
/* 'FJLib' => prepareString ( $etab [ 'FJLib' ]),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => prepareString ( $etab [ 'NafEtabLib' ]), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => prepareString ( $etab [ 'NafEntLib' ]), */
'FJLib' => prepareString ( $this -> iInsee -> getLibelleFJ ( $etab [ 'FJ' ])),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => prepareString ( $this -> iInsee -> getLibelleNaf ( $etab [ 'NafEtab' ])), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => prepareString ( $this -> iInsee -> getLibelleNaf ( $etab [ 'NafEnt' ])),
// Dirigeant
'DirRs' => prepareString ( $etab [ 'DirRs' ]),
'DirNom' => prepareString ( $etab [ 'DirNom' ]),
'DirPrenom' => prepareString ( $etab [ 'DirPrenom' ]),
'DirNomUsage' => prepareString ( $etab [ 'DirNomUsage' ]),
'DirDateEffet' => $etab [ 'DirDateEffet' ],
'DirFonction' => prepareString ( $etab [ 'DirFonction' ]),
'DirDepart' => $etab [ 'DirDepart' ],
);
$tabRet = $etabs ;
$tabRet [ 'reponses' ] = $tabRet2 ;
if ( $tabRet [ 'nbReponses' ] == 0 ) {
debugLog ( 'W' , " Aucun r<> sultat pour cette recherche ! " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 100 , 'errmsg' => 'Pas de reponse' ), 'results' => $tabRet );
}
else return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
2011-06-09 09:39:42 +00:00
/** Recherche d ' entreprise par leur actionnaire
**
2011-07-11 09:54:09 +00:00
** @ param string $nom Raison sociale / Nom de l ' actionnaire ( obligatoire )
** @ param string $cpVille CP , Ville
2011-06-09 09:39:42 +00:00
** @ param integer $siren Siren de l ' actionnaire
** @ param string $pays Pays de l ' actionnaire
** @ param string $pctMin Niveau de d<EFBFBD> tention Minimam de l ' actionnaire
** @ param string $pctMax Niveau de d<EFBFBD> tention Maximum de l ' actionnaire
** @ param integer $deb Position du curseur dans la liste des r<EFBFBD> ponses ( 0 par d<EFBFBD> faut )
** @ param integer $nbRep Nombre de r<EFBFBD> ponses retourn<EFBFBD> es au maximum par cette requete ( 20 par d<EFBFBD> faut )
** @ param integer $maxRep Nombre de r<EFBFBD> ponses recherch<EFBFBD> es au maximum ( 200 par d<EFBFBD> faut )
** @ param bool $pertinence Recherche orthographique stricte sur les noms et pr<EFBFBD> noms ( si true )
** @ return Liste des entreprises trouv<EFBFBD> es
**/
2011-07-11 09:54:09 +00:00
function searchAct ( $nom , $cpVille = '' , $siren = 0 , $pays = '' , $pctMin = 0 , $pctMax = 100 , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false ) {
debugLog ( 'I' , " Recherche Actionnaire de $nom , $cpVille (Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( ! empty ( $pays )){
$wdb = new WDB ( 'jo' );
$result = $wdb -> select ( 'tabPays' , 'codPays3' , " libPays LIKE ' " . $pays );
if ( count ( $result > 0 )){
$pays = $result [ 0 ][ 'codPays3' ];
} else {
$pays = '' ;
}
}
2011-06-09 09:39:42 +00:00
2011-07-11 09:54:09 +00:00
$mLiens = new MLiens ( '' );
$etabs = $mLiens -> rechercheActionnaire ( $nom , $cpVille , $siren , $pays , $pctMin , $pctMax , $deb , $nbRep , $maxRep , $pertinence );
2011-06-09 09:39:42 +00:00
$tabRet2 = array ();
foreach ( $etabs [ 'reponses' ] as $etab )
2011-07-11 09:54:09 +00:00
$tabRet2 [] = array (
'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => prepareString ( strtr ( $etab [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $etab [ 'Nom2' ]),
'Sigle' => prepareString ( $etab [ 'Sigle' ]),
'Enseigne' => prepareString ( $etab [ 'Enseigne' ]),
'Adresse' => prepareString ( $etab [ 'Adresse' ]),
'Adresse2' => prepareString ( $etab [ 'Adresse2' ]),
'CP' => $etab [ 'CP' ],
'Ville' => prepareString ( $etab [ 'Ville' ]),
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
'FJLib' => prepareString ( $this -> iInsee -> getLibelleFJ ( $etab [ 'FJ' ])),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => prepareString ( $this -> iInsee -> getLibelleNaf ( $etab [ 'NafEtab' ])), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => prepareString ( $this -> iInsee -> getLibelleNaf ( $etab [ 'NafEnt' ])),
'ActNomRs' => $etab [ 'ActNomRs' ],
'ActPays' => $etab [ 'ActPays' ],
'ActDateLien' => $etab [ 'ActDateLien' ],
'ActActif' => $etab [ 'ActActif' ],
'ActPmin' => $etab [ 'ActPmin' ],
);
$tabRet = $etabs ;
2011-06-09 09:39:42 +00:00
$tabRet [ 'reponses' ] = $tabRet2 ;
if ( $tabRet [ 'nbReponses' ] == 0 ) {
debugLog ( 'W' , " Aucun r<> sultat pour cette recherche ! " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 100 , 'errmsg' => 'Pas de reponse' ), 'results' => $tabRet );
}
else return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
2010-11-04 11:05:01 +00:00
/** Recherche d 'entreprise ou d' <EFBFBD> tablissement par leur identifiant SIREN ou SIRET
**
** @ param integer $siret Siren ou Siret de l 'entreprise ou de l' <EFBFBD> tablissement sur 9 ou 14 chiffres significatifs
** @ param integer $deb Position du curseur dans la liste des r<EFBFBD> ponses ( 0 par d<EFBFBD> faut )
** @ param integer $nbRep Nombre de r<EFBFBD> ponses retourn<EFBFBD> es au maximum par cette requete ( 20 par d<EFBFBD> faut )
** @ param integer $maxRep Nombre de r<EFBFBD> ponses recherch<EFBFBD> es au maximum ( 200 par d<EFBFBD> faut )
** @ param integer $dep D<EFBFBD> partement
** @ return Liste d ' <EFBFBD> tablissements
**/
function searchSiren ( $siret , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $dep = 0 ) {
$tabRet = array ();
debugLog ( 'I' , " Recherche par Siret de $siret (dep= $dep ) avec un maximum de $maxRep r<> ponses pour la tranche $deb <20> $nbRep " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( strlen ( $siret ) == 14 ) $nic = substr ( '' . $siret , 9 , 5 );
elseif ( strlen ( $siret ) == 9 ) $nic = '' ;
else {
debugLog ( 'W' , " Siren/Siret $siret incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren Siret inexistant' ), 'results' => $tabRet );
}
$siren = substr ( '' . $siret , 0 , 9 );
$rep = $this -> iInsee -> getEtablissements ( $siren , $nic , $deb , $nbRep , $maxRep , $dep );
if ( count ( $rep [ 'reponses' ]) == 0 && $dep > 0 ) {
$rep = $this -> iInsee -> getEtablissements ( $siren , $nic , $deb , $nbRep , $maxRep );
}
$etabs = $rep [ 'reponses' ];
foreach ( $etabs as $nb => $etab ) {
$tabRet [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => prepareString ( strtr ( $etab [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $etab [ 'Nom2' ]),
'Sigle' => prepareString ( $etab [ 'Sigle' ]),
'Enseigne' => prepareString ( $etab [ 'Enseigne' ]),
'Adresse' => prepareString ( $etab [ 'Adresse' ]),
'Adresse2' => prepareString ( $etab [ 'Adresse2' ]),
'CP' => $etab [ 'CP' ],
'Ville' => prepareString ( $etab [ 'Ville' ]),
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
'FJLib' => prepareString ( $etab [ 'FJLib' ]),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => prepareString ( $etab [ 'NafEtabLib' ]), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => prepareString ( $etab [ 'NafEntLib' ]),
);
}
$rep [ 'reponses' ] = $tabRet ;
/** Si le siren est valide, on part chez Infogreffe **/
if ( count ( $tabRet ) == 0 && $this -> iInsee -> valideSiren ( $siren )) {
$iGeffes = new MGreffes ();
$etab = $iGeffes -> getIdentite ( $siren );
if ( $etab ) {
$tabRet [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => prepareString ( $etab [ 'Nom' ]),
'Nom2' => prepareString ( $etab [ 'Nom2' ]),
'Sigle' => prepareString ( $etab [ 'Sigle' ]),
'Enseigne' => prepareString ( $etab [ 'Enseigne' ]),
'Adresse' => prepareString ( $etab [ 'Adresse' ]),
'Adresse2' => prepareString ( $etab [ 'Adresse2' ]),
'CP' => $etab [ 'CP' ],
'Ville' => prepareString ( $etab [ 'Ville' ]),
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
'FJLib' => prepareString ( $etab [ 'FJLib' ]),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ],
'NafEtabLib' => prepareString ( $etab [ 'NafEtabLib' ]),
'NafEnt' => $etab [ 'NafEnt' ],
'NafEntLib' => prepareString ( $etab [ 'NafEntLib' ]),
);
$rep = array ( 'criteres' => array ( 'siren' => $siren , 'nic' => $nic , 'dep' => $dep ),
'nbReponses' => 1 ,
'nbReponsesTotal' => 1 ,
'reponses' => $tabRet );
} else {
$iDb = new WDB ();
global $tabInfoUser ;
$iDb -> insert ( 'siren_inexistants' ,
array ( 'siren' => $siren ,
'nic' => $nic ,
'dep' => $dep ,
'login' => $tabInfoUser [ 'login' ],
'client' => $tabInfoUser [ 'idClient' ],
'dateInsert' => date ( 'YmdHis' )));
$rep = array ( 'criteres' => array ( 'siren' => $siren , 'nic' => $nic , 'dep' => $dep ),
'nbReponses' => 0 ,
'nbReponsesTotal' => 0 ,
'reponses' => array ());
}
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $rep );
}
/** Recherche d 'entreprise ou d' <EFBFBD> tablissement par leur TEL FAX
**
** @ param integer $telFax T<EFBFBD> l<EFBFBD> phone ou fax de l ' <EFBFBD> tablissement ( ex : 017543 8010 )
** @ param integer $deb Position du curseur dans la liste des r<EFBFBD> ponses ( 0 par d<EFBFBD> faut )
** @ param integer $nbRep Nombre de r<EFBFBD> ponses retourn<EFBFBD> es au maximum par cette requete ( 20 par d<EFBFBD> faut )
** @ param integer $maxRep Nombre de r<EFBFBD> ponses recherch<EFBFBD> es au maximum ( 200 par d<EFBFBD> faut )
** @ return Liste d ' <EFBFBD> tablissements
**/
function searchTelFax ( $telFax , $deb = 0 , $nbRep = 20 , $maxRep = 200 ) {
$tabRet = array ();
debugLog ( 'I' , " Recherche par Tel/Fax de $telFax avec un maximum de $nbRep r<> ponses " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
//$assocs=$this->iInsee->rechercheEtab($raisonSociale, $adresse, $codePostal, $ville, $siege, $nbRep, $pertinence);
/** @ todo A FAIRE
**/
if ( strlen ( $telFax ) < 10 || strlen ( $telFax ) > 14 ) {
debugLog ( 'W' , " Tel/Fax $telFax incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Tel/Fax inexistant' ), 'results' => $tabRet );
}
$rep = $this -> iInsee -> getEtablissementsParId ( 'TEL' , $telFax , $deb , $nbRep , $maxRep );
$etabs = $rep [ 'reponses' ];
foreach ( $etabs as $nb => $etab ) {
$tabRet [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => prepareString ( strtr ( $etab [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $etab [ 'Nom2' ]),
'Sigle' => prepareString ( $etab [ 'Sigle' ]),
'Enseigne' => prepareString ( $etab [ 'Enseigne' ]),
'Adresse' => prepareString ( $etab [ 'Adresse' ]),
'Adresse2' => prepareString ( $etab [ 'Adresse2' ]),
'CP' => $etab [ 'CP' ],
'Ville' => prepareString ( $etab [ 'Ville' ]),
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
'FJLib' => prepareString ( $etab [ 'FJLib' ]),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => prepareString ( $etab [ 'NafEtabLib' ]), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => prepareString ( $etab [ 'NafEntLib' ]),
);
}
$rep [ 'reponses' ] = $tabRet ;
//$tabRet=$etabs;
/* if ( count ( $tabRet ) == 0 ) {
debugLog ( 'W' , " Siren/Siret $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 100 , 'errmsg' => 'Pas de reponse' ), 'results' => $tabRet );
}
else */ return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $rep );
}
public function rechercheHisto ( $recherche , $annee = '' , $typeBod = '' , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false ) {
include_once ( FWK_PATH . 'sphinx/recherche2.php' );
debugLog ( 'I' , " rechercheHisto de $recherche ( $annee ) (Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabFiltresAnnee = array ();
if ( $annee <> '' && $annee * 1 >= 1953 && $annee * 1 <= date ( 'Y' ) * 1 )
$tabFiltresAnnee = array ( 'annee1' => $annee );
$ret = search2 ( 'idx_histo' , " $recherche " , $tabFiltresAnnee , $deb , $nbRep , $maxRep , $pertinence );
$liste = $ret [ 'results' ];
$nbTot = $ret [ 'nbTot' ];
$duree = $ret [ 'duration' ];
$tabMots = $ret [ 'words' ];
$tabRet = array ();
$k = 0 ;
foreach ( $liste as $n => $etab ) {
$texte =/* preg_replace ( '/ +/' , ' ' , */ $etab [ 'Texte' ]; //);
$posMin = 100000 ;
$hitMin = 1000000 ;
foreach ( $tabMots as $mot => $tabMot )
if ( $tabMot [ 'hits' ] < $hitMin ){
$hitMin = $tabMot [ 'hits' ];
$motSignificatif = $mot ;
}
$posMin = stripos ( $texte , '' . $motSignificatif );
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug", print_r($tabMots,true).EOL.$motSignificatif.' trouv<75> en position '.$posMin) ;
if ( $posMin < 150 ) $posMin = 150 ;
$texte2 = substr ( $texte , $posMin - 150 , 250 );
$tabRet [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Fichier' => strtr ( $etab [ 'Fichier' ], array ( '.txt' => '.pdf' , '/mnt/bodacc/' => 'http://tville.scores-decisions.com/bodacc/' )),
'Annee' => $etab [ 'Annee' ],
'Code' => $etab [ 'Code' ],
'Texte' => prepareString ( preg_replace ( '/^[A-Za-z0-9\s<> <73> <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> <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> ݟ]/' , '' ,
$texte2 )),
);
$k ++ ;
}
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug", print_r($tabRet,true)) ;
return array ( 'criteres' => array ( 'recherche' => $recherche , 'annee' => $annee ),
'nbReponses' => count ( $tabRet ),
'nbReponsesTotal' => $nbTot ,
'duree' => $duree ,
'mots' => array_keys ( $tabMots ),
'reponses' => $tabRet );
}
/** Retourne une annonce en fonction de sa r<EFBFBD> f<EFBFBD> rence
**
** @ param integer $siren Siren de l ' entreprise
** @ param integer $filtre 0 = Pas de Filtre , 1 = BODACC , 2 = B . A . L . O , 3 = JO Association
** @ param integer $idAnn Identifiant de l ' annonce
** @ return Liste des annonces l<EFBFBD> gales
*/
function rechercheAnnonce ( $source , $dateAnnee , $numParution , $numAnnonce ) {
debugLog ( 'I' , " Annonce pr<70> cise demand<6E> e pour $source , $dateAnnee , $numParution , $numAnnonce " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $dateAnnee ) == 4 ) $annee = $dateAnnee ;
else $annee = substr ( $dateAnnee , 0 , 4 );
$iDb = new WDB ( 'jo' );
switch ( strtoupper ( $source )) {
case 'BODA' :
case 'BODB' :
case 'BODC' :
$lettre = substr ( strtoupper ( $source ), 3 , 1 );
if ( $annee < 2005 ) {
if ( $lettre == 'A' ) $numJAL = 1 ;
elseif ( $lettre == 'B' ) $numJAL = 200 ;
else break ;
$anneeDeb = $annee . '0101' ;
$anneeFin = $annee . '1231' ;
$res = $iDb -> select ( 'historiques.entrep e, texte t' , " $annee AS Annee_Parution, e.NOBOD AS Num_Parution, e.NOANN AS Num_Annonce, e.NOPAGE AS Num_Page, e.`DATE` AS Date_Parution, e.DEPT AS Departement, e.CODTRI AS Tribunal_Code, 'I' AS typeAnnonce, CONCAT(e.NOANN,' - ',t.annonceTxt) AS annonce " ,
" e.JAL= $numJAL AND e.NOBOD= $numParution AND e.`DATE` BETWEEN $anneeDeb AND $anneeFin AND e.NOANN= $numAnnonce AND e.ANBASE=t.annonceNum " );
//if (preg_mat$res=
//$res= Rectificatif:
} else
$res = $iDb -> select ( 'bodacc' , 'Bodacc_Annee_Parution AS Annee_Parution, Bodacc_Num AS Num_Parution, Num_Annonce, Bodacc_Page AS Num_Page, Bodacc_Date_Parution AS Date_Parution, Tribunal_Dept AS Departement, Tribunal_Code, typeAnnonce, annonce' , " Bodacc_Code=' $lettre ' AND Bodacc_Annee_Parution= $annee AND Bodacc_Num= $numParution AND Num_Annonce= $numAnnonce " );
break ;
case 'ASSO' :
$res = $iDb -> select ( 'asso' , 'YEAR(Date_Parution) AS Annee_Parution, Num_Parution, Num_Annonce, pageDeb AS Num_Page, Date_Parution, Departement, codTribunal AS Tribunal_Code, typeAnnonce, Annonce_Html AS annonce' , " Date_Parution BETWEEN ' $annee -01-01' AND ' $annee -12-31' AND Num_Parution= $annee " . sprintf ( '%04d' , $numParution ) . " AND Num_Annonce= $numAnnonce " );
break ;
case 'BALO' :
$res = $iDb -> select ( 'balo' , " YEAR(Date_Parution) AS Annee_Parution, Num_Parution, Num_Affaire AS Num_Annonce, '' AS Num_Page, Date_Parution, '' AS Departement, '' AS Tribunal_Code, 'Insertion' AS typeAnnonce, Annonce_Html AS annonce " , " Date_Parution BETWEEN ' $annee -01-01' AND ' $annee -12-31' AND Num_Parution= $numParution AND Num_Affaire= $numAnnonce " );
break ;
}
$tabRet = array (); $k = 0 ;
$iBodacc = new MBodacc ();
if ( count ( $res ) > 0 ) {
foreach ( $res as $i => $etab ) {
$tabRet [] = array ( 'Annee_Parution' => $etab [ 'Annee_Parution' ],
'Num_Parution' => $etab [ 'Num_Parution' ],
'Num_Annonce' => $etab [ 'Num_Annonce' ],
'Num_Page' => $etab [ 'Num_Page' ],
'Date_Parution' => $etab [ 'Date_Parution' ],
'Departement' => $etab [ 'Departement' ],
'Tribunal_Code' => $etab [ 'Tribunal_Code' ],
'Tribunal' => $iBodacc -> getTribunalNom ( $etab [ 'Tribunal_Code' ]),
'Type_Annonce' => $etab [ 'typeAnnonce' ],
'Annonce' => prepareString ( strip_tags ( strtr ( html_entity_decode ( $etab [ 'annonce' ]), array ( '>' => '>' , '&' => '&' , '<' => '<' , '’' => " ' " )))),
);
$k ++ ;
}
}
$nbTot = count ( $tabRet );
$duree = $ret [ 'duration' ];
return array ( 'criteres' => array ( 'source' => $source , 'annnee' => $dateAnnee , 'numParution' => $numParution , 'numAnnonce' => $numAnnonce ),
'nbReponses' => $nbTot ,
'nbReponsesTotal' => $nbTot ,
//'duree'=>$duree,
'reponses' => $tabRet );
}
/** Recherche d 'entreprise ou d' <EFBFBD> tablissement par un autre Identifiant
**
** @ param integer $typeId I = Code Isin , W = N<EFBFBD> Waldec ( Associations ) ou R = N<EFBFBD> RC ( Registre Greffe )
** @ param integer $identifiant Identifiant recherch<EFBFBD>
** @ param integer $deb Position du curseur dans la liste des r<EFBFBD> ponses ( 0 par d<EFBFBD> faut )
** @ param integer $nbRep Nombre de r<EFBFBD> ponses retourn<EFBFBD> es au maximum par cette requete ( 20 par d<EFBFBD> faut )
** @ param integer $maxRep Nombre de r<EFBFBD> ponses recherch<EFBFBD> es au maximum ( 200 par d<EFBFBD> faut )
** @ return Liste d ' <EFBFBD> tablissements
**/
function searchAutreId ( $typeId , $identifiant , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $dep = 0 ) {
$tabRet = array ();
$typeId = substr ( trim ( strtoupper ( $typeId )), 0 , 1 );
if ( $typeId <> 'I' && $typeId <> 'W' && $typeId <> 'R' ) {
debugLog ( 'I' , " Type d'identifiant $typeId inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 698987 , 'errmsg' => 'Type d\'identifiant inexistant' ), 'results' => $tabRet );
}
debugLog ( 'I' , " Recherche par identifiant $typeId de $identifiantavec un maximum de $nbRep r<> ponses " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( $typeId == 'W' || $typeId == 'R' ) {
$rep = $this -> iInsee -> getEtablissementsParId ( 'AUTRE' , $identifiant , $deb , $nbRep , $maxRep , $dep );
$etabs = $rep [ 'reponses' ];
foreach ( $etabs as $nb => $etab ) {
$tabRet [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => prepareString ( strtr ( $etab [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $etab [ 'Nom2' ]),
'Sigle' => prepareString ( $etab [ 'Sigle' ]),
'Enseigne' => prepareString ( $etab [ 'Enseigne' ]),
'Adresse' => prepareString ( $etab [ 'Adresse' ]),
'Adresse2' => prepareString ( $etab [ 'Adresse2' ]),
'CP' => $etab [ 'CP' ],
'Ville' => prepareString ( $etab [ 'Ville' ]),
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
'FJLib' => prepareString ( $etab [ 'FJLib' ]),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => prepareString ( $etab [ 'NafEtabLib' ]), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => prepareString ( $etab [ 'NafEntLib' ]), );
}
$rep [ 'reponses' ] = $tabRet ;
//$tabRet=$etabs;
/* if ( count ( $tabRet ) == 0 ) {
debugLog ( 'W' , " Siren/Siret $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 100 , 'errmsg' => 'Pas de reponse' ), 'results' => $tabRet );
}
else */ return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $rep );
}
else {
$iBourse = new MBourse ( $siren );
$siren = $iBourse -> getCodeSiren ( $identifiant );
return $this -> searchSiren ( $siren , $deb , $nbRep , $maxRep );
}
}
/** V<EFBFBD> rifie si un siren existe en base Scores & D<EFBFBD> cisions
**
** @ param integer $siren Siren de l ' entit<EFBFBD>
** @ return unknown
**/
function isSirenExistant ( $siren ) {
debugLog ( 'I' , " Siren existant demand<6E> e pour siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$siren = trim ( substr ( '' . $siret , 0 , 9 )) * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$entrep = $this -> iInsee -> sirenExiste ( $siren );
if ( empty ( $entrep )) {
debugLog ( 'W' , " Siren $siren non pr<70> sent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
debugLog ( 'I' , " Siren $siren pr<70> sent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'sirenExiste' , $siren );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
}
/** Retourne les informations identitaires de l 'entreprise ou de l' <EFBFBD> tablissement demand<EFBFBD>
**
** @ param integer $siret Siren de l 'entreprise ou siret de l' <EFBFBD> tablissement
** @ param integer $id Identifiant S & D de l ' <EFBFBD> tablissement
** @ return array Fiche d 'identit<69> de l' <EFBFBD> tablissement
**/
function getIdentite ( $siret , $id = 0 , $forceVerif = false ) {
$tdeb = microtime ( 1 );
$ligne = date ( 'YmdHis' ) . " ; $siret ;Ws->getIdentite Avant ... " ;
$fp = fopen ( '/var/www/log/accesDistant.log' , 'a' );
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
/* $login , $page , $siret , $ip , $host , $resolution , $nbcolors , $user_agent , $referer , $date_login , $date_last_action , $request ) {
if ( ! file_exists ( '/var/www/site_extranet/log/actions.log' )) {
$fp = fopen ( '/var/www/site_extranet/log/actions.log' , 'a' );
fwrite ( $fp , 'Date et Heure;Login;Page;Siret;Ip;Host;Resolution;Nbcolors;User Agent;Referer;Date login;Date last action;Request' . " \n " );
} else {
$fp = fopen ( '/var/www/site_extranet/log/actions.log' , 'a' );
}
fwrite ( $fp , date ( 'Y/m/d H:i:s' ) . " ; $login ; $page ; $siret ; $ip ; $host ; $resolution ; $nbcolors ; $user_agent ; $referer ; $date_login ; $date_last_action ; $request\n " );
fclose ( $fp );
} */
debugLog ( 'I' , " Identit<EFBFBD> s demand<6E> e pour siret $siret (id= $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$siret = trim ( $siret );
$len = strlen ( $siret );
$id = trim ( $id ) * 1 ;
if ( $len == 14 ) $nic = substr ( '' . $siret , 9 , 5 ) * 1 ;
elseif ( $len == 9 ) $nic = 0 ;
elseif ( $len == 0 ) { $siren = 0 ; $nic = 0 ; }
else {
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren Siret inexistant' ), 'result' => $tabRet );
}
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
if ( $siren == 0 && $id == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
debugLog ( 'I' , " Avant getIdentiteEntreprise( $siren , $nic , $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$entrep = $this -> iInsee -> getIdentiteEntreprise ( $siren , $nic , $id , $forceVerif );
debugLog ( 'I' , " Apr<EFBFBD> s getIdentiteEntreprise( $siren , $nic , $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$duree = round ( microtime ( 1 ) - $tdeb , 3 );
$ligne = date ( 'YmdHis' ) . " ; $siret ;Ws->getIdentite juste apres iInsee->... ( $duree s) " ;
$fp = fopen ( '/var/www/log/accesDistant.log' , 'a' );
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
if ( empty ( $entrep )) {
debugLog ( 'W' , " Siren $siren non pr<70> sent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$iBourse = new MBourse ( $siren );
$bourse = $iBourse -> getInfosBourse ( $siren );
$tabRet = array ( 'id' => $entrep [ 'id' ],
'Siret' => $entrep [ 'Siret' ],
'SiretSiege' => $entrep [ 'SiretSiege' ],
'Siege' => $entrep [ 'Siege' ],
2011-06-09 09:39:42 +00:00
'AncienSiege' => $entrep [ 'AncienSiege' ],
'AncienSiegeDateFin' => $entrep [ 'AncienSiegeDateFin' ],
2010-11-04 11:05:01 +00:00
'TribunalCode' => prepareString ( $entrep [ 'Tribunal' ]),
'TribunalLib' => prepareString ( $entrep [ 'TribunalLib' ]),
//'NumGreffe' =>$entrep['numGreffe'], // Ajout<75> le 4 08 2009
'NumRC' => $entrep [ 'numRC' ], // Ajout<75> le 4 08 2009
'Actif' => $entrep [ 'Actif' ],
2011-06-09 09:39:42 +00:00
'ActifEco' => $entrep [ 'ActifEco' ], // Etab <20> co actif, ajout le 28/04/2011
'ActifEcoDate' => $entrep [ 'ActifEcoDate' ], // Date si <20> co inactif et jur actif
'ActifEcoType' => $entrep [ 'ActifEcoType' ], // vide ou NPAI ou PFER ou ECOF
2010-11-04 11:05:01 +00:00
'EntActiveRCS' => $entrep [ 'EntActiveRCS' ],
'AutreId' => $entrep [ 'AutreId' ],
'Source' => $entrep [ 'Source' ],
'SourceId' => $entrep [ 'SourceId' ],
'Isin' => $entrep [ 'Isin' ],
'Nom' => prepareString ( strtr ( $entrep [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $entrep [ 'Nom2' ]),
'NomLong' => prepareString ( $entrep [ 'nomLong' ]), // Ajout<75> le 4 08 2009
2010-11-29 14:17:26 +00:00
'NomCommercial' => prepareString ( $entrep [ 'NomCommercial' ]), // Ajout<75> le 16 11 2010
2010-11-04 11:05:01 +00:00
'Siret' => $entrep [ 'Siret' ],
'Sigle' => prepareString ( $entrep [ 'Sigle' ]),
'SigleLong' => prepareString ( $entrep [ 'sigleLong' ]), // Ajout<75> le 4 08 2009
'Enseigne' => prepareString ( $entrep [ 'Enseigne' ]),
2010-11-29 14:17:26 +00:00
'EnseigneLong' => prepareString ( $entrep [ 'enseigneLong' ]), // Ajout<75> le 16 11 2010
2010-11-04 11:05:01 +00:00
'Adresse' => prepareString ( $entrep [ 'Adresse' ]),
'Adresse2' => prepareString ( $entrep [ 'Adresse2' ]),
'AdresseNum' => prepareString ( $entrep [ 'AdresseNum' ]),
'AdresseBtq' => prepareString ( $entrep [ 'AdresseBtq' ]),
'AdresseVoie' => prepareString ( $entrep [ 'AdresseVoie' ]),
'AdresseRue' => prepareString ( $entrep [ 'AdresseRue' ]),
'CP' => $entrep [ 'CP' ],
'Ville' => prepareString ( $entrep [ 'Ville' ]),
'Pays' => prepareString ( $entrep [ 'Pays' ]), // Ajout<75> le 18 02 2008
'PaysIso2' => $entrep [ 'PaysIso2' ],
'AdresseDom' => $entrep [ 'AdresseDom' ],
'AdresseDomEnt' => $entrep [ 'AdresseDomEnt' ],
'AdresseDomNb' => $entrep [ 'AdresseDomNb' ],
'Civilite' => $entrep [ 'Civilite' ],
'NbEtab' => $entrep [ 'NbEtab' ],
'Tel' => prepareString ( $entrep [ 'Tel' ]),
'Fax' => prepareString ( $entrep [ 'Fax' ]),
'Web' => prepareString ( $entrep [ 'Web' ]),
'Mail' => prepareString ( $entrep [ 'Mail' ]),
'GeoLat' => $entrep [ 'GeoLat' ],
'GeoLon' => $entrep [ 'GeoLon' ],
'GeoPrecis' => $entrep [ 'GeoPrecis' ],
'GeoInfos' => $entrep [ 'GeoInfos' ],
'TvaNumero' => $entrep [ 'TvaNumero' ],
'TvaAttribue' => $entrep [ 'TvaAttribue' ],
'FJ' => $entrep [ 'FJ' ],
'FJ_lib' => prepareString ( $entrep [ 'FJ_lib' ]),
'FJ2' => $entrep [ 'FJ2' ], // Ajout<75> le 4 08 2009
'FJ2_Lib' => prepareString ( $entrep [ 'FJ2_Lib' ]), // Ajout<75> le 4 08 2009
'Siren' => $entrep [ 'Siren' ],
'Nic' => $entrep [ 'Nic' ],
'NafEnt' => $entrep [ 'NafEnt' ],
'NafEntLib' => prepareString ( $entrep [ 'NafEntLib' ]),
'NafEtab' => $entrep [ 'NafEtab' ],
'NafEtabLib' => prepareString ( $entrep [ 'NafEtabLib' ]),
'NaceEtab' => $entrep [ 'NaceEtab' ],
'NaceEnt' => $entrep [ 'NaceEnt' ],
'Nafa' => $entrep [ 'APRM' ],
2011-03-24 15:11:22 +00:00
'NafaLib' => prepareString ( $entrep [ 'APRM_Lib' ]),
2010-11-04 11:05:01 +00:00
'NumRM' => $entrep [ 'NumRM' ],
'Activite' => prepareString ( $entrep [ 'Activite' ]),
'Capital' => $entrep [ 'Capital' ],
'CapitalDev' => $entrep [ 'CapitalDev' ],
'CapitalLib' => prepareString ( $entrep [ 'CapitalLib' ]), // Ajout<75> le 18 02 2008
'CapitalType' => prepareString ( $entrep [ 'CapitalType' ]), // Ajout<75> le 4 08 2009
'DateCreaEt' => $entrep [ 'DateCreaEt' ],
'DateCreaEn' => $entrep [ 'DateCreaEn' ],
'DateClotEt' => $entrep [ 'DateClotEt' ],
'DateImmat' => $entrep [ 'dateImmat' ], // Ajout<75> le 4 08 2009
'DateRadiation' => $entrep [ 'dateRad' ], // Ajout<75> le 4 08 2009
// 'DateMajRCS' =>$entrep['DateMajRCS'], // Ajout<75> le 4 08 2009
'EffEnTr' => prepareString ( $entrep [ 'EffEnTr' ]),
'EffEnTrLib' => prepareString ( $entrep [ 'EffEnTrLib' ]),
'Effectif' => prepareString ( $entrep [ 'Effectif' ]),
'EffEtTr' => prepareString ( $entrep [ 'EffEtTr' ]), // Ajout le 11 08 2010
'EffEtTrLib' => prepareString ( $entrep [ 'EffEtTrLib' ]), // Ajout le 11 08 2010
'EffectifEtab' => prepareString ( $entrep [ 'EffectifEtab' ]), // Ajout le 11 08 2010
'Dept' => $entrep [ 'Dept' ],
'codeCommune' => prepareString ( $entrep [ 'codeCommune' ]),
'AnneeEffEn' => $entrep [ 'AnneeEffEn' ],
'AnneeEffEt' => $entrep [ 'AnneeEffEt' ],
'AnneeTCA' => $entrep [ 'AnneeTCA' ],
'TrancheCA' => prepareString ( $entrep [ 'TrancheCA' ]),
'TrancheCALib' => prepareString ( $entrep [ 'TrancheCALib' ]),
'dir1Code' => $entrep [ 'dir1Code' ],
'dir1Titre' => prepareString ( $entrep [ 'dir1Titre' ]), //utf8
'dir1NomPrenom' => prepareString ( $entrep [ 'dir1NomPrenom' ]),
'dir1DateFct' => prepareString ( $entrep [ 'dir1DateFct' ]),
'dir1DateNaiss' => $entrep [ 'dir1DateNaiss' ], // Ajout<75> le 4 08 2009
'dir1LieuNaiss' => prepareString ( $entrep [ 'dir1LieuNaiss' ]), // Ajout<75> le 4 08 2009
'dir2Code' => $entrep [ 'dir2Code' ],
'dir2Titre' => prepareString ( $entrep [ 'dir2Titre' ]), //utf8
'dir2NomPrenom' => prepareString ( $entrep [ 'dir2NomPrenom' ]),
'dir2DateFct' => prepareString ( $entrep [ 'dir2DateFct' ]),
'dir2DateNaiss' => $entrep [ 'dir2DateNaiss' ], // Ajout<75> le 4 08 2009
'dir2LieuNaiss' => prepareString ( $entrep [ 'dir2LieuNaiss' ]), // Ajout<75> le 4 08 2009
'Rivoli' => $entrep [ 'Rivoli' ],
2011-03-24 15:11:22 +00:00
'InfosIris' => array ( 'codIris' => $entrep [ 'InfosIris' ][ 'codIris' ],
'codComIris' => $entrep [ 'InfosIris' ][ 'codComIris' ],
'libIris' => prepareString ( $entrep [ 'InfosIris' ][ 'libIris' ]),
'typIris' => prepareString ( $entrep [ 'InfosIris' ][ 'typIris' ]),
'evoIris' => $entrep [ 'InfosIris' ][ 'evoIris' ],
'trIris' => $entrep [ 'InfosIris' ][ 'trIris' ],
'grdQuartier' => $entrep [ 'InfosIris' ][ 'grdQuartier' ]),
2010-11-04 11:05:01 +00:00
'NatureActivite' => $entrep [ 'NatureActivite' ], // Nature de l'activit<69>
'OrigineCreation' => $entrep [ 'OrigineCreation' ], // Origine de la cr<63> ation
'TypeExploitation' => $entrep [ 'TypeExploitation' ],
'Auxiliaire' => $entrep [ 'Auxiliaire' ], // 1=Auxiliaire / 0=Non auxiliaire
'Saisonnalite' => $entrep [ 'Saisonnalite' ], // P=Activit<69> permanente / S=Activit<69> saisonni<6E> re
'SituationJuridique' => $entrep [ 'SituationJuridique' ],
'Bilan' => array ( 'Cloture' => $entrep [ 'bilanDate' ],
'Duree' => $entrep [ 'bilanMois' ],
'Devise' => $entrep [ 'bilanDevise' ],
'Capital' => $entrep [ 'bilanDA' ],
'CA' => $entrep [ 'bilanFL' ],
'Resultat' => $entrep [ 'bilanHN' ],
'Effectif' => $entrep [ 'bilanYP' ],
),
'Bourse' => array ( 'placeCotation' => $bourse [ 'placeCotation' ],
'nombreTitres' => $bourse [ 'nombreTitres' ],
'capitalisation' => $bourse [ 'close' ] * $bourse [ 'nombreTitres' ],
'derCoursDate' => $bourse [ 'date' ],
'derCoursCloture' => $bourse [ 'close' ]),
'AutreSiren' => $entrep [ 'AutreSiren' ],
2011-06-09 09:39:42 +00:00
'AutreSiret' => $entrep [ 'AutreSiret' ],
2010-11-04 11:05:01 +00:00
'DateMajINSEE' => $entrep [ 'DateMajINSEE' ],
'DateMajRCS' => $entrep [ 'DateMajRCS' ],
'DateMajBILAN' => $entrep [ 'bilanDateMaj' ],
'DateMajANN' => $entrep [ 'dateMajANN' ],
'DateMajID' => $entrep [ 'dateMajIdentite' ],
//'importExport' =>$entrep['importExport'],
);
global $tabInfoUser ;
if ( preg_match ( '/NAF4/i' , $tabInfoUser [ 'pref' ])) {
$entrep2 = $this -> iInsee -> getNaf4 ( $siren , $nic , $id );
$tabRet [ 'Naf4Ent' ] = $entrep2 [ 'apen4' ];
$tabRet [ 'Naf4Etab' ] = $entrep2 [ 'apet4' ];
$tabRet [ 'Naf4EntLib' ] = prepareString ( $entrep2 [ 'apen4_lib' ]);
$tabRet [ 'Naf4EtabLib' ] = prepareString ( $entrep2 [ 'apet4_lib' ]);
}
/* $tabRet = $entrep ;
$tabRet [ 'Bourse' ] = array ( 'placeCotation' => $bourse [ 'placeCotation' ],
'nombreTitres' => $bourse [ 'nombreTitres' ],
'capitalisation' => $bourse [ 'close' ] * $bourse [ 'nombreTitres' ],
'derCoursDate' => $bourse [ 'date' ],
'derCoursCloture' => $bourse [ 'close' ]); */
//$tabRet=$entrep;
debugLog ( 'I' , 'Etablissement retourn<72> = ' . $entrep [ 'Nom' ], __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'identite' , $siret , $id );
$duree = round ( microtime ( 1 ) - $tdeb , 3 );
$ligne = date ( 'YmdHis' ) . " ; $siret ;Ws->getIdentite APRES ( $duree s) !!! " ;
$fp = fopen ( '/var/www/log/accesDistant.log' , 'a' );
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Retourne l 'ensemble des informations identitaires des dirigeants de l' entreprise
**
** @ param integer $siren Siren de l ' entreprise
** @ param bool $histo Afficher l ' historique des dirigeants
** @ return Liste des dirigeants actifs de l ' entreprise
*/
function getDirigeants ( $siren , $histo = false ) {
debugLog ( 'I' , " Dirigeants demand<6E> e pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 ) {
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren Siret inexistant' ), 'results' => $tabRet );
}
$siren = $siren * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
if ( $histo ) $option = 'histo' ;
else $option = '' ;
$dirs = $this -> iInsee -> getDirigeants ( $siren , $histo );
//debugLog('W', print_r($entrep, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
foreach ( $dirs as $nb => $dir ) {
//debugLog('I', "Siren/Siret $siren trouv<75> : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$tabRet [] = array ( 'Code' => $dir [ 'Fonction' ],
'Titre' => prepareString ( $dir [ 'Titre' ]),
'Societe' => prepareString ( $dir [ 'Societe' ]),
'Civilite' => prepareString ( $dir [ 'Civilite' ]),
'Nom' => prepareString ( $dir [ 'Nom' ]),
'Prenom' => prepareString ( $dir [ 'Prenom' ]),
'NaissDate' => $dir [ 'NaissDate' ], // 07/09/1961
'NaissVille' => prepareString ( $dir [ 'NaissVille' ]), // LE RUSSEY
'NaissDepPays' => prepareString ( $dir [ 'NaissDepPays' ]), // LE RUSSEY
'Ancien' => $dir [ 'Ancien' ],
'DateFct' => $dir [ 'DateFct' ],
);
}
wsLog ( 'dirigeants' , $siren , $option );
debugLog ( 'I' , 'Nb Dirigeants retourn<72> s = ' . count ( $dirs ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Retourne la liste des annonces l<EFBFBD> gales relative <EFBFBD> une entreprise
**
** @ todo Revoir cette fonction pour la faire marcher avec les associations
**
** @ param integer $siren Siren de l ' entreprise
** @ param integer $filtre 0 = Pas de Filtre , 1 = BODACC , 2 = B . A . L . O , 3 = JO Association , 4 = Boamp
** @ param integer $idAnn Identifiant de l ' annonce
** @ return Liste des annonces l<EFBFBD> gales
*/
function getAnnonces ( $siren , $filtre = 0 , $idAnn = 0 ) {
debugLog ( 'I' , " Annonces demand<6E> es pour $siren ( $filtre , $idAnn ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 ) {
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren Siret inexistant' ), 'results' => $tabRet );
}
$siren = $siren * 1 ;
2011-03-24 15:11:22 +00:00
//$filtre=$filtre*1;
2010-11-04 11:05:01 +00:00
if ( $siren == 0 && $idAnn == 0 ) {
debugLog ( 'W' , " Siren $siren ou annonce $idAnn inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant A' ), 'result' => $tabRet );
}
/*
if ( $siren > 100 && $filtre == 3 ) $asso = true ;
else {
$asso = false ;
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $siren );
if ( $tabIdentite [ 'FJ' ] > 90 && $tabIdentite [ 'FJ' ] < 94 ||
$tabIdentite [ 'FJ' ] > 9000 && $tabIdentite [ 'FJ' ] < 9400 ) $asso = true ;
} */
if ( $idAnn == 0 ) {
$anns = $this -> iInsee -> getAnnoncesLegales ( $siren );
$annsB = $this -> iInsee -> getAnnoncesBalo ( $siren );
$annsA = $this -> iInsee -> getAnnoncesAsso ( $siren );
$annsM = $this -> iInsee -> getAnnoncesBoamp ( $siren , $idAnn );
} elseif ( $filtre == 1 )
$anns = $this -> iInsee -> getAnnoncesLegales ( $siren , $idAnn );
elseif ( $filtre == 2 )
$annsB = $this -> iInsee -> getAnnoncesBalo ( $siren , $idAnn );
elseif ( $filtre == 3 )
$annsA = $this -> iInsee -> getAnnoncesAsso ( $siren , $idAnn );
elseif ( $filtre == 4 )
$annsM = $this -> iInsee -> getAnnoncesBoamp ( $siren , $idAnn );
//debugLog('W', print_r($entrep, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
if ( empty ( $anns ) && empty ( $annsB ) && empty ( $annsA ) && empty ( $annsM )) {
debugLog ( 'W' , " Aucune annonce pour le siren $siren (source= $filtre , id= $idAnn ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant B ' . $siren . ' ' . $idAnn ), 'result' => $tabRet );
}
foreach ( $anns as $nb => $ann ) {
//debugLog('I', "Siren/Siret $siren trouv<75> : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$tabRetEven = array ();
foreach ( $ann [ 'evenements' ] as $tabEven )
$tabRetEven [] = array ( 'CodeEven' => $tabEven [ 'CodeEven' ],
'LibEven' => prepareString ( $tabEven [ 'LibEven' ]));
$tabRet [] = array ( 'id' => $ann [ 'id' ],
'BodaccCode' => $ann [ 'BodaccCode' ],
'BodaccNum' => $ann [ 'BodaccNum' ],
'NumAnnonce' => $ann [ 'NumAnnonce' ],
'DateParution' => $ann [ 'DateParution' ],
'Departement' => $ann [ 'Departement' ],
'Tribunal' => $ann [ 'Tribunal' ],
'TribunalCode' => $ann [ 'TribunalCode' ],
'TribunalSiret' => $ann [ 'TribunalSiret' ],
'Rubrique' => $ann [ 'Rubrique' ],
'typeAnnonce' => $ann [ 'typeAnnonce' ],
'texteRectificatif' => prepareString ( $ann [ 'texteRectificatif' ]),
'texteAnnonce' => prepareString ( $ann [ 'texteAnnonce' ]),
'libFJ' => prepareString ( $ann [ 'libFJ' ]),
'codFJ' => $ann [ 'codFJ' ],
'capital' => $ann [ 'capital' ],
'capitalDev' => $ann [ 'capitalDev' ],
2010-11-29 14:17:26 +00:00
'raisonSociale' => prepareString ( $ann [ 'raisonSociale' ]),
'nomCommercial' => prepareString ( $ann [ 'nomCommercial' ]),
'sigle' => prepareString ( $ann [ 'sigle' ]),
'adresse' => prepareString ( $ann [ 'adresse' ]),
2010-11-04 11:05:01 +00:00
'dateEffet' => $ann [ 'dateEffet' ],
'dateJugement' => $ann [ 'dateJugement' ],
'dateInsertionSD' => $ann [ 'dateInsertionSD' ],
'evenements' => $tabRetEven ,
'Lien_Annonce_Pdf' => $ann [ 'Lien_Annonce_Pdf' ]
);
}
if ( is_array ( $annsB ))
foreach ( $annsB as $nb => $ann ) {
//debugLog('I', "Siren/Siret $siren trouv<75> : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$tabRetEven = array ();
foreach ( $ann [ 'evenements' ] as $tabEven )
$tabRetEven [] = array ( 'CodeEven' => $tabEven [ 'CodeEven' ],
'LibEven' => prepareString ( $tabEven [ 'LibEven' ]));
$tabRet [] = array ( 'id' => $ann [ 'id' ],
'BodaccCode' => $ann [ 'BodaccCode' ],
'BodaccNum' => $ann [ 'BodaccNum' ],
'NumAnnonce' => $ann [ 'NumAnnonce' ],
'DateParution' => $ann [ 'DateParution' ],
'Departement' => $ann [ 'Departement' ],
'Tribunal' => $ann [ 'Tribunal' ],
'TribunalSiret' => $ann [ 'TribunalSiret' ],
'Rubrique' => $ann [ 'Rubrique' ],
'typeAnnonce' => $ann [ 'typeAnnonce' ],
'texteRectificatif' => prepareString ( $ann [ 'texteRectificatif' ]),
'texteAnnonce' => utf8_encode ( $ann [ 'texteAnnonce' ]), //prepareString
'dateEffet' => $ann [ 'dateEffet' ],
'dateJugement' => $ann [ 'dateJugement' ],
'dateInsertionSD' => $ann [ 'dateInsertionSD' ],
'evenements' => $tabRetEven ,
'Lien_Annonce_Pdf' => $ann [ 'Lien_Annonce_Pdf' ]
);
}
if ( is_array ( $annsA ))
foreach ( $annsA as $nb => $ann ) {
//debugLog('I', "Siren/Siret $siren trouv<75> : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
$tabRetEven = array ();
foreach ( $ann [ 'evenements' ] as $tabEven )
$tabRetEven [] = array ( 'CodeEven' => $tabEven [ 'CodeEven' ],
'LibEven' => prepareString ( $tabEven [ 'LibEven' ]));
$tabRet [] = array ( 'id' => $ann [ 'id' ],
'BodaccCode' => $ann [ 'BodaccCode' ],
'BodaccNum' => $ann [ 'BodaccNum' ],
'NumAnnonce' => $ann [ 'NumAnnonce' ],
'DateParution' => $ann [ 'DateParution' ],
'Departement' => $ann [ 'Departement' ],
'Tribunal' => prepareString ( $ann [ 'Tribunal' ]),
'TribunalSiret' => $ann [ 'TribunalSiret' ],
'Rubrique' => $ann [ 'Rubrique' ],
'typeAnnonce' => $ann [ 'typeAnnonce' ],
'texteRectificatif' => prepareString ( $ann [ 'texteRectificatif' ]),
'texteAnnonce' => utf8_encode ( $ann [ 'texteAnnonce' ]), //prepareString
'dateEffet' => $ann [ 'dateEffet' ],
'dateJugement' => $ann [ 'dateJugement' ],
'dateInsertionSD' => $ann [ 'dateInsertionSD' ],
'evenements' => $tabRetEven ,
'Lien_Annonce_Pdf' => $ann [ 'Lien_Annonce_Pdf' ]
);
}
if ( is_array ( $annsM ))
foreach ( $annsM as $nb => $ann ) {
$tabRetEven = array ();
foreach ( $ann [ 'evenements' ] as $tabEven )
$tabRetEven [] = array ( 'CodeEven' => $tabEven [ 'CodeEven' ],
'LibEven' => prepareString ( $tabEven [ 'LibEven' ]));
$tabRet [] = array ( 'id' => $ann [ 'id' ],
'BodaccCode' => $ann [ 'BodaccCode' ],
'BodaccNum' => $ann [ 'BodaccNum' ],
'NumAnnonce' => $ann [ 'NumAnnonce' ],
'DateParution' => $ann [ 'DateParution' ],
'Departement' => $ann [ 'Departement' ],
'Tribunal' => prepareString ( $ann [ 'Tribunal' ]),
'TribunalSiret' => $ann [ 'TribunalSiret' ],
'Rubrique' => $ann [ 'Rubrique' ],
'typeAnnonce' => $ann [ 'typeAnnonce' ],
'texteRectificatif' => prepareString ( $ann [ 'texteRectificatif' ]),
'texteAnnonce' => utf8_encode ( $ann [ 'texteAnnonce' ]), //prepareString
'dateEffet' => $ann [ 'dateEffet' ],
'dateJugement' => $ann [ 'dateJugement' ],
'dateInsertionSD' => $ann [ 'dateInsertionSD' ],
'evenements' => $tabRetEven ,
'Lien_Annonce_Pdf' => $ann [ 'Lien_Annonce_Pdf' ]
);
}
debugLog ( 'I' , " Nb Annonces $filtre retourn<72> es pour $siren (source= $filtre , id= $idAnn ) = " . count ( $tabRet ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'annonces' , $siren , $filtre . '/' . $idAnn );
file_put_contents ( '/var/www/log/annonces.log' , print_r ( $tabRet , 1 ));
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Retourne la fiche d 'identit<69> simplifi<66> d' une entreprise avec son num<EFBFBD> ro de TVA .
**
** @ param integer $siren Identifiant Siren de l ' entreprise
** @ return Fiche d ' identit<EFBFBD> avec Num<EFBFBD> ro de TVA Intracommunautaire
*/
function getTVA ( $siren ) {
$siren = trim ( $siren );
debugLog ( 'I' , " TVA demand<6E> e pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 ) {
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'results' => $tabRet );
}
$siren = $siren * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
debugLog ( 'I' , " Avant getIdentiteEntreprise( $siren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$entrep = $this -> iInsee -> getIdentiteEntreprise ( $siren );
debugLog ( 'I' , " Apr<EFBFBD> s getIdentiteEntreprise( $siren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( empty ( $entrep )) {
debugLog ( 'W' , " Siren $siren non pr<70> sent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
debugLog ( 'I' , " Avant MTva( $siren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iTva = new MTva ( $siren );
if ( $iTva -> vatDefined ) $tva = $iTva -> vatNumber ;
else $tva = 'N/A' ;
debugLog ( 'I' , " Apr<EFBFBD> s MTva( $siren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ( 'id' => $entrep [ 'id' ],
'AutreId' => $entrep [ 'AutreId' ],
'Nom' => prepareString ( $entrep [ 'Nom' ]),
'Sigle' => prepareString ( $entrep [ 'Sigle' ]),
'Enseigne' => prepareString ( $entrep [ 'Enseigne' ]),
'Adresse' => prepareString ( $entrep [ 'Adresse' ]),
'Adresse2' => prepareString ( $entrep [ 'Adresse2' ]),
'CP' => $entrep [ 'CP' ],
'Ville' => prepareString ( $entrep [ 'Ville' ]),
'Siren' => $entrep [ 'Siren' ],
'Tva' => $tva ,
);
debugLog ( 'I' , " TVA retourn<72> e = $tva ( " . $entrep [ 'Nom' ] . ')' , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'tva' , $siren );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Retourne tout ou patie des informations r<EFBFBD> glement<EFBFBD> es sur l ' entreprise
**
** @ param integer $siren SIREN de l ' entreprise
** @ param integer $id Id du communiqu<EFBFBD>
** @ return Liste des informations r<EFBFBD> glement<EFBFBD> es disponible
**/
function getInfosReg ( $siren , $id = false ) {
debugLog ( 'I' , " Infos r<> glement<6E> es demand<6E> es pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$tabRet = array ();
$siren = substr ( $siren , 0 , 9 ) * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$iBourse = new MBourse ( $siren );
$anns = $iBourse -> getInfosReg ( $siren , $id );
//debugLog('W', print_r($entrep, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
if ( empty ( $anns )) {
debugLog ( 'W' , " Aucune info r<> glement<6E> e pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet ); // @todo A voir
}
foreach ( $anns as $nb => $ann ) {
//debugLog('I', "Siren/Siret $siren trouv<75> : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
if ( $id == false )
$tabRet [] = array ( 'id' => $ann [ 'id' ],
'source' => $ann [ 'source' ],
'DateParution' => $ann [ 'DateParution' ],
'raisonSociale' => prepareString ( $ann [ 'raisonSociale' ]),
'titre' => prepareString ( $ann [ 'titre' ]),
'pj' => $ann [ 'pj' ],
'url' => $ann [ 'url' ],
'dateInsertionSD' => $ann [ 'dateInsertionSD' ],
);
else
$tabRet [] = array ( 'id' => $ann [ 'id' ],
'source' => $ann [ 'source' ],
'DateParution' => $ann [ 'DateParution' ],
'raisonSociale' => prepareString ( $ann [ 'raisonSociale' ]),
'titre' => prepareString ( $ann [ 'titre' ]),
'communique' => prepareString ( $ann [ 'communique' ]),
'communiqueHtml' => utf8_encode ( $ann [ 'communiqueHtml' ]),
'pj' => $ann [ 'pj' ],
'url' => $ann [ 'url' ],
'dateInsertionSD' => $ann [ 'dateInsertionSD' ],
);
}
debugLog ( 'I' , 'Nb infos retourn<72> s = ' . count ( $anns ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'infosreg' , $siren , $id );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Retourne les informations boursi<EFBFBD> res de l ' entreprise
**
** @ param integer $siren SIREN de l ' entreprise
** @ return Informations boursi<EFBFBD> res disponibles
**/
function getInfosBourse ( $siren ) {
debugLog ( 'I' , " Infos bourse demand<6E> es pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$siren = substr ( $siren , 0 , 9 ) * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$iBourse = new MBourse ( $siren );
$bourse = $iBourse -> getInfosBourse ( $siren );
//debugLog('W', print_r($entrep, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
if ( empty ( $bourse )) {
debugLog ( 'W' , " Aucune info bourse pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet ); // @todo A voir
}
$tabRet = array ( 'Siren' => $bourse [ 'siren' ],
'RaisonSociale' => prepareString ( $bourse [ 'raisonSociale' ]),
'Adresse' => prepareString ( $bourse [ 'adresse' ]),
'Effectif' => $bourse [ 'effectif' ],
'CodeSicovam' => $bourse [ 'code_sicovam' ],
'CodeMnemo' => $bourse [ 'code_mnemo' ],
'CodeBloomberg' => $bourse [ 'code_bloomberg' ],
'CodeDatastream' => $bourse [ 'code_datastream' ],
'Isin' => $bourse [ 'code_isin' ],
'CodeRic' => $bourse [ 'code_ric' ],
'DateIntroduction' => prepareString ( $bourse [ 'dateIntroduction' ]),
'DateDerAG' => prepareString ( $bourse [ 'dateDerAG' ]),
'DateRadiation' => prepareString ( $bourse [ 'dateRadiation' ]),
'AutreIsin' => $bourse [ 'autre_isin' ],
'EligibleSRD' => $bourse [ 'eligibleSRD' ],
'EligiblePEA' => $bourse [ 'eligiblePEA' ],
'Tel' => $bourse [ 'tel1' ],
'Tel2' => $bourse [ 'tel2' ],
'Fax' => $bourse [ 'fax1' ],
'Fax2' => $bourse [ 'fax2' ],
'Web' => $bourse [ 'web' ],
'Mail' => $bourse [ 'mail' ],
'Marche' => prepareString ( $bourse [ 'marche' ]),
'Description' => prepareString ( $bourse [ 'description' ]),
'Secteur' => prepareString ( $bourse [ 'secteur' ]),
'Activite' => prepareString ( $bourse [ 'activite' ]),
'ActiviteDet' => prepareString ( $bourse [ 'activiteDet' ]),
'placeCotation' => prepareString ( $bourse [ 'placeCotation' ]),
'nombreTitres' => $bourse [ 'nombreTitres' ],
'capitalisation' => $bourse [ 'close' ] * $bourse [ 'nombreTitres' ],
'derCoursDate' => $bourse [ 'date' ],
'derCoursCloture' => $bourse [ 'close' ],
'derCoursOuverture' => $bourse [ 'open' ],
'derCoursPlusHaut' => $bourse [ 'high' ],
'derCoursPlusBas' => $bourse [ 'low' ],
'derCoursVolume' => $bourse [ 'volume' ],
'coursMin' => $bourse [ 'coursMin' ],
'coursMoy' => $bourse [ 'coursMoy' ],
'coursMax' => $bourse [ 'coursMax' ],
//'dirigeants'=>utf_prepare(unserialize($bourse['dirigeants'])),
//'actionnaires'=>utf_prepare(unserialize($bourse['actionnaires'])),
//'chiffresTrim'=>utf_prepare(unserialize($bourse['chiffresTrim'])),
);
debugLog ( 'I' , 'Nb infos retourn<72> s = ' . count ( $anns ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'bourse' , $siren , $id );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Retourne la liste des bilans disponible pour une entreprise
**
** @ param integer $siren Siren de l ' entreprise
** @ return Liste des mill<EFBFBD> simes de bilan disponibles
*/
function getListeBilans ( $siren ) {
debugLog ( 'I' , " Liste des Bilans demand<6E> e pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 ) {
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'results' => $tabRet );
}
$siren = $siren * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$mBil = new MBilans ( $siren );
2011-06-09 09:39:42 +00:00
//if (ENV=='PRD')
$tabBilans = $mBil -> listeBilans ( true );
//else $tabBilans=$mBil->listeBilans(false);
2010-11-04 11:05:01 +00:00
// @sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "WsEntreprise::getListeBilans sur $siren", print_r($tabBilans, true));
/* print_r ( $rncs -> getIdentite ( $siren ));
echo 'Dernier bilan S (simplifi<66> ) : ' . $lastBilS . '<br/>' ;
echo 'Dernier bilan N (normal) : ' . $lastBilN . '<br/>' ;
echo 'Dernier bilan C (consolid<69> ) : ' . $lastBilC . '<br/>' ;
} else {
debugLog ( 'W' , " Aucun bilan pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Aucun bilan pour le siren' ), 'result' => $tabMillesime );
}
*/
debugLog ( 'I' , 'Nb Annonces retourn<72> s = ' . count ( $tabBilans ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabBilans );
}
/** Liste des 3000 premiers <EFBFBD> tablissements d ' une entreprise
**
** @ param integer $siren Siren de l ' entreprise
** @ param integer $departement Limiter aux <EFBFBD> tablissements du departement
** @ param boolean $actif Otpionnel 1 = Uniquements les actifs , 0 = inactifs , N<EFBFBD> ant = Tous
**
** @ return Liste des <EFBFBD> tablissements disponible
**/
function getListeEtablissements ( $siren , $dep = 0 , $actif =- 1 ) {
debugLog ( 'I' , " Liste des <20> tablissements demand<6E> e pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 ) {
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'results' => $tabRet );
}
$siren = $siren * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$rep = $this -> iInsee -> getEtablissements ( $siren , '' , 0 , 3000 , 3000 , $departement , $actif );
$etabs = $rep [ 'reponses' ];
$tabRet = array ();
foreach ( $etabs as $nb => $etab ) {
$tabRet [] = array ( 'id' => $etab [ 'id' ],
'Siege' => $etab [ 'Siege' ],
'Enseigne' => prepareString ( $etab [ 'Enseigne' ]),
'Adresse' => prepareString ( $etab [ 'Adresse' ]),
'Adresse2' => prepareString ( $etab [ 'Adresse2' ]),
'CP' => $etab [ 'CP' ],
'Ville' => prepareString ( $etab [ 'Ville' ]),
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ],
'NafEtabLib' => prepareString ( $etab [ 'NafEtabLib' ]),
'EffEtTr' => $etab [ 'EffEtTr' ],
'EffEtTrLib' => prepareString ( $etab [ 'EffEtTrLib' ]),
);
}
debugLog ( 'I' , " Nb Etablissements retourn<72> s ( $departement , $actif ) = " . count ( $tabRet ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'etablissements' , $siren );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Liste de tous les <EFBFBD> v<EFBFBD> nements enregistr<EFBFBD> s <EFBFBD> l ' INSEE pour une entreprise
**
** @ param integer $siren Siren de l ' entreprise
** @ return Liste des <EFBFBD> v<EFBFBD> nements INSEE de l ' entreprise
**/
function getListeEvenements ( $siren , $nic = 0 , $deb = 0 , $max = 1000 ) {
debugLog ( 'I' , " Liste des <20> v<EFBFBD> nements pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 ) {
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'results' => $tabRet );
}
$siren = $siren * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$evens = $this -> iInsee -> getEvenements ( $siren , $nic , $deb , $max );
$tabRet = array ();
foreach ( $evens as $nb => $even ) {
$tabRet [] = array ( 'Nic' => $even [ 'nic' ],
'Siege' => $even [ 'siege' ],
'SiretAss' => $even [ 'siretAssocie' ],
'TypeSiretAss' => prepareString ( $even [ 'typeSiretAss' ]),
'EvenCode' => $even [ 'codeEven' ],
'EvenLib' => prepareString ( $even [ 'libEven' ]),
'EvenLibDet' => prepareString ( $even [ 'libEvenDet' ]),
'EvenDate' => $even [ 'dateEven' ],
'DateInfo' => $even [ 'dateMAJ' ],
);
}
/*
$iRncs = new MRncs ();
$evens = $iRncs -> getEvenements ( $siren );
foreach ( $evens as $nb => $even )
$tabRet [] = array ( 'Nic' => $even [ 'nic' ],
'Siege' => $even [ 'siege' ],
'SiretAss' => $even [ 'siretAssocie' ],
'TypeSiretAss' => prepareString ( $even [ 'typeSiretAss' ]),
'EvenCode' => $even [ 'codeEven' ],
'EvenLib' => prepareString ( $even [ 'libEven' ]),
'EvenLibDet' => prepareString ( $even [ 'libEvenDet' ]),
'EvenDate' => $even [ 'dateEven' ],
'DateInfo' => $even [ 'dateMAJ' ],
);
*/
debugLog ( 'I' , 'Nb <20> v<EFBFBD> nements retourn<72> s = ' . count ( $tabRet ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
//wsLog('etablissements',$siren);
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Retourne le bilan correspondant au siren , <EFBFBD> l ' exercice et au formalisme demand<EFBFBD> .
**
** @ param integer $siren Siren de l ' entreprise
** @ param string $millesime Date du bilan au format JJ\MM\AAAA
** @ param string $typeBilan N = R<EFBFBD> el Normal , S = R<EFBFBD> el Simplifi<EFBFBD> , C = Consolid<EFBFBD>
** @ param string $ref R<EFBFBD> f<EFBFBD> rence S & D obligatoire
** @ return Ensemble des postes du Bilan au formalisme demand<EFBFBD> e
*/
function getBilan ( $siren , $millesime , $typeBilan = 'N' , $ref = '' ) {
debugLog ( 'I' , " Bilan $millesime $typeBilan demand<6E> e pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 ) {
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'results' => $tabRet );
}
$siren = $siren * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$mBil = new MBilans ( $siren );
$tabBilan = $mBil -> getBilan ( $millesime , $typeBilan , $ref , true );
//global $tabInfoUser;
2011-06-09 09:39:42 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " Debug Bilan Siren= $siren , Millesime= $millesime , Type= $typeBilan , Ref= $ref " , print_r ( $tabBilan , true )) ;
2010-11-04 11:05:01 +00:00
/* print_r ( $rncs -> getIdentite ( $siren ));
echo 'Dernier bilan S (simplifi<66> ) : ' . $lastBilS . '<br/>' ;
echo 'Dernier bilan N (normal) : ' . $lastBilN . '<br/>' ;
echo 'Dernier bilan C (consolid<69> ) : ' . $lastBilC . '<br/>' ;
} else {
debugLog ( 'W' , " Aucun bilan pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Aucun bilan pour le siren' ), 'result' => $tabMillesime );
}
*/
//debugLog('I', 'Nb Annonces retourn<72> s = '. count($anns), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabBilan );
}
function getRatios ( $siren , $page = 'ratios' ) {
$tabRatiosInfos = $tabRatiosSecteurs = $tabBilansR = $tabRatios2 = $tabRatiosEvol = array ();
global $tva , $tabFormules , $mBil , $tabBilan , $efftr ;
debugLog ( 'I' , " Liste des Ratios demand<6E> e pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 ) {
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'results' => $tabRet );
}
$siren = $siren * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
debugLog ( 'I' , " Liste des Ratios demand<6E> e pour $siren avant getIdentiteEntreprise " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabIdentite = $this -> iInsee -> getIdentiteEntreprise ( $siren , 0 , 0 , false , false );
debugLog ( 'I' , " Liste des Ratios demand<6E> e pour $siren apr<70> s getIdentiteEntreprise " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$naf = $tabIdentite [ 'NafEnt' ];
$nafLib = $tabIdentite [ 'NafEntLib' ];
$efftr = $tabIdentite [ 'Effectif' ] * 1 ;
$fj = $tabIdentite [ 'FJ' ];
$mBil = new MBilans ( $siren );
$tabBilans = $mBil -> listeBilans ( true );
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getRatios sur $siren", print_r($tabBilans, true));
$nbBilans = count ( $tabBilans );
$tabBilan = $tabBil = array ();
if ( $nbBilans > 0 )
$tabRatios =@ calculRatios ( $tabBilans , $tabIdentite , true );
$nbRatios = count ( $tabRatios );
debugLog ( 'I' , " Liste des Ratios demand<6E> e pour $siren apr<70> s calculRatios ( $nbRatios ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
/** Tableau d'infos sur les formules **/
$tabBorneMin = $tabBorneMax = array ();
foreach ( $tabFormules as $formule ) {
$id = $formule [ 'id' ] * 1 ;
$libelle = $formule [ 'libelle' ];
$unite = $formule [ 'unite' ];
$commentaires = $formule [ 'commentaires' ];
// Utilisation d'un index texte <20> cause du webservice
$tabRatiosInfos [ 'r' . $id ] = array ( 'libelle' => prepareString ( $formule [ 'libelle' ]),
'unite' => $formule [ 'unite' ],
//'borneMin' => $formule['borneMin'],
//'borneMax' => $formule['borneMax'],
'commentaires' => prepareString ( $formule [ 'commentaires' ]),
);
$tabBorneMin [ $id ] = $formule [ 'borneMin' ];
$tabBorneMax [ $id ] = $formule [ 'borneMax' ];
}
/** Tanleau des ann<6E> es de bilans **/
$tabAnnees = array ();
// Tableau d'infos sur les bilans
foreach ( $tabRatios as $i => $R ) {
$tabBilansR [ $i ] = array ( 'dateCloture' => $tabBilan [ $i ][ 'DATE_CLOTURE' ],
'duree' => $tabBilan [ $i ][ 'DUREE_MOIS' ],
'devise' => $tabBilan [ $i ][ 'MONNAIE' ],
'typeBilan' => $tabBilan [ $i ][ 'CONSOLIDE' ],
'unite' => 'U' ,
);
if ( substr ( $tabBilan [ $i ][ 'DATE_CLOTURE' ], 0 , 4 ) > 1900 )
$tabAnnees [ $i ] = substr ( $tabBilan [ $i ][ 'DATE_CLOTURE' ], 0 , 4 );
}
foreach ( $tabRatios as $i => $R ) {
// Utilisation d'un index texte <20> cause du webservice
foreach ( $R as $Ridx => $Rmont ) {
if ( $Rmont <> 'NS' ) {
if ( $tabBorneMin [ $Ridx ] <> '' && $Rmont < $tabBorneMin [ $Ridx ])
$Rmont = '<' . $tabBorneMin [ $Ridx ];
elseif ( $tabBorneMax [ $Ridx ] <> '' && $Rmont > $tabBorneMax [ $Ridx ])
$Rmont = '>' . $tabBorneMax [ $Ridx ];
}
if ( substr ( $Rmont , 0 , 1 ) == 'N' || substr ( $Rmont , 0 , 1 ) == '<' || substr ( $Rmont , 0 , 1 ) == '>' )
$tabRatios2 [ $i ][ 'r' . $Ridx ] = $Rmont ;
else
$tabRatios2 [ $i ][ 'r' . $Ridx ] = round ( $Rmont , 2 );
if ( ( $tabBilan [ $i ][ 'CONSOLIDE' ] == 'S' && isset ( $tabRatios [ $i + 1 ]) && ( $tabBilan [ $i + 1 ][ 'CONSOLIDE' ] == 'S' || ( $tabBilan [ $i + 1 ][ 'CONSOLIDE' ] == 'N' && $tabBilan [ $i + 1 ][ 'DATE_CLOTURE' ] <> $tabBilan [ $i ][ 'DATE_CLOTURE' ])))
|| ( $tabBilan [ $i ][ 'CONSOLIDE' ] == 'N' && isset ( $tabRatios [ $i + 1 ]) && ( $tabBilan [ $i + 1 ][ 'CONSOLIDE' ] == 'N' || ( $tabBilan [ $i + 1 ][ 'CONSOLIDE' ] == 'S' && $tabBilan [ $i + 1 ][ 'DATE_CLOTURE' ] <> $tabBilan [ $i ][ 'DATE_CLOTURE' ])))
)
$Rmont = (( $R [ $Ridx ] - $tabRatios [ $i + 1 ][ $Ridx ]) * 100 ) / abs ( $tabRatios [ $i + 1 ][ $Ridx ]);
elseif ( ( $tabBilan [ $i ][ 'CONSOLIDE' ] == 'S' && isset ( $tabRatios [ $i + 1 ]) && ( $tabBilan [ $i + 2 ][ 'CONSOLIDE' ] == 'S' || ( $tabBilan [ $i + 2 ][ 'CONSOLIDE' ] == 'N' && $tabBilan [ $i + 2 ][ 'DATE_CLOTURE' ] <> $tabBilan [ $i ][ 'DATE_CLOTURE' ])))
|| ( $tabBilan [ $i ][ 'CONSOLIDE' ] == 'N' && isset ( $tabRatios [ $i + 1 ]) && ( $tabBilan [ $i + 2 ][ 'CONSOLIDE' ] == 'N' || ( $tabBilan [ $i + 2 ][ 'CONSOLIDE' ] == 'S' && $tabBilan [ $i + 2 ][ 'DATE_CLOTURE' ] <> $tabBilan [ $i ][ 'DATE_CLOTURE' ])))
)
$Rmont = (( $R [ $Ridx ] - $tabRatios [ $i + 2 ][ $Ridx ]) * 100 ) / abs ( $tabRatios [ $i + 2 ][ $Ridx ]);
else
$Rmont = 'NS' ;
if ( $Rmont == 'NS' || $Rmont <- 800 || $Rmont > 800 )
$tabRatiosEvol [ $i ][ 'r' . $Ridx ] = 'NS' ;
else
$tabRatiosEvol [ $i ][ 'r' . $Ridx ] =@ number_format ( $Rmont , 2 , ',' , ' ' );
// debugLog('I',"Liste des Ratios demand<6E> e pour $siren ratio $i, $Ridx=$Rmont",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
}
}
debugLog ( 'I' , " Liste des Ratios demand<6E> e pour $siren apr<70> s EVOLUTION " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
/** Tableau des ratios secteurs */
$tabRatiosSecteurs = array ();
if ( strlen ( $naf ) > 4 ) $strNaf = " AND naf5=' $naf ' " ;
else $strNaf = " AND naf4=' $naf ' " ;
$strAnnees = implode ( ',' , $tabAnnees );
if ( count ( $tabAnnees ) > 0 ) {
$iDb = new WDB ( 'jo' );
$tabTmp = $iDb -> select ( 'ratios_secteurs' , 'annee, naf5, naf4, id, (montant/nombre) AS ratio, nombre' , " 1 $strNaf AND annee IN ( $strAnnees ) ORDER BY annee DESC, id ASC " , true , MYSQL_ASSOC );
$nbRatiosSec = 0 ;
$anneePre = $tabTmp [ 0 ][ 'annee' ];
$iAn = 0 ;
foreach ( $tabTmp as $tabTmp2 ) {
if ( $anneePre <> $tabTmp2 [ 'annee' ]) $iAn ++ ;
$Ridx = $tabTmp2 [ 'id' ];
if ( $tabTmp2 [ 'nombre' ] > $nbRatiosSec ) $nbRatiosSec = $tabTmp2 [ 'nombre' ];
if ( $tabRatiosInfos [ 'r' . $Ridx ][ 'unite' ] == 'EUR' ) $montant = round ( $tabTmp2 [ 'ratio' ] * 1000 );
else $montant = round ( $tabTmp2 [ 'ratio' ]);
if ( $tabBorneMin [ $Ridx ] <> '' && $montant < $tabBorneMin [ $Ridx ])
$montant = '<' . $tabBorneMin [ $Ridx ];
elseif ( $tabBorneMax [ $Ridx ] <> '' && $montant > $tabBorneMax [ $Ridx ])
$montant = '>' . $tabBorneMax [ $Ridx ];
if ( substr ( $montant , 0 , 1 ) == 'N' || substr ( $montant , 0 , 1 ) == '<' || substr ( $montant , 0 , 1 ) == '>' )
$tabRatiosSecteurs [ $iAn ][ 'r' . $Ridx ] = $montant ;
else
$tabRatiosSecteurs [ $iAn ][ 'r' . $Ridx ] = round ( $montant , 2 );
// $tabRatiosSecteurs[$iAn]['r'.$Ridx]=$montant;
$anneePre = $tabTmp2 [ 'annee' ];
//$tabRatiosSecteurs=array('titi');
}
}
//$tabRatiosSecteurs=array(count($tabTmp), "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC");
$tabRet = array ( 'Nom' => prepareString ( $tabIdentite [ 'Nom' ]),
'NafEnt' => $tabIdentite [ 'NafEnt' ],
'NafEntLib' => prepareString ( $tabIdentite [ 'NafEntLib' ]),
'FJ' => $fj ,
'FJ_lib' => prepareString ( $tabIdentite [ 'FJ_lib' ]),
'Siren' => $siren ,
'NbEntNaf' => $nbRatiosSec ,
'BilansInfos' => $tabBilansR ,
'RatiosInfos' => $tabRatiosInfos ,
'RatiosEntrep' => $tabRatios2 ,
'RatiosEntrepEvol' => $tabRatiosEvol ,
'RatiosSecteur' => $tabRatiosSecteurs ,
);
debugLog ( 'I' , " Liste des Ratios demand<6E> e pour $siren RETURN " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( $page , $siren );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
function getListeBilanImage ( $siren ) {
/* array ( 'num_gest' => array ( 'greffe' => '' , 'dossier_millesime' => '' , 'dossier_statut' => '' , 'dossier_chrono' => '' ),
'num_siren' => 495251019 ,
'date_cloture' => 31 / 12 / 2007 ,
'millesime' => 2007 ,
'num_depot' => 0013755 ,
'type_comptes' => 'sociaux' ,
'mode_diffusion' =>
< mode type = " T " />
< mode type = " C " />
</ mode_diffusion >
</ bilan_complet >
</ liste_bilan_complet >*/
}
/** Retourne la liste des ratios pour une entreprise
**
** @ param integer $siren Siren de l ' entreprise
** @ return array Ratios par mill<EFBFBD> simes d<EFBFBD> croissants
*/
/** Retourne les liens financiers pour une entreprise .
**
** @ param integer $siren Siren de l ' entreprise
** @ param bool $actifsUniquement Uniquement les liens Actifs
** @ return Liste des liens financiers
*/
function getLiens ( $siren , $actifsUniquement = true ) {
debugLog ( 'I' , " Liens entreprises demand<6E> s pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = $tabAct = $tabPar = array ();
if ( strlen ( $siren ) <> 9 ) {
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'results' => $tabRet );
}
$siren = $siren * 1 ;
if ( $siren == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$mLiens = new MLiens ( $siren );
$tabA = $mLiens -> getActionnaires ( $siren , $actifsUniquement );
$nbA = count ( $tabA );
foreach ( $tabA as $i => $lien )
$tabAct [] = array ( 'Pmin' => $lien [ 'Pmin' ],
'MajMin' => $lien [ 'MajMin' ],
'RaisonSociale' => prepareString ( $lien [ 'RaisonSociale' ]),
'Pays' => prepareString ( $lien [ 'Pays' ]),
'Siren' => $lien [ 'Siren' ],
'Actif' => $lien [ 'Actif' ],
'Source' => prepareString ( $lien [ 'Source' ]),
'DateLien' => @ $lien [ 'DateLien' ],
'DateMaj' => @ $lien [ 'DateMaj' ],
);
debugLog ( 'W' , " $nbA actionnaires pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabP = $mLiens -> getParticipations ( $siren , $actifsUniquement );
$nbP = count ( $tabP );
foreach ( $tabP as $i => $lien )
$tabPar [] = array ( 'Pmin' => $lien [ 'Pmin' ],
'MajMin' => $lien [ 'MajMin' ],
'RaisonSociale' => prepareString ( $lien [ 'RaisonSociale' ]),
'Pays' => prepareString ( $lien [ 'Pays' ]),
'Siren' => $lien [ 'Siren' ],
'Actif' => $lien [ 'Actif' ],
'Source' => prepareString ( $lien [ 'Source' ]),
'DateLien' => @ $lien [ 'DateLien' ],
'DateMaj' => @ $lien [ 'DateMaj' ],
);
debugLog ( 'W' , " $nbP participations pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'liens' , $siren );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => array ( 'actionnaires' => $tabAct ,
'participations' => $tabPar ));
}
/** Evaluation indiScore d ' une entreprise
**
** @ param integer $siren Siren de l ' entreprise
** @ return Evaluation indiScore de l ' entreprise
**/
2011-01-10 17:05:54 +00:00
function getIndiScore ( $siren , $nic = 0 , $accesDist = true , $niveau = 2 , $plus = false ) {
global $tabInfoUser ;
2010-11-04 11:05:01 +00:00
$niveau = $niveau * 1 ;
if ( $niveau <> 0 && $niveau <> 1 && $niveau <> 2 && $niveau <> 3 && $niveau <> 4 && $niveau <> 5 ) $niveau = 2 ;
debugLog ( 'I' , " IndiScore demand<6E> e pour $siren en niveau $niveau " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) > 9 || ( substr ( '' . $siren , 0 , 9 ) * 1 ) < 100 ) {
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren Siret inexistant' ), 'result' => $tabRet );
}
$tDeb = microtime ( true );
include_once ( INCLUDE_PATH . 'scores/classMScores.php' );
$tabRet = calculIndiScore ( $siren , $nic , $accesDist , $niveau );
$duree = round ( microtime ( true ) - $tDeb , 3 );
debugLog ( 'W' , " indiscore DUREE = $duree s " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'indiscore' , $siren );
2011-01-10 17:05:54 +00:00
if ( $plus ) {
$this -> setSurveillance ( $siren , $tabInfoUser [ 'email' ], 'Indiscore+' , 'privileges' , false , 0 );
$this -> setSurveillance ( $siren , $tabInfoUser [ 'email' ], 'Indiscore+' , 'score' );
if ( $tabInfoUser [ 'idClient' ] == 89 )
$this -> setSurveillance ( $siren , $tabInfoUser [ 'email' ], 'Indiscore+' , 'annonces' );
}
2010-11-04 11:05:01 +00:00
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
2011-03-24 15:11:22 +00:00
2010-11-04 11:05:01 +00:00
/** Enter description here ...
** @ nodoc
** @ param unknown_type $from
** @ param unknown_type $arrayTo
** @ param unknown_type $subject
** @ param unknown_type $text
** @ param unknown_type $html
** @ param unknown_type $priority
** @ param unknown_type $tabImgFiles
** @ param unknown_type $tabAttachedFiles
**/
function sendMail ( $from , $arrayTo , $subject , $text = '' , $html = '' , $priority = 'high' , $tabImgFiles = array (), $tabAttachedFiles = array ()) {
include_once ( FWK_PATH . 'common/mail.php' );
$mail = new htmlMimeMail5 ();
/** Set the from address **/
$mail -> setFrom ( $from ); //'Richard <richard@example.com>
/** Set the subject **/
$mail -> setSubject ( 'Test email' );
/** Set high priority **/
$mail -> setPriority ( $priority );
/** Set the text of the Email **/
$mail -> setText ( $text );
/** Set the HTML of the email **/
if ( $html <> '' )
$mail -> setHTML ( $html ); //'<b>Sample HTML</b> <img src="background.gif">');
/** Add an embedded image **/
if ( count ( $tabImgFiles ) > 0 )
$mail -> addEmbeddedImage ( new fileEmbeddedImage ( 'background.gif' ));
/** Add an attachment **/
if ( count ( $tabAttachedFiles ) > 0 )
$mail -> addAttachment ( new fileAttachment ( 'example.zip' ));
/** Send the email **/
$mail -> send ( $arrayTo ); //array('richard@example.com')
}
/** Enter description here ...
** @ nodoc
**/
function getListeCompetences ( $siret , $type , $codeInsee ) {
$type = strtolower ( $type );
debugLog ( 'I' , " Liste des comp<6D> tences $type demand<6E> e pour la commune $codeInsee " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$iBodacc = new MBodacc ();
$cp = $codeInsee * 1 ;
$dep = false ;
if ( substr ( $codeInsee , 0 , 2 ) == '2A' ||
substr ( $codeInsee , 0 , 2 ) == '2B' ) { $dep = 20 ; $cp = 20000 + ( substr ( $codeInsee , 2 , 3 )) * 1 ; }
elseif ( $cp > 0 && $cp < 100 ) $dep = $cp ;
elseif ( $cp > 970 && $cp < 977 ) $dep = $cp ;
elseif ( $cp > 999 && $cp < 10000 ) $dep = '0' . substr ( $cp , 0 , 1 );
elseif ( $cp >= 10000 && $cp < 96000 ) $dep = substr ( $cp , 0 , 2 );
elseif ( $cp >= 99000 ) $dep = substr ( $cp , 0 , 2 );
elseif ( $cp >= 98000 ) $dep = substr ( $cp , 0 , 3 );
elseif ( $cp >= 97100 && $cp < 97700 ) $dep = substr ( $cp , 0 , 3 );
if ( $type == 'pre' ) {
$iDb = new WDB ( 'jo' );
$tabTmp2 = $iDb -> select ( 'villes' , 'DEP, COM, AR, CT' , 'codeInsee=' . $codeInsee , false , MYSQL_ASSOC );
$arrond = $tabTmp2 [ 0 ][ 'AR' ];
unset ( $iDb );
$iDb = new WDB ( 'insee' );
$tabTmp2 = $iDb -> select ( 'insee_tabArrond' , 'CHEFLIEU, ARTMAJ, NCC' , " DEP=' $dep ' AND AR=' $arrond ' " , false , MYSQL_ASSOC );
$nomSousPref = trim ( strtr ( $tabTmp2 [ 0 ][ 'ARTMAJ' ], array ( '(' => '' , ')' => '' , ' ' => '' , " ' " => '' )) . ' ' . $tabTmp2 [ 0 ][ 'NCC' ]);
unset ( $iDb );
$tabTmp = $iBodacc -> getTribunauxParDep ( $dep );
foreach ( $tabTmp as $i => $tribunal ) {
if ( $tribunal [ 'triType' ] == 'A' || $tribunal [ 'triType' ] == 'B' ) {
$pref = levenshtein ( $tribunal [ 'triNom' ], 'PREFECTURE DE ' . $nomSousPref );
$spref = levenshtein ( $tribunal [ 'triNom' ], 'SOUS PREFECTURE DE ' . $nomSousPref );
if ( $tribunal [ 'triType' ] == 'B' && ( $pref > 7 || $spref > 5 )) continue ;
$tabRet [ $i ] = array ( 'Id' => $tribunal [ 'triId' ],
'IdSup' => $tribunal [ 'triIdSup' ],
'Code' => $tribunal [ 'triCode' ],
'Type' => $tribunal [ 'triType' ] . $typeP ,
'Nom' => prepareString ( strtoupper ( $tribunal [ 'triNom' ])),
'Siret' => $tribunal [ 'triSiret' ],
'Adr' => strtoupper ( preg_replace ( '/ +/' , ' ' , $tribunal [ 'triAdrNum' ] . ' ' . $tribunal [ 'triAdrIndRep' ] . ' ' .
$tribunal [ 'triAdrTypeVoie' ] . ' ' . prepareString ( $tribunal [ 'triAdrVoie' ]))),
'AdrComp' => prepareString ( strtoupper ( $tribunal [ 'triAdrComp' ])),
'CP' => $tribunal [ 'triCP' ],
'Ville' => prepareString ( strtoupper ( $tribunal [ 'triVille' ])),
'CodeInsee' => $tribunal [ 'CodeInsee' ],
'Tel' => $tribunal [ 'triTel' ],
'Fax' => $tribunal [ 'triFax' ],
'Web' => $tribunal [ 'triWeb' ],
'Mail' => $tribunal [ 'triMail' ],
'Statut' => prepareString ( $tribunal [ 'triStatut' ]),
'DateCessation' => $tribunal [ 'triDateCessation' ],
'Remarque' => prepareString ( $tribunal [ 'triCommentaire' ]),
);
}
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
} elseif ( $type == 'jal' ) {
$tabTmp = $iBodacc -> getJALparDep ( $dep );
foreach ( $tabTmp as $i => $comp ) {
$infos = '' ;
if ( trim ( $comp [ 'parution' ]) <> '' ) $infos .= 'Parution ' . $comp [ 'parution' ] . '. ' ;
if ( trim ( $comp [ 'aboAnnuel' ]) > 0 ) $infos .= 'Abonnement Annuel : ' . $comp [ 'aboAnnuel' ] . ' euros. ' ;
if ( trim ( $comp [ 'infos' ]) <> '' ) $infos .= $comp [ 'infos' ];
$tabRet [ $i ] = array ( 'Id' => 9000 + $comp [ 'id' ] * 1 ,
'IdSup' => 0 ,
'Code' => '' ,
'Type' => '' ,
'Nom' => prepareString ( strtoupper ( $comp [ 'nomJal' ])),
'Siret' => '' ,
'Adr' => strtoupper ( prepareString ( $comp [ 'adresse' ])),
'AdrComp' => '' ,
'CP' => prepareString ( $comp [ 'cp' ]),
'Ville' => prepareString ( strtoupper ( $comp [ 'ville' ])),
'CodeInsee' => '' ,
'Tel' => prepareString ( $comp [ 'tel' ]),
'Fax' => prepareString ( $comp [ 'fax' ]),
'Web' => prepareString ( $comp [ 'siteWeb' ]),
'Mail' => prepareString ( $comp [ 'email' ]),
'Statut' => prepareString ( 'Actif' ),
'DateCessation' => '' ,
'Remarque' => prepareString ( trim ( $infos )),
);
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
} elseif ( $type == 'tri' || $type == 'adm' || $type == 'hui' ) {
$tabTmp = $iBodacc -> getTribunauxParCommune ( $codeInsee );
foreach ( $tabTmp as $i => $tribunal ) {
if ( //$tribunal['triType']=='C' ||
$tribunal [ 'triType' ] == 'G' // ||
/*$tribunal['triType']=='I'*/ ) {
$idCA = $tribunal [ 'triIdSup' ];
$codeTGI = $tribunal [ 'triCode' ];
$code = strtoupper ( substr ( $tribunal [ 'triCode' ], 0 , 3 ));
}
debugLog ( 'D' , " Liste des comp<6D> tences $type demand<6E> e pour la commune $codeInsee ( $dep ) : " .
" Type= " . $tribunal [ 'triType' ] . ', ' .
" Code= " . $tribunal [ '$codeTGI' ], __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( $tribunal [ 'triType' ] <> 'E' && $tribunal [ 'triType' ] <> 'O' && $tribunal [ 'triType' ] <> 'T'
&& $tribunal [ 'triType' ] <> 'R' && $tribunal [ 'triType' ] <> 'N'
&& $tribunal [ 'triType' ] <> 'U' && $tribunal [ 'triType' ] <> 'Z' ) {
$tabRet [ $i ] = array ( 'Id' => $tribunal [ 'triId' ],
'IdSup' => $tribunal [ 'triIdSup' ],
'Code' => $tribunal [ 'triCode' ],
'Type' => $tribunal [ 'triType' ],
'Nom' => prepareString ( strtoupper ( $tribunal [ 'triNom' ])),
'Siret' => $tribunal [ 'triSiret' ],
'Adr' => strtoupper ( preg_replace ( '/ +/' , ' ' , $tribunal [ 'triAdrNum' ] . ' ' . $tribunal [ 'triAdrIndRep' ] . ' ' .
$tribunal [ 'triAdrTypeVoie' ] . ' ' . prepareString ( $tribunal [ 'triAdrVoie' ]))),
'AdrComp' => prepareString ( strtoupper ( $tribunal [ 'triAdrComp' ])),
'CP' => $tribunal [ 'triCP' ],
'Ville' => prepareString ( strtoupper ( $tribunal [ 'triVille' ])),
'CodeInsee' => $tribunal [ 'CodeInsee' ],
'Tel' => $tribunal [ 'triTel' ],
'Fax' => $tribunal [ 'triFax' ],
'Web' => $tribunal [ 'triWeb' ],
'Mail' => $tribunal [ 'triMail' ],
'Statut' => prepareString ( $tribunal [ 'triStatut' ]),
'DateCessation' => $tribunal [ 'triDateCessation' ],
'Remarque' => prepareString ( $tribunal [ 'triCommentaire' ]),
);
if ( $tribunal [ 'triNumGreffe' ] * 1 > 0 )
$tabRet [ $i ][ 'IdentifiantGreffe' ] = $tribunal [ 'triNumGreffe' ];
}
}
if ( $type == 'tri' ) return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
if ( $type == 'adm' ) {
//die($idCA);
$tabTmp = $this -> iInsee -> getMandataires ( array ( $idCA ), false );
$tabRet = array ();
$nbAff = 0 ;
foreach ( $tabTmp as $i => $tribunal ) /** @todo A revoir Debut **/
if ( stripos ( $tribunal [ 'tribunal' ], $code ) !== false || stripos ( $tribunal [ 'tribunal' ], 'SAINT' ) !== false ) {
$tabRet [ $i ] = array ( 'Id' => $tribunal [ 'id' ],
'IdSup' => $tribunal [ 'sirenGrp' ],
'Code' => prepareString ( $tribunal [ 'tribunal' ]) . '/' . $code ,
'Type' => prepareString ( $tribunal [ 'type' ]),
'Nom' => prepareString ( $tribunal [ 'Nom' ] . ' ' . $tribunal [ 'Prenom' ]),
'Siret' => $tribunal [ 'sirenMand' ],
'Adr' => prepareString ( strtoupper ( $tribunal [ 'adresse' ])),
'AdrComp' => prepareString ( strtoupper ( $tribunal [ 'adresseComp' ])),
'CP' => $tribunal [ 'cp' ],
'Ville' => prepareString ( strtoupper ( $tribunal [ 'ville' ])),
//'CodeInsee'=>$tribunal['CodeInsee'],
'Tel' => $tribunal [ 'tel' ],
'Fax' => $tribunal [ 'fax' ],
'Web' => prepareString ( $tribunal [ 'web' ]),
'Mail' => prepareString ( $tribunal [ 'email' ]),
'Statut' => prepareString ( $tribunal [ 'Statut' ]),
//'DateCessation'=>$tribunal['triDateCessation'],
'Remarque' => prepareString ( $tribunal [ 'contact' ]),
); //,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact
$nbAff ++ ;
}
if ( $nbAff == 0 ) {
foreach ( $tabTmp as $i => $tribunal )
$tabRet [ $i ] = array ( 'Id' => $tribunal [ 'id' ],
'IdSup' => $tribunal [ 'sirenGrp' ],
'Code' => prepareString ( $tribunal [ 'tribunal' ]) . '/' . $code ,
'Type' => prepareString ( $tribunal [ 'type' ]),
'Nom' => prepareString ( $tribunal [ 'Nom' ] . ' ' . $tribunal [ 'Prenom' ]),
'Siret' => $tribunal [ 'sirenMand' ],
'Adr' => prepareString ( strtoupper ( $tribunal [ 'adresse' ])),
'AdrComp' => prepareString ( strtoupper ( $tribunal [ 'adresseComp' ])),
'CP' => $tribunal [ 'cp' ],
'Ville' => prepareString ( strtoupper ( $tribunal [ 'ville' ])),
//'CodeInsee'=>$tribunal['CodeInsee'],
'Tel' => $tribunal [ 'tel' ],
'Fax' => $tribunal [ 'fax' ],
'Web' => prepareString ( $tribunal [ 'web' ]),
'Mail' => prepareString ( $tribunal [ 'email' ]),
'Statut' => prepareString ( $tribunal [ 'Statut' ]),
//'DateCessation'=>$tribunal['triDateCessation'],
'Remarque' => prepareString ( $tribunal [ 'contact' ]),
); //,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact
} /** @todo A revoir Fin : Lier correctement les mandataires <20> un TI principal **/
} elseif ( $type == 'hui' ) {
$tabTmp = $this -> iInsee -> getHuissiers ( array ( $codeTGI ), false );
$tabRet = array ();
$nbAff = 0 ;
foreach ( $tabTmp as $i => $tribunal ) {
$adr = $this -> iInsee -> structureVoie ( $tribunal [ 'adresse' ]);
$tabRet [ $i ] = array ( 'Id' => $tribunal [ 'id' ],
'IdSup' => $tribunal [ 'sirenGrp' ],
'Code' => prepareString ( $tribunal [ 'tribunal' ]) . '/' . $code ,
'Type' => prepareString ( $tribunal [ 'type' ]),
'Nom' => prepareString ( $tribunal [ 'Nom' ] . ' ' . $tribunal [ 'Prenom' ]),
'Siret' => $tribunal [ 'sirenMand' ],
'Adr' => prepareString ( strtoupper ( $adr [ 'num' ] . ' ' . $adr [ 'adr_btq' ] . ' ' .
$adr [ 'typeVoie' ] . ' ' . $adr [ 'libVoie' ])),
'AdrComp' => prepareString ( strtoupper ( $tribunal [ 'adresseComp' ])),
'CP' => $adr [ 'cp' ],
'Ville' => prepareString ( strtoupper ( $tribunal [ 'ville' ])),
//'CodeInsee'=>$tribunal['CodeInsee'],
'Tel' => $tribunal [ 'tel' ],
'Fax' => $tribunal [ 'fax' ],
'Web' => prepareString ( $tribunal [ 'web' ]),
'Mail' => prepareString ( $tribunal [ 'email' ]),
'Statut' => prepareString ( $tribunal [ 'Statut' ]),
//'DateCessation'=>$tribunal['triDateCessation'],
'Remarque' => prepareString ( strtr ( $tribunal [ 'contact' ],
array ( '<br/>' => ', ' , '<br>' => ', ' ,
'<br />' => ', ' ,
))),
);
}
$nbComp = count ( $tabTmp );
debugLog ( 'I' , " $nbComp comp<6D> tences $type trouv<75> es pour le tribunal $codeTGI " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
} elseif ( $type == 'cfe' ) {
$tabTmp = $iBodacc -> getTribunauxParCommune ( $codeInsee );
foreach ( $tabTmp as $i => $tribunal ) {
if ( $tribunal [ 'triType' ] == 'C' || $tribunal [ 'triType' ] == 'O' || $tribunal [ 'triType' ] == 'T'
|| $tribunal [ 'triType' ] == 'R' || $tribunal [ 'triType' ] == 'N'
|| $tribunal [ 'triType' ] == 'U' || $tribunal [ 'triType' ] == 'Z' ) {
if ( strlen ( $tribunal [ 'triCommentaire' ]) == 32 && strpos ( $tribunal [ 'triCommentaire' ], ' ' ) === false )
$remarque = '' ;
else $remarque = prepareString ( $tribunal [ 'triCommentaire' ]);
$tabRet [ $i ] = array ( 'Id' => $tribunal [ 'triId' ],
'IdSup' => $tribunal [ 'triIdSup' ],
'Code' => $tribunal [ 'triCode' ],
'Type' => $tribunal [ 'triType' ],
'Nom' => prepareString ( strtoupper ( $tribunal [ 'triNom' ])),
'Siret' => $tribunal [ 'triSiret' ],
'Adr' => strtoupper ( preg_replace ( '/ +/' , ' ' , $tribunal [ 'triAdrNum' ] . ' ' . $tribunal [ 'triAdrIndRep' ] . ' ' .
$tribunal [ 'triAdrTypeVoie' ] . ' ' . prepareString ( $tribunal [ 'triAdrVoie' ]))),
'AdrComp' => prepareString ( strtoupper ( $tribunal [ 'triAdrComp' ])),
'CP' => $tribunal [ 'triCP' ],
'Ville' => prepareString ( strtoupper ( $tribunal [ 'triVille' ])),
'CodeInsee' => $tribunal [ 'CodeInsee' ],
'Tel' => $tribunal [ 'triTel' ],
'Fax' => $tribunal [ 'triFax' ],
'Web' => $tribunal [ 'triWeb' ],
'Mail' => $tribunal [ 'triMail' ],
'Statut' => prepareString ( $tribunal [ 'triStatut' ]),
'DateCessation' => $tribunal [ 'triDateCessation' ],
'Remarque' => $remarque ,
);
}
}
}
wsLog ( 'competences' , $siret , $type . '/' . $codeInsee );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Enter description here ...
** @ nodoc
**/
function getListeConventions ( $siren ) {
debugLog ( 'I' , " Liste des conventions demand<6E> e pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabIdentite = $this -> iInsee -> getIdentiteEntreprise ( $siren );
if ( empty ( $tabIdentite ) && isset ( $tabIdentite [ 'erreur' ]) && $tabIdentite [ 'erreur' ] <> '' ) {
debugLog ( 'W' , " Siren $siren non pr<70> sent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 123456789 , 'errmsg' => 'Evaluation indiScore indisponible pour le siren $siren' ), 'result' => $tabRet );
}
$naf = $tabIdentite [ 'NafEnt' ];
$trancheEffectif = $tabIdentite [ 'EffEnTr' ];
$effectif = $tabIdentite [ 'Effectif' ];
$fj = $tabIdentite [ 'entreprise' ][ 'FJCodeEntrep' ];
$isolv = new MSolvabilite ( $siren , $naf , $trancheEffectif , $effectif , $tabIdentite [ 'CP' ], $fj , $tabIdentite [ 'Capital' ],
$tabIdentite [ 'CapitalDev' ], $tabIdentite [ 'DateCreaEn' ], $tabIdentite [ 'DateCreaEt' ]); //, $tabIdentite['Singularite']);
$noteStructure = $isolv -> getSolvabilite ();
$naf4 = $isolv -> getNaf4 ( $naf );
$tabTmp = $this -> iInsee -> listeConventions ( $naf4 , $tabIdentite [ 'Dept' ]);
$tabRet = array ();
foreach ( $tabTmp as $i => $conv ) {
$tabRet [ $i ] = array ( 'idCC' => prepareString ( $conv [ 'id CC' ]),
'nomCC' => prepareString ( $conv [ 'nom CC' ]),
'infoCC' => prepareString ( $conv [ 'infoCC' ]),
'editorCC' => prepareString ( $conv [ 'editeur CC' ]),
'nbPageCC' => $conv [ 'nb page CC' ],
'isbnCC' => $conv [ 'isbn CC' ],
'dateCC' => prepareString ( $conv [ 'date edition CC' ]),
'joCCmaj' => $conv [ 'joCCmaj' ],
);
}
wsLog ( 'competences' , $siren );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
2010-11-29 14:17:26 +00:00
/** Liste des marques d<EFBFBD> pos<EFBFBD> es pour une entreprise donn<EFBFBD> e
2010-11-04 11:05:01 +00:00
** @ nodoc
**/
function getMarques ( $siren , $idDepot = 0 ) {
debugLog ( 'I' , " Liste des marques d<> pos<6F> es pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$marques = array ();
$iDb = new WDB ();
2010-11-29 14:17:26 +00:00
include_once ( INCLUDE_PATH . 'partenaires/classMMarques.php' );
$iMarque = new MMarques ();
$ret = $iMarque -> getMarques ( $siren , $idDepot );
foreach ( $ret as $i => $marque ) {
if ( trim ( $marque [ 'imgLink' ]) <> '' ) $idLien = $marque [ 'numeroMarque' ];
else $idLien = '' ;
$marques [ $i ] = array ( 'Marques' => prepareString ( $marque [ 'nomMarque' ]),
'Date' => $marque [ 'dateDepot' ],
'Depot' => $marque [ 'numeroMarque' ],
'IdLien' => $idLien ,
'UrlLien' => $marque [ 'UrlLien' ], // Rempli que si $idDepot<>0
'PdfDispo' => $marque [ 'pdfLink' ], // Nouveau
);
if ( $idDepot == $marque [ 'numeroMarque' ]) {
$marques [ $i ][ 'Classes' ] = $marque [ 'classesMarque' ]; // Nouveau
$marques [ $i ][ 'Perimetre' ] = prepareString ( $marque [ 'periMarque' ]); // Nouveau
$marques [ $i ][ 'DateExpir' ] = $marque [ 'dateExpir' ]; // Nouveau
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => array ( end ( $marques )));
2010-11-04 11:05:01 +00:00
}
}
2010-11-29 14:17:26 +00:00
/* $res = $iDb -> select ( 'marques' , 'Marques,Date,Depot,IdLien, DATEDIFF(NOW(),dateUpdate) AS nbJourLastUpdate' , " Siren= $siren ORDER BY `Date` DESC " );
2010-11-04 11:05:01 +00:00
if ( count ( $res ) > 0 ) {
foreach ( $res as $i => $marque ) {
$marques [ $i ] = array ( 'Marques' => prepareString ( $marque [ 'Marques' ]),
'Date' => prepareString ( $marque [ 'Date' ]),
'Depot' => prepareString ( $marque [ 'Depot' ]),
'IdLien' => prepareString ( $marque [ 'IdLien' ]),
);
if ( $idDepot <> 0 ) {
$marques [ $i ][ 'UrlLien' ] = DOC_WEB_URL . " marques/ $siren - $idDepot .jpg " ;
if ( $marque [ 'IdLien' ] == $idDepot ) {
if ( ! file_exists ( DOC_WEB_LOCAL . " marques/ $siren - $idDepot .jpg " ) ||
filesize ( DOC_WEB_LOCAL . " marques/ $siren - $idDepot .jpg " ) < 43 ) {
// $url=;
// filesize("/var/www/site_extranet/www/pdf/acte-$siren-$option.pdf")==0) {
$tdeb = microtime ( true );
$page = getUrl ( " http://www.societe.com/cgi-bin/consultcgi?en= $idDepot " , '' , '' , '' , false , '' , '' , 21 );
$tfin = microtime ( true );
$duree = $tfin - $tdeb ;
$body = $page [ 'body' ];
$fp =@ fopen ( DOC_WEB_LOCAL . " marques/ $siren - $idDepot .jpg " , 'w' );
@ fwrite ( $fp , $body );
@ fclose ( $fp );
$fp =@ fopen ( " /var/www/log/marques.log " , " a " );
@ fwrite ( $fp , date ( 'Y-m-d H:i:s' ) . " ; $siren ; $idDepot ; $duree\n " );
@ fclose ( $fp );
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => array ( end ( $marques )));
}
}
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $marques );
}
2010-11-29 14:17:26 +00:00
*/
2010-11-04 11:05:01 +00:00
wsLog ( 'marques' , $siren );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $marques );
}
/** Enter description here ...
** @ nodoc
**/
function getDevises ( $codeIsoDevise = '' ) {
debugLog ( 'I' , " Liste des devises ou devise $codeIsoDevise demand<6E> e " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabTmp = $this -> iInsee -> getDevises ( $codeIsoDevise );
$tabRet = array ();
foreach ( $tabTmp as $i => $devise )
$tabRet [ $i ] = prepareString ( $devise );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Retourne la liste des tribunaux ou Comp<EFBFBD> tences demand<EFBFBD> es
**
** @ param array $tabTypes Tableau des types de Comp<EFBFBD> tences demand<EFBFBD> s 'C' : Commerce , 'I' : Instance , 'G' : TGI , 'A' : Pr<EFBFBD> fectures , 'B' : Sous - pr<EFBFBD> f , 'D' : Tribunal Administratif , 'H' : Prud 'hommes, ' L ': Cour d' Appel , 'M' : Tribunal Mixte , 'O' : CCI , 'V' : Cour Administrative d ' Appel
** @ return unknown
**/
function getTribunaux ( $tabTypes = array ()) {
$iBodacc = new MBodacc ();
debugLog ( 'I' , " Liste des tribunaux demand<6E> es " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabTmp = $iBodacc -> getListeTribunaux ();
$tabRet = array ();
if ( count ( $tabTypes ) == 0 )
foreach ( $tabTmp as $i => $tribunal )
$tabRet [ $i ] = prepareString ( $tribunal [ 'nom' ]);
else
foreach ( $tabTmp as $i => $tribunal ) {
$type = substr ( $i , - 1 );
if ( in_array ( $type , $tabTypes ))
$tabRet [ $i ] = prepareString ( $tribunal [ 'nom' ]);
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Enter description here ...
** @ nodoc
**/
function getListeJalCollecte () {
$iBodacc = new MBodacc ();
$tabRet = $iBodacc -> getListeJalCollecte ();
foreach ( $tabRet as $i => $jal )
$tabRet [ $i ] = prepareString ( $jal );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Liste les mandataires comp<EFBFBD> tentes pour une cours d ' appel donn<EFBFBD> e
**
** @ param mixed $codeTribunal Identifiants BODACC du tribunal ou tableau d 'Identifiants num<75> riques des cours d' appel
** @ param array $type Type de mandataire ( A ) dministrateur , ( M ) andataire , ( O ) ppositions , ( N ) otaires , a ( V ) ocat
** @ return Liste des mandataires en tableau
**/
function getMandataires ( $codeTribunal = 0 , $type = array ( 'A' , 'M' )) {
$trib = serialize ( $codeTribunal );
debugLog ( 'I' , " Liste des Mandaitaires ou Administrateur du Tribunal/Cours d'Appel $trib demand<6E> " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( ! is_array ( $codeTribunal ) && strlen ( $codeTribunal ) > 3 && $codeTribunal * 1 == 0 ) {
// $codeTribunal est un identifiant de tribunal
$iBodacc = new MBodacc ();
$tabTmp = $this -> iInsee -> getMandataires ( array ( $iBodacc -> getTribunalIdCA ( $codeTribunal )), true , $type );
} elseif ( $codeTribunal * 1 == 0 ) {
// On veut tous les mandataires
$tabTmp = $this -> iInsee -> getMandataires ( array (), true , $type );
} elseif ( is_array ( $codeTribunal )) {
// On veut les mandataires d'une CA
$tabTmp = $this -> iInsee -> getMandataires ( $codeTribunal , true , $type );
}
$tabRet = array ();
foreach ( $tabTmp as $i => $mand )
$tabRet [ 'm' . $i ] = prepareString ( $mand );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Liste les mandataires correspondant <EFBFBD> un nom donn<EFBFBD>
**
** @ param mixed $codeTribunal Identifiants BODACC du tribunal ou tableau d 'Identifiants num<75> riques des cours d' appel
** @ param array $type Type de mandataire ( A ) dministrateur , ( M ) andataire , ( O ) ppositions , ( N ) otaires , a ( V ) ocat
** @ param int $cpDep Code postal ou d<EFBFBD> partement du mandataire
** @ return Liste des mandataires en tableau
**/
function searchMandataires ( $nom , $type = array ( 'A' , 'M' ), $cpDep = 0 ) {
debugLog ( 'I' , " Recherche de Mandataires ' $nom ' (Dep= $cpDep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabTmp = $this -> iInsee -> searchMandataires ( $nom , true , $type , $cpDep );
$tabRet = array ();
foreach ( $tabTmp as $i => $mand )
$tabRet [ 'm' . $i ] = prepareString ( $mand );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** R<EFBFBD> cup<EFBFBD> re le mandataire par son id
** @ nodoc
**
** @ param integer $idMand Identifiant du mandataire
**
** @ return array Information sur le mandataire
**/
function getMandataire ( $idMand ) {
debugLog ( 'I' , " Donne le Mandataires correspondant <20> $idMand " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = $this -> iInsee -> getMandataire ( $idMand );
$tabRet [ 'Nom' ] = prepareString ( $tabRet [ 'Nom' ]);
$tabRet [ 'Prenom' ] = prepareString ( $tabRet [ 'Prenom' ]);
$tabRet [ 'tribunal' ] = prepareString ( $tabRet [ 'tribunal' ]);
$tabRet [ 'adresse' ] = prepareString ( $tabRet [ 'adresse' ]);
$tabRet [ 'adresseComp' ] = prepareString ( $tabRet [ 'adresseComp' ]);
$tabRet [ 'ville' ] = prepareString ( $tabRet [ 'ville' ]);
$tabRet [ 'email' ] = prepareString ( $tabRet [ 'email' ]);
$tabRet [ 'web' ] = prepareString ( $tabRet [ 'web' ]);
$tabRet [ 'contact' ] = prepareString ( $tabRet [ 'contact' ]);
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/** Met a jour les informations sur un mandataire
**
** @ param array $tabInfos Tableau des informations sur le mandataire <EFBFBD> cr<EFBFBD> er ou <EFBFBD> ajouter ( ajout si id absent )
**
** @ return boolean
**/
function setMandataire ( $tabInfos = array ()) {
global $iDbCrm , $tabInfoUser ;
$iDb = new WDB ();
/** Nom et Identifiant de l'op<6F> rateur de saisie **/
$rep = $iDbCrm -> select ( 'utilisateurs' , 'id' , " login=' " . $tabInfoUser [ 'login' ] . " ' " );
$idUser = $rep [ 0 ][ 0 ];
$infos = serialize ( $tabInfos );
debugLog ( 'I' , " Ajout/MAJ de mandaitaire $infos demand<6E> e " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$type = substr ( strtoupper ( $tabInfos [ 'type' ]), 0 , 1 );
$stag = substr ( strtoupper ( $tabInfos [ 'type' ]), 1 , 1 );
if ( $stag == 'S' ) $stag = 1 ; else $stag = 0 ;
if ( $type == 'A' || $type == 'H' || $type == 'M' || $type == 'V' || $type == 'N' || $type == 'T' ) {
$tabUpdate = array ( 'sirenGrp' => substr ( $tabInfos [ 'sirenGrp' ], 0 , 9 ) * 1 ,
'nicGrp' => substr ( $tabInfos [ 'sirenGrp' ], 9 , 5 ) * 1 ,
'sirenMand' => substr ( $tabInfos [ 'sirenMand' ], 0 , 9 ) * 1 ,
'nicMand' => substr ( $tabInfos [ 'sirenMand' ], 9 , 5 ) * 1 ,
'Nom' => ucwords ( strtolower ( $tabInfos [ 'Nom' ])),
'Prenom' => ucwords ( strtolower ( $tabInfos [ 'Prenom' ])),
'type' => $type ,
'stagiaire' => $stag ,
'coursAppel' => $tabInfos [ 'coursAppel' ] * 1 ,
'coursAppel2' => $tabInfos [ 'coursAppel2' ] * 1 ,
'tribunal' => $tabInfos [ 'tribunal' ],
'Statut' => strtoupper ( $tabInfos [ 'Statut' ]),
'adresse' => ucwords ( $tabInfos [ 'adresse' ]),
'adresseComp' => strtoupper ( $tabInfos [ 'adresseComp' ]),
'cp' => $tabInfos [ 'cp' ] * 1 ,
'ville' => strtoupper ( $tabInfos [ 'ville' ]),
'tel' => $tabInfos [ 'tel' ],
'fax' => $tabInfos [ 'fax' ],
'email' => $tabInfos [ 'email' ],
'web' => $tabInfos [ 'web' ],
'contact' => $tabInfos [ 'contact' ],
'idUser' => $idUser ,
);
}
$id = str_replace ( 'm' , '' , '' . $tabInfos [ 'id' ]) * 1 ;
if ( isset ( $tabInfos [ 'id' ]) && $id > 0 ) {
// MAJ
if ( ! $iDb -> update ( 'tabMandataires' , $tabUpdate , " id= $id " , true ))
return array ( 'error' => array ( 'errnum' => 768521741 , 'errmsg' => 'Mise a jour impossible' ), 'result' => 0 );
} else {
// Insertion
if ( ! $iDb -> insert ( 'tabMandataires' , array_merge ( $tabUpdate , array ( 'dateInsert' => date ( 'YmdHis' ))), true ))
return array ( 'error' => array ( 'errnum' => 768657741 , 'errmsg' => 'Insertion impossible' ), 'result' => 0 );
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
2011-03-24 15:11:22 +00:00
}
2010-11-04 11:05:01 +00:00
/** Mise <EFBFBD> jour d ' informations dans la base
** @ nodoc
**/
function setInfosEntrep ( $siret , $id , $tabInfos ) {
$tabRet = array ();
$iBodacc = new MBodacc ();
global $iDbCrm , $tabInfoUser ;
if ( $tabInfoUser [ 'idClient' ] <> 1 )
return array ( 'error' => array ( 'errnum' => 464561 , 'errmsg' => 'Code Client Incorrect' ), 'result' => 0 );
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$iDb = new WDB ();
debugLog ( 'W' , print_r ( $tabInfos , true ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabIdentite = $tabInfos [ 'identite' ];
$tabJugement = $tabInfos [ 'jugement' ];
$tabActio = $tabInfos [ 'actionnaire' ];
$tabParti = $tabInfos [ 'participation' ];
$tabScores = $tabInfos [ 'score' ];
/** Mise <EFBFBD> jour de l ' identit<EFBFBD>
**/
if ( trim ( strtolower ( $tabIdentite [ 'web' ])) == 'http://' ) $web = '' ;
else $web = trim ( $tabIdentite [ 'web' ]);
$tabUpdate = array ( 'isin' => trim ( $tabIdentite [ 'isin' ]),
'tel' => trim ( $tabIdentite [ 'tel' ]),
'fax' => trim ( $tabIdentite [ 'fax' ]),
'web' => $web ,
'mail' => trim ( $tabIdentite [ 'mail' ]),
'activite' => stripslashes ( trim ( $tabIdentite [ 'activite' ])),
'sirenDoublon' => substr ( str_replace ( ' ' , '' , strtr ( $tabIdentite [ 'sirenDoublon' ], '"\'./- ,\*#()' , ' ' )), 0 , 9 ),
2011-06-09 09:39:42 +00:00
'waldec' => trim ( str_replace ( ' ' , '' , strtr ( $tabIdentite [ 'waldec' ], '"\'./- ,\*#()' , ' ' ))),
2010-11-04 11:05:01 +00:00
);
/** @todo non trait<69> es : [capital_mt] => 335400, [capital_dev] => EUR **/
if ( ! $iDb -> update ( 'infos_entrep' , $tabUpdate , " siren=' $siren ' " ))
if ( ! $iDb -> insert ( 'infos_entrep' , array_merge ( array ( 'siren' => $siren ), $tabUpdate )))
return array ( 'error' => array ( 'errnum' => 76841 , 'errmsg' => 'Mise a jour impossible' ), 'result' => 0 );
if ( isset ( $tabIdentite [ 'moisOppositionInsee' ]) && $tabIdentite [ 'moisOppositionInsee' ] > 0 &&
$tabIdentite [ 'moisOppositionInsee' ] <= ( date ( 'Ym' ) * 1 )) {
$iDb2 = new WDB ( 'insee' );
if ( ! $iDb2 -> insert ( 'insee_nondiff' , array ( 'siren' => $siren , 'mois' => $tabIdentite [ 'moisOppositionInsee' ])))
if ( $iDb2 -> getLastErrorNum () <> 1062 )
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ERREUR setInfosEntrep pour $siren " , " Erreur lors de l'inscription <20> la liste des oppositions de la sph<70> re commerciale INSEE pour $siren au mois de " . $tabIdentite [ 'moisOppositionInsee' ] . " : " . EOL . print_r ( $tabIdentite , true ) . EOL . $iDb2 -> getLastError ());
}
2011-06-09 09:39:42 +00:00
if ( isset ( $tabIdentite [ 'domiciliataire' ]) && $siren > 1000 ) {
if ( $tabIdentite [ 'domiciliataire' ] == 'oui' || $tabIdentite [ 'domiciliataire' ] == 'non' ) {
// L'entreprise et ces <20> tablissements seront mis <20> jour automatiquement ce soir
$iDb -> query ( " INSERT IGNORE INTO jo.tabAdrDom (siren,nic,siege, etActif, nom, sigle, enseigne, adrNum, adrBtq, adrTypVoie, adrLibVoie, ville, cp, depComEt, adrComp, cj, apen,apet, dateInsert)
SELECT siren , nic , siege , actif AS etActif , raisonSociale AS nom , sigle , enseigne , adr_num as adrNum , adr_btq AS adrBtq , adr_typeVoie AS adrTypVoie , adr_libVoie AS adrLibVoie , adr_ville AS ville , adr_cp AS cp , CONCAT ( adr_dep , adr_com ) AS depComEt , adr_comp AS adrComp , cj , ape_entrep AS apen , ape_etab AS apet , DATE ( NOW ()) as dateInsert
FROM jo . etablissements WHERE siren = $siren ; " , false);
}
// Si demande de suppression, on force l'indicateur ""
if ( $tabIdentite [ 'domiciliataire' ] == 'non' ) {
$tabUpdate = array ( 'pasEntrepDom' => 1 );
if ( ! $iDb -> update ( 'tabAdrDom' , $tabUpdate , " siren= $siren " ))
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ERREUR setInfosEntrep pour $siren " , " Erreur lors de la suppression du marqueur de domiciliation pour $siren : " . EOL . print_r ( $tabUpdate , true ) . EOL . $iDb -> getLastError ());
}
2010-11-04 11:05:01 +00:00
}
/** Insertion des scores
**/
if ( isset ( $tabScores [ 'encours' ]) || isset ( $tabScores [ 'scoreSolv' ]) ||
isset ( $tabScores [ 'scoreDir' ]) || isset ( $tabScores [ 'scoreConf' ])) {
$tabUpdate = array ();
$setScore = false ;
if ( isset ( $tabScores [ 'encours' ]) && $tabScores [ 'encours' ] <> '' ) { $tabUpdate [ 'encours' ] = $tabScores [ 'encours' ] * 1 ; $setScore = true ; }
if ( isset ( $tabScores [ 'scoreSolv' ]) && $tabScores [ 'scoreSolv' ] <> '' ) { $tabUpdate [ 'scoreSolv' ] = $tabScores [ 'scoreSolv' ] * 1 ; $setScore = true ; }
if ( isset ( $tabScores [ 'scoreDir' ]) && $tabScores [ 'scoreDir' ] <> '' ) { $tabUpdate [ 'scoreDir' ] = $tabScores [ 'scoreDir' ] * 1 ; $setScore = true ; }
if ( isset ( $tabScores [ 'scoreConf' ]) && $tabScores [ 'scoreConf' ] <> '' ) { $tabUpdate [ 'scoreConf' ] = $tabScores [ 'scoreConf' ] * 1 ; $setScore = true ; }
if ( $setScore )
// Mise <20> jour des Cute Offs
if ( ! $iDb -> update ( 'scores_cutoff' , $tabUpdate , " siren= $siren " ))
if ( ! $iDb -> insert ( 'scores_cutoff' , array_merge ( array ( 'siren' => $siren ,
'dateInsert' => date ( 'Ymd' )), $tabUpdate )))
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ERREUR setInfosEntrep pour $siren " , print_r ( $tabScores , true ) . EOL . $iDb -> getLastError ());
}
/** Insertion du jugement
**/
//print_r($tabJugement);die();
if ( isset ( $tabJugement [ 'even' ]) && is_array ( $tabJugement [ 'even' ]) && count ( $tabJugement [ 'even' ]) > 0 ) {
$idAdmin = str_replace ( 'm' , '' , trim ( $tabJugement [ 'admin' ])) * 1 ;
$idMand = str_replace ( 'm' , '' , trim ( $tabJugement [ 'mand' ])) * 1 ;
$idOppo = str_replace ( 'm' , '' , trim ( $tabJugement [ 'oppo' ])) * 1 ;
/** Nom et Identifiant de l'op<6F> rateur de saisie **/
$rep = $iDbCrm -> select ( 'utilisateurs' , 'id' , " login=' " . $tabInfoUser [ 'login' ] . " ' " );
$idUser = $rep [ 0 ][ 0 ];
$tabSource = explode ( '_' , $tabJugement [ 'source' ]);
$source =@ $tabSource [ 0 ];
$numJal =@ $tabSource [ 1 ];
$dateSource = WDate :: dateT ( 'd/m/Y' , 'Ymd' , trim ( $tabJugement [ 'dateParution' ])) * 1 ;
if ( $dateSource < 20000101 )
$dateSource = date ( 'YmdHis' );
$montant = trim ( preg_replace ( '/[^0-9]/' , '' , $tabJugement [ 'montant' ])) * 1 ;
$actionsMt = trim ( preg_replace ( '/[^0-9]/' , '' , $tabJugement [ 'actionsMt' ])) * 1 ;
$actionsNb = trim ( preg_replace ( '/[^0-9]/' , '' , $tabJugement [ 'actionsNb' ])) * 1 ;
if ( $montant > 0 && ( $actionsNb > 0 || $actionsMt > 0 )) {
if ( $actionsNb > 0 ) $actionsMt = $montant / $actionsNb ;
elseif ( $actionsMt > 0 ) $actionsNb = $montant / $actionsMt ;
}
$strDir = '' ;
if ( $tabJugement [ 'nouvDir1Fonc' ] * 1 > 0 ) {
$strDir .= $iBodacc -> getFctDir ( $tabJugement [ 'nouvDir1Fonc' ] * 1 ) . ' : ' . $tabJugement [ 'nouvDir1Genre' ] . ' ' . ucwords ( strtolower ( $tabJugement [ 'nouvDir1Pre' ])) . ' ' . strtoupper ( $tabJugement [ 'nouvDir1Nom' ]) . ', domicili<6C> <20> ' . $tabJugement [ 'nouvDir1Dom' ] . '. ' ;
}
if ( $tabJugement [ 'nouvDir2Fonc' ] * 1 > 0 ) {
$strDir .= $iBodacc -> getFctDir ( $tabJugement [ 'nouvDir2Fonc' ] * 1 ) . ' : ' . $tabJugement [ 'nouvDir2Genre' ] . ' ' . ucwords ( strtolower ( $tabJugement [ 'nouvDir2Pre' ])) . ' ' . strtoupper ( $tabJugement [ 'nouvDir2Nom' ]) . ', domicili<6C> <20> ' . $tabJugement [ 'nouvDir2Dom' ] . '. ' ;
}
if ( $tabJugement [ 'nouvDir3Fonc' ] * 1 > 0 ) {
$strDir .= $iBodacc -> getFctDir ( $tabJugement [ 'nouvDir3Fonc' ] * 1 ) . ' : ' . $tabJugement [ 'nouvDir3Genre' ] . ' ' . ucwords ( strtolower ( $tabJugement [ 'nouvDir3Pre' ])) . ' ' . strtoupper ( $tabJugement [ 'nouvDir3Nom' ]) . ', domicili<6C> <20> ' . $tabJugement [ 'nouvDir3Dom' ] . '. ' ;
}
if ( trim ( $tabJugement [ 'nouvAdrCp' ]) <> '' )
$strAdr = stripslashes ( trim ( $tabJugement [ 'nouvAdr' ]) . ', ' . trim ( $tabJugement [ 'nouvAdrCp' ]) . ' ' . trim ( $tabJugement [ 'nouvAdrVille' ]));
else
$strAdr = '' ;
$nic = $tabJugement [ 'nic' ] * 1 ;
$entrep = $this -> iInsee -> getIdentiteLight ( $siren , $nic );
if ( $nic > 0 && $tabJugement [ 'even' ][ 0 ] == 6700 && $entrep [ 'Siege' ] == 0 )
// Radiation d'un <20> tablissement
$tabJugement [ 'even' ][ 0 ] = 6600 ;
$tabEven = array ();
for ( $i = 1 ; isset ( $tabJugement [ 'even' ][ $i ]); $i ++ )
$tabEven [] = $tabJugement [ 'even' ][ $i ];
$strEven = implode ( ';' , $tabEven );
$tabUpdate = array ( 'strEven' => $strEven ,
'sirenValide' => $this -> iInsee -> valideSiren ( $siren ),
'dateCessationPaiement' => WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabJugement [ 'datePaie' ])),
'dateEffetFinP' => WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabJugement [ 'dateFinPeriode' ])),
'tribunal' => trim ( $tabJugement [ 'tribunal' ]),
'montant' => $montant ,
'actionsNb' => $actionsNb ,
'inter1type' => 'A' ,
'inter1id' => $idAdmin ,
'inter1nom' => $this -> iInsee -> getMandatairesParId ( $idAdmin ),
'inter2type' => 'M' ,
'inter2id' => $idMand ,
'inter2nom' => $this -> iInsee -> getMandatairesParId ( $idMand ),
'inter3type' => 'O' ,
'inter3id' => $idOppo ,
'inter3nom' => $this -> iInsee -> getMandatairesParId ( $idOppo ),
'complement' => stripslashes ( trim ( $tabJugement [ 'comp' ])),
'nouvActivite' => stripslashes ( trim ( $tabJugement [ 'nouvActivite' ])),
'nouvDir' => stripslashes ( trim ( $strDir )),
'nouvAdr' => $strAdr ,
'nouvFJ' => trim ( $tabJugement [ 'nouvFJ' ]),
'raisonSociale' => $entrep [ 'Nom' ],
'adresse' => $entrep [ 'Adresse' ],
'codePostal' => $entrep [ 'CP' ],
'ville' => $entrep [ 'Ville' ],
'source' => $source ,
'idSaisie' => $idUser ,
'parutionIdJal' => $numJal ,
'parutionNum' => $tabJugement [ 'numParution' ],
);
$dateJuge = WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabJugement [ 'dateJuge' ]));
$tabInsert = array_merge ( $tabUpdate , array ( 'siren' => $siren ,
'dateJugement' => $dateJuge ,
'typeEven' => $tabJugement [ 'even' ][ 0 ],
'dateSource' => $dateSource ,
));
if ( ! $iDb -> insert ( 'annonces' , array_merge ( $tabInsert , array ( 'dateInsert' => date ( 'YmdHis' ))), true ))
if ( ! $iDb -> update ( 'annonces' , $tabUpdate , " siren= $siren AND dateJugement=' $dateJuge ' AND typeEven= " . $tabJugement [ 'even' ][ 0 ], true ))
return array ( 'error' => array ( 'errnum' => 768741 , 'errmsg' => 'Mise a jour impossible' ), 'result' => 0 );
}
/** Insertion de l ' actionnaire
**/
if ( is_array ( $tabActio ) && trim ( $tabActio [ 'siren' ]) <> '' ) {
// Tableau des actionnaires
//die('Actionnaires:'.print_r($tabActio));
$nom = $pays = $dateMAJ = '' ;
$ppPm = 'P' ;
$pct = trim ( str_replace ( ',' , '.' , $tabActio [ 'pct' ])) * 1 ;
$siren2 = preg_replace ( '/[^0-9]/' , '' , $tabActio [ 'siren' ]);
$entrep2 = $this -> iInsee -> getIdentiteEntreprise ( $siren );
$nom2 = $entrep2 [ 'Nom' ];
$pays2 = $entrep2 [ 'Pays' ];
if ( $pays2 == '' ) $pays2 = 'FRA' ;
if ( substr ( $entrep2 [ 'FJ' ], 0 , 1 ) * 1 <> 1 ) $ppPm = 'M' ;
$entrep = $this -> iInsee -> getIdentiteEntreprise ( $siren2 );
$nom = $entrep [ 'Nom' ];
$pays = trim ( $entrep [ 'Pays' ]);
if ( $pays == '' ) $pays = 'FRA' ;
if ( trim ( $tabActio [ 'nom' ]) <> '' ) $nom = $tabActio [ 'nom' ];
if ( $tabActio [ 'pays' ] <> 'XXX' ) $pays = $tabActio [ 'pays' ];
if ( trim ( $tabActio [ 'dateMAJ' ]) <> 'JJ/MM/AAAA' && trim ( $tabActio [ 'dateMAJ' ]) <> '' )
$dateMAJ = WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabActio [ 'dateMAJ' ]));
if ( $tabActio [ 'majMin' ] == 'maj' ) $majMin = '+' ;
elseif ( $tabActio [ 'majMin' ] == 'min' ) $majMin = '-' ;
else $majMin = '' ;
$tabUpdate = array ( //'Siren1'=> $siren,
'Pmin' => $pct ,
'Pmax' => $pct ,
'MajMin' => $majMin ,
'PpPm' => $ppPm ,
//'Siren2'=> $siren2,
//'RaisonSociale'=> $nom,
//'Pays'=> $pays,
'dateLien' => $dateMAJ ,
);
$tabInsert1 = array_merge ( $tabUpdate , array ( 'ActionPart' => 1 ),
array ( 'Siren1' => $siren ,
'Siren2' => $siren2 ,
'RaisonSociale' => $nom ,
'Pays' => $pays ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' )));
$res = $iDb -> select ( 'liens' , 'count(*)' , " Siren1= $siren AND (Siren2= $siren2 OR (RaisonSociale=' $nom ' AND Pays=' $pays ')) " );
if ( $res [ 0 ][ 0 ] > 0 ) {
if ( ! $iDb -> update ( 'liens' , array_merge ( $tabUpdate , array ( 'ActionPart' => 1 )), " siren= $siren AND (Siren2= $siren2 OR (RaisonSociale=' $nom ' AND Pays=' $pays ')) " , true ))
$errMaj = 1016166 ;
} else {
if ( ! $iDb -> insert ( 'liens' , $tabInsert1 , true ))
$errMaj = 1016167 ;
}
$tabInsert2 = array_merge ( $tabUpdate , array ( 'ActionPart' => 2 ),
array ( 'Siren1' => $siren2 ,
'Siren2' => $siren ,
'RaisonSociale' => $nom2 ,
'Pays' => $pays2 ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' )));
$res = $iDb -> select ( 'liens' , 'count(*)' , " Siren1= $siren2 AND (Siren2= $siren OR (RaisonSociale=' $nom2 ' AND Pays=' $pays2 ')) " );
if ( $res [ 0 ][ 0 ] > 0 ) {
if ( ! $iDb -> update ( 'liens' , array_merge ( $tabUpdate , array ( 'ActionPart' => 2 )), " siren= $siren2 AND (Siren2= $siren OR (RaisonSociale=' $nom2 ' AND Pays=' $pays2 ')) " , true ))
$errMaj = 1016168 ;
} else {
if ( ! $iDb -> insert ( 'liens' , $tabInsert2 , true ))
$errMaj = 1016169 ;
}
}
/** Insertion de la participation
**/
if ( is_array ( $tabParti ) && trim ( $tabParti [ 'siren' ]) <> '' ) {
//die('Participation:'.print_r($tabParti));
$nom = $pays = $dateMAJ = '' ;
$ppPm = 'P' ;
$pct = trim ( str_replace ( ',' , '.' , $tabParti [ 'pct' ])) * 1 ;
$siren2 = preg_replace ( '/[^0-9]/' , '' , $tabParti [ 'siren' ]);
$entrep2 = $this -> iInsee -> getIdentiteEntreprise ( $siren );
$nom2 = $entrep2 [ 'Nom' ];
$pays2 = $entrep2 [ 'Pays' ];
if ( $pays2 == '' ) $pays2 = 'FRA' ;
if ( substr ( $entrep2 [ 'FJ' ], 0 , 1 ) * 1 <> 1 ) $ppPm = 'M' ;
$entrep = $this -> iInsee -> getIdentiteEntreprise ( $siren2 );
$nom = $entrep [ 'Nom' ];
$pays = trim ( $entrep [ 'Pays' ]);
if ( $pays == '' ) $pays = 'FRA' ;
if ( trim ( $tabParti [ 'nom' ]) <> '' ) $nom = $tabParti [ 'nom' ];
if ( $tabParti [ 'pays' ] <> 'XXX' ) $pays = $tabParti [ 'pays' ];
if ( trim ( $tabParti [ 'dateMAJ' ]) <> 'JJ/MM/AAAA' && trim ( $tabParti [ 'dateMAJ' ]) <> '' )
$dateMAJ = WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabParti [ 'dateMAJ' ]));
if ( $tabParti [ 'majMin' ] == 'maj' ) $majMin = '+' ;
elseif ( $tabParti [ 'majMin' ] == 'min' ) $majMin = '-' ;
else $majMin = '' ;
$tabUpdate = array ( 'Pmin' => $pct ,
'Pmax' => $pct ,
'MajMin' => $majMin ,
'PpPm' => $ppPm ,
'dateLien' => $dateMAJ ,
);
$tabInsert1 = array_merge ( $tabUpdate , array ( 'ActionPart' => 2 ),
array ( 'Siren1' => $siren ,
'Siren2' => $siren2 ,
'RaisonSociale' => $nom ,
'Pays' => $pays ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' )));
$res = $iDb -> select ( 'liens' , 'count(*)' , " Siren1= $siren AND (Siren2= $siren2 OR (RaisonSociale=' $nom ' AND Pays=' $pays ')) " );
if ( $res [ 0 ][ 0 ] > 0 ) {
if ( ! $iDb -> update ( 'liens' , array_merge ( $tabUpdate , array ( 'ActionPart' => 2 )), " siren= $siren AND (Siren2= $siren2 OR (RaisonSociale=' $nom ' AND Pays=' $pays ')) " , true ))
$errMaj = 10168 ;
} else {
if ( ! $iDb -> insert ( 'liens' , $tabInsert1 , true ))
$errMaj = 10169 ;
}
$tabInsert2 = array_merge ( $tabUpdate , array ( 'ActionPart' => 1 ),
array ( 'Siren1' => $siren2 ,
'Siren2' => $siren ,
'RaisonSociale' => $nom2 ,
'Pays' => $pays2 ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' )));
$res = $iDb -> select ( 'liens' , 'count(*)' , " Siren1= $siren2 AND (Siren2= $siren OR (RaisonSociale=' $nom2 ' AND Pays=' $pays2 ')) " );
if ( $res [ 0 ][ 0 ] > 0 ) {
if ( ! $iDb -> update ( 'liens' , array_merge ( $tabUpdate , array ( 'ActionPart' => 1 )), " siren= $siren2 AND (Siren2= $siren OR (RaisonSociale=' $nom2 ' AND Pays=' $pays2 ')) " , true ))
$errMaj = 10170 ;
} else {
if ( ! $iDb -> insert ( 'liens' , $tabInsert2 , true ))
$errMaj = 10171 ;
}
}
if ( $errMaj > 0 )
return array ( 'error' => array ( 'errnum' => 745741 , 'errmsg' => 'Mise a jour impossible' ), 'result' => 0 );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
}
2011-03-24 15:11:22 +00:00
/** Suppression logique d ' une annonce relative <EFBFBD> une entit<EFBFBD>
**
** @ param integer $source 0 = Collecte , 1 = BODACC , 2 = B . A . L . O , 3 = JO Association , 4 = Boamp
** @ param integer $idAnn Identifiant de l ' annonce
** @ param integer $siret Siren de l 'entreprise ou Siret de l' <EFBFBD> tablissement
** @ return bool
*/
function supprAnnonce ( $source = 0 , $idAnn , $siret = 0 ) {
2010-11-04 11:05:01 +00:00
global $tabInfoUser ;
if ( $tabInfoUser [ 'idClient' ] <> 1 )
return array ( 'error' => array ( 'errnum' => 464561 , 'errmsg' => 'Code Client Incorrect' ), 'result' => 0 );
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$iDb = new WDB ();
2011-03-24 15:11:22 +00:00
switch ( $source ) {
case 0 :
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
$table = 'annonces' ;
break ;
case 1 :
if ( $idAnn < 0 )
return array ( 'error' => array ( 'errnum' => 415245461 , 'errmsg' => 'Code annonce Incorrect' ), 'result' => 0 );
if ( $siren > 0 )
$strSql = " AND siren= $siren " ;
$table = 'bodacc_detail' ;
break ;
case 3 :
$table = 'asso' ;
break ;
case 2 :
case 4 :
default :
return array ( 'error' => array ( 'errnum' => 4461 , 'errmsg' => 'Cas non g<> r<EFBFBD> ' ), 'result' => 0 );
break ;
}
2010-11-04 11:05:01 +00:00
if ( $idAnn > 0 ) {
2011-03-24 15:11:22 +00:00
if ( $iDb -> update ( $table ,
2010-11-04 11:05:01 +00:00
array ( 'dateSuppr' => date ( 'YmdHis' ),
'idSuppr' => $tabInfoUser [ 'id' ],
),
2011-03-24 15:11:22 +00:00
" id= $idAnn $strSql " , false ))
debugLog ( 'I' , " Suppression de l'annonce en source $source n<> $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-04 11:05:01 +00:00
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
}
2011-03-24 15:11:22 +00:00
debugLog ( 'I' , " Suppression impossible de l'annonce en source $source n<> $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-04 11:05:01 +00:00
return array ( 'error' => array ( 'errnum' => 987964641 , 'errmsg' => 'Suppression de l\'annonce impossible' ), 'result' => 0 );
}
2011-03-24 15:11:22 +00:00
/** Supprime une annonce issue de la collecte
2010-11-04 11:05:01 +00:00
** @ nodoc
**/
2011-03-24 15:11:22 +00:00
function supprAnnonceCollecte ( $idAnn , $siret = 0 ) {
2010-11-04 11:05:01 +00:00
global $tabInfoUser ;
if ( $tabInfoUser [ 'idClient' ] <> 1 )
return array ( 'error' => array ( 'errnum' => 464561 , 'errmsg' => 'Code Client Incorrect' ), 'result' => 0 );
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$iDb = new WDB ();
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
2011-03-24 15:11:22 +00:00
if ( $idAnn > 0 ) {
if ( $iDb -> update ( 'annonces' ,
array ( 'dateSuppr' => date ( 'YmdHis' ),
'idSuppr' => $tabInfoUser [ 'id' ],
),
" id= $idAnn " , false ))
debugLog ( 'I' , " Suppression de l'annonce collect<63> e n<> $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-04 11:05:01 +00:00
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
}
debugLog ( 'I' , " Suppression impossible de l'annonce collect<63> e n<> $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 987964641 , 'errmsg' => 'Suppression de l\'annonce impossible' ), 'result' => 0 );
}
2011-03-24 15:11:22 +00:00
/** Duplication d ' une annonce relative <EFBFBD> une entit<EFBFBD>
2011-01-10 17:05:54 +00:00
**
2011-03-24 15:11:22 +00:00
** @ param integer $source 0 = Collecte , 1 = BODACC , 2 = B . A . L . O , 3 = JO Association , 4 = Boamp
** @ param integer $idAnn Identifiant de l ' annonce
** @ param integer $siretIn Siren de l 'entreprise ou Siret de l' <EFBFBD> tablissement de l ' annonce <EFBFBD> duppliquer
** @ param integer $siretOut Siren / Siret de l 'entreprise ou <20> tab sur lequel il faut dupliquer l' annonce
** @ return bool
*/
function dupliqueAnnonce ( $source = 0 , $idAnn , $siretIn = 0 , $siretOut = 0 ) {
debugLog ( 'I' , " Demande de duplication d'annonce en source $source sur n<> $idAnn (siretIn= $siretIn , siretOut= $siretOut ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-01-10 17:05:54 +00:00
global $tabInfoUser ;
if ( $tabInfoUser [ 'idClient' ] <> 1 )
return array ( 'error' => array ( 'errnum' => 464561 , 'errmsg' => 'Code Client Incorrect' ), 'result' => 0 );
2011-03-24 15:11:22 +00:00
$sirenIn = substr ( '' . $siretIn , 0 , 9 ) * 1 ;
$nicIn = substr ( '' . $siretIn , 9 , 5 ) * 1 ;
$sirenOut = substr ( '' . $siretOut , 0 , 9 ) * 1 ;
$nicOut = substr ( '' . $siretOut , 9 , 5 ) * 1 ;
2011-01-10 17:05:54 +00:00
$iDb = new WDB ();
2011-03-24 15:11:22 +00:00
$strSql = '' ;
switch ( $source ) {
case 0 :
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
$table = 'annonces' ;
break ;
case 1 :
if ( $idAnn < 0 )
return array ( 'error' => array ( 'errnum' => 415245461 , 'errmsg' => 'Code annonce Incorrect' ), 'result' => 0 );
if ( $sirenIn > 0 )
$strSql .= " AND siren= $sirenIn " ;
$table = 'bodacc_detail' ;
break ;
case 3 :
$table = 'asso' ;
break ;
case 2 :
case 4 :
default :
return array ( 'error' => array ( 'errnum' => 4461 , 'errmsg' => 'Cas non g<> r<EFBFBD> ' ), 'result' => 0 );
break ;
}
2011-01-10 17:05:54 +00:00
if ( $idAnn > 0 ) {
2011-03-24 15:11:22 +00:00
$res = $iDb -> select ( $table , '*' , " id= $idAnn $strSql " , false , MYSQL_ASSOC );
if ( count ( $res ) == 0 ) return array ( 'error' => array ( 'errnum' => 4645644561 , 'errmsg' => 'Annonce inexistante' ), 'result' => 0 );
$annonce = $res [ 0 ];
$annonce [ 'siren' ] = $sirenOut ;
$annonce [ 'sirenValide' ] = 2 ;
$annonce [ 'dateInsert' ] = date ( 'YmdHis' );
if ( $source == 0 ) {
// Suppression des zones inexistantes dans la table ou devant <20> tre vides
unset ( $annonce [ 'id' ]);
unset ( $annonce [ 'nic' ]);
$annonce [ 'idSaisie' ] = $tabInfoUser [ 'id' ];
} else {
$annonce [ 'idSirenage' ] = $tabInfoUser [ 'id' ];
$annonce [ 'nic' ] = $nicOut ;
if ( $nicOut > 0 ) $annonce [ 'nicValide' ] = 2 ;
}
if ( $iDb -> insert ( $table , $annonce , true , true )) {
debugLog ( 'I' , " Duplication de l'annonce en source $source sur n<> $idAnn (siretIn= $siretIn , siretOut= $siretOut ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-01-10 17:05:54 +00:00
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
2011-03-24 15:11:22 +00:00
} else
debugLog ( 'I' , " Duplication imposible de l'annonce en source $source sur n<> $idAnn (siretIn= $siretIn , siretOut= $siretOut ) : " . mysql_error (), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-01-10 17:05:54 +00:00
}
2011-03-24 15:11:22 +00:00
debugLog ( 'I' , " Duplication impossible de l'annonce en source $source sur n<> $idAnn (siretIn= $siretIn , siretOut= $siretOut ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 987964641 , 'errmsg' => 'Duplication de l\'annonce impossible' ), 'result' => 0 );
2011-01-10 17:05:54 +00:00
}
/** Duplique une annonce issue de la collecte
** @ nodoc
2011-03-24 15:11:22 +00:00
**/
function dupliqueAnnonceCollecte ( $idAnn , $siret = 0 ) {
2011-01-10 17:05:54 +00:00
global $tabInfoUser ;
debugLog ( 'I' , " Demande de duplication d'annonce collect<63> e sur n<> $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( $tabInfoUser [ 'idClient' ] <> 1 )
return array ( 'error' => array ( 'errnum' => 464561 , 'errmsg' => 'Code Client Incorrect' ), 'result' => 0 );
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$nic = substr ( '' . $siret , 9 , 5 ) * 1 ;
$iDb = new WDB ();
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
debugLog ( 'I' , " Demande de duplication d'annonce collect<63> e sur n<> $idAnn (siret= $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( $idAnn > 0 && $siren > 1000 ) {
$res = $iDb -> select ( 'annonces' , '*' , " id= $idAnn " , false , MYSQL_ASSOC );
if ( count ( $res ) == 0 ) return array ( 'error' => array ( 'errnum' => 4645644561 , 'errmsg' => 'Annonce inexistante' ), 'result' => 0 );
$annonce = $res [ 0 ];
// Suppression des zones inexistantes dans la table ou devant <20> tre vides
unset ( $annonce [ 'id' ]);
unset ( $annonce [ 'nic' ]); //=$nic;
$annonce [ 'siren' ] = $siren ;
$annonce [ 'dateInsert' ] = date ( 'YmdHis' );
if ( $iDb -> insert ( 'annonces' , $annonce )) {
debugLog ( 'I' , " Duplication de l'annonce collect<63> e n<> $idAnn sur $siret " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
} else
debugLog ( 'I' , " Duplication imposible de l'annonce collect<63> e n<> $idAnn sur $siret : " . mysql_error (), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
debugLog ( 'I' , " Demande de duplication d'annonce collect<63> e sur n<> $idAnn (siret= $siret !!!!) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
2011-03-24 15:11:22 +00:00
debugLog ( 'I' , " Duplication impossible de l'annonce collect<63> e n<> $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 987964641 , 'errmsg' => 'Duplication de l\'annonce impossible' ), 'result' => 0 );
}
2010-11-04 11:05:01 +00:00
/** R<EFBFBD> cup<EFBFBD> re le contenu d ' une annonce issue de la collecte
** @ nodoc
**/
function getAnnonceCollecte ( $idAnn , $siret ) {
global $tabInfoUser ;
if ( $tabInfoUser [ 'idClient' ] <> 1 )
return array ( 'error' => array ( 'errnum' => 464561 , 'errmsg' => 'Code Client Incorrect' ), 'result' => 0 );
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$iDb = new WDB ();
debugLog ( 'I' , " Lecture de l'annonce collect<63> e n<> $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
if ( $idAnn > 0 ) {
$res = $iDb -> select ( 'annonces' ,
'id, siren, sirenValide, typeEven, strEven, raisonSociale, adresse, codePostal, ville, dateJugement, dateCessationPaiement, dateEffetFinP, numero, inter1type, inter1id, inter1nom, inter2type, inter2id, inter2nom, inter3type, inter3id, inter3nom, inter4type, inter4id, inter4nom, tribunal, montant, actionsNb, complement, infosBrutes, nouvActivite, nouvDir, nouvAdr, nouvFJ, annonce, source, parutionIdJal, parutionNum, dateSource, idSaisie, idAnnonce, dateInsert' ,
" id= $idAnn " , false , MYSQL_ASSOC );
if ( count ( $res ) > 0 ) {
$ann = $res [ 0 ];
$tabRet = array ( 'id' => $ann [ 'id' ],
'siren' => $ann [ 'siren' ],
'raisonSociale' => prepareString ( $ann [ 'raisonSociale' ]),
'adresse' => prepareString ( $ann [ 'adresse' ]),
'codePostal' => $ann [ 'codePostal' ],
'ville' => prepareString ( $ann [ 'ville' ]),
'dateJugement' => $ann [ 'dateJugement' ],
'even' => array_merge ( array ( $ann [ 'typeEven' ]), explode ( ';' , $ann [ 'strEven' ])),
'dateSource' => $ann [ 'dateSource' ],
'dateCessationPaiement' => $ann [ 'dateCessationPaiement' ],
'dateEffetFinP' => $ann [ 'dateEffetFinP' ],
'tribunal' => $ann [ 'tribunal' ],
'numero' => $ann [ 'numero' ],
'montant' => $ann [ 'montant' ],
'actionsNb' => $ann [ 'actionsNb' ],
'inter1type' => $ann [ 'inter1type' ],
'inter1id' => $ann [ 'inter1id' ],
'inter1nom' => prepareString ( $ann [ 'inter1nom' ]),
'inter2type' => $ann [ 'inter2type' ],
'inter2id' => $ann [ 'inter2id' ],
'inter2nom' => prepareString ( $ann [ 'inter2nom' ]),
'inter3type' => $ann [ 'inter3type' ],
'inter3id' => $ann [ 'inter3id' ],
'inter3nom' => prepareString ( $ann [ 'inter3nom' ]),
'complement' => prepareString ( $ann [ 'complement' ]),
'nouvActivite' => prepareString ( $ann [ 'nouvActivite' ]),
'nouvDir' => prepareString ( $ann [ 'nouvDir' ]),
'nouvAdr' => prepareString ( $ann [ 'nouvAdr' ]),
'nouvFJ' => $ann [ 'nouvFJ' ],
'source' => $ann [ 'source' ],
);
/*
inter4type
inter4id
inter4nom
infosBrutes ,
annonce
parutionIdJal
parutionNum
idSaisie
idAnnonce
dateInsert
*/
debugLog ( 'I' , " Lecture de l'annonce collect<63> e n<> $idAnn ( $siret ) : " . $ann [ 'raisonSociale' ], __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
}
return array ( 'error' => array ( 'errnum' => 745741 , 'errmsg' => 'Selection impossible' ), 'result' => 0 );
}
/**
* Enter description here ...
*
* @ param unknown_type $page
* @ param unknown_type $siret
* @ param unknown_type $id
* @ param unknown_type $ref
* @ nodoc
**/
function setLog ( $page , $siret , $id = 0 , $ref = '' ) {
if ( $id <> 0 ) $ref2 = '' . $id . '/' . $ref ;
else $ref2 = $ref ;
wsLog ( $page , $siret , $ref2 );
debugLog ( 'I' , " Insertion d'un log pour la page $page $siret $ref2 " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
/** Ajout d ' une surveillance Annonces L<EFBFBD> gales
** @ nodoc
**
** @ param unknown_type $siret
** @ param unknown_type $email
** @ param unknown_type $ref
** @ param unknown_type $delete
** @ return unknown
*/
function setSurveillanceAnnoncesLegales ( $siret , $email , $ref = '' , $delete = false ) {
/* $tabRet = array ();
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$iDb = new WDB ();
global $tabInfoUser ;
$tabInsert = array ( 'dateAjout' => date ( 'Y-m-d' ),
'siren' => $siren ,
'email' => $email ,
'ref' => $ref ,
'login' => $tabInfoUser [ 'login' ],
);
if ( ! $iDb -> insert ( 'surveillances_site' , $tabInsert ))
return array ( 'error' => array ( 'errnum' => 76841 , 'errmsg' => 'Mise a jour impossible' ), 'result' => 0 );
*/
return $this -> setSurveillance ( $siret , $email , $ref , 'annonces' , $delete );
}
/** Ajout d ' une surveillance
**
** @ param integer $siret Siret / Siren <EFBFBD> surveiller
** @ param string $email Adresse email du client
** @ param string $ref R<EFBFBD> f<EFBFBD> rence de la surveillance
** @ param string $source Type de source en surveillance ( insee , annonces , bilans , actes , privileges , score , dirigeants )
** @ param boolean $delete Suppression de la ligne
** @ param integer $encoursClient Encours demand<EFBFBD> par le client
** @ return unknown
*/
function setSurveillance ( $siret , $email , $ref = '' , $source = 'annonces' , $delete = false , $encoursClient = 0 ) {
debugLog ( 'I' , " setSurveillances(siret= $siret , email= $email , ref= $ref , source= $source , delete= $delete ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$nic = substr ( '' . $siret , 9 , 5 ) * 1 ;
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $siren , $nic );
$iDb = new WDB ();
global $tabInfoUser ;
$login = $tabInfoUser [ 'login' ];
$source = strtolower ( $source );
switch ( $source ) {
case 'insee' :
case 'annonces' :
case 'bilans' :
case 'actes' :
case 'privileges' :
case 'dir1igeants' :
$encoursClient = 0 ;
break ;
case 'score' :
$encoursClient = $encoursClient * 1 ;
break ;
default :
$source = 'annonces' ;
break ;
}
$tabUpdate = array ( 'source' => $source ,
'login' => $login ,
'email' => $email ,
'siren' => $siren ,
'nic' => $nic ,
'ref' => $ref ,
'encoursClient' => $encoursClient ,
'rs' => $tabIdentite [ 'Nom' ],
'cp' => $tabIdentite [ 'CP' ],
'ville' => $tabIdentite [ 'Ville' ],
);
if ( $delete )
$tabUpdate = array_merge ( $tabUpdate , array ( 'dateSuppr' => date ( 'Y-m-d' )));
else
$tabUpdate = array_merge ( $tabUpdate , array ( 'dateAjout' => date ( 'Y-m-d' ), 'dateSuppr' => 0 ));
if ( $delete || ! $iDb -> insert ( 'surveillances_site' , $tabUpdate )) {
/*@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " debugSurv pour $login " ,
" source=' $source ' AND login=' $login ' AND email=' $email ' AND siren= $siren AND nic= $nic AND ref=' $ref ' " . EOL .
print_r ( $tabUpdate , true ) . EOL
); */
if ( ! $iDb -> update ( 'surveillances_site' , $tabUpdate , " source=' $source ' AND login=' $login ' AND email=' $email ' AND siren= $siren AND nic= $nic AND ref=' $ref ' " ))
return array ( 'error' => array ( 'errnum' => 76841 , 'errmsg' => 'Mise a jour impossible' ), 'result' => 0 );
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
}
function getSurveillances ( $siret = 0 , $source = 'annonces' , $detail = false , $deb = 0 , $nbRet = 100 , $tri = 'siren' ) {
$tri = strtolower ( trim ( $tri ));
switch ( $tri ) {
case 'ref' : $orderBy = 'ORDER BY ref' ; break ;
case 'dateAjout' : $orderBy = 'ORDER BY dateAjout' ; break ;
case 'dateDerEnvoi' : $orderBy = 'ORDER BY dateDerEnvoi' ; break ;
case 'rs' : $orderBy = 'ORDER BY rs' ; break ;
case 'cp' : $orderBy = 'ORDER BY cp' ; break ;
case 'ville' : $orderBy = 'ORDER BY ville' ; break ;
default : $orderBy = 'ORDER BY siren' ; break ; // siren ou vide ou autre
}
$tabRet = array ();
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$nic = substr ( '' . $siret , 9 , 5 ) * 1 ;
$iDb = new WDB ();
global $tabInfoUser ;
$login = $tabInfoUser [ 'login' ];
if ( $detail ) $strSelect = 'source, email, siren, nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi' ;
else $strSelect = 'source, email, siren, nic, ref, dateAjout, dateDerEnvoi' ;
if ( $source <> '' ) $strSource = " AND source=' $source ' " ;
else $strSource = '' ;
if ( $siren > 0 ) $strSiren = " AND siren= $siren " ;
else $strSiren = '' ;
// Il faut compter le nombre de siren au total
$tabTmp = $iDb -> select ( 'surveillances_site' , 'count(*) as nb' , " login=' $login ' AND dateSuppr=0 $strSiren $strSource " , false , MYSQL_ASSOC );
$nbRepTot = $tabTmp [ 0 ][ 'nb' ];
$tabTmp = $iDb -> select ( 'surveillances_site' , $strSelect , " login=' $login ' AND dateSuppr=0 $strSiren $strSource $orderBy LIMIT $deb , $nbRet " , false , MYSQL_ASSOC );
foreach ( $tabTmp as $i => $tabSurv ) {
if ( ! $detail )
$tabRet [] = array ( 'source' => $tabSurv [ 'source' ],
'email' => $tabSurv [ 'email' ],
'siren' => $tabSurv [ 'siren' ],
'nic' => $tabSurv [ 'nic' ],
'ref' => prepareString ( $tabSurv [ 'ref' ]),
'dateAjout' => $tabSurv [ 'dateAjout' ],
'dateDerEnvoi' => $tabSurv [ 'dateDerEnvoi' ],
);
else {
if ( trim ( $tabSurv [ 'rs' ]) <> '' ) {
$rs = $tabSurv [ 'rs' ];
$cp = $tabSurv [ 'cp' ];
$ville = $tabSurv [ 'ville' ];
} else {
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $tabSurv [ 'siren' ], $tabSurv [ 'nic' ]);
$rs = $tabIdentite [ 'Nom' ];
$cp = $tabIdentite [ 'CP' ];
$ville = $tabIdentite [ 'Ville' ];
$iDb -> update ( 'surveillances_site' , array ( 'rs' => $rs ,
'cp' => $cp ,
'ville' => $ville ),
" login=' $login ' AND dateSuppr=0 AND siren= " . $tabSurv [ 'siren' ] . " AND nic= " . $tabSurv [ 'nic' ] . " $strSource " , false );
}
$tabRet [] = array ( 'source' => $tabSurv [ 'source' ],
'email' => $tabSurv [ 'email' ],
'siren' => $tabSurv [ 'siren' ],
'nic' => $tabSurv [ 'nic' ],
'ref' => prepareString ( $tabSurv [ 'ref' ]),
'dateAjout' => $tabSurv [ 'dateAjout' ],
'encoursClient' => $tabSurv [ 'encoursClient' ],
'rs' => $rs ,
'cp' => $cp ,
'ville' => $ville ,
'dateDerEnvoi' => $tabSurv [ 'dateDerEnvoi' ],
);
}
}
$rep = array ( 'criteres' => array ( 'siren' => $siren , 'nic' => $nic , 'source' => $source ),
'nbReponses' => count ( $tabRet ),
'nbReponsesTotal' => $nbRepTot ,
'reponses' => $tabRet ,
);
// debugLog('I',"getSurveillances".print_r($tabRet,true),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $rep );
}
function getListeSurveillancesCsv ( $source = '' , $login = '' , $idClient = 0 ) {
debugLog ( 'I' , " getListeSurveillancesCsv D<> but $source $login $idClient " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
//return array();
global $tabInfoUser ;
$tabRet = array ();
$iDb = new WDB ();
$strClient = $strLogin = '' ;
$exportPtf = false ;
switch ( $source ) {
case 'insee' :
case 'annonces' :
case 'bilans' :
case 'score' :
case 'actes' :
case 'privileges' :
case 'dirigeants' :
break ;
case 'portefeuille' :
$source = 'score' ;
$exportPtf = true ;
break ;
default :
$source = '' ;
break ;
}
if ( $source <> '' ) $strSource = " AND source=' $source ' " ;
else $strSource = '' ;
if ( $idClient * 1 == 0 || ( $idClient * 1 <> $tabInfoUser [ 'idClient' ] && $tabInfoUser [ 'profil' ] <> 'SuperAdministrateur' ) )
$idClient = $tabInfoUser [ 'idClient' ];
$strClient = " AND u.idClient= $idClient " ;
if ( $login == '' && ( $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' || $tabInfoUser [ 'profil' ] == 'Administrateur' ))
// On veut toutes les surveillances du client
$login = '' ; //$tabInfoUser['login'];
elseif ( $login <> '' && ( $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' || $tabInfoUser [ 'profil' ] == 'Administrateur' ))
$strLogin = " AND s.login=' $login ' " ;
else
$strLogin = " AND s.login=' " . $tabInfoUser [ 'login' ] . " ' " ;
2010-11-29 14:17:26 +00:00
2010-11-04 11:05:01 +00:00
$fichierCsv = DOC_WEB_LOCAL . " csv/listesurv- $source - $login - $idClient .csv " ;
if ( file_exists ( $fichierCsv ) &&
date ( 'Ymd' , filemtime ( $fichierCsv )) == date ( 'Ymd' ) &&
filesize ( $fichierCsv ) > 60 ) {
$size = filesize ( $fichierCsv );
$erreur = false ;
$tabNom = array ();
$cache = 1 ;
} else {
@ unlink ( $fichierCsv );
2010-11-29 14:17:26 +00:00
if ( $source == 'score' ) {
if ( $tabInfoUser [ 'typeScore' ] * 1 == 20 ) { $strScore = 'v.indiScore20 AS indiScore20' ; $strScorePre = 'v.indiScore20Pre AS indiScore20Pre' ; }
else { $strScore = 'v.indiScore AS indiScore100' ; $strScorePre = 'v.indiScorePre AS indiScore100Pre' ; }
/* v . scoreZ , v . scoreZPre , v . scoreCH , v . scoreCHPre ,
v . scoreAfdcc2 , v . scoreAfdcc2Pre , v . situFi , v . situFiPre , v . infoNote , v . infoNotePre ,
v . noteStruct , v . noteStructPre , v . noteFin , v . noteFinPre , v . tendance , v . tendancePre , */
2010-11-04 11:05:01 +00:00
$sql = " SELECT LOWER(s.login) as loginUti, s.source, s.email, s.siren, s.nic, s.ref, s.dateAjout,
2010-11-29 14:17:26 +00:00
s . rs , s . cp , s . ville , s . dateDerEnvoi ,
s . encoursClient , v . actif , v . procol , $strScore , v . encours , v . indiScoreDate , v . dateBilan ,
$strScorePre , v . encoursPre , v . indiScoreDatePre , v . sourceModif , v . scoreSolv , v . scoreSolvPre , v . scoreDir ,
v . scoreDirPre , v . scoreConf , v . scoreConfPre ,
e . cj , e . capital , e . capitalDev , e . ape_entrep , e . tca , e . teff_entrep ,
v . dateUpdate
FROM surveillances_site s , sdv1 . utilisateurs u , sdv1 . clients c , scores_surveillance v , etablissements e
WHERE s . source = 'score' $strClient $strLogin AND dateSuppr = 0 AND s . login = u . login AND u . idClient = c . id AND s . siren = v . siren AND s . siren = e . siren
GROUP BY loginUti , s . siren , s . nic , s . source , s . ref
2010-11-04 11:05:01 +00:00
ORDER BY loginUti ASC , s . siren ASC , s . nic ASC , s . source ASC , s . ref ASC " ;
2010-11-29 14:17:26 +00:00
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeSurveillancesCsv($source, $login, $idClient)", $sql);
} else
2010-11-04 11:05:01 +00:00
$sql = " SELECT LOWER(s.login) as loginUti, s.source, s.email, s.siren, s.nic, s.ref, s.dateAjout,
s . rs , s . cp , s . ville , s . dateDerEnvoi
FROM surveillances_site s , sdv1 . utilisateurs u , sdv1 . clients c
WHERE 1 $strSource $strClient $strLogin AND dateSuppr = 0 AND s . login = u . login AND u . idClient = c . id
ORDER BY loginUti ASC , s . siren ASC , s . nic ASC , s . source ASC , s . ref ASC " ;
debugLog ( 'I' , " getListeSurveillancesCsv SQL $sql " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$fp = fopen ( " /tmp/listesurv- $source - $login - $idClient .sql " , 'w' );
fwrite ( $fp , $sql . EOL );
fclose ( $fp );
exec ( " ./sql2csv.php jo /tmp/listesurv- $source - $login - $idClient .sql $fichierCsv > /dev/null & " );
$size = $cache = 0 ;
}
$tabRet = array ( 'Url' => DOC_WEB_URL . " csv/listesurv- $source - $login - $idClient .csv " ,
'Taille' => $size ,
'Cache' => $cache ,
);
debugLog ( 'I' , 'getListeSurveillancesCsv Url=' . DOC_WEB_URL . " csv/listesurv- $source - $login - $idClient .csv, Taille= $size , Cache= $cache " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
function getPortefeuilleCsv ( $login = '' , $idClient = 0 ) {
return $this -> getListeSurveillancesCsv ( 'portefeuille' , $login , $idClient );
}
function getPortefeuille ( $siret = 0 , $deb = 0 , $nbRet = 100 , $tri = 'siren' ) {
/** Indiscore100 ou 20**/
$tri = strtolower ( trim ( $tri ));
switch ( $tri ) {
case 'ref' : $orderBy = 'ORDER BY ref' ; break ;
case 'dateAjout' : $orderBy = 'ORDER BY dateAjout' ; break ;
case 'dateDerEnvoi' : $orderBy = 'ORDER BY dateDerEnvoi' ; break ;
case 'rs' : $orderBy = 'ORDER BY rs' ; break ;
case 'cp' : $orderBy = 'ORDER BY cp' ; break ;
case 'ville' : $orderBy = 'ORDER BY ville' ; break ;
case 'indiScore' : $orderBy = 'ORDER BY indiScore' ; break ;
case 'encours' : $orderBy = 'ORDER BY encours' ; break ;
default : $orderBy = 'ORDER BY siren' ; break ; // siren ou vide ou autre
}
$tabRet = array ();
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$nic = substr ( '' . $siret , 9 , 5 ) * 1 ;
$iDb = new WDB ();
global $tabInfoUser ;
$login = $tabInfoUser [ 'login' ];
$strSelect = 's.email, s.siren, s.nic, s.ref, s.dateAjout, s.rs, s.cp, s.ville, s.dateDerEnvoi, s.encoursClient, c.actif, c.procol, c.indiScore, c.indiScore20, c.encours, c.indiScoreDate, c.dateBilan, c.indiScorePre, c.indiScore20Pre, c.encoursPre, c.indiScoreDatePre, c.sourceModif, c.scoreSolv, c.scoreSolvPre, c.scoreDir, c.scoreDirPre, c.scoreConf, c.scoreConfPre, c.scoreZ, c.scoreZPre, c.scoreCH, c.scoreCHPre, c.scoreAfdcc2, c.scoreAfdcc2Pre, c.situFi, c.situFiPre, c.infoNote, c.infoNotePre, c.noteStruct, c.noteStructPre, c.noteFin, c.noteFinPre, c.tendance, c.tendancePre, c.dateUpdate' ;
if ( $siren > 0 ) $strSiren = " AND s.siren= $siren " ;
else $strSiren = '' ;
// Il faut compter le nombre de siren au total
$tabTmp = $iDb -> select ( 'surveillances_site' , 'count(*) as nb' , " login=' $login ' AND source='score' AND dateSuppr=0 $strSiren " , false , MYSQL_ASSOC );
$nbRepTot = $tabTmp [ 0 ][ 'nb' ];
$tabTmp = $iDb -> select ( 'surveillances_site s, scores_surveillance c' , $strSelect , " s.login=' $login ' AND s.source='score' AND s.dateSuppr=0 AND s.siren=c.siren $strSiren $orderBy LIMIT $deb , $nbRet " , false , MYSQL_ASSOC );
foreach ( $tabTmp as $i => $tabSurv ) {
if ( trim ( $tabSurv [ 'rs' ]) <> '' ) {
$rs = $tabSurv [ 'rs' ];
$cp = $tabSurv [ 'cp' ];
$ville = $tabSurv [ 'ville' ];
} else {
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $tabSurv [ 'siren' ], $tabSurv [ 'nic' ]);
$rs = $tabIdentite [ 'Nom' ];
$cp = $tabIdentite [ 'CP' ];
$ville = $tabIdentite [ 'Ville' ];
$iDb -> update ( 'surveillances_site' , array ( 'rs' => $rs ,
'cp' => $cp ,
'ville' => $ville ),
" login=' $login ' AND source='score' AND dateSuppr=0 AND siren= " . $tabSurv [ 'siren' ] . " AND nic= " . $tabSurv [ 'nic' ], false );
}
$tabRet [] = array ( 'email' => $tabSurv [ 'email' ],
'siren' => $tabSurv [ 'siren' ],
'nic' => $tabSurv [ 'nic' ],
'ref' => prepareString ( $tabSurv [ 'ref' ]),
'dateAjout' => $tabSurv [ 'dateAjout' ],
'rs' => $rs ,
'cp' => $cp ,
'ville' => $ville ,
// Entreprise
'actif' => $tabSurv [ 'actif' ],
'procol' => $tabSurv [ 'procol' ],
'indiScore' => $tabSurv [ 'indiScore' ],
'indiScore20' => $tabSurv [ 'indiScore20' ],
'indiScorePre' => $tabSurv [ 'indiScorePre' ],
'indiScore20Pre' => $tabSurv [ 'indiScore20Pre' ],
'encours' => $tabSurv [ 'encours' ],
'encoursPre' => $tabSurv [ 'encoursPre' ],
'indiScoreDate' => $tabSurv [ 'indiScoreDate' ],
'indiScoreDatePre' => $tabSurv [ 'indiScoreDatePre' ],
'encoursClient' => $tabSurv [ 'encoursClient' ],
'dateBilan' => $tabSurv [ 'dateBilan' ],
'sourceModif' => $tabSurv [ 'sourceModif' ],
//, c.scoreSolv, c.scoreSolvPre, c.scoreDir, c.scoreDirPre, c.scoreConf, c.scoreConfPre, c.scoreZ, c.scoreZPre, c.scoreCH, c.scoreCHPre, c.scoreAfdcc2, c.scoreAfdcc2Pre, c.situFi, c.situFiPre, c.infoNote, c.infoNotePre, c.noteStruct, c.noteStructPre, c.noteFin, c.noteFinPre, c.tendance, c.tendancePre, c.dateUpdate';
'dateDerEnvoi' => $tabSurv [ 'dateDerEnvoi' ],
);
}
$rep = array ( 'criteres' => array ( 'siren' => $siren , 'nic' => $nic , 'source' => $source ),
'nbReponses' => count ( $tabRet ),
'nbReponsesTotal' => $nbRepTot ,
'reponses' => $tabRet ,
);
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $rep );
}
/** R<EFBFBD> cup<EFBFBD> ration d ' un kbis
** @ nodoc
**/
function getKbis ( $siren , $visu = 1 , $courrier = 0 , $mail = '' , $ref = '' ) {
return $this -> getPiece ( $siren , 'kbis' , '' , $visu , $courrier , $ref );
}
/** R<EFBFBD> cup<EFBFBD> ration d ' une Pi<EFBFBD> ce Infogreffe
** @ nodoc
**/
/*
function getPiece ( $siren , $piece = 'kbis' , $type = '' , $visu = 1 , $courrier = 0 , $ref = '' ) {
set_time_limit ( 400 );
$erreur = false ;
if ( file_exists ( " /var/www/html/pdf/ $piece - $siren .pdf " ) &&
date ( 'Ymd' , filemtime ( " /var/www/html/pdf/ $piece - $siren .pdf " )) == date ( 'Ymd' ) &&
filesize ( " /var/www/html/pdf/ $piece - $siren .pdf " ) > 0 ) {
$size = filesize ( " /var/www/html/pdf/ $piece - $siren .pdf " );
$erreur = false ;
$tabNom = array ();
$ficDist = '' ;
$cache = 1 ;
} else {
exec ( " ./getPieces.php $siren $piece > /dev/null & " );
$ficDist = '' ;
$size = $cache = 0 ;
}
/** On supprimer l ' ancien kbis si trop vieux ou vide **
if ( date ( 'Ymd' , filemtime ( " /var/www/html/pdf/ $piece - $siren .pdf " )) <> date ( 'Ymd' ) ||
filesize ( " /var/www/html/pdf/ $piece - $siren .pdf " ) == 0 )
move ( " /var/www/html/pdf/ $piece - $siren .pdf " , " /var/www/html/pdf/ $piece - $siren - " . date ( 'Ymd' ) . " .pdf " );
$tabRet = array ( 'Siren' => $siren ,
'Url' => " http://saulnier.scores-decisions.com/pdf/ $piece - $siren .pdf " ,
'Taille' => $size ,
'Cache' => $cache ,
'debug' => array ( 'tabNom' => $tabNom , 'tabDir' => $tabDirs ),
'fichier' => $ficDist ,
);
wsLog ( 'kbis' , $siren , " $cache / $visu / $courrier / $type / $ref " );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
} */
function getPiece ( $siren , $piece = 'kbis' , $type = '' , $visu = 1 , $courrier = 0 , $ref = '' ) {
set_time_limit ( 400 );
$erreur = false ;
if ( file_exists ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " ) &&
date ( 'Ymd' , filemtime ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " )) == date ( 'Ymd' ) &&
filesize ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " ) > 0 ) {
$size = filesize ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " );
$erreur = false ;
$tabNom = array ();
$ficDist = '' ;
$cache = 1 ;
} else {
exec ( " ./getPieces.php $siren $piece > /dev/null & " );
$ficDist = '' ;
$size = $cache = 0 ;
}
/** On supprimer l'ancien kbis si trop vieux ou vide **/
if ( date ( 'Ymd' , filemtime ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " )) <> date ( 'Ymd' ) ||
filesize ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " ) == 0 )
move ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " , DOC_WEB_LOCAL . " kbis/ $piece - $siren - " . date ( 'Ymd' ) . " .pdf " );
$tabRet = array ( 'Siren' => $siren ,
'Url' => DOC_WEB_URL . " kbis/ $piece - $siren .pdf " ,
'Taille' => $size ,
'Cache' => $cache ,
'debug' => array ( 'tabNom' => $tabNom , 'tabDir' => $tabDirs ),
'fichier' => $ficDist ,
);
wsLog ( 'kbis' , $siren , " $cache / $visu / $courrier / $type / $ref " );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/**
* @ nodoc
*
* @ param unknown_type $login
* @ param unknown_type $mois
* @ param unknown_type $type
* @ param unknown_type $payants
* @ return unknown
*/
function getStatsUtilisateurs ( $login , $mois , $type = 'jour' , $payants = false ) {
global $iDbCrm , $tabInfoUser ;
if ( $payants ) $strPayant = " AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis') AND params<>'' AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') " ;
else $strPayant = '' ;
if ( $type == 'jour' )
$rep = $iDbCrm -> select ( 'logs' , 'date(dateHeure) as jours, count(*) as nb' , " 1 $strPayant AND login=' $login ' AND dateHeure BETWEEN ' $mois -01' AND ' $mois -31' GROUP BY jours " , true , MYSQL_ASSOC );
elseif ( $type == 'heure' )
$rep = $iDbCrm -> select ( 'logs' , 'HOUR(dateHeure) as heures, count(*) as nb' , " 1 $strPayant AND login=' $login ' AND dateHeure BETWEEN ' $mois -01' AND ' $mois -31' GROUP BY heures " , true , MYSQL_ASSOC );
$tabRet = $rep ;
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
/**
* @ nodoc ICI
*
* @ param unknown_type $mois
* @ param unknown_type $detail
* @ param unknown_type $idClient
* @ param unknown_type $login
* @ return unknown
*/
function getLogsClients ( $mois , $detail = 0 , $idClient = 0 , $login = '' , $all = 0 ) {
global $iDbCrm , $tabInfoUser ;
$strDetail = $strClient = $strLogin = '' ;
// Vue d<> taill<6C> e ou uniquement les infos payantes
if ( $detail == 0 ) { $detail = 'Non' ;
//$strDetail=" AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page='indiscore' ) AND (params<>'' OR page='indiscore' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') ";
2010-11-29 14:17:26 +00:00
$strDetail = " AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page LIKE 'indiscore%' OR page='privileges' OR page='commandeAsso') AND (params<>'' OR page LIKE 'indiscore%' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') " ;
2010-11-04 11:05:01 +00:00
} elseif ( $detail == 1 ) $detail = 'Oui' ;
// On veut uniquement le client pr<70> cis
if ( $all && $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) {
$all = 'Oui' ;
} else {
$all = 'Non' ;
// Pas d'idClient mentionn<6E> ou tentative sur autre client et non SAD
if ( $idClient * 1 == 0 || ( $idClient * 1 <> $tabInfoUser [ 'idClient' ] && $tabInfoUser [ 'profil' ] <> 'SuperAdministrateur' ) )
$idClient = $tabInfoUser [ 'idClient' ];
$strClient = " AND u.idClient= $idClient " ;
}
// On veut uniquement le login pr<70> cis
if ( $login <> '' ) $strLogin = " AND l.login=' $login ' " ;
else $login = 'Non' ;
// Dates de d<> but et de fin
$mois = strtr ( $mois , array ( '-' => '' , '/' => '' )) * 1 ;
$annee = substr ( $mois , 0 , 4 );
$mois = substr ( $mois , 4 , 2 );
$dateDeb = date ( 'Y-m-d' , mktime ( 0 , 0 , 0 , $mois , 1 , $annee ));
$dateFin = date ( 'Y-m-t' , mktime ( 0 , 0 , 0 , $mois , 15 , $annee ));
$fichierCsv = DOC_WEB_LOCAL . " csv/logs- $annee - $mois - $detail - $idClient - $login - $all .csv " ;
if ( file_exists ( $fichierCsv ) &&
date ( 'Ymd' , filemtime ( $fichierCsv )) == date ( 'Ymd' ) &&
filesize ( $fichierCsv ) > 60 ) {
$size = filesize ( $fichierCsv );
$erreur = false ;
$tabNom = array ();
$cache = 1 ;
} else {
@ unlink ( $fichierCsv );
$sql = " SELECT LOWER(l.login) as loginUti, page, l.siren, l.nic, l.params, l.dateHeure, u.idClient, c.nom, u.referenceParDefaut AS refUti
FROM `logs` l , utilisateurs u , clients c
WHERE 1 $strDetail $strClient $strLogin AND dateHeure BETWEEN '$dateDeb 00:00:00' AND '$dateFin 23:59:59' AND l . login = u . login AND u . idClient = c . id
2011-03-24 15:11:22 +00:00
GROUP BY l . login , l . siren , page , date ( dateHeure ), params
2010-11-04 11:05:01 +00:00
ORDER BY l . login ASC , dateHeure ASC " ;
$fp = fopen ( " /tmp/logs- $annee - $mois - $detail - $idClient - $login - $all .sql " , 'w' );
fwrite ( $fp , $sql . EOL );
fclose ( $fp );
exec ( " ./sql2csv.php sdv1 /tmp/logs- $annee - $mois - $detail - $idClient - $login - $all .sql $fichierCsv > /dev/null & " );
$size = $cache = 0 ;
}
$tabRet = array ( 'Url' => DOC_WEB_URL . " csv/logs- $annee - $mois - $detail - $idClient - $login - $all .csv " ,
'Taille' => $size ,
'Cache' => $cache ,
);
//wsLog('kbis', $siren, "$cache/$visu/$courrier/$type/$ref");
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/**
* @ nodoc
*
* @ param unknown_type $login
* @ param unknown_type $ref
* @ param unknown_type $nomFic
* @ return unknown
*/
function getListeFichierSurv ( $login , $ref = '*' , $nomFic = '' ) {
2010-11-29 14:17:26 +00:00
//debugLog('I',"getListeFichierSurv pour $login, $ref, $nomFic",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
2010-11-04 11:05:01 +00:00
$tabFichier = $tabDates = array ();
$numAbo = substr ( $ref , 0 , 5 );
2011-03-24 15:11:22 +00:00
if ( strtolower ( $login ) == 'vwbank' ) {
2010-11-04 11:05:01 +00:00
$repClient = 'volkswagen bank' ;
$ficClient = 'surveillanceBodacc_SURBODPRDCFTVWBANK' ;
$numAbo = $ref = '19300' ;
2010-11-29 14:17:26 +00:00
} elseif ( substr ( $login , 0 , 6 ) == 'apicil' ) {
$repClient = 'apicil' ;
$ficClient = 'surveillanceBodacc_SURBODPRDCFTAPICIL' ;
$numAbo = $ref = '' ;
2011-03-24 15:11:22 +00:00
} elseif ( strtolower ( $login ) == 'omni04' ) {
$repClient = 'aggm mederic ' ;
$ficClient = 'surveillanceBodacc_SURBODPRDFTSOMNIREP' ;
$numAbo = $ref = '' ;
2010-11-04 11:05:01 +00:00
} else {
$repClient = 'cnasea' ;
$ficClient = 'surveillanceBodacc_SURBODTSTFTSCNASEA' ;
}
2011-03-24 15:11:22 +00:00
//debugLog('I',"getListeFichierSurv pour login=$login, repClient=$repClient, ficClient=$ficClient, numAbo=$numAbo, ref=$ref, avant openDir",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$dh = opendir ( " /home/data/clients/ $repClient " );
2010-11-29 14:17:26 +00:00
if ( ! $dh ) {
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , $nomFic " , " Impossible d'ouvrir le dossier '/home/data/clients/ $repClient /' " );
return array ( 'error' => array ( 'errnum' => 354659 , 'errmsg' => " Impossible d'ouvrir le dossier client " ), 'results' => array ());
}
2011-03-24 15:11:22 +00:00
debugLog ( 'I' , " getListeFichierSurv pour login= $login , repClient= $repClient , ficClient= $ficClient , numAbo= $numAbo , ref= $ref , apr<70> s openDir " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-04 11:05:01 +00:00
while ( false !== ( $filename = readdir ( $dh ))) {
if ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.csv' && substr ( $filename , 0 , 42 ) == $ficClient . $numAbo ) {
$tabFichier [] = $filename ;
$tabDates [] = substr ( $filename , 43 , 8 );
$tabClients [] = substr ( $filename , 0 , 42 );
}
elseif ( $ref == '*' && $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.csv' && substr ( $filename , 0 , 37 ) == $ficClient && substr ( $filename , 37 , 1 ) <> '_' ) {
$tabFichier [] = $filename ;
$tabDates [] = substr ( $filename , 43 , 8 );
$tabClients [] = substr ( $filename , 0 , 42 );
}
2010-11-29 14:17:26 +00:00
elseif ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.csv' && substr ( $filename , 0 , 37 ) == $ficClient && substr ( $filename , 37 , 1 ) == '_' && $repClient == 'apicil' ) {
$tabFichier [] = $filename ;
$tabDates [] = substr ( $filename , 38 , 8 );
$tabClients [] = substr ( $filename , 0 , 37 );
}
2011-03-24 15:11:22 +00:00
elseif ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.csv' && substr ( $filename , 0 , 38 ) == $ficClient && substr ( $filename , 38 , 1 ) == '_' && $repClient == 'aggm mederic ' ) {
$tabFichier [] = $filename ;
$tabDates [] = substr ( $filename , 39 , 8 );
$tabClients [] = substr ( $filename , 0 , 38 );
}
//debugLog('I',"getListeFichierSurv pour login=$login, repClient=$repClient, ficClient=$ficClient, numAbo=$numAbo, ref=$ref, Fichier lu '$filename'",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
2010-11-04 11:05:01 +00:00
}
/** Tableau des noms de fichier **/
sort ( $tabFichier );
/** Tableau des dates de livraisons **/
$tabDates = array_unique ( $tabDates );
sort ( $tabDates );
/** Tableau des Clients **/
$tabClients = array_unique ( $tabClients );
sort ( $tabClients );
//return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'results'=>$tabDates);
2011-03-24 15:11:22 +00:00
/*
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , $nomFic " ,
2010-11-29 14:17:26 +00:00
" Fichiers : " . EOL .
print_r ( $tabFichier , true ) .
" Dates: " . EOL .
print_r ( $tabDates , true ) .
" Clients : " . EOL .
print_r ( $tabClients , true )
); */
2010-11-04 11:05:01 +00:00
if ( $ref == '*' ) {
$tabFichier = array ();
// Boucle sur les dates de livraison
foreach ( $tabDates as $dateFic ) {
if ( strlen ( $dateFic ) <> 8 ) continue ;
if ( ! file_exists ( " /home/data/clients/ $repClient / $ficClient " . '_' . " $dateFic .csv " ) ||
filesize ( " /home/data/clients/ $repClient / $ficClient " . '_' . " $dateFic .csv " ) == 0 ) {
$fpW = fopen ( " /home/data/clients/ $repClient / $ficClient " . '_' . " $dateFic .csv " , 'w' );
$entete = true ;
// Boucle afin de v<> rifier si on est sur le bon client
foreach ( $tabClients as $nomClient ) {
$dh = opendir ( " /home/data/clients/ $repClient / " );
while ( false !== ( $filename = readdir ( $dh ))) {
if ( substr ( $filename , 0 , 51 ) == $nomClient . '_' . $dateFic && substr ( $filename , - 4 ) == '.csv' ) {
$fichier = $filename ;
//break;
}
}
$fpR = fopen ( " /home/data/clients/ $repClient / $fichier " , 'r' );
//return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'results'=>array(($fichier)));//die;
if ( $fpR ) {
while ( ! feof ( $fpR )) {
$ligne = trim ( fgets ( $fpR ));
if ( substr ( $ligne , 0 , 5 ) == 'Siren' && $entete == true ) {
fwrite ( $fpW , 'SITE;' . $ligne . EOL );
$entete = false ;
}
elseif ( substr ( $ligne , 0 , 5 ) <> 'Siren' && trim ( $ligne ) <> '' ) {
fwrite ( $fpW , strtr ( $nomClient , array ( 'surveillanceBodacc_SURBODTSTFTS' => '' ,
'surveillanceBodacc_SURBODPRDCFT' => '' )) . ';' . $ligne . EOL );
}
}
fclose ( $fpR );
}
}
fclose ( $fpW );
}
if ( strlen ( $dateFic ) == 8 )
$tabFichier [] = $ficClient . '_' . $dateFic . '.csv' ;
}
}
rsort ( $tabFichier );
if ( $nomFic <> '' ) {
2011-03-24 15:11:22 +00:00
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, /home/data/clients/$repClient/$nomFic", 'Avant BZ2');
2010-11-04 11:05:01 +00:00
if ( ! file_exists ( " /var/www/html/csv/ $nomFic .bz2 " ) ||
2011-03-24 15:11:22 +00:00
filesize ( " /var/www/html/csv/ $nomFic .bz2 " ) <= 14 ) {
2010-11-04 11:05:01 +00:00
$string = file_get_contents ( " /home/data/clients/ $repClient / $nomFic " );
2011-03-24 15:11:22 +00:00
if ( $string === false ) {
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , $nomFic " , " Ouverture impossible du fichier '/home/data/clients/ $repClient / $nomFic ' " );
}
2010-11-04 11:05:01 +00:00
$bz = bzopen ( " /var/www/html/csv/ $nomFic .bz2 " , 'w' );
if ( $bz ) {
bzwrite ( $bz , $string , strlen ( $string ));
bzclose ( $bz );
}
2011-03-24 15:11:22 +00:00
} /* else
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , /home/data/clients/ $repClient / $nomFic " , 'Sans BZ2' );
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , /home/data/clients/ $repClient / $nomFic " , 'Apr<70> s BZ2' );
*/
2010-11-04 11:05:01 +00:00
}
2011-03-24 15:11:22 +00:00
debugLog ( 'I' , " getListeFichierSurv pour $login , $ref , $nomFic : nbr fichiers= " . count ( $tabFichier ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-04 11:05:01 +00:00
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabFichier );
}
/** Donne la cours d 'appel d' un tribunal par son code
** @ nodoc
** @ param string $codeTribunal Code BODACC sur 6 caract<EFBFBD> res du tribunal
** @ return L 'identifiant Interne S&D de la cours d' appel
**/
function getIdCoursAppel ( $codeTribunal ) {
$iBodacc = new MBodacc ();
return $iBodacc -> getTribunalIdCA ( $codeTribunal );
}
/** Geocodage d ' une adresse
**
** @ nodoc
** @ param string $adresse
** @ param string $cp
** @ param string $ville
** @ param string $pays
**/
function geoCode ( $adresse , $cp , $ville , $pays = 'France' ) {
$ligne = date ( 'YmdHis' ) . " ; $siren ;MMap AVANT " ;
$fp = fopen ( '/var/www/log/accesDistant.log' , 'a' );
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
$mMap = new MMap ( $adresse , $cp , $ville , $pays );
$ligne = date ( 'YmdHis' ) . " ; $siren ;MMap APRES " ;
$fp = fopen ( '/var/www/log/accesDistant.log' , 'a' );
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
$tabRet = array ( 'latitude' => $mMap -> latitudeDec ,
'longitude' => $mMap -> longitudeDec ,
'precis' => $mMap -> precision ,
'adresseValidee' => prepareString ( $mMap -> adresseValidee ),
'latitudeDeg' => $mMap -> latitudeDeg ,
'longitudeDeg' => $mMap -> longitudeDeg ,
);
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
function commandeAsso ( $siren , $infoAsso = array (), $infoDemande = array ()) {
global $iDbCrm ;
global $tabInfoUser ;
$iDb = new WDB ();
$idEntreprise = $infoAsso [ 'idEntreprise' ] * 1 ;
$assoNom = $infoAsso [ 'RaisonSociale' ];
debugLog ( 'I' , " commandeAsso pour $assoNom ( $siren ) d<> but " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $siren , 0 , $idEntreprise );
$assoSigle = $tabIdentite [ 'Sigle' ];
$assoAdresse = $tabIdentite [ 'Adresse' ] . EOL . $tabIdentite [ 'Adresse2' ];
$assoCP = $tabIdentite [ 'CP' ];
$assoVille = $tabIdentite [ 'Ville' ];
$mail = trim ( $infoDemande [ 'Email' ]);
if ( $mail == '' ) $mail = $tabInfoUser [ 'email' ];
$tabInsert = array ( 'idUser' => $tabInfoUser [ 'id' ],
'source' => 'asso' ,
'login' => $tabInfoUser [ 'login' ],
'emailCommande' => $mail ,
'siren' => $siren ,
'refUtilisateur' => $infoDemande [ 'Ref' ],
'refDocument' => serialize ( $infoDemande ),
'refCommande' => serialize ( $infoAsso ),
'dateCommande' => DATETIME ,
);
$url = 'http://d2g.refasso.com/Dev2Go.web' ;
$referer = '' ; // http://d2g.refasso.com/dev2go.web?anchor=dem_statuts_02
$cookie = '' ;
$post = array ( 'mode' => 20 ,
'lBlockID' => 445031 ,
'sInputNames' => '' ,
'lFormSubAction' => 100 ,
'sLinkTo' => 'dem_statuts_03' ,
'iDune_DateDemande_input' => str_replace ( '/' , '%2F' , date ( 'd/m/Y' )),
'iDune_TitreAsso_input' => urlencode ( $assoNom ),
'iDune_SigleAsso_input' => urlencode ( $assoSigle ),
'iDune_AdresseAsso_input' => urlencode ( $assoAdresse ),
'iDune_CpAsso_input' => urlencode ( $assoCP ),
'iDune_VilleAsso_input' => urlencode ( $assoVille ),
'iDune_TelAsso_input' => '' ,
'iDune_FaxAsso_input' => '' ,
'iDune_EmailAsso_input' => '' ,
'iDune_DateCreaAsso_input' => '' ,
'iDune_DateDerDeclaAsso_input' => '' ,
'iDune_NomDem_input' => 'SCORES+ET+DECISIONS' ,
'iDune_PrenomDem_input' => 'Yoann+LE+NAOUR' ,
'iDune_AdresseDem_input' => '19+rue+de+Clairefontaine' ,
'iDune_CpDem_input' => 78120 ,
'iDune_VilleDem_input' => 'RAMBOUILLET' ,
'iDune_TelDem_input' => '0134573953' ,
'iDune_EmailDem_input' => 'asso%40scores-decisions.com' ,
'iDune_CGAccepte_input' => 'o' ,
'iDune_Statut_input' => 'n' ,
'iDune_Archive_input' => 'n' ,
'x' => 48 ,
'y' => 8 ,
);
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , $post , $referer , false , '' , '' , 7 );
$tfin = microtime ( true );
$duree = $tfin - $tdeb ;
$body = $page [ 'body' ];
$fp =@ fopen ( " /tmp/asso- $siren .html " , " a " );
@ fwrite ( $fp , $body );
@ fclose ( $fp );
if ( preg_match ( '/Votre commande est enregistr/i' , $body )) {
2010-11-29 14:17:26 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'asso@scores-decisions.com' , " Commande de statuts association pour $assoNom ( $siren ) " , " Association : " . EOL . print_r ( $infoAsso , true ) . EOL . EOL .
2010-11-04 11:05:01 +00:00
" Demandeur: " . EOL . print_r ( $infoDemande , true ) . EOL . EOL .
" R<EFBFBD> ponse RefAsso en $duree secondes : " . EOL . print_r ( $page , true ));
$ret = $iDbCrm -> insert ( 'commandes' , $tabInsert , true );
$tabRet = array ( 'siren' => $siren ,
'emailCommande' => $mail ,
'dateCommande' => DATETIME ,
'refCmde' => 'i' . $ret ,
);
@ sendMail ( 'production@scores-decisions.com' , $mail , " Votre commande de statuts association sur $assoNom ( $siren ) " , " Votre demande de statuts sur l'association $assoNom a <20> t<EFBFBD> prise en compte sous la r<> f<EFBFBD> rence i $ret - " . DATETIME );
wsLog ( 'commandeAsso' , $siren , 'i' . $ret . '-' . DATETIME );
debugLog ( 'I' , " commandeAsso pour $assoNom ( $siren ) fin " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
} else {
2010-11-29 14:17:26 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'asso@scores-decisions.com' , " ERREUR lors de lommande de statuts association pour $assoNom ( $siren ) " , " Association : " . EOL . print_r ( $infoAsso , true ) . EOL . EOL .
2010-11-04 11:05:01 +00:00
" Demandeur: " . EOL . print_r ( $infoDemande , true ) . EOL . EOL .
" R<EFBFBD> ponse RefAsso en $duree secondes : " . EOL . print_r ( $page , true ));
$tabRet = array ( 'siren' => $siren ,
'emailCommande' => $mail ,
'dateCommande' => DATETIME ,
'refCmde' => 'ERREUR' ,
);
debugLog ( 'E' , " commandeAsso pour $assoNom ( $siren ) fin " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
/** Retourne la liste des codes devises , libell<EFBFBD> s , date et valeur ( toutes les devises ou une seule )
**
** @ nodoc
** @ param string $devise Devise sur 3 lettres ( facultatif )
** @ return array
**/
function getDeviseCours ( $devise = false ) {
$iDb = new WDB ( 'sdv1' );
if ( $devise ) $strDevise = " AND c.devise=' $devise ' " ;
else $strDevise = '' ;
$tabRet = array ();
$res = $iDb -> select ( 'devise_cours c, devise_liste l' , 'c.devise, l.devNom, max(c.date) as dateChange, c.valeur' , " c.devise=l.devIso $strDevise GROUP BY c.devise ORDER BY c.devise ASC " , false , MYSQL_ASSOC );
foreach ( $res as $tabDev ) {
$tabRet [] = array ( 'codeDevise' => $tabDev [ 'devise' ],
'nomDevise' => prepareString ( $tabDev [ 'devNom' ]),
'dateChange' => $tabDev [ 'dateChange' ],
'valeurDevise' => $tabDev [ 'valeur' ],
);
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
/** Retourne la liste des banques connues pour une entreprise
**
** @ nodoc
** @ param string $siren Siren de l ' entreprise
** @ return array
**/
function getBanques ( $siren ) {
$iDb = new WDB ( 'sdv1' );
$tabRet = array ();
debugLog ( 'I' , " Liste des banques demand<6E> e pour siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( $siren * 1 > 1000 ) {
$res = $iDb -> select ( 'banques' , 'codeBanque, codeGuichet, libBanqueGuichet, precis, dateSource*1 AS dateSource' , " siren= $siren " , false , MYSQL_ASSOC );
$tmp = $iDb -> select ( 'fedRib' , " codeBanque, codeGuichet, CONCAT(libBanque,' ',libGuichet) AS libBanqueGuichet, 0 AS precis, IF (dateInfo='0000-00-00', dateDispo*1, dateInfo*1) AS dateSource " , " siren= $siren " , false , MYSQL_ASSOC );
$res = array_merge ( $res , $tmp );
foreach ( $res as $tabBanque ) {
$dateSource = $tabBanque [ 'dateSource' ];
$codBanque = $tabBanque [ 'codeBanque' ];
$codGuichet = $tabBanque [ 'codeGuichet' ];
$libBanque = trim ( $tabBanque [ 'libBanqueGuichet' ]);
$found = false ;
$adrBanque1 = $adrBanque2 = $adrBanqueCP = $adrBanqueVille = '' ;
if ( $codBanque > 0 && $codGuichet > 0 && $dateSource > ( date ( 'Y' ) - 4 ) * 10000 + 101 && $dateSource < date ( 'Ymd' )) {
$tmp = $iDb -> select ( 'insee.BDF_Etabs b, insee.BDF_Guichets g' , 'g.bdfFibCodeEtab AS banque, g.bdfFibCodeGuichet AS guichet, b.bdfFibDenom40 AS nomBanque, b.bdfFibDenom10 AS sigleBanque, g.bdfFibDenom20 AS nomGuichet, g.bdfFibAdresse1 AS adresse1, g.bdfFibAdresse2 AS adresse2, g.bdfFibAdresse3 AS adresse3, g.CP, g.Ville' , " g.bdfFibCodeEtab= $codBanque AND g.bdfFibCodeGuichet= $codGuichet AND b.bdfFibCodeEtab=g.bdfFibCodeEtab " , false , MYSQL_ASSOC );
if ( isset ( $tmp [ 0 ])) {
$libBanque = trim ( $tmp [ 0 ][ 'nomBanque' ] . ' ' . $tmp [ 0 ][ 'nomGuichet' ]);
$adrBanque1 = $tmp [ 0 ][ 'adresse1' ];
$adrBanque2 = trim ( $tmp [ 0 ][ 'adresse2' ] . ' ' . $tmp [ 0 ][ 'adresse3' ]);
$adrBanqueCP = $tmp [ 0 ][ 'CP' ];
$adrBanqueVille = $tmp [ 0 ][ 'Ville' ];
$found = true ;
};
}
if ( ! $found && $codBanque > 0 && $dateSource > ( date ( 'Y' ) - 4 ) * 10000 + 101 && $dateSource < date ( 'Ymd' )) {
$tmp = $iDb -> select ( 'insee.BDF_Etabs' , " bdfFibCodeEtab AS banque, '' AS guichet, bdfFibDenom40 AS nomBanque, '' AS nomGuichet, '' AS adresse1, '' AS adresse2, '' AS adresse3, '' AS CP, '' AS Ville " , " bdfFibCodeEtab= $codBanque " , false , MYSQL_ASSOC );
if ( isset ( $tmp [ 0 ])) {
$libBanque = trim ( $tmp [ 0 ][ 'nomBanque' ] . ' ' . $tmp [ 0 ][ 'nomGuichet' ]);
$adrBanque1 = $tmp [ 0 ][ 'adresse1' ];
$adrBanque2 = trim ( $tmp [ 0 ][ 'adresse2' ] . ' ' . $tmp [ 0 ][ 'adresse3' ]);
$adrBanqueCP = $tmp [ 0 ][ 'CP' ];
$adrBanqueVille = $tmp [ 0 ][ 'Ville' ];
} else continue ;
} else continue ;
$tabRet [] = array ( 'codeBanque' => $codBanque ,
'codeGuichet' => $codGuichet ,
'libBanque' => prepareString ( $libBanque ),
'adresse1' => prepareString ( $adrBanque1 ),
'adresse2' => prepareString ( $adrBanque2 ),
'cp' => prepareString ( $adrBanqueCP ),
'ville' => prepareString ( $adrBanqueVille ),
);
}
} else {
return array ( 'error' => array ( 'errnum' => 75454698 , 'errmsg' => 'Siren invalide' ), 'results' => $tabRet );
}
debugLog ( 'I' , " Liste des banques pour siren $siren : " . count ( $tabRet ) . ' banques' , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( count ( $tabRet ) == 0 ) {
return array ( 'error' => array ( 'errnum' => 256454 , 'errmsg' => 'Aucune relation bancaire en base' ), 'results' => $tabRet );
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
/** Commande d 'une enqu<71> te sur une entreprise en France ou <20> l' Internationale
** @ param string $siren
** @ param array $infoEnq
** @ param array $infoDemande
**/
function commandeEnquete ( $siren , $infoEnq = array (), $infoDemande = array ()) {
global $iDbCrm ;
global $tabInfoUser ;
$mail = trim ( $infoDemande [ 'Email' ]);
if ( $mail == '' ) $mail = $tabInfoUser [ 'email' ];
$tabInsert = array ( 'idUser' => $tabInfoUser [ 'id' ],
'source' => 'intersud' , // 'greffes', 'asso', 'graydon'
'login' => $tabInfoUser [ 'login' ],
'emailCommande' => $mail ,
'siren' => $siren ,
'refDocument' => serialize ( $infoDemande ),
'refCommande' => serialize ( $infoEnq ),
'dateCommande' => DATETIME ,
// 'idClient'=> $tabInfoUser['idClient'],
);
2011-06-09 09:39:42 +00:00
debugLog ( 'I' , " Intersud, d<> but commande sur $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-04 11:05:01 +00:00
$messageInfo = print_r ( $infoEnq , 1 ) . EOL . print_r ( $infoDemande , 1 ) . EOL ;
$idClient = $tabInfoUser [ 'idClient' ];
$rep = $iDbCrm -> select ( 'clients' , ' nom, racineLogin, InterSudLogin, InterSudPass' , " id=' $idClient ' " , false , MYSQL_ASSOC );
$login = trim ( $rep [ 0 ][ 'InterSudLogin' ]);
$pass = trim ( $rep [ 0 ][ 'InterSudPass' ]);
$nomClient = trim ( strtoupper ( $rep [ 0 ][ 'nom' ]));
$strInfoCommande = " NOM et Pr<50> nom du client demandeur : " . $infoDemande [ 'Identite' ] . EOL ;
$strInfoCommande .= " Email du client demandeur : $mail " . EOL ;
$strInfoCommande .= " Tel/Fax du demandeur : " . $infoDemande [ 'Tel' ] . ' / ' . $infoDemande [ 'Fax' ] . EOL ;
$strInfoCommande .= " Profil du demandeur : " . trim ( $infoDemande [ 'Profil' ] . ' ' . $infoDemande [ 'ProfilAutre' ]) . EOL ;
$typeEnqLog = 'enqueteDemNF' ;
2011-06-09 09:39:42 +00:00
if ( $login == '' || $pass == '' ) {
2010-11-04 11:05:01 +00:00
/** Il ne s'agit pas d'un client final, on anonymise la commande **/
$login = 'YLENA' ; // Demandes en test
$pass = 'WYLFE' ;
$nomClient = $strInfoCommande = '' ;
$typeEnqLog = 'enqueteDem' ;
/* ENQUETES EN PROD
$login = 'FACTURE' ;
$pass = 'AWKROM' ;
*/
}
2011-06-09 09:39:42 +00:00
/** Connexion <EFBFBD> l ' Extranet Intersud
**/
2010-11-04 11:05:01 +00:00
$url = 'http://www.intersud.fr/espace_client/espace_client.php' ;
$cookie = $referer = '' ;
$tabPost = array ( 'login' => $login ,
'pwd' => $pass ,
);
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , $tabPost , $referer , false , '' , '' , 7 );
2011-06-09 09:39:42 +00:00
if ( $page [ 'code' ] <> 200 ) {
$tabRet = array ();
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ATTENTION : Commande d'enquete sur $siren " , " Connexion impossible <20> la plateforme Intersud " . EOL . $strInfoCommande );
// wsLog($typeEnqLog, $siren, 'i'.$ret.'-'.DATETIME);
return array ( 'error' => array ( 'errnum' => 4563456 , 'errmsg' => 'Connexion impossible <20> la plateforme d\'enquetes' ), 'results' => $tabRet );
}
2010-11-04 11:05:01 +00:00
$tfin = microtime ( true );
$duree = $tfin - $tdeb ;
$referer = $url ;
$body = $page [ 'body' ];
$cookie = $page [ 'header' ][ 'Set-Cookie' ];
2011-06-09 09:39:42 +00:00
$intersudNomPrenom = $intersudRaisonSociale = '' ;
if ( preg_match ( '/<td colspan="5" class="txt_blanc" background="images_ec\/1erpageespaceclient_14\.jpg" width="274" height="22">(.*)<\/td>/Uis' , $body , $matches ))
$intersudNomPrenom = trim ( $matches [ 1 ]);
if ( preg_match ( '/<td class="txt_blanc" colspan="7" rowspan="2" valign="middle" background="images_ec\/1erpageespaceclient_17\.jpg">(.*)<\/td>/Uis' , $body , $matches ))
$intersudRaisonSociale = trim ( $matches [ 1 ]);
debugLog ( 'I' , " Intersud, connexion via $login pour $intersudRaisonSociale ( $intersudNomPrenom , cookie= $cookie ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
/* $fp =@ fopen ( " /var/www/html/ws2/intersud.log " , " a " );
@ fwrite ( $fp , EOL . DATETIME . EOL . print_r ( $page , true ) . '=========================================================================================================' . EOL . EOL );
@ fclose ( $fp );
die ();
*/
/** Page formulaire de demande d ' enqu<EFBFBD> te
**/
2010-11-04 11:05:01 +00:00
$url = 'http://intersud.fr/espace_client/demande_enquete.php' ;
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , '' , $referer , false , '' , '' , 7 );
2011-06-09 09:39:42 +00:00
if ( $page [ 'code' ] <> 200 ) {
$tabRet = array ();
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ATTENTION : Commande d'enquete sur $siren " , " Connexion impossible au formulaire d'enqu<71> te Intersud " . EOL . $strInfoCommande );
return array ( 'error' => array ( 'errnum' => 456345 , 'errmsg' => 'Connexion impossible <20> la plateforme d\'enquetes 2' ), 'results' => $tabRet );
}
2010-11-04 11:05:01 +00:00
$tfin = microtime ( true );
$duree += $tfin - $tdeb ;
$referer = $url ;
$body = $page [ 'body' ];
$fp =@ fopen ( " /var/www/html/ws2/intersud.log " , " a " );
@ fwrite ( $fp , print_r ( $page , true ));
@ fclose ( $fp );
$tabInterSud = array ();
if ( preg_match_all ( '/<input(?:.*)name="(.*)"(?:.*)value="(.*)"/Uim' , $body , $matches )) {
foreach ( $matches [ 1 ] as $i => $field ) {
$tmp = explode ( '"' , $matches [ 2 ][ $i ]);
$tabInterSud [ $field ] = $tmp [ 0 ];
}
}
if ( preg_match_all ( '/<input(?:.*)value="(.*)"(?:.*)name="(.*)"/Uim' , $body , $matches )) {
foreach ( $matches [ 2 ] as $i => $field ) {
$tmp = explode ( '"' , $matches [ 1 ][ $i ]);
$tabInterSud [ $field ] = $tmp [ 0 ];
}
}
2011-06-09 09:39:42 +00:00
$ref_exp = $tabInterSud [ 'ref_exp' ];
$email_exp = $tabInterSud [ 'email_exp' ];
$tel_exp = $tabInterSud [ 'tel_exp' ];
debugLog ( 'I' , " Intersud, formulaire enqu<71> te ref $ref_exp , $email_exp , $tel_exp " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-04 11:05:01 +00:00
$fp =@ fopen ( " /var/www/html/ws2/intersud.log " , " a " );
@ fwrite ( $fp , print_r ( $matches , true ));
@ fwrite ( $fp , print_r ( $tabInterSud , true ));
@ fclose ( $fp );
2011-06-09 09:39:42 +00:00
/** Insertion de la commande en base
**/
2010-11-04 11:05:01 +00:00
$ret = $iDbCrm -> insert ( 'commandes' , $tabInsert , true );
$comment = " R<EFBFBD> f<EFBFBD> rence de la commande chez Scores et D<> cisions : i $ret - " . DATETIME . "
Date et heure de la commande : " .date('d/m/Y - H:i'). "
Origine de la commande : $nomClient
$strInfoCommande
CA : " . $infoEnq['Precisions'] ['MontantCA']. "
Motif de la demande : " .trim( $infoEnq['Precisions'] ['Motif'].' '. $infoEnq['Precisions'] ['Autre']). "
Type de la demande : " . $infoEnq['Precisions'] ['Type']. "
Anciennete de la relation : " . $infoEnq['Anciennete'] .' '. $infoEnq['AncienneteDuree'] . "
Observations : " . $infoEnq['Observation'] .EOL;
if ( $infoEnq [ 'ImpayeesChoix' ] <> 'non' )
$comment .= " Impay<EFBFBD> (s) : " . $infoEnq [ 'Impayees' ][ 'Nombre' ] . " impay<61> (s) pour un montant de " . $infoEnq [ 'Impayees' ][ 'Montant' ] . " en date du " . $infoEnq [ 'Impayees' ][ 'Date' ] . EOL ;
if ( $infoEnq [ 'RetardPaiementChoix' ] <> 'non' )
$comment .= " Retard(s) de paiement : " . $infoEnq [ 'RetardPaiement' ][ 'Nombre' ] . " retard(s) pour un montant de " . $infoEnq [ 'RetardPaiement' ][ 'Montant' ] . " en date du " . $infoEnq [ 'RetardPaiement' ][ 'Date' ] . EOL ;
if ( $infoEnq [ 'LitigeChoix' ] <> 'non' )
$comment .= " Pr<EFBFBD> sence de litige(s) : " . $infoEnq [ 'Litige' ][ 'Precisions' ] . EOL ;
$enqType = 0 ;
$enqDelai = 7 ;
switch ( strtolower ( $infoEnq [ 'Type' ])) {
case 'premier' : $enqType = 0 ; $enqDelai = 6 ; break ;
case 'gold' : $enqType = 1 ; break ;
case 'distrimat' : $enqType = 2 ; break ;
case 'star' : $enqType = 3 ; break ;
case 'avis_bancaire' : $enqType = 4 ; break ;
case 'autre' : $enqType = 5 ; break ;
}
/** Ajout du RIB si communiqu<71> **/
if ( @ trim ( implode ( ' ' , $infoEnq [ 'Entrep' ][ 'Rib' ])) <> '' )
$iDbCrm -> insert ( 'banques' , array ( 'siren' => $siren ,
'libBanqueGuichet' => '' ,
'precis' => 1 ,
'codeBanque' => $infoEnq [ 'Entrep' ][ 'Rib' ][ 'Banque' ],
'codeGuichet' => $infoEnq [ 'Entrep' ][ 'Rib' ][ 'Guichet' ],
'numCompte' => $infoEnq [ 'Entrep' ][ 'Rib' ][ 'Compte' ] . $infoEnq [ 'Entrep' ][ 'Rib' ][ 'Cle' ],
'dateSource' => DATETIME ,
), true );
2011-06-09 09:39:42 +00:00
/** Remplissage du formulaire d'enqu<71> te pour soumission <20> Intersud **/
2010-11-04 11:05:01 +00:00
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $siren );
$tabPost = array ( 'soc' => $tabIdentite [ 'Nom' ],
'cible_enk' => 9 , // 9
'siret' => $siren ,
'acti' => '' ,
'soc_exp' => $tabInterSud [ 'soc_exp' ],
'type_enk' => $enqType , // 0=Premier, 1=Gold, 2=Distrimat, 3=Star, 4=Avis bancaire, 5=Autre
'nom_diri' => '' ,
'adr' => $tabIdentite [ 'Adresse' ],
'ref_exp' => $tabInterSud [ 'ref_exp' ],
'autre_type_enk' => '' , // Texte libre
'adr2' => $tabIdentite [ 'Adresse2' ],
'delai_enk' => $enqDelai , // 6=24h, 7=72h, 8=+de5jours
'ville' => $tabIdentite [ 'Ville' ],
'cp' => $tabIdentite [ 'CP' ],
'pays' => '' , // International ?
'nom_exp' => $tabInterSud [ 'nom_exp' ],
'tel' => $tabIdentite [ 'Tel' ],
'port' => $infoEnq [ 'Entrep' ][ 'AutreTel' ],
'tel_exp' => $tabInterSud [ 'tel_exp' ],
'bank' => trim ( implode ( ' ' , $infoEnq [ 'Entrep' ][ 'Rib' ])),
'int_enk' => $tabInterSud [ 'int_enk' ], // International ?
'encours' => $infoEnq [ 'Encours' ],
'nb_ech' => $infoEnq [ 'NbEcheances' ],
'delai2_enk' => $tabInterSud [ 'delai2_enk' ], // International ?
'email_exp' => $tabInterSud [ 'email_exp' ],
'cred' => '' ,
'comment' => urlencode ( $comment ),
2011-06-09 09:39:42 +00:00
'val_ret' => $tabInterSud [ 'val_ret' ],
2010-11-04 11:05:01 +00:00
);
$url = 'http://intersud.fr/espace_client/demande_enquete.php' ;
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , $tabPost , $referer , false , '' , '' , 7 );
2011-06-09 09:39:42 +00:00
if ( $page [ 'code' ] <> 200 ) {
$tabRet = array ();
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ATTENTION : Commande d'enquete sur $siren " , " Validation impossible du formulaire d'enqu<71> te Intersud " . EOL . $strInfoCommande );
return array ( 'error' => array ( 'errnum' => 456345 , 'errmsg' => 'Connexion impossible <20> la plateforme d\'enquetes 3' ), 'results' => $tabRet );
}
2010-11-04 11:05:01 +00:00
$tfin = microtime ( true );
$duree += $tfin - $tdeb ;
$referer = $url ;
$body = $page [ 'body' ];
$tabRet = array ( 'siren' => $siren ,
'emailCommande' => $mail ,
'dateCommande' => DATETIME ,
'refCmde' => 'i' . $ret ,
);
//$strInfoCommande $mail
2011-06-09 09:39:42 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " Commande d'enquete sur $siren " , $comment . EOL . EOL . '---------------------------------' . EOL . $messageInfo . EOL . EOL . '---------------------------------' . EOL . $body );
2010-11-04 11:05:01 +00:00
@ sendMail ( 'production@scores-decisions.com' , $mail , " Votre demande d'enquete sur " . $tabIdentite [ 'Nom' ] . " ( $siren ) " , " Votre demande d'enqu<71> te sur la soci<63> t<EFBFBD> " . $tabIdentite [ 'Nom' ] . " a <20> t<EFBFBD> prise en compte sous la r<> f<EFBFBD> rence i $ret - " . DATETIME );
wsLog ( $typeEnqLog , $siren , 'i' . $ret . '-' . DATETIME );
2011-06-09 09:39:42 +00:00
/** Gestion de la d<> connexion **/
$url = 'http://intersud.fr/espace_client/index.php?code_ret=9' ;
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , '' , $referer , false , '' , '' , 7 );
$tfin = microtime ( true );
$duree += $tfin - $tdeb ;
$ret = $iDbCrm -> update ( 'commandes' , array ( 'dureeCommande' => round ( $duree , 3 )), " idCommande= $ret " );
2010-11-04 11:05:01 +00:00
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
/** @ nodoc
**
** @ param unknown_type $siren
** @ param unknown_type $niveau
** @ param unknown_type $id
** @ param unknown_type $forceVerif
** @ return unknown
**/
function getRapport ( $siren , $niveau = 3 , $id = 0 , $forceVerif = false ) {
$filtre = 0 ;
$idAnn = 0 ;
$accesDist = true ;
if ( $niveau == 1 )
$tabRet = array ( 'getIndiScore' => $this -> getIndiScore ( $siren , 0 , $accesDist ),
);
elseif ( $niveau == 2 )
$tabRet = array ( 'getIdentite' => $this -> getIdentite ( $siren , $id = 0 , $forceVerif ),
'getDirigeants' => $this -> getDirigeants ( $siren , false ),
'getLiens' => $this -> getLiens ( $siren , true ),
'getRatios' => $this -> getRatios ( $siren , $page = " rapport $niveau " ),
'getIndiScore' => $this -> getIndiScore ( $siren , 0 , $accesDist ),
);
elseif ( $niveau == 3 )
$tabRet = array ( 'getIdentite' => $this -> getIdentite ( $siren , $id = 0 , $forceVerif ),
'getDirigeants' => $this -> getDirigeants ( $siren , false ),
'getLiens' => $this -> getLiens ( $siren , true ),
'getRatios' => $this -> getRatios ( $siren , $page = " rapport $niveau " ),
'getIndiScore' => $this -> getIndiScore ( $siren , 0 , $accesDist ),
'getAnnonces' => $this -> getAnnonces ( $siren , $filtre , $idAnn ),
);
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ),
'results' => $tabRet );
}
/** Retourne les informations identitaires de l 'entreprise ou de l' <EFBFBD> tablissement demand<EFBFBD>
**
** @ param integer $siret Siren de l 'entreprise ou siret de l' <EFBFBD> tablissement
** @ param integer $id Identifiant S & D de l ' <EFBFBD> tablissement
** @ return array Fiche d 'identit<69> de l' <EFBFBD> tablissement
**/
function getIdentiteAGS ( $siret , $id = 0 , $forceVerif = false ) {
debugLog ( 'I' , " Identit<EFBFBD> AGS demand<6E> e pour siret $siret (id= $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$siret = trim ( $siret );
$len = strlen ( $siret );
$id = trim ( $id ) * 1 ;
if ( $len == 14 ) $nic = substr ( '' . $siret , 9 , 5 ) * 1 ;
elseif ( $len == 9 ) $nic = 0 ;
elseif ( $len == 0 ) { $siren = 0 ; $nic = 0 ; }
else {
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren Siret inexistant' ), 'result' => $tabRet );
}
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
if ( $siren == 0 && $id == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
debugLog ( 'I' , " Avant getIdentiteEntreprise( $siren , $nic , $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$entrep = $this -> iInsee -> getIdentiteEntreprise ( $siren , $nic , $id , $forceVerif );
debugLog ( 'I' , " Apr<EFBFBD> s getIdentiteEntreprise( $siren , $nic , $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$duree = round ( microtime ( 1 ) - $tdeb , 3 );
$ligne = date ( 'YmdHis' ) . " ; $siret ;Ws->getIdentite juste apres iInsee->... ( $duree s) " ;
$fp = fopen ( '/var/www/log/accesDistant.log' , 'a' );
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
if ( empty ( $entrep )) {
debugLog ( 'W' , " Siren $siren non pr<70> sent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$tabRet = array ( 'id' => $entrep [ 'id' ],
'Siret' => $entrep [ 'Siret' ],
'SiretSiege' => $entrep [ 'SiretSiege' ],
'Siege' => $entrep [ 'Siege' ],
'TribunalCode' => prepareString ( $entrep [ 'Tribunal' ]),
'TribunalLib' => prepareString ( $entrep [ 'TribunalLib' ]),
//'NumGreffe' =>$entrep['numGreffe'], // Ajout<75> le 4 08 2009
'NumRC' => $entrep [ 'numRC' ], // Ajout<75> le 4 08 2009
'Actif' => $entrep [ 'Actif' ],
'AutreId' => $entrep [ 'AutreId' ],
'Source' => $entrep [ 'Source' ],
'SourceId' => $entrep [ 'SourceId' ],
'Isin' => $entrep [ 'Isin' ],
'Nom' => prepareString ( strtr ( $entrep [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $entrep [ 'Nom2' ]),
'NomLong' => prepareString ( $entrep [ 'nomLong' ]), // Ajout<75> le 4 08 2009
'Siret' => $entrep [ 'Siret' ],
'Sigle' => prepareString ( $entrep [ 'Sigle' ]),
'SigleLong' => prepareString ( $entrep [ 'sigleLong' ]), // Ajout<75> le 4 08 2009
'Enseigne' => prepareString ( $entrep [ 'Enseigne' ]),
'Adresse' => prepareString ( $entrep [ 'Adresse' ]),
'Adresse2' => prepareString ( $entrep [ 'Adresse2' ]),
'AdresseNum' => prepareString ( $entrep [ 'AdresseNum' ]),
'AdresseBtq' => prepareString ( $entrep [ 'AdresseBtq' ]),
'AdresseVoie' => prepareString ( $entrep [ 'AdresseVoie' ]),
'AdresseRue' => prepareString ( $entrep [ 'AdresseRue' ]),
'CP' => $entrep [ 'CP' ],
'Ville' => prepareString ( $entrep [ 'Ville' ]),
'Pays' => prepareString ( $entrep [ 'Pays' ]), // Ajout<75> le 18 02 2008
'Civilite' => $entrep [ 'Civilite' ],
'NbEtab' => $entrep [ 'NbEtab' ],
'Tel' => prepareString ( $entrep [ 'Tel' ]),
'Fax' => prepareString ( $entrep [ 'Fax' ]),
'Web' => prepareString ( $entrep [ 'Web' ]),
'Mail' => prepareString ( $entrep [ 'Mail' ]),
'GeoLat' => $entrep [ 'GeoLat' ],
'GeoLon' => $entrep [ 'GeoLon' ],
'GeoPrecis' => $entrep [ 'GeoPrecis' ],
'GeoInfos' => $entrep [ 'GeoInfos' ],
'TvaNumero' => $entrep [ 'TvaNumero' ],
'TvaAttribue' => $entrep [ 'TvaAttribue' ],
'FJ' => $entrep [ 'FJ' ],
'FJ_lib' => prepareString ( $entrep [ 'FJ_lib' ]),
'FJ2' => $entrep [ 'FJ2' ], // Ajout<75> le 4 08 2009
'FJ2_Lib' => prepareString ( $entrep [ 'FJ2_Lib' ]), // Ajout<75> le 4 08 2009
'Siren' => $entrep [ 'Siren' ],
'Nic' => $entrep [ 'Nic' ],
'NafEnt' => $entrep [ 'NafEnt' ],
'NafEntLib' => prepareString ( $entrep [ 'NafEntLib' ]),
'NafEtab' => $entrep [ 'NafEtab' ],
'NafEtabLib' => prepareString ( $entrep [ 'NafEtabLib' ]),
'Activite' => prepareString ( $entrep [ 'Activite' ]),
'Capital' => $entrep [ 'Capital' ],
'CapitalDev' => $entrep [ 'CapitalDev' ],
'CapitalLib' => prepareString ( $entrep [ 'CapitalLib' ]), // Ajout<75> le 18 02 2008
'CapitalType' => prepareString ( $entrep [ 'CapitalType' ]), // Ajout<75> le 4 08 2009
'DateCreaEt' => $entrep [ 'DateCreaEt' ],
'DateCreaEn' => $entrep [ 'DateCreaEn' ],
'DateClotEt' => $entrep [ 'DateClotEt' ],
'DateImmat' => $entrep [ 'dateImmat' ], // Ajout<75> le 4 08 2009
'DateRadiation' => $entrep [ 'dateRad' ], // Ajout<75> le 4 08 2009
// 'DateMajRCS' =>$entrep['DateMajRCS'], // Ajout<75> le 4 08 2009
'EffEnTr' => prepareString ( $entrep [ 'EffEnTr' ]),
'EffEnTrLib' => prepareString ( $entrep [ 'EffEnTrLib' ]),
'Effectif' => prepareString ( $entrep [ 'Effectif' ]),
'Dept' => $entrep [ 'Dept' ],
'codeCommune' => prepareString ( $entrep [ 'codeCommune' ]),
'TrancheCA' => prepareString ( $entrep [ 'TrancheCA' ]),
'TrancheCALib' => prepareString ( $entrep [ 'TrancheCALib' ]),
'dir1Code' => $entrep [ 'dir1Code' ],
'dir1Titre' => prepareString ( $entrep [ 'dir1Titre' ]), //utf8
'dir1NomPrenom' => prepareString ( $entrep [ 'dir1NomPrenom' ]),
'dir1DateFct' => prepareString ( $entrep [ 'dir1DateFct' ]),
'dir1DateNaiss' => $entrep [ 'dir1DateNaiss' ], // Ajout<75> le 4 08 2009
'dir1LieuNaiss' => prepareString ( $entrep [ 'dir1LieuNaiss' ]), // Ajout<75> le 4 08 2009
'dir2Code' => $entrep [ 'dir2Code' ],
'dir2Titre' => prepareString ( $entrep [ 'dir2Titre' ]), //utf8
'dir2NomPrenom' => prepareString ( $entrep [ 'dir2NomPrenom' ]),
'dir2DateFct' => prepareString ( $entrep [ 'dir2DateFct' ]),
'dir2DateNaiss' => $entrep [ 'dir2DateNaiss' ], // Ajout<75> le 4 08 2009
'dir2LieuNaiss' => prepareString ( $entrep [ 'dir2LieuNaiss' ]), // Ajout<75> le 4 08 2009
'Rivoli' => $entrep [ 'Rivoli' ],
'NatureActivite' => $entrep [ 'NatureActivite' ], // Nature de l'activit<69>
'OrigineCreation' => $entrep [ 'OrigineCreation' ], // Origine de la cr<63> ation
'TypeExploitation' => $entrep [ 'TypeExploitation' ],
'Auxiliaire' => $entrep [ 'Auxiliaire' ], // 1=Auxiliaire / 0=Non auxiliaire
'Saisonnalite' => $entrep [ 'Saisonnalite' ], // P=Activit<69> permanente / S=Activit<69> saisonni<6E> re
'SituationJuridique' => $entrep [ 'SituationJuridique' ],
'Bilan' => array ( 'Cloture' => $entrep [ 'bilanDate' ],
'Duree' => $entrep [ 'bilanMois' ],
'Devise' => $entrep [ 'bilanDevise' ],
'Capital' => $entrep [ 'bilanDA' ],
'CA' => $entrep [ 'bilanFL' ],
'Resultat' => $entrep [ 'bilanHN' ],
'Effectif' => $entrep [ 'bilanYP' ],
),
'Bourse' => $entrep [ 'Bourse' ],
'AutreSiren' => $entrep [ 'AutreSiren' ],
'DateMajINSEE' => $entrep [ 'DateMajINSEE' ],
'DateMajRCS' => $entrep [ 'DateMajRCS' ],
'DateMajBILAN' => $entrep [ 'bilanDateMaj' ],
'DateMajANN' => $entrep [ 'dateMajANN' ],
'DateMajID' => $entrep [ 'dateMajIdentite' ],
//'importExport' =>$entrep['importExport'],
);
$anns = $this -> getAnnonces ( $siren , 1 );
$tabRetAnn = $tabLastEven = array ();
$anns = $anns [ 'result' ];
$tribunalProcol = false ;
foreach ( $anns as $nb => $ann ) {
$tabRetEven = array ();
foreach ( $ann [ 'evenements' ] as $tabEven ) {
// On ignore les <20> l<EFBFBD> ments suivants
if ( $tabEven [ 'CodeEven' ] >= 7000 ) continue ;
if ( $tabEven [ 'CodeEven' ] >= 4000 && $tabEven [ 'CodeEven' ] <= 4999 ) continue ;
// Par d<> faut, on force le tribunal <20> celui pr<70> sent dans la derni<6E> re annonce de Procol
if ( $tribunalProcol == false && $tabEven [ 'CodeEven' ] >= 1000 && $tabEven [ 'CodeEven' ] < 2000 && $ann [ 'BodaccCode' ] == 'BODA' ) {
$tabRet [ 'TribunalCode' ] = $ann [ 'TribunalCode' ];
$tabRet [ 'TribunalLib' ] = prepareString ( $ann [ 'Tribunal' ]);
$tribunalProcol = true ;
}
// On ne prend que le dernier <20> l<EFBFBD> ment de chaque type
if ( in_array ( $tabEven [ 'CodeEven' ], $tabLastEven )) continue ;
$tabLastEven [] = $tabEven [ 'CodeEven' ];
$tabRetEven [] = array ( 'CodeEven' => $tabEven [ 'CodeEven' ],
'LibEven' => prepareString ( $tabEven [ 'LibEven' ]));
}
if ( count ( $tabRetEven ) > 0 ) {
$tabRetAnn [] = array ( 'id' => $ann [ 'id' ],
'BodaccCode' => $ann [ 'BodaccCode' ],
'BodaccNum' => $ann [ 'BodaccNum' ],
'NumAnnonce' => $ann [ 'NumAnnonce' ],
'DateParution' => $ann [ 'DateParution' ],
'Departement' => $ann [ 'Departement' ],
'Tribunal' => $ann [ 'Tribunal' ],
'TribunalSiret' => $ann [ 'TribunalSiret' ],
'Rubrique' => $ann [ 'Rubrique' ],
'typeAnnonce' => $ann [ 'typeAnnonce' ],
'texteRectificatif' => $ann [ 'texteRectificatif' ],
'texteAnnonce' => $ann [ 'texteAnnonce' ],
'dateEffet' => $ann [ 'dateEffet' ],
'dateJugement' => $ann [ 'dateJugement' ],
'dateInsertionSD' => $ann [ 'dateInsertionSD' ],
'evenements' => $tabRetEven ,
'Lien_Annonce_Pdf' => $ann [ 'Lien_Annonce_Pdf' ]
);
}
}
$tabRet [ 'Annonces' ] = $tabRetAnn ;
$iRncs = new MRncs ();
if ( $entrep [ 'Siege' ] == 1 || $entrep [ 'Siege' ] == 11 )
$tabRet [ 'LibTypeEtab' ] = 'Etablissement Siege' ;
else {
$tabEtabRncs = $iRncs -> getIdentiteEtab ( $siren , $entrep [ 'Nic' ]);
if ( $tabEtabRncs [ 'Siege' ] == 2 ) $tabRet [ 'LibTypeEtab' ] = 'Etablissement Principal' ;
elseif ( $tabEtabRncs [ 'Siege' ] == 1 ) $tabRet [ 'LibTypeEtab' ] = 'Etablissement Complementaire' ;
elseif ( $tabEtabRncs [ 'Siege' ] == 0 ) $tabRet [ 'LibTypeEtab' ] = 'Etablissement Secondaire' ;
}
$tabJuge = $iRncs -> getIntervenants ( $siren );
$tabDepots = array ();
foreach ( $tabJuge as $iDepot => $depot ) {
$tabDepots [] = array ( 'codEven' => $depot [ 'codEven' ],
'libEven' => prepareString ( $depot [ 'libEven' ]),
'dateEffet' => $depot [ 'dateEffet' ],
'admcode' => $depot [ 'admcode' ],
'admfonction' => prepareString ( $depot [ 'admfonction' ]),
'admnom' => prepareString ( $depot [ 'admnom' ]),
'admadrNum' => $depot [ 'admadrNum' ],
'admadrInd' => $depot [ 'admadrInd' ],
'admadrVoie' => prepareString ( $depot [ 'admadrVoie' ]), // @todo : adm1adr1, adm1adr2, adm1adr3,
'admadrCP' => $depot [ 'admadrCP' ],
'admadrVille' => prepareString ( $depot [ 'admadrVille' ]),
);
}
$tabRet [ 'Organes' ] = $tabDepots ;
$mLiens = new MLiens ( $siren );
$tabA = $mLiens -> getActionnaires ( $siren , 1 );
$nbA = count ( $tabA );
$tabAct = array ();
foreach ( $tabA as $i => $lien )
$tabAct [] = array ( 'Pmin' => $lien [ 'Pmin' ],
'MajMin' => $lien [ 'MajMin' ],
'RaisonSociale' => prepareString ( $lien [ 'RaisonSociale' ]),
'Pays' => prepareString ( $lien [ 'Pays' ]),
'Siren' => $lien [ 'Siren' ],
'Actif' => $lien [ 'Actif' ],
);
$tabRet [ 'Actionnaires' ] = $tabAct ;
$iGreffes = new MGreffes ();
$tabActes = $iGreffes -> getListeActes ( $siren );
$tabRet [ 'StatutsModifDepot' ] = $tabRet [ 'StatutsModif' ] = '0000-00-00' ;
foreach ( $tabActes as $i => $acte ) {
if ( '_' . $acte [ 'acte_type' ] == '_04' ) { // STATUTS CONSTITUTIFS
$tabRet [ 'StatutsConstDepot' ] = $acte [ 'depot_date' ]; // => 1997-12-18
$tabRet [ 'StatutsConst' ] = $acte [ 'acte_date' ]; // => 1997-11-13
break ;
} elseif ( in_array ( '_' . $acte [ 'acte_type' ],
array ( //'_04', // STATUTS CONSTITUTIFS
'_06' , // STATUTS A JOUR 9 0000-00-00 2009-09-02 17:05:55
'_07' , // STATUTS A JOUR 9 0000-00-00 2009-09-02 17:05:55
'_08' , // STATUTS A JOUR ET DECLARATION DE CONFORMITE 9 0000-00-00 2009-09-02 17:05:55
'_09' , // STATUTS APRES TRANSFERT DE SIEGE 9 0000-00-00 2009-09-02 17:05:55
'_A1' , // STATUTS 9 0000-00-00 2009-09-02 17:05:55
'_AH' , // AVENANT AUX STATUTS
))) {
// On ne prend que la derni<6E> re modif
if ( $tabRet [ 'StatutsModifDepot' ] == '0000-00-00' && $tabRet [ 'StatutsModif' ] == '0000-00-00' ) {
$tabRet [ 'StatutsModifDepot' ] = $acte [ 'depot_date' ]; // => 1997-12-18
$tabRet [ 'StatutsModif' ] = $acte [ 'acte_date' ]; // => 1997-11-13
}
}
}
/** Y a t il eu des informations relatives <20> une cession ? **/
$tabCes = $iGreffes -> getInfosCessions ( $siren );
if ( $tabCes ) {
$tabRet [ 'CessionJugeLib' ] = $tabCes [ 'cessJuge' ];
$tabRet [ 'CessionJugeDate' ] = $tabCes [ 'cessDateJuge' ];
$tabRet [ 'CessionAvisBodac' ] = $tabCes [ 'cessDateBod' ];
$tabRet [ 'CessionInvenDate' ] = $tabCes [ 'cessDateInv' ];
$tabRet [ 'CessionCAdeclare' ] = $tabCes [ 'cessCAdec' ];
$tabRet [ 'CessionEffectif' ] = $tabCes [ 'cessEffectif' ];
$tabRet [ 'CessionDesc' ] = $tabCes [ 'cessDesc' ];
$tabRet [ 'CessionDescDate' ] = $tabCes [ 'cessDateDesc' ];
$tabRet [ 'CessionOffreDate' ] = $tabCes [ 'cessDateLim' ];
$tabRet [ 'CessionMandataire' ] = $tabCes [ 'cessMand' ];
}
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug $siren", print_r($tabActes,true)) ;
global $tabInfoUser ;
if ( preg_match ( '/NAF4/i' , $tabInfoUser [ 'pref' ])) {
$entrep2 = $this -> iInsee -> getNaf4 ( $siren , $nic , $id );
$tabRet [ 'Naf4Ent' ] = $entrep2 [ 'apen4' ];
$tabRet [ 'Naf4Etab' ] = $entrep2 [ 'apet4' ];
$tabRet [ 'Naf4EntLib' ] = prepareString ( $entrep2 [ 'apen4_lib' ]);
$tabRet [ 'Naf4EtabLib' ] = prepareString ( $entrep2 [ 'apet4_lib' ]);
}
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug $siren", print_r($tabRet,true)) ;
debugLog ( 'I' , 'Etablissement retourn<72> = ' . $entrep [ 'Nom' ], __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'identite' , $siret , $id );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
function getIdentiteProcol ( $siret , $id = 0 , $forceVerif = false ) {
return $this -> getIdentiteAGS ( $siret , $id , $forceVerif );
}
/** Liste des privil<EFBFBD> ges pour une entreprise en suivi Privil<EFBFBD> ges
**
** @ param string $siren
** @ param bool $detail
** @ param array $tabTypes
*/
function getPrivileges ( $siren , $detail = false , $tabTypes = array ( '03' , '04' )) {
debugLog ( 'I' , " Liste des privil<69> ges $detail sur $siren " . print_r ( $tabTypes , true ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iPriv = new MPrivileges ();
if ( $detail )
$ret = $iPriv -> getPrivilegesDetail ( $siren , $tabTypes );
//foreach ($ret as )
else
$ret = $iPriv -> getPrivilegesCumul ( $siren , $tabTypes );
return $ret ;
}
/** Recherche d 'entreprise ou d' <EFBFBD> tablissement par leur identifiant interne
**
** @ param integer $refClient Ref<EFBFBD> rence Interne de l 'entreprise ou de l' <EFBFBD> tablissement dans la base du client
** @ param integer $deb Position du curseur dans la liste des r<EFBFBD> ponses ( 0 par d<EFBFBD> faut )
** @ param integer $nbRep Nombre de r<EFBFBD> ponses retourn<EFBFBD> es au maximum par cette requete ( 20 par d<EFBFBD> faut )
** @ param integer $maxRep Nombre de r<EFBFBD> ponses recherch<EFBFBD> es au maximum ( 200 par d<EFBFBD> faut )
** @ return Liste d ' <EFBFBD> tablissements
**/
function searchRefClient ( $refClient , $deb = 0 , $nbRep = 20 , $maxRep = 200 ) {
global $tabInfoUser ;
$tabRet = array ();
debugLog ( 'I' , " Recherche par R<> f<EFBFBD> rence Interne= $refClient avec un maximum de $maxRep r<> ponses pour la tranche $deb <20> $nbRep " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( strlen ( $refClient ) == 0 ) {
debugLog ( 'W' , " R<EFBFBD> f<EFBFBD> rence $refClient incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 132 , 'errmsg' => 'R<> f<EFBFBD> rence inexistante' ), 'results' => $tabRet );
}
//$tabInfoUser['id'],
$rep = $this -> iInsee -> getEtabClients ( $refClient , $tabInfoUser [ 'idClient' ], $tabInfoUser [ 'login' ], $deb , $nbRep , $maxRep );
$etabs = $rep [ 'reponses' ];
foreach ( $etabs as $nb => $etab ) {
$tabRet [] = array ( 'id' => $etab [ 'id' ],
'Pertinence' => $etab [ 'Pertinence' ],
'Siret' => $etab [ 'Siret' ],
'Siege' => $etab [ 'Siege' ],
'Nom' => prepareString ( strtr ( $etab [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $etab [ 'Nom2' ]),
'Sigle' => prepareString ( $etab [ 'Sigle' ]),
'Enseigne' => prepareString ( $etab [ 'Enseigne' ]),
'Adresse' => prepareString ( $etab [ 'Adresse' ]),
'Adresse2' => prepareString ( $etab [ 'Adresse2' ]),
'CP' => $etab [ 'CP' ],
'Ville' => prepareString ( $etab [ 'Ville' ]),
'Tel' => $etab [ 'Tel' ],
'Fax' => $etab [ 'Fax' ],
'FJ' => $etab [ 'FJ' ],
'FJLib' => prepareString ( $etab [ 'FJLib' ]),
'Siren' => $etab [ 'Siren' ],
'Nic' => $etab [ 'Nic' ],
'Actif' => $etab [ 'Actif' ],
'NafEtab' => $etab [ 'NafEtab' ], // Etablissement
'NafEtabLib' => prepareString ( $etab [ 'NafEtabLib' ]), // Etablissement
'NafEnt' => $etab [ 'NafEnt' ], // Entreprise
'NafEntLib' => prepareString ( $etab [ 'NafEntLib' ]),
);
}
$rep [ 'reponses' ] = $tabRet ;
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $rep );
}
}
2011-03-24 15:11:22 +00:00
?>