Add pagination

This commit is contained in:
Michael RICOIS 2012-06-18 10:28:35 +00:00
parent 94178db172
commit b171ffcffa

View File

@ -1111,28 +1111,24 @@ class Entreprise extends WsScore
/**
* Retourne les annonces légales
* @param string $siren
* @param int $filtre
* @param string $idAnn
* @param int $position
* @param int $nbRep
* @return AnnoncesReturn
*/
public function getAnnoncesLegales($siren, $filtre = 1, $idAnn = null, $position = 0, $nbRep = 20)
public function getAnnoncesLegales($siren, $idAnn = null, $position = 0, $nbRep = 20)
{
$this->authenticate();
//Initialisation
if (empty($filtre)) { $filtre = 1; }
if (empty($idAnn)) { $idAnn = ''; }
if (empty($idAnn)) { $idAnn = null; }
if (empty($position)) { $position = 0; }
if (empty($nbRep)) { $nbRep = 100; }
//Valeur max
if($nbRep > 200) { $nbRep = 200; }
debugLog('I',"Annonces demandées pour $siren ($filtre, $idAnn)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$liste = array();
debugLog('I',"Annonces demandées pour $siren ($idAnn)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
if (strlen($siren)<>9) {
debugLog('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
@ -1143,22 +1139,29 @@ class Entreprise extends WsScore
}
$iInsee = new MInsee();
$iInsee = new MInsee();
$isList = false;
if ( is_null($idAnn) ) {
$anns = $iInsee->getAnnoncesLegales($siren);
$nbReponses = count($anns);
$isList = true;
} else {
$anns = $iInsee->getAnnoncesLegales($siren, $idAnn);
$nbReponses = count($anns);
}
$liste = array();
$cpt = 0;
if (is_array($anns))
{
foreach ($anns as $nb=>$ann)
foreach ($anns as $nb => $ann)
{
if ($isList===true && $nb<$position) { continue; }
$cpt++;
if ($isList===true && $cpt>$nbRep) { break; }
$evens = array();
foreach ($ann['evenements'] as $tabEven)
{