Mmm, le problème c'est qu'il y a beaucoups de code pour afficher ce "simple" tableau et que je ne peut mettre ma page en ligne. Je vait tout de même essayer de séléctionner le code utile.
CSS:
table.large
{
border: 1px solid #000000;
font-size: x-small;
width:100%;
}
tr.titre
{
font-weight: bold;
color:#000000;
}
tr.paire
{
background-color: #dddddd;
}
tr.impaire
{
background-color: #FFFFFF;
}
td.changepagetableau
{
text-align:center;
width:30px;
height:25px;
}
Code PHP - HTML:
$ressources = $load->ressources('Nom', 'ASC', null, null, 1); //load est une classe qui me permet de charger des donnés selon plusieur paramètres
$nbpage = ceil((count($ressources))/10);
if (isset($_POST['numpage']))
{
$numpage = $_POST['numpage'];
}
else
{
$numpage = 1;
}
if (isset($_POST['gopage']))
{
if ($_POST['gopage']=='suivant')
{
if ($numpage < $nbpage)
{
$numpage++;
}
}
if ($_POST['gopage']=='precedant')
{
if ($numpage > 1)
{
$numpage--;
}
}
if ($_POST['gopage']=='premier')
{
$numpage = 1;
}
if ($_POST['gopage']=='dernier')
{
$numpage = $nbpage;
}
}
if ((!empty($_GET['coltri']))and(!empty($_GET['senstri'])))
{
if ($_GET['coltri'] <> 'Serviceid')
{
$enregistrementdepart = ($numpage -1) * 10;
$nbenregistrement = 10;
$ressources = $load->ressources($_GET['coltri'], $_GET['senstri'], $enregistrementdepart, $nbenregistrement, 1);
}
else
{
$services = $load->services($_GET['coltri'], $_GET['senstri']);
$ressources = $load->ressources(null, null, '0', '10', 1);
}
}
else
{
$ressources = $load->ressources('Nom', 'ASC', '0', '10', 1);
}
$nbrressourcetable1 = 0;
foreach ($ressources as $row)
{
$nbrressourcetable1++;
}
$idxligne1 = ($numpage-1)*10 + 0;
if (!empty($_GET['coltri']))
{
if ($_GET['senstri'] == 'ASC')
{
$imagetri = 'tri.png';
$senstri = 'DESC';
$senstrivrai = 'ASC';
}
if ($_GET['senstri'] == 'DESC')
{
$imagetri = 'triup.png';
$senstri = 'ASC';
$senstrivrai = 'DESC';
}
$coltri = $_GET['coltri'];
$boutontri1 = '<a href="?page=ressources/ressourcesglobal&coltri=';
$boutontri2 = '&senstri=' . $senstri . '" class="table">';
$boutontri4 = ' <img src="api/default/pictures/icones/' . $imagetri . '">';
$boutontri5 = '</a>';
}
else
{
$coltri = 'Nom';
$senstri = 'ASC';
$senstrivrai = 'ASC';
$boutontri1 = '<a href="?page=ressources/ressourcesglobal&coltri=';
$boutontri2 = '&senstri=ASC" class="table">';
$boutontri4 = '';
$boutontri5 = '</a>';
}
$boutontri3 = '&senstri=ASC" class="table">';
?>
<div class="marge20px">
<table class="large">
<tr class="titre">
<td class="icone"></td>
<td><img src="api/default/pictures/icones/alarme.png" title="Alarme"></td>
<td><?php if (($coltri == 'Grade')or(empty($coltri))){ $bouton = $boutontri1. 'Grade'. $boutontri2 . 'Grade' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='Grade'){$bouton = $boutontri1. 'Grade'. $boutontri3 . 'Grade' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'Grade'. $boutontri3 . 'Grade'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'Nom')or(empty($coltri))){ $bouton = $boutontri1. 'Nom'. $boutontri2 . 'Nom' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='Nom'){$bouton = $boutontri1. 'Nom'. $boutontri3 . 'Nom' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'Nom'. $boutontri3 . 'Nom'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'Prenom')or(empty($coltri))){ $bouton = $boutontri1. 'Prenom'. $boutontri2 . 'Prénom' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='Prenom'){$bouton = $boutontri1. 'Prenom'. $boutontri3 . 'Prénom' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'Prenom'. $boutontri3 . 'Prénom'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'Adresse')or(empty($coltri))){ $bouton = $boutontri1. 'Adresse'. $boutontri2 . 'Adresse' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='Adresse'){$bouton = $boutontri1. 'Adresse'. $boutontri3 . 'Adresse' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'Adresse'. $boutontri3 . 'Adresse'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'NPA')or(empty($coltri))){ $bouton = $boutontri1. 'NPA'. $boutontri2 . 'NPA' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='NPA'){$bouton = $boutontri1. 'NPA'. $boutontri3 . 'NPA' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'NPA'. $boutontri3 . 'NPA'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'Localite')or(empty($coltri))){ $bouton = $boutontri1. 'Localite'. $boutontri2 . 'Localité' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='Localite'){$bouton = $boutontri1. 'Localite'. $boutontri3 . 'Localité' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'Localite'. $boutontri3 . 'Localité'. $boutontri5; echo $bouton;}}?></td>
<td>Service</td>
<td><?php if (($coltri == 'Fonction')or(empty($coltri))){ $bouton = $boutontri1. 'Fonction'. $boutontri2 . 'Fonction' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='Fonction'){$bouton = $boutontri1. 'Fonction'. $boutontri3 . 'Fonction' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'Fonction'. $boutontri3 . 'Fonction'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'NbrJour')or(empty($coltri))){ $bouton = $boutontri1. 'NbrJour'. $boutontri2 . 'NbJour' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='NbrJour'){$bouton = $boutontri1. 'NbrJour'. $boutontri3 . 'NbJour' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'NbrJour'. $boutontri3 . 'NbJour'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'PDG')or(empty($coltri))){ $bouton = $boutontri1. 'PDG'. $boutontri2 . 'PDG' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='PDG'){$bouton = $boutontri1. 'PDG'. $boutontri3 . 'PDG' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'PDG'. $boutontri3 . 'PDG'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'TelPrive')or(empty($coltri))){ $bouton = $boutontri1. 'TelPrive'. $boutontri2 . 'Tel Privé' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='TelPrive'){$bouton = $boutontri1. 'TelPrive'. $boutontri3 . 'Tel Privé' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'TelPrive'. $boutontri3 . 'Tel Privé'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'TelProf')or(empty($coltri))){ $bouton = $boutontri1. 'TelProf'. $boutontri2 . 'Tel Prof' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='TelProf'){$bouton = $boutontri1. 'TelProf'. $boutontri3 . 'Tel Prof' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'TelProf'. $boutontri3 . 'Tel Prof'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'Natel')or(empty($coltri))){ $bouton = $boutontri1. 'Natel'. $boutontri2 . 'Natel' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='Natel'){$bouton = $boutontri1. 'Natel'. $boutontri3 . 'Natel' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'Natel'. $boutontri3 . 'Natel'. $boutontri5; echo $bouton;}}?></td>
<td><?php if (($coltri == 'Fax')or(empty($coltri))){ $bouton = $boutontri1. 'Fax'. $boutontri2 . 'Fax' . $boutontri4. $boutontri5; echo $bouton;}else{if ($coltri=='Fax'){$bouton = $boutontri1. 'Fax'. $boutontri3 . 'Fax' . $boutontri4 . $boutontri5; echo $bouton;}else{$bouton = $boutontri1. 'Fax'. $boutontri3 . 'Fax'. $boutontri5; echo $bouton;}}?></td>
<td></td>
</tr>
<?php
for ($idx=1; $idx<=$nbrressourcetable1; $idx++)
{
if ($idxligne1 % 2 == 1)
{
$styleligne = 'paire';
}
else
{
$styleligne = 'impaire';
}
?>
<tr class=<?php echo $styleligne ?>>
<td><form method="post" name="checktable1" action="?page=ressources/ressourcesglobal&coltri=<?php echo $coltri; ?>&senstri=<?php echo $senstrivrai; ?>"><input type="checkbox" name="check1_<?php echo $idxligne1 ?>"></td>
<td>
<?php
if ($ressources[$idx]->alarme == 1)
{
?><a href="?page=ressources/alarmes&ID=<?php echo ($numpage-1)*10 + $idx;?>" name="modify_<?php echo $idxligne1 ?>"><img src="api/default/pictures/icones/alarme.png" title="Alarme"></a></td><?php
}
?>
</td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->grade; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->nom; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->prenom; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->adresse; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->npa; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->localite; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $services[$ressources[$idx]->serviceid]->nom; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->fonction; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->nbrjour; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->pdg; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->telprive; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->telprof; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->natel; ?></a></td>
<td><a href="?page=ressources/detailressources&ID=<?php echo ($numpage-1)*10 + $idx;?>&coltri=<?php echo $coltri?>&senstri=<?php echo $senstrivrai?>" class="table"><?php echo $ressources[$idx]->fax; ?></a></td>
<?php
$droitaffichage = $config->get('EDIT_RES');
if ($security->check($droitaffichage, $droits, $utilisateurs)==true)
{
echo '<td class="centrer"><a href="?page=ressources/modificationressources&ID='.(($numpage-1)*10 + $idx) .'&coltri=' .$coltri. '&senstri='. $senstrivrai. '"><img src="api/default/pictures/icones/edit.png" title="Etiter"></a></td>';
}
$droitaffichage = $config->get('TRAN_RES');
if ($security->check($droitaffichage, $droits, $utilisateurs)==true)
{
echo '<td class="centrer"><a href="?page=ressources/ressourcesglobal&desafectationID='.(($numpage-1)*10 + $idx).'"><img src="api/default/pictures/icones/insert.png" title="Demande d\'affectation"></a></td>';
}
$droitaffichage = $config->get('SUPP_RES');
if ($security->check($droitaffichage, $droits, $utilisateurs)==true)
{
echo '<td class="centrer"><a href="?page=ressources/ressourcesglobal&suppressionID='.(($numpage-1)*10 + $idx).'"><img src="api/default/pictures/icones/desactiv.png" title="Supprimer"></a></td>';
}
?>
</tr>
<?php
if (empty($_POST['affectation']))
{
$table1id[$idxligne1] = $idx;
echo '<input type="hidden" name="table1id'. $idxligne1 .'" value="'. $idx .'"></input>';
}
else
{
if (!empty($_POST['table1id'. $idxligne1]))
{
$table1id[$idxligne1] = $_POST['table1id'. $idxligne1];
}
else
{
$table1id[$idxligne1] = ($numpage-1)*10 + $idx;
}
}
$idxligne1 = ($numpage-1)*10 + $idxligne1 + 1 ;
}
?>
</table>
<?php
if ($nbpage > 1)
{
if (isset($_POST['numpage']))
{
echo '<input type="hidden" name="numpage" value="'.$numpage.'">';
}
else
{
echo '<input type="hidden" name="numpage" value="1">';
}
?>
<input type="hidden" name="gopage" value="aucun">
<div class="centrer">
<table>
<tr>
<td class="changepagetableau"><?php if ($numpage <> 1){ echo '<a href="javascript:document.checktable1.gopage.value=\'premier\';document.checktable1.submit()"><img src="api/default/pictures/icones/premier.png" title="première page"></a>'; } ?></td>
<td class="changepagetableau"><?php if ($numpage <> 1){ echo '<a href="javascript:document.checktable1.gopage.value=\'precedant\';document.checktable1.submit()"><img src="api/default/pictures/icones/precedant.png" title="page précédente"></a>'; } ?></td>
<td>Page <?php echo $numpage;?></td>
<td class="changepagetableau"><?php if ($numpage <> $nbpage){ echo '<a href="javascript:document.checktable1.gopage.value=\'suivant\';document.checktable1.submit()"><img src="api/default/pictures/icones/suivant.png" title="page suivante"></a>'; } ?></td>
<td class="changepagetableau"><?php if ($numpage <> $nbpage){ echo '<a href="javascript:document.checktable1.gopage.value=\'dernier\';document.checktable1.submit()"><img src="api/default/pictures/icones/dernier.png" title="dernière page"></a>'; } ?></td>
</tr>
</table>
</div><br>
<?php
}
$droitaffichage = $config->get('TRAN_RES');
if ($security->check($droitaffichage, $droits, $utilisateurs) == true)
{
$image1 = 'api/default/pictures/icones/insert.png';
$text1 = 'Demande d\'affectation';
?><input type="hidden" value="affectation" name="affectation"></input><?php
?>
<a href="javascript:document.checktable1.submit()"><img src="<?php echo $image1; ?>"></a>
<a href="javascript:document.checktable1.submit()"><?php echo $text1; ?></a>
<?php
}
?>
</form>
</div>