extranet/includes/annonces/annonces.php

388 lines
9.5 KiB
PHP
Raw Normal View History

2010-09-29 15:03:33 +00:00
<?php
2011-04-05 07:16:07 +00:00
require_once 'common/dates.php';
2010-09-29 15:03:33 +00:00
2011-04-05 07:16:07 +00:00
/**
*
* Enter description here ...
* @author mricois
*
*/
2010-09-29 15:03:33 +00:00
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) {
2010-09-29 15:03:33 +00:00
$this->annonces = $annonces;
$this->triAnnonces();
2011-08-25 10:38:17 +00:00
krsort($this->annoncesBodacc);
krsort($this->annoncesBalo);
krsort($this->annoncesAsso);
krsort($this->annoncesBomp);
}
2010-09-29 15:03:33 +00:00
}
2011-08-25 10:38:17 +00:00
2011-04-05 07:16:07 +00:00
/**
* Enter description here ...
* @param unknown_type $ann
*/
public function getAnnonceDesc($ann)
2010-09-29 15:03:33 +00:00
{
2011-04-29 09:31:06 +00:00
if ($this->isBalo($ann['BodaccCode'])) {
return 'BALO n&deg;'.$ann['BodaccNum'].' du '.
$this->dateAnnonce($ann['DateParution']).'.';
2011-04-29 09:31:06 +00:00
} elseif ($this->isAsso($ann['BodaccCode'])) {
return 'J.O. ASSOCIATION n&deg;'.$ann['BodaccNum'].' du '.
$this->dateAnnonce($ann['DateParution']).'.';
} elseif ($this->isBomp($ann['BodaccCode'])){
return 'Annonce n&deg;'.$ann['NumAnnonce'] . '. ' .
'Source ' . $ann['BodaccCode'] . ' ' .
'n&deg;' . ($ann['BodaccNum']*1) . ' ' .
' du '.$this->dateAnnonce($ann['DateParution']).
'. D&eacute;partement n&deg;'.$ann['Departement'].'.';
} else {
$tabSource = explode('-', $ann['BodaccCode']);
$source = $tabSource[0];
$idSource = $tabSource[1];
if ($source[0] == 'B') {
$logo = 'img/logo_jo.png';
if ($ann['BodaccNum']==0){
$libelle = 'Source BODACC '.substr($ann['BodaccCode'],-1).
' du '.$this->dateAnnonce($ann['DateParution']);
} else {
$libelle = 'Source BODACC n&deg;'.$ann['BodaccNum'].'&nbsp;'.
substr($ann['BodaccCode'],-1).
' du '.$this->dateAnnonce($ann['DateParution']).
'. D&eacute;partement n&deg;'.$ann['Departement'].
'. <a href="/?page=competences&siret='.
$_SESSION['tabInfo']['entrep']['siret'].
'&type=tri">'.$ann['Tribunal'].'</a>';
}
2011-04-29 09:31:06 +00:00
} elseif ($source[0] == 'G' || $source[0] == 'T') {
$logo = './img/logo_greffe.png';
$libelle = 'Source Greffe du Tribunal';
2011-04-29 09:31:06 +00:00
} elseif ($source[0] == 'P') {
$logo = './img/logo_inpi.png';
$libelle = 'Source Registre National du Commerce';
2011-04-29 09:31:06 +00:00
} else {
$logo = './img/logo_jal.png';
$libelle = '';
if( hasModeEdition() &&
(substr($source,0,2)=='JT' || $source=='ANTE') ){
$libelle = '<b>Source TESSI</b> - ';
}
$libelle.= 'Source Journal Annonces L&eacute;gales';
}
return '<img src="'.$logo.'" /> '.$libelle.'.';
2010-09-29 15:03:33 +00:00
}
}
2011-04-05 07:16:07 +00:00
/**
*
* Enter description here ...
* @param unknown_type $ann
*/
public function getAnnonceEntree($ann)
{
2011-04-29 09:31:06 +00:00
if ($this->isBalo($ann['BodaccCode'])) {
return 'Entr&eacute; n&deg;'.$ann['NumAnnonce'].'.';
} elseif ($this->isAsso($ann['BodaccCode'])) {
2010-09-29 15:03:33 +00:00
return 'Annonce n&deg;'.$ann['NumAnnonce'].'.';
} elseif ($this->isBomp($ann['BodaccCode'])){
return '';
2011-04-29 09:31:06 +00:00
} else {
2011-04-29 09:31:06 +00:00
if ($ann['dateInsertionSD']!='') {
return ' - Entr&eacute;e en base : '.
$this->dateAnnonce($ann['dateInsertionSD']);
}
2010-09-29 15:03:33 +00:00
}
}
2011-04-05 07:16:07 +00:00
/**
*
* Enter description here ...
* @param unknown_type $ann
*/
public function getAnnonceEntreeSD($ann)
{
if ($this->isBodacc($ann['BodaccCode'])) {
} elseif ($this->isBalo($ann['BodaccCode'])) {
2010-09-29 15:03:33 +00:00
return 'Entr&eacute;e en base S&amp;D : '.
$this->dateAnnonce($ann['dateInsertionSD']).'.';
} elseif ($this->isAsso($ann['BodaccCode'])) {
2010-09-29 15:03:33 +00:00
return 'Entr&eacute;e en base S&amp;D : '.
$this->dateAnnonce($ann['dateInsertionSD']).'.';
} elseif ($this->isBomp($ann['BodaccCode'])){
return '';
} else {
2010-09-29 15:03:33 +00:00
}
}
2011-04-05 07:16:07 +00:00
/**
*
* Enter description here ...
* @param unknown_type $ann
*/
public function getAnnonceEven($ann)
2010-09-29 15:03:33 +00:00
{
$output = '';
foreach ($ann['evenements'] as $i=>$even) {
$output.= $even['LibEven'].'<br/>';
}
return $output;
}
2011-04-05 07:16:07 +00:00
/**
*
* Enter description here ...
* @param unknown_type $ann
*/
public function getAnnonceTexte($ann)
{
$pattern = "/((?:[0-9]{9,9})|(?:[0-9]{3,3} [0-9]{3,3} [0-9]{3,3})|(?:[0-9]{3,3}\.[0-9]{3,3}\.[0-9]{3,3})|(?:[0-9]{3,3}-[0-9]{3,3}-[0-9]{3,3}))/";
return preg_replace_callback($pattern, 'replace_siren', $ann['texteAnnonce']);
2010-09-29 15:03:33 +00:00
}
2011-04-05 07:16:07 +00:00
/**
*
* Enter description here ...
* @param unknown_type $ann
*/
2010-09-29 15:03:33 +00:00
public function getAnnonceResume($ann)
{
return array(
'date' => $this->dateAnnonce($ann['DateParution']),
'logo' => $this->logoAnnonce($ann),
'href' => $this->hrefAnnonce($ann),
'lib' => $this->libAnnonce($ann)
);
}
2011-04-05 07:16:07 +00:00
/**
*
* Enter description here ...
* @param unknown_type $ann
*/
2010-09-29 15:03:33 +00:00
protected function hrefAnnonce($ann)
{
$href = false;
if ($this->isBodacc($ann['BodaccCode'])) {
2010-09-29 15:03:33 +00:00
$href = 'idan='.$ann['id'].'&vue=bodacc';
} elseif ($this->isBalo($ann['BodaccCode'])) {
$href = 'idan='.$ann['id'].'&vue=balo';
} elseif ($this->isAsso($ann['BodaccCode'])) {
$href = 'idan='.$ann['id'].'&vue=asso';
} elseif ($this->isBomp($ann['BodaccCode'])){
$href = 'idan='.$ann['id'].'&vue=bomp';
} else {
$href = 'idan='.$ann['id'].'&vue=bodacc';
}
return $href;
}
/**
* Retourne une date formatté
2011-04-05 07:16:07 +00:00
* @param string $date
*/
2010-09-29 15:03:33 +00:00
protected function dateAnnonce($date)
{
return WDate::dateT('Y-m-d', 'd/m/Y', $date);
}
/**
* logoAnnonce
2011-04-05 07:16:07 +00:00
* @param array $ann
*/
2010-09-29 15:03:33 +00:00
protected function logoAnnonce($ann)
{
$src = '';
$title = '';
if ($this->isBalo($ann['BodaccCode']))
2010-09-29 15:03:33 +00:00
{
$src = './img/logo_jo.png';
$title = 'Source BALO n°'.$ann['BodaccNum'];
}
elseif ($this->isAsso($ann['BodaccCode']))
2010-09-29 15:03:33 +00:00
{
$src = './img/logo_jo.png';
$title = 'Source JO ASSOCIATION n°'.$ann['BodaccNum'];
}
elseif ($this->isBomp($ann['BodaccCode']))
{
$src = './img/logo_jo.png';
if ($ann['BodaccCode'] == 'MAPA' ){
$title = 'Source '.$ann['BodaccCode'] . ' ' .
($ann['BodaccNum']*1);
}else {
$title = 'Source '.$ann['BodaccCode'] . ' ' .
'n&deg;' . ($ann['BodaccNum']*1) . ' de ' .
substr($ann['DateParution'],0,4);
}
}
2010-09-29 15:03:33 +00:00
else
{
$tabSource = explode('-', $ann['BodaccCode']);
$source = $tabSource[0];
$idSource = $tabSource[1];
if ($source[0] == 'B')
{
$src = './img/logo_jo.png';
$title = 'Source BODACC ' . $ann['BodaccNum'] . ' ' .
substr($source,-1) . ' ' .
'de ' . substr($ann['DateParution'],0,4);
2010-09-29 15:03:33 +00:00
}
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 ($idSource>0) $title.= ' '.$idSource;
}
}
if ($src != '') {
return '<img src="'.$src.'" title="'.$title.'">';
} else {
return false;
}
}
/**
* Retourne le libellé de l'annonce
2011-04-05 07:16:07 +00:00
* @param array $ann
*/
2010-09-29 15:03:33 +00:00
protected function libAnnonce($ann)
{
$lib = '';
foreach ($ann['evenements'] as $i=>$even) {
$lib.= $even['LibEven'];
$tabSource = explode('-', $ann['BodaccCode']);
$source = $tabSource[0];
$idSource = $tabSource[1];
$numEven = $even['CodeEven']*1;
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' || $source=='ANTE')) {
2010-09-29 15:03:33 +00:00
$lib.= ' - <b>(Source TESSI)</b>';
}
$lib.= '<br/>';
}
return $lib;
}
/**
* Tri les annonces en fonction de la source
*/
2010-09-29 15:03:33 +00:00
protected function triAnnonces()
{
foreach ($this->annonces as $i => $ann)
{
2011-08-25 10:12:36 +00:00
//Génération id pour tri par date.
$id = $ann['DateParution'].':'.$ann['id'];
2010-09-29 15:03:33 +00:00
if ($this->isBodacc($ann['BodaccCode'])){
2011-08-25 10:12:36 +00:00
$this->annoncesBodacc[$id] = $ann;
2010-09-29 15:03:33 +00:00
} elseif ($this->isBalo($ann['BodaccCode'])) {
$ann['texteAnnonce'] = utf8_decode($ann['texteAnnonce']);
2011-08-25 10:12:36 +00:00
$this->annoncesBalo[$id] = $ann;
2010-09-29 15:03:33 +00:00
} elseif ($this->isAsso($ann['BodaccCode'])) {
2011-08-25 10:12:36 +00:00
$this->annoncesAsso[$id] = $ann;
2010-09-29 15:03:33 +00:00
} elseif ($this->isBomp($ann['BodaccCode'])){
2011-08-25 10:12:36 +00:00
$this->annoncesBomp[$id] = $ann;
2010-09-29 15:03:33 +00:00
} else {
2011-08-25 10:12:36 +00:00
$this->annoncesBodacc[$id] = $ann;
2010-09-29 15:03:33 +00:00
}
}
}
/**
* Détermine si l'annonce est une annonce BODACC
* @param string $code
*/
2010-09-29 15:03:33 +00:00
protected function isBodacc($code)
{
if (in_array($code, array('BODA', 'BODB', 'BODC'))){
return true;
} else {
return false;
}
}
/**
* Détermine si l'annonce est une annonce BALO
* @param string $code
*/
2010-09-29 15:03:33 +00:00
protected function isBalo($code)
{
if ($code == 'BALO'){
return true;
} else {
return false;
}
}
/**
* Détermine si l'annonce est une annonce ASSO
* @param string $code
*/
2010-09-29 15:03:33 +00:00
protected function isAsso($code)
{
if ($code == 'ASSO'){
return true;
} else {
return false;
}
}
/**
* Détermine si l'annonce est une annonce BOAMP
* @param string $code
*/
2010-09-29 15:03:33 +00:00
protected function isBomp($code)
{
if (in_array($code, array('BOMP A', 'BOMP B', 'BOMP C', 'MAPA'))){
return true;
} else {
return false;
}
}
}