$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); #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 "
" . unhtmlentities($vocab["nothing_found"]) . "\r\n"; sql_free($res); } else { if ($sumby=="c") echo unhtmlentities($vocab["summarize_by"])." " .unhtmlentities($vocab["sum_by_creator"])." - $day $month $year;"; else echo unhtmlentities($vocab["summarize_by"])." " .unhtmlentities($vocab["sum_by_descrip"])." - $day $month $year;"; if ($areamatch != null or $roommatch != null or $namematch != null or $descrmatch != null) { echo unhtmlentities($vocab["enrecherchant"]); echo "$areamatch $roommatch $namematch $descrmatch - $From_day/$From_month/$From_year -> $To_day/$To_month/$To_year"; } echo "\r\n"; } for ($i = 0; ($row = sql_row($res, $i)); $i++) { accumulate($row, $count, $hours, $report_start, $report_end,$room_hash, $name_hash); } echo "\r\n".unhtmlentities($vocab["summarize_by"])."\r\n"; do_summary($count, $hours, $room_hash, $name_hash); echo "\r\n\r\n\r\n".unhtmlentities($vocab["summarize_by2"])."\r\n"; do_summary2($count, $hours, $room_hash, $name_hash); 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 cell1($count, $hours) { echo "". sprintf("%.2f", $hours) . ";"; } function cell2($count, $hours) { echo "$count;"; } #Table de résumé. $count et $hours sont 2 rangées indexées par [area/room][name]. # $room_hash & $name_hash sont des rangées avec des indexes appelant des rooms et noms uniques. function do_summary(&$count, &$hours, &$room_hash, &$name_hash) { echo" ;"; global $vocab; #Array de area/room et des noms pour utiliser pour la colonne et l'indexe. 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); for ($c = 0; $c < $n_rooms; $c++) { echo "$rooms[$c];"; $col_count_total[$c] = 0; $col_hours_total[$c] = 0.0; } echo unhtmlentities($vocab['total']).";\r\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]; if ($name!=null) echo "$name;"; else echo "Salles;"; 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]; cell1($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 ";"; } cell1($row_count_total, $row_hours_total); echo "\r\n"; $grand_count_total += $row_count_total; $grand_hours_total += $row_hours_total; } echo unhtmlentities($vocab['total']).";"; for ($c = 0; $c < $n_rooms; $c++) cell1($col_count_total[$c], $col_hours_total[$c]); cell1($grand_count_total, $grand_hours_total); } function do_summary2(&$count, &$hours, &$room_hash, &$name_hash) { echo" ;"; global $vocab; #Array de area/room et des noms pour utiliser pour la colonne et l'indexe. 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); for ($c = 0; $c < $n_rooms; $c++) { echo "$rooms[$c];"; $col_count_total[$c] = 0; $col_hours_total[$c] = 0.0; } echo unhtmlentities($vocab[total]).";\r\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]; if ($name!=null) echo "$name;"; else echo "Salles;"; 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]; cell2($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 ";"; } cell2($row_count_total, $row_hours_total); echo "\r\n"; $grand_count_total += $row_count_total; $grand_hours_total += $row_hours_total; } echo unhtmlentities($vocab[total]).";"; for ($c = 0; $c < $n_rooms; $c++) cell2($col_count_total[$c], $col_hours_total[$c]); cell2($grand_count_total, $grand_hours_total); } ?>