Skip to content

Commit

Permalink
correctif : fonction show_color_key() - suggestion #301 du forum
Browse files Browse the repository at this point in the history
  • Loading branch information
ynaessens committed Dec 9, 2018
1 parent d8d93a4 commit 456a3cd
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions include/functions.inc.php
Expand Up @@ -2,7 +2,7 @@
/**
* include/functions.inc.php
* fichier Bibliothèque de fonctions de GRR
* Dernière modification : $Date: 2018-11-18 15:15$
* Dernière modification : $Date: 2018-12-09 10:15$
* @author JeromeB & Laurent Delineau & Marc-Henri PAMISEUX & Yan Naessens
* @copyright Copyright 2003-2018 Team DEVOME - JeromeB
* @link http://www.gnu.org/licenses/licenses.html
Expand Down Expand Up @@ -1846,39 +1846,36 @@ function tdcell_rowspan($colclass, $step)
//Display the entry-type color key. This has up to 2 rows, up to 10 columns.
function show_colour_key($area_id)
{
echo '<table class="legende"><caption>'.get_vocab("show_color_key").'</caption>'.PHP_EOL;
$sql = "SELECT DISTINCT t.id, t.type_name, t.type_letter, t.order_display FROM `".TABLE_PREFIX."_type_area` t
LEFT JOIN `".TABLE_PREFIX."_j_type_area` j on j.id_type=t.id
WHERE (j.id_area IS NULL or j.id_area != '".$area_id."')ORDER BY t.order_display";
$res = grr_sql_query($sql);
if ($res)
{
$nct = -1;
for ($i = 0; ($row = grr_sql_row($res, $i)); $i++)
{
// La requête sql précédente laisse passer les cas où un type est non valide dans le domaine concerné ET au moins dans un autre domaine, d'où le test suivant
$test = grr_sql_query1("SELECT id_type FROM `".TABLE_PREFIX."_j_type_area` WHERE id_type = '".$row[0]."' and id_area='".$area_id."'");
if ($test == -1)
{
$type_name = $row[1];
$type_letter = $row[2];
if ($nct == -1)
echo '<tr>'.PHP_EOL;
if (++$nct == 2)
{
$nct = 0;
echo '</tr>'.PHP_EOL, '<tr>'.PHP_EOL;
}
tdcell($type_letter);
echo $type_name, '</td>'.PHP_EOL;
}
}
if ($i % 2 == 1)
echo '<td></td>',PHP_EOL,'</tr>'.PHP_EOL;

}
echo '</table>'.PHP_EOL;
$sql = "SELECT DISTINCT t.id, t.type_name, t.type_letter, t.order_display FROM `".TABLE_PREFIX."_type_area` t
LEFT JOIN `".TABLE_PREFIX."_j_type_area` j on j.id_type=t.id
WHERE (j.id_area IS NULL or j.id_area != '".$area_id."')
AND NOT EXISTS (SELECT y.id_type FROM `".TABLE_PREFIX."_j_type_area` y WHERE y.id_type = j.id_type and id_area='".$area_id."')
ORDER BY t.order_display";
$res = grr_sql_query($sql);
echo '<table class="legende"><caption>'.get_vocab("show_color_key").'</caption>'.PHP_EOL;
if ($res)
{
$nct = -1;
for ($i = 0; ($row = grr_sql_row($res, $i)); $i++)
{
$type_name = $row[1];
$type_letter = $row[2];
if ($nct == -1)
echo '<tr>'.PHP_EOL;
if (++$nct == 2)
{
$nct = 0;
echo '</tr>'.PHP_EOL, '<tr>'.PHP_EOL;
}
tdcell($type_letter);
echo $type_name, '</td>'.PHP_EOL;
}
if ($i % 2 == 1)
echo '<td></td>',PHP_EOL,'</tr>'.PHP_EOL;
}
echo '</table>'.PHP_EOL;
}

//Display the entry-type color keys. This has up to 2 rows, up to 10 columns.
function show_colour_keys()
{
Expand Down

0 comments on commit 456a3cd

Please sign in to comment.