ws-2.0 : getSurveillances

This commit is contained in:
Michael RICOIS 2011-01-20 15:03:38 +00:00
parent 246b72091d
commit e7d3ddd846
3 changed files with 79 additions and 57 deletions

View File

@ -17,6 +17,26 @@ class WsScores
}
}
public function getSurveillances($siret = '', $source='', $detail=false, $deb=0, $nbRet=100, $tri='siren'){
$params = new stdClass();
$params->filtre->siret = $siret;
$params->filtre->source = $source;
$params->filtre->detail = $detail;
$params->filtre->tri = $tri;
$params->position = $deb;
$params->nbRep = $nbRet;
$client = $this->loadClient('entreprise');
try {
$reponse = $client->getSurveillances($params);
return $reponse->getSurveillancesResult;
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client, $fault, $_SESSION['tabInfo']);
return false;
}
}
public function rechercheEntreprise($type, $criteres, $position = 0) {
$params = new stdClass();
$params->type = $type;

View File

@ -11,40 +11,40 @@ function defaultTriTab($tab){
$i=0;
$tabIndex = array();
$listTrier = array();
foreach($tab as $item){
if(!array_key_exists($item['siren'], $tabIndex)){
//Création du tableau trier
$listTrier[$i]['siren'] = $item['siren'];
$listTrier[$i]['nic'] = $item['nic'];
$listTrier[$i]['rs'] = $item['rs'];
$listTrier[$i]['cp'] = $item['cp'];
$listTrier[$i]['ville'] = $item['ville'];
$listTrier[$i]['sources'][$item['source']][0] = array(
'email' => $item['email'],
'ref' => $item['ref'],
'dateAjout' => $item['dateAjout'],
'dateDerEnvoi' => $item['dateDerEnvoi'],
);
//Tableau d'index
$tabIndex[$item['siren']] = $i;
}else{
$key = $tabIndex[$item['siren']];
$source = array(
'email'=>$item['email'],
'ref'=>$item['ref'],
'dateAjout'=>$item['dateAjout'],
'dateDerEnvoi'=> $item['dateDerEnvoi'],
);
if ( array_key_exists(
$item['source'],
$listTrier[$key]['sources'] ) ){
$nbSource = count($listTrier[$key]['sources'][$item['source']]);
if (count($tab)>0){
foreach($tab as $item){
if(!array_key_exists($item->siren, $tabIndex)){
//Création du tableau trier
$listTrier[$i]['siren'] = $item->siren;
$listTrier[$i]['nic'] = $item->nic;
$listTrier[$i]['rs'] = $item->rs;
$listTrier[$i]['cp'] = $item->cp;
$listTrier[$i]['ville'] = $item->ville;
$listTrier[$i]['sources'][$item->source][0] = array(
'email' => $item->email,
'ref' => $item->ref,
'dateAjout' => $item->dateAjout,
'dateDerEnvoi' => $item->dateDerEnvoi,
);
//Tableau d'index
$tabIndex[$item->siren] = $i;
}else{
$nbSource = 0;
$key = $tabIndex[$item->siren];
$source = array(
'email' => $item->email,
'ref' => $item->ref,
'dateAjout' => $item->dateAjout,
'dateDerEnvoi'=> $item->dateDerEnvoi,
);
if ( array_key_exists( $item->source, $listTrier[$key]['sources'] ) ){
$nbSource = count($listTrier[$key]['sources'][$item->source]);
}else{
$nbSource = 0;
}
$listTrier[$key]['sources'][$item->source][$nbSource] = $source;
}
$listTrier[$key]['sources'][$item['source']][$nbSource] = $source;
$i++;
}
$i++;
}
return $listTrier;
}

View File

@ -47,22 +47,24 @@ if (isset($parametres) && $parametres['info']['page'] == 'recherche') {
}
// Liste des surveillances de l'utilisateur
require_once 'scoresws/scoresws-int.php';
$result = scoresws_getSurveillances(0, $source, true, $position,
$nbAffichage, $triws);
if ($result === false) {
$ws = new WsScores();
$reponse = $ws->getSurveillances('', $source, true, $position,
$nbAffichage, $triws);
FB::log($reponse, 'getSurveillances');
if ($reponse === false) {
die();
}
$listSurveillance = $result['results']['reponses'];
$nbReponses = $result['results']['nbReponses'];
$nbSurveillances = $result['results']['nbReponsesTotal'];
$result = $reponse->result;
$listSurveillance = $result->liste->item;
$nbReponses = $result->nbReponses;
$nbSurveillances = $result->nbReponsesTotal;
$totPage = ceil($nbSurveillances/$nbAffichage);
$curPage = ceil($position/$nbAffichage);
require_once 'surveillance/function.php';
// Appel de la fonction de tri
require_once 'surveillance/surveillance_tri.php';
$listTrier = $fonctionTri($listSurveillance);
$listTrier = $fonctionTri($listSurveillance); FB::log($listTrier, 'listTrier');
if (AFFICHAGE_EXACT) {
$listTrier = array_splice($listTrier, 0, AFFICHAGE_MAX);
}
@ -415,30 +417,30 @@ if ($vue == 'default') {
foreach ($listTrier as $item) {
print '<tr>';
print '<td class="aleft"><a href="./?page=identite&siret='.
$item['siren'].$item['nic'].'">'.$item['siren'].'</a></td>';
print '<td>'.$item['rs'].'<br/><i>'.$item['cp'].' '.$item['ville'].
$item->siren.$item->nic.'">'.$item->siren.'</a></td>';
print '<td>'.$item->rs.'<br/><i>'.$item->cp.' '.$item->ville.
'</i></td>';
print '<td>';
if ($item['ref'] != '') {
print '<p>'.$item['ref'].'</p>';
if ($item->ref != '') {
print '<p>'.$item->ref.'</p>';
} else {
print ' <p>-</p> ';
}
print '</td>';
print '<td class="aleft">';
print '<div class="action">';
print '<p>'.ucfirst($item['source']).'</p>';
print '<p>'.ucfirst($item->source).'</p>';
print '<a class="dialogsurv" href="./?page=surveillance&q=ajouter/'.
$item['siren'].$item['nic'].'/'.$item['source'].'&ref='.
$item['ref'].'&email='.$item['email'].
'" title="Editer la surveillance '.$item['source'].'">';
$item->siren.$item->nic.'/'.$item->source.'&ref='.
$item->ref.'&email='.$item->email.
'" title="Editer la surveillance '.$item->source.'">';
print '<img src="./img/interface/editer.png"/>';
print '</a>';
print '<a href="./?page=surveillance&action=supprimer&siret='.
$item['siren'].$item['nic'].'&ref='.$item['ref'].'&source='.
$item['source'].'&email='.$item['email'].
'" title="Supprimer la surveillance '.$item['source'].' '.
$item['email'].'">';
$item->siren.$item->nic.'&ref='.$item->ref.'&source='.
$item->source.'&email='.$item->email.
'" title="Supprimer la surveillance '.$item->source.' '.
$item->email.'">';
print '<img src="./img/interface/supprimer.png"/>';
print '</a>';
print '</div>';
@ -446,15 +448,15 @@ if ($vue == 'default') {
print '</td>';
print '<td>';
print '<p>'.
substr($item['dateAjout'], 8, 2).'/'.
substr($item['dateAjout'], 5, 2).'/'.
substr($item['dateAjout'], 0, 4).'</p>';
substr($item->dateAjout, 8, 2).'/'.
substr($item->dateAjout, 5, 2).'/'.
substr($item->dateAjout, 0, 4).'</p>';
print '</td>';
print '<td>';
$pDate =
substr($item['dateDerEnvoi'], 8, 2).'/'.
substr($item['dateDerEnvoi'], 5, 2).'/'.
substr($item['dateDerEnvoi'], 0, 4);
substr($item->dateDerEnvoi, 8, 2).'/'.
substr($item->dateDerEnvoi, 5, 2).'/'.
substr($item->dateDerEnvoi, 0, 4);
if ($pDate != '00/00/0000') {
print '<p>'.$pDate.'</p>';
} else {