Filtre sur les annonces en sorties de getAnnoncesLegales

This commit is contained in:
Michael RICOIS 2015-08-24 19:43:55 +00:00
parent cc891e2077
commit f42f84222a

View File

@ -4289,7 +4289,8 @@ class MInsee
/**
* Parse les annonces légales pour déterminer leur rubrique
* plus rapide d'executer sur la liste des annonces légales que d'executer les requetes SQL
* @param mixed $type
* @param array $annonces Annonces au format BDD
* @param mixed $rubrique
* @return array
* Retourne une liste filtrer suivant la/les rubriques
*/
@ -4304,28 +4305,42 @@ class MInsee
$typeEven = explode(' ', $ann['typeEven']);
// Procédure collective
if ($rubrique=='P' || $rubrique=='PH') {
$evenOk = true;
foreach($typeEven as $even) {
if ($ann['Rubrique'] == 'procol'
&& !in_array($even, array('1005','1010','1050','1055','1550'))) {
$annonceFilter[] = $ann;
}
if (in_array($even, array('1005','1010','1050','1055','1550'))) {
$evenOk = false;
break;
}
}
if ($ann['Rubrique'] == 'procol' && $evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Dissolution de la société
elseif ($rubrique=='D') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('2202','2203','2204','2210','2211','2212'))) {
$annonceFilter[] = $ann;
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Absorption
elseif ($rubrique=='A') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('2720','2721'))) {
$annonceFilter[] = $ann;
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
// BODACC A
elseif ($rubrique=='BODA') {
@ -4341,52 +4356,77 @@ class MInsee
}
// Dépôt des comptes, BODACC C
elseif ($rubrique=='C' || $rubrique=='BODC') {
$evenOk = false;
foreach($typeEven as $even) {
if ($ann['Rubrique'] == 'comptes'
|| in_array($even, array('3100','3200','3300','3999'))) {
$annonceFilter[] = $ann;
}
if (in_array($even, array('3100','3200','3300','3999'))) {
$evenOk = true;
break;
}
}
if ($ann['Rubrique'] == 'comptes' || $evenOk === true) {
$annonceFilter[] = $ann;
}
} elseif ($rubrique=='R') {
$evenOk = false;
foreach($typeEven as $even) {
if ($ann['Rubrique'] == 'radiations'
|| in_array($even, array('2202','2203','2204','2210','2211','2212'))) {
$annonceFilter[] = $ann;
}
if (in_array($even, array('2202','2203','2204','2210','2211','2212'))) {
$evenOk = true;
break;
}
}
if ($ann['Rubrique'] == 'radiations' || $evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Location gérance Locataire
elseif ($rubrique=='L') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('2800','2875','2880','2881','2885','2840','4355'))) {
$annonceFilter[] = $ann;
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Location gérance Propriétaire
elseif ($rubrique=='G') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('2850','2851','2860','2870'))) {
$annonceFilter[] = $ann;
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Ventes/Cessions
elseif ($rubrique=='V') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('5500','5501','5502','5503','5510','5600','5650'))) {
$annonceFilter[] = $ann;
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
} elseif (is_array($rubrique) && count($rubrique) > 0) {
foreach ($rubrique as $codeEven) {
$tabTmp[] = $codeEven;
}
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, $tabTmp)) {
$annonceFilter[] = $ann;
if (in_array($even, $rubrique)) {
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
}
@ -4494,11 +4534,8 @@ class MInsee
$annonceFilter[] = $ann;
}
} elseif (is_array($rubrique) && count($rubrique)>0) {
foreach ($rubrique as $codeEven) {
$tabTmp[] = $codeEven;
}
foreach($typeEven as $even) {
if (in_array($even, $tabTmp)) {
if (in_array($even, $rubrique)) {
$annonceFilter[] = $ann;
}
}
@ -4510,6 +4547,153 @@ class MInsee
return $annonceFilter;
}
/**
* Tri les annonces de la fonction getAnnoncesLegales
* @param array $annonces
* @param mixed $rubrique
* @return array
*/
public function annoncesFilter($annonces, $rubrique)
{
$annonceFilter = array();
foreach ($annonces as $ann) {
$typeEven = array();
foreach ($ann['evenements'] as $item) {
$typeEven[] = $item['CodeEven'];
}
// Procédure collective
if ($rubrique=='P' || $rubrique=='PH') {
$evenOk = true;
foreach($typeEven as $even) {
if (in_array($even, array('1005','1010','1050','1055','1550'))) {
$evenOk = false;
break;
}
}
if ($ann['Rubrique'] == 'procol' && $evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Dissolution de la société
elseif ($rubrique=='D') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('2202','2203','2204','2210','2211','2212'))) {
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Absorption
elseif ($rubrique=='A') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('2720','2721'))) {
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
// BODACC A
elseif ($rubrique=='BODA') {
if (in_array($ann['Rubrique'], array('creations', 'procol', 'ventes'))) {
$annonceFilter[] = $ann;
}
}
// BODACC B
elseif ($rubrique=='BODB') {
if (in_array($ann['Rubrique'], array('mmd', 'radiations'))) {
$annonceFilter[] = $ann;
}
}
// Dépôt des comptes, BODACC C
elseif ($rubrique=='C' || $rubrique=='BODC') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('3100','3200','3300','3999'))) {
$evenOk = true;
break;
}
}
if ($ann['Rubrique'] == 'comptes' || $evenOk === true) {
$annonceFilter[] = $ann;
}
} elseif ($rubrique=='R') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('2202','2203','2204','2210','2211','2212'))) {
$evenOk = true;
break;
}
}
if ($ann['Rubrique'] == 'radiations' || $evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Location gérance Locataire
elseif ($rubrique=='L') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('2800','2875','2880','2881','2885','2840','4355'))) {
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Location gérance Propriétaire
elseif ($rubrique=='G') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('2850','2851','2860','2870'))) {
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
// Ventes/Cessions
elseif ($rubrique=='V') {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, array('5500','5501','5502','5503','5510','5600','5650'))) {
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
} elseif (is_array($rubrique) && count($rubrique) > 0) {
$evenOk = false;
foreach($typeEven as $even) {
if (in_array($even, $rubrique)) {
$evenOk = true;
break;
}
}
if ($evenOk === true) {
$annonceFilter[] = $ann;
}
}
}
return $annonceFilter;
}
/**
* Analyse les annonces légales pour déterminer si en plan
* @param string $type Type d'annonce bodacc|histo|annonces