Skip to content

Commit

Permalink
affichage des réservations sur toutes les ressources d'un site
Browse files Browse the repository at this point in the history
  • Loading branch information
ynaessens committed Feb 26, 2018
1 parent bbdd18f commit ce2f61e
Show file tree
Hide file tree
Showing 3 changed files with 644 additions and 20 deletions.
101 changes: 99 additions & 2 deletions include/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* include/functions.inc.php
* fichier Bibliothèque de fonctions de GRR
* Dernière modification : $Date: 2017-12-16 14:00$
* @author JeromeB & Laurent Delineau & Marc-Henri PAMISEUX
* Dernière modification : $Date: 2018-01-30 19:00$
* @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 @@ -1059,6 +1059,7 @@ function print_header($day = '', $month = '', $year = '', $type_session = 'with_
echo Settings::get('message_accueil');
$sql = "SELECT value FROM ".TABLE_PREFIX."_setting WHERE name='mail_etat_destinataire'";
$res = grr_sql_query1($sql);
//Libère le résultat de la mémoire
grr_sql_free($res);

if ( ( $res == 1 && $type_session == "no_session" ) || ( ( $res == 1 || $res == 2) && $type_session == "with_session" && (authGetUserLevel(getUserName(), -1, 'area')) == 1 ) )
Expand Down Expand Up @@ -1803,6 +1804,35 @@ function show_colour_key($area_id)
}
echo '</table>'.PHP_EOL;
}
//Display the entry-type color keys. This has up to 2 rows, up to 10 columns.
function show_colour_keys()
{
echo '<table class="legende"><caption class="titre">Légendes des réservations</caption>'.PHP_EOL;
$sql = "SELECT DISTINCT id, type_name, type_letter, order_display FROM `".TABLE_PREFIX."_type_area` ";
$res = grr_sql_query($sql);
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;
}
//Round time down to the nearest resolution
function round_t_down($t, $resolution, $am7)
{
Expand Down Expand Up @@ -1980,6 +2010,73 @@ function make_area_select_html( $link, $current_site, $current_area, $year, $mon
$out_html .= '</form>'.PHP_EOL;
return $out_html;
}
/**
* sélecteur de domaines, y compris tous les domaines d'un site
* area selector, including any area in a site
*
* @param string $link
* @param string $current_site
* @param string $current_area
* @param string $year
* @param string $month
* @param string $day
* @param string $user
* @return string
*/
function make_area_select_all_html( $link, $current_site, $current_area, $year, $month, $day, $user)
{
global $vocab;
if (Settings::get("module_multisite") == "Oui")
$use_multi_site = 'y';
else
$use_multi_site = 'n';
if ($use_multi_site == 'y')
{
// on a activé les sites
if ($current_site != -1)
$sql = "SELECT a.id, a.area_name,a.access FROM ".TABLE_PREFIX."_area a, ".TABLE_PREFIX."_j_site_area j WHERE a.id=j.id_area and j.id_site=$current_site ORDER BY a.order_display, a.area_name";
else
$sql = "";
}
else
$sql = "SELECT id, area_name,access FROM ".TABLE_PREFIX."_area ORDER BY order_display, area_name";
$out_html = '<b><i>'.get_vocab("areas").'</i></b>'.PHP_EOL;
$out_html .= '<form id="area_001" action="'.$_SERVER['PHP_SELF'].'">'.PHP_EOL;
$out_html .= '<div><select class="form-control" name="area" ';
$out_html .= ' onchange="area_go()" ';
$out_html .= '>'.PHP_EOL;
$out_html .= "<option value=\"".$link."_all.php?year=$year&amp;site=$current_site\">".get_vocab("any_area")."</option>";
$res = grr_sql_query($sql);
if ($res)
{
for ($i = 0; ($row = grr_sql_row($res, $i)); $i++)
{
$selected = ($row[0] == $current_area) ? 'selected="selected"' : "";
$link2 = $link.'.php?year='.$year.'&amp;month='.$month.'&amp;day='.$day.'&amp;area='.$row[0];
if (authUserAccesArea($user,$row[0]) == 1)
{
$out_html .= '<option '.$selected.' value="'.$link2.'">'.htmlspecialchars($row[1]).'</option>'.PHP_EOL;
}
}
}
$out_html .= '</select>'.PHP_EOL;
$out_html .= '</div>'.PHP_EOL;
$out_html .= '<script type="text/javascript">'.PHP_EOL;
$out_html .= 'function area_go()'.PHP_EOL;
$out_html .= '{'.PHP_EOL;
$out_html .= 'box = document.getElementById("area_001").area;'.PHP_EOL;
$out_html .= 'destination = box.options[box.selectedIndex].value;'.PHP_EOL;
$out_html .= 'if (destination) location.href = destination;'.PHP_EOL;
$out_html .= '}'.PHP_EOL;
$out_html .= '</script>'.PHP_EOL;
$out_html .= '<noscript>'.PHP_EOL;
$out_html .= '<div>'.PHP_EOL;
$out_html .= '<input type="submit" value="Change" />'.PHP_EOL;
$out_html .= '</div>'.PHP_EOL;
$out_html .= '</noscript>'.PHP_EOL;
$out_html .= '</form>'.PHP_EOL;
return $out_html;
}
/**
* Menu gauche affichage des room via select
*
Expand Down
25 changes: 7 additions & 18 deletions year.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@
$month_num = date("m", $month_indice);
$year_num = date("Y", $month_indice);
$days_in_month = date("t", $month_indice);
$weekcol = 0;
echo "<div class=\"titre_planning\">" . ucfirst(utf8_strftime("%B %Y", $month_indice)). "</div>\n";
echo "<table border=\"2\">\n";
$sql = "select room_name, capacity, id, description from ".TABLE_PREFIX."_room where area_id=$area order by order_display,room_name";
Expand All @@ -354,22 +353,17 @@
echo "<tr>";
tdcell("cell_hours");
echo " </td>\n";
//Corrige un bug avec certains fuseaux horaires (par exemple GMT-05:00 celui du Québec) :
//plusieurs mois débutent par le dernier jours du mois précédent.
//En changeant "gmmktime" par "mktime" le bug est corrigé
//$t2=gmmktime(0,0,0,$month_num,1,$year_num);
$t2 = mktime(0, 0, 0, $month_num, 1, $year_num);
for ($k = 0; $k < $days_in_month; $k++)
{
$cday = date("j", $t2);
$cmonth =date("m", $t2);
$cweek = date("w", $t2);
$cyear = date("Y", $t2);
$name_day = ucfirst(utf8_strftime("%a<br />%d", $t2));
$name_day = ucfirst(utf8_strftime("%a<br />%d", $t2)); // On inscrit le numéro du mois dans la deuxième ligne
$temp = mktime(0,0,0,$cmonth,$cday,$cyear);
$jour_cycle = grr_sql_query1("SELECT Jours FROM ".TABLE_PREFIX."_calendrier_jours_cycle WHERE DAY='$temp'");
$t2 += 86400;
// On inscrit le numéro du mois dans la deuxième ligne
if ($display_day[$cweek] == 1)
{
if (isHoliday($temp)) {echo tdcell("cell_hours_ferie");}
Expand Down Expand Up @@ -400,16 +394,12 @@
if ($verif_acces_ressource)
{
// on n'affiche pas toutes les ressources
// Calcul du niveau d'accès aux fiche de réservation détaillées des ressources
// Calcul du niveau d'accès aux fiches de réservation détaillées des ressources
$acces_fiche_reservation = verif_acces_fiche_reservation(getUserName(), $row[2]);
echo "<tr>";
tdcell("cell_hours");
echo htmlspecialchars($row[0]) ."</td>\n";
$li++;
//Corrige un bug avec certains fuseaux horaires (par exemple GMT-05:00 celui du Québec) :
//plusieurs mois débutent par le dernier jours du mois précédent.
//En changeant "gmmktime" par "mktime" le bug est corrigé
//$t2=gmmktime(0,0,0,$month_num,1,$year_num);
$t2 = mktime(0, 0, 0, $month_num, 1, $year_num);
for ($k = 0; $k < $days_in_month; $k++)
{
Expand All @@ -426,7 +416,7 @@
echo "<img src=\"img_grr/stop.png\" alt=\"".get_vocab("reservation_impossible")."\" title=\"".get_vocab("reservation_impossible")."\" width=\"16\" height=\"16\" class=\"".$class_image."\" /></div>";
}
//Anything to display for this day?
if (isset($d[$cday][$cmonth][$cyear]["id"][0]))
elseif (isset($d[$cday][$cmonth][$cyear]["id"][0]))
{
$n = count($d[$cday][$cmonth][$cyear]["id"]);
//Show the start/stop times, 2 per line, linked to view_entry.
Expand All @@ -440,10 +430,10 @@
}
for ($i = 0; $i < $n; $i++)
{
if ($d[$cday][$cmonth][$cyear]["room"][$i] == $row[0])
if ($d[$cday][$cmonth][$cyear]["room"][$i] == $row[0]) // test peu fiable car c'est l'id qui est unique YN le 26/02/2018
{
//if ($i > 0 && $i % 2 == 0) echo "<br />"; else echo " ";
echo "\n<br />\n<table width=\"100%\" border=\"0\" ><tr>\n";
echo "\n<table width=\"100%\" border=\"0\" ><tr>\n";
tdcell($d[$cday][$cmonth][$cyear]["color"][$i]);
if ($d[$cday][$cmonth][$cyear]["res"][$i] != '-')
echo " <img src=\"img_grr/buzy.png\" alt=\"".get_vocab("ressource actuellement empruntee")."\" title=\"".get_vocab("ressource actuellement empruntee")."\" width=\"20\" height=\"20\" class=\"image\" /> \n";
Expand All @@ -467,14 +457,13 @@
echo "</td>\n";
}
// fin condition "on n'affiche pas tous les jours de la semaine"
// if (++$weekcol == 7) $weekcol = 0;
}
echo "</tr>\n";
}
}
echo "</table>\n";
$month_indice = mktime(0, 0, 0, $month_num + 1, 2, $year_num);
// Fin de la boucle sur les mois
$month_indice = mktime(0, 0, 0, $month_num + 1, 1, $year_num);
// Fin de la boucle sur les mois
}
show_colour_key($area);
// Affichage d'un message pop-up
Expand Down

0 comments on commit ce2f61e

Please sign in to comment.