extranet/www/pages/options_surv.php

427 lines
11 KiB
PHP
Raw Normal View History

2009-05-20 15:49:08 +00:00
<?php
if (!$_SESSION['connected'])
{
echo 'Vous devez être connecté afin de '.
'pouvoir utiliser cette fonctionnalité';
exit;
}
if(!hasPerm('survliste')){
echo 'Vous n\'avez pas les droits nécessaires.';
exit;
}
$idEntreprise = isset($_REQUEST['idEntreprise'])?
$_REQUEST['idEntreprise'] : '';
$siret = isset($_REQUEST['siret'])? $_REQUEST['siret'] : '';
2009-05-20 15:49:08 +00:00
if($_REQUEST['action']=='supprimer'){
require_once 'surveillance/surveillance.php';
deleteSurveillance( $siret,
$_REQUEST['email'],
$_REQUEST['ref'],
$_REQUEST['source'],
true);
header('Location: ./?page=surveillance');
2010-03-03 13:33:16 +00:00
exit;
2009-05-25 13:17:22 +00:00
}
$vue = isset($_REQUEST['vue']) ? $_REQUEST['vue'] : 'default' ;
$tri = isset($_REQUEST['tri']) ? $_REQUEST['tri'] : 'siren' ;
$source = isset($_REQUEST['source']) ? $_REQUEST['source'] : '' ;
$position = isset($_REQUEST['p']) ? $_REQUEST['p'] : 0 ;
$fonctionTri = $vue.'TriTab';
switch($tri){
default:
case 'siren': $triws = 'siren'; break;
case 'rs': $triws = 'rs'; break;
case 'reference': $triws = 'ref'; break;
case 'dateajout': $triws = 'dateAjout'; break;
case 'datederenvoi': $triws = 'dateDerEnvoi'; break;
}
// Source => Permission
$tabSource = array(
'annonces' => 'annonce',
'insee'=>'insee',
'bilans'=>'bilan',
'score'=>'score',
'actes'=>'actes',
'dirigeants'=>'dirigeants');
$nbAffichage = 100;
2009-06-12 06:57:41 +00:00
//Enregistrement pour liste dernière recherche
require_once 'recherche/session.php';
$parametres = recherche_element(0);
if( isset($parametres) && $parametres['info']['page']=='recherche' ){
recherche_saveinfo( array('page' => $page) );
}
2009-05-25 07:35:14 +00:00
//Liste des surveillances de l'utilisateur
try{
$result = $client->getSurveillances(0, $source, true, $position,
$nbAffichage, $triws);
2009-06-12 06:57:41 +00:00
$listSurveillance = $result['results']['reponses'];
2009-08-21 15:05:19 +00:00
/*
print '<!--';
print_r($listSurveillance);
print '-->';
2009-08-21 15:05:19 +00:00
*/
$nbReponses = $result['results']['nbReponses'];
$nbSurveillances = $result['results']['nbReponsesTotal'];
$totPage = ceil($nbSurveillances/$nbAffichage);
$curPage = ceil($position/$nbAffichage);
2009-05-20 15:49:08 +00:00
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo);
die();
}
require_once 'surveillance/function.php';
2009-05-25 13:17:22 +00:00
//Appel de la fonction de tri
require_once 'surveillance/surveillance_tri.php';
$listTrier = $fonctionTri($listSurveillance);
2009-05-20 15:49:08 +00:00
?>
2009-05-25 13:17:22 +00:00
<script type="text/javascript">
$(document).ready(function()
{
<?php
2009-05-25 13:17:22 +00:00
if($source == ''){
?>
$('#surveillance').tablesorter({
headers: {
2: { sorter: false },
3: { sorter: false },
4: { sorter: false },
5: { sorter: false }
2009-05-25 13:17:22 +00:00
}
});
2009-05-25 13:17:22 +00:00
<?php
2009-05-25 13:17:22 +00:00
}else{
?>
$('#surveillance').tablesorter({
headers: {
3: { sorter: false }
}
});
<?php
2009-05-25 13:17:22 +00:00
}
?>
});
2009-05-25 13:17:22 +00:00
</script>
2009-05-20 15:49:08 +00:00
<div id="center">
<h1 class="titre">SURVEILLANCE</h1>
<?php
2009-05-25 07:35:14 +00:00
//Affichage du nombre de surveillances
$nbEtab = count($listTrier);
2009-05-25 15:25:44 +00:00
if($vue=='default'){
2009-05-25 07:35:14 +00:00
?>
<table id="info">
<tr>
<td width="200" class="StyleInfoLib">Nombre d'entités affichées</td>
<td><?=$nbEtab?></td>
</tr>
<tr>
<td class="StyleInfoLib">Nombre de surveillances</td>
<td><?=$nbSurveillances?></td>
</tr>
2009-05-25 07:35:14 +00:00
</table>
<?php
2009-05-25 15:25:44 +00:00
}else{
?>
2009-05-25 15:25:44 +00:00
<table id="info">
<tr>
<td class="StyleInfoLib">Nombre de surveillances <?=$source?></td>
<td><?=$nbSurveillances?></td>
</tr>
2009-05-25 15:25:44 +00:00
</table>
<?php
2009-05-25 15:25:44 +00:00
}
?>
<h2>Extraction des surveillances</h2>
<p class="options">
<label>Extraire uniquement les surveillances de type</label>
<select name="source">
<option value="-">toutes</option>
<?php
foreach($tabSource as $s => $perm)
{
if(preg_match('/\bsurv'.$perm.'\b/i', $_SESSION['tabInfo']['droits']))
{
?>
<option value="<?=$s?>" <?php if(isset($source) && $source==$s){print 'selected';}?>><?=$s?></option>
<?php
}
}
?>
</select>
<a href="#" id="getSurveillanceCsv">Ok</a>
</p>
<div id="getSurveillanceMsg"></div>
2009-05-25 07:35:14 +00:00
2009-05-25 13:17:22 +00:00
<h2>Options de tri</h2>
<p class="options">
Afficher uniquement les suveillances de type
2009-05-25 13:17:22 +00:00
<select name="type">
<option value="-">toutes</option>
<?php
foreach($tabSource as $s => $perm)
{
if(preg_match('/\bsurv'.$perm.'\b/i', $_SESSION['tabInfo']['droits']))
{
?>
<option value="<?=$s?>"
<?=(isset($source) && $source==$s) ? 'selected' : '' ;?>><?=$s?>
</option>
<?php
}
}
?>
2009-05-25 13:17:22 +00:00
</select>
</p>
<p class="options">
<ul id="tri">
<li>
<a href="<?=lienTri('siren', $vue, $source, $siret, $idEntreprise)?>">
Tri par Siren
</a>
</li>
<li>
<a href="<?=lienTri('rs', $vue, $source, $siret, $idEntreprise)?>">
Tri par Raison sociale
</a>
</li>
<?php
2009-05-25 13:17:22 +00:00
if($source != ''){
?>
<li>
<a href="<?=lienTri('reference', $vue, $source, $siret, $idEntreprise)?>">
Tri par Référence
</a>
</li>
<li>
<a href="<?=lienTri('dateajout', $vue, $source, $siret, $idEntreprise)?>">
Tri par Date d'ajout
</a>
</li>
<li>
<a href="<?=lienTri('datederenvoi', $vue, $source, $siret, $idEntreprise)?>">
Tri par Date de dernier envoi
</a>
</li>
<?php
2009-05-25 13:17:22 +00:00
}
?>
</ul>
</p>
2009-05-25 13:17:22 +00:00
<p class="options">
Les options de tri pemettent de trier la liste de vos surveillances.
Il est ensuite possible de trier les surveillances affichées dans le tableau en
cliquant sur chaque titre de colonnes.
2009-05-25 13:17:22 +00:00
</p>
<?php
if($totPage != 1)
{
?>
2009-06-12 06:57:41 +00:00
<p class="options">Page : </p>
<p class="options">
<?php
for($countPage=0 ; $countPage<$totPage ; $countPage++ )
{
if($countPage==$curPage)
{
2009-06-12 06:57:41 +00:00
?>
&nbsp;<?=$countPage+1?>&nbsp;
<?php
}else{
?>
&nbsp;<a href="./?page=surveillance&vue=<?=$vue;?>
<?=isset($tri) ? '&tri='.$tri : '';?>
<?=isset($source) ? '&source='.$source : '';?>
&idEntreprise=<?=$idEntreprise?>
&siret=<?=$siret?>
&p=<?=$nbReponses*$countPage?>">
<?=$countPage+1?></a>&nbsp;
2009-06-12 06:57:41 +00:00
<?php
}
}
?>
</p>
<?php
2009-06-12 06:57:41 +00:00
}
?>
2009-05-25 07:35:14 +00:00
<h2>Liste des surveillances</h2>
2009-05-25 13:17:22 +00:00
<table class="tablesorter" id="surveillance" width="570">
2009-05-20 15:49:08 +00:00
<thead>
<tr>
2009-05-25 13:17:22 +00:00
<th>Siren</th>
<th>Raison Sociale</th>
<th>Référence</th>
2009-05-25 13:17:22 +00:00
<th>Surveillance</th>
2009-05-25 15:25:44 +00:00
<th>Ajout le</th>
<th>Envoyé le</th>
2009-05-20 15:49:08 +00:00
</tr>
2009-05-25 13:17:22 +00:00
</thead>
<tbody>
<?php
//Si vue=defaut alors on affiche les entités avec toutes leurs surveillances
2009-05-25 15:25:44 +00:00
if($vue=='default'){
foreach($listTrier as $item)
{
$firephp->log($item, 'item');
2009-05-20 15:49:08 +00:00
?>
<tr>
<td class="aleft">
<a href="./?page=identite&siret=<?=$item['siren']?>">
<?=$item['siren']?>
</a>
</td>
<td width="110">
<?=$item['rs']?><br/><i><?=$item['cp'].' '.$item['ville']?></i>
</td>
2009-05-25 07:35:14 +00:00
<td>
<?php
foreach($tabSource as $source => $perm)
{
if(preg_match('/\bsurv'.$perm.'\b/i', $_SESSION['tabInfo']['droits']))
{
if(isset($item['sources'][$source]))
{
foreach($item['sources'][$source] as $surveillance)
{
2009-05-25 15:25:44 +00:00
if($surveillance['ref']!=''){
print '<p>'.$surveillance['ref'].'</p>';
}else{?> <p>-</p> <?php }
}
}else{?> <p>-</p> <?php }
}
}
2009-05-20 15:49:08 +00:00
?>
</td>
<td id="type" class="aleft">
<?php
foreach($tabSource as $source => $perm)
{
if(preg_match('/\bsurv'.$perm.'\b/i', $_SESSION['tabInfo']['droits']))
{
if(array_key_exists($source, $item['sources']))
{
foreach($item['sources'][$source] as $surveillance)
{
?>
<div id="a<?php print $item['siren'];?>" class="action">
<p><?php print ucfirst($source);?></p>
<a class="dialogsurv" href="./pages/ajax_surveillance.php?q=ajouter&siret=<?=$item['siren'].$item['nic']?>&source=<?=$source?>"
title="Ajouter la surveillance <?=$source?>">
<img src="./img/interface/ajouter.png"/>
</a>
<a class="dialogsurv" href="./pages/ajax_surveillance.php?q=ajouter&siret=<?=$item['siren'].$item['nic']?>&source=<?=$source?>&ref=<?=$surveillance['ref']?>&email=<?=$surveillance['email']?>"
title="Editer la surveillance <?=$source?>">
<img src="./img/interface/editer.png"/>
</a>
<a href="./?page=surveillance&action=supprimer&siret=<?=$item['siren'].$item['nic']?>&ref=<?=$surveillance['ref']?>&source=<?=$source?>&email=<?=$surveillance['email']?>"
title="Supprimer la surveillance <?=$source.' '.$surveillance['email']?>">
<img src="./img/interface/supprimer.png"/>
</a>
</div>
<?php
}
2009-05-25 15:25:44 +00:00
}
else
{
?>
<div id="a<?=$item['siren']?>" class="action">
<p><?=ucfirst($source)?></p>
<a class="dialogsurv" href="./pages/ajax_surveillance.php?q=ajouter&siret=<?=$item['siren'].$item['nic']?>&source=<?php print $source;?>" title="Ajouter la surveillance <?=$source?>"><img src="./img/interface/ajouter.png"/></a>
</div>
<?php
}
?>
<br/>
<?php
2009-05-20 15:49:08 +00:00
}
}
2009-05-20 15:49:08 +00:00
?>
</td>
<td>
<?php
foreach($tabSource as $source => $perm){
if(preg_match('/surv'.$perm.'/i', $_SESSION['tabInfo']['droits']))
{
if(array_key_exists($source, $item['sources'])){
foreach($item['sources'][$source] as $surveillance){
print '<p>'.substr($surveillance['dateAjout'],8,2).'/'.substr($surveillance['dateAjout'],5,2).'/'.substr($surveillance['dateAjout'],0,4).'</p>';
}
}else{?> <p>-</p> <?php }
}
}
2009-05-20 15:49:08 +00:00
?>
</td>
<td>
<?php
foreach($tabSource as $source => $perm){
if(preg_match('/\bsurv'.$perm.'\b/i', $_SESSION['tabInfo']['droits']))
{
if(array_key_exists($source, $item['sources'])){
foreach($item['sources'][$source] as $surveillance){
$pDate = substr($surveillance['dateDerEnvoi'],8,2).'/'.substr($surveillance['dateDerEnvoi'],5,2).'/'.substr($surveillance['dateDerEnvoi'],0,4);
if ($pDate!='00/00/0000'){print '<p>'.$pDate.'</p>'; }else{ print '<p>-</p>';}
}
}else{?> <p>-</p> <?php }
}
}
2009-05-20 15:49:08 +00:00
?>
</td>
</tr>
<?php
}
//si vue=source alors on a forcément qu'une seul source donc 1 ligne par surveillance d'entité
}
elseif($vue=='source')
{
2009-05-25 15:25:44 +00:00
foreach($listTrier as $item){
?>
<tr>
<td class="aleft"><a href="./?page=identite&siret=<?=$item['siren'].$item['nic']?>"><?=$item['siren']?></a></td>
<td><?=$item['rs']?><br/><i><?=$item['cp'].' '.$item['ville']?></i></td>
2009-05-25 15:25:44 +00:00
<td>
<?php
2009-05-25 15:25:44 +00:00
if($item['ref']!=''){
print '<p>'.$item['ref'].'</p>';
}else{?> <p>-</p> <?php }
?>
</td>
<td class="aleft">
<div id="a<?php print $item['siren'];?>" class="action">
<p><?php print ucfirst($item['source']);?></p>
<a class="dialogsurv" href="./pages/ajax_surveillance.php?q=ajouter&siret=<?=$item['siren'].$item['nic']?>&source=<?php print $item['source'];?>&ref=<?php print $item['ref'];?>&email=<?php print $item['email'];?>" title="Editer la surveillance <?php print $item['source'];?>"><img src="./img/interface/editer.png"/></a>
<a href="./?page=surveillance&action=supprimer&siret=<?$item['siren'].$item['nic']?>&ref=<?php print $item['ref']; ?>&source=<?php print $item['source'];?>&email=<?php print $item['email']; ?>" title="Supprimer la surveillance <?php print $item['source'].' '.$item['email'];?>"><img src="./img/interface/supprimer.png"/></a>
2009-05-25 15:25:44 +00:00
</div>
<br/>
</td>
<td>
<?php
2009-05-25 15:25:44 +00:00
print '<p>'.substr($item['dateAjout'],8,2).'/'.substr($item['dateAjout'],5,2).'/'.substr($item['dateAjout'],0,4).'</p>';
?>
</td>
<td>
<?php
2009-05-25 15:25:44 +00:00
$pDate = 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{ print '<p>-</p>';}
?>
</td>
</tr>
<?php
}
}//Fin vue==source
2009-05-20 15:49:08 +00:00
?>
2009-05-25 13:17:22 +00:00
<tbody>
2009-05-20 15:49:08 +00:00
</table>
</div>