= 2) and ($rep_type==2)) $rep_type = 6; $rep_month = isset($_GET["rep_month"]) ? $_GET["rep_month"] : NULL; if (($rep_type==3) and ($rep_month == 3)) $rep_type =3; if (($rep_type==3) and ($rep_month == 5)) $rep_type =5; $returl = isset($_GET["returl"]) ? $_GET["returl"] : NULL; $create_by = isset($_GET["create_by"]) ? $_GET["create_by"] : NULL; $rep_id = isset($_GET["rep_id"]) ? $_GET["rep_id"] : NULL; $edit_type = isset($_GET["edit_type"]) ? $_GET["edit_type"] : NULL; $rep_day = isset($_GET["rep_day"]) ? $_GET["rep_day"] : NULL; $rep_end_day = isset($_GET["rep_end_day"]) ? $_GET["rep_end_day"] : NULL; $rep_end_month = isset($_GET["rep_end_month"]) ? $_GET["rep_end_month"] : NULL; $rep_end_year = isset($_GET["rep_end_year"]) ? $_GET["rep_end_year"] : NULL; $room_back = isset($_GET["room_back"]) ? $_GET["room_back"] : NULL; $page = isset($_GET["page"]) ? $_GET["page"] : NULL; if ($page == '') $page="day"; if ($hour > 23) $hour = 23; if ($minute > 59) $hour = 59; #If we dont know the right date then make it up if(!isset($day) or !isset($month) or !isset($year)) { $day = date("d"); $month = date("m"); $year = date("Y"); } if (isset($_SERVER['HTTP_REFERER'])) $back = $_SERVER['HTTP_REFERER']; if(empty($area)) $area = get_default_area(); if(authGetUserLevel(getUserName(),-1) < 2) { showAccessDenied($day, $month, $year, $area,$back); exit(); } if (check_begin_end_bookings($day, $month, $year)) { showNoBookings($day, $month, $year, $area,$back); exit(); } // Units start in seconds $units = 1.0; switch($dur_units) { case "years": $units *= 52; case "weeks": $units *= 7; case "days": $units *= 24; case "hours": $units *= 60; case "minutes": $units *= 60; case "seconds": break; } // Units are now in "$dur_units" numbers of seconds if(isset($all_day) && ($all_day == "yes")) { $starttime = mktime($morningstarts, 0, 0, $month, $day , $year); $endtime = mktime($eveningends, 0, $resolution, $month, $day, $year); } else { if (!$twentyfourhour_format) { if (isset($ampm) && ($ampm == "pm")) { $hour += 12; } } $starttime = mktime($hour, $minute, 0, $month, $day, $year); $endtime = mktime($hour, $minute, 0, $month, $day, $year) + ($units * $duration); # Round up the duration to the next whole resolution unit. # If they asked for 0 minutes, push that up to 1 resolution unit. $diff = $endtime - $starttime; if (($tmp = $diff % $resolution) != 0 || $diff == 0) $endtime += $resolution - $tmp; } if(isset($rep_type) && isset($rep_end_month) && isset($rep_end_day) && isset($rep_end_year)) // Si une périodicité a été définie { // Get the repeat entry settings // Calcul de la date de fin de périodicité $rep_enddate = mktime($hour, $minute, 0, $rep_end_month, $rep_end_day, $rep_end_year); // Cas où la date de fin de périodicité est supérieure à la date de fin de réservation if ($rep_enddate > getSettingValue("end_bookings")) $rep_enddate = getSettingValue("end_bookings"); } else // Si aucune périodicité n'a été définie $rep_type = 0; if(!isset($rep_day)) $rep_day = ""; # For weekly repeat(2), build string of weekdays to repeat on: $rep_opt = ""; if (($rep_type == 2) || ($rep_type == 6)) for ($i = 0; $i < 7; $i++) $rep_opt .= empty($rep_day[$i]) ? "0" : "1"; # Expand a series into a list of start times: if ($rep_type != 0) // $reps est un tableau des dates de début de réservation $reps = mrbsGetRepeatEntryList($starttime, isset($rep_enddate) ? $rep_enddate : 0, $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks); # When checking for overlaps, for Edit (not New), ignore this entry and series: $repeat_id = 0; if (isset($id) and ($id!=0)) { $ignore_id = $id; $repeat_id = sql_query1("SELECT repeat_id FROM grr_entry WHERE id=$id"); if ($repeat_id < 0) $repeat_id = 0; } else $ignore_id = 0; # Acquire mutex to lock out others trying to book the same slot(s). if (!sql_mutex_lock('grr_entry')) fatal_error(1, $vocab['failed_to_acquire']); $date_now = mktime(); $error_booking_in_past = 'no'; $error_booking_room_out = 'no'; foreach ( $rooms as $room_id ) { # On verifie qu'aucune réservation ne se situe dans la passé if ($rep_type != 0 && !empty($reps)) { $diff = $endtime - $starttime; $i = 0; while (($i < count($reps)) and ($error_booking_in_past == 'no')) { if (!(verif_booking_date(getUserName(), -1, $reps[$i], $date_now))) $error_booking_in_past = 'yes'; $i++; } } else { if (!(verif_booking_date(getUserName(), -1, $starttime, $date_now))) $error_booking_in_past = 'yes'; } $statut_room = sql_query1("select statut_room from grr_room where id = '$room_id'"); // on vérifie qu'un utilisateur non autorisé ne tente pas de réserver une ressource non disponible if (($statut_room == "0") and authGetUserLevel(getUserName(),$room_id) < 3) $error_booking_room_out = 'yes'; } # end foreach rooms // Si le test précédent est passé avec succès, # Check for any schedule conflicts in each room we're going to try and # book in $err = ""; if ($error_booking_in_past == 'no') { foreach ( $rooms as $room_id ) { if ($rep_type != 0 && !empty($reps)) { if(count($reps) < $max_rep_entrys) { $diff = $endtime - $starttime; for($i = 0; $i < count($reps); $i++) { $tmp = mrbsCheckFree($room_id, $reps[$i], $reps[$i] + $diff, $ignore_id, $repeat_id); if(!empty($tmp)) $err = $err . $tmp; } } else { $err .= $vocab["too_may_entrys"] . "
"; $hide_title = 1; } } else $err .= mrbsCheckFree($room_id, $starttime, $endtime-1, $ignore_id, 0); } # end foreach rooms } // Si tous les tests précédents sont passés avec succès : if (empty($err) and ($error_booking_in_past == 'no') and ($error_booking_room_out == 'no')) { // On teste si l'utilisateur a le droit d'effectuer la série de réservation, compte tenu des // réser déjà effectuées et de la limite posée sur la ressource foreach ( $rooms as $room_id ) { $area = mrbsGetRoomArea($room_id); // Contrôle droit d'écriture if (isset($id) and ($id!=0)) { if(!getWritable($create_by, getUserName(),$id)) { showAccessDenied($day, $month, $year, $area,$back); exit; } } // Contrôle accès restreint if(authUserAccesArea($_SESSION['login'], $area)==0) { showAccessDenied($day, $month, $year, $area,$back); exit(); } if ($rep_type != 0 && !empty($reps)) { if(UserRoomMaxBooking(getUserName(), $room_id, count($reps)) == 0) { showAccessDeniedMaxBookings($day, $month, $year, $area, $room_id, $back); exit(); } } else { if(UserRoomMaxBooking(getUserName(), $room_id, 1) == 0) { showAccessDeniedMaxBookings($day, $month, $year, $area, $room_id, $back); exit(); } } } foreach ( $rooms as $room_id ) { if($edit_type == "series") { mrbsCreateRepeatingEntrys($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt, $room_id, $create_by, $name, $type, $description, $rep_num_weeks); $new_id = sql_insert_id("grr_entry", "id"); if (getSettingValue("automatic_mail") == 'yes') { if (isset($id) and ($id!=0)) { echo send_mail($new_id,2,$dformat); } else { echo send_mail($new_id,1,$dformat); } } } else { # Mark changed entry in a series with entry_type 2: if ($repeat_id > 0) $entry_type = 2; else $entry_type = 0; # Create the entry: mrbsCreateSingleEntry($starttime, $endtime, $entry_type, $repeat_id, $room_id, $create_by, $name, $type, $description); $new_id = sql_insert_id("grr_entry", "id"); if (getSettingValue("automatic_mail") == 'yes') { if(isset($id) and ($id!=0)) { send_mail($new_id,2,$dformat); } else { send_mail($new_id,1,$dformat); } } } } # end foreach $rooms # Delete the original entry if(isset($id) and ($id!=0)) { mrbsDelEntry(getUserName(), $id, ($edit_type == "series"), 1); } sql_mutex_unlock('grr_entry'); $area = mrbsGetRoomArea($room_id); # Now its all done go back to the day view Header("Location: ".$page.".php?year=$year&month=$month&day=$day&area=$area&room=$room_back&display_message=yes"); // Header("Location: day.php?year=$year&month=$month&day=$day&area=$area&display_message=yes"); exit; } # The room was not free. sql_mutex_unlock('grr_entry'); // Si il y a tentative de réserver dans le passé if ($error_booking_in_past == 'yes') { $str_date = strftime("%d %B %Y, %H:%M", $date_now); print_header($day, $month, $year, $area); echo "
" . $vocab["booking_in_past_explain_with_periodicity"] . $str_date."
"; } else { echo "" . $vocab["booking_in_past_explain"] . $str_date."
"; } include "trailer.inc.php"; die(); } // Si l'utilisateur tente de réserver une ressource non disponible if ($error_booking_room_out == 'yes') { print_header($day, $month, $year, $area); echo "" . $vocab["tentative_reservation_ressource_indisponible"] . "
"; include "trailer.inc.php"; die(); } if(strlen($err)) { print_header($day, $month, $year, $area); echo ""; include "trailer.inc.php"; ?>