Display with first letter ranking

This commit is contained in:
Gregory Colpart 2017-02-10 15:15:00 +01:00
parent 0d7df91a61
commit 0f68f20d4c

View file

@ -20,9 +20,13 @@
* @param string $type * @param string $type
* @return NULL * @return NULL
*/ */
function show_my_details($name,$type) { function show_my_details($name,$type,$letter=NULL) {
global $conf;
print '<tr><td><a href="' .$type. '.php?view=' print '<tr><td>';
if($letter) {
printf('<a name="%s"></a>', $letter);
}
print '<a href="' .$type. '.php?view='
.$name. '">' .$name. '</a></td>'; .$name. '">' .$name. '</a></td>';
if ( $type == 'compte' && $conf['admin']['quota']) { if ( $type == 'compte' && $conf['admin']['quota']) {
@ -150,6 +154,24 @@ if (isset($_SESSION['login'])) {
<h3>Liste des comptes&nbsp;:</h3> <h3>Liste des comptes&nbsp;:</h3>
<?php
$alpha = array();
foreach($comptes as $compte) {
$letter = strtoupper(substr($compte, 0, 1));
$alpha[$letter] = 1;
}
$letters = array_keys($alpha);
sort($letters);
foreach($letters as $letter) {
printf('<a href="#%s">%s</a>&nbsp;', $letter, $letter);
}
?>
<br/>
<br/>
<table width="500px" bgcolor="#ddd" border="1"> <table width="500px" bgcolor="#ddd" border="1">
<tr> <tr>
<td><strong>Nom du compte</strong></td> <td><strong>Nom du compte</strong></td>
@ -167,7 +189,13 @@ if (isset($_SESSION['login'])) {
<?php <?php
foreach ($comptes as $compte) { foreach ($comptes as $compte) {
show_my_details($compte,'compte'); $letter = strtoupper(substr($compte, 0, 1));
if($alpha[$letter] == 1) {
$alpha[$letter] = 0;
} else {
$letter = NULL;
}
show_my_details($compte,'compte', $letter);
} }
print "</table>"; print "</table>";