$vocab[room] $area_room $areadescrip

\n"; $last_area_room = $area_room; } echo "
\n"; # Brief Description (title), linked to view_entry: echo "\n"; # From date-time and duration: echo "\n"; #Description echo "\n"; #Type de réservation $et = empty($typel[$row[5]]) ? "?$row[5]?" : $typel[$row[5]]; echo "\n"; #Affichage de "crée par" et de la date de la dernière mise à jour echo "\n"; echo "
" . htmlspecialchars($row[3]) . "" . describe_span($row[1], $row[2],$dformat) . "
". date("d\/m\/Y\ \-\ H\:i",$row[1])." ==> ".date("d\/m\/Y\ \-\ H\:i",$row[2])."
".$vocab['description']." " . nl2br(htmlspecialchars($row[4])) . "
".$vocab['type']." $et
".$vocab['createdby']." " . htmlspecialchars($row[6]) . ", ".$vocab['lastupdate']." " . date_time_string($row[7],$dformat) . "
\n"; } #Statistique d'une entrée. Cela va créer une table de toutes les areas et rooms uniques. #Cela va devenir la colonne et la ligne d'entête de la table de staistique.' # Collect summary statistics on one entry. See below for columns in $row[]. # $sumby selects grouping on brief description (d) or created by (c). # This also builds hash tables of all unique names and rooms. When sorted, # these will become the column and row headers of the summary table. function accumulate(&$row, &$count, &$hours, $report_start, $report_end, &$room_hash, &$name_hash) { global $sumby; #Description "Créer par": $name = htmlspecialchars($row[($sumby == "d" ? 3 : 6)]); #Area et room: $room = htmlspecialchars($row[8]) . "
" . htmlspecialchars($row[9]) . "
" .htmlspecialchars($row[10]); #Ajoute le nombre de réservations pour cette "room" et nom. @$count[$room][$name]++; #Ajoute le nombre d'heure ou la ressource est utilisée. @$hours[$room][$name] += (min((int)$row[2], $report_end) - max((int)$row[1], $report_start)) / 3600.0; $room_hash[$room] = 1; $name_hash[$name] = 1; } #Table contenant un compteur (int) et une heure (float): function cell($count, $hours) { echo "($count) " . sprintf("%.2f", $hours) . "\n"; } # Output the summary table (a "cross-tab report"). $count and $hours are # 2-dimensional sparse arrays indexed by [area/room][name]. # $room_hash & $name_hash are arrays with indexes naming unique rooms and names. function do_summary(&$count, &$hours, &$room_hash, &$name_hash) { global $vocab; # Make a sorted array of area/rooms, and of names, to use for column # and row indexes. Use the rooms and names hashes built by accumulate(). # At PHP4 we could use array_keys(). reset($room_hash); while (list($room_key) = each($room_hash)) $rooms[] = $room_key; ksort($rooms); reset($name_hash); while (list($name_key) = each($name_hash)) $names[] = $name_key; ksort($names); $n_rooms = sizeof($rooms); $n_names = sizeof($names); echo "

$vocab[summary_header]

\n"; echo "\n"; for ($c = 0; $c < $n_rooms; $c++) { echo "\n"; $col_count_total[$c] = 0; $col_hours_total[$c] = 0.0; } echo "\n"; $grand_count_total = 0; $grand_hours_total = 0; for ($r = 0; $r < $n_names; $r++) { $row_count_total = 0; $row_hours_total = 0.0; $name = $names[$r]; echo "\n"; for ($c = 0; $c < $n_rooms; $c++) { $room = $rooms[$c]; if (isset($count[$room][$name])) { $count_val = $count[$room][$name]; $hours_val = $hours[$room][$name]; cell($count_val, $hours_val); $row_count_total += $count_val; $row_hours_total += $hours_val; $col_count_total[$c] += $count_val; $col_hours_total[$c] += $hours_val; } else { echo "\n"; } } cell($row_count_total, $row_hours_total); echo "\n"; $grand_count_total += $row_count_total; $grand_hours_total += $row_hours_total; } echo "\n"; for ($c = 0; $c < $n_rooms; $c++) cell($col_count_total[$c], $col_hours_total[$c]); cell($grand_count_total, $grand_hours_total); echo "
 $rooms[$c]
$vocab[total]
$name 
$vocab[total]
\n"; } #Si nous ne savons pas la date, nous devons la créer if(!isset($day) or !isset($month) or !isset($year)) { $day = date("d"); $month = date("m"); $year = date("Y"); } if(empty($area)) $area = get_default_area(); #Affiche les informations dans l'header print_header($day, $month, $year, $area); if (isset($areamatch)) { #Applique les paramètres par defaut. #S'assurer que ces paramètres ne sont pas cités. $areamatch = unslashes($areamatch); $roommatch = unslashes($roommatch); $namematch = unslashes($namematch); $descrmatch = unslashes($descrmatch); $loginmatch = unslashes($loginmatch); #Mettre les valeurs par défaut quand le formulaire est réutilisé. $areamatch_default = htmlspecialchars($areamatch); $roommatch_default = htmlspecialchars($roommatch); $namematch_default = htmlspecialchars($namematch); $descrmatch_default = htmlspecialchars($descrmatch); $loginmatch_default = htmlspecialchars($loginmatch); } else { #Nouveau rapport (défaut). $areamatch_default = ""; $roommatch_default = ""; $namematch_default = ""; $descrmatch_default = ""; $loginmatch_default = ""; $From_day = $day; $From_month = $month; $From_year = $year; $To_time = mktime(0, 0, 0, $month, $day + $default_report_days, $year); $To_day = date("d", $To_time); $To_month = date("m", $To_time); $To_year = date("Y", $To_time); } #$summarize: 1=Rapport seulement, 2=Résumé seulement, 3=Les deux. if (empty($summarize)) $summarize = 1; #$sumby: d=Par une description brève, c=Par créateur. if (empty($sumby)) $sumby = "d"; #Le formulaire. if ($summarize != 4) { ?>

:
" . $vocab["report_only"];?> " . $vocab["summary_only"];?> " . $vocab["report_and_summary"];?> " . $vocab["csv"];?>
" . $vocab["sum_by_descrip"];?> " . $vocab["sum_by_creator"];?>
' . $vocab["ppreview"] . '

'; } #S'assurer que ces paramètres ne sont pas cités. $areamatch = unslashes($areamatch); $roommatch = unslashes($roommatch); $namematch = unslashes($namematch); $descrmatch = unslashes($descrmatch); #Les heures de début et de fin sont aussi utilisés pour mettre l'heure dans le rapport. $report_start = mktime(0, 0, 0, $From_month, $From_day, $From_year); $report_end = mktime(0, 0, 0, $To_month, $To_day+1, $To_year); # La requête SQL va contenir les colonnes suivantes: # Col Index Description: # 1 [0] Entry ID, Non affiché # 2 [1] Date de début (Unix) # 3 [2] Date de fin (Unix) # 4 [3] Descrition brêve,(HTML) # 5 [4] Descrition,(HTML) # 6 [5] Type # 7 [6] Créer par (nom ou IP), (HTML) # 8 [7] Timestamp (création), (Unix) # 9 [8] Area (HTML) # 10 [9] Room (HTML) # 11 [10] Room description $sql = "SELECT distinct e.id, e.start_time, e.end_time, e.name, e.description, " . "e.type, e.create_by, " . sql_syntax_timestamp_to_unix("e.timestamp") . ", a.area_name, r.room_name, r.description" . " FROM grr_entry e, grr_area a, grr_room r"; // Si l'utilisateur n'est pas administrateur, seuls les domaines auxquels il a accès sont pris en compte if(authGetUserLevel(getUserName(),-1) < 5) if ($test_grr_j_user_area != 0) $sql .= ", grr_j_user_area j "; $sql .= " WHERE e.room_id = r.id AND r.area_id = a.id"; // Si l'utilisateur n'est pas administrateur, seuls les domaines auxquels il a accès sont pris en compte if(authGetUserLevel(getUserName(),-1) < 5) if ($test_grr_j_user_area == 0) $sql .= " and a.access='a' "; else $sql .= " and ((j.login='".$_SESSION['login']."' and j.id_area=a.id and a.access='r') or (a.access='a')) "; $sql .= " AND e.start_time < $report_end AND e.end_time > $report_start"; if (!empty($areamatch)) $sql .= " AND" . sql_syntax_caseless_contains("a.area_name", $areamatch); if (!empty($roommatch)) $sql .= " AND" . sql_syntax_caseless_contains("r.room_name", $roommatch); if (!empty($namematch)) $sql .= " AND" . sql_syntax_caseless_contains("e.name", $namematch); if (!empty($descrmatch)) $sql .= " AND" . sql_syntax_caseless_contains("e.description", $descrmatch); if (!empty($loginmatch)) $sql .= " AND" . sql_syntax_caseless_contains("e.create_by", $loginmatch); #Trié par: Area, room, debut, date/heure. $sql .= " ORDER BY 9,10,2"; $res = sql_query($sql); if (! $res) fatal_error(0, sql_error()); $nmatch = sql_count($res); if ($nmatch == 0) { echo "

" . $vocab["nothing_found"] . "\n"; sql_free($res); } else { $last_area_room = ""; echo "

" . $nmatch . " " . ($nmatch == 1 ? $vocab["entry_found"] : $vocab["entries_found"]) . "\n"; for ($i = 0; ($row = sql_row($res, $i)); $i++) { if ($summarize & 1) reporton($row, $last_area_room, $dformat); if ($summarize & 2) accumulate($row, $count, $hours, $report_start, $report_end, $room_hash, $name_hash); } if ($summarize & 2) do_summary($count, $hours, $room_hash, $name_hash); if ($summarize & 4) { echo "

".$vocab["indexcsv"]."

"; echo'


'.$vocab["dlrapportcsv"].'
'; echo'


'.$vocab["dlresumecsv"].'
'; } } } include "trailer.inc.php";