} if ($_GET['pview'] == 1) { $class_image = "print_image"; } else { $class_image = "image"; } $back = ''; if (isset($_SERVER['HTTP_REFERER'])) { $back = htmlspecialchars($_SERVER['HTTP_REFERER']); } if ($settings->get("authentification_obli") == 0 && getUserName() == '') { $type_session = "no_session"; } else { $type_session = "with_session"; } get_planning_area_values($area); if ($area <= 0) { print_header($day, $month, $year, $type_session); echo '<h1>' . get_vocab("noareas") . '</h1>'; echo '<a href="./admin/admin_accueil.php">' . get_vocab("admin") . '</a>' . PHP_EOL . '</body>' . PHP_EOL . '</html>'; exit; } print_header($day, $month, $year, $type_session); if (authGetUserLevel(getUserName(), -1) < 1 && $settings->get("authentification_obli") == 1) { showAccessDenied($back); exit; } if (authUserAccesArea(getUserName(), $area) == 0) { showAccessDenied($back); exit; }
if ($_GET["sumby"] == "3") { echo html_entity_decode($vocab["summarize_by"]) . " " . html_entity_decode($vocab["sum_by_descrip"]) . " - {$day} {$month} {$year};"; } else { if ($_GET["sumby"] == "5") { echo html_entity_decode($vocab["summarize_by"]) . " " . html_entity_decode($vocab["type"]) . " - {$day} {$month} {$year};"; } else { $fieldname = grr_sql_query1("SELECT fieldname FROM " . TABLE_PREFIX . "_overload WHERE id='" . $_GET["sumby"] . "'"); echo html_entity_decode($vocab["summarize_by"]) . " " . html_entity_decode($fieldname) . " - {$day} {$month} {$year};"; } } } echo "\r\n"; } for ($i = 0; $row = grr_sql_row($res, $i); $i++) { // Récupération des données concernant l'affichage du planning du domaine get_planning_area_values($row[11]); if ($enable_periods == 'y') { // pour le décompte des créneaux accumulate_periods($row, $count1, $hours1, $report_start, $report_end, $room_hash1, $breve_description_hash1, "y"); $do_sum1 = 'y'; } else { // pour le décompte des heures accumulate($row, $count2, $hours2, $report_start, $report_end, $room_hash2, $breve_description_hash2, "y"); $do_sum2 = 'y'; } // pour le décompte des réservations accumulate($row, $count, $hours, $report_start, $report_end, $room_hash, $breve_description_hash, "y"); } // Décompte des heures (cas ou $enable_periods != 'y') if (isset($do_sum1)) { echo "\r\n" . html_entity_decode($vocab["summary_header"]) . "\r\n";
function verif_heure_debut_fin($start_time, $end_time, $area) { global $enable_periods, $resolution, $morningstarts, $eveningends, $eveningends_minutes; // Récupération des données concernant l'affichage du planning du domaine get_planning_area_values($area); // On ne traite pas le cas des plannings basés sur les intitulés prédéfinis if ($enable_periods != "y") { $day = date("d", $start_time); $month = date("m", $start_time); $year = date("Y", $start_time); $startday = mktime($morningstarts, 0, 0, $month, $day, $year); $day = date("d", $end_time); $month = date("m", $end_time); $year = date("Y", $end_time); $endday = mktime($eveningends, $eveningends_minutes, $resolution, $month, $day, $year); if ($start_time < $startday) { return false; } else { if ($end_time > $endday) { return false; } } } return true; }
exit; } if(authUserAccesArea(getUserName(), $area)==0) { showAccessDenied($day, $month, $year, $area,$back); exit(); } grr_sql_begin(); if (getSettingValue("automatic_mail") == 'yes') { $_SESSION['session_message_error'] = send_mail($id,3,$dformat); } // On vérifie les dates $room_id = grr_sql_query1("SELECT ".TABLE_PREFIX."_entry.room_id FROM ".TABLE_PREFIX."_entry, ".TABLE_PREFIX."_room WHERE ".TABLE_PREFIX."_entry.room_id = ".TABLE_PREFIX."_room.id AND ".TABLE_PREFIX."_entry.id='".$id."'"); $date_now = mktime(); get_planning_area_values($area); // Récupération des données concernant l'affichage du planning du domaine if ((!(verif_booking_date(getUserName(), $id, $room_id, -1, $date_now, $enable_periods))) or ((verif_booking_date(getUserName(), $id, $room_id, -1, $date_now, $enable_periods)) and ($can_delete_or_create!="y")) ) { showAccessDenied($day, $month, $year, $area,$back); exit(); } $result = mrbsDelEntry(getUserName(), $id, $series, 1); grr_sql_commit(); if ($result) { $_SESSION['displ_msg'] = 'yes'; Header("Location: ".$page.".php?day=$day&month=$month&year=$year&area=$area&room=".$info["room_id"]); exit();
/** * mincals.inc.php * Fonctions permettant d'afficher le mini calendrier * Ce script fait partie de l'application GRR * Dernière modification : $Date: 2010-01-06 10:21:20 $ * @author Laurent Delineau <*****@*****.**> * @copyright Copyright 2003-2008 Laurent Delineau * @link http://www.gnu.org/licenses/licenses.html * @package root * @version $Id: mincals.inc.php,v 1.7 2010-01-06 10:21:20 grr Exp $ * @filesource * * This file is part of GRR. * * GRR is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * GRR is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GRR; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ function minicals($year, $month, $day, $area, $room, $dmy) { global $display_day, $vocab; get_planning_area_values($area); class Calendar { private $month; private $year; private $day; private $h; private $area; private $room; private $dmy; private $week; private $mois_precedent; private $mois_suivant; /** * @param string $day * @param string $month * @param string $year * @param integer $h * @param integer $mois_precedent * @param integer $mois_suivant */ public function Calendar($day, $month, $year, $h, $area, $room, $dmy, $mois_precedent, $mois_suivant) { $this->day = $day; $this->month = $month; $this->year = $year; $this->h = $h; $this->area = $area; $this->room = $room; $this->dmy = $dmy; $this->mois_precedent = $mois_precedent; $this->mois_suivant = $mois_suivant; } /** * @param integer $day * @param double $month * @param string $year */ private function getDateLink($day, $month, $year) { global $vocab; if ($this->dmy == 'day') { if (isset($this->room)) { return "<a onclick=\"charger();\" class=\"calendar\" title=\"" . htmlspecialchars(get_vocab("see_all_the_rooms_for_the_day")) . "\" href=\"" . $this->dmy . ".php?year={$year}&month={$month}&day={$day}&room=" . $this->room . "\""; } return "<a onclick=\"charger();\" class=\"calendar\" title=\"" . htmlspecialchars(get_vocab("see_all_the_rooms_for_the_day")) . "\" href=\"" . $this->dmy . ".php?year={$year}&month={$month}&day={$day}&area=" . $this->area . "\""; } if ($this->dmy != 'day') { if (isset($this->room)) { return "<a onclick=\"charger();\" class=\"calendar\" title=\"" . htmlspecialchars(get_vocab("see_all_the_rooms_for_the_day")) . "\" href=\"day.php?year={$year}&month={$month}&day={$day}&room=" . $this->room . "\""; } return "<a onclick=\"charger();\" class=\"calendar\" title=\"" . htmlspecialchars(get_vocab("see_all_the_rooms_for_the_day")) . "\" href=\"day.php?year={$year}&month={$month}&day={$day}&area=" . $this->area . "\""; } } /** * @param integer $m * @param integer $y * @param string $month * @param string $year * @param string $text * @param string $glyph */ private function createlink($m, $y, $month, $year, $dmy, $room, $area, $text, $glyph) { global $vocab, $type_month_all; $tmp = mktime(0, 0, 0, $month + $m, 1, $year + $y); $lastmonth = date("m", $tmp); $lastyear = date("Y", $tmp); if ($dmy != 'day' && $dmy != 'week_all' && $dmy != 'month_all' && $dmy != 'month_all2') { return "<button type=\"button\" title=\"" . htmlspecialchars(get_vocab($text)) . "\" class=\"btn btn-default btn-xs\" onclick=\"charger();javascript: location.href='month.php?year={$lastyear}&month={$lastmonth}&day=1&area={$this->area}&room={$room}';\"><span class=\"glyphicon glyphicon-{$glyph}\"></span></button>\n"; } else { return "<button type=\"button\" title=\"" . htmlspecialchars(get_vocab($text)) . "\" class=\"btn btn-default btn-xs\" onclick=\"charger();javascript: location.href='" . $type_month_all . ".php?year={$lastyear}&month={$lastmonth}&day=1&area={$area}';\"><span class=\"glyphicon glyphicon-{$glyph}\"></span></button>\n"; } } private function getNumber($weekstarts, $d, $daysInMonth) { global $display_day; $s = ''; for ($i = 0; $i < 7; $i++) { $j = ($i + 7 + $weekstarts) % 7; if ($display_day[$j] == "1") { if ($this->dmy == 'day' && $d == $this->day && $this->h) { $s .= "<td class=\"week\">"; } else { $s .= "<td class=\"cellcalendar\">"; } if ($d > 0 && $d <= $daysInMonth) { $link = $this->getDateLink($d, $this->month, $this->year); if ($link == "") { $s .= $d; } elseif ($d == $this->day && $this->h) { $s .= $link . "><span class=\"cal_current_day\">{$d}</span></a>"; } else { $s .= $link . ">{$d}</a>"; } } else { $s .= " "; } $s .= "</td>\n"; } $d++; } return array($d, $s); } /** * @param integer $d * @param integer $daysInMonth * @param string $week_today * @param string $week * @param integer $temp * @return string $s */ private function DayOfMonth($d, $daysInMonth, $week_today, $week, $temp) { global $weekstarts; $s = ''; while ($d <= $daysInMonth) { $bg_lign = ''; if ($week_today == $week && $this->h && ($this->dmy == 'week_all' || $this->dmy == 'week')) { $bg_lign = " class=\"week\""; } $s .= "<tr " . $bg_lign . "><td class=\"calendarcol1 lienSemaine\">"; $t = "<a onclick=\"charger();\" title=\"" . htmlspecialchars(get_vocab("see_week_for_this_area")) . "\" href=\"week_all.php?year={$this->year}&month={$this->month}&day={$temp}&area={$this->area}\">" . sprintf("%02d", $week) . "</a>"; if ($this->dmy != 'day' && $this->dmy != 'week_all' && $this->dmy != 'month_all' && $this->dmy != 'month_all2') { $t = "<a onclick=\"charger();\" title=\"" . htmlspecialchars(get_vocab("see_week_for_this_room")) . "\" href=\"week.php?year={$this->year}&month={$this->month}&day={$temp}&area={$this->area}&room={$this->room}\">" . sprintf("%02d", $week) . "</a>"; } $s .= $t; $temp = $temp + 7; while (!checkdate($this->month, $temp, $this->year) && $temp > 0) { $temp--; } $date = mktime(12, 0, 0, $this->month, $temp, $this->year); $week = $this->getWeekNumber($date); $s .= "</td>\n"; $ret = $this->getNumber($weekstarts, $d, $daysInMonth); $d = $ret[0]; $s .= $ret[1]; $s .= "</tr>\n"; } return $s; } private function GetAction() { $action = "day.php?year=" . date('Y', time()) . "&month=" . date('m', time()) . "&day=" . date('d', time()); if (isset($_GET['area']) && $_GET['area'] != null) { $action .= "&area=" . $_GET['area']; } if (isset($_GET['room']) && $_GET['room'] != null) { $action .= "&room=" . $_GET['room']; } if (isset($_GET['id_site']) && $_GET['id_site'] != null) { $action .= "&site=" . $_GET['id_site']; } return $action; } private function getDaysInMonth($month, $year) { return date('t', mktime(0, 0, 0, $month, 1, $year)); } private function getFirstDays() { global $weekstarts, $display_day; $basetime = mktime(12, 0, 0, 6, 11 + $weekstarts, 2000); for ($i = 0, $s = ""; $i < 7; $i++) { $j = ($i + 7 + $weekstarts) % 7; $show = $basetime + $i * 24 * 60 * 60; $fl = ucfirst(utf8_strftime('%a', $show)); if ($display_day[$j] == 1) { $s .= '<td class="calendarcol1">' . $fl . '</td>' . PHP_EOL; } else { $s .= ""; } } return $s; } private function getWeekNumber($date) { return date('W', $date); } public function getHTML() { global $weekstarts, $vocab, $type_month_all, $display_day, $nb_display_day; $date_today = mktime(12, 0, 0, $this->month, $this->day, $this->year); $week_today = $this->getWeekNumber($date_today); if (!isset($weekstarts)) { $weekstarts = 0; } $s = ""; $daysInMonth = $this->getDaysInMonth($this->month, $this->year); $date = mktime(12, 0, 0, $this->month, 1, $this->year); $first = (strftime("%w", $date) + 7 - $weekstarts) % 7; $monthName = ucfirst(utf8_strftime("%B", $date)); $s .= PHP_EOL . '<table class="calendar">' . PHP_EOL; $s .= '<caption>' . PHP_EOL; $week = $this->getWeekNumber($date); $weekd = $week; $s .= '<div class="btn-group">' . PHP_EOL; $s .= $this->createlink(0, -1, $this->month, $this->year, $this->dmy, $this->room, $this->area, "previous_year", "backward"); $s .= $this->createlink(-1, 0, $this->month, $this->year, $this->dmy, $this->room, $this->area, "see_month_for_this_room", "chevron-left"); if ($this->dmy != 'day' && $this->dmy != 'week_all' && $this->dmy != 'month_all' && $this->dmy != 'month_all2') { $s .= '<button title="' . htmlspecialchars(get_vocab("see_all_the_rooms_for_the_month")) . '" class="btn btn-default btn-xs" onclick="charger();javascript: location.href=\'month.php?year=' . $this->year . '&month=' . $this->month . '&day=1&area=' . $this->area . '&room=' . $this->room . '\';">' . $monthName . ' ' . $this->year . '</button>' . PHP_EOL; } else { $s .= '<button title="' . htmlspecialchars(get_vocab("see_all_the_rooms_for_the_month")) . '" class="btn btn-default btn-xs" onclick="charger();javascript: location.href=\'' . $type_month_all . '.php?year=' . $this->year . '&month=' . $this->month . '&day=1&area=' . $this->area . '\';">' . $monthName . ' ' . $this->year . '</button>' . PHP_EOL; } $s .= $this->createlink(1, 0, $this->month, $this->year, $this->dmy, $this->room, $this->area, "see_month_for_this_room", "chevron-right"); $s .= $this->createlink(0, 1, $this->month, $this->year, $this->dmy, $this->room, $this->area, "following_year", "forward"); $s .= '</div>' . PHP_EOL; $action = $this->GetAction(); $s .= '<br/><button title="' . htmlspecialchars(get_vocab("gototoday")) . '" class="btn btn-default btn-xs" onclick="charger();javascript: location.href=\'' . $action . '\';">' . get_vocab("gototoday") . '</button>' . PHP_EOL; $s .= '</caption>' . PHP_EOL; $s .= '<tr>' . PHP_EOL . '<td class="calendarcol1">' . get_vocab("semaine") . '</td>' . PHP_EOL; $s .= $this->getFirstDays(); $s .= '</tr>' . PHP_EOL; $d = 1 - $first; $temp = 1; $s .= $this->DayOfMonth($d, $daysInMonth, $week_today, $week, $temp); if ($week - $weekd < 6) { $s .= ""; } $s .= '</table>' . PHP_EOL; return $s; } } $nb_calendar = Settings::get("nb_calendar"); if ($nb_calendar >= 1) { $month_ = array(); $milieu = $nb_calendar % 2 == 1 ? ($nb_calendar + 1) / 2 : $nb_calendar / 2; for ($k = 1; $k < $milieu; $k++) { $month_[] = mktime(0, 0, 0, $month + $k - $milieu, 1, $year); } $month_[] = mktime(0, 0, 0, $month, $day, $year); for ($k = $milieu; $k < $nb_calendar; $k++) { $month_[] = mktime(0, 0, 0, $month + $k - $milieu + 1, 1, $year); } $ind = 1; foreach ($month_ as $key) { if ($ind == 1) { $mois_precedent = 1; } else { $mois_precedent = 0; } if ($ind == $nb_calendar) { $mois_suivant = 1; } else { $mois_suivant = 0; } if ($ind == $milieu) { $flag_surlignage = 1; } else { $flag_surlignage = 0; } $cal = new Calendar(date("d", $key), date("m", $key), date("Y", $key), $flag_surlignage, $area, $room, $dmy, $mois_precedent, $mois_suivant); echo $cal->getHTML(); $ind++; } } }
/** * $Log: mincals.inc.php,v $ * Revision 1.7 2010-01-06 10:21:20 grr * *** empty log message *** * * Revision 1.6 2008-11-16 22:00:59 grr * *** empty log message *** * * */ function minicals($year, $month, $day, $area, $room, $dmy) { global $display_day, $vocab; // Récupération des données concernant l'affichage du planning du domaine get_planning_area_values($area); // PHP Calendar Class // Copyright David Wilkinson 2000. All Rights reserved. // This software may be used, modified and distributed freely // providing this copyright notice remains intact at the head // of the file. // This software is freeware. The author accepts no liability for // any loss or damages whatsoever incurred directly or indirectly // from the use of this script. // URL: http://www.cascade.org.uk/software/php/calendar/ // Email: davidw@cascade.org.uk #constructeur de la classe calendar class Calendar { var $month; var $year; var $day; var $h; var $area; var $room; var $dmy; var $week; var $mois_precedent; var $mois_suivant; function Calendar($day, $month, $year, $h, $area, $room, $dmy, $mois_precedent, $mois_suivant) { $this->day = $day; $this->month = $month; $this->year = $year; $this->h = $h; $this->area = $area; $this->room = $room; $this->dmy = $dmy; $this->mois_precedent = $mois_precedent; $this->mois_suivant = $mois_suivant; } function getCalendarLink($month, $year) { return ""; } #Liens vers une une date donnée. function getDateLink($day, $month, $year) { global $vocab; if ($this->dmy=='day') return "<a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_the_day"))."\" href=\"".$this->dmy.".php?year=$year&month=$month&day=$day&area=".$this->area."\""; if ($this->dmy!='day') return "<a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_the_day"))."\" href=\"day.php?year=$year&month=$month&day=$day&area=".$this->area."\""; } function getHTML() { global $weekstarts, $vocab, $type_month_all, $display_day, $nb_display_day; // Calcul de la date courante $date_today = mktime(12, 0, 0, $this->month, $this->day, $this->year); // Calcul du numéro de semaine courante $week_today = numero_semaine($date_today); if (!isset($weekstarts)) $weekstarts = 0; $s = ""; $daysInMonth = getDaysInMonth($this->month, $this->year); // Calcul de la date au 1er du mois de la date courante $date = mktime(12, 0, 0, $this->month, 1, $this->year); $first = (strftime("%w",$date) + 7 - $weekstarts) % 7; $monthName = utf8_strftime("%B",$date); $prevMonth = $this->getCalendarLink($this->month - 1 > 0 ? $this->month - 1 : 12, $this->month - 1 > 0 ? $this->year : $this->year - 1); $nextMonth = $this->getCalendarLink($this->month + 1 <= 12 ? $this->month + 1 : 1, $this->month + 1 <= 12 ? $this->year : $this->year + 1); $s .= "<table border = \"0\" class=\"calendar\">\n"; $s .= "<tr><td></td>\n"; if (($this->h) and (($this->dmy=='month') or ($this->dmy=='month_all') or ($this->dmy=='month_all2') )) $bg_lign = "week"; else $bg_lign = 'calendarHeader'; $s .= "<td align=\"center\" valign=\"top\" class=\"$bg_lign\" colspan=\"".$nb_display_day."\">"; #Permet de récupérer le numéro de la 1ere semaine affichée par le mini calendrier. // $week = number_format(strftime("%W",$date),0); $week = numero_semaine($date); $weekd = $week; // on ajoute un lien vers le mois précédent if ($this->mois_precedent == 1) { $tmp = mktime(0, 0, 0, ($this->month)-1, 1, $this->year); $lastmonth = date("m",$tmp); $lastyear= date("Y",$tmp); if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all') and ($this->dmy!='month_all2')) $s .= "<a title=\"".grr_htmlSpecialChars(get_vocab("see_month_for_this_room"))."\" href=\"month.php?year=$lastyear&month=$lastmonth&day=1&area=$this->area&room=$this->room\"><<</a> "; else $s .= "<a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_the_month"))."\" href=\"".$type_month_all.".php?year=$lastyear&month=$lastmonth&day=1&area=$this->area\"><<</a> "; } if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all') and ($this->dmy!='month_all2')) $s .= "<a title=\"".grr_htmlSpecialChars(get_vocab("see_month_for_this_room"))."\" href=\"month.php?year=$this->year&month=$this->month&day=1&area=$this->area&room=$this->room\">$monthName $this->year</a>"; else $s .= "<a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_the_month"))."\" href=\"".$type_month_all.".php?year=$this->year&month=$this->month&day=1&area=$this->area\">$monthName $this->year</a>"; // on ajoute un lien vers le mois suivant if ($this->mois_suivant == 1) { $tmp = mktime(0, 0, 0, ($this->month)+1, 1, $this->year); $nextmonth = date("m",$tmp); $nextyear= date("Y",$tmp); if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all') and ($this->dmy!='month_all2')) $s .= " <a title=\"".grr_htmlSpecialChars(get_vocab("see_month_for_this_room"))."\" href=\"month.php?year=$nextyear&month=$nextmonth&day=1&area=$this->area&room=$this->room\">>></a>"; else $s .= " <a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_the_month"))."\" href=\"".$type_month_all.".php?year=$nextyear&month=$nextmonth&day=1&area=$this->area\">>></a>"; } $s .= "</td>\n"; $s .= "</tr>\n"; $s .= "<tr><td></td>\n"; $s .= getFirstDays(); $s .= "</tr>\n"; $d = 1 - $first; $temp = 1; while ($d <= $daysInMonth) { // if (($date_today <= $date) and ($this->h) and (($this->dmy=='week_all') or ($this->dmy=='week') )) $bg_lign = " class=\"week\""; else $bg_lign = ''; if (($week_today == $week) and ($this->h) and (($this->dmy=='week_all') or ($this->dmy=='week') )) $bg_lign = " class=\"week\""; else $bg_lign = ''; $s .= "<tr ".$bg_lign."><td class=\"calendarcol1\" align=\"right\" valign=\"top\">"; #Affichage du numéro de la semaine en cours à droite du calendrier et génère un lien sur la semaine voulue. if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all') and ($this->dmy!='month_all2')) $s .="<a title=\"".grr_htmlSpecialChars(get_vocab("see_week_for_this_room"))."\" href=\"week.php?year=$this->year&month=$this->month&day=$temp&area=$this->area&room=$this->room\">s".sprintf("%02d",$week)."</a>"; else $s .="<a title=\"".grr_htmlSpecialChars(get_vocab("see_week_for_this_area"))."\" href=\"week_all.php?year=$this->year&month=$this->month&day=$temp&area=$this->area\">s".sprintf("%02d",$week)."</a>"; $temp=$temp+7; while ((!checkdate($this->month, $temp, $this->year)) and ($temp > 0)) $temp--; #Nouveau affichage, affiche le numéro de la semaine dans l'année.Incrémentation de ce numéro à chaque nouvelle semaine. $date = mktime(12, 0, 0, $this->month, $temp, $this->year); $week = numero_semaine($date); $s .= "</td>\n"; for ($i = 0; $i < 7; $i++) { $j = ($i + 7 + $weekstarts) % 7; if ($display_day[$j] == "1") {// début condition "on n'affiche pas tous les jours de la semaine" if (($this->dmy == 'day') and ($d == $this->day) and ($this->h)) $s .= "<td class=\"week\" align=\"right\" valign=\"top\">"; else $s .= "<td class=\"calendar\" align=\"right\" valign=\"top\">"; if ($d > 0 && $d <= $daysInMonth) { $link = $this->getDateLink($d, $this->month, $this->year); if ($link == "") $s .= $d; #Permet de colorer la date affichée sur la page elseif (($d == $this->day) and ($this->h)) $s .= $link."><span class=\"cal_current_day\">$d</span></a>"; else $s .= $link.">$d</a>"; } else $s .= " "; $s .= "</td>\n"; }// fin condition "on n'affiche pas tous les jours de la semaine" $d++; } $s .= "</tr>\n"; } if ($week-$weekd<6) $s .= "<tr><td> </td></tr>"; $s .= "</table>\n"; return $s; } } $nb_calendar = getSettingValue("nb_calendar"); if ($nb_calendar >= 1) { if ($nb_calendar % 2 == 1) $milieu = ($nb_calendar+1)/2; else $milieu = $nb_calendar/2; // Les mois avant le mois courant for ($k=1;$k<$milieu;$k++) { $month_[]=mktime(0, 0, 0, $month+$k-$milieu, 1, $year); } // Le mois courant $month_[] = mktime(0, 0, 0, $month, $day, $year); // Les mois après le mois courant for ($k=$milieu;$k<$nb_calendar;$k++) { $month_[]=mktime(0, 0, 0, $month+$k-$milieu+1, 1, $year); } $ind=1; foreach ($month_ as $key) { if ($ind == 1) $mois_precedent=1; else $mois_precedent=0; if ($ind == $nb_calendar) $mois_suivant=1; else $mois_suivant=0; if ($ind == $milieu) $flag_surlignage=1; else $flag_surlignage=0; echo "<td>";$cal = new Calendar(date("d",$key), date("m",$key), date("Y",$key), $flag_surlignage, $area, $room, $dmy, $mois_precedent, $mois_suivant); echo $cal->getHTML(); // if ($ind == $milieu) echo "<a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_several_months"))."\" href=\"year.php?area=$area\">".$vocab["viewyear"]."</a>"; echo "</td>"; $ind++; } } // Affichage du lien "plusieurs mois" echo "<td>"; echo "<a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_several_months"))."\" href=\"year.php?area=$area\">".$vocab["viewyear"]."</a>"; echo "</td>"; }?>
function minicals($year, $month, $day, $area, $room, $dmy) { global $display_day, $vocab; get_planning_area_values($area); class Calendar { private $month; private $year; private $day; private $h; private $area; private $room; private $dmy; private $week; private $mois_precedent; private $mois_suivant; /** * @param string $day * @param string $month * @param string $year * @param int $h * @param int $mois_precedent * @param int $mois_suivant */ public function Calendar($day, $month, $year, $h, $area, $room, $dmy, $mois_precedent, $mois_suivant) { $this->day = $day; $this->month = $month; $this->year = $year; $this->h = $h; $this->area = $area; $this->room = $room; $this->dmy = $dmy; $this->mois_precedent = $mois_precedent; $this->mois_suivant = $mois_suivant; } /** * @param int $day * @param float $month * @param string $year */ private function getDateLink($day, $month, $year) { global $vocab; $tplArray['vocab']['see_all_the_rooms_for_the_day'] = htmlspecialchars(get_vocab('see_all_the_rooms_for_the_day')); if ($this->dmy == 'day') { if (isset($this->room)) { //return '<a onclick="charger();" class="calendar" title="'.htmlspecialchars(get_vocab('see_all_the_rooms_for_the_day')).'" href="'.$this->dmy.".php?year=$year&month=$month&day=$day&room=".$this->room.'"'; $tplArray['dateLink'] = $this->dmy . '.php?year=' . $year . '&month=' . $month . '&day=' . $day . '&room=' . $this->room; return $tplArray['dateLink']; } $tplArray['dateLink'] = $this->dmy . '.php?year=' . $year . '&month=' . $month . '&day=' . $day . '&area=' . $this->area; //return '<a onclick="charger();" class="calendar" title="'.htmlspecialchars(get_vocab('see_all_the_rooms_for_the_day')).'" href="'.$this->dmy.".php?year=$year&month=$month&day=$day&area=".$this->area.'"'; return $tplArray['dateLink']; } if ($this->dmy != 'day') { if (isset($this->room)) { //return '<a onclick="charger();" class="calendar" title="'.htmlspecialchars(get_vocab('see_all_the_rooms_for_the_day'))."\" href=\"day.php?year=$year&month=$month&day=$day&room=".$this->room.'"'; $tplArray['dateLink'] = 'day.php?year=' . $year . '&month=' . $month . '&day=' . $day . '&room=' . $this->room; return $tplArray['dateLink']; } //return '<a onclick="charger();" class="calendar" title="'.htmlspecialchars(get_vocab('see_all_the_rooms_for_the_day'))."\" href=\"day.php?year=$year&month=$month&day=$day&area=".$this->area.'"'; $tplArray['dateLink'] = 'day.php?year=' . $year . '&month=' . $month . '&day=' . $day . '&area=' . $this->area; return $tplArray['dateLink']; } } /** * @param int $m * @param int $y * @param string $month * @param string $year * @param string $text * @param string $glyph */ private function createlink($m, $y, $month, $year, $dmy, $room, $area, $text, $glyph) { global $vocab, $type_month_all; $tplArray['vocab'][$text] = htmlspecialchars(get_vocab($text)); $tmp = mktime(0, 0, 0, $month + $m, 1, $year + $y); $lastmonth = date('m', $tmp); $lastyear = date('Y', $tmp); if ($dmy != 'day' && $dmy != 'week_all' && $dmy != 'month_all' && $dmy != 'month_all2') { $tplArray['link'] = 'month_all2.php?year=' . $lastyear . '&month=' . $lastmonth . '&day=1&area=' . $this->area . '&room=' . $room; //return '<button type="button" title="'.htmlspecialchars(get_vocab($text))."\" class=\"btn btn-default btn-xs\" onclick=\"charger();javascript: location.href='month.php?year=$lastyear&month=$lastmonth&day=1&area=$this->area&room=$room';\"><span class=\"glyphicon glyphicon-$glyph\"></span></button>\n"; return $tplArray['link']; } else { $tplArray['link'] = $type_month_all . '.php?year=' . $lastyear . '&month=' . $lastmonth . '&day=1&area=' . $area; //return '<button type="button" title="'.htmlspecialchars(get_vocab($text))."\" class=\"btn btn-default btn-xs\" onclick=\"charger();javascript: location.href='".$type_month_all.".php?year=$lastyear&month=$lastmonth&day=1&area=$area';\"><span class=\"glyphicon glyphicon-$glyph\"></span></button>\n"; return $tplArray['link']; } } private function getNumber($weekstarts, $d, $daysInMonth) { global $display_day; $tplArray = []; $s = ''; for ($i = 0; $i < 7; $i++) { $j = ($i + 7 + $weekstarts) % 7; if ($display_day[$j] == '1') { if ($this->dmy == 'day' && $d == $this->day && $this->h) { $tplArray['numbers'][$d][$i]['week'] = true; //$s .= '<td class="week">'; } else { $tplArray['numbers'][$d][$i]['week'] = false; //$s .= '<td class="cellcalendar">'; } if ($d > 0 && $d <= $daysInMonth) { $link = $this->getDateLink($d, $this->month, $this->year); $tplArray['numbers'][$d][$i]['link'] = $link; if ($link == '') { $s .= $d; $tplArray['numbers'][$d][$i]['current'] = false; } elseif ($d == $this->day && $this->h) { $tplArray['numbers'][$d][$i]['current'] = true; //$s .= $link."><span class=\"cal_current_day\">$d</span></a>"; } else { //$s .= $link.">$d</a>"; $tplArray['numbers'][$d][$i]['current'] = false; } } else { //$s .= ' '; $tplArray['numbers'][$d][$i]['link'] = false; } //$s .= "</td>\n"; } $d++; } //return array($d, $s); $retour['data']['day'] = $d; $retour['data']['numbers'] = $tplArray; /* tableau de jour dans la semaine avec lien */ return $retour; } /** * @param int $d * @param int $daysInMonth * @param string $week_today * @param string $week * @param int $temp * * @return string $s */ private function DayOfMonth($d, $daysInMonth, $week_today, $week, $temp) { global $weekstarts; $tplArray = []; $s = ''; $i = 0; //echo "dans dayOfMonth avant while<br>"; //var_dump(); while ($d <= $daysInMonth) { //$bg_lign = ''; if ($week_today == $week && $this->h && ($this->dmy == 'week_all' || $this->dmy == 'week')) { $tplArray['dayInMonth'][$i]['week'] = true; //$bg_lign = ' class="week"'; } else { $tplArray['dayInMonth'][$i]['week'] = false; } //$s .= '<tr '.$bg_lign.'><td class="calendarcol1 lienSemaine">'; $tplArray['dayInMonth'][$i]['linkToWeekArea'] = 'week_all.php?year=' . $this->year . '&month=' . $this->month . '&day=' . $temp . '&area=' . $this->area; $tplArray['dayInMonth'][$i]['textToWeekArea'] = sprintf('%02d', $week); //$t = '<a onclick="charger();" title="'.htmlspecialchars(get_vocab('see_week_for_this_area'))."\" href=\"week_all.php?year=$this->year&month=$this->month&day=$temp&area=$this->area\">".sprintf('%02d', $week).'</a>'; if ($this->dmy != 'day' && $this->dmy != 'week_all' && $this->dmy != 'month_all' && $this->dmy != 'month_all2') { $tplArray['dayInMonth'][$i]['linkToWeekRoom'] = 'week.php?year=' . $this->year . '&month=' . $this->month . '&day=' . $temp . '&area=' . $this->area . '&room=' . $this->room; $tplArray['dayInMonth'][$i]['textToWeekRoom'] = sprintf('%02d', $week); //$t = '<a onclick="charger();" title="'.htmlspecialchars(get_vocab('see_week_for_this_room'))."\" href=\"week.php?year=$this->year&month=$this->month&day=$temp&area=$this->area&room=$this->room\">".sprintf('%02d', $week).'</a>'; } //$s .= $t; $temp = $temp + 7; while (!checkdate($this->month, $temp, $this->year) && $temp > 0) { $temp--; } $date = mktime(12, 0, 0, $this->month, $temp, $this->year); $week = $this->getWeekNumber($date); //$s .= "</td>\n"; $return = $this->getNumber($weekstarts, $d, $daysInMonth); $tplArray['dayInMonth'][$i]['numbers'] = $return['data']['numbers']; /*var_dump($tplArray);*/ $d = $return['data']['day']; //$s .= $ret[1]; //$s .= "</tr>\n"; ++$i; /*if ($i == 50) { break; }*/ } return $tplArray; } private function GetAction() { $action = 'day.php?year=' . date('Y', time()) . '&month=' . date('m', time()) . '&day=' . date('d', time()); if (isset($_GET['area']) && $_GET['area'] != null) { $action .= '&area=' . $_GET['area']; } if (isset($_GET['room']) && $_GET['room'] != null) { $action .= '&room=' . $_GET['room']; } if (isset($_GET['id_site']) && $_GET['id_site'] != null) { $action .= '&site=' . $_GET['id_site']; } return $action; } private function getDaysInMonth($month, $year) { return date('t', mktime(0, 0, 0, $month, 1, $year)); } private function getFirstDays() { global $weekstarts, $display_day; $basetime = mktime(12, 0, 0, 6, 11 + $weekstarts, 2000); $s = ''; for ($i = 0; $i < 7; ++$i) { $j = ($i + 7 + $weekstarts) % 7; $show = $basetime + $i * 24 * 60 * 60; $fl = ucfirst(utf8_strftime('%a', $show)); if ($display_day[$j] == 1) { $tplArray['firstDays'][$i] = $fl; $s .= "<td class=\"calendarcol1\">{$fl}</td>\n"; } else { $s .= ''; $tplArray['firstDays'][$i] = false; } } return $tplArray; } private function getWeekNumber($date) { return date('W', $date); } public function getHTML() { global $weekstarts, $vocab, $type_month_all, $display_day, $nb_display_day; $tplArray = []; $date_today = mktime(12, 0, 0, $this->month, $this->day, $this->year); $week_today = $this->getWeekNumber($date_today); if (!isset($weekstarts)) { $weekstarts = 0; } //$s = ''; $daysInMonth = $this->getDaysInMonth($this->month, $this->year); $date = mktime(12, 0, 0, $this->month, 1, $this->year); $first = (strftime('%w', $date) + 7 - $weekstarts) % 7; $monthName = ucfirst(utf8_strftime('%B', $date)); //$s .= "\n<table class=\"calendar\">\n"; //$s .= '<caption>'; $week = $this->getWeekNumber($date); //$weekd = $week; //$s .= '<div class="btn-group">'; $tplArray = $this->getFirstDays(); //$s .= $this->createlink(0, -1, $this->month, $this->year, $this->dmy, $this->room, $this->area, 'previous_year', 'backward'); $tplArray['previousYear'] = $this->createlink(0, -1, $this->month, $this->year, $this->dmy, $this->room, $this->area, 'previous_year', 'backward'); //$s .= $this->createlink(-1, 0, $this->month, $this->year, $this->dmy, $this->room, $this->area, 'see_month_for_this_room', 'chevron-left'); $tplArray['monthForThisRoomLeft'] = $this->createlink(-1, 0, $this->month, $this->year, $this->dmy, $this->room, $this->area, 'see_month_for_this_room', 'chevron-left'); $tplArray['monthForThisRoomLeftMoins2'] = $this->createlink(-2, 0, $this->month, $this->year, $this->dmy, $this->room, $this->area, 'see_month_for_this_room', 'chevron-left'); $tplArray['TextAllRoomsForTheMonth'] = $monthName . ' ' . $this->year; if ($this->dmy != 'day' && $this->dmy != 'week_all' && $this->dmy != 'month_all' && $this->dmy != 'month_all2') { $tplArray['linkAllRoomsForTheMonth'] = 'month.php?year=' . $this->year . '&month=' . $this->month . '&day=1&area=' . $this->area . '&room=' . $this->room; //$s .= '<button type="button" title="'.htmlspecialchars(get_vocab('see_all_the_rooms_for_the_month'))."\" class=\"btn btn-default btn-xs\" onclick=\"charger();javascript: location.href='month.php?year=$this->year&month=$this->month&day=1&area=$this->area&room=$this->room';\">$monthName $this->year</button>\n"; } else { //$s .= '<button type="button" title="'.htmlspecialchars(get_vocab('see_all_the_rooms_for_the_month'))."\" class=\"btn btn-default btn-xs\" onclick=\"charger();javascript: location.href='".$type_month_all.".php?year=$this->year&month=$this->month&day=1&area=$this->area';\">$monthName $this->year</button>\n"; $tplArray['linkAllRoomsForTheMonth'] = $type_month_all . '.php?year=' . $this->year . '&month=' . $this->month . '&day=1&area=' . $this->area; } /* ajouté pour avoir le month_all2 tout le temps prêt pour twig */ $tplArray['linkAllRoomsForTheMonth2'] = 'month_all2.php?year=' . $this->year . '&month=' . $this->month . '&day=1&area=' . $this->area; //$s .= $this->createlink(1, 0, $this->month, $this->year, $this->dmy, $this->room, $this->area, 'see_month_for_this_room', 'chevron-right'); $tplArray['monthForThisRoomRight'] = $this->createlink(1, 0, $this->month, $this->year, $this->dmy, $this->room, $this->area, 'see_month_for_this_room', 'chevron-right'); //$s .= $this->createlink(0, 1, $this->month, $this->year, $this->dmy, $this->room, $this->area, 'following_year', 'forward'); $tplArray['nextYear'] = $this->createlink(0, 1, $this->month, $this->year, $this->dmy, $this->room, $this->area, 'following_year', 'forward'); //$s .= '</div>'; $tplArray['action'] = $this->GetAction(); //$s .= '<br/><button type="button" title="'.htmlspecialchars(get_vocab('gototoday'))."\" class=\"btn btn-default btn-xs\" onclick=\"charger();javascript: location.href='".$action."';\">".get_vocab('gototoday').'</button>'; //$s .= '</caption>'; //$s .= '<tr><td class="calendarcol1">'.get_vocab('semaine')."</td>\n"; //$s .= $this->getFirstDays(); /*echo "avant dayOfMonth<br>"; var_dump($tplArray);*/ //$s .= "</tr>\n"; $d = 1 - $first; $temp = 1; $tplArray['daysOfTheMonth'] = $this->DayOfMonth($d, $daysInMonth, $week_today, $week, $temp); //$s .= $this->DayOfMonth($d, $daysInMonth, $week_today, $week, $temp); /*if ($week - $weekd < 6) { $s .= ''; } $s .= "</table>\n";*/ return $tplArray; } } $nb_calendar = Settings::get('nb_calendar'); if ($nb_calendar >= 1) { $month_ = array(); $milieu = $nb_calendar % 2 == 1 ? ($nb_calendar + 1) / 2 : $nb_calendar / 2; for ($k = 1; $k < $milieu; ++$k) { $month_[] = mktime(0, 0, 0, $month + $k - $milieu, 1, $year); } $month_[] = mktime(0, 0, 0, $month, $day, $year); for ($k = $milieu; $k < $nb_calendar; ++$k) { $month_[] = mktime(0, 0, 0, $month + $k - $milieu + 1, 1, $year); } $ind = 1; foreach ($month_ as $key) { if ($ind == 1) { $mois_precedent = 1; } else { $mois_precedent = 0; } if ($ind == $nb_calendar) { $mois_suivant = 1; } else { $mois_suivant = 0; } if ($ind == $milieu) { $flag_surlignage = 1; } else { $flag_surlignage = 0; } $cal = new Calendar(date('d', $key), date('m', $key), date('Y', $key), $flag_surlignage, $area, $room, $dmy, $mois_precedent, $mois_suivant); $tplArray['month'][$ind] = $cal->getHTML(); ++$ind; } return $tplArray; } }