3973 lines
140 KiB
PHP
3973 lines
140 KiB
PHP
<?php
|
|
require_once realpath(dirname(__FILE__)).'/WsScore.php';
|
|
require_once realpath(dirname(__FILE__)).'/functions.php';
|
|
require_once realpath(dirname(__FILE__)).'/Types/InterneTypes.php';
|
|
|
|
class WsInterne extends WsScore
|
|
{
|
|
/**
|
|
* Enregistrement des informations saisie manuellement
|
|
* @param string $siret
|
|
* @param int $idEntreprise
|
|
* @param array $tabInfos
|
|
* @return SetInfosEntrepReturn
|
|
*/
|
|
public function setInfosEntrep( $siret, $idEntreprise, $tabInfos )
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$tabRet = array();
|
|
$iBodacc = new MBodacc();
|
|
$result = false;
|
|
if ($this->tabInfoUser['idClient']<>1){
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Code Client Incorrect';
|
|
} else {
|
|
$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 à jour de l'identité **/
|
|
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),
|
|
);
|
|
|
|
/** @todo non traité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))){
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Mise a jour impossible';
|
|
$output = new SetInfosEntrepReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
exit;
|
|
}
|
|
}
|
|
|
|
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 à la liste des oppositions de la sphère commerciale INSEE pour $siren au mois de ".$tabIdentite['moisOppositionInsee']." : ".EOL.print_r($tabIdentite, true).EOL.$iDb2->getLastError());
|
|
}
|
|
}
|
|
|
|
if (isset($tabIdentite['domiciliataire']) &&
|
|
$tabIdentite['domiciliataire']=='oui' && $siren>1000)
|
|
{
|
|
if (!$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, NOW() as dateInsert
|
|
FROM jo.etablissements WHERE siren=$siren;", false))
|
|
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "ERREUR setInfosEntrep pour $siren", "Erreur lors de l'inscription comme entreprise de domiciliation : ".EOL.print_r($tabIdentite, true).EOL.$iDb->getLastError());
|
|
}
|
|
|
|
/** 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 à 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érateur de saisie **/
|
|
$iDbCrm = new WDB('sdv1');
|
|
$rep=$iDbCrm->select('utilisateurs', 'id', "login='".$this->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é à '.$tabJugement['nouvDir1Dom'].'. ';
|
|
}
|
|
if ($tabJugement['nouvDir2Fonc']*1>0) {
|
|
$strDir.=$iBodacc->getFctDir($tabJugement['nouvDir2Fonc']*1).' : '.$tabJugement['nouvDir2Genre'].' '.ucwords(strtolower($tabJugement['nouvDir2Pre'])).' '.strtoupper($tabJugement['nouvDir2Nom']).', domicilié à '.$tabJugement['nouvDir2Dom'].'. ';
|
|
}
|
|
if ($tabJugement['nouvDir3Fonc']*1>0) {
|
|
$strDir.=$iBodacc->getFctDir($tabJugement['nouvDir3Fonc']*1).' : '.$tabJugement['nouvDir3Genre'].' '.ucwords(strtolower($tabJugement['nouvDir3Pre'])).' '.strtoupper($tabJugement['nouvDir3Nom']).', domicilié à '.$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 é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))
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Mise a jour impossible';
|
|
$output = new SetInfosEntrepReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
/** 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){
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Mise a jour impossible';
|
|
} else {
|
|
$result = true;
|
|
}
|
|
}
|
|
$output = new SetInfosEntrepReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Commande de bilan
|
|
* @param InfoCommandeBilan $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return CmdBilanReturn
|
|
*/
|
|
public function setCmdBilan( InfoCommandeBilan $infoCommande, InfoDemandeur $infoDemandeur )
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande de bilan
|
|
* @param string $reference
|
|
* @return CmdBilanReturn
|
|
*/
|
|
public function getCmdBilan( $reference )
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Commande d'acte
|
|
* @param InfoCommandeActe $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return CmdActeReturn
|
|
*/
|
|
public function setCmdActe( $infoCommande, $infoDemandeur )
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande d'acte
|
|
* @param string $reference
|
|
* @return CmdActeReturn
|
|
*/
|
|
public function getCmdActe( $reference ){}
|
|
|
|
/**
|
|
* Commande de kbis
|
|
* @param InfoCommandeKbis $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return CmdKbisReturn
|
|
*/
|
|
public function setCmdKbis(InfoCommandeKbis $infoCommande, InfoDemandeur $infoDemandeur )
|
|
{
|
|
$this->authenticate();
|
|
|
|
$error = new ErrorType();
|
|
$ref = new RefCommande();
|
|
//Vérifier les informations
|
|
switch($infoCommande->mode)
|
|
{
|
|
case 'courrier': break;
|
|
case 'mail': break;
|
|
default:
|
|
exit; break;
|
|
}
|
|
if (empty($infoCommande->siren))
|
|
{
|
|
$error->errnum = 0;
|
|
$error->errmsg = 'Erreur SIREN invalide';
|
|
}
|
|
else
|
|
{
|
|
$login = $_SERVER['PHP_AUTH_USER'];
|
|
// Insertion des données commande
|
|
$dataCommandes = array(
|
|
'user_login' => $login,
|
|
'user_email' => $this->tabInfoUser['email'],
|
|
'type' => 'kbis',
|
|
'demandeurReference' => $infoDemandeur->reference,
|
|
'demandeurEmail' => $infoDemandeur->email,
|
|
'demandeurTel' => $infoDemandeur->tel,
|
|
'demandeurNom' => $infoDemandeur->nom,
|
|
'demandeurService' => $infoDemandeur->service,
|
|
'demandeurSociete' => $infoDemandeur->societe,
|
|
'demandeurAdresse' => $infoDemandeur->adresse,
|
|
'demandeurCp' => $infoDemandeur->cp,
|
|
'demandeurVille' => $infoDemandeur->ville,
|
|
'infoCommande' => serialize($infoCommande)
|
|
);
|
|
try {
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$commande = new Application_Model_Commandes();
|
|
$commande_id = $commande->insert($dataCommandes);
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
}
|
|
if ($commande_id)
|
|
{
|
|
//Enregistrement des détails de commande
|
|
$dataCommandesKbis = array(
|
|
'commande_id' => $commande_id,
|
|
'siren' => $infoCommande->siren,
|
|
'raisonSociale' => '',
|
|
'fichier' => '',
|
|
'partenaireRequete' => '',
|
|
'partenaireReponse' => '',
|
|
);
|
|
try {
|
|
$commandeKbisTable = new Application_Model_CommandesPieces();
|
|
$commandeKbisTable->insert($dataCommandesKbis);
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
}
|
|
try {
|
|
$row = $commande->find($commande_id);
|
|
$data = $row->current();
|
|
$ref->reference = $data->id;
|
|
$ref->dateCommande = $data->date_added;
|
|
$ref->dateMaj = $data->date_updated;
|
|
$ref->dateReception = $data->date_closed;
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
$error->errnum = 0;
|
|
$error->errmsg = "Commande Introuvable";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 0;
|
|
$error->errmsg = "Erreur enregistrement commande";
|
|
}
|
|
}
|
|
$output = new CmdKbisReturn();
|
|
$cmd = new CmdKbisDetail();
|
|
$cmd->infoCommande = $infoCommande;
|
|
$cmd->infoDemandeur = $infoDemandeur;
|
|
$cmd->refCommande = $ref;
|
|
$output->commande = $cmd;
|
|
$output->error = $error;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande de Kbis
|
|
* @param string $reference
|
|
* @return CmdKbisReturn
|
|
*/
|
|
public function getCmdKbis( $reference ){}
|
|
|
|
/**
|
|
* Commande de statut association
|
|
* @param InfoCommandeAsso $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return CmdAssoReturn
|
|
*/
|
|
public function setCmdAsso( $infoCommande, $infoDemandeur ){}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande association
|
|
* @param string $reference
|
|
* @return CmdAssoReturn
|
|
*/
|
|
public function getCmdAsso( $reference ){}
|
|
|
|
/**
|
|
* Commande de privilèges et nantissements par email
|
|
* @param InfoCommandePieces $infoCommande
|
|
* @param InfoDemandeur $infoDemandeur
|
|
* @return CmdPiecesReturn
|
|
*/
|
|
public function setCmdPieces( $infoCommande, $infoDemandeur )
|
|
{
|
|
$this->authenticate();
|
|
$error = new ErrorType();
|
|
$ref = new RefCommande();
|
|
if (!empty($infoCommande->siren)){
|
|
//Vérification SIREN
|
|
// Insertion des données commande
|
|
$dataCommandes = array(
|
|
'user_login' => $this->tabInfoUser['login'],
|
|
'user_email' => $this->tabInfoUser['email'],
|
|
'type' => 'pieces',
|
|
'demandeurReference' => $infoDemandeur->reference,
|
|
'demandeurEmail' => $infoDemandeur->email,
|
|
'demandeurTel' => $infoDemandeur->tel,
|
|
'demandeurNom' => $infoDemandeur->nom,
|
|
'demandeurService' => $infoDemandeur->service,
|
|
'demandeurSociete' => $infoDemandeur->societe,
|
|
'demandeurAdresse' => $infoDemandeur->adresse,
|
|
'demandeurCp' => $infoDemandeur->cp,
|
|
'demandeurVille' => $infoDemandeur->ville,
|
|
'infoCommande' => serialize($infoCommande)
|
|
);
|
|
try {
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$commande = new Application_Model_Commandes();
|
|
$commande_id = $commande->insert($dataCommandes);
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
}
|
|
if ($commande_id){
|
|
//Enregistrement des détails de commande
|
|
$dataCommandesPieces = array(
|
|
'commande_id' => $commande_id,
|
|
'siren' => $infoCommande->siren,
|
|
'raisonSociale' => '',
|
|
'fichier' => '',
|
|
);
|
|
try {
|
|
$commandePieces = new Application_Model_CommandesPieces();
|
|
$commandePieces->insert($dataCommandesPieces);
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
}
|
|
|
|
try {
|
|
$row = $commande->find($commande_id);
|
|
$data = $row->current();
|
|
$ref->reference = $data->id;
|
|
$ref->dateCommande = $data->date_added;
|
|
$ref->dateMaj = $data->date_updated;
|
|
$ref->dateReception = $data->date_closed;
|
|
} catch (Zend_Exception $e) {
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
$error->errnum = 0;
|
|
$error->errmsg = "Commande Introuvable";
|
|
}
|
|
} else {
|
|
$error->errnum = 0;
|
|
$error->errmsg = "Erreur enregistrement commande";
|
|
}
|
|
} else {
|
|
$error->errnum = 0;
|
|
$error->errmsg = 'Erreur SIREN invalide';
|
|
}
|
|
$output = new CmdPiecesReturn();
|
|
$cmd = new CmdPiecesDetail();
|
|
$cmd->infoCommande = $infoCommande;
|
|
$cmd->infoDemandeur = $infoDemandeur;
|
|
$cmd->refCommande = $ref;
|
|
$output->error = $error;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Renvoi des informations sur une commande pièces
|
|
* @param string $reference
|
|
* @return CmdPiecesReturn
|
|
*/
|
|
public function getCmdPieces( $reference )
|
|
{
|
|
list($typeCommande, $idCommande) = explode('-', $reference);
|
|
try {
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$commandeTable = new Application_Model_Commandes();
|
|
$select = $commandeTable->select()
|
|
->where('type = ?', 'pieces')
|
|
->where('id = ?', $idCommande);
|
|
$commandeRowset = $commandeTable->fetchAll($select);
|
|
}
|
|
catch (Zend_Db_Adapter_Exception $e)
|
|
{
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
}
|
|
$error = new ErrorType();
|
|
$ref = new RefCommande();
|
|
$infoCommande = new InfoCommandePieces();
|
|
$infoDemandeur = new InfoDemandeur();
|
|
if ( $commandeRowset->count()>0 )
|
|
{
|
|
$commande = $commandeRowset->current();
|
|
$selectEven = $commandeTable->select()
|
|
->order('date_added DESC')->limit(1);
|
|
$evenRowset = $commande->findDependentRowset(
|
|
'Application_Model_CommandesEven', null, $selectEven);
|
|
$info = '';
|
|
if($evenRowset->count()>0){
|
|
$even = $evenRowset->current();
|
|
$info = $even->commentaire;
|
|
}
|
|
$ref->reference = strtoupper($commande->type).'-'.$commande->id;
|
|
$ref->dateCommande = $commande->date_added;
|
|
$ref->dateMaj = $commande->date_updated;
|
|
$ref->dateReception = $commande->date_closed;
|
|
$ref->info = $info;
|
|
$ref->fichier = ''; // @todo : Détecter le fichier
|
|
$ref->login = $commande->user_login;
|
|
$infoCommande = unserialize($commande->infoCommande);
|
|
$infoDemandeur->reference = $commande->demandeurReference;
|
|
$infoDemandeur->email = $commande->demandeurEmail;
|
|
$infoDemandeur->tel = $commande->demandeurTel;
|
|
$infoDemandeur->nom = $commande->demandeurNom;
|
|
$infoDemandeur->service = $commande->demandeurService;
|
|
$infoDemandeur->societe = $commande->demandeurSociete;
|
|
$infoDemandeur->adresse = $commande->demandeurAdresse;
|
|
$infoDemandeur->cp = $commande->demandeurCp;
|
|
$infoDemandeur->ville = $commande->demandeurVille;
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 0;
|
|
$error->errmsg = 'Référence inconnue';
|
|
}
|
|
$output = new CmdPiecesReturn();
|
|
$cmd = new CmdPiecesDetail();
|
|
$cmd->refCommande = $ref;
|
|
$cmd->infoCommande = $infoCommande;
|
|
$cmd->infoDemandeur = $infoDemandeur;
|
|
$output->commande = $cmd;
|
|
$output->error = $error;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne la liste des commandes de pièces ainsi que leur détails
|
|
* @param CmdFiltrePieces $filtre
|
|
* @param int $position
|
|
* @param int $nbRep
|
|
* @return ListeCmdPiecesReturn
|
|
*/
|
|
public function getListeCmdPieces( $filtre, $position = 0, $nbRep = 20 )
|
|
{
|
|
$error = new ErrorType();
|
|
//Traitements des filtres pour générer la requête SQL
|
|
|
|
//Selection
|
|
$nbCommandes = 0;
|
|
try
|
|
{
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$commandeTable = new Application_Model_Commandes();
|
|
$select = $commandeTable->select()->where('type = ?', 'pieces');
|
|
$countRowset = $commandeTable->fetchAll($select);
|
|
$nbCommandes = $countRowset->count();
|
|
$select->order('date_added DESC')->limit($nbRep, $position);
|
|
$commandeRowset = $commandeTable->fetchAll($select);
|
|
}
|
|
catch (Zend_Db_Adapter_Exception $e)
|
|
{
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Erreur';
|
|
}
|
|
|
|
if ( $commandeRowset->count()>0 )
|
|
{
|
|
$liste = array();
|
|
foreach ($commandeRowset as $commande)
|
|
{
|
|
$selectEven = $commandeTable->select()
|
|
->order('date_added DESC')->limit(1);
|
|
$evenRowset = $commande->findDependentRowset(
|
|
'Application_Model_CommandesEven', null, $selectEven);
|
|
$info = '';
|
|
if($evenRowset->count()>0){
|
|
$even = $evenRowset->current();
|
|
$info = $even->commentaire;
|
|
}
|
|
|
|
$ref = new RefCommande();
|
|
$ref->reference = strtoupper($commande->type).'-'.$commande->id;
|
|
$ref->dateCommande = $commande->date_added;
|
|
$ref->dateMaj = $commande->date_updated;
|
|
$ref->dateReception = $commande->date_closed;
|
|
$ref->info = $info;
|
|
$ref->fichier = ''; // @todo : Détecter le fichier
|
|
$ref->login = $commande->user_login;
|
|
|
|
$infoCommande = new InfoCommandePieces();
|
|
$infoCommande = unserialize($commande->infoCommande);
|
|
|
|
$infoDemandeur = new InfoDemandeur();
|
|
$infoDemandeur->reference = $commande->demandeurReference;
|
|
$infoDemandeur->email = $commande->demandeurEmail;
|
|
$infoDemandeur->tel = $commande->demandeurTel;
|
|
$infoDemandeur->nom = $commande->demandeurNom;
|
|
$infoDemandeur->service = $commande->demandeurService;
|
|
$infoDemandeur->societe = $commande->demandeurSociete;
|
|
$infoDemandeur->adresse = $commande->demandeurAdresse;
|
|
$infoDemandeur->cp = $commande->demandeurCp;
|
|
$infoDemandeur->ville = $commande->demandeurVille;
|
|
|
|
$cmd = new CmdPiecesDetail();
|
|
$cmd->refCommande = $ref;
|
|
$cmd->infoCommande = $infoCommande;
|
|
$cmd->infoDemandeur = $infoDemandeur;
|
|
|
|
$liste[] = $cmd;
|
|
}
|
|
}
|
|
|
|
$output = new ListeCmdPiecesReturn();
|
|
$output->error = $error;
|
|
$output->nbCommandes = $nbCommandes;
|
|
$output->liste = $liste;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Liste des bilans
|
|
* @param string $siren
|
|
* @param string $waldec
|
|
* @param int $idEntreprise
|
|
* @return ListeBilan
|
|
*/
|
|
public function getListeBilan( $siren, $waldec = null, $idEntreprise = null ){}
|
|
|
|
/**
|
|
* Liste des actes
|
|
* @param string $siren
|
|
* @return ListeActe
|
|
*/
|
|
public function getListeActe( $siren ){}
|
|
|
|
/**
|
|
* Retourne la liste des statuts de commande
|
|
* @param string $type
|
|
* @return CmdStatut[]
|
|
*/
|
|
public function getListeCmdStatut( $type )
|
|
{
|
|
Zend_Registry::get('WsLogger')->info("getListeStatut - ".$type);
|
|
try {
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$dbStatut = new Application_Model_CommandesStatut();
|
|
$result = $dbStatut->fetchAll(array("commande_type = '$type'"));
|
|
}
|
|
catch (Zend_Db_Adapter_Exception $e)
|
|
{
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
}
|
|
$listeStatut = array();
|
|
if (count($result)>0)
|
|
{
|
|
foreach($result as $r)
|
|
{
|
|
$statut = new CmdStatut();
|
|
$statut->code = $r['code'];
|
|
$statut->lib = $r['libelle'];
|
|
$listeStatut[] = $statut;
|
|
}
|
|
}
|
|
return $listeStatut;
|
|
}
|
|
|
|
/**
|
|
* Spécifier un état défini pour une commande
|
|
* (avec déclenchement d'une action)
|
|
* @param int $reference
|
|
* @param int $statutCode
|
|
* @return bool
|
|
*/
|
|
public function setCmdStatut( $reference, $statutCode)
|
|
{
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
$dbStatut = new Application_Model_CommandesStatut();
|
|
$row = $dbStatut->fetchRow(array("code = '$statutCode'"));
|
|
if ( count($row)>0 && $this->setCommandeEven($reference, $row['lib']) )
|
|
{
|
|
if (!empty($row['action'])){
|
|
switch($row['action']){
|
|
case 'CLOSE':
|
|
//date_closed
|
|
break;
|
|
}
|
|
}
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Spécifier un état pour une commande
|
|
* @param int $reference
|
|
* @param string $comment
|
|
* @return bool
|
|
*/
|
|
public function setCmdEven ( $reference, $comment )
|
|
{
|
|
$this->authenticate();
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
try {
|
|
//Vérifier que la commande existe avec la référence fournie
|
|
$commandeTable = new Application_Model_Commandes();
|
|
$commandeRowset = $commandeTable->find($reference);
|
|
if ($commandeRowset->count()>0)
|
|
{
|
|
$commande = $commandeRowset->current();
|
|
//Enregistrer l'événement
|
|
$commandeEvenTable = new Application_Model_CommandesEven();
|
|
$insert = $commandeEvenTable->createRow();
|
|
$insert->commande_id = $commande->id;
|
|
$insert->commentaire = $comment;
|
|
$insert->user_login = $this->tabInfoUser['login'];
|
|
$insert->save();
|
|
//Mettre à jour la commande
|
|
$commande->date_updated = date('Y-m-d H:i:s');
|
|
$commande->save();
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
catch (Zend_Db_Adapter_Exception $e)
|
|
{
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ajout du nom de fichier liée à la commande
|
|
* @param int $reference
|
|
* @param string $filename
|
|
* @return bool
|
|
*/
|
|
public function setCmdDocument( $reference, $filename )
|
|
{
|
|
$this->authenticate();
|
|
$db = Zend_Db::factory($this->dbConfig->Commandes);
|
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
|
try {
|
|
//Vérifier que la commande existe avec la référence fournie
|
|
$commandeTable = new Application_Model_Commandes();
|
|
$commandeRowset = $commandeTable->find($reference);
|
|
if ($commandeRowset->count()>0)
|
|
{
|
|
$commande = $commandeRowset->current();
|
|
switch($commande->type)
|
|
{
|
|
case 'pieces':
|
|
$infoCommandePieces = $commande->findDependentRowset('Application_Model_CommandesPieces');
|
|
if ($infoCommandePieces->count()>0)
|
|
{
|
|
//Update informations pieces
|
|
$commandePieces = $infoCommandePieces->current();
|
|
$commandePieces->fichier = $filename;
|
|
$commandePieces->save();
|
|
//Mettre à jour la commande
|
|
$commande->date_updated = date('Y-m-d H:i:s');
|
|
$commande->save();
|
|
//Mettre à jour les évenements de commande
|
|
//@todo
|
|
return true;
|
|
}
|
|
break;
|
|
case 'default':
|
|
return false;
|
|
break;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
catch (Zend_Db_Adapter_Exception $e)
|
|
{
|
|
Zend_Registry::get('WsLogger')
|
|
->err(__FUNCTION__.' - '.$e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Récupère les informations du profil connecté
|
|
* @param string $login
|
|
* @param string $ipUtilisateur
|
|
* @return InfosLoginReturn
|
|
*/
|
|
public function getInfosLogin($login, $ipUtilisateur = '')
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
if (empty($ipUtilisateur)) $ipUtilisateur = $_SERVER['REMOTE_ADDR'];
|
|
$error = new ErrorType();
|
|
|
|
debugLog('I',"getInfosLogin pour $login (IP=$ipUtilisateur)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
//L'utilisateur qui demande les informations est différent
|
|
if ($this->tabInfoUser['login']<>$login &&
|
|
( $this->tabInfoUser['profil']=='Administrateur' ||
|
|
$this->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 ? **/
|
|
$iDbCrm = new WDB('sdv1');
|
|
$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'=> $tabRep['nom'],
|
|
'prenom'=> $tabRep['prenom'],
|
|
'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'],
|
|
'tel'=> $tabRep['tel'],
|
|
'fax'=> $tabRep['fax'],
|
|
'mobile'=> $tabRep['mobile'],
|
|
'pref'=> $tabRep['pref'],
|
|
'profil'=> $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'],
|
|
'reference'=> $tabRep['referenceParDefaut'],
|
|
'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'];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Identification utilisateur
|
|
$connected = true;
|
|
if (trim($this->tabInfoUser['filtre_ip'])<>'')
|
|
{
|
|
//debugLog('I',"getInfosLogin test filtre IP",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$connected = checkPlagesIp($this->tabInfoUser['filtre_ip'], $ipUtilisateur);
|
|
if (!$connected)
|
|
{
|
|
debugLog('I',"getInfosLogin Adresse IP $ipUtilisateur non declaree pour le compte $login",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$error->errnum = 10818;
|
|
$error->errmsg = "Adresse IP $ipUtilisateur non declaree pour ce compte. Contactez votre administrateur !";
|
|
}
|
|
}
|
|
$rep = array(
|
|
'connected'=> $connected,
|
|
'login'=> $this->tabInfoUser['login'],
|
|
'id'=> $this->tabInfoUser['id'],
|
|
'idClient'=> $this->tabInfoUser['idClient'],
|
|
'email'=> $this->tabInfoUser['email'],
|
|
'typeCompte'=> $this->tabInfoUser['typeCompte'],
|
|
'filtre_ip'=> $this->tabInfoUser['filtre_ip'],
|
|
'ipPasserelle'=> $this->tabInfoUser['ipConnexion'],
|
|
'ipConnexion'=> $ipUtilisateur,
|
|
'civilite'=> $this->tabInfoUser['civilite'],
|
|
'nom'=> $this->tabInfoUser['nom'],
|
|
'prenom'=> $this->tabInfoUser['prenom'],
|
|
'raisonSociale'=> $this->tabInfoUser['raisonSociale'],
|
|
'siret'=> $this->tabInfoUser['siret'],
|
|
'adrNum'=> $this->tabInfoUser['adrNum'],
|
|
'adrIndRep'=> $this->tabInfoUser['adrIndRep'],
|
|
'adrTypeVoie'=> $this->tabInfoUser['adrTypeVoie'],
|
|
'adrLibVoie'=> $this->tabInfoUser['adrLibVoie'],
|
|
'adrCp'=> $this->tabInfoUser['adrCp'],
|
|
'adrVille'=> $this->tabInfoUser['adrVille'],
|
|
'adrComp'=> $this->tabInfoUser['adrComp'],
|
|
'tel'=> $this->tabInfoUser['tel'],
|
|
'fax'=> $this->tabInfoUser['fax'],
|
|
'mobile'=> $this->tabInfoUser['mobile'],
|
|
'pref'=> $this->tabInfoUser['pref'],
|
|
'profil'=> $this->tabInfoUser['profil'],
|
|
'dateInscription'=> $this->tabInfoUser['dateInscription'],
|
|
'dateValidation'=> $this->tabInfoUser['dateValidation'],
|
|
'nombreConnexions'=> $this->tabInfoUser['nombreConnexions'],
|
|
'dateDerniereConnexion'=> $this->tabInfoUser['dateDerniereConnexion'],
|
|
'droits'=> $this->tabInfoUser['droits'],
|
|
'droitsClients'=> $this->tabInfoUser['droitsClients'],
|
|
'timeout'=> $this->tabInfoUser['timeout'],
|
|
'nbReponses'=> $this->tabInfoUser['nbReponses'],
|
|
'formatMail'=> $this->tabInfoUser['formatMail'],
|
|
'reference'=> $this->tabInfoUser['referenceParDefaut'],
|
|
'dateDebutCompte'=> $this->tabInfoUser['dateDebutCompte'],
|
|
'dateFinCompte'=> $this->tabInfoUser['dateFinCompte'],
|
|
'maxFicheId'=> $this->tabInfoUser['maxFicheId'],
|
|
'typeScore'=> $this->tabInfoUser['typeScore'],
|
|
);
|
|
//debugLog('I',"getInfosLogin fin ".print_r($rep,true),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
}
|
|
$result = new InfosLogin();
|
|
$result = arrayToClass($rep, 'InfosLogin');
|
|
$output = new InfosLoginReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Mise à jour des informations du profil connecté
|
|
* @param string $login
|
|
* @param array $tabInfoUserWS
|
|
* @return SetInfosLoginReturn
|
|
*/
|
|
public function setInfosLogin($login, $tabInfoUserWS)
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
$result = false;
|
|
|
|
if ($tabInfoUserWS['delete']==1 &&
|
|
($this->tabInfoUser['profil']=='Administrateur' ||
|
|
$this->tabInfoUser['profil']=='SuperAdministrateur') )
|
|
{
|
|
$tabUpdate = array('deleted'=>1);
|
|
}
|
|
elseif (isset($tabInfoUserWS['actif']) && $tabInfoUserWS['actif']==0 &&
|
|
($this->tabInfoUser['profil']=='Administrateur' ||
|
|
$this->tabInfoUser['profil']=='SuperAdministrateur') )
|
|
{
|
|
$tabUpdate = array('actif'=>0);
|
|
}
|
|
elseif (isset($tabInfoUserWS['actif']) && $tabInfoUserWS['actif']==1 &&
|
|
($this->tabInfoUser['profil']=='Administrateur' ||
|
|
$this->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']);
|
|
}
|
|
}
|
|
$iDbCrm = new WDB('sdv1');
|
|
if ($tabInfoUserWS['action']=='new')
|
|
{
|
|
$tabUpdate['login']=$login;
|
|
$tabUpdate['idClient']=$tabInfoUserWS['idClient'];
|
|
if ($iDbCrm->insert('utilisateurs', $tabUpdate))
|
|
{
|
|
$result = true;
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Création impossible';
|
|
}
|
|
}
|
|
if ($iDbCrm->update('utilisateurs', $tabUpdate, "login='$login'"))
|
|
{
|
|
$result = true;
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Mise a jour impossible';
|
|
}
|
|
$output = new SetInfosLoginReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
|
|
/**
|
|
* Obtention automatique d'un nouveau login pour un client
|
|
* @param string $login
|
|
* @return NextLoginReturn
|
|
*/
|
|
public function getNextLogin( $login )
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
if ($this->tabInfoUser['profil']=='Administrateur' ||
|
|
$this->tabInfoUser['profil']=='SuperAdministrateur')
|
|
{
|
|
/** Un administrateur veut créer un nouveau login **/
|
|
$iDbCrm = new WDB('sdv1');
|
|
$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;
|
|
}
|
|
$result = new NextLoginResult();
|
|
$result->racine = $racine;
|
|
$result->idClient = $idClient;
|
|
$result->droitsClients = $droitsClients;
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 0;
|
|
$error->errmsg = 'Acces non authorisé!';
|
|
}
|
|
$output = new NextLoginReturn();
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Enregistre une action utilisateur pour la facturation
|
|
* @param string $page
|
|
* @param string $siret
|
|
* @param int $id
|
|
* @param string $ref
|
|
* @return void
|
|
*/
|
|
public function setLog($page, $siret, $id=0, $ref='')
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
if (empty($id)) $id = 0;
|
|
if (empty($ref)) $ref = '';
|
|
$error = new ErrorType();
|
|
|
|
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__);
|
|
}
|
|
|
|
/**
|
|
* Met a jour les informations sur un mandataire
|
|
* @param array $tabInfos Tableau des informations sur le mandataire à créer ou à ajouter (ajout si id absent)
|
|
* @return SetMandataireReturn
|
|
**/
|
|
public function setMandataire($tabInfos=array())
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
$result = true;
|
|
|
|
$iDb = new WDB();
|
|
/** Nom et Identifiant de l'opérateur de saisie **/
|
|
$iDbCrm = new WDB('sdv1');
|
|
$rep = $iDbCrm->select('utilisateurs', 'id', "login='".$this->tabInfoUser['login']."'");
|
|
$idUser = $rep[0][0];
|
|
|
|
$infos = serialize($tabInfos);
|
|
debugLog('I',"Ajout/MAJ de mandaitaire $infos demandé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))
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Mise a jour impossible';
|
|
$result = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Insertion
|
|
if (!$iDb->insert('tabMandataires', array_merge($tabUpdate,array('dateInsert'=>date('YmdHis'))), true))
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Insertion impossible';
|
|
$result = false;
|
|
}
|
|
}
|
|
$output = new SetMandataireReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Supprime une annonce issue de la collecte
|
|
* @param string $idAnn
|
|
* @param string $siret
|
|
* @return SupprAnnonceCollecteReturn
|
|
*/
|
|
public function supprAnnonceCollecte($idAnn, $siret=null)
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
if (empty($siret)) $siret = 0;
|
|
$error = new ErrorType();
|
|
$result = false;
|
|
|
|
if ($this->tabInfoUser['idClient']<>1)
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Code Client Incorrect';
|
|
}
|
|
else
|
|
{
|
|
$siren = substr($siret,0,9)*1;
|
|
$iDb = new WDB();
|
|
$idAnn = preg_replace('/^0\./','', ''.$idAnn)*1;
|
|
|
|
if ($idAnn>0)
|
|
{
|
|
if ($iDb->update('annonces',array(
|
|
'dateSuppr'=>date('YmdHis'),
|
|
'idSuppr'=>$this->tabInfoUser['id']),
|
|
"id=$idAnn", false))
|
|
{
|
|
debugLog('I',"Suppression de l'annonce collectée n°$idAnn ($siret)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$result = true;
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Suppression de l\'annonce impossible';
|
|
debugLog('I',"Suppression impossible de l'annonce collectée n°$idAnn ($siret)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'idAnn incorrect';
|
|
}
|
|
}
|
|
$output = new SupprAnnonceCollecte();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Récupère le mandataire par son id
|
|
* @param int $idMand Identifiant du mandataire
|
|
* @return MandataireReturn
|
|
*/
|
|
public function getMandataire($idMand)
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
debugLog('I',"Donne le Mandataires correspondant à $idMand",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$iInsee = new classMInsee();
|
|
$tabRet = $iInsee->getMandataire($idMand);
|
|
$mandataire = new MandataireDetail();
|
|
$mandataire->Nom = $tabRet['Nom'];
|
|
$mandataire->Prenom = $tabRet['Prenom'];
|
|
$mandataire->tribunal = $tabRet['tribunal'];
|
|
$mandataire->adresse = $tabRet['adresse'];
|
|
$mandataire->adresseComp = $tabRet['adresseComp'];
|
|
$mandataire->ville = $tabRet['ville'];
|
|
$mandataire->email = $tabRet['email'];
|
|
$mandataire->web = $tabRet['web'];
|
|
$mandataire->contact = $tabRet['contact'];
|
|
$output = new MandataireReturn();
|
|
$output->error = $error;
|
|
$output->result = $mandataire;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Liste les mandataires compétentes pour une cours d'appel donnée
|
|
*
|
|
* @param mixed $codeTribunal Identifiants BODACC du tribunal ou tableau d'Identifiants numériques des cours d'appel
|
|
* @param array $type Type de mandataire (A)dministrateur, (M)andataire, (O)ppositions, (N)otaires, a(V)ocat
|
|
* @return MandatairesReturn
|
|
*/
|
|
public function getMandataires($codeTribunal=0, $type=array('A','M'))
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
$trib = serialize($codeTribunal);
|
|
debugLog('I',"Liste des Mandaitaires ou Administrateur du Tribunal/Cours d'Appel $trib demandé",__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){
|
|
$mandataire = new Mandataire();
|
|
$mandataire->id = 'm'.$i;
|
|
$mandataire->mand = $mand;
|
|
$tabRet[]= $mandataire;
|
|
}
|
|
$output = new MandatairesReturn();
|
|
$output->error = $error;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Enter description here ...
|
|
* @param string $siret
|
|
* @param string $type
|
|
* @param string $codeInsee
|
|
* @return ListeCompetencesReturn
|
|
*/
|
|
public function getListeCompetences($siret, $type, $codeInsee)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
$type = strtolower($type);
|
|
|
|
debugLog('I',"Liste des compétences $type demandé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;
|
|
|
|
$competence = new Competence();
|
|
$competence = arrayToClass(array(
|
|
'Id' => $tribunal['triId'],
|
|
'IdSup' => $tribunal['triIdSup'],
|
|
'Code' => $tribunal['triCode'],
|
|
'Type' => $tribunal['triType'].$typeP,
|
|
'Nom' => strtoupper($tribunal['triNom']),
|
|
'Siret' => $tribunal['triSiret'],
|
|
'Adr' => strtoupper(preg_replace('/ +/',' ',$tribunal['triAdrNum'].' '.$tribunal['triAdrIndRep'].' '.
|
|
$tribunal['triAdrTypeVoie'].' '.$tribunal['triAdrVoie'])),
|
|
'AdrComp' => strtoupper($tribunal['triAdrComp']),
|
|
'CP' => $tribunal['triCP'],
|
|
'Ville' => strtoupper($tribunal['triVille']),
|
|
'CodeInsee' => $tribunal['CodeInsee'],
|
|
'Tel' => $tribunal['triTel'],
|
|
'Fax' => $tribunal['triFax'],
|
|
'Web' => $tribunal['triWeb'],
|
|
'Mail' => $tribunal['triMail'],
|
|
'Statut' => $tribunal['triStatut'],
|
|
'DateCessation' => $tribunal['triDateCessation'],
|
|
'Remarque' => $tribunal['triCommentaire'],
|
|
), 'Competence');
|
|
|
|
$tabRet[$i] = $competence;
|
|
|
|
}
|
|
}
|
|
}
|
|
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'];
|
|
|
|
$competence = new Competence();
|
|
$competence = arrayToClass(array(
|
|
'Id' => 9000+$comp['id']*1,
|
|
'IdSup' => 0,
|
|
'Code' => '',
|
|
'Type' => '',
|
|
'Nom' => strtoupper($comp['nomJal']),
|
|
'Siret' => '',
|
|
'Adr' => strtoupper($comp['adresse']),
|
|
'AdrComp' => '',
|
|
'CP' => $comp['cp'],
|
|
'Ville' => strtoupper($comp['ville']),
|
|
'CodeInsee' => '',
|
|
'Tel' => $comp['tel'],
|
|
'Fax' => $comp['fax'],
|
|
'Web' => $comp['siteWeb'],
|
|
'Mail' => $comp['email'],
|
|
'Statut' => 'Actif',
|
|
'DateCessation' => '',
|
|
'Remarque' => trim($infos),
|
|
), 'Competence');
|
|
$tabRet[$i] = $competence;
|
|
}
|
|
}
|
|
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étences $type demandé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')
|
|
{
|
|
$competence = new Competence();
|
|
$competence = arrayToClass(array(
|
|
'Id' => $tribunal['triId'],
|
|
'IdSup' => $tribunal['triIdSup'],
|
|
'Code' => $tribunal['triCode'],
|
|
'Type' => $tribunal['triType'],
|
|
'Nom' => strtoupper($tribunal['triNom']),
|
|
'Siret' => $tribunal['triSiret'],
|
|
'Adr' => strtoupper(preg_replace('/ +/',' ',$tribunal['triAdrNum'].' '.$tribunal['triAdrIndRep'].' '.
|
|
$tribunal['triAdrTypeVoie'].' '.$tribunal['triAdrVoie'])),
|
|
'AdrComp' => strtoupper($tribunal['triAdrComp']),
|
|
'CP' => $tribunal['triCP'],
|
|
'Ville' => strtoupper($tribunal['triVille']),
|
|
'CodeInsee' => $tribunal['CodeInsee'],
|
|
'Tel' => $tribunal['triTel'],
|
|
'Fax' => $tribunal['triFax'],
|
|
'Web' => $tribunal['triWeb'],
|
|
'Mail' => $tribunal['triMail'],
|
|
'Statut' => $tribunal['triStatut'],
|
|
'DateCessation' => $tribunal['triDateCessation'],
|
|
'Remarque' => $tribunal['triCommentaire'],
|
|
), 'Competence');
|
|
if ($tribunal['triNumGreffe']*1>0)
|
|
{
|
|
$competence->IdentifiantGreffe = $tribunal['triNumGreffe'];
|
|
}
|
|
$tabRet[$i] = $competence;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($type=='adm')
|
|
{
|
|
$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)
|
|
{
|
|
$competence = new Competence();
|
|
$competence = arrayToClass(array(
|
|
'Id' => $tribunal['id'],
|
|
'IdSup' => $tribunal['sirenGrp'],
|
|
'Code' => $tribunal['tribunal'].'/'.$code,
|
|
'Type' => $tribunal['type'],
|
|
'Nom' => $tribunal['Nom'].' '.$tribunal['Prenom'],
|
|
'Siret' => $tribunal['sirenMand'],
|
|
'Adr' => strtoupper($tribunal['adresse']),
|
|
'AdrComp' => strtoupper($tribunal['adresseComp']),
|
|
'CP' => $tribunal['cp'],
|
|
'Ville' => strtoupper($tribunal['ville']),
|
|
//'CodeInsee'=>$tribunal['CodeInsee'],
|
|
'Tel' => $tribunal['tel'],
|
|
'Fax' => $tribunal['fax'],
|
|
'Web' => $tribunal['web'],
|
|
'Mail' => $tribunal['email'],
|
|
'Statut' => $tribunal['Statut'],
|
|
//'DateCessation'=>$tribunal['triDateCessation'],
|
|
'Remarque' => $tribunal['contact'],
|
|
), 'Competence');//,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact
|
|
|
|
$tabRet[$i] = $competence;
|
|
|
|
$nbAff++;
|
|
}
|
|
}
|
|
if ($nbAff==0)
|
|
{
|
|
foreach ($tabTmp as $i=>$tribunal)
|
|
{
|
|
$competence = new Competence();
|
|
$competence = arrayToClass(array(
|
|
'Id' => $tribunal['id'],
|
|
'IdSup' => $tribunal['sirenGrp'],
|
|
'Code' => $tribunal['tribunal'].'/'.$code,
|
|
'Type' => $tribunal['type'],
|
|
'Nom' => $tribunal['Nom'].' '.$tribunal['Prenom'],
|
|
'Siret' => $tribunal['sirenMand'],
|
|
'Adr' => strtoupper($tribunal['adresse']),
|
|
'AdrComp' => strtoupper($tribunal['adresseComp']),
|
|
'CP' => $tribunal['cp'],
|
|
'Ville' => strtoupper($tribunal['ville']),
|
|
//'CodeInsee'=>$tribunal['CodeInsee'],
|
|
'Tel' => $tribunal['tel'],
|
|
'Fax' => $tribunal['fax'],
|
|
'Web' => $tribunal['web'],
|
|
'Mail' => $tribunal['email'],
|
|
'Statut' => $tribunal['Statut'],
|
|
//'DateCessation'=>$tribunal['triDateCessation'],
|
|
'Remarque' => $tribunal['contact'],
|
|
), 'Competence');//,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact
|
|
|
|
$tabRet[$i] = $competence;
|
|
}
|
|
}/** @todo A revoir Fin : Lier correctement les mandataires à 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']);
|
|
$competence = new Competence();
|
|
$competence = arrayToClass(array(
|
|
'Id' => $tribunal['id'],
|
|
'IdSup' => $tribunal['sirenGrp'],
|
|
'Code' => $tribunal['tribunal'].'/'.$code,
|
|
'Type' => $tribunal['type'],
|
|
'Nom' => $tribunal['Nom'].' '.$tribunal['Prenom'],
|
|
'Siret' => $tribunal['sirenMand'],
|
|
'Adr' => strtoupper($adr['num'].' '.$adr['adr_btq'].' '.
|
|
$adr['typeVoie'].' '.$adr['libVoie']),
|
|
'AdrComp' => strtoupper($tribunal['adresseComp']),
|
|
'CP' => $adr['cp'],
|
|
'Ville' => strtoupper($tribunal['ville']),
|
|
//'CodeInsee'=>$tribunal['CodeInsee'],
|
|
'Tel' => $tribunal['tel'],
|
|
'Fax' => $tribunal['fax'],
|
|
'Web' => $tribunal['web'],
|
|
'Mail' => $tribunal['email'],
|
|
'Statut' => $tribunal['Statut'],
|
|
//'DateCessation'=>$tribunal['triDateCessation'],
|
|
'Remarque' => strtr($tribunal['contact'],
|
|
array( '<br/>'=>', ', '<br>'=>', ',
|
|
'<br />'=>', ',
|
|
)),
|
|
), 'Competence');
|
|
|
|
$tabRet[$i] = $competence;
|
|
|
|
}
|
|
$nbComp = count($tabTmp);
|
|
debugLog('I',"$nbComp compétences $type trouvé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']);
|
|
|
|
$competence = new Competence();
|
|
$competence = arrayToClass(array(
|
|
'Id' => $tribunal['triId'],
|
|
'IdSup' => $tribunal['triIdSup'],
|
|
'Code' => $tribunal['triCode'],
|
|
'Type' => $tribunal['triType'],
|
|
'Nom' => strtoupper($tribunal['triNom']),
|
|
'Siret' => $tribunal['triSiret'],
|
|
'Adr' => strtoupper(preg_replace('/ +/',' ',$tribunal['triAdrNum'].' '.$tribunal['triAdrIndRep'].' '.
|
|
$tribunal['triAdrTypeVoie'].' '.$tribunal['triAdrVoie'])),
|
|
'AdrComp' => strtoupper($tribunal['triAdrComp']),
|
|
'CP' => $tribunal['triCP'],
|
|
'Ville' => strtoupper($tribunal['triVille']),
|
|
'CodeInsee' => $tribunal['CodeInsee'],
|
|
'Tel' => $tribunal['triTel'],
|
|
'Fax' => $tribunal['triFax'],
|
|
'Web' => $tribunal['triWeb'],
|
|
'Mail' => $tribunal['triMail'],
|
|
'Statut' => $tribunal['triStatut'],
|
|
'DateCessation' => $tribunal['triDateCessation'],
|
|
'Remarque' => $remarque,
|
|
), 'Competence');
|
|
|
|
$tabRet[$i] = $competence;
|
|
}
|
|
}
|
|
}
|
|
wsLog('competences',$siret,$type.'/'.$codeInsee);
|
|
$result = new ListeCompetencesResult();
|
|
$result->nbReponses = count($tabRet);
|
|
$result->liste = $tabRet;
|
|
$output = new ListeCompetencesReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
/*Zend_Registry::get('WsLogger')
|
|
->info(__FUNCTION__.' - '.print_r($output, 1));*/
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne la liste des banques connues pour une entreprise
|
|
* @param string $siren Siren de l'entreprise
|
|
* @return BanquesReturn
|
|
**/
|
|
public function getBanques($siren)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
$iDb = new WDB('sdv1');
|
|
$tabRet = array();
|
|
debugLog('I',"Liste des banques demandé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;
|
|
|
|
$banque = new Banque();
|
|
$banque->codeBanque = $codBanque;
|
|
$banque->codeGuichet = $codGuichet;
|
|
$banque->libBanque = $libBanque;
|
|
$banque->adresse1 = $adrBanque1;
|
|
$banque->adresse2 = $adrBanque2;
|
|
$banque->ville = $adrBanqueCP;
|
|
$banque->cp = $adrBanqueCP;
|
|
$banque->ville = $adrBanqueVille;
|
|
|
|
$tabRet[] = $banque;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 75454698;
|
|
$error->errmsg = 'Siren invalide';
|
|
}
|
|
|
|
debugLog('I',"Liste des banques pour siren $siren : ".count($tabRet).' banques',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if (count($tabRet)==0)
|
|
{
|
|
$error->errnum = 256454;
|
|
$error->errmsg = 'Aucune relation bancaire en base';
|
|
}
|
|
|
|
$output = new BanquesReturn();
|
|
$output->error = $error;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* Retourne la liste des conventions
|
|
* @param string $siren
|
|
* @return ListeConventionsReturn
|
|
*/
|
|
public function getListeConventions($siren)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
$tabRet=array();
|
|
|
|
debugLog('I',"Liste des conventions demandée pour le siren $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if (strlen($siren)<>9)
|
|
{
|
|
debugLog('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$error->errnum = 102;
|
|
$error->errmsg = 'Siren Siret inexistant';
|
|
}
|
|
elseif ($siren*1==0)
|
|
{
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$error->errnum = 102;
|
|
$error->errmsg = 'Siren inexistant';
|
|
}
|
|
else
|
|
{
|
|
$tabIdentite = $this->iInsee->getIdentiteEntreprise($siren);
|
|
if (empty($tabIdentite) && isset($tabIdentite['erreur']) &&
|
|
$tabIdentite['erreur']<>'')
|
|
{
|
|
debugLog('W', "Siren $siren non présent en base", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$error->errnum = 102;
|
|
$error->errmsg = 'Siren inexistant';
|
|
}
|
|
else
|
|
{
|
|
$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']);
|
|
foreach ($tabTmp as $i=>$conv)
|
|
{
|
|
$convention = new Convention();
|
|
$convention->idCC = $conv['id CC'];
|
|
$convention->nomCC = $conv['nom CC'];
|
|
$convention->infoCC = $conv['infoCC'];
|
|
$convention->editorCC = $conv['editeur CC'];
|
|
$convention->nbPageCC = $conv['nb page CC'];
|
|
$convention->isbnCC = $conv['isbn CC'];
|
|
$convention->dateCC = $conv['date edition CC'];
|
|
$convention->joCCmaj = $conv['joCCmaj'];
|
|
$tabRet[$i] = $convention;
|
|
}
|
|
wsLog('conventions',$siren);
|
|
}
|
|
}
|
|
|
|
$output = new ListeConventionsReturn();
|
|
$output->error = $error;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Donne la cours d'appel d'un tribunal par son code
|
|
* @param string $codeTribunal Code BODACC sur 6 caractères du tribunal
|
|
* @return int
|
|
**/
|
|
public function getIdCoursAppel($codeTribunal)
|
|
{
|
|
$this->authenticate();
|
|
$iBodacc = new MBodacc();
|
|
return $iBodacc->getTribunalIdCA($codeTribunal);
|
|
}
|
|
|
|
/**
|
|
* Duplique une annonce issue de la collecte
|
|
* @param string $idAnn
|
|
* @param string $siret
|
|
* @return DupliqueAnnonceReturn
|
|
*/
|
|
public function dupliqueAnnonceCollecte($idAnn, $siret = null)
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
if (empty($siret)) $siret = '';
|
|
$error = new ErrorType();
|
|
$result = 0;
|
|
|
|
if ($this->tabInfoUser['idClient']<>1)
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Code Client Incorrect';
|
|
}
|
|
else
|
|
{
|
|
$siren = substr($siret,0,9)*1;
|
|
$nic = substr($siret,9,5)*1;
|
|
$iDb = new WDB();
|
|
$idAnn = preg_replace('/^0\./','', ''.$idAnn)*1;
|
|
if ($idAnn>0 && $siren>1000)
|
|
{
|
|
$res = $iDb->select('annonces', '*', "id=$idAnn", false, MYSQL_ASSOC);
|
|
if (count($res)==0)
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Annonce inexistante';
|
|
}
|
|
else
|
|
{
|
|
$annonce = $res[0];
|
|
unset($annonce['id']);
|
|
$annonce['siren'] = $siren;
|
|
$annonce['nic'] = $nic;
|
|
if ($iDb->insert('annonces', $annonce, false))
|
|
{
|
|
debugLog('I',"Duplication de l'annonce collectée n°$idAnn sur $siret",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$result = 1;
|
|
}
|
|
else
|
|
{
|
|
debugLog('I',"Suppression impossible de l'annonce collectée n°$idAnn ($siret)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Suppression de l\'annonce impossible';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$output = new DupliqueAnnonceCollecte();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Récupère le contenu d'une annonce issue de la collecte
|
|
* @param string $idAnn
|
|
* @param string $siret
|
|
* @return AnnonceCollecteReturn
|
|
*/
|
|
public function getAnnonceCollecte($idAnn, $siret)
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
$annonceCollecte = new AnnonceCollecte();
|
|
$siren = substr(''.$siret,0,9)*1;
|
|
if ($this->tabInfoUser['idClient']<>1)
|
|
{
|
|
$error->errnum = 0;
|
|
$error->errmsg = 'Code Client Incorrect';
|
|
}
|
|
else
|
|
{
|
|
$iDb = new WDB();
|
|
debugLog('I',"Lecture de l'annonce collecté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];
|
|
$annonceCollecte->id = $ann['id'];
|
|
$annonceCollecte->siren = $ann['siren'];
|
|
$annonceCollecte->raisonSociale = $ann['raisonSociale'];
|
|
$annonceCollecte->adresse = $ann['adresse'];
|
|
$annonceCollecte->codePostal = $ann['codePostal'];
|
|
$annonceCollecte->ville = $ann['ville'];
|
|
$annonceCollecte->dateJugement = $ann['dateJugement'];
|
|
|
|
$tabEven = array();
|
|
foreach ( $ann['typeEven'] as $code => $even )
|
|
{
|
|
$annonceEvenement = new AnnonceEvenement();
|
|
$annonceEvenement->codeEven = $code;
|
|
$annonceEvenement->LibEven = $even;
|
|
$tabEven[] = $annonceEvenement;
|
|
}
|
|
foreach ( explode(';',$ann['strEven']) as $code => $even )
|
|
{
|
|
$annonceEvenement = new AnnonceEvenement();
|
|
$annonceEvenement->codeEven = $code;
|
|
$annonceEvenement->LibEven = $even;
|
|
$tabEven[] = $annonceEvenement;
|
|
}
|
|
$annonceCollecte->even = $tabEven;
|
|
|
|
$annonceCollecte->dateSource = $ann['dateSource'];
|
|
$annonceCollecte->dateCessationPaiement = $ann['dateCessationPaiement'];
|
|
$annonceCollecte->dateEffetFinP = $ann['dateEffetFinP'];
|
|
$annonceCollecte->tribunal = $ann['tribunal'];
|
|
$annonceCollecte->numero = $ann['numero'];
|
|
$annonceCollecte->montant = $ann['montant'];
|
|
$annonceCollecte->actionsNb = $ann['actionsNb'];
|
|
$annonceCollecte->inter1type = $ann['inter1type'];
|
|
$annonceCollecte->inter1id = $ann['inter1id'];
|
|
$annonceCollecte->inter1nom = $ann['inter1nom'];
|
|
$annonceCollecte->inter2type = $ann['inter2type'];
|
|
$annonceCollecte->inter2id = $ann['inter2id'];
|
|
$annonceCollecte->inter2nom = $ann['inter2nom'];
|
|
$annonceCollecte->inter3type = $ann['inter3type'];
|
|
$annonceCollecte->inter3id = $ann['inter3id'];
|
|
$annonceCollecte->inter3nom = $ann['inter3nom'];
|
|
$annonceCollecte->complement = $ann['complement'];
|
|
$annonceCollecte->nouvActivite = $ann['nouvActivite'];
|
|
$annonceCollecte->nouvDir = $ann['nouvDir'];
|
|
$annonceCollecte->nouvAdr = $ann['nouvAdr'];
|
|
$annonceCollecte->nouvFJ = $ann['nouvFJ'];
|
|
$annonceCollecte->source = $ann['source'];
|
|
|
|
debugLog('I',"Lecture de l'annonce collectée n°$idAnn ($siret) : ".$ann['raisonSociale'],__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$error->errnum = 745741;
|
|
$error->errmsg = 'Selection impossible';
|
|
}
|
|
}
|
|
$output = new AnnonceCollecteReturn();
|
|
$output->error = $error;
|
|
$output->result = $annonceCollecte;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* getDevises
|
|
* @param string $codeIsoDevise
|
|
* @return DevisesReturn
|
|
*/
|
|
public function getDevises($codeIsoDevise='')
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
if (empty($codeIsoDevise)) $codeIsoDevise = '';
|
|
|
|
debugLog('I',"Liste des devises ou devise $codeIsoDevise demandée",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$tabTmp = $this->iInsee->getDevises($codeIsoDevise);
|
|
$tabRet = array();
|
|
foreach ($tabTmp as $i=>$devise)
|
|
{
|
|
$devise = new Devise();
|
|
$devise->devIso = $i;
|
|
$devise->devNom = $devise;
|
|
$tabRet[] = $devise;
|
|
}
|
|
$output = new DevisesReturn();
|
|
$output->error = $error;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne la liste des codes devises, libellés, date et valeur
|
|
* (toutes les devises ou une seule)
|
|
* @param string $devise Devise sur 3 lettres (facultatif)
|
|
* @return DevisesCoursReturn
|
|
*/
|
|
public function getDeviseCours($devise=false)
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
$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)
|
|
{
|
|
$devise = new DevisesCours();
|
|
$devise->codeDevise = $tabDev['devise'];
|
|
$devise->nomDevise = $tabDev['devNom'];
|
|
$devise->dateChange = $tabDev['dateChange'];
|
|
$devise->valeurDevise = $tabDev['valeur'];
|
|
$tabRet[] = $devise;
|
|
}
|
|
$output = new DevisesCoursReturn();
|
|
$output->error = $error;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Enter description here...
|
|
* @param string $siren
|
|
* @param int $idDepot
|
|
* @return
|
|
*/
|
|
protected function getMarques($siren, $idDepot=0) {
|
|
debugLog('I',"Liste des marques déposées pour le siren $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$marques=array();
|
|
$iDb=new WDB();
|
|
|
|
require_once 'Metier/partenaires/classMMarques.php';
|
|
$iMarque=new MMarques();
|
|
$ret=$iMarque->getMarques($siren, $idDepot);
|
|
foreach ($ret as $i=>$marque) {
|
|
if (trim($marque['imgLink'])<>'') $idLien=$marque['numeroMarque'];
|
|
else $idLien='';
|
|
$marques[$i]=array( 'Marques' => prepareString($marque['nomMarque']),
|
|
'Date' => $marque['dateDepot'],
|
|
'Depot' => $marque['numeroMarque'],
|
|
'IdLien' => $idLien,
|
|
'UrlLien' => $marque['UrlLien'], // Rempli que si $idDepot<>0
|
|
'PdfDispo' => $marque['pdfLink'], // Nouveau
|
|
);
|
|
if ($idDepot==$marque['numeroMarque']) {
|
|
$marques[$i]['Classes'] = $marque['classesMarque']; // Nouveau
|
|
$marques[$i]['Perimetre'] = prepareString($marque['periMarque']); // Nouveau
|
|
$marques[$i]['DateExpir'] = $marque['dateExpir']; // Nouveau
|
|
return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>array(end($marques)));
|
|
}
|
|
}
|
|
|
|
/* $res=$iDb->select('marques', 'Marques,Date,Depot,IdLien, DATEDIFF(NOW(),dateUpdate) AS nbJourLastUpdate', "Siren=$siren ORDER BY `Date` DESC");
|
|
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);
|
|
}
|
|
*/
|
|
wsLog('marques',$siren);
|
|
return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>$marques);
|
|
}
|
|
|
|
/**
|
|
* Enter description here ...
|
|
* @param string $siren
|
|
* @param string $piece
|
|
* @param string $type
|
|
* @param integer $visu
|
|
* @param integer $courrier
|
|
* @param string $ref
|
|
* @return PieceReturn
|
|
*/
|
|
public function getPiece($siren, $piece='kbis', $type='', $visu=1, $courrier=0, $ref='')
|
|
{
|
|
global $hostName;
|
|
$this->authenticate();
|
|
set_time_limit(400);
|
|
|
|
if (empty($piece)) $piece = 'kbis';
|
|
if (empty($type)) $type = '';
|
|
if (empty($visu)) $visu = 1;
|
|
if (empty($courrier)) $courrier = 1;
|
|
if (empty($ref)) $ref = '';
|
|
$error = new ErrorType();
|
|
|
|
$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");
|
|
}
|
|
$result = new PieceResult();
|
|
$result->Siren = $siren;
|
|
$result->Url = $hostName.'/data/kbis/'.$piece.'-'.$siren.'.pdf';
|
|
$result->Taille = $size;
|
|
$result->Cache = $cache;
|
|
$result->fichier = $ficDist;
|
|
wsLog('kbis', $siren, "$cache/$visu/$courrier/$type/$ref");
|
|
$output = new PieceReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* commandeAsso
|
|
* @param string $siren
|
|
* @param array $infoAsso
|
|
* @param array $infoDemande
|
|
* @return CommandeAssoReturn
|
|
*/
|
|
public function commandeAsso($siren, $infoAsso=array(), $infoDemande=array())
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
$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 = $this->tabInfoUser['email'];
|
|
|
|
$tabInsert=array(
|
|
'idUser' => $this->tabInfoUser['id'],
|
|
'source' => 'asso',
|
|
'login' => $this->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))
|
|
{
|
|
@sendMail('production@scores-decisions.com', 'asso@scores-decisions.com',
|
|
"Commande de statuts association pour $assoNom ($siren)",
|
|
"Association :".EOL.print_r($infoAsso, true).EOL.EOL.
|
|
"Demandeur:".EOL.print_r($infoDemande, true).EOL.EOL.
|
|
"Réponse RefAsso en $duree secondes :".EOL.print_r($page, true)
|
|
);
|
|
$iDbCrm = new WDB('sdv1');
|
|
$ret = $iDbCrm->insert('commandes', $tabInsert, true);
|
|
|
|
$result = new CommandeAsso();
|
|
$result->siren = $siren;
|
|
$result->emailCommande = $mail;
|
|
$result->dateCommande = DATETIME;
|
|
$result->refCmd = '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 été prise en compte sous la référence i$ret - ".DATETIME);
|
|
wsLog('commandeAsso', $siren, 'i'.$ret.'-'.DATETIME);
|
|
debugLog('I',"commandeAsso pour $assoNom ($siren) fin",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
} else {
|
|
@sendMail('production@scores-decisions.com', 'asso@scores-decisions.com',
|
|
"ERREUR lors de lommande de statuts association pour $assoNom ($siren)", "Association :".EOL.print_r($infoAsso, true).EOL.EOL.
|
|
"Demandeur:".EOL.print_r($infoDemande, true).EOL.EOL.
|
|
"Réponse RefAsso en $duree secondes :".EOL.print_r($page, true));
|
|
|
|
$result = new CommandeAsso();
|
|
$result->siren = $siren;
|
|
$result->emailCommande = $mail;
|
|
$result->dateCommande = DATETIME;
|
|
$result->refCmd = 'ERREUR';
|
|
debugLog('E',"commandeAsso pour $assoNom ($siren) fin",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
}
|
|
$output = new CommandeAssoReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Commande d'une enquête sur une entreprise en France ou à l'Internationale
|
|
* @param string $siren
|
|
* @param array $infoEnq
|
|
* @param array $infoDemande
|
|
* @return CommandeEnqueteReturn
|
|
**/
|
|
public function commandeEnquete($siren, $infoEnq=array(), $infoDemande=array())
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
$mail = trim($infoDemande['Email']);
|
|
if ($mail=='') $mail = $this->tabInfoUser['email'];
|
|
|
|
$tabInsert = array(
|
|
'idUser' => $this->tabInfoUser['id'],
|
|
'source'=> 'intersud', // 'greffes', 'asso', 'graydon'
|
|
'login'=> $this->tabInfoUser['login'],
|
|
'emailCommande'=> $mail,
|
|
'siren'=> $siren,
|
|
'refDocument'=> serialize($infoDemande),
|
|
'refCommande'=> serialize($infoEnq),
|
|
'dateCommande'=> DATETIME,
|
|
);
|
|
debugLog('I',"commande d'enquete sur $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$messageInfo=print_r($infoEnq, 1).EOL.print_r($infoDemande,1).EOL;
|
|
|
|
$idClient = $this->tabInfoUser['idClient'];
|
|
$iDbCrm = new WDB('sdv1');
|
|
$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é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';
|
|
|
|
if ($login=='') {
|
|
/** 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';
|
|
*/
|
|
}
|
|
|
|
$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);
|
|
$tfin=microtime(true);
|
|
$duree=$tfin-$tdeb;
|
|
$referer=$url;
|
|
$body=$page['body'];
|
|
$cookie=$page['header']['Set-Cookie'];
|
|
|
|
$url='http://intersud.fr/espace_client/demande_enquete.php';
|
|
$tdeb=microtime(true);
|
|
$page=getUrl($url, $cookie, '', $referer, false, '', '', 7);
|
|
$tfin=microtime(true);
|
|
$duree+=$tfin-$tdeb;
|
|
$referer=$url;
|
|
$body=$page['body'];
|
|
|
|
$fp=@fopen(LOG_PATH."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];
|
|
}
|
|
}
|
|
$fp=@fopen(LOG_PATH."intersud.log", "a");
|
|
@fwrite($fp, print_r($matches,true));
|
|
@fwrite($fp, print_r($tabInterSud,true));
|
|
@fclose($fp);
|
|
|
|
$ret = $iDbCrm->insert('commandes', $tabInsert, true);
|
|
$comment = "Référence de la commande chez Scores et Décisions : i$ret - ".
|
|
DATETIME."\n".
|
|
"Date et heure de la commande : ".date('d/m/Y - H:i')."\n".
|
|
"Origine de la commande : $nomClient".
|
|
"$strInfoCommande"."\n\n".
|
|
|
|
"CA : ".$infoEnq['Precisions']['MontantCA']."\n".
|
|
"Motif de la demande : ".trim($infoEnq['Precisions']['Motif'].' '.$infoEnq['Precisions']['Autre'])."\n".
|
|
"Type de la demande : ".$infoEnq['Precisions']['Type']."\n".
|
|
"Anciennete de la relation : ".$infoEnq['Anciennete'].' '.$infoEnq['AncienneteDuree']."\n".
|
|
"Observations : ".$infoEnq['Observation'].EOL;
|
|
|
|
if ($infoEnq['ImpayeesChoix']<>'non')
|
|
$comment.="Impayé(s) : ".$infoEnq['Impayees']['Nombre']." impayé(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é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é **/
|
|
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);
|
|
|
|
$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),
|
|
'val_ret'=>1,
|
|
);
|
|
$url='http://intersud.fr/espace_client/demande_enquete.php';
|
|
$tdeb=microtime(true);
|
|
$page=getUrl($url, $cookie, $tabPost, $referer, false, '', '', 7);
|
|
$tfin=microtime(true);
|
|
$duree+=$tfin-$tdeb;
|
|
$referer=$url;
|
|
$body=$page['body'];
|
|
|
|
$result = new CommandeEnquete();
|
|
$result->siren = $siren;
|
|
$result->emailCommande = $mail;
|
|
$result->dateCommande = DATETIME;
|
|
$result->refCmd = 'i'.$ret;
|
|
|
|
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Commande d'enquete sur $siren", $comment.EOL.EOL.'---------------------------------'.EOL.$messageInfo);
|
|
@sendMail('production@scores-decisions.com', $mail, "Votre demande d'enquete sur ".$tabIdentite['Nom']." ($siren)", "Votre demande d'enquête sur la société ".$tabIdentite['Nom']." a été prise en compte sous la référence i$ret - ".DATETIME);
|
|
wsLog($typeEnqLog, $siren, 'i'.$ret.'-'.DATETIME);
|
|
|
|
$output = new CommandeEnqueteReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Récupération d'un kbis
|
|
* @param string $siren
|
|
* @param int $visu
|
|
* @param int $courrier
|
|
* @param string $mail
|
|
* @param string $ref
|
|
* @return PieceReturn
|
|
*/
|
|
public function getKbis($siren, $visu=1, $courrier=0, $mail='', $ref='')
|
|
{
|
|
return $this->getPiece($siren, 'kbis', '', $visu, $courrier, $ref);
|
|
}
|
|
|
|
/**
|
|
* Récupère les informations du profil connecté
|
|
* @param string $login
|
|
* @param int $idClient
|
|
* @return ListeUtilisateursReturn
|
|
*/
|
|
public function getListeUtilisateurs($login, $idClient=-1)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
if (empty($idClient)) $idClient = -1;
|
|
$error = new ErrorType();
|
|
$tabRet = array();
|
|
|
|
if ($this->tabInfoUser['profil']<>'Administrateur' &&
|
|
$this->tabInfoUser['profil']<>'SuperAdministrateur')
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Profil non administrateur';
|
|
}
|
|
else
|
|
{
|
|
$iDbCrm = new WDB('sdv1');
|
|
$rep=$iDbCrm->select('utilisateurs', 'idClient', "login='$login'");
|
|
$idClient=$rep[0][0];
|
|
if ($idClient==-1)
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'idClient=0';
|
|
}
|
|
else
|
|
{
|
|
$rep=$iDbCrm->select('utilisateurs', 'id, idClient, login, email, actif, nom, prenom, referenceParDefaut', "idClient='$idClient' AND deleted=0 ORDER BY login ASC", true, MYSQL_ASSOC);
|
|
foreach ($rep as $uti)
|
|
{
|
|
$utilisateur = new Utilisateur();
|
|
$utilisateur->idUti = $uti['id'];
|
|
$utilisateur->idClient= $uti['idClient'];
|
|
$utilisateur->login = $uti['login'];
|
|
$utilisateur->email = $uti['email'];
|
|
$utilisateur->actif= $uti['actif'];
|
|
$utilisateur->nom = $uti['nom'];
|
|
$utilisateur->prenom = $uti['prenom'];
|
|
$utilisateur->reference = $uti['referenceParDefaut'];
|
|
$tabRet[]= $utilisateur;
|
|
}
|
|
}
|
|
}
|
|
$output = new ListeUtilisateursReturn();
|
|
$output->error = $error;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Créations/Modification d'utilisateurs
|
|
* @param integer $idClient
|
|
* @param SetUtilisateurs[] $users
|
|
* @return UtilisateursReturn
|
|
*/
|
|
protected function setUtilisateurs($idClient, $users)
|
|
{
|
|
$this->authenticate();
|
|
$error = new ErrorType();
|
|
$result = false;
|
|
//idClient existe
|
|
$iDbCrm = new WDB('sdv1');
|
|
$rep = $iDbCrm->select('clients', 'id, nom, actif, test, racineLogin, siren, nic, droits, filtres_ip, typeAcces, typeScore, accesPieces, accesKbis, accesInvestigations, accesInternationnal, accesEnquetes, miseSousSurveillance', "1 AND id='$idClient'", true, MYSQL_ASSOC);
|
|
if (count($rep)>0){
|
|
$client = $rep[0];
|
|
$idClient = $client['id'];
|
|
if (count($users)>0){
|
|
foreach($users as $user){
|
|
$tabInfos = array();
|
|
$tabInfos['idClient'] = $idClient;
|
|
$tabInfos['login'] = $user->login;
|
|
$tabInfos['email'] = '';
|
|
$tabInfos['password'] = $user->password;
|
|
$tabInfos['actif'] = '';
|
|
//$tabInfos['deleted'] = '';
|
|
|
|
if (in_array($user->typeCompte, array('TEST', 'PROD'))){
|
|
$tabInfos['typeCompte'] = $user->typeCompte;
|
|
} else {
|
|
$tabInfos['typeCompte'] = 'PROD';
|
|
}
|
|
|
|
//$tabInfos['filtre_ip'] = '';
|
|
|
|
//SetInfosLogin
|
|
$tabInfos['civilite'] = '';
|
|
$tabInfos['nom'] = '';
|
|
$tabInfos['prenom'] = '';
|
|
|
|
//Identique au client
|
|
$tabInfos['raisonSociale'] = '';
|
|
$tabInfos['siret'] = '';
|
|
$tabInfos['adrNum'] = '';
|
|
$tabInfos['adrInRep'] = '';
|
|
$tabInfos['adrTypeVoie'] = '';
|
|
$tabInfos['adrLibVoie'] = '';
|
|
$tabInfos['adrCp'] = '';
|
|
$tabInfos['adrVille'] = '';
|
|
$tabInfos['adrComp'] = '';
|
|
$tabInfos['tel'] = '';
|
|
$tabInfos['fax'] = '';
|
|
$tabInfos['mobile'] = '';
|
|
|
|
$tabInfos['pref'] = '';
|
|
|
|
if (in_array($user->typeCompte, array('Administrateur', 'Utilisateur'))){
|
|
$tabInfos['profil'] = $user->profil;
|
|
} else {
|
|
$tabInfos['profil'] = 'Utilisateur';
|
|
}
|
|
/*
|
|
$tabInfos['dateInscription'] = '';
|
|
$tabInfos['dateValidation'] = '';
|
|
*/
|
|
|
|
if (empty($user->droits)){
|
|
$tabInfos['droits'] = $client->droits;
|
|
} else {
|
|
$tabInfos['droits'] = $user->droits;
|
|
}
|
|
$tabInfos['referenceParDefaut'] = '';
|
|
$tabInfos['nbReponses'] = '';
|
|
$tabInfos['listeEven'] = '';
|
|
$tabInfos['maxFicheId'] = $user->maxFicheId;
|
|
|
|
//$tabInfos['dateInsert'] = '';
|
|
|
|
|
|
if (empty($user->id)){
|
|
$iDbCrm->insert('utilisateurs', $tabInfos);
|
|
} else {
|
|
$iDbCrm->update('utilisateurs', $tabInfos, "id='$user->id'");
|
|
}
|
|
|
|
}
|
|
} else {
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Aucun utiliateur';
|
|
}
|
|
} else {
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Identifiant client inconnu!';
|
|
}
|
|
$output = new UtilisateursReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Création d'un modele pour le préremplisage des données utilisateurs
|
|
* @param integer $idClient
|
|
* @param string $nom
|
|
* @param ModeleUtilisateur $infos
|
|
* @return ModeleUtilisateurReturn
|
|
*/
|
|
protected function setModeleUtilisateur($idClient, $nom, $infos)
|
|
{
|
|
$this->authenticate();
|
|
|
|
}
|
|
|
|
/**
|
|
* Création/Modification d'un client
|
|
* @param Client $infos
|
|
* @param integer $idModele
|
|
* @return ClientReturn
|
|
*/
|
|
public function setClient($infos, $idModele = null)
|
|
{
|
|
$this->authenticate();
|
|
$error = new ErrorType();
|
|
$result = false;
|
|
//Pas SuperAdministrateur
|
|
if ($this->tabInfoUser['profil']!='SuperAdministrateur')
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Profil insuffisant pour cette méthode';
|
|
}
|
|
else
|
|
{
|
|
$tabInfos = array();
|
|
$tabInfos['nom'] = $infos->nom;
|
|
$tabInfos['actif'] = ($infos->actif=='Oui') ? 'Oui' : 'Non' ;
|
|
$tabInfos['test'] = ($infos->test=='Oui') ? 'Oui' : 'Non' ;
|
|
$tabInfos['racineLogin'] = $infos->racineLogin;
|
|
$tabInfos['siren'] = (int) $infos->siren;
|
|
$tabInfos['nic'] = (int) $infos->nic;
|
|
$tabInfos['tva'] = $infos->tva;
|
|
$tabInfos['idClientFacture'] = $infos->idClientFacture;
|
|
if ($infos->editerFacture=='Non') {
|
|
$tabInfos['editerFacture'] = 'Non' ;
|
|
}
|
|
$tabInfos['fact_detail'] = ($infos->fact_detail=='Oui') ? 'Oui' : 'Non' ;
|
|
$tabInfos['fact_dest'] = $infos->fact_dest;
|
|
$tabInfos['fact_adr1'] = $infos->fact_adr1;
|
|
$tabInfos['fact_adr2'] = $infos->fact_adr2;
|
|
$tabInfos['fact_adr3'] = $infos->fact_adr3;
|
|
$tabInfos['fact_email'] = $infos->fact_email;
|
|
$tabInfos['fact_tel'] = $infos->fact_tel;
|
|
if (in_array($infos->fact_rib, array('BPOSTALE','CCOOP', 'CDNORD'))){
|
|
$tabInfos['fact_rib'] = $infos->fact_rib;
|
|
}
|
|
$tabInfos['fact_tel'] = $infos->fact_tel;
|
|
$tabInfos['liv_dest'] = $infos->liv_dest;
|
|
$tabInfos['liv_adr1'] = $infos->liv_adr1;
|
|
$tabInfos['liv_adr2'] = $infos->liv_adr2;
|
|
$tabInfos['liv_adr3'] = $infos->liv_adr3;
|
|
$tabInfos['liv_email'] = $infos->liv_email;
|
|
$tabInfos['liv_tel'] = $infos->liv_tel;
|
|
$tabInfos['droits'] = $infos->droits;
|
|
$tabInfos['filtres_ip'] = $infos->filtres_ip;
|
|
//$tabInfos['respComSD'] = $infos->respComSD;
|
|
if (in_array($infos->typeContrat, array('Contrat','Marché'))){
|
|
$tabInfos['typeContrat'] = $infos->typeContrat;
|
|
}
|
|
if (in_array($infos->typeAcces, array('userPassword','userPasswordIP', 'IP'))){
|
|
$tabInfos['typeAcces'] = $infos->typeAcces;
|
|
}
|
|
if (in_array($infos->typeScore, array('20','100'))){
|
|
$tabInfos['typescores'] = $infos->typeScores;
|
|
}
|
|
if (!empty($timeout)){
|
|
$tabInfos['timeout'] = $infos->timeout;
|
|
}
|
|
$tabInfos['accesPieces'] = ($infos->accesPieces=='Oui') ? 'Oui' : 'Non' ;
|
|
$tabInfos['accesKbis'] = ($infos->accesKbis=='Oui') ? 'Oui' : 'Non' ;
|
|
$tabInfos['accesInvestigations'] = ($infos->accesInvestigations=='Oui') ? 'Oui' : 'Non' ;
|
|
$tabInfos['accesInternationnal'] = ($infos->accesInternationnal=='Oui') ? 'Oui' : 'Non' ;
|
|
$tabInfos['accesEnquetes'] = ($infos->accesEnquetes=='Oui') ? 'Oui' : 'Non' ;
|
|
$tabInfos['miseSousSurveillance'] = ($infos->miseSousSurveillance=='Oui') ? 'Oui' : 'Non' ;
|
|
if (in_array($infos->forfaitExtranetPeriode, array('Mensuel','Trimestriel','Semestriel', 'Annuel'))){
|
|
$tabInfos['forfaitExtranetPeriode'] = $infos->forfaitExtranetPeriode;
|
|
}
|
|
$tabInfos['forfaitExtranetMontant'] = $infos->forfaitExtranetMontant;
|
|
if ($infos->reconductionAuto=='Non') {
|
|
$tabInfos['reconductionAuto'] = 'Non';
|
|
}
|
|
$tabInfos['remarque'] = $infos->remarque;
|
|
$tabInfos['forfaitPiecesNb'] = $infos->forfaitPiecesNb;
|
|
$tabInfos['forfaitPiecesMt'] = $infos->forfaitPiecesMt;
|
|
$tabInfos['forfaitPiecesDep'] = $infos->forfaitPiecesDep;
|
|
$tabInfos['forfaitInvestigNb'] = $infos->forfaitInvestigNb;
|
|
$tabInfos['forfaitInvestigMt'] = $infos->forfaitInvestigMt;
|
|
$tabInfos['forfaitInvestigDep'] = $infos->forfaitInvestigDep;
|
|
$tabInfos['tarifIndiscore'] = $infos->tarifIndiscore;
|
|
$tabInfos['InterSudLogin'] = $infos->InterSudLogin;
|
|
$tabInfos['InterSudPass'] = $infos->InterSudPass;
|
|
|
|
$iDbCrm = new WDB('sdv1');
|
|
if (empty($infos->idClient)){
|
|
//Ajout
|
|
//$tabInfos['dateInsert'] = now();
|
|
if($iDbCrm->insert('clients', $tabInfos)){
|
|
$result = true;
|
|
}
|
|
} else {
|
|
//Modification
|
|
if ($iDbCrm->update('clients', $tabInfos, "id='$idClient'")){
|
|
$result = true;
|
|
}
|
|
}
|
|
}
|
|
$output = new ClientReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Récupère la liste des clients ou les informations d'un client
|
|
* @param int $idClient
|
|
* @return ListeClientsReturn
|
|
*/
|
|
public function getListeClients($idClient=0)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
if (empty($idClient)) $idClient = 0;
|
|
$error = new ErrorType();
|
|
|
|
$isAuthorized = false;
|
|
|
|
if ($this->tabInfoUser['profil']=='Administrateur' &&
|
|
($idClient==0 || $idClient==$this->tabInfoUser['idClient']))
|
|
{
|
|
$idClient = $this->tabInfoUser['idClient'];
|
|
$isAuthorized = true;
|
|
}
|
|
|
|
if ($this->tabInfoUser['profil']<>'SuperAdministrateur')
|
|
{
|
|
$error->errnum = 1;
|
|
$error->errmsg = 'Profil non administrateur';
|
|
}
|
|
else
|
|
{
|
|
$isAuthorized = true;
|
|
}
|
|
|
|
if ($isAuthorized)
|
|
{
|
|
$strClient = '';
|
|
if ($idClient>0) $strClient.=" AND id='$idClient' ";
|
|
$iDbCrm = new WDB('sdv1');
|
|
$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)
|
|
{
|
|
$client = new Client();
|
|
$client->idClient = $uti['id'];
|
|
$client->nom = $uti['nom'];
|
|
$client->actif = $uti['actif'];
|
|
$client->test = $uti['test'];
|
|
$client->racineLogin = $uti['racineLogin'];
|
|
$client->siren = $uti['siren'];
|
|
$client->nic = $uti['nic'];
|
|
$client->tva = $uti['tva'];
|
|
$client->editerFacture = $uti['editerFacture'];
|
|
$client->fact_detail = $uti['fact_detail'];
|
|
$client->fac_dest = $uti['fac_dest'];
|
|
$client->fac_adr1 = $uti['fac_adr1'];
|
|
$client->fac_adr2 = $uti['fac_adr2'];
|
|
$client->fac_adr3 = $uti['fac_adr3'];
|
|
$client->fac_email = $uti['fac_email'];
|
|
$client->fac_tel = $uti['fac_tel'];
|
|
$client->fact_rib = $uti['fact_rib'];
|
|
$client->liv_dest = $uti['liv_dest'];
|
|
$client->liv_adr1 = $uti['liv_adr1'];
|
|
$client->liv_adr2 = $uti['liv_adr2'];
|
|
$client->liv_adr3 = $uti['liv_adr3'];
|
|
$client->liv_email = $uti['liv_email'];
|
|
$client->liv_tel = $uti['liv_tel'];
|
|
$client->droits = $uti['droits'];
|
|
$client->timeout = $uti['timeout'];
|
|
$client->filtres_ip = $uti['filtres_ip'];
|
|
$client->dateInsert = $uti['dateInsert'];
|
|
$client->dateUpdate = $uti['dateUpdate'];
|
|
$client->respComSD = $uti['respComSD'];
|
|
$client->typeContrat = $uti['typeContrat'];
|
|
$client->dateSignature = $uti['dateSignature'];
|
|
$client->typeAcces = $uti['typeAcces'];
|
|
$client->typeScore = $uti['typeScore'];
|
|
$client->accesPieces = $uti['accesPieces'];
|
|
$client->accesKbis = $uti['accesKbis'];
|
|
$client->accesInvestigations = $uti['accesInvestigations'];
|
|
$client->accesInternationnal = $uti['accesInternationnal'];
|
|
$client->accesEnquetes = $uti['accesEnquetes'];
|
|
$client->miseSousSurveillance = $uti['miseSousSurveillance'];
|
|
$client->forfaitExtranetPeriode = $uti['forfaitExtranetPeriode'];
|
|
$client->forfaitExtranetMontant = $uti['forfaitExtranetMontant'];
|
|
$client->reconductionAuto = $uti['reconductionAuto'];
|
|
$client->remarque = $uti['remarque'];
|
|
$client->forfaitPiecesNb = $uti['forfaitPiecesNb'];
|
|
$client->forfaitPiecesMt = $uti['forfaitPiecesMt'];
|
|
$client->forfaitPiecesDep = $uti['forfaitPiecesDep'];
|
|
$client->forfaitInvestigNb = $uti['forfaitInvestigNb'];
|
|
$client->forfaitInvestigMt = $uti['forfaitInvestigMt'];
|
|
$client->forfaitInvestigDep = $uti['forfaitInvestigDep'];
|
|
$client->tarifIndiscore = $uti['tarifIndiscore'];
|
|
|
|
$tabRet[] = $client;
|
|
}
|
|
}
|
|
$output = new ListeClientsReturn();
|
|
$output->error = $error;
|
|
$output->result = $tabRet;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* Retourne la liste des droits
|
|
* @return ListeDroitsReturn[]
|
|
*/
|
|
public function getListeDroits()
|
|
{
|
|
$tabRet = array();
|
|
foreach($this->listeDroits as $code => $desc){
|
|
$droit = new ListeDroitsReturn();
|
|
$droit->code = $code;
|
|
$droit->desc = $desc;
|
|
$tabRet[] = $droit;
|
|
}
|
|
return $tabRet;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* Retourne la liste des préférences
|
|
* @return ListePrefsReturn[]
|
|
*/
|
|
public function getListePrefs()
|
|
{
|
|
$tabRet = array();
|
|
foreach($this->listePrefs as $code => $desc){
|
|
$pref = new ListePrefsReturn();
|
|
$pref->code = $code;
|
|
$pref->desc = $desc;
|
|
$tabRet[] = $pref;
|
|
}
|
|
return $tabRet;
|
|
}
|
|
|
|
|
|
/**
|
|
* getStatsUtilisateurs
|
|
* @param string $login
|
|
* @param string $mois
|
|
* @param string $type
|
|
* @param boolean $payants
|
|
* @return array
|
|
*/
|
|
public function getStatsUtilisateurs($login, $mois, $type='jour', $payants=false)
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
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='';
|
|
}
|
|
$iDbCrm = new WDB('sdv1');
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* getPortefeuilleCsv
|
|
* @param string $login
|
|
* @param int $idClient
|
|
* @return ListeSurveillancesCsvReturn
|
|
*/
|
|
public function getPortefeuilleCsv($login='', $idClient=0)
|
|
{
|
|
return $this->getListeSurveillancesCsv('portefeuille', $login, $idClient);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* getSurveillances
|
|
* @param string $siret
|
|
* @param string $source
|
|
* @param boolean $detail
|
|
* @param int $deb
|
|
* @param int $nbRet
|
|
* @param string $tri
|
|
* @return SurveillancesReturn
|
|
*/
|
|
public function getSurveillances($siret=0, $source='annonces', $detail=false, $deb=0, $nbRet=100, $tri='siren')
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
$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();
|
|
|
|
$login = $this->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)
|
|
{
|
|
$surveillance = new SurveillancesReponses();
|
|
$surveillance->source = $tabSurv['source'];
|
|
$surveillance->email = $tabSurv['email'];
|
|
$surveillance->siren = $tabSurv['siren'];
|
|
$surveillance->nic = $tabSurv['nic'];
|
|
$surveillance->ref = $tabSurv['ref'];
|
|
$surveillance->dateAjout = $tabSurv['dateAjout'];
|
|
$surveillance->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);
|
|
}
|
|
|
|
$surveillance = new SurveillancesReponses();
|
|
$surveillance->source = $tabSurv['source'];
|
|
$surveillance->email = $tabSurv['email'];
|
|
$surveillance->siren = $tabSurv['siren'];
|
|
$surveillance->nic = $tabSurv['nic'];
|
|
$surveillance->ref = $tabSurv['ref'];
|
|
$surveillance->dateAjout = $tabSurv['dateAjout'];
|
|
$surveillance->dateDerEnvoi = $tabSurv['dateDerEnvoi'];
|
|
$surveillance->encoursClient = $tabSurv['encoursClient'];
|
|
$surveillance->rs = $rs;
|
|
$surveillance->cp = $cp;
|
|
$surveillance->ville = $ville;
|
|
}
|
|
$tabRet[] = $surveillance;
|
|
}
|
|
|
|
$criteres = new SurveillancesCriteres();
|
|
$criteres->siren = $siren;
|
|
$criteres->nic = $nic;
|
|
$criteres->source = $source;
|
|
|
|
$result = new SurveillancesResult();
|
|
$result->criteres = $criteres;
|
|
$result->nbReponses = count($tabRet);
|
|
$result->nbReponsesTotal = $nbRepTot;
|
|
$result->reponses = $tabRet;
|
|
|
|
$output = new SurveillancesReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* rechercheHisto
|
|
* @param string $recherche
|
|
* @param string $annee
|
|
* @param string $typeBod
|
|
* @param int $deb
|
|
* @param int $nbRep
|
|
* @param int $maxRep
|
|
* @param bool $pertinence
|
|
* @return RechercheHistoReturn
|
|
*/
|
|
public function rechercheHisto($recherche, $annee='', $typeBod='', $deb=0, $nbRep=20, $maxRep=200, $pertinence=false)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
if (empty($annee)) $annee = '';
|
|
if (empty($typeBod)) $typeBod = '';
|
|
if (empty($deb)) $deb = 0;
|
|
if (empty($nbRep)) $nbRep = 20;
|
|
if (empty($maxRep)) $maxRep = 200;
|
|
if (empty($annee)) $pertinence = false;
|
|
|
|
require_once 'framework/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é en position '.$posMin) ;
|
|
|
|
if ($posMin<150) $posMin=150;
|
|
$texte2=substr($texte, $posMin-150, 250);
|
|
|
|
|
|
$reponse = new RechercheHistoReponses();
|
|
$reponse->id = $etab['id'];
|
|
$reponse->Pertinence = $etab['Pertinence'];
|
|
$reponse->Fichier = strtr($etab['Fichier'], array('.txt'=>'.pdf', '/mnt/bodacc/'=>'http://tville.scores-decisions.com/bodacc/'));
|
|
$reponse->Annee = $etab['Annee'];
|
|
$reponse->Code = $etab['Code'];
|
|
$reponse->Texte = preg_replace('/^[A-Za-z0-9\sàáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝŸ]/','',$texte2);
|
|
$tabRet[] = $reponse;
|
|
$k++;
|
|
}
|
|
|
|
$criteres = new RechercheHistoCriteres();
|
|
$criteres->recherche = $recherche;
|
|
$criteres->annee = $annee;
|
|
|
|
$output = new RechercheHistoReturn();
|
|
$output->criteres = $criteres;
|
|
$output->nbReponses = count($tabRet);
|
|
$output->nbReponsesTotal = $nbTot;
|
|
$output->duree = $duree;
|
|
$output->mots = array_keys($tabMots);
|
|
$output->reponses = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* getLogsClients
|
|
* @param string $mois
|
|
* @param int $detail
|
|
* @param int $idClient
|
|
* @param string $login
|
|
* @param int $all
|
|
* @return LogsClientsReturn
|
|
*/
|
|
public function getLogsClients($mois, $detail=0, $idClient=0, $login='', $all=0)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
$strDetail = $strClient = $strLogin='';
|
|
|
|
// Vue détaillé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%') ";
|
|
$strDetail=" AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page LIKE 'indiscore%' OR page='privileges' OR page='commandeAsso') AND (params<>'' OR page LIKE 'indiscore%' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') ";
|
|
} elseif($detail==1) {
|
|
$detail='Oui';
|
|
}
|
|
|
|
// On veut uniquement le client précis
|
|
if ($all && $this->tabInfoUser['profil']=='SuperAdministrateur') {
|
|
$all='Oui';
|
|
} else {
|
|
$all='Non';
|
|
// Pas d'idClient mentionné ou tentative sur autre client et non SAD
|
|
if ($idClient*1==0 || ($idClient*1<>$this->tabInfoUser['idClient'] &&
|
|
$this->tabInfoUser['profil']<>'SuperAdministrateur') ){
|
|
$idClient=$this->tabInfoUser['idClient'];
|
|
}
|
|
$strClient=" AND u.idClient=$idClient ";
|
|
}
|
|
|
|
// On veut uniquement le login pré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
|
|
GROUP BY l.login, l.siren, date(dateHeure), params
|
|
ORDER BY l.login ASC, dateHeure ASC";
|
|
$fp = fopen(DOC_WEB_LOCAL."/csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql", 'w');
|
|
fwrite($fp, $sql.EOL);
|
|
fclose($fp);
|
|
exec(APPLICATION_PATH."/batch/sql2csv.php sdv1 ".DOC_WEB_LOCAL."/csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql $fichierCsv > /dev/null &");
|
|
$size=$cache=0;
|
|
}
|
|
|
|
$result = new LogsClients();
|
|
$result->Url = DOC_WEB_URL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
|
$result->Taille = $size;
|
|
$result->Cache = $cache;
|
|
|
|
$output = new LogsClientsReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* getListeSurveillanceCsv
|
|
* @param string $source
|
|
* @param string $login
|
|
* @param string $idClient
|
|
* @return ListeSurveillancesCsvReturn
|
|
*/
|
|
public function getListeSurveillancesCsv($source='', $login='', $idClient=0)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
debugLog('I',"getListeSurveillancesCsv Début $source $login $idClient",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$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<>$this->tabInfoUser['idClient'] && $this->tabInfoUser['profil']<>'SuperAdministrateur') )
|
|
{
|
|
$idClient=$this->tabInfoUser['idClient'];
|
|
}
|
|
$strClient=" AND u.idClient=$idClient ";
|
|
|
|
if ($login=='' && ($this->tabInfoUser['profil']=='SuperAdministrateur' || $this->tabInfoUser['profil']=='Administrateur'))
|
|
{
|
|
// On veut toutes les surveillances du client
|
|
$login='';//$tabInfoUser['login'];
|
|
}
|
|
elseif ($login<>'' && ($this->tabInfoUser['profil']=='SuperAdministrateur' || $this->tabInfoUser['profil']=='Administrateur'))
|
|
{
|
|
$strLogin=" AND s.login='$login' ";
|
|
}
|
|
else
|
|
{
|
|
$strLogin=" AND s.login='".$this->tabInfoUser['login']."' ";
|
|
}
|
|
|
|
$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);
|
|
if ($source=='score')
|
|
{
|
|
if ($tabInfoUser['typeScore']*1==20) { $strScore='v.indiScore20 AS indiScore20'; $strScorePre='v.indiScore20Pre AS indiScore20Pre'; }
|
|
else { $strScore='v.indiScore AS indiScore100'; $strScorePre='v.indiScorePre AS indiScore100Pre'; }
|
|
/*v.scoreZ, v.scoreZPre, v.scoreCH, v.scoreCHPre,
|
|
v.scoreAfdcc2, v.scoreAfdcc2Pre, v.situFi, v.situFiPre, v.infoNote, v.infoNotePre,
|
|
v.noteStruct, v.noteStructPre, v.noteFin, v.noteFinPre, v.tendance, v.tendancePre, */
|
|
$sql="SELECT LOWER(s.login) as loginUti, s.source, s.email, s.siren, s.nic, s.ref, s.dateAjout,
|
|
s.rs, s.cp, s.ville, s.dateDerEnvoi,
|
|
s.encoursClient, v.actif, v.procol, $strScore, v.encours, v.indiScoreDate, v.dateBilan,
|
|
$strScorePre, v.encoursPre, v.indiScoreDatePre, v.sourceModif, v.scoreSolv, v.scoreSolvPre, v.scoreDir,
|
|
v.scoreDirPre, v.scoreConf, v.scoreConfPre,
|
|
e.cj, e.capital, e.capitalDev, e.ape_entrep, e.tca, e.teff_entrep,
|
|
v.dateUpdate
|
|
FROM surveillances_site s, sdv1.utilisateurs u, sdv1.clients c, scores_surveillance v, etablissements e
|
|
WHERE s.source='score' $strClient $strLogin AND dateSuppr=0 AND s.login=u.login AND u.idClient=c.id AND s.siren=v.siren AND s.siren=e.siren
|
|
GROUP BY loginUti, s.siren, s.nic, s.source, s.ref
|
|
ORDER BY loginUti ASC, s.siren ASC, s.nic ASC, s.source ASC, s.ref ASC";
|
|
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeSurveillancesCsv($source, $login, $idClient)", $sql);
|
|
} else {
|
|
$sql="SELECT LOWER(s.login) as loginUti, s.source, s.email, s.siren, s.nic, s.ref, s.dateAjout,
|
|
s.rs, s.cp, s.ville, s.dateDerEnvoi
|
|
FROM surveillances_site s, sdv1.utilisateurs u, sdv1.clients c
|
|
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(DOC_WEB_LOCAL."csv/listesurv-$source-$login-$idClient.sql", 'w');
|
|
fwrite($fp, $sql.EOL);
|
|
fclose($fp);
|
|
exec(APPLICATION_PATH."/batch/sql2csv.php jo ".DOC_WEB_LOCAL."csv/listesurv-$source-$login-$idClient.sql $fichierCsv > /dev/null &");
|
|
$size=$cache=0;
|
|
}
|
|
|
|
$result = new ListeSurveillancesCsv();
|
|
$result->Url = DOC_WEB_URL."csv/listesurv-$source-$login-$idClient.csv";
|
|
$result->Taille = $size;
|
|
$result->Cache = $cache;
|
|
|
|
debugLog('I','getListeSurveillancesCsv Url='.DOC_WEB_URL."csv/listesurv-$source-$login-$idClient.csv, Taille=$size, Cache=$cache",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$output = new ListeSurveillancesCsvReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* getListeJalCollecte
|
|
* @return ListeJalCollecteReturn
|
|
*/
|
|
public function getListeJalCollecte()
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
|
|
$iBodacc = new MBodacc();
|
|
$tabRet = $iBodacc->getListeJalCollecte();
|
|
foreach ($tabRet as $i=>$jal)
|
|
{
|
|
$jalCollecte = new JalCollecte();
|
|
$jalCollecte->id = $i;
|
|
$jalCollecte->nom = $jal;
|
|
$tabRet[] = $jalCollecte;
|
|
}
|
|
$output = new ListeJalCollecteReturn();
|
|
$output->error = $error;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* getListeFichierSurv
|
|
* @param string $login
|
|
* @param string $ref
|
|
* @param string $nomFic
|
|
* @return ListeFichierSurvReturn
|
|
*/
|
|
public function getListeFichierSurv($login, $ref='*', $nomFic='')
|
|
{
|
|
global $hostName;
|
|
$this->authenticate();
|
|
if (empty($ref)) $ref = '*';
|
|
if (empty($nomFic)) $nomFic = '';
|
|
$error = new ErrorType();
|
|
//debugLog('I',"getListeFichierSurv pour $login, $ref, $nomFic",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$tabFichier=$tabDates=array();
|
|
$numAbo=substr($ref, 0,5);
|
|
if ($login=='vwbank') {
|
|
$repClient='volkswagen bank';
|
|
$ficClient='surveillanceBodacc_SURBODPRDCFTVWBANK';
|
|
$numAbo=$ref='19300';
|
|
} elseif (substr($login,0,6)=='apicil') {
|
|
$repClient='apicil';
|
|
$ficClient='surveillanceBodacc_SURBODPRDCFTAPICIL';
|
|
$numAbo=$ref='';
|
|
} else {
|
|
$repClient='cnasea';
|
|
$ficClient='surveillanceBodacc_SURBODTSTFTSCNASEA';
|
|
}
|
|
$dh = opendir(DOC_WEB_LOCAL."clients/$repClient/");
|
|
if (!$dh) {
|
|
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, $nomFic", "Impossible d'ouvrir le dossier '/home/data/clients/$repClient/'");
|
|
$error->errnum = 1;
|
|
$error->errmsg = "Impossible d'ouvrir le dossier client";
|
|
} else {
|
|
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);
|
|
}
|
|
elseif ($filename<>'.' && $filename<>'..' && substr($filename, -4)=='.csv' && substr($filename,0,37)==$ficClient && substr($filename,37,1)=='_' && $repClient=='apicil') {
|
|
$tabFichier[] = $filename;
|
|
$tabDates[]=substr($filename,38,8);
|
|
$tabClients[]=substr($filename,0,37);
|
|
}
|
|
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, $nomFic : fichier lu '$filename'", "Fichier lu '$filename'");
|
|
}
|
|
/** Tableau des noms de fichier **/
|
|
sort($tabFichier);
|
|
/** 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);
|
|
|
|
/*@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, $nomFic",
|
|
"Fichiers :".EOL.
|
|
print_r($tabFichier, true).
|
|
"Dates:".EOL.
|
|
print_r($tabDates, true).
|
|
"Clients :".EOL.
|
|
print_r($tabClients, true)
|
|
);*/
|
|
|
|
if ($ref=='*') {
|
|
$tabFichier = array();
|
|
// Boucle sur les dates de livraison
|
|
foreach ($tabDates as $dateFic) {
|
|
if (strlen($dateFic)<>8) continue;
|
|
if (!file_exists(DOC_WEB_LOCAL."clients/$repClient/$ficClient".'_'."$dateFic.csv") ||
|
|
filesize(DOC_WEB_LOCAL."clients/$repClient/$ficClient".'_'."$dateFic.csv")==0) {
|
|
|
|
$fpW=fopen(DOC_WEB_LOCAL."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(DOC_WEB_LOCAL."clients/$repClient/");
|
|
while (false !== ($filename = readdir($dh))) {
|
|
if (substr($filename,0,51)==$nomClient.'_'.$dateFic && substr($filename,-4)=='.csv') {
|
|
$fichier=$filename;
|
|
//break;
|
|
}
|
|
}
|
|
$fpR=fopen(DOC_WEB_LOCAL."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<>'') {
|
|
if (!file_exists(DOC_WEB_LOCAL."csv/$nomFic.bz2") ||
|
|
filesize(DOC_WEB_LOCAL."csv/$nomFic.bz2")==0) {
|
|
$string=file_get_contents(DOC_WEB_LOCAL."clients/$repClient/$nomFic");
|
|
$bz = bzopen(DOC_WEB_LOCAL."csv/$nomFic.bz2",'w');
|
|
if ($bz) {
|
|
bzwrite($bz, $string, strlen($string));
|
|
bzclose($bz);
|
|
}
|
|
}
|
|
}
|
|
debugLog('I',"getListeFichierSurv pour $login, $ref, $nomFic : nb fichiers=".count($tabFichier),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$result = array();
|
|
foreach($tabFichier as $fichier){
|
|
$retFichier = new ListeFichierSurv();
|
|
$retFichier->UrlFichier = $hostName.'/data/csv/'.$fichier;
|
|
$result[] = $retFichier;
|
|
}
|
|
}
|
|
$output = new ListeFichierSurvReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Geocodage d'une adresse
|
|
* @param string $adresse
|
|
* @param string $cp
|
|
* @param string $ville
|
|
* @param string $pays
|
|
* @return GeoCodeReturn
|
|
*/
|
|
public function geoCode($adresse, $cp, $ville, $pays='France')
|
|
{
|
|
$this->authenticate();
|
|
|
|
$ligne = date('YmdHis').";$siren;MMap AVANT";
|
|
$fp = fopen(LOG_PATH.'/accesDistant.log', 'a');
|
|
fwrite($fp,$ligne.EOL);
|
|
fclose($fp);
|
|
|
|
$mMap = new MMap($adresse, $cp, $ville, $pays);
|
|
|
|
$ligne=date('YmdHis').";$siren;MMap APRES";
|
|
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
|
fwrite($fp,$ligne.EOL);
|
|
fclose($fp);
|
|
|
|
$geocode = new GeoCode();
|
|
$geocode->latitude = $mMap->latitudeDec;
|
|
$geocode->longitude = $mMap->longitudeDec;
|
|
$geocode->precis = $mMap->precision;
|
|
$geocode->adresseValidee = $mMap->adresseValidee;
|
|
$geocode->latitudeDeg = $mMap->latitudeDeg;
|
|
$geocode->longitudeDeg = $mMap->longitudeDeg;
|
|
|
|
$output = new GeoCodeReturn();
|
|
$output->error = $error;
|
|
$output->result = $geocode;
|
|
}
|
|
|
|
/** Retourne les informations identitaires de l'entreprise ou de l'établissement demandé
|
|
**
|
|
** @param integer $siret Siren de l'entreprise ou siret de l'établissement
|
|
** @param integer $id Identifiant S&D de l'établissement
|
|
** @return array Fiche d'identité de l'établissement
|
|
**/
|
|
protected function getIdentiteAGS($siret, $id=0, $forceVerif=false) {
|
|
debugLog('I',"Identité AGS demandé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è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é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é le 4 08 2009
|
|
'NumRC' =>$entrep['numRC'], // Ajouté 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é le 4 08 2009
|
|
'Siret' =>$entrep['Siret'],
|
|
'Sigle' =>prepareString($entrep['Sigle']),
|
|
'SigleLong' =>prepareString($entrep['sigleLong']), // Ajouté 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é 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é le 4 08 2009
|
|
'FJ2_Lib' =>prepareString($entrep['FJ2_Lib']), // Ajouté 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é le 18 02 2008
|
|
'CapitalType' =>prepareString($entrep['CapitalType']),// Ajouté le 4 08 2009
|
|
'DateCreaEt' =>$entrep['DateCreaEt'],
|
|
'DateCreaEn' =>$entrep['DateCreaEn'],
|
|
'DateClotEt' =>$entrep['DateClotEt'],
|
|
'DateImmat' =>$entrep['dateImmat'], // Ajouté le 4 08 2009
|
|
'DateRadiation' =>$entrep['dateRad'], // Ajouté le 4 08 2009
|
|
// 'DateMajRCS' =>$entrep['DateMajRCS'], // Ajouté 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é le 4 08 2009
|
|
'dir1LieuNaiss' =>prepareString($entrep['dir1LieuNaiss']),// Ajouté le 4 08 2009
|
|
'dir2Code' =>$entrep['dir2Code'],
|
|
'dir2Titre' =>prepareString($entrep['dir2Titre']),//utf8
|
|
'dir2NomPrenom' =>prepareString($entrep['dir2NomPrenom']),
|
|
'dir2DateFct' =>prepareString($entrep['dir2DateFct']),
|
|
'dir2DateNaiss' =>$entrep['dir2DateNaiss'],// Ajouté le 4 08 2009
|
|
'dir2LieuNaiss' =>prepareString($entrep['dir2LieuNaiss']),// Ajouté le 4 08 2009
|
|
'Rivoli' =>$entrep['Rivoli'],
|
|
'NatureActivite' =>$entrep['NatureActivite'], // Nature de l'activité
|
|
'OrigineCreation' =>$entrep['OrigineCreation'], // Origine de la création
|
|
'TypeExploitation' =>$entrep['TypeExploitation'],
|
|
'Auxiliaire' =>$entrep['Auxiliaire'], // 1=Auxiliaire / 0=Non auxiliaire
|
|
'Saisonnalite' =>$entrep['Saisonnalite'], // P=Activité permanente / S=Activité saisonniè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 éléments suivants
|
|
if ($tabEven['CodeEven']>=7000) continue;
|
|
if ($tabEven['CodeEven']>=4000 && $tabEven['CodeEven']<=4999) continue;
|
|
// Par défaut, on force le tribunal à celui présent dans la derniè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 élé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è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 à 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)) ;
|
|
if (preg_match('/NAF4/i', $this->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é = '. $entrep['Nom'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
wsLog('identite',$siret,$id);
|
|
return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>$tabRet);
|
|
}
|
|
|
|
protected function getIdentiteProcol($siret, $id=0, $forceVerif=false) {
|
|
return $this->getIdentiteAGS($siret, $id, $forceVerif);
|
|
}
|
|
}
|
|
|
|
?>
|