Liste des établissements sur even 6700

This commit is contained in:
Michael RICOIS 2015-08-31 13:22:53 +00:00
parent 2e6000dfe2
commit 95bf03bf01
2 changed files with 16 additions and 13 deletions

View File

@ -552,7 +552,7 @@ class SaisieController extends Zend_Controller_Action
case '6700':
//Liste des établissements
$ws = new WsScores();
$reponse = $ws->getListeEtablissements($siren, -1, 0, 200);
$reponse = $ws->getListeEtablissements($siren, -1, 0, 100);
$listeEtablissements = $reponse->result->item;
//Zend_Registry::get('firebug')->info(count($listeEtablissements));
$this->view->assign('ListeEtablissements', $listeEtablissements);
@ -614,23 +614,29 @@ class SaisieController extends Zend_Controller_Action
$request = $this->getRequest();
$siren = $this->getParam('siren');
$p = $request->getParam('p', 0);
$p = $request->getParam('p', 1);
$nbAffichage = 100;
$position = ($p - 1 ) * $nbAffichage;
if (!empty($p)) {
$ws = new WsScores();
$reponse = $ws->getListeEtablissements($siren, -1, $p);
$reponse = $ws->getListeEtablissements($siren, -1, $position, $nbAffichage);
$liste = array();
if (count($reponse->result->item)>0) {
foreach ($reponse->result->item as $item) {
$liste[] = array(
'value' => $item->Nic,
'label' => $siren.$item->Nic.' - '.$item->Adresse.' '.$item->CP.' '.$item->Ville,
'label' => $item->Nic.' - '.$item->Adresse.' '.$item->CP.' '.$item->Ville,
);
}
}
if ($p < $reponse->nbReponses) {
$p = $p+200;
}
$output = array( 'p' => $p, 'list' => $liste );
$nbReponsesTotal = $reponse->nbReponses;
$pageTotal = ceil( $nbReponsesTotal / $nbAffichage );
$pageNext = $p + 1;
if( $pageNext > $pageTotal ) {
$pageNext = $pageTotal;
}
$output = array( 'p' => $pageNext, 'list' => $liste );
}
echo json_encode($output);
}

View File

@ -1,6 +1,3 @@
<?php
//Afficher la liste des établissements
?>
<label>Etablissement concerné</label>
<select name="jugement[nic]" size="5">
<option value="-">-</option>
@ -22,17 +19,17 @@ foreach($this->ListeEtablissements as $etablissement) {
</select>
<div class="info">
<a href="<?=$this->url(array('controller'=>'saisie','action'=>'listetab','siren'=>$this->siren),null,true)?>" id="insert-etab">Insérer les établissements suivant</a>
<input type="hidden" name="p" value="200"/>
<input type="hidden" name="p" value="2"/>
<script>
$('#insert-etab').click(function(e){
e.preventDefault();
var p = $('input[name=p]').val();
$.getJSON($(this).attr('href'), { p: p }, function(data){
$('input[name=p]').val(data.p);
$.each(data.list, function(i, v) {
var option = '<option value="'+ v.value+'">'+v.label+'</option>';
$(option).appendTo('select[name="jugement[nic]"]');
});
$('input[name=p]').val(data.p);
});
});
</script>