0) { $objAnnonces = new Annonces($annonces->liste->item); $typeAnnonces = array('Bodacc' => 'EVÉNEMENTS LÉGAUX', 'Balo' => 'BALO', 'Bomp' => 'Marchés publics', 'Asso' => 'Associations'); foreach ($typeAnnonces as $type => $titre) { $classType = 'annonces'.$type; if (count($objAnnonces->$classType) > 0) { print '

'.$titre.'

'; print ''; foreach ($objAnnonces->$classType as $ann) { $resume = $objAnnonces->getAnnonceResume($ann); print ''; print ''; print ''; print ''; print ''; } print '
 '; print 'Le '.$resume['date']. ' '; print ''.$resume['logo'].''; print ''; print ''; print $resume['lib']; print ''; print '
'; } } } else { // Aucune annonce bodacc pour cette entreprise print '

Evénements légaux

'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
  '. 'Néant
 
'; } } // -------------------------------------------------------------------------- // // class Annonces // -------------------------------------------------------------------------- // class Annonces { public $annoncesBodacc = array(); public $annoncesBalo = array(); public $annoncesAsso = array(); public $annoncesBomp = array(); protected $annonces; public function __construct($annonces = array()) { if (is_array($annonces) && count($annonces) > 0) { $this->annonces = $annonces; $this->triAnnonces(); } } public function getAnnonceResume($ann) { return array('date' => $this->dateAnnonce($ann->DateParution), 'logo' => $this->logoAnnonce($ann), 'href' => $this->hrefAnnonce($ann), 'lib' => $this->libAnnonce($ann)); } protected function hrefAnnonce($ann) { $href = false; if ($this->isBodacc($ann->BodaccCode)){ $href = 'idan='.$ann->id.'&vue=bodacc'; } else if ($this->isBalo($ann->BodaccCode)) { $href = 'idan='.$ann->id.'&vue=balo'; } else if ($this->isAsso($ann->BodaccCode)) { $href = 'idan='.$ann->id.'&vue=asso'; } else if ($this->isBomp($ann->BodaccCode)) { $href = 'idan='.$ann->id.'&vue=bomp'; } else { $href = 'idan='.$ann->id.'&vue=bodacc'; } return $href; } protected function dateAnnonce($date) { $wdate = new WDate; return $wdate->dateT('Y-m-d', 'd/m/Y', $date); } protected function logoAnnonce($ann) { $src = ''; $title = ''; if ($this->isBalo($ann->BodaccCode)) { $src = './img/logo_jo.png'; $title = 'Source BALO n°'.$ann->BodaccNum; } else if ($this->isAsso($ann->BodaccCode)) { $src = './img/logo_jo.png'; $title = 'Source JO ASSOCIATION n°'.$ann['BodaccNum']; } else if ($this->isBomp($ann->BodaccCode)) { $src = './img/logo_jo.png'; if ($ann->BodaccCode == 'MAPA') { $title = 'Source '.$ann->BodaccCode.' '. intval($ann->BodaccNum); } else { $title = 'Source '.$ann->BodaccCode.' '. 'n°'.intval($ann->BodaccNum).' de '. substr($ann->DateParution, 0, 4); } } else { $tabSource = explode('-', $ann->BodaccCode); $source = $tabSource[0]; if ($source[0] == 'B') { $src = './img/logo_jo.png'; $title = 'Source BODACC '.$ann->BodaccNum.' '. substr($source, -1).' de ' . substr($ann->DateParution, 0, 4); } else if ($source[0] == 'G' || $source[0] == 'T') { $src = './img/logo_greffe.png'; $title = 'Source Collecte Greffe'; } else if ($source[0] == 'P') { $src = './img/logo_inpi.png'; $title = 'Source Collecte RNCS'; } else { $src = './img/logo_jal.png'; $title = 'Source Collecte JAL'; if (isset($tabSource[1]) && $tabSource[1] > 0) { $title .= ' '.$tabSource[1]; } } } if ($src != '') { return ''; } else { return false; } } protected function libAnnonce($ann) { $wdate = new WDate; $lib = ''; foreach ($ann->evenements->item as $even) { $lib .= $even->LibEven; $tabSource = explode('-', $ann->BodaccCode); $source = $tabSource[0]; $numEven = intval($even->CodeEven); if ($numEven > 3000 && $numEven < 3999) { if (isset($ann->dateEffet)) { $lib .= ' (clôture au '. $wdate->dateT('Y-m-d','d/m/Y', $ann->dateEffet).')'; } } if (hasModeEdition() && substr($source, 0, 2) == 'JT') { $lib .= ' - (Source TESSI)'; } $lib .= '
'; } return $lib; } protected function triAnnonces() { foreach ($this->annonces as $ann) { if ($this->isBodacc($ann->BodaccCode)){ $this->annoncesBodacc[] = $ann; } elseif ($this->isBalo($ann->BodaccCode)) { $this->annoncesBalo[] = $ann; } elseif ($this->isAsso($ann->BodaccCode)) { $this->annoncesAsso[] = $ann; } elseif ($this->isBomp($ann->BodaccCode)) { $this->annoncesBomp[] = $ann; } else { $this->annoncesBodacc[] = $ann; } } } protected function isBodacc($code) { return in_array($code, array('BODA', 'BODB', 'BODC')); } protected function isBalo($code) { return ($code == 'BALO'); } protected function isAsso($code) { return ($code == 'ASSO'); } protected function isBomp($code) { return in_array($code, array('BOMP A', 'BOMP B', 'BOMP C', 'MAPA')); } }