MRncs : getIdentiteEtab
This commit is contained in:
parent
794fdd3ede
commit
dab30b5827
@ -378,67 +378,75 @@ class Metier_Partenaires_MRncs
|
||||
*/
|
||||
public function getIdentiteEtab($siren, $nic=0)
|
||||
{
|
||||
$siren=$siren*1;
|
||||
$nic=$nic*1;
|
||||
if ($nic>0) {
|
||||
$strSql=" AND nic=$nic";
|
||||
$siren = $siren*1;
|
||||
$nic = $nic*1;
|
||||
if ($nic > 0) {
|
||||
$strSql = " AND nic=$nic";
|
||||
} else {
|
||||
$strSql=" AND siege=1 ORDER BY actif DESC, nic DESC";
|
||||
$strSql = " AND siege=1 ORDER BY actif DESC, nic DESC";
|
||||
}
|
||||
|
||||
$rep=$this->iDb->select('jo.rncs_etab', 'siren, nic, siege, actif, enseigne, nomCommercial, adrNumVoie, adrIndRep, adrLibVoie, adrTypeVoie, adrVoie, cp, commune, adrComp, adresse1, adresse2, adresse3, naf, dateFermeture, flux, DATE(dateUpdate) AS jourUpdate', "siren=$siren $strSql", false, MYSQL_ASSOC);
|
||||
if (count($rep)==0) {
|
||||
$sql = "SELECT siren, nic, siege, actif, enseigne, nomCommercial, adrNumVoie, adrIndRep,
|
||||
adrLibVoie, adrTypeVoie, adrVoie, cp, commune, adrComp, adresse1, adresse2, adresse3,
|
||||
naf, dateFermeture, flux, DATE(dateUpdate) AS jourUpdate
|
||||
FROM jo.rncs_etab WHERE siren=:siren $strSql";
|
||||
$stmt = $this->conn->prepare($sql);
|
||||
$stmt->bindValue('siren', $siren);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$entrep = $rep[0];
|
||||
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
|
||||
if ($entrep['jourUpdate']<>'0000-00-00') {
|
||||
$dateMaj=$entrep['jourUpdate'];
|
||||
if ($result['jourUpdate'] != '0000-00-00') {
|
||||
$dateMaj = $result['jourUpdate'];
|
||||
} else {
|
||||
$dateMaj=$entrep['flux'];
|
||||
$dateMaj = $result['flux'];
|
||||
}
|
||||
|
||||
if (trim($entrep['adresse1'])=='') {
|
||||
$adresse1=trim(preg_replace('/ +/', ' ', $entrep['adrNumVoie'].' '.strtoupper($entrep['adrIndRep']).' '. strtoupper($entrep['adrLibVoie'])));
|
||||
if (trim($result['adresse1'])=='') {
|
||||
$adresse1 = trim(preg_replace('/ +/', ' ', $result['adrNumVoie'].' '.
|
||||
strtoupper($result['adrIndRep']).' '. strtoupper($result['adrLibVoie'])));
|
||||
} else {
|
||||
$adresse1=trim(strtoupper($entrep['adresse1']));
|
||||
$adresse1 = trim(strtoupper($result['adresse1']));
|
||||
}
|
||||
if (trim($entrep['adresse2'])=='') {
|
||||
$adresse2=trim(strtoupper($entrep['adrComp']));
|
||||
if (trim($result['adresse2']) == '') {
|
||||
$adresse2 = trim(strtoupper($result['adrComp']));
|
||||
} else {
|
||||
$adresse2=trim(strtoupper($entrep['adresse2']));
|
||||
$adresse2 = trim(strtoupper($result['adresse2']));
|
||||
}
|
||||
if (trim($entrep['adresse3'])=='') {
|
||||
$adresse3='';
|
||||
if (trim($result['adresse3'])=='') {
|
||||
$adresse3 = '';
|
||||
} else {
|
||||
$adresse3=trim(strtoupper($entrep['adresse3']));
|
||||
$adresse3 = trim(strtoupper($result['adresse3']));
|
||||
}
|
||||
$tabIdentite=array(
|
||||
'siren' => $entrep['siren'],
|
||||
'nic' => $entrep['nic'],
|
||||
'siret' => $entrep['siren'].$entrep['nic'],
|
||||
'actif' => $entrep['actif'],
|
||||
'actifEt' => $entrep['actif'],
|
||||
'siege' => $entrep['siege'],
|
||||
'enseigne' => strtoupper($entrep['enseigne']),
|
||||
'nomCommercial' => strtoupper($entrep['nomCommercial']),
|
||||
'adrNumVoie' => $entrep['adrNumVoie'],
|
||||
'adrIndRep' => strtoupper($entrep['adrIndRep']),
|
||||
'adrLibVoie' => strtoupper($entrep['adrLibVoie']),
|
||||
'adrTypeVoie' => strtoupper($entrep['adrTypeVoie']),
|
||||
'adrVoie' => strtoupper($entrep['adrVoie']),
|
||||
'adrComp' => strtoupper($entrep['adrComp']),
|
||||
'cp' => strtoupper($entrep['cp']),
|
||||
'commune' => strtoupper($entrep['commune']),
|
||||
'adresse1' => $adresse1,
|
||||
'adresse2' => $adresse2,
|
||||
'adresse3' => $adresse3,
|
||||
'nafEtab' => $entrep['naf'],
|
||||
'nafEtabLib' => $this->getLibelleNaf($entrep['naf']),
|
||||
'dateFerEtab' => $entrep['dateFermeture'],
|
||||
'dateMajEtab' => $dateMaj,
|
||||
$tabIdentite = array(
|
||||
'siren' => $result['siren'],
|
||||
'nic' => $result['nic'],
|
||||
'siret' => $result['siren'].$result['nic'],
|
||||
'actif' => $result['actif'],
|
||||
'actifEt' => $result['actif'],
|
||||
'siege' => $result['siege'],
|
||||
'enseigne' => strtoupper($result['enseigne']),
|
||||
'nomCommercial' => strtoupper($result['nomCommercial']),
|
||||
'adrNumVoie' => $result['adrNumVoie'],
|
||||
'adrIndRep' => strtoupper($result['adrIndRep']),
|
||||
'adrLibVoie' => strtoupper($result['adrLibVoie']),
|
||||
'adrTypeVoie' => strtoupper($result['adrTypeVoie']),
|
||||
'adrVoie' => strtoupper($result['adrVoie']),
|
||||
'adrComp' => strtoupper($result['adrComp']),
|
||||
'cp' => strtoupper($result['cp']),
|
||||
'commune' => strtoupper($result['commune']),
|
||||
'adresse1' => $adresse1,
|
||||
'adresse2' => $adresse2,
|
||||
'adresse3' => $adresse3,
|
||||
'nafEtab' => $result['naf'],
|
||||
'nafEtabLib' => $this->getLibelleNaf($result['naf']),
|
||||
'dateFerEtab' => $result['dateFermeture'],
|
||||
'dateMajEtab' => $dateMaj,
|
||||
);
|
||||
|
||||
return array_merge($tabIdentite, $this->getInfosEntrep($siren));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user