extranet/www/pages/options_surv.php
2009-08-21 15:05:19 +00:00

335 lines
12 KiB
PHP

<?php
if (!$_SESSION['connected'])
echo ('Vous devez être connecté afin de pouvoir utiliser cette fonctionnalité');
/*
if (!preg_match('/SURVLISTE/i', $_SESSION['tabInfo']['droits'])) {
print 'Vous n\'avez pas les droits nécessaires.';
exit;
}
*/
isset($_REQUEST['idEntreprise'])? $idEntreprise=$_REQUEST['idEntreprise'] : $idEntreprise='';
isset($_REQUEST['siret'])? $siret=$_REQUEST['siret'] : $siret='';
if($_REQUEST['action']=='supprimer'){
require_once 'surveillance/surveillance.php';
deleteSurveillance($_REQUEST['siren'], $_REQUEST['email'], $_REQUEST['ref'], $_REQUEST['source'], true);
header('Location: ./?page=surveillance&idEntreprise='.$idEntreprise.'&siret='.$siret);
}
isset($_REQUEST['vue']) ? $vue = $_REQUEST['vue'] : $vue = 'default' ;
isset($_REQUEST['tri']) ? $tri = $_REQUEST['tri'] : $tri = 'siren' ;
isset($_REQUEST['source']) ? $source = $_REQUEST['source'] : $source = '' ;
isset($_REQUEST['p']) ? $position = $_REQUEST['p'] : $position = 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;
}
$tabSource = array('annonces', 'insee', 'bilans', 'score');
$nbAffichage = 100;
//Liste des surveillances de l'utilisateur
try{
$result = $client->getSurveillances(0, $source, true, $position, $nbAffichage, $triws);
$listSurveillance = $result['results']['reponses'];
/*
print '<!--';
print_r($listSurveillance);
print '-->';
*/
$nbReponses = $result['results']['nbReponses'];
$nbSurveillances = $result['results']['nbReponsesTotal'];
$totPage = ceil($nbSurveillances/$nbAffichage);
$curPage = ceil($position/$nbSurveillances);
} catch (SoapFault $fault) {
require_once 'soaperror.php';
processSoapFault($client,$fault,$tabInfo);
die();
}
//Appel de la fonction de tri
require_once 'surveillance/surveillance_tri.php';
$listTrier = $fonctionTri($listSurveillance);
?>
<style>
#center {background: #ffffff; width:580px; padding:5px; }
#center h1 {margin:5px; padding:5px; background:#606060; color:#ffffff; font:600 1.4em Arial, Verdana, Sans-serif; letter-spacing:1px; line-height:1.2em;}
#center h2 {margin:5px; padding:5px; background:#00008c; color:#ffffff; font:bold 1.2em Arial, Verdana, Sans-serif; }
#surveillance {margin:5px; border-collapse:collapse; border:1px solid; font:normal 1em Arial, Verdana, Sans-serif; letter-spacing:1px; line-height: 1em;}
#surveillance tr {border:1px solid;}
#surveillance th {border:1px solid; padding:5px 15px 5px 2px;}
#surveillance td {border:1px solid; text-align:center; padding:2px; }
#surveillance .aleft {text-align:left;}
#surveillance .action {clear:both; margin:0; padding:0; font:normal 1em Arial, Verdana, Sans-serif; letter-spacing:1px; line-height: 1em;}
#surveillance td p {line-height:16px;}
#surveillance .action p {display:block; float:left; line-height:16px; margin:0;}
#surveillance .action a {display:block; float:right;}
#surveillance .action img {vertical-align:middle;}
#surveillance #type {width:120px;}
#info {margin:5px 5px 5px 30px; font:normal 1em Arial, Verdana, Sans-serif; letter-spacing:1px; line-height: 1em;}
#info td {padding-right:10px;}
table.tablesorter thead tr .header { background-image:url(./img/bg.gif); background-repeat:no-repeat; background-position:center right; cursor:pointer; }
table.tablesorter thead tr .headerSortUp { background-image: url(./img/asc.gif); }
table.tablesorter thead tr .headerSortDown { background-image: url(./img/desc.gif); }
#tri li {list-syle:none; margin-left:10px; display:inline; }
p.options {margin-left:10px; margin-top:5px;}
</style>
<link rel="stylesheet" href="./css/thickbox.css" type="text/css" />
<script type="text/javascript" src="./js/thickbox.js"></script>
<script type="text/javascript" src="./js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="./js/jquery.pngFix.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(document).pngFix();
<?php
if($source == ''){
?>
$("#surveillance").tablesorter({
headers: {
2: { sorter: false },
3: { sorter: false },
4: { sorter: false },
5: { sorter: false }
}
});
<?php
}else{
?>
$("#surveillance").tablesorter({
headers: {
3: { sorter: false }
}
});
<?php
}
?>
$("select[name=type]").change(function(){
var value = $(this).val();
if (value == '-'){
document.location.href = './?page=surveillance&idEntreprise=<?=$idEntreprise?>&siret=<?=$siret?>';
}else{
document.location.href = './?page=surveillance&vue=source&source='+value+'&idEntreprise=<?=$idEntreprise?>&siret=<?=$siret?>';
}
});
});
</script>
<div id="center">
<h1 class="titre">SURVEILLANCE</h1>
<?php
//Affichage du nombre de surveillances
$nbEtab = count($listTrier);
if($vue=='default'){
?>
<table id="info">
<tr><td width="200" class="StyleInfoLib">Nombre d'entités affichées</td><td><?php print $nbEtab; ?></td></tr>
<tr><td class="StyleInfoLib">Nombre de surveillances</td><td><?php print $nbSurveillances; ?></td></tr>
</table>
<?php
}else{
?>
<table id="info">
<tr><td class="StyleInfoLib">Nombre de surveillances <?php print $source; ?></td><td><?php print $nbSurveillances; ?></td></tr>
</table>
<?php
}
?>
<h2>Options de tri</h2>
<p class="options">
Afficher uniquement les suveillances de type
<select name="type">
<option value="-">toutes</option>
<option value="annonces" <?php if(isset($source) && $source=='annonces'){print 'selected';}?>>annonces</option>
<option value="insee" <?php if(isset($source) && $source=='insee'){print 'selected';}?>>insee</option>
<option value="bilans" <?php if(isset($source) && $source=='bilans'){print 'selected';}?>>bilans</option>
<option value="score" <?php if(isset($source) && $source=='score'){print 'selected';}?>>score</option>
</select>
</p>
<p class="options"><ul id="tri">
<li><a href="./?page=surveillance&vue=<?php print $vue;?><?php if(isset($source)){print '&source='.$source;}?>&tri=siren&idEntreprise=<?=$idEntreprise?>&siret=<?=$siret?>">Tri par Siren</a></li>
<li><a href="./?page=surveillance&vue=<?php print $vue;?><?php if(isset($source)){print '&source='.$source;}?>&tri=rs&idEntreprise=<?=$idEntreprise?>&siret=<?=$siret?>">Tri par Raison sociale</a></li>
<?php
if($source != ''){
?>
<li><a href="./?page=surveillance&vue=<?php print $vue;?><?php if(isset($source)){print '&source='.$source;}?>&tri=reference&idEntreprise=<?=$idEntreprise?>&siret=<?=$siret?>">Tri par Référence</a></li>
<li><a href="./?page=surveillance&vue=<?php print $vue;?><?php if(isset($source)){print '&source='.$source;}?>&tri=dateajout&idEntreprise=<?=$idEntreprise?>&siret=<?=$siret?>">Tri par Date d'ajout</a></li>
<li><a href="./?page=surveillance&vue=<?php print $vue;?><?php if(isset($source)){print '&source='.$source;}?>&tri=datederenvoi&idEntreprise=<?=$idEntreprise?>&siret=<?=$siret?>">Tri par Date de dernier envoi</a></li>
<?php
}
?>
</ul></p>
<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.
</p>
<?php if($totPage != 1){?>
<p class="options">Page : </p>
<p class="options">
<?php
for($countPage=0 ; $countPage<$totPage ; $countPage++ ){
if($countPage==$curPage){
?>
&nbsp;<?=$countPage+1?>&nbsp;
<?php
}else{
?>
&nbsp;<a href="./?page=surveillance&vue=<?=$vue;?>
<?php if(isset($tri)){print '&tri='.$tri;}?>
<?php if(isset($source)){print '&source='.$source;}?>&idEntreprise=<?=$idEntreprise?>&siret=<?=$siret?>&p=<?=$nbReponses*$countPage?>"><?=$countPage+1?></a>&nbsp;
<?php
}
}
?>
</p>
<?php
}
?>
<h2>Liste des surveillances</h2>
<table class="tablesorter" id="surveillance" width="570">
<thead>
<tr>
<th>Siren</th>
<th>Raison Sociale</th>
<th>Référence</th>
<th>Surveillance</th>
<th>Ajout le</th>
<th>Envoyé le</th>
</tr>
</thead>
<tbody>
<?php
//Si vue=defaut alors on affiche les entités avec toutes leurs surveillances
if($vue=='default'){
foreach($listTrier as $item)
{
?>
<tr>
<td class="aleft"><a href="./?page=identite&siret=<?php print $item['siren']; ?>"><?php print $item['siren']; ?></a></td>
<td width="110"><?php print $item['rs']; ?><br/><i><?php print $item['cp'].' '.$item['ville']; ?></i></td>
<td>
<?php
foreach($tabSource as $source){
if(isset($item['sources'][$source])){
foreach($item['sources'][$source] as $surveillance){
if($surveillance['ref']!=''){
print '<p>'.$surveillance['ref'].'</p>';
}else{?> <p>-</p> <?php }
}
}else{?> <p>-</p> <?php }
}
?>
</td>
<td id="type" class="aleft">
<?php
foreach($tabSource as $source){
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="thickbox" href="./pages/ajax_surveillance.php?q=ajouter&siren=<?php print $item['siren']; ?>&source=<?php print $source;?>" title="Ajouter la surveillance <?php print $source;?>"><img src="./img/interface/ajouter.png"/></a>
<a class="thickbox" href="./pages/ajax_surveillance.php?q=ajouter&siren=<?php print $item['siren']; ?>&source=<?php print $source;?>&ref=<?php print $surveillance['ref'];?>&email=<?php print $surveillance['email'];?>" title="Editer la surveillance <?php print $source;?>"><img src="./img/interface/editer.png"/></a>
<a href="./?page=surveillance&action=supprimer&siren=<?php print $item['siren']; ?>&ref=<?php print $surveillance['ref']; ?>&source=<?php print $source;?>&email=<?php print $surveillance['email']; ?>&idEntreprise=<?=$idEntreprise?>&siret=<?=$siret?>" title="Supprimer la surveillance <?php print $source.' '.$surveillance['email'];?>"><img src="./img/interface/supprimer.png"/></a>
</div>
<?php
}
}else{
?>
<div id="a<?php print $item['siren'];?>" class="action">
<p><?php print ucfirst($source);?></p>
<a class="thickbox" href="./pages/ajax_surveillance.php?q=ajouter&siren=<?php print $item['siren']; ?>&source=<?php print $source;?>" title="Ajouter la surveillance <?php print $item['source'];?>"><img src="./img/interface/ajouter.png"/></a>
</div>
<?php
}
?>
<br/>
<?php
}
?>
</td>
<td>
<?php
foreach($tabSource as $source){
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 }
}
?>
</td>
<td>
<?php
foreach($tabSource as $source){
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 }
}
?>
</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')
{
foreach($listTrier as $item){
?>
<tr>
<td class="aleft"><a href="./?page=identite&siret=<?php print $item['siren']; ?>"><?php print $item['siren']; ?></a></td>
<td><?php print $item['rs']; ?><br/><i><?php print $item['cp'].' '.$item['ville']; ?></i></td>
<td>
<?php
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="thickbox" href="./pages/ajax_surveillance.php?q=ajouter&siren=<?php print $item['siren']; ?>&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&siren=<?php print $item['siren']; ?>&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>
</div>
<br/>
</td>
<td>
<?php
print '<p>'.substr($item['dateAjout'],8,2).'/'.substr($item['dateAjout'],5,2).'/'.substr($item['dateAjout'],0,4).'</p>';
?>
</td>
<td>
<?php
$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
?>
<tbody>
</table>
</div>