diff --git a/library/Metier/Insee/MInsee.php b/library/Metier/Insee/MInsee.php index a8602570..440a91b6 100644 --- a/library/Metier/Insee/MInsee.php +++ b/library/Metier/Insee/MInsee.php @@ -3694,9 +3694,6 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $tabJugements = array(); foreach ($annoncesList as $i => $ann) { $date = str_replace('-','', $ann['dateJugement']); - if (intval($date) == 0) { - $date = str_replace('-','', $ann['dateEffet']); - } if (intval($date) == 0) { $date = str_replace('-','', $ann['dateParution']); } @@ -3709,7 +3706,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $annFormat = new stdClass(); $date = str_replace('-', '', $ann['dateJugement']); if (intval($date) == 0) { - $date = str_replace('-', '', $ann['dateEffet']); + $date = str_replace('-','', $ann['dateParution']); } $annFormat->date = $date; $annFormat->code = $ann['evenements'][0]['CodeEven']; diff --git a/library/Metier/Insee/MInsee.php.defaillance b/library/Metier/Insee/MInsee.php.defaillance index 2bd12916..68d98b37 100644 --- a/library/Metier/Insee/MInsee.php.defaillance +++ b/library/Metier/Insee/MInsee.php.defaillance @@ -555,20 +555,20 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } } - $sql = "SELECT id, LPAD(insSIREN,9,0) as insSIREN, siretValide, LPAD(insNIC,5,0) as insNIC, - insLIBCOM, insSIEGE, insAUXILT, insORIGINE, insTEFET, insAPET700, insAPRM, insMODET, - insMARCHET, insSAISONAT, insACTIVNAT, insENSEIGNE, insL1_NOMEN, insL2_COMP, insL4_VOIE, - insL3_CADR, insNUMVOIE, insINDREP, insTYPVOIE, insLIBVOIE, insL5_DISP, insL6_POST, - insCODPOS, insL7_ETRG, insRPET, insDEPCOM, insCODEVOIE, insDREACTET, insEXPLET, insDAPET, - insLIEUACT, insACTISURF, insDEFET, insTEL, insCJ, insCIVILITE, insTEFEN, insAPEN700, - insMODEN, insMARCHEN, insNOMEN, insTYPCREH, insEVE, insDATEVE, insTRAN, insNICTRAN, - insMNICSIEGE, insMNOMEN, insMCJ, insMAPEN, insFiller1, insFiller2, insMMARCHEN, - insMORDIN, insEFENCENT, insSIGLE, insNBETEXPL, insNICSIEGE, insDEPCOMEN, - insFiller3, insMENSEIGNE, insMAPET, insMNATURE, insMADRESSE, insMEFET, insMSINGT, - insMTELT, insMMARCHET, insMAUXILT, insSINGT, insEFETCENT, insSIRETPS, insDESTINAT, - insDATEMAJ, idFlux, dirNom, dirNomUsage, dirPrenom, insDCRET, insDCREN, insPRODPART, - insSIRETASS, insDREACTEN, insEXPLEN, insFiller4, insDEFEN, insMONOREG, insREGIMP, - insMONOACT, insMSIGLE, insMEXPLEN, insRPEN, insMEXPLET, insTYPETAB, insDAPEN + $sql = "SELECT id, LPAD(insSIREN,9,0) as insSIREN, siretValide, LPAD(insNIC,5,0) as insNIC, + insLIBCOM, insSIEGE, insAUXILT, insORIGINE, insTEFET, insAPET700, insAPRM, insMODET, + insMARCHET, insSAISONAT, insACTIVNAT, insENSEIGNE, insL1_NOMEN, insL2_COMP, insL4_VOIE, + insL3_CADR, insNUMVOIE, insINDREP, insTYPVOIE, insLIBVOIE, insL5_DISP, insL6_POST, + insCODPOS, insL7_ETRG, insRPET, insDEPCOM, insCODEVOIE, insDREACTET, insEXPLET, insDAPET, + insLIEUACT, insACTISURF, insDEFET, insTEL, insCJ, insCIVILITE, insTEFEN, insAPEN700, + insMODEN, insMARCHEN, insNOMEN, insTYPCREH, insEVE, insDATEVE, insTRAN, insNICTRAN, + insMNICSIEGE, insMNOMEN, insMCJ, insMAPEN, insFiller1, insFiller2, insMMARCHEN, + insMORDIN, insEFENCENT, insSIGLE, insNBETEXPL, insNICSIEGE, insDEPCOMEN, + insFiller3, insMENSEIGNE, insMAPET, insMNATURE, insMADRESSE, insMEFET, insMSINGT, + insMTELT, insMMARCHET, insMAUXILT, insSINGT, insEFETCENT, insSIRETPS, insDESTINAT, + insDATEMAJ, idFlux, dirNom, dirNomUsage, dirPrenom, insDCRET, insDCREN, insPRODPART, + insSIRETASS, insDREACTEN, insEXPLEN, insFiller4, insDEFEN, insMONOREG, insREGIMP, + insMONOACT, insMSIGLE, insMEXPLEN, insRPEN, insMEXPLET, insTYPETAB, insDAPEN FROM insee.insee_even WHERE $sqlIdentifiant ORDER BY insDATEMAJ DESC LIMIT $iDeb, $iMax"; try { @@ -829,9 +829,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Recherche d'évènement pour lesquels le SIREN est ASSOCIE try { - $stmt = $this->conn->executeQuery("SELECT id FROM insee.insee_even - WHERE insSIREN != $siren AND insSIRETASS BETWEEN $siretDeb AND $siretFin - GROUP BY insSIREN, ROUND(insSIRETASS/100000) ORDER BY insDATEMAJ DESC"); + $stmt = $this->conn->executeQuery("SELECT id FROM insee.insee_even + WHERE insSIREN != $siren AND insSIRETASS BETWEEN $siretDeb AND $siretFin + GROUP BY insSIREN, ROUND(insSIRETASS/100000) ORDER BY insDATEMAJ DESC"); if ($stmt->rowCount() > 0) { while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) { $tabSupId[] = $row->id; @@ -845,8 +845,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Recherche d'évènement pour lesquels le SIREN est Prédécesseur ou Successeur try { - $stmt = $this->conn->executeQuery("SELECT id FROM insee.insee_even - WHERE insSIREN != $siren AND insSIRETASS BETWEEN $siretDeb AND $siretFin + $stmt = $this->conn->executeQuery("SELECT id FROM insee.insee_even + WHERE insSIREN != $siren AND insSIRETASS BETWEEN $siretDeb AND $siretFin GROUP BY insSIREN, ROUND(insSIRETPS/100000) ORDER BY insDATEMAJ DESC"); if ($stmt->rowCount() > 0) { while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) { @@ -944,12 +944,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table * [num] => 33 * [typeVoie] => R * [libVoie] => Louis Blanc - * [cp] => ... - * [ville] => ... Si contenu dans l'adresse + * [cp] => ... + * [ville] => ... Si contenu dans l'adresse * ) * - * @param string $strLigneDAdresse La ligne d'adresse textuelle (ex : Maison des associations, 33 rue Louis Blanc - * @return array tableau contenant l'adresse structurée ici + * @param string $strLigneDAdresse La ligne d'adresse textuelle (ex : Maison des associations, 33 rue Louis Blanc + * @return array tableau contenant l'adresse structurée ici */ public function structureVoie($strLigneDAdresse) { @@ -1045,13 +1045,13 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $strInfo = ''; - $fields = "'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, - LPAD(e.siren, 9, 0) AS siren, LPAD(e.nic, 5, 0) AS nic, e.siege, e.raisonSociale, - e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, - e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, e.adr_dep, LPAD(e.adr_com,3,0) AS adr_com, - LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, - CONCAT(e.siren, e.nic) AS siret, e.actif, e.identite_pre, IF(e.siege=2,0.5,e.siege) AS triSiege, - IF (e.adr_dep=99, (SELECT libPays FROM jo.tabPays p WHERE p.codePaysInsee=e.adr_com LIMIT 0,1) , 'France') AS libPays"; + $fields = "'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, + LPAD(e.siren, 9, 0) AS siren, LPAD(e.nic, 5, 0) AS nic, e.siege, e.raisonSociale, + e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, + e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, e.adr_dep, LPAD(e.adr_com,3,0) AS adr_com, + LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, + CONCAT(e.siren, e.nic) AS siret, e.actif, e.identite_pre, IF(e.siege=2,0.5,e.siege) AS triSiege, + IF (e.adr_dep=99, (SELECT libPays FROM jo.tabPays p WHERE p.codePaysInsee=e.adr_com LIMIT 0,1) , 'France') AS libPays"; $strActif = $strDep = ''; if (intval($actif) == 1) { @@ -1121,8 +1121,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $strSiren = implode(',', $listeSiren); try { - $stmt = $this->conn->executeQuery("SELECT count(*) AS nb FROM jo.etablissements - WHERE siren IN ($strSiren) AND siege=1"); + $stmt = $this->conn->executeQuery("SELECT count(*) AS nb FROM jo.etablissements + WHERE siren IN ($strSiren) AND siege=1"); $result = $stmt->fetch(\PDO::FETCH_OBJ); $nbTot = $result->nb; } catch (\Doctrine\DBAL\DBALException $e) { @@ -1131,13 +1131,13 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } } $sql = "SELECT $fields FROM jo.etablissements e - WHERE siren IN ($strSiren) AND siege=1 - ORDER BY e.rang DESC, e.actif DESC, e.nic ASC $sqlLimit"; + WHERE siren IN ($strSiren) AND siege=1 + ORDER BY e.rang DESC, e.actif DESC, e.nic ASC $sqlLimit"; $strInfo = 'Siren saisi invalide'; } } else { - $sql = "SELECT $fields FROM jo.etablissements e - WHERE $sqlWhere $sqlOrder $sqlLimit"; + $sql = "SELECT $fields FROM jo.etablissements e + WHERE $sqlWhere $sqlOrder $sqlLimit"; } try { @@ -1247,18 +1247,18 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $filtreActif = " AND WHERE actif=$actif"; } - $fields = "'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, - LPAD(e.siren, 9, 0) AS siren, LPAD(e.nic, 5, 0) AS nic, e.siege, e.raisonSociale, - e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, - e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, e.adr_dep, LPAD(e.adr_com,3,0) AS adr_com, - LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, - CONCAT(e.siren, e.nic) AS siret, e.actif, - IF (e.adr_dep=99, (SELECT libPays FROM jo.tabPays p WHERE p.codePaysInsee=e.adr_com) , 'France') AS libPays"; + $fields = "'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, + LPAD(e.siren, 9, 0) AS siren, LPAD(e.nic, 5, 0) AS nic, e.siege, e.raisonSociale, + e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, + e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, e.adr_dep, LPAD(e.adr_com,3,0) AS adr_com, + LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, + CONCAT(e.siren, e.nic) AS siret, e.actif, + IF (e.adr_dep=99, (SELECT libPays FROM jo.tabPays p WHERE p.codePaysInsee=e.adr_com) , 'France') AS libPays"; if ($typeId == 'TEL') { Metier_Util_Log::write('I', "Recherche par TEL de $id avec un maximum de $nbRep réponses", __LINE__, __FILE__, __FUNCTION__, __CLASS__); try { - $stmt = $this->conn->executeQuery("SELECT count(*) AS nb FROM jo.etablissements + $stmt = $this->conn->executeQuery("SELECT count(*) AS nb FROM jo.etablissements WHERE TEL=$id OR FAX=$id $filtreActif"); $result = $stmt->fetch(\PDO::FETCH_OBJ); $nbTot = $result->nb; @@ -1269,9 +1269,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } try { - $stmt = $this->conn->executeQuery("SELECT $fields FROM jo.etablissements e - WHERE TEL=$id OR FAX=$id $filtreActif - ORDER BY e.siege DESC, e.actif DESC $limit"); + $stmt = $this->conn->executeQuery("SELECT $fields FROM jo.etablissements e + WHERE TEL=$id OR FAX=$id $filtreActif + ORDER BY e.siege DESC, e.actif DESC $limit"); } catch (\Doctrine\DBAL\DBALException $e) { if ($this->logger !== null) { $this->logger->error($e->getMessage()); @@ -1314,8 +1314,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } try { - $stmt = $this->conn->executeQuery("SELECT count(*) AS nb FROM jo.etablissements - WHERE autre_id IN ('$strId') $filtreActif $strDep"); + $stmt = $this->conn->executeQuery("SELECT count(*) AS nb FROM jo.etablissements + WHERE autre_id IN ('$strId') $filtreActif $strDep"); $result = $stmt->fetch(\PDO::FETCH_OBJ); $nbTot = $result->nb; } catch (\Doctrine\DBAL\DBALException $e) { @@ -1325,8 +1325,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } try { - $stmt = $this->conn->executeQuery("SELECT $fields FROM jo.etablissements e - WHERE autre_id IN ('$strId') $filtreActif $strDep + $stmt = $this->conn->executeQuery("SELECT $fields FROM jo.etablissements e + WHERE autre_id IN ('$strId') $filtreActif $strDep ORDER BY siege DESC $limit"); } catch (\Doctrine\DBAL\DBALException $e) { if ($this->logger !== null) { @@ -1433,15 +1433,15 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $tabRet = array(); try { - $stmt = $this->conn->executeQuery("SELECT e.id, e.source, e.source_id, e.autre_id, - LPAD(e.siren, 9, 0) as siren, LPAD(e.nic, 5, 0) as nic, e.siege, e.autre_id, e.triCode, - e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, - e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, LPAD(e.tel,10,0) AS tel, - LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, e.adr_dep, - LPAD(e.adr_com,3,0) AS adr_com, e.capital, e.capitalDev, e.capitalSrc, e.tca, - e.teff_entrep, e.teff_etab, CONCAT(LPAD(e.siren,9,0), LPAD(e.nic,5,0)) as siret, - e.actif, e.identite_pre FROM jo.etablissements e - WHERE $where ORDER BY siege DESC, actif DESC, nic DESC $limit"); + $stmt = $this->conn->executeQuery("SELECT e.id, e.source, e.source_id, e.autre_id, + LPAD(e.siren, 9, 0) as siren, LPAD(e.nic, 5, 0) as nic, e.siege, e.autre_id, e.triCode, + e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, + e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, LPAD(e.tel,10,0) AS tel, + LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, e.adr_dep, + LPAD(e.adr_com,3,0) AS adr_com, e.capital, e.capitalDev, e.capitalSrc, e.tca, + e.teff_entrep, e.teff_etab, CONCAT(LPAD(e.siren,9,0), LPAD(e.nic,5,0)) as siret, + e.actif, e.identite_pre FROM jo.etablissements e + WHERE $where ORDER BY siege DESC, actif DESC, nic DESC $limit"); } catch (\Doctrine\DBAL\DBALException $e) { if ($this->logger !== null) { $this->logger->error($e->getMessage()); @@ -1507,7 +1507,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table /** * Retourne la liste des devise * - * @param string $codeDevise Code ISO devise + * @param string $codeDevise Code ISO devise * @return Devise ou liste des devises (si pas de code ISO en entrée) */ public function getDevises($codeIso = '') @@ -1966,12 +1966,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $where = " siren=$siren "; } try { - $stmt = $this->conn->executeQuery("SELECT e.id, e.source, e.source_id, e.triCode, e.autre_id, LPAD(e.siren,9,0) as siren, LPAD(e.nic,5,0) as nic, e.siege, e.autre_id, - e.raisonSociale, e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, - e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, - e.capital, e.capitalDev, e.capitalSrc, CONCAT(e.siren, e.nic) as siret, e.actif, - e.age_entrep, e.age_etab, e.tca, e.tcaexp, e.teff_entrep, e.teff_etab FROM jo.etablissements e - WHERE $where ORDER BY siege DESC, actif DESC, nic DESC $limit"); + $stmt = $this->conn->executeQuery("SELECT e.id, e.source, e.source_id, e.triCode, e.autre_id, LPAD(e.siren,9,0) as siren, LPAD(e.nic,5,0) as nic, e.siege, e.autre_id, + e.raisonSociale, e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, + e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, + e.capital, e.capitalDev, e.capitalSrc, CONCAT(e.siren, e.nic) as siret, e.actif, + e.age_entrep, e.age_etab, e.tca, e.tcaexp, e.teff_entrep, e.teff_etab FROM jo.etablissements e + WHERE $where ORDER BY siege DESC, actif DESC, nic DESC $limit"); $nbEtab = $stmt->rowCount(); } catch (\Doctrine\DBAL\DBALException $e) { if ($this->logger !== null) { @@ -2034,9 +2034,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Informations locales issues de la table infos_entrep if ($siren > 100) { try { - $stmt = $this->conn->executeQuery("SELECT raisonSociale, isin, nscrl, tel, fax, web, mail, - latitude, longitude, precis, dateCreation, dateFermeture, naf, naf_lib, ca, effectif, - nbEtab, activite, LPAD(sirenDoublon,9,'0') AS sirenDoublon, waldec FROM jo.infos_entrep WHERE siren=$siren"); + $stmt = $this->conn->executeQuery("SELECT raisonSociale, isin, nscrl, tel, fax, web, mail, + latitude, longitude, precis, dateCreation, dateFermeture, naf, naf_lib, ca, effectif, + nbEtab, activite, LPAD(sirenDoublon,9,'0') AS sirenDoublon, waldec FROM jo.infos_entrep WHERE siren=$siren"); if ($stmt->rowCount() > 0) { $tab = $stmt->fetch(\PDO::FETCH_ASSOC); $waldec = $tab['waldec']; @@ -2055,9 +2055,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } try { - $stmt = $this->conn->executeQuery("SELECT CONCAT(LPAD(SIREN,9,0), LPAD(NIC,5,0)) AS siret - FROM jo.etablissements - WHERE SIREN=$siren AND SIEGE=1 ORDER BY ACTIF%10 DESC, NIC DESC"); + $stmt = $this->conn->executeQuery("SELECT CONCAT(LPAD(SIREN,9,0), LPAD(NIC,5,0)) AS siret + FROM jo.etablissements + WHERE SIREN=$siren AND SIEGE=1 ORDER BY ACTIF%10 DESC, NIC DESC"); if ($stmt->rowCount() > 0) { $result = $stmt->fetch(\PDO::FETCH_OBJ); $siretSiege = $result->siret; @@ -2080,20 +2080,20 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $strNic = "AND NIC<100000 AND SIEGE=1"; } try { - $stmt = $this->conn->executeQuery("SELECT ACTIF%10 AS ACTIF, actifEco%10 AS actifEco, - NOM, NOM2, SIGLE, ENSEIGNE, ADR_NUMVOIE, ADR_BTQ, ADR_TYPVOIE, ADR_LIBVOIE, - ADR_LIBCOM, ADR_CP, ADR_COMP, ADR_DISTSP, PAYS, TRIM(LEADING '0' FROM DCREN) AS DCREN, - SIEGE, AUXILT, SAISONAT, CJ, CIVILITE, NBETAB, APE_ENT, APE_ETAB, PROCOL, PROCOL_TYPE, - PROCOL_DATE, CAPITAL, EFF_ENT, NUMRC, TEL, FAX, DIR_FCT, DIR_IDEN, DIR_DATEN, - DIR_LIEUN, CAPITAL_DATE, CAPITAL_DEV, TRIM(LEADING '0' FROM DCRET) AS DCRET, - TEFF_ENT, ADR_DEP, LPAD(ADR_COM,3,0) AS ADR_COM, TCA, TCAEXP, EFF_ET, TEFF_ET, - CODEVOIE, DATE_MAJ, APRM, ACTIVNAT, ORIGINE, MODET, EXPLET, LIEUACT, ACTISURF, DEFET, - MODEN, PRODPART, EXPLEN, MONOREG, REGIMP, MONOACT, DEFEN, DEFET, IDENTITE_PRE, - insL1_NOMEN, insL2_COMP, insL3_CADR, insL4_VOIE, insL5_DISP, insL6_POST, insL7_ETRG, - dateMajRNVP, insCATEGORIE, insIND_PUBLIPO, RPET, ARRONET, CTONET, DU, TU, UU, TCD, - ZEMET, ESAANN, ESAAPEN, DREACTET, AMINTRET, DREACTEN, AMINTREN, NOMEN_LONG, CEDEX, - EPCI, NOM_COM, NATETAB, PRODET, PRODEN, hexavia - FROM insee.identite WHERE SIREN=$siren $strNic ORDER BY SIEGE DESC, ACTIF DESC LIMIT 0,1"); + $stmt = $this->conn->executeQuery("SELECT ACTIF%10 AS ACTIF, actifEco%10 AS actifEco, + NOM, NOM2, SIGLE, ENSEIGNE, ADR_NUMVOIE, ADR_BTQ, ADR_TYPVOIE, ADR_LIBVOIE, + ADR_LIBCOM, ADR_CP, ADR_COMP, ADR_DISTSP, PAYS, TRIM(LEADING '0' FROM DCREN) AS DCREN, + SIEGE, AUXILT, SAISONAT, CJ, CIVILITE, NBETAB, APE_ENT, APE_ETAB, PROCOL, PROCOL_TYPE, + PROCOL_DATE, CAPITAL, EFF_ENT, NUMRC, TEL, FAX, DIR_FCT, DIR_IDEN, DIR_DATEN, + DIR_LIEUN, CAPITAL_DATE, CAPITAL_DEV, TRIM(LEADING '0' FROM DCRET) AS DCRET, + TEFF_ENT, ADR_DEP, LPAD(ADR_COM,3,0) AS ADR_COM, TCA, TCAEXP, EFF_ET, TEFF_ET, + CODEVOIE, DATE_MAJ, APRM, ACTIVNAT, ORIGINE, MODET, EXPLET, LIEUACT, ACTISURF, DEFET, + MODEN, PRODPART, EXPLEN, MONOREG, REGIMP, MONOACT, DEFEN, DEFET, IDENTITE_PRE, + insL1_NOMEN, insL2_COMP, insL3_CADR, insL4_VOIE, insL5_DISP, insL6_POST, insL7_ETRG, + dateMajRNVP, insCATEGORIE, insIND_PUBLIPO, RPET, ARRONET, CTONET, DU, TU, UU, TCD, + ZEMET, ESAANN, ESAAPEN, DREACTET, AMINTRET, DREACTEN, AMINTREN, NOMEN_LONG, CEDEX, + EPCI, NOM_COM, NATETAB, PRODET, PRODEN, hexavia + FROM insee.identite WHERE SIREN=$siren $strNic ORDER BY SIEGE DESC, ACTIF DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $tabInsee = $stmt->fetch(\PDO::FETCH_ASSOC); $tabNotice = $this->getInfosNotice($siren, $nic); @@ -2143,8 +2143,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Nombre d'etablissements $nbEtab = 0; try { - $stmt = $this->conn->executeQuery("SELECT count(*) AS nbEtabs FROM jo.etablissements - WHERE siren=$siren AND NIC<100000 AND ACTIF%10=1"); + $stmt = $this->conn->executeQuery("SELECT count(*) AS nbEtabs FROM jo.etablissements + WHERE siren=$siren AND NIC<100000 AND ACTIF%10=1"); if ($stmt->rowCount() > 0) { $result = $stmt->fetch(\PDO::FETCH_OBJ); $nbEtab = $result->nbEtabs; @@ -2156,8 +2156,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } try { - $stmt = $this->conn->executeQuery("SELECT mois FROM insee.insee_nondiff - WHERE siren=$siren"); + $stmt = $this->conn->executeQuery("SELECT mois FROM insee.insee_nondiff + WHERE siren=$siren"); if ($stmt->rowCount() > 0) { $result = $stmt->fetch(\PDO::FETCH_OBJ); $moisNonDiff = $result->mois; @@ -2347,12 +2347,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table '7'=>'Partage', '8'=>'Reprise', - '9'=>'Autre modalité d\'acquisition', - 'A'=>'Reprise globale d\'une exploitation agricole', - 'B'=>'Poursuite de l\'exploitation agricole par le conjoint', - 'C'=>'Transfert de propriété d\'une exploitation agricole', - 'D'=>'Apport d\'exploitation(s) agricole(s) individuelle(s)', - 'E'=>'Reprise totale ou partielle d\'exploitation individuelle', + '9'=>'Autre modalité d\'acquisition', + 'A'=>'Reprise globale d\'une exploitation agricole', + 'B'=>'Poursuite de l\'exploitation agricole par le conjoint', + 'C'=>'Transfert de propriété d\'une exploitation agricole', + 'D'=>'Apport d\'exploitation(s) agricole(s) individuelle(s)', + 'E'=>'Reprise totale ou partielle d\'exploitation individuelle', */ $typeExploitation = 10; } elseif ($nbEtab < 2) { @@ -2400,10 +2400,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($tabInsee['ADR_DEP'] > 98) { $codePaysInsee = $tabInsee['ADR_COM']; try { - $stmt = $this->conn->executeQuery("SELECT j.codPays, j.numPays, j.codPays3, j.codePaysInpi, - j.libPays, i.LIBCOG, i.ACTUAL FROM jo.tabPays j, insee.insee_tabPays i - WHERE j.codePaysInsee=$codePaysInsee AND j.codePaysInsee=substring( i.COG, 3, 3 ) - AND i.ACTUAL IN (1,4) AND j.numPays is NOT NULL"); + $stmt = $this->conn->executeQuery("SELECT j.codPays, j.numPays, j.codPays3, j.codePaysInpi, + j.libPays, i.LIBCOG, i.ACTUAL FROM jo.tabPays j, insee.insee_tabPays i + WHERE j.codePaysInsee=$codePaysInsee AND j.codePaysInsee=substring( i.COG, 3, 3 ) + AND i.ACTUAL IN (1,4) AND j.numPays is NOT NULL"); if ($stmt->rowCount() == 1) { $result = $stmt->fetch(\PDO::FETCH_OBJ); $codePaysIso2 = $result->codPays; @@ -2456,8 +2456,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if (intval($siren) > 100 && $tabInsee['ACTIF']*1 == 1 && $tabInsee['actifEco']*1 == 0) { // L'établissement est actif juridiquement à l'INSEE mais sans activité économique - $stmt = $this->conn->executeQuery("SELECT insEVE, IF(insDATEVE=0, idFlux*1, insDATEVE) AS insDATEVE - FROM insee.insee_even WHERE insSIREN=$siren AND insNIC=$nic + $stmt = $this->conn->executeQuery("SELECT insEVE, IF(insDATEVE=0, idFlux*1, insDATEVE) AS insDATEVE + FROM insee.insee_even WHERE insSIREN=$siren AND insNIC=$nic AND insEVE IN ('OD','TD','MPF','MNP','420','425','620','621','650') ORDER BY insDATEVE DESC"); if ($stmt->rowCount() > 0) { $tabModif = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -2465,7 +2465,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table case 'OD': case 'TD': case '420': // Absence d'activité de l'entreprise (cessation économique de l.entreprise) - case '425': // Absence d'activité d'une entreprise suite à une mise à jour au répertoire // + case '425': // Absence d'activité d'une entreprise suite à une mise à jour au répertoire // case '620': case '621': case '650': // Fermé économiquement @@ -2669,8 +2669,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table ); if (in_array($tabInsee['APE_ENT'], $tabNafTourisme) || in_array($tabInsee['APE_ETAB'], $tabNafTourisme)) { - $stmt = $this->conn->executeQuery("SELECT id, nom, adresse, adrCp, adrVille, - nbEtoiles, typeClasse, categorie, dateClasse, tel, fax, mail, web, + $stmt = $this->conn->executeQuery("SELECT id, nom, adresse, adrCp, adrVille, + nbEtoiles, typeClasse, categorie, dateClasse, tel, fax, mail, web, typeChambres, capacite FROM jo.tourisme WHERE siren=$siren AND nic=$nic"); if ($stmt->rowCount() > 0) { $result = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -2695,8 +2695,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Nombre d'actions du capital si disponible if ($etab['capital'] > 0) { try { - $stmt = $this->conn->executeQuery("SELECT capital, deviseCapital, nbActions, actionNominale, dateInfo - FROM sdv1.capitalActions WHERE siren=$siren AND capital>0 ORDER BY dateInfo DESC LIMIT 0,1"); + $stmt = $this->conn->executeQuery("SELECT capital, deviseCapital, nbActions, actionNominale, dateInfo + FROM sdv1.capitalActions WHERE siren=$siren AND capital>0 ORDER BY dateInfo DESC LIMIT 0,1"); $tabRet['CapitalNbActions'] = 0; $tabRet['CapitalMtActions'] = 0; if ($stmt->rowCount() > 0) { @@ -2804,7 +2804,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if (intval($siren) > 0) { if ($tabInsee['CIVILITE']>0 && ($tabRet['dir1Nom']=='' || $tabRet['dir1Prenom'])) { - $stmt = $this->conn->executeQuery("SELECT dirNom, dirNomUsage, dirPrenom, insCIVILITE + $stmt = $this->conn->executeQuery("SELECT dirNom, dirNomUsage, dirPrenom, insCIVILITE FROM insee.insee_even WHERE insSIREN=$siren ORDER BY insDATEVE DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $dir = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -2853,9 +2853,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($tabRet['CapitalSrc'] != 5) { // Recherche du n° RC, de la Forme Juridique et du Capital au Bodacc try { - $stmt = $this->conn->executeQuery("SELECT Capital, CapitalDev FROM jo.bodacc_detail - WHERE siren=$siren AND capital != 0 $strEvenVtLg - ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1"); + $stmt = $this->conn->executeQuery("SELECT Capital, CapitalDev FROM jo.bodacc_detail + WHERE siren=$siren AND capital != 0 $strEvenVtLg + ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $annCap = $stmt->fetch(\PDO::FETCH_ASSOC); if ($tabRet['Capital']==0 || $tabRet['CapitalDev']=='' || $tabRet['Capital'] != $annCap['Capital']*1) { @@ -2874,10 +2874,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($tabRet['Capital']==0 || $tabRet['CapitalDev']=='') { try { - $stmt = $this->conn->executeQuery("SELECT e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, - e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, - e.E1GNIC, x.annonceNum, x.annonceTxt FROM historiques.entrep e, historiques.texte x - WHERE e.E1GSIR=$siren AND e.ANBASE=x.annonceNum AND e.DATE BETWEEN 19890101 AND 20041231 + $stmt = $this->conn->executeQuery("SELECT e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, + e.DATE, e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, + e.E1GNIC, x.annonceNum, x.annonceTxt FROM historiques.entrep e, historiques.texte x + WHERE e.E1GSIR=$siren AND e.ANBASE=x.annonceNum AND e.DATE BETWEEN 19890101 AND 20041231 AND x.annonceTxt LIKE '%capital%' GROUP BY e.ANBASE ORDER BY e.DATE DESC"); if ($stmt->rowCount() > 0) { while ($ann = $stmt->fetch(\PDO::FETCH_ASSOC)) { @@ -2912,8 +2912,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($tabRet['CapitalDev'] != '' && $tabRet['CapitalDev'] != 'EUR') { $dev = $tabRet['CapitalDev']; try { - $stmt = $this->conn->executeQuery("SELECT c.devise, c.valeur, c.date, l.devNom, - l.devNomPays, l.devPaysIso FROM sdv1.devise_liste l, sdv1.devise_cours c + $stmt = $this->conn->executeQuery("SELECT c.devise, c.valeur, c.date, l.devNom, + l.devNomPays, l.devPaysIso FROM sdv1.devise_liste l, sdv1.devise_cours c WHERE c.devise='$dev' and l.devIso='$dev' ORDER BY c.date DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $dev = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -2931,7 +2931,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Recherche du code Tribunal du siège if ($tabRet['CapitalSrc'] != 5) { try { - $stmt = $this->conn->executeQuery("SELECT RC, FJ, Tribunal_Code FROM jo.bodacc_detail + $stmt = $this->conn->executeQuery("SELECT RC, FJ, Tribunal_Code FROM jo.bodacc_detail WHERE siren=$siren AND RC != '' $strEvenVtLg ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $bodacc = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -2951,8 +2951,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($tabRet['FJ_lib'] == '') { try { - $stmt = $this->conn->executeQuery("SELECT FJ FROM jo.bodacc_detail - WHERE siren=$siren AND FJ != '' $strEvenVtLg ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1"); + $stmt = $this->conn->executeQuery("SELECT FJ FROM jo.bodacc_detail + WHERE siren=$siren AND FJ != '' $strEvenVtLg ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $result = $stmt->fetch(\PDO::FETCH_OBJ); $tabRet['FJ_lib'] = $result->FJ; @@ -2966,9 +2966,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Recherche de l'activité réelle try { - $stmt = $this->conn->executeQuery("SELECT Activite FROM jo. - bodacc_detail WHERE siren=$siren AND Activite != '' - AND Activite NOT LIKE 'non precis%' $strEvenVtLg + $stmt = $this->conn->executeQuery("SELECT Activite FROM jo. + bodacc_detail WHERE siren=$siren AND Activite != '' + AND Activite NOT LIKE 'non precis%' $strEvenVtLg ORDER BY Bodacc_Date_Parution DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $annCap = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -2988,10 +2988,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table && ($tabInsee['CJ']>90 && $tabInsee['CJ']<94 || $tabInsee['CJ']>9000 && $tabInsee['CJ']<9400)) { try { - $stmt = $this->conn->executeQuery("SELECT Assoc_Web, Assoc_Mail, Assoc_Objet, - Assoc_NObjet, Assoc_Nom, typeAsso, Waldec FROM jo.asso WHERE siren=$siren - AND dateSuppr=0 AND (Assoc_Objet != '' OR Assoc_NObjet != '') - ORDER BY Date_Parution DESC LIMIT 0,1"); + $stmt = $this->conn->executeQuery("SELECT Assoc_Web, Assoc_Mail, Assoc_Objet, + Assoc_NObjet, Assoc_Nom, typeAsso, Waldec FROM jo.asso WHERE siren=$siren + AND dateSuppr=0 AND (Assoc_Objet != '' OR Assoc_NObjet != '') + ORDER BY Date_Parution DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $annCap = $stmt->fetch(\PDO::FETCH_ASSOC); $tabRet['Activite'] = trim($annCap['Assoc_NObjet']); @@ -3027,12 +3027,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } } elseif ($tabRet['Activite']=='' && ($tabInsee['CJ']<7000 || $tabInsee['CJ']>7999)) { try { - $stmt = $this->conn->executeQuery("SELECT e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, - e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, - x.annonceNum, x.annonceTxt FROM historiques.entrep e, historiques.texte x - WHERE e.E1GSIR=$siren AND e.ANBASE=x.annonceNum AND e.DATE BETWEEN 19890101 AND 20041231 - AND x.annonceTxt LIKE '%ctivit%' - GROUP BY e.ANBASE ORDER BY e.DATE DESC"); + $stmt = $this->conn->executeQuery("SELECT e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, + e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, + x.annonceNum, x.annonceTxt FROM historiques.entrep e, historiques.texte x + WHERE e.E1GSIR=$siren AND e.ANBASE=x.annonceNum AND e.DATE BETWEEN 19890101 AND 20041231 + AND x.annonceTxt LIKE '%ctivit%' + GROUP BY e.ANBASE ORDER BY e.DATE DESC"); if ($stmt->rowCount() > 0) { while ($ann = $stmt->fetch(\PDO::FETCH_ASSOC)) { if ($ann['DATE']<19960101 && $ann['E1GSIR'] != $ann['SIREN']) { @@ -3061,19 +3061,19 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } $timer['activiteReelle']=microtime(true); - $stmt = $this->conn->executeQuery("SELECT nom, prenom, naissance_nom, civilite, - fonction_code as code, fonction_lib as libelle, naissance_date AS dateNaiss, - naissance_lieu AS lieuNaiss, dirRS as rs, '' as dateEffet - FROM jo.rncs_dirigeants - WHERE siren=$siren AND actif%10=1 AND fonction_lib NOT LIKE '%Administrateur%' - ORDER BY actif DESC, fonction_lib DESC"); + $stmt = $this->conn->executeQuery("SELECT nom, prenom, naissance_nom, civilite, + fonction_code as code, fonction_lib as libelle, naissance_date AS dateNaiss, + naissance_lieu AS lieuNaiss, dirRS as rs, '' as dateEffet + FROM jo.rncs_dirigeants + WHERE siren=$siren AND actif%10=1 AND fonction_lib NOT LIKE '%Administrateur%' + ORDER BY actif DESC, fonction_lib DESC"); if ($stmt->rowCount() == 0) { - $stmt = $this->conn->executeQuery("SELECT nom, prenom, naissance_nom, civilite, - fonction_code as code, fonction_lib as libelle, naissance_date AS dateNaiss, - naissance_lieu AS lieuNaiss, dirRS as rs, '' as dateEffet - FROM jo.rncs_dirigeants - WHERE siren=$siren AND actif%10=0 AND fonction_lib NOT LIKE '%Administrateur%' - ORDER BY actif DESC, fonction_lib DESC"); + $stmt = $this->conn->executeQuery("SELECT nom, prenom, naissance_nom, civilite, + fonction_code as code, fonction_lib as libelle, naissance_date AS dateNaiss, + naissance_lieu AS lieuNaiss, dirRS as rs, '' as dateEffet + FROM jo.rncs_dirigeants + WHERE siren=$siren AND actif%10=0 AND fonction_lib NOT LIKE '%Administrateur%' + ORDER BY actif DESC, fonction_lib DESC"); } if ($stmt->rowCount() > 0) { @@ -3123,12 +3123,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } } else { try { - $stmt = $this->conn->executeQuery("SELECT d.num, d.dateEffet, d.Rubrique, d.fonction, d.rs, - d.nom, d.prenom, d.nomUsage, d.depart, d.dateInsert, f.libelle - FROM jo.bodacc_dirigeants d, jo.bodacc_detail b, jo.bodacc_fonctions f - WHERE b.SIREN=$siren AND b.id=d.id AND b.typeEven NOT BETWEEN 5000 AND 5700 - AND b.typeEven NOT BETWEEN 2700 AND 2900 AND d.fonction=f.codeFct - AND d.depart != 1 AND f.triCode IN ('ASS','COG','DID','DIR','GER','PCS','PDG','PRD','PRE','PRT','VIC') + $stmt = $this->conn->executeQuery("SELECT d.num, d.dateEffet, d.Rubrique, d.fonction, d.rs, + d.nom, d.prenom, d.nomUsage, d.depart, d.dateInsert, f.libelle + FROM jo.bodacc_dirigeants d, jo.bodacc_detail b, jo.bodacc_fonctions f + WHERE b.SIREN=$siren AND b.id=d.id AND b.typeEven NOT BETWEEN 5000 AND 5700 + AND b.typeEven NOT BETWEEN 2700 AND 2900 AND d.fonction=f.codeFct + AND d.depart != 1 AND f.triCode IN ('ASS','COG','DID','DIR','GER','PCS','PDG','PRD','PRE','PRT','VIC') GROUP BY d.fonction, d.rs, d.nom, d.prenom ORDER BY d.dateEffet DESC"); if ($stmt->rowCount() > 0) { $k = 1; @@ -3160,8 +3160,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $tabInsee['CJ']>9000 && $tabInsee['CJ']<9400)) { try { - $stmt = $this->conn->executeQuery("SELECT Assoc_Web, Assoc_Mail FROM jo.asso - WHERE siren=$siren AND dateSuppr=0 AND (Assoc_Web != '' OR Assoc_Mail != '') + $stmt = $this->conn->executeQuery("SELECT Assoc_Web, Assoc_Mail FROM jo.asso + WHERE siren=$siren AND dateSuppr=0 AND (Assoc_Web != '' OR Assoc_Mail != '') ORDER BY Date_Parution DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $annCap = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -3182,9 +3182,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($etab['source'] == 3) { $id = $etab['source_id']; try { - $stmt = $this->conn->executeQuery("SELECT Activite, Sous_Prefecture, Assoc_Web, - Assoc_Mail, Assoc_Objet, Assoc_Fusion, Assoc_Date_Declaration2 - FROM jo.asso WHERE id=$id AND dateSuppr=0"); + $stmt = $this->conn->executeQuery("SELECT Activite, Sous_Prefecture, Assoc_Web, + Assoc_Mail, Assoc_Objet, Assoc_Fusion, Assoc_Date_Declaration2 + FROM jo.asso WHERE id=$id AND dateSuppr=0"); if ($stmt->rowCount() > 0) { $annCap = $stmt->fetch(\PDO::FETCH_ASSOC); $tabRet['Activite'] = $annCap['Assoc_Objet']; @@ -3251,11 +3251,11 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // RNCS Entrep et Etab, RM if (intval($siren) > 0) { - $stmt = $this->conn->executeQuery("SELECT siren, sirenValide, actif, numGreffe, triCode, - triId, numRC, numRC2, raisonSociale, nom, prenom, nomUsage, sigle, dateNaiss, - lieuNaiss, sexe, nationalite, pays, naf, cj, capitalMontant, capitalDevise, - capitalDevIso, dateImma, dateRad, dateRad*1 AS dateRadNum, capitalType, capitalCent, - provisoires, flux, DATE(dateUpdate) AS jourUpdate FROM jo.rncs_entrep WHERE siren=$siren"); + $stmt = $this->conn->executeQuery("SELECT siren, sirenValide, actif, numGreffe, triCode, + triId, numRC, numRC2, raisonSociale, nom, prenom, nomUsage, sigle, dateNaiss, + lieuNaiss, sexe, nationalite, pays, naf, cj, capitalMontant, capitalDevise, + capitalDevIso, dateImma, dateRad, dateRad*1 AS dateRadNum, capitalType, capitalCent, + provisoires, flux, DATE(dateUpdate) AS jourUpdate FROM jo.rncs_entrep WHERE siren=$siren"); if ($stmt->rowCount() > 0) { $entrep = $stmt->fetch(\PDO::FETCH_ASSOC); // ETRANGER @@ -3335,11 +3335,11 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Informations sur l'établissement au RNCS try { - $stmt = $this->conn->executeQuery("SELECT id, siege, actif, enseigne, - nomCommercial, adrNumVoie, adrIndRep, adrLibVoie, adrTypeVoie, adrVoie, cp, - commune, adrComp, adresse1, adresse2, adresse3, naf, dateFermeture, flux, - dateInsert, DATE(dateUpdate) AS jourUpdate FROM jo.rncs_etab - WHERE siren=$siren AND nic=$nic"); + $stmt = $this->conn->executeQuery("SELECT id, siege, actif, enseigne, + nomCommercial, adrNumVoie, adrIndRep, adrLibVoie, adrTypeVoie, adrVoie, cp, + commune, adrComp, adresse1, adresse2, adresse3, naf, dateFermeture, flux, + dateInsert, DATE(dateUpdate) AS jourUpdate FROM jo.rncs_etab + WHERE siren=$siren AND nic=$nic"); if ($stmt->rowCount() > 0) { $rncsEtab = $stmt->fetch(\PDO::FETCH_ASSOC); $tabRet['EtabActifRCS'] = 0; @@ -3375,12 +3375,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } elseif ($siren > 1000) { // Recherche au RM try { - $stmt = $this->conn->executeQuery("SELECT siren, actif, numRM, denomination, - sigle, nomCommercial, enseigne, fj, effectif, aprm, debutActivite, activite, - adresse, cp, ville, cessation, radiation, nom, prenom, nomUsage, dateNaiss, - lieuNaiss, qualite, qualif, dateQualif, dateFctDeb, dateFctFin, - DATE(dateUpdate) AS jourUpdate, DATE(dateInsert) AS dateInsert - FROM jo.artisanat WHERE siren=$siren"); + $stmt = $this->conn->executeQuery("SELECT siren, actif, numRM, denomination, + sigle, nomCommercial, enseigne, fj, effectif, aprm, debutActivite, activite, + adresse, cp, ville, cessation, radiation, nom, prenom, nomUsage, dateNaiss, + lieuNaiss, qualite, qualif, dateQualif, dateFctDeb, dateFctFin, + DATE(dateUpdate) AS jourUpdate, DATE(dateInsert) AS dateInsert + FROM jo.artisanat WHERE siren=$siren"); if ($stmt->rowCount() > 0) { $rmEntrep = $stmt->fetch(\PDO::FETCH_ASSOC); if (isset($entrep['numRM'])) { @@ -3479,9 +3479,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table || preg_match('/EIRL/', $tabRet['Adresse']) || preg_match('/EIRL/', $tabRet['Adresse2']) ) && ($tabInsee['CJ']==1700 || // Agents commerciaux (uniquement au Greffes RSAC) - $tabRet['numRC']=='' || // Numéro de RCS absent = Anomalie (<à3%) + $tabRet['numRC']=='' || // Numéro de RCS absent = Anomalie (<à3%) $tabRet['Tribunal']=='' || // Tribunal absent = anomalie - str_replace('-', '', $tabRet['dateImmat'])*1==0 || // Pas de date d'immat = anomalie (<à9%) + str_replace('-', '', $tabRet['dateImmat'])*1==0 || // Pas de date d'immat = anomalie (<à9%) ($nbEtab*1 == 0 && str_replace('-', '', $tabRet['dateRad'])*1==0) // Inactif sans date de RAD ) ) { @@ -3542,8 +3542,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Eléments Financiers en provenance du dernier Bilan try { - $stmt = $this->conn->executeQuery("SELECT siren, dateExercice, dureeExercice, monnaie, - typeBilan, unite, postes, dateProvPartenaire, dateInsert FROM jo.bilans + $stmt = $this->conn->executeQuery("SELECT siren, dateExercice, dureeExercice, monnaie, + typeBilan, unite, postes, dateProvPartenaire, dateInsert FROM jo.bilans WHERE siren=$siren AND typeBilan IN ('N','S') ORDER BY dateExercice DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $bilEntrep = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -3602,7 +3602,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } // Contrôle de la cohérence du type d'exploitation - if ($tabBilan['AH'] > 0 && // Je possède un fond commercial + if ($tabBilan['AH'] > 0 && // Je possède un fond commercial $tabRet['TypeExploitation'] != 2 && // et je ne suis pas Loueur d'un fond $tabRet['TypeExploitation'] != 3 && // et je ne suis pas Prestataire de personnel $tabRet['TypeExploitation'] != 10) { // et je ne suis pas exploitant direct @@ -3641,7 +3641,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Numero de Registre du métier si nécessaire if (($tabRet['FJ']==1100 || $tabRet['FJ']==1300 || $tabRet['FJ']==11 || $tabRet['FJ']==13 || $tabInsee['APRM'] != '') && ($tabRet['Dept']=='2A' || $tabRet['Dept']=='2B' || $tabRet['Dept']<98)) { - // Artisan Commerçant OU Artisan en FRANCE + // Artisan Commerçant OU Artisan en FRANCE $tabRet['NumRM'] = $siren.' RM '.$tabRet['Dept']; // Ajaccio if ($tabRet['Dept'] == '2A') { @@ -3694,9 +3694,6 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $tabJugements = array(); foreach ($annoncesList as $i => $ann) { $date = str_replace('-','', $ann['dateJugement']); - if (intval($date) == 0) { - $date = str_replace('-','', $ann['dateEffet']); - } if (intval($date) == 0) { $date = str_replace('-','', $ann['dateParution']); } @@ -3709,7 +3706,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $annFormat = new stdClass(); $date = str_replace('-', '', $ann['dateJugement']); if (intval($date) == 0) { - $date = str_replace('-', '', $ann['dateEffet']); + $date = str_replace('-','', $ann['dateParution']); } $annFormat->date = $date; $annFormat->code = $ann['evenements'][0]['CodeEven']; @@ -3774,8 +3771,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table try { $stmt = $this->conn->executeQuery("SELECT id, siren, nic, civ, nom, prenom, nom_usage, - lieuNais, dateNais, d.codFct, f.libelle, tel, fax, email, dateInsert, dateUpdate - FROM sdv1.dirigeantsOp d, jo.bodacc_fonctions f WHERE $where"); + lieuNais, dateNais, d.codFct, f.libelle, tel, fax, email, dateInsert, dateUpdate + FROM sdv1.dirigeantsOp d, jo.bodacc_fonctions f WHERE $where"); if ($stmt->rowCount() > 0) { while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $tabRet[] = array( @@ -3821,12 +3818,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($histo) { try { - $stmt = $this->conn->executeQuery("SELECT d.num, d.dateEffet, d.Rubrique, d.fonction, - d.dirSiren, d.rs, d.nom, d.prenom, d.nomUsage, d.depart, d.dateInsert, f.libelle - FROM jo.bodacc_dirigeants d, jo.bodacc_detail b, jo.bodacc_fonctions f - WHERE b.SIREN=$siren AND b.id=d.id AND b.typeEven NOT BETWEEN 5000 AND 5700 AND b.typeEven - NOT BETWEEN 2700 AND 2900 AND d.fonction=f.codeFct - GROUP BY d.fonction, d.rs, d.nom, d.prenom + $stmt = $this->conn->executeQuery("SELECT d.num, d.dateEffet, d.Rubrique, d.fonction, + d.dirSiren, d.rs, d.nom, d.prenom, d.nomUsage, d.depart, d.dateInsert, f.libelle + FROM jo.bodacc_dirigeants d, jo.bodacc_detail b, jo.bodacc_fonctions f + WHERE b.SIREN=$siren AND b.id=d.id AND b.typeEven NOT BETWEEN 5000 AND 5700 AND b.typeEven + NOT BETWEEN 2700 AND 2900 AND d.fonction=f.codeFct + GROUP BY d.fonction, d.rs, d.nom, d.prenom ORDER BY d.dateInsert DESC, d.dateEffet DESC, d.fonction DESC"); if ($stmt->rowCount() > 0) { while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { @@ -3854,11 +3851,11 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } try { - $stmt = $this->conn->executeQuery("SELECT e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, - e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, - x.annonceNum, x.annonceTxt FROM historiques.entrep e, historiques.texte x - WHERE e.E1GSIR=$siren AND e.ANBASE=x.annonceNum - AND e.DATE BETWEEN 19960101 AND 20050101 AND x.annonceTxt LIKE '%Administration%' + $stmt = $this->conn->executeQuery("SELECT e.ANBASE, e.NOBOD, e.CODTRI, e.JAL, e.DATE, + e.CODEVE, e.SSCODE, e.DEPT, e.NOANN, e.ROLE, e.SIREN, e.E1GSIR, e.E1GNIC, + x.annonceNum, x.annonceTxt FROM historiques.entrep e, historiques.texte x + WHERE e.E1GSIR=$siren AND e.ANBASE=x.annonceNum + AND e.DATE BETWEEN 19960101 AND 20050101 AND x.annonceTxt LIKE '%Administration%' GROUP BY e.ANBASE ORDER BY e.DATE DESC"); if ($stmt->rowCount() > 0) { while ($ann = $stmt->fetch(\PDO::FETCH_ASSOC)) { @@ -3930,9 +3927,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if (!$histo || ($histo && count($tabRet) == 0)) { try { - $stmt = $this->conn->executeQuery("SELECT siren, raisonSociale, LPAD(dirSiren,9,0) AS dirSiren, - dirRS, civilite, nom, prenom, naissance_nom, naissance_date, naissance_lieu, - fonction_code, fonction_lib, cinf, dateFin, flux, dateInsert + $stmt = $this->conn->executeQuery("SELECT siren, raisonSociale, LPAD(dirSiren,9,0) AS dirSiren, + dirRS, civilite, nom, prenom, naissance_nom, naissance_date, naissance_lieu, + fonction_code, fonction_lib, cinf, dateFin, flux, dateInsert FROM jo.rncs_dirigeants WHERE siren=$siren AND actif%10=1"); if ($stmt->rowCount() > 0) { while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { @@ -3982,14 +3979,14 @@ class Metier_Insee_MInsee extends Metier_Insee_Table /** Recherche de CAC si liste des dirigeants actifs **/ if (!$histo) { try { - $stmt = $this->conn->executeQuery("SELECT d.num, d.dateEffet, d.Rubrique, d.fonction, - LPAD(d.dirSiren,9,0) AS dirSiren, d.rs, d.nom, d.prenom, d.nomUsage, d.depart, - d.dateInsert, f.libelle - FROM jo.bodacc_dirigeants d, jo.bodacc_detail b, jo.bodacc_fonctions f - WHERE b.SIREN=$siren AND b.id=d.id AND b.typeEven NOT BETWEEN 5000 AND 5700 - AND b.typeEven NOT BETWEEN 2700 AND 2900 AND d.fonction=f.codeFct - AND d.fonction BETWEEN 300 AND 304 GROUP BY d.fonction, d.rs, d.nom, d.prenom - ORDER BY d.dateEffet DESC, d.fonction DESC"); + $stmt = $this->conn->executeQuery("SELECT d.num, d.dateEffet, d.Rubrique, d.fonction, + LPAD(d.dirSiren,9,0) AS dirSiren, d.rs, d.nom, d.prenom, d.nomUsage, d.depart, + d.dateInsert, f.libelle + FROM jo.bodacc_dirigeants d, jo.bodacc_detail b, jo.bodacc_fonctions f + WHERE b.SIREN=$siren AND b.id=d.id AND b.typeEven NOT BETWEEN 5000 AND 5700 + AND b.typeEven NOT BETWEEN 2700 AND 2900 AND d.fonction=f.codeFct + AND d.fonction BETWEEN 300 AND 304 GROUP BY d.fonction, d.rs, d.nom, d.prenom + ORDER BY d.dateEffet DESC, d.fonction DESC"); if ($stmt->rowCount() > 0) { $k = 0; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { @@ -4035,12 +4032,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table /** Si on ne trouve absolument rien, on regarde quand même dans l'historique RNCS **/ if (count($tabRet)==0) { try { - $stmt = $this->conn->executeQuery("SELECT siren, raisonSociale, - LPAD(dirSiren,9,0) AS dirSiren, dirRS, civilite, nom, prenom, naissance_nom, - naissance_date, naissance_lieu, fonction_code, fonction_lib, cinf, dateFin, - flux, dateInsert, date(dateUpdate)*1 as dateUpdate - FROM jo.rncs_dirigeants WHERE siren=$siren AND actif%10=0 - ORDER BY dateUpdate DESC"); + $stmt = $this->conn->executeQuery("SELECT siren, raisonSociale, + LPAD(dirSiren,9,0) AS dirSiren, dirRS, civilite, nom, prenom, naissance_nom, + naissance_date, naissance_lieu, fonction_code, fonction_lib, cinf, dateFin, + flux, dateInsert, date(dateUpdate)*1 as dateUpdate + FROM jo.rncs_dirigeants WHERE siren=$siren AND actif%10=0 + ORDER BY dateUpdate DESC"); if ($stmt->rowCount() > 0) { $dateUpdatePre = null; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { @@ -4109,8 +4106,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $civilite = ''; } try { - $stmt = $this->conn->executeQuery("SELECT SIREN, CJ, CIVILITE, DIR_DATEN, DIR_LIEUN - FROM insee.identite WHERE SIREN=$siren AND (DIR_DATEN>0 OR DIR_LIEUN != '') + $stmt = $this->conn->executeQuery("SELECT SIREN, CJ, CIVILITE, DIR_DATEN, DIR_LIEUN + FROM insee.identite WHERE SIREN=$siren AND (DIR_DATEN>0 OR DIR_LIEUN != '') ORDER BY DIR_DATEN DESC, DIR_LIEUN DESC"); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $tabRet[] = array( @@ -4234,17 +4231,17 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($type == 'bodacc') { // Procédure collective if ($rubrique=='P' || $rubrique=='PH') { - $where = " AND d.Rubrique='procol' - AND d.typeEven NOT LIKE '%1005%' - AND d.typeEven NOT LIKE '%1010%' - AND d.typeEven NOT LIKE '%1050%' - AND d.typeEven NOT LIKE '%1055%' - AND d.typeEven NOT LIKE '%1550%' "; + $where = " AND d.Rubrique='procol' + AND d.typeEven NOT LIKE '%1005%' + AND d.typeEven NOT LIKE '%1010%' + AND d.typeEven NOT LIKE '%1050%' + AND d.typeEven NOT LIKE '%1055%' + AND d.typeEven NOT LIKE '%1550%' "; } // Dissolution de la société elseif ($rubrique=='D') { - $where =" AND (d.typeEven LIKE '%2202%' OR d.typeEven LIKE '%2203%' OR d.typeEven LIKE '%2204%' OR - d.typeEven LIKE '%2210%' OR d.typeEven LIKE '%2211%' OR d.typeEven LIKE '%2212%') "; + $where =" AND (d.typeEven LIKE '%2202%' OR d.typeEven LIKE '%2203%' OR d.typeEven LIKE '%2204%' OR + d.typeEven LIKE '%2210%' OR d.typeEven LIKE '%2211%' OR d.typeEven LIKE '%2212%') "; } // Absorption elseif ($rubrique=='A') { @@ -4260,29 +4257,29 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } // Dépôt des comptes, BODACC C elseif ($rubrique=='C' || $rubrique=='BODC') { - $where =" AND (d.Rubrique='comptes' OR d.typeEven LIKE '%3100%' OR d.typeEven LIKE '%3200%' - OR d.typeEven LIKE '%3300%' OR d.typeEven LIKE '%3999%') "; + $where =" AND (d.Rubrique='comptes' OR d.typeEven LIKE '%3100%' OR d.typeEven LIKE '%3200%' + OR d.typeEven LIKE '%3300%' OR d.typeEven LIKE '%3999%') "; } elseif ($rubrique=='R') { - $where =" AND (d.typeEven LIKE '%2202%' OR d.typeEven LIKE '%2203%' OR d.typeEven LIKE '%2204%' OR - d.typeEven LIKE '%2210%' OR d.typeEven LIKE '%2211%' OR d.typeEven LIKE '%2212%' OR - d.Rubrique='radiations') "; + $where =" AND (d.typeEven LIKE '%2202%' OR d.typeEven LIKE '%2203%' OR d.typeEven LIKE '%2204%' OR + d.typeEven LIKE '%2210%' OR d.typeEven LIKE '%2211%' OR d.typeEven LIKE '%2212%' OR + d.Rubrique='radiations') "; } // Location gérance Locataire elseif ($rubrique=='L') { - $where =" AND (d.typeEven LIKE '%2800%' OR d.typeEven LIKE '%2875%' OR d.typeEven LIKE '%2880%' OR - d.typeEven LIKE '%2881%' OR d.typeEven LIKE '%2885%' OR d.typeEven LIKE '%2840%' OR - d.typeEven LIKE '%4355%') "; + $where =" AND (d.typeEven LIKE '%2800%' OR d.typeEven LIKE '%2875%' OR d.typeEven LIKE '%2880%' OR + d.typeEven LIKE '%2881%' OR d.typeEven LIKE '%2885%' OR d.typeEven LIKE '%2840%' OR + d.typeEven LIKE '%4355%') "; } // Location gérance Propriétaire elseif ($rubrique=='G') { - $where =" AND (d.typeEven LIKE '%2850%' OR d.typeEven LIKE '%2851%' OR d.typeEven LIKE '%2860%' OR - d.typeEven LIKE '%2870%') "; + $where =" AND (d.typeEven LIKE '%2850%' OR d.typeEven LIKE '%2851%' OR d.typeEven LIKE '%2860%' OR + d.typeEven LIKE '%2870%') "; } // Ventes/Cessions elseif ($rubrique=='V') { - $where =" AND (d.typeEven LIKE '%5500%' OR d.typeEven LIKE '%5501%' OR d.typeEven LIKE '%5502%' OR - d.typeEven LIKE '%5503%' OR d.typeEven LIKE '%5510%' OR d.typeEven LIKE '%5600%' OR - d.typeEven LIKE '%5650%') "; + $where =" AND (d.typeEven LIKE '%5500%' OR d.typeEven LIKE '%5501%' OR d.typeEven LIKE '%5502%' OR + d.typeEven LIKE '%5503%' OR d.typeEven LIKE '%5510%' OR d.typeEven LIKE '%5600%' OR + d.typeEven LIKE '%5650%') "; } elseif (is_array($rubrique) && count($rubrique)>0) { $where =" AND ("; foreach ($rubrique as $codeEven) { @@ -5098,99 +5095,99 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } else { $unionDate = 'd.dateJugement AS unionDate'; } - $sql = "SELECT - b.id AS id, - /* BODACC */ - b.Bodacc_Code, - b.Bodacc_Annee_Parution, - b.Bodacc_Num, - b.Num_Annonce, - b.Bodacc_Date_Parution, - b.Tribunal_Dept, - b.Tribunal_Code, - d.Rubrique, - b.typeAnnonce, - b.corrNum_Annonce, - b.corrBodacc_Date_Parution, - b.corrPage, - b.corrNumParution, - b.corrTexteRectificatif, - b.annonce, - b.dateInsert, - d.typeEven, - d.dateEffet, - d.dateDebutActivite, - d.dateCessationActivite, - d.dateJugement, - d.dateFinObservation, - d.VenteMt, - d.VenteDev, - d.FJ, - d.Capital, - d.CapitalDev, - CONCAT(d.commentaires,' ',d.fusion) AS complement, - d.raisonSociale, - d.nomCommercial, - d.enseigne, - d.sigle, - d.adresse, - d.codePostal, - d.ville, - d.adresseSiege, - d.codePostalSiege, - d.villeSiege, - /* HISTO */ - '' AS ANBASE, - '' AS NOBOD, - '' AS CODTRI, - '' AS JAL, - '' AS DATE, - '' AS CODEVE, - '' AS SSCODE, - '' AS DEPT, - '' AS NOANN, - '' AS ROLE, - '' AS SIREN, - '' AS E1GSIR, - '' AS E1GNIC, - '' AS annonceNum, - '' AS annonceTxt, - /* ANNONCE */ - '' AS strEven, - '' AS dateCessationPaiement, - '' AS dateEffetFinP, - '' AS numero, - '' AS inter1type, - '' AS inter1id, - '' AS inter1nom, - '' AS inter2type, - '' AS inter2id, - '' AS inter2nom, - '' AS inter3type, - '' AS inter3id, - '' AS inter3nom, - '' AS inter4type, - '' AS inter4id, - '' AS inter4nom, - '' AS tribunal, - '' AS montant, - '' AS actionsNb, - '' AS nouvActivite, - '' AS nouvDir, - '' AS nouvAdr, - '' AS nouvFJ, - '' AS source, - '' AS parutionIdJal, - '' AS parutionNum, - '' AS dateSource, - /* UNION NEEDED */ - t.triCode, - t.triNom, - t.triSiret, - t.triCP, - IF(d.dateSuppr=0,'',d.dateSuppr) AS deleted, - ".$unionDate.", - 'bodacc' AS SourceTable + $sql = "SELECT + b.id AS id, + /* BODACC */ + b.Bodacc_Code, + b.Bodacc_Annee_Parution, + b.Bodacc_Num, + b.Num_Annonce, + b.Bodacc_Date_Parution, + b.Tribunal_Dept, + b.Tribunal_Code, + d.Rubrique, + b.typeAnnonce, + b.corrNum_Annonce, + b.corrBodacc_Date_Parution, + b.corrPage, + b.corrNumParution, + b.corrTexteRectificatif, + b.annonce, + b.dateInsert, + d.typeEven, + d.dateEffet, + d.dateDebutActivite, + d.dateCessationActivite, + d.dateJugement, + d.dateFinObservation, + d.VenteMt, + d.VenteDev, + d.FJ, + d.Capital, + d.CapitalDev, + CONCAT(d.commentaires,' ',d.fusion) AS complement, + d.raisonSociale, + d.nomCommercial, + d.enseigne, + d.sigle, + d.adresse, + d.codePostal, + d.ville, + d.adresseSiege, + d.codePostalSiege, + d.villeSiege, + /* HISTO */ + '' AS ANBASE, + '' AS NOBOD, + '' AS CODTRI, + '' AS JAL, + '' AS DATE, + '' AS CODEVE, + '' AS SSCODE, + '' AS DEPT, + '' AS NOANN, + '' AS ROLE, + '' AS SIREN, + '' AS E1GSIR, + '' AS E1GNIC, + '' AS annonceNum, + '' AS annonceTxt, + /* ANNONCE */ + '' AS strEven, + '' AS dateCessationPaiement, + '' AS dateEffetFinP, + '' AS numero, + '' AS inter1type, + '' AS inter1id, + '' AS inter1nom, + '' AS inter2type, + '' AS inter2id, + '' AS inter2nom, + '' AS inter3type, + '' AS inter3id, + '' AS inter3nom, + '' AS inter4type, + '' AS inter4id, + '' AS inter4nom, + '' AS tribunal, + '' AS montant, + '' AS actionsNb, + '' AS nouvActivite, + '' AS nouvDir, + '' AS nouvAdr, + '' AS nouvFJ, + '' AS source, + '' AS parutionIdJal, + '' AS parutionNum, + '' AS dateSource, + /* UNION NEEDED */ + t.triCode, + t.triNom, + t.triSiret, + t.triCP, + IF(d.dateSuppr=0,'',d.dateSuppr) AS deleted, + ".$unionDate.", + 'bodacc' AS SourceTable FROM jo.bodacc_detail d, jo.bodacc b, jo.tribunaux t"; } @@ -5202,99 +5199,99 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($count === true) { $sql = "SELECT e.ANBASE AS id, DATE_FORMAT(e.DATE, '%Y-%m-%d') AS unionDate, 'histo' AS SourceTable"; } else { - $sql = "SELECT - e.ANBASE AS id, - /* BODACC */ - '' AS Bodacc_Code, - '' AS Bodacc_Annee_Parution, - '' AS Bodacc_Num, - '' AS Num_Annonce, - '' AS Bodacc_Date_Parution, - '' AS Tribunal_Dept, - '' AS Tribunal_Code, - '' AS Rubrique, - '' AS typeAnnonce, - '' AS corrNum_Annonce, - '' AS corrBodacc_Date_Parution, - '' AS corrPage, - '' AS corrNumParution, - '' AS corrTexteRectificatif, - '' AS annonce, - '' AS dateInsert, - '' AS typeEven, - '' AS dateEffet, - '' AS dateDebutActivite, - '' AS dateCessationActivite, - '' AS dateJugement, - '' AS dateFinObservation, - '' AS VenteMt, - '' AS VenteDev, - '' AS FJ, - '' AS Capital, - '' AS CapitalDev, - '' AS complement, - '' AS raisonSociale, - '' AS nomCommercial, - '' AS enseigne, - '' AS sigle, - '' AS adresse, - '' AS codePostal, - '' AS ville, - '' AS adresseSiege, - '' AS codePostalSiege, - '' AS villeSiege, - /* HISTO */ - e.ANBASE, - e.NOBOD, - e.CODTRI, - e.JAL, - e.DATE, - e.CODEVE, - e.SSCODE, - e.DEPT, - e.NOANN, - e.ROLE, - e.SIREN AS siren, - e.E1GSIR, - e.E1GNIC, - x.annonceNum, - x.annonceTxt, - /* ANNONCE */ - '' AS strEven, - '' AS dateCessationPaiement, - '' AS dateEffetFinP, - '' AS numero, - '' AS inter1type, - '' AS inter1id, - '' AS inter1nom, - '' AS inter2type, - '' AS inter2id, - '' AS inter2nom, - '' AS inter3type, - '' AS inter3id, - '' AS inter3nom, - '' AS inter4type, - '' AS inter4id, - '' AS inter4nom, - '' AS tribunal, - '' AS montant, - '' AS actionsNb, - '' AS nouvActivite, - '' AS nouvDir, - '' AS nouvAdr, - '' AS nouvFJ, - '' AS source, - '' AS parutionIdJal, - '' AS parutionNum, - '' AS dateSource, - /* UNION NEEDED */ - '' AS triCode, - '' AS triNom, - '' AS triSiret, - '' AS triCP, - '' AS deleted, - DATE_FORMAT(e.DATE, '%Y-%m-%d') AS unionDate, - 'histo' AS SourceTable + $sql = "SELECT + e.ANBASE AS id, + /* BODACC */ + '' AS Bodacc_Code, + '' AS Bodacc_Annee_Parution, + '' AS Bodacc_Num, + '' AS Num_Annonce, + '' AS Bodacc_Date_Parution, + '' AS Tribunal_Dept, + '' AS Tribunal_Code, + '' AS Rubrique, + '' AS typeAnnonce, + '' AS corrNum_Annonce, + '' AS corrBodacc_Date_Parution, + '' AS corrPage, + '' AS corrNumParution, + '' AS corrTexteRectificatif, + '' AS annonce, + '' AS dateInsert, + '' AS typeEven, + '' AS dateEffet, + '' AS dateDebutActivite, + '' AS dateCessationActivite, + '' AS dateJugement, + '' AS dateFinObservation, + '' AS VenteMt, + '' AS VenteDev, + '' AS FJ, + '' AS Capital, + '' AS CapitalDev, + '' AS complement, + '' AS raisonSociale, + '' AS nomCommercial, + '' AS enseigne, + '' AS sigle, + '' AS adresse, + '' AS codePostal, + '' AS ville, + '' AS adresseSiege, + '' AS codePostalSiege, + '' AS villeSiege, + /* HISTO */ + e.ANBASE, + e.NOBOD, + e.CODTRI, + e.JAL, + e.DATE, + e.CODEVE, + e.SSCODE, + e.DEPT, + e.NOANN, + e.ROLE, + e.SIREN AS siren, + e.E1GSIR, + e.E1GNIC, + x.annonceNum, + x.annonceTxt, + /* ANNONCE */ + '' AS strEven, + '' AS dateCessationPaiement, + '' AS dateEffetFinP, + '' AS numero, + '' AS inter1type, + '' AS inter1id, + '' AS inter1nom, + '' AS inter2type, + '' AS inter2id, + '' AS inter2nom, + '' AS inter3type, + '' AS inter3id, + '' AS inter3nom, + '' AS inter4type, + '' AS inter4id, + '' AS inter4nom, + '' AS tribunal, + '' AS montant, + '' AS actionsNb, + '' AS nouvActivite, + '' AS nouvDir, + '' AS nouvAdr, + '' AS nouvFJ, + '' AS source, + '' AS parutionIdJal, + '' AS parutionNum, + '' AS dateSource, + /* UNION NEEDED */ + '' AS triCode, + '' AS triNom, + '' AS triSiret, + '' AS triCP, + '' AS deleted, + DATE_FORMAT(e.DATE, '%Y-%m-%d') AS unionDate, + 'histo' AS SourceTable FROM historiques.texte x, historiques.entrep e"; } @@ -5311,99 +5308,99 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } else { $unionDate = 'a.dateJugement AS unionDate'; } - $sql = "SELECT - a.id AS id, - /* BODACC */ - '' AS Bodacc_Code, - '' AS Bodacc_Annee_Parution, - '' AS Bodacc_Num, - '' AS Num_Annonce, - '' AS Bodacc_Date_Parution, - '' AS Tribunal_Dept, - '' AS Tribunal_Code, - '' AS Rubrique, - '' AS typeAnnonce, - '' AS corrNum_Annonce, - '' AS corrBodacc_Date_Parution, - '' AS corrPage, - '' AS corrNumParution, - '' AS corrTexteRectificatif, - a.annonce, - a.dateInsert, - a.typeEven, - '' AS dateEffet, - '' AS dateDebutActivite, - '' AS dateCessationActivite, - a.dateJugement, - '' AS dateFinObservation, - '' AS VenteMt, - '' AS VenteDev, - '' AS FJ, - '' AS Capital, - '' AS CapitalDev, - a.complement, - a.raisonSociale, - '' AS nomCommercial, - '' AS enseigne, - '' AS sigle, - a.adresse, - a.codePostal, - a.ville, - '' AS adresseSiege, - '' AS codePostalSiege, - '' AS villeSiege, - /* HISTO */ - '' AS ANBASE, - '' AS NOBOD, - '' AS CODTRI, - '' AS JAL, - '' AS DATE, - '' AS CODEVE, - '' AS SSCODE, - '' AS DEPT, - '' AS NOANN, - '' AS ROLE, - a.siren, - '' AS E1GSIR, - '' AS E1GNIC, - '' AS annonceNum, - '' AS annonceTxt, - /* ANNONCE */ - a.strEven, - a.dateCessationPaiement, - a.dateEffetFinP, - a.numero, - a.inter1type, - a.inter1id, - a.inter1nom, - a.inter2type, - a.inter2id, - a.inter2nom, - a.inter3type, - a.inter3id, - a.inter3nom, - a.inter4type, - a.inter4id, - a.inter4nom, - a.tribunal, - a.montant, - a.actionsNb, - a.nouvActivite, - a.nouvDir, - a.nouvAdr, - a.nouvFJ, - a.source, - a.parutionIdJal, - a.parutionNum, - DATE_FORMAT(a.dateSource, '%Y-%m-%d') AS dateSource, - /* UNION NEEDED */ - t.triCode, - t.triNom, - t.triSiret, - t.triCP, - '' AS deleted, - ".$unionDate.", - 'annonce' AS SourceTable + $sql = "SELECT + a.id AS id, + /* BODACC */ + '' AS Bodacc_Code, + '' AS Bodacc_Annee_Parution, + '' AS Bodacc_Num, + '' AS Num_Annonce, + '' AS Bodacc_Date_Parution, + '' AS Tribunal_Dept, + '' AS Tribunal_Code, + '' AS Rubrique, + '' AS typeAnnonce, + '' AS corrNum_Annonce, + '' AS corrBodacc_Date_Parution, + '' AS corrPage, + '' AS corrNumParution, + '' AS corrTexteRectificatif, + a.annonce, + a.dateInsert, + a.typeEven, + '' AS dateEffet, + '' AS dateDebutActivite, + '' AS dateCessationActivite, + a.dateJugement, + '' AS dateFinObservation, + '' AS VenteMt, + '' AS VenteDev, + '' AS FJ, + '' AS Capital, + '' AS CapitalDev, + a.complement, + a.raisonSociale, + '' AS nomCommercial, + '' AS enseigne, + '' AS sigle, + a.adresse, + a.codePostal, + a.ville, + '' AS adresseSiege, + '' AS codePostalSiege, + '' AS villeSiege, + /* HISTO */ + '' AS ANBASE, + '' AS NOBOD, + '' AS CODTRI, + '' AS JAL, + '' AS DATE, + '' AS CODEVE, + '' AS SSCODE, + '' AS DEPT, + '' AS NOANN, + '' AS ROLE, + a.siren, + '' AS E1GSIR, + '' AS E1GNIC, + '' AS annonceNum, + '' AS annonceTxt, + /* ANNONCE */ + a.strEven, + a.dateCessationPaiement, + a.dateEffetFinP, + a.numero, + a.inter1type, + a.inter1id, + a.inter1nom, + a.inter2type, + a.inter2id, + a.inter2nom, + a.inter3type, + a.inter3id, + a.inter3nom, + a.inter4type, + a.inter4id, + a.inter4nom, + a.tribunal, + a.montant, + a.actionsNb, + a.nouvActivite, + a.nouvDir, + a.nouvAdr, + a.nouvFJ, + a.source, + a.parutionIdJal, + a.parutionNum, + DATE_FORMAT(a.dateSource, '%Y-%m-%d') AS dateSource, + /* UNION NEEDED */ + t.triCode, + t.triNom, + t.triSiret, + t.triCP, + '' AS deleted, + ".$unionDate.", + 'annonce' AS SourceTable FROM jo.annonces a, jo.tribunaux t"; } @@ -5414,8 +5411,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table * Liste des annonces légales pour un siren donnée * @param integer $siren * @param integer $idAnnonce - * @param mixed $rubrique Filter par rubrique - * (P)rocol, (D)issolution, (R)adiation, (A)bsorption, (L)ocataire, (G)érance:propriétaire, + * @param mixed $rubrique Filter par rubrique + * (P)rocol, (D)issolution, (R)adiation, (A)bsorption, (L)ocataire, (G)érance:propriétaire, * (V)endeur, bodacc (C), (BODA) (BODB) (BODC) ou tableau des codeEven * @param bool $forceVerif * @return array @@ -5808,8 +5805,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table && ($ann['inter'.$mandNum.'id']>0 || trim($ann['inter'.$mandNum.'nom']) != '')) { $texteAnnonce.= $tabInter[$ann['inter'.$mandNum.'type']].' : '.$ann['inter'.$mandNum.'nom']; if ($ann['inter'.$mandNum.'id'] != 0) { - $mandStmt = $this->conn->executeQuery("SELECT sirenGrp, sirenMand, - tel, fax, email FROM jo.tabMandataires + $mandStmt = $this->conn->executeQuery("SELECT sirenGrp, sirenMand, + tel, fax, email FROM jo.tabMandataires WHERE id=".$ann['inter'.$mandNum.'id']); $mand = $mandStmt->fetch(\PDO::FETCH_ASSOC); if ($mand['sirenGrp'] != 0) { @@ -6006,7 +6003,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table try { $stmt = $this->conn->executeQuery("SELECT Societe_Rcs, Categorie, Num_Affaire, - Date_Parution, Num_Parution, Url_Annonce_Html, Url_Annonce_Pdf, Annonce_Html, dateInsert + Date_Parution, Num_Parution, Url_Annonce_Html, Url_Annonce_Pdf, Annonce_Html, dateInsert FROM jo.balo WHERE Societe_Rcs='$siren' $strIdAnn ORDER BY Date_Parution DESC, Num_Affaire LIMIT $offset, $lignes"); } catch (\Doctrine\DBAL\DBALException $e) { @@ -6104,15 +6101,15 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } } try { - $stmt = $this->conn->executeQuery("SELECT l.id, l.idAnn, l.Boamp_Code, l.Boamp_Rubrique, - b.Boamp_Rubrique_Lib, b.typeAnnonce, l.Boamp_Date_Parution, b.Boamp_Num, - b.Boamp_Annee_Parution, b.Num_AnnoncePre, b.Num_Annonce, b.Boamp_Dept, b.annonce, - l.num, l.`desc` AS description, l.nom, d.raisonSociale, l.montantTxt, - sum(l.montant) AS montant, l.montantAnMin, l.montantAnMax, l.trancheCond, - l.trancheFerme, l.dateAttrib, l.intitule, l.nomenclature, l.objets, l.cpv, - l.cpvComp, l.volume, l.execution, l.livraison, l.dureeJours, l.dureeMois, l.dateDeb, - l.dateFin, l.dateInsert, d.titre, d.objet, d.titreMarche, d.typeObjetMarche, d.objetAutre, d.autres - FROM jo.boamp_lots l, jo.boamp b, jo.boamp_detail d + $stmt = $this->conn->executeQuery("SELECT l.id, l.idAnn, l.Boamp_Code, l.Boamp_Rubrique, + b.Boamp_Rubrique_Lib, b.typeAnnonce, l.Boamp_Date_Parution, b.Boamp_Num, + b.Boamp_Annee_Parution, b.Num_AnnoncePre, b.Num_Annonce, b.Boamp_Dept, b.annonce, + l.num, l.`desc` AS description, l.nom, d.raisonSociale, l.montantTxt, + sum(l.montant) AS montant, l.montantAnMin, l.montantAnMax, l.trancheCond, + l.trancheFerme, l.dateAttrib, l.intitule, l.nomenclature, l.objets, l.cpv, + l.cpvComp, l.volume, l.execution, l.livraison, l.dureeJours, l.dureeMois, l.dateDeb, + l.dateFin, l.dateInsert, d.titre, d.objet, d.titreMarche, d.typeObjetMarche, d.objetAutre, d.autres + FROM jo.boamp_lots l, jo.boamp b, jo.boamp_detail d WHERE l.siren=$siren AND l.idAnn=b.id $strIdAnn AND d.id=b.id GROUP BY b.id ORDER BY l.Boamp_Date_Parution DESC LIMIT $offset,$lignes"); } catch (\Doctrine\DBAL\DBALException $e) { @@ -6206,13 +6203,13 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } } try { - $stmt = $this->conn->executeQuery("SELECT d.id, d.Boamp_Code, d.Boamp_Rubrique, - b.Boamp_Rubrique_Lib, b.typeAnnonce, d.Boamp_Date_Parution, b.Boamp_Num, - b.Boamp_Annee_Parution, b.Num_AnnoncePre, b.Num_Annonce, b.Boamp_Dept, - b.annonce, titre AS description, d.raisonSociale, d.estimValeur AS montantTxt, - d.estimValeurMin AS montantAnMin, d.estimValeurMax AS montantAnMax, + $stmt = $this->conn->executeQuery("SELECT d.id, d.Boamp_Code, d.Boamp_Rubrique, + b.Boamp_Rubrique_Lib, b.typeAnnonce, d.Boamp_Date_Parution, b.Boamp_Num, + b.Boamp_Annee_Parution, b.Num_AnnoncePre, b.Num_Annonce, b.Boamp_Dept, + b.annonce, titre AS description, d.raisonSociale, d.estimValeur AS montantTxt, + d.estimValeurMin AS montantAnMin, d.estimValeurMax AS montantAnMax, objet, cpv_obj, cpv_comp, d.dateInsert - FROM jo.boamp b, jo.boamp_detail d + FROM jo.boamp b, jo.boamp_detail d WHERE d.siren=$siren AND d.id=b.id $strIdAnn GROUP BY b.id ORDER BY d.Boamp_Date_Parution DESC LIMIT $offset,$lignes"); } catch (\Doctrine\DBAL\DBALException $e) { @@ -6245,12 +6242,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $rub=='96' || // Annulation - Rectificatif - Sans suite - Infructueux $rub=='977' // Annulation - Rectificatif / Avis en cas de transparence ex ante volontaire ) { - $stmt2 = $this->conn->executeQuery("SELECT l.id, l.idAnn, l.Boamp_Code, - l.Boamp_Rubrique, l.Boamp_Date_Parution, l.num, l.desc AS description, - l.nom, l.montantTxt, l.montant, l.montantAnMin, l.montantAnMax, - l.trancheCond, l.trancheFerme, l.dateAttrib, l.intitule, l.nomenclature, - l.objets, l.cpv, l.cpvComp, l.volume, l.execution, l.livraison, - l.dureeJours, l.dureeMois, l.dateDeb, l.dateFin + $stmt2 = $this->conn->executeQuery("SELECT l.id, l.idAnn, l.Boamp_Code, + l.Boamp_Rubrique, l.Boamp_Date_Parution, l.num, l.desc AS description, + l.nom, l.montantTxt, l.montant, l.montantAnMin, l.montantAnMax, + l.trancheCond, l.trancheFerme, l.dateAttrib, l.intitule, l.nomenclature, + l.objets, l.cpv, l.cpvComp, l.volume, l.execution, l.livraison, + l.dureeJours, l.dureeMois, l.dateDeb, l.dateFin FROM jo.boamp_lots l WHERE l.idAnn=$id"); while ($ann2 = $stmt2->fetch(\PDO::FETCH_ASSOC)) { if ($ann2['nom'] != '') { @@ -6328,7 +6325,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table /** * Nombre total d'annonces BOAMP * @param string $siren - * @param string $type A:avis d'attribution, M:Avis de marché + * @param string $type A:avis d'attribution, M:Avis de marché */ public function getAnnoncesBoampCount($siren, $type='') { @@ -6338,8 +6335,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // --- Recherche dans les avis d'attribution if ($type=='' || $type=='A') { try { - $stmt = $this->conn->executeQuery("SELECT COUNT(b.id) AS nb FROM jo.boamp_lots l, jo.boamp b, jo.boamp_detail d - WHERE l.siren=$siren AND l.idAnn=b.id AND d.id=b.id"); + $stmt = $this->conn->executeQuery("SELECT COUNT(b.id) AS nb FROM jo.boamp_lots l, jo.boamp b, jo.boamp_detail d + WHERE l.siren=$siren AND l.idAnn=b.id AND d.id=b.id"); if ($stmt->rowCount() > 0) { $result = $stmt->fetch(\PDO::FETCH_OBJ); $bodaccA = $result->nb; @@ -6354,8 +6351,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // --- Recherche dans les avis de marchés if ($type=='' || $type=='M') { try { - $stmt = $this->conn->executeQuery("SELECT COUNT(d.id) AS nb FROM jo.boamp b, jo.boamp_detail d - WHERE d.siren=$siren AND d.id=b.id"); + $stmt = $this->conn->executeQuery("SELECT COUNT(d.id) AS nb FROM jo.boamp b, jo.boamp_detail d + WHERE d.siren=$siren AND d.id=b.id"); if ($stmt->rowCount()) { $result = $stmt->fetch(\PDO::FETCH_OBJ); $bodaccM = $result->nb; @@ -6396,12 +6393,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $annonceNb = 0; try { - $stmt = $this->conn->executeQuery("SELECT id, Assoc_Nom, siren, nic, Waldec, Activite, Num_Annonce, - Date_Parution, Num_Parution, Departement, Sous_Prefecture, Type_Annonce, Annonce_Html, - Assoc_Objet, Assoc_Adresse, Assoc_NObjet, Assoc_AObjet, Assoc_NAdresse, Assoc_Fusion, - Assoc_Annulation, Assoc_ANom, Assoc_NNom, Assoc_Date_Declaration, Assoc_Date_Declaration2, - typeAnnonce, codEven, dateInsert - FROM jo.asso WHERE $strIdAnn AND dateSuppr=0 ORDER BY Date_Parution DESC LIMIT $offset,$lignes"); + $stmt = $this->conn->executeQuery("SELECT id, Assoc_Nom, siren, nic, Waldec, Activite, Num_Annonce, + Date_Parution, Num_Parution, Departement, Sous_Prefecture, Type_Annonce, Annonce_Html, + Assoc_Objet, Assoc_Adresse, Assoc_NObjet, Assoc_AObjet, Assoc_NAdresse, Assoc_Fusion, + Assoc_Annulation, Assoc_ANom, Assoc_NNom, Assoc_Date_Declaration, Assoc_Date_Declaration2, + typeAnnonce, codEven, dateInsert + FROM jo.asso WHERE $strIdAnn AND dateSuppr=0 ORDER BY Date_Parution DESC LIMIT $offset,$lignes"); $annonceNb = $stmt->rowCount(); } catch (\Doctrine\DBAL\DBALException $e) { if ($this->logger !== null) { @@ -6516,6 +6513,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } } + return 0; } @@ -6528,8 +6526,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table /** Chargement initial au cas ou la requête Coface plante **/ try { - $stmt = $this->conn->executeQuery("SELECT raisonSociale, isin, nscrl, tel, fax, web, mail, - DATE(dateUpdate)*1 as dateUpdate FROM jo.infos_entrep WHERE siren=$siren"); + $stmt = $this->conn->executeQuery("SELECT raisonSociale, isin, nscrl, tel, fax, web, mail, + DATE(dateUpdate)*1 as dateUpdate FROM jo.infos_entrep WHERE siren=$siren"); if ($stmt->rowCount() > 0) { $idComp = $stmt->fetch(\PDO::FETCH_ASSOC); // L'entrep est en base infos_entrep @@ -6577,8 +6575,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $strDep = "AND (n.territoire='' OR n.territoire LIKE '%$dep%')"; } try { - $stmt = $this->conn->executeQuery("SELECT n.`id CC`, n.`nom CC`, n.`editeur CC`, n.`nb page CC`, n.`isbn CC`, n.`date edition CC`, c.infoCC, joCCmaj - FROM jo.conv_naf n, jo.conventions c WHERE n.naf='$naf4' AND substring(n.`id CC`,1,4)=c.numBrochure $strDep GROUP BY n.`id CC`"); + $stmt = $this->conn->executeQuery("SELECT n.`id CC`, n.`nom CC`, n.`editeur CC`, n.`nb page CC`, n.`isbn CC`, n.`date edition CC`, c.infoCC, joCCmaj + FROM jo.conv_naf n, jo.conventions c WHERE n.naf='$naf4' AND substring(n.`id CC`,1,4)=c.numBrochure $strDep GROUP BY n.`id CC`"); if ($stmt->rowCount() > 0) { return $stmt->fetchAll(\PDO::FETCH_ASSOC); } @@ -6621,8 +6619,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $strAnnees.= implode(',', $tabAnnees).')'; } try { - $stmt = $this->conn->executeQuery("SELECT importExport, annee, rangNational, deptSiege - FROM jo.importExport WHERE siren=$siren $strImportExport $strAnnees ORDER BY annee DESC, importExport ASC"); + $stmt = $this->conn->executeQuery("SELECT importExport, annee, rangNational, deptSiege + FROM jo.importExport WHERE siren=$siren $strImportExport $strAnnees ORDER BY annee DESC, importExport ASC"); if ($stmt->rowCount() > 0) { return $stmt->fetch(\PDO::FETCH_ASSOC); } @@ -6642,12 +6640,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table public function getInfosNotice($siren, $nic) { try { - $stmt = $this->conn->executeQuery("SELECT LPAD(insSIREN,9,0) AS insSIREN, LPAD(insNIC,5,0) AS insNIC, - insL4_VOIE, insL6_POST, LPAD(insRPET,2,0) AS insRPET, insDEPCOMEN, LPAD(insRPEN,2,0) AS insRPEN, - insARRONET, insCTONET, insTCD, LPAD(insZEMET,2,0) AS insZEMET, insDU, insTU, - LPAD(insUU,2,0) AS insUU, LPAD(insMMINTRET,2,0) AS insMMINTRET, LPAD(insMMINTREN,2,0) AS insMMINTREN, - insVMAJ, insVMAJ1, insVMAJ2, insVMAJ3, insRECME, insEAEANT, insEAEAPET, insEAESEC1T, - insEAESEC2T, insEAEANN, insEAEAPEN, insEAESEC1N, insEAESEC2N, insEAESEC3N, insEAESEC4N, + $stmt = $this->conn->executeQuery("SELECT LPAD(insSIREN,9,0) AS insSIREN, LPAD(insNIC,5,0) AS insNIC, + insL4_VOIE, insL6_POST, LPAD(insRPET,2,0) AS insRPET, insDEPCOMEN, LPAD(insRPEN,2,0) AS insRPEN, + insARRONET, insCTONET, insTCD, LPAD(insZEMET,2,0) AS insZEMET, insDU, insTU, + LPAD(insUU,2,0) AS insUU, LPAD(insMMINTRET,2,0) AS insMMINTRET, LPAD(insMMINTREN,2,0) AS insMMINTREN, + insVMAJ, insVMAJ1, insVMAJ2, insVMAJ3, insRECME, insEAEANT, insEAEAPET, insEAESEC1T, + insEAESEC2T, insEAEANN, insEAEAPEN, insEAESEC1N, insEAESEC2N, insEAESEC3N, insEAESEC4N, dateNotice FROM insee.insee_notices WHERE insSIREN=$siren AND insNIC=$nic ORDER BY dateNotice DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { return $stmt->fetch(\PDO::FETCH_ASSOC); @@ -6659,13 +6657,13 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } try { - $stmt = $this->conn->executeQuery("SELECT LPAD(insSIREN,9,0) AS insSIREN, LPAD(insNIC,5,0) AS insNIC, - insL4_VOIE, insL6_POST, LPAD(insRPET,2,0) AS insRPET, insDEPCOMEN, LPAD(insRPEN,2,0) AS insRPEN, - insARRONET, insCTONET, insTCD, LPAD(insZEMET,2,0) AS insZEMET, insDU, insTU, - LPAD(insUU,2,0) AS insUU, insAMINTRET, insAMINTREN, insVMAJ, insVMAJ1, insVMAJ2, - insVMAJ3, '' AS insRECME, '' AS insEAEANT, '' AS insEAEAPET, '' AS insEAESEC1T, '' AS insEAESEC2T, - insESAANN AS insEAEANN, insESAPEN AS insEAEAPEN, insESASEC1N AS insEAESEC1N, - insESASEC2N AS insEAESEC2N, insESASEC3N AS insEAESEC3N, insESASEC4N AS insEAESEC4N, + $stmt = $this->conn->executeQuery("SELECT LPAD(insSIREN,9,0) AS insSIREN, LPAD(insNIC,5,0) AS insNIC, + insL4_VOIE, insL6_POST, LPAD(insRPET,2,0) AS insRPET, insDEPCOMEN, LPAD(insRPEN,2,0) AS insRPEN, + insARRONET, insCTONET, insTCD, LPAD(insZEMET,2,0) AS insZEMET, insDU, insTU, + LPAD(insUU,2,0) AS insUU, insAMINTRET, insAMINTREN, insVMAJ, insVMAJ1, insVMAJ2, + insVMAJ3, '' AS insRECME, '' AS insEAEANT, '' AS insEAEAPET, '' AS insEAESEC1T, '' AS insEAESEC2T, + insESAANN AS insEAEANN, insESAPEN AS insEAEAPEN, insESASEC1N AS insEAESEC1N, + insESASEC2N AS insEAESEC2N, insESASEC3N AS insEAESEC3N, insESASEC4N AS insEAESEC4N, dateInsert AS dateNotice FROM insee.insee_even WHERE insSIREN=$siren AND insNIC=$nic ORDER BY dateNotice DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { return $stmt->fetch(\PDO::FETCH_ASSOC); @@ -6719,11 +6717,11 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } try { - $stmt = $this->conn->executeQuery("SELECT id, siren, nic, enActif, etActif, procol, nom, nom2, - sigle, enseigne, adrNum, adrBtq, adrTypVoie, adrLibVoie, ville, cp, adrComp, adrDistSp, - cj, apen, apet, nbEntrep, dateInsert, dateUpdate FROM jo.tabAdrDom - WHERE adrNum=$num AND adrBtq='$indRep' AND adrTypVoie LIKE '%$typeVoie%' AND - adrLibVoie LIKE '%$libVoie%' AND cp=$cp $strAdrActive GROUP BY siren ORDER BY enActif DESC"); + $stmt = $this->conn->executeQuery("SELECT id, siren, nic, enActif, etActif, procol, nom, nom2, + sigle, enseigne, adrNum, adrBtq, adrTypVoie, adrLibVoie, ville, cp, adrComp, adrDistSp, + cj, apen, apet, nbEntrep, dateInsert, dateUpdate FROM jo.tabAdrDom + WHERE adrNum=$num AND adrBtq='$indRep' AND adrTypVoie LIKE '%$typeVoie%' AND + adrLibVoie LIKE '%$libVoie%' AND cp=$cp $strAdrActive GROUP BY siren ORDER BY enActif DESC"); if ($stmt->rowCount() > 0) { return $stmt->fetchAll(\PDO::FETCH_ASSOC); } @@ -6777,8 +6775,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $tabRet['L6_POST'] = $tabNotice['L6_POST']; } - $stmt = $this->conn->executeQuery("SELECT NOM2, ADR_COMP, ADR_DISTSP, PAYS - FROM insee.identite WHERE SIREN=$siren AND NIC=$nic"); + $stmt = $this->conn->executeQuery("SELECT NOM2, ADR_COMP, ADR_DISTSP, PAYS + FROM insee.identite WHERE SIREN=$siren AND NIC=$nic"); if ($stmt->rowCount() > 0) { $tabIdentite = $stmt->fetch(\PDO::FETCH_ASSOC); if ($tabIdentite['NOM2'] != '' && $tabIdentite['NOM2'] != $tabRet['L2_NOM2']) { @@ -6798,10 +6796,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table //Cedexa if ($cedexa = 1) { try { - $stmt = $this->conn->executeQuery("SELECT contrat, hexavia, codePostal, l1_nom, l2_nomComp, - l3_compGeo, l4_numVoie, l4_indRep, l4_libVoie, l5_distrib, l5_numMS, l5_libCom, - l6_codCedex, l6_achCedex, codeInsee, actif, dateFlux, dateInsert, dateUpdate - FROM insee.cedexa WHERE siren=$siren AND nic=$nic"); + $stmt = $this->conn->executeQuery("SELECT contrat, hexavia, codePostal, l1_nom, l2_nomComp, + l3_compGeo, l4_numVoie, l4_indRep, l4_libVoie, l5_distrib, l5_numMS, l5_libCom, + l6_codCedex, l6_achCedex, codeInsee, actif, dateFlux, dateInsert, dateUpdate + FROM insee.cedexa WHERE siren=$siren AND nic=$nic"); if ($stmt->rowCount() > 0) { $tabCedex = $stmt->fetch(\PDO::FETCH_ASSOC); if ($tabCedex['l2_nomComp'] != '' && $tabCedex['l2_nomComp'] != $tabRet['L2_NOM2']) { @@ -6865,13 +6863,13 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } try { - $stmt = $this->conn->executeQuery("SELECT infoTel, count(*) AS nb FROM jo.telephonie - WHERE siren=$siren AND typeTel='an8' ORDER BY nb DESC LIMIT 0,1"); + $stmt = $this->conn->executeQuery("SELECT infoTel, count(*) AS nb FROM jo.telephonie + WHERE siren=$siren AND typeTel='an8' ORDER BY nb DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $result = $stmt->fetch(\PDO::FETCH_OBJ); if ($result->nb > 0) { $an8en = $result->infoTel; - $stmt = $this->conn->executeQuery("SELECT infoTel FROM jo.telephonie + $stmt = $this->conn->executeQuery("SELECT infoTel FROM jo.telephonie WHERE siren=$siren $strNic AND typeTel='an8' ORDER BY dateProvPartenaire DESC LIMIT 0,1"); if ($stmt->rowCount() > 0) { $result = $stmt->fetch(\PDO::FETCH_OBJ); @@ -6888,8 +6886,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table // Recherche des activités réglementées possibles Naf4&5 ou An8 $actregNb = 0; try { - $stmt = $this->conn->executeQuery("SELECT id, libActivite, listeActivite, naf5, naf4, codAn8, listeCJ, nomAutorite - FROM jo.tabActivReg WHERE naf5='$naf5en' OR naf5='$naf5et' OR naf4='$naf4en' + $stmt = $this->conn->executeQuery("SELECT id, libActivite, listeActivite, naf5, naf4, codAn8, listeCJ, nomAutorite + FROM jo.tabActivReg WHERE naf5='$naf5en' OR naf5='$naf5et' OR naf4='$naf4en' OR naf4='$naf4et' OR codAn8='$an8en' OR codAn8='$an8et'"); $actregNb = $stmt->rowCount(); } catch (\Doctrine\DBAL\DBALException $e) { @@ -6970,12 +6968,12 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $limit = "LIMIT $deb, $nbRep"; try { - $stmt = $this->conn->executeQuery("SELECT 'Etab' AS Loc, e.id, e.source, e.source_id, - e.triCode, e.autre_id, e.siren, e.nic, e.siege, e.raisonSociale, e.enseigne, e.sigle, - e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, e.adr_comp, e.adr_cp, e.adr_ville, - LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, - CONCAT(e.siren, e.nic) AS siret, e.actif FROM jo.etablissements e, jo.surveillances_site s - WHERE s.login='$login' AND s.siren=e.siren AND (s.nic=e.nic OR e.siege=1) + $stmt = $this->conn->executeQuery("SELECT 'Etab' AS Loc, e.id, e.source, e.source_id, + e.triCode, e.autre_id, e.siren, e.nic, e.siege, e.raisonSociale, e.enseigne, e.sigle, + e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, e.adr_comp, e.adr_cp, e.adr_ville, + LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, + CONCAT(e.siren, e.nic) AS siret, e.actif FROM jo.etablissements e, jo.surveillances_site s + WHERE s.login='$login' AND s.siren=e.siren AND (s.nic=e.nic OR e.siege=1) AND s.ref='$refClient' ORDER BY e.siege DESC, e.actif DESC $limit"); $nbTot = $stmt->rowCount(); @@ -7060,13 +7058,13 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } else { $strNic = " AND nic=$nic"; } - $stmt = $this->conn->executeQuery("SELECT raiSoc, dateMaj, siren, nic, etatEt, dateEtatEt, - typeEtab, adresseEt0, adresseEt1, adresseEt2, adresseEt3, fj, fjLib, nafEt, nafEtLib, - effEtPeriode, effEtTr, erreurs, adresseEn0, adresseEn1, adresseEn2, adresseEn3, nafEn, - nafEnLib, effEnPeriode, effEnTr, fjEn, fjEnLib, employes, etatEn, dateEtatEn, nicSiege, - nbEtabActifs, dateInsert, dateUpdate, - DATE(IF(dateUpdate>dateInsert, dateUpdate, dateInsert))*1 AS dateMajSD - FROM insee.insee_avis WHERE siren=$siren $strNic"); + $stmt = $this->conn->executeQuery("SELECT raiSoc, dateMaj, siren, nic, etatEt, dateEtatEt, + typeEtab, adresseEt0, adresseEt1, adresseEt2, adresseEt3, fj, fjLib, nafEt, nafEtLib, + effEtPeriode, effEtTr, erreurs, adresseEn0, adresseEn1, adresseEn2, adresseEn3, nafEn, + nafEnLib, effEnPeriode, effEnTr, fjEn, fjEnLib, employes, etatEn, dateEtatEn, nicSiege, + nbEtabActifs, dateInsert, dateUpdate, + DATE(IF(dateUpdate>dateInsert, dateUpdate, dateInsert))*1 AS dateMajSD + FROM insee.insee_avis WHERE siren=$siren $strNic"); $tabInfos = $stmt->fetch(\PDO::FETCH_ASSOC); if ($tabInfos['dateMajSD'] == date('Ymd')) { $tabInfos['enCache'] = true; @@ -7098,10 +7096,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table else { $crit=''; } // établissement particulier, saisissez le NIC - /* $crit='T'; // tous les établissements de l'entreprise - $crit='T'; // tous les établissements de l'entreprise du département $dep - $crit='A'; // tous les établissements actifs de l'entreprise - $crit='A'; // tous les établissements actifs de l'entreprise du département $depActif + /* $crit='T'; // tous les établissements de l'entreprise + $crit='T'; // tous les établissements de l'entreprise du département $dep + $crit='A'; // tous les établissements actifs de l'entreprise + $crit='A'; // tous les établissements actifs de l'entreprise du département $depActif */ //Post du formulaire $url = 'http://avis-situation-sirene.insee.fr/avisitu/IdentificationListeSiret.do'; @@ -7312,8 +7310,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $dep = substr($codeCommune, 0, 3)*1; } // Recherche par NAF - $stmt = $this->conn->executeQuery("SELECT codeOPS, libInstitution, codeAnnexe, Limitations - FROM sdv1.retraiteNaf WHERE naf5='$naf5' or naf5='$naf4'"); + $stmt = $this->conn->executeQuery("SELECT codeOPS, libInstitution, codeAnnexe, Limitations + FROM sdv1.retraiteNaf WHERE naf5='$naf5' or naf5='$naf4'"); if ($stmt->rowCount() == 1) { while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $limite = $row['Limitations']; @@ -7327,8 +7325,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table } // Recherche par Département - $stmt = $this->conn->executeQuery("SELECT codeOPS, libInstitution FROM sdv1.retraiteDep - WHERE codeDep=$dep AND codeAnnexe IN ('$annexe','A','B') GROUP BY codeAnnexe ASC"); + $stmt = $this->conn->executeQuery("SELECT codeOPS, libInstitution FROM sdv1.retraiteDep + WHERE codeDep=$dep AND codeAnnexe IN ('$annexe','A','B') GROUP BY codeAnnexe ASC"); if ($stmt->rowCount() > 0) { while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { if ($row['codeOPS'] != '') { @@ -7348,8 +7346,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table public function getInfoOPS($idOPS) { $stmt = $this->conn->executeQuery( - "SELECT siren,nic,codeOPS,nomLong,nomCourt,adresse1,adresse2,cp,ville,groupe,declaration,rattachement,codeOPSdest - FROM sdv1.retraiteCaisses WHERE codeOPS='$idOPS'"); + "SELECT siren,nic,codeOPS,nomLong,nomCourt,adresse1,adresse2,cp,ville,groupe,declaration,rattachement,codeOPSdest + FROM sdv1.retraiteCaisses WHERE codeOPS='$idOPS'"); if ($stmt->rowCount()) { return $stmt->fetch(\PDO::FETCH_ASSOC); } @@ -7369,10 +7367,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $nb = 0; try { $stmt = $this->conn->executeQuery( - "SELECT insSIREN, insNIC, insDATEVE, insEVE, insAPET700, insSIEGE, insLIBCOM, insL1_NOMEN, - insL2_COMP, insL4_VOIE, insL3_CADR, insL5_DISP, insL6_POST, insCODPOS, insL7_ETRG, insDEPCOM, - insCODEVOIE, insNICTRAN, insSIRETPS, insDATEMAJ, idFlux, insSIRETASS, insEVE, insDESTINAT, insTYPETAB, insORIGINE - FROM insee.insee_even WHERE insSIREN=$siren AND insNIC=$nic AND insMNICSIEGE=1 ORDER BY insDATEVE DESC LIMIT 0,1"); + "SELECT insSIREN, insNIC, insDATEVE, insEVE, insAPET700, insSIEGE, insLIBCOM, insL1_NOMEN, + insL2_COMP, insL4_VOIE, insL3_CADR, insL5_DISP, insL6_POST, insCODPOS, insL7_ETRG, insDEPCOM, + insCODEVOIE, insNICTRAN, insSIRETPS, insDATEMAJ, idFlux, insSIRETASS, insEVE, insDESTINAT, insTYPETAB, insORIGINE + FROM insee.insee_even WHERE insSIREN=$siren AND insNIC=$nic AND insMNICSIEGE=1 ORDER BY insDATEVE DESC LIMIT 0,1"); $nb = $stmt->rowCount(); } catch (\Doctrine\DBAL\DBALException $e) { if ($this->logger !== null) { @@ -7405,16 +7403,16 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $nb = 0; try { - $stmt = $this->conn->executeQuery("SELECT LPAD(insSIREN,9,0) AS insSIREN, LPAD(insNIC,5,0) AS insNIC, - insDATEVE, insEVE, insAPET700, insSIEGE, insLIBCOM, insL1_NOMEN, insL2_COMP, insL4_VOIE, - insL3_CADR, insL5_DISP, insL6_POST, insCODPOS, insL7_ETRG, insDEPCOM, insCODEVOIE, - insNICTRAN, insSIRETPS, insDATEMAJ, idFlux, insSIRETASS, insDESTINAT, insTYPETAB, - insORIGINE, insTRAN, insNOMEN, insENSEIGNE, insNUMVOIE, insINDREP, insTYPVOIE, - insLIBVOIE, sirVersion FROM insee.insee_even WHERE insSIREN=$siren AND insNIC!=$nic AND - (insEVE IN ('510','520','530','540', 'CTS','CTE','STS','STE','MTDS','MTDE','MTAS','MTAE') OR insEVE LIKE 'T%') - AND insDATEMAJ IN ( - SELECT insDATEMAJ FROM insee.insee_even WHERE insSIREN=$siren AND insNIC=$nic AND - (insEVE IN ('510','520','530','540', 'CTS','CTE','STS','STE','MTDS','MTDE','MTAS','MTAE') OR insEVE LIKE 'T%') + $stmt = $this->conn->executeQuery("SELECT LPAD(insSIREN,9,0) AS insSIREN, LPAD(insNIC,5,0) AS insNIC, + insDATEVE, insEVE, insAPET700, insSIEGE, insLIBCOM, insL1_NOMEN, insL2_COMP, insL4_VOIE, + insL3_CADR, insL5_DISP, insL6_POST, insCODPOS, insL7_ETRG, insDEPCOM, insCODEVOIE, + insNICTRAN, insSIRETPS, insDATEMAJ, idFlux, insSIRETASS, insDESTINAT, insTYPETAB, + insORIGINE, insTRAN, insNOMEN, insENSEIGNE, insNUMVOIE, insINDREP, insTYPVOIE, + insLIBVOIE, sirVersion FROM insee.insee_even WHERE insSIREN=$siren AND insNIC!=$nic AND + (insEVE IN ('510','520','530','540', 'CTS','CTE','STS','STE','MTDS','MTDE','MTAS','MTAE') OR insEVE LIKE 'T%') + AND insDATEMAJ IN ( + SELECT insDATEMAJ FROM insee.insee_even WHERE insSIREN=$siren AND insNIC=$nic AND + (insEVE IN ('510','520','530','540', 'CTS','CTE','STS','STE','MTDS','MTDE','MTAS','MTAE') OR insEVE LIKE 'T%') )"); $nb = $stmt->rowCount(); } catch (\Doctrine\DBAL\DBALException $e) { @@ -7620,8 +7618,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $rivoliNb = 0; try { $stmt = $this->conn->executeQuery("SELECT codeInsee, codeIris, rivoli, typVoie, - libVoie, typeNum, numd,indd, numf, indf, codeInseeIris - FROM insee.iris WHERE codeInsee='$codeCommune' + libVoie, typeNum, numd,indd, numf, indf, codeInseeIris + FROM insee.iris WHERE codeInsee='$codeCommune' AND libVoie LIKE '$adrLibVoie2%' GROUP BY codeInsee, rivoli"); $rivoliNb = $stmt->rowCount(); } catch (\Doctrine\DBAL\DBALException $e) { @@ -7647,7 +7645,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $adrNum = intval($adrNum); $rivoliNb = 0; try { - $stmt = $this->conn->executeQuery("SELECT codeInsee, codeIris, rivoli, codeInseeIris + $stmt = $this->conn->executeQuery("SELECT codeInsee, codeIris, rivoli, codeInseeIris FROM insee.iris WHERE codeInsee='$codeCommune' AND rivoli LIKE '$codeRivoli%' GROUP BY codeInseeIris"); } catch (\Doctrine\DBAL\DBALException $e) { if ($this->logger !== null) { @@ -7665,8 +7663,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $strAdr = "AND typeNum=2 AND $adrNum BETWEEN numd AND numf "; } - $stmt2 = $this->conn->executeQuery("SELECT codeInsee, codeIris, rivoli, codeInseeIris, numd, indd, numf, indf - FROM insee.iris WHERE codeInsee='$codeCommune' AND rivoli LIKE '$codeRivoli%' $strAdr GROUP BY codeInseeIris"); + $stmt2 = $this->conn->executeQuery("SELECT codeInsee, codeIris, rivoli, codeInseeIris, numd, indd, numf, indf + FROM insee.iris WHERE codeInsee='$codeCommune' AND rivoli LIKE '$codeRivoli%' $strAdr GROUP BY codeInseeIris"); if ($stmt2->rowCount() == 1) { $result = $stmt2->fetch(\PDO::FETCH_ASSOC); } elseif ($stmt2->rowCount() > 1 && $codeRivoli != '') { @@ -7702,8 +7700,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table if ($result !== null || $codeRivoli == '') { $codeIris = $result['codeIris']; $codeComIris = $result['codeInseeIris']; - $stmt = $this->conn->executeQuery("SELECT CODE_IRIS AS codeInseeIris, SUBSTRING(CODE_IRIS,6,4) AS codeIris, LIB_IRIS, TYP_IRIS, MODIF_IRIS, TRIRIS, GRD_QUART - FROM insee.insee_tabIris WHERE DEPCOM='$codeCommune' AND (TYP_IRIS='Z' OR CODE_IRIS='$codeComIris')"); + $stmt = $this->conn->executeQuery("SELECT CODE_IRIS AS codeInseeIris, SUBSTRING(CODE_IRIS,6,4) AS codeIris, LIB_IRIS, TYP_IRIS, MODIF_IRIS, TRIRIS, GRD_QUART + FROM insee.insee_tabIris WHERE DEPCOM='$codeCommune' AND (TYP_IRIS='Z' OR CODE_IRIS='$codeComIris')"); if ($stmt->rowCount() > 0) { $row = $stmt->fetch(\PDO::FETCH_ASSOC); return array( @@ -7788,10 +7786,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table { $nb = 0; try { - $stmt = $this->conn->prepare("SELECT id, naf5, annee, SUM(montant), SUM(nombre), SUM(montant)/SUM(nombre) AS moyenne - FROM jo.ratios_secteurs WHERE naf5=:naf AND id=267 AND ANNEE > ( - SELECT MAX(annee) FROM jo.ratios_secteurs WHERE naf5=:naf AND id=267 - )-2 GROUP BY id, naf5"); + $stmt = $this->conn->prepare("SELECT id, naf5, annee, SUM(montant), SUM(nombre), SUM(montant)/SUM(nombre) AS moyenne + FROM jo.ratios_secteurs WHERE naf5=:naf AND id=267 AND ANNEE > ( + SELECT MAX(annee) FROM jo.ratios_secteurs WHERE naf5=:naf AND id=267 + )-2 GROUP BY id, naf5"); $stmt->bindValue('naf', $naf); $stmt->execute(); $nb = $stmt->rowCount(); @@ -7857,8 +7855,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table $nb = 0; try { - $stmt = $this->conn->executeQuery("SELECT codComInsee, idVoieCom, cleRivoli, voieNature, voieLib, 1 AS score - FROM insee.fantoirVoi WHERE codComInsee='$codeCommune' $strTypesVoies AND voieLib='$adrLibVoie2'"); + $stmt = $this->conn->executeQuery("SELECT codComInsee, idVoieCom, cleRivoli, voieNature, voieLib, 1 AS score + FROM insee.fantoirVoi WHERE codComInsee='$codeCommune' $strTypesVoies AND voieLib='$adrLibVoie2'"); } catch (\Doctrine\DBAL\DBALException $e) { if ($this->logger !== null) { $this->logger->error($e->getMessage());