// getPreviousEntryData to prepare entry comparison. if (isset($id)) { $mail_previous = getPreviousEntryData($id, 1); } $result = notifyAdminOnBooking(!isset($id), $new_id); } } } 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: $new_id = mrbsCreateSingleEntry($starttime, $endtime, $entry_type, $repeat_id, $room_id, $create_by, $name, $type, $description); // Send a mail to the Administrator if (MAIL_ADMIN_ON_BOOKINGS or MAIL_AREA_ADMIN_ON_BOOKINGS or MAIL_ROOM_ADMIN_ON_BOOKINGS or MAIL_BOOKER) { include_once "functions_mail.inc"; // Send a mail only if this a new entry, or if this is an // edited entry but we have to send mail on every change, // and if mrbsCreateRepeatingEntrys is successful if ((isset($id) && MAIL_ADMIN_ALL or !isset($id)) && 0 != $new_id) { // Get room name and are name. Would be better to avoid // a database access just for that. Ran only if we need // details. if (MAIL_DETAILS) { $sql = "SELECT r.id, r.room_name, r.area_id, a.area_name "; $sql .= "FROM {$tbl_room} r, {$tbl_area} a "; $sql .= "WHERE r.id={$room_id} AND r.area_id = a.id"; $res = sql_query($sql);
} } else { if ($send_mail_moderate) { $message_error = send_mail($id_first_resa, 5, $dformat); } else { $message_error = send_mail($id_first_resa, 1, $dformat); } } } } else { if ($repeat_id > 0) { $entry_type = 2; } else { $entry_type = 0; } mrbsCreateSingleEntry($starttime, $endtime, $entry_type, $repeat_id, $room_id, $create_by, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $option_reservation, $overload_data, $entry_moderate, $rep_jour_c, $statut_entry, $keys, $courrier); $new_id = grr_sql_insert_id(); $idPourEvent = $new_id; if (Settings::get('automatic_mail') == 'yes') { if (isset($id) && $id != 0) { if ($send_mail_moderate) { $message_error = send_mail($new_id, 5, $dformat); } else { $message_error = send_mail($new_id, 2, $dformat); } } else { if ($send_mail_moderate) { $message_error = send_mail($new_id, 5, $dformat); } else { $message_error = send_mail($new_id, 1, $dformat); }
} $data['entry_type'] = $repeat_id > 0 ? ENTRY_RPT_CHANGED : ENTRY_SINGLE; $data['repeat_id'] = $repeat_id; } // The following elements are needed for email notifications $data['duration'] = $duration; $data['dur_units'] = $dur_units; if ($edit_type == "series") { $booking = mrbsCreateRepeatingEntrys($data); $new_id = $booking['id']; $is_repeat_table = $booking['series']; $data['id'] = $new_id; // Add in the id now we know it } else { // Create the entry: $new_id = mrbsCreateSingleEntry($data); $is_repeat_table = FALSE; $data['id'] = $new_id; // Add in the id now we know it } // Send an email if neccessary, provided that the entry creation was successful if ($need_to_send_mail && !empty($new_id)) { // Only send an email if (a) this is a changed entry and we have to send emails // on change or (b) it's a new entry and we have to send emails for new entries if (isset($id) && $mail_settings['on_change'] || !isset($id) && $mail_settings['on_new']) { require_once "functions_mail.inc"; // Get room name and area name for email notifications. // Would be better to avoid a database access just for that. // Ran only if we need details if ($mail_settings['details']) { $sql = "SELECT R.room_name, A.area_name\n FROM {$tbl_room} R, {$tbl_area} A\n WHERE R.id={$room_id} AND R.area_id = A.id\n LIMIT 1";
/** mrbsCreateRepeatingEntrys() * * Creates a repeat entry in the data base + all the repeating entrys * * $starttime - Start time of entry * $endtime - End time of entry * $rep_type - The repeat type * $rep_enddate - When the repeating ends * $rep_opt - Any options associated with the entry * $room_id - Room ID * $owner - Owner * $name - Name * $type - Type (Internal/External) * $description - Description * * Returns: * 0 - An error occured while inserting the entry * non-zero - The entry's ID */ function mrbsCreateRepeatingEntrys($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt, $room_id, $owner, $name, $type, $description, $rep_num_weeks) { global $max_rep_entrys; $reps = mrbsGetRepeatEntryList($starttime, $rep_enddate, $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks); if (count($reps) > $max_rep_entrys) { return 0; } if (empty($reps)) { $ent = mrbsCreateSingleEntry($starttime, $endtime, 0, 0, $room_id, $owner, $name, $type, $description); return $ent; } $ent = mrbsCreateRepeatEntry($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt, $room_id, $owner, $name, $type, $description, $rep_num_weeks); if ($ent) { for ($i = 0; $i < count($reps); $i++) { # calculate diff each time and correct where events # cross DST $diff = $endtime - $starttime; $diff += cross_dst($reps[$i], $reps[$i] + $diff); mrbsCreateSingleEntry($reps[$i], $reps[$i] + $diff, 1, $ent, $room_id, $owner, $name, $type, $description); } } return $ent; }
/** mrbsCreateRepeatingEntrys() * * Creates a repeat entry in the data base + all the repeating entrys * * $starttime - Start time of entry * $endtime - End time of entry * $rep_type - The repeat type * $rep_enddate - When the repeating ends * $rep_opt - Any options associated with the entry * $room_id - Room ID * $beneficiaire - beneficiaire * $beneficiaire_ext - bénéficiaire extérieur * $name - Name * $type - Type (Internal/External) * $description - Description *$rep_jour_c - Le jour cycle d'une réservation, si aucun 0 * * Returns: * 0 - An error occured while inserting the entry * non-zero - The entry's ID */ function mrbsCreateRepeatingEntrys($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt, $room_id, $creator, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $rep_num_weeks, $option_reservation,$overload_data, $moderate, $rep_jour_c) { global $max_rep_entrys, $id_first_resa; $area = mrbsGetRoomArea($room_id); $reps = mrbsGetRepeatEntryList($starttime, $rep_enddate, $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks, $rep_jour_c, $area); if(count($reps) > $max_rep_entrys) return 0; if(empty($reps)) { mrbsCreateSingleEntry($starttime, $endtime, 0, 0, $room_id, $creator, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $option_reservation,$overload_data,$moderate, $rep_jour_c,"-"); $id_first_resa = grr_sql_insert_id("".TABLE_PREFIX."_entry", "id"); return; } $ent = mrbsCreateRepeatEntry($starttime, $endtime, $rep_type, $rep_enddate, $rep_opt, $room_id, $creator, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $rep_num_weeks,$overload_data, $rep_jour_c); if($ent) { $diff = $endtime - $starttime; for($i = 0; $i < count($reps); $i++) { mrbsCreateSingleEntry($reps[$i], $reps[$i] + $diff, 1, $ent, $room_id, $creator, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $option_reservation,$overload_data, $moderate, $rep_jour_c,"-"); $id_new_resa = grr_sql_insert_id("".TABLE_PREFIX."_entry", "id"); // s'il s'agit d'une modification d'une ressource déjà modérée et acceptée : on met à jour les infos dans la table ".TABLE_PREFIX."_entry_moderate if ($moderate==2) moderate_entry_do($id_new_resa,1,"","no"); // On récupère l'id de la première réservation de la série et qui sera utilisé pour l'enoi d'un mail if ($i == 0) $id_first_resa = $id_new_resa; } } return $ent; }
if ($endtime <= $starttime) { $erreur = 'y'; } } else { $starttime = mktime($morningstarts, 0, 0, $month, $day, $year); $endtime = mktime($eveningends, $eveningends_minutes, 0, $month, $day, $year); } if ($erreur != 'y') { // On efface toutes les résa en conflit $result += grrDelEntryInConflict($row[0], $starttime, $endtime, 0, 0, 1); // S'il s'agit d'une action de réservation, on réserve ! if ($type_resa == "resa") { // Par sécurité, on teste quand même s'il reste des conflits $err = mrbsCheckFree($row[0], $starttime, $endtime, 0, 0); if (!$err) { mrbsCreateSingleEntry($starttime, $endtime, 0, 0, $row[0], getUserName(), $beneficiaire, "", $name, $type_, $description, -1, array(), 0, 0, '-', 0, 0); } } } } $day++; } $month++; if ($month == 13) { $year++; $month = 1; } } } } }