$old_enable_periods = grr_sql_query1("select enable_periods from " . TABLE_PREFIX . "_area WHERE id='" . $id_area . "'"); if ($old_enable_periods != $_POST['enable_periods']) { $del = grr_sql_query("DELETE " . TABLE_PREFIX . "_entry FROM " . TABLE_PREFIX . "_entry, " . TABLE_PREFIX . "_room, " . TABLE_PREFIX . "_area WHERE\n\t\t\t\t\t\t" . TABLE_PREFIX . "_entry.room_id = " . TABLE_PREFIX . "_room.id and\n\t\t\t\t\t\t" . TABLE_PREFIX . "_room.area_id = " . TABLE_PREFIX . "_area.id and\n\t\t\t\t\t\t" . TABLE_PREFIX . "_area.id = '" . $id_area . "'"); $del = grr_sql_query("DELETE " . TABLE_PREFIX . "_repeat FROM " . TABLE_PREFIX . "_repeat, " . TABLE_PREFIX . "_room, " . TABLE_PREFIX . "_area WHERE\n\t\t\t\t\t\t" . TABLE_PREFIX . "_repeat.room_id = " . TABLE_PREFIX . "_room.id and\n\t\t\t\t\t\t" . TABLE_PREFIX . "_room.area_id = " . TABLE_PREFIX . "_area.id and\n\t\t\t\t\t\t" . TABLE_PREFIX . "_area.id = '" . $id_area . "'"); } $sql = "UPDATE " . TABLE_PREFIX . "_area SET\n\t\t\t\tarea_name='" . protect_data_sql($area_name) . "',\n\t\t\t\taccess='" . protect_data_sql($access) . "',\n\t\t\t\torder_display='" . protect_data_sql($area_order) . "',\n\t\t\t\tip_adr='" . protect_data_sql($ip_adr) . "',\n\t\t\t\tcalendar_default_values = 'n',\n\t\t\t\tduree_max_resa_area = '" . protect_data_sql($duree_max_resa_area) . "',\n\t\t\t\tmorningstarts_area = '" . protect_data_sql($_POST['morningstarts_area']) . "',\n\t\t\t\teveningends_area = '" . protect_data_sql($_POST['eveningends_area']) . "',\n\t\t\t\tresolution_area = '" . protect_data_sql($_POST['resolution_area']) . "',\n\t\t\t\tduree_par_defaut_reservation_area = '" . protect_data_sql($_POST['duree_par_defaut_reservation_area']) . "',\n\t\t\t\teveningends_minutes_area = '" . protect_data_sql($_POST['eveningends_minutes_area']) . "',\n\t\t\t\tweekstarts_area = '" . protect_data_sql($_POST['weekstarts_area']) . "',\n\t\t\t\tenable_periods = '" . protect_data_sql($_POST['enable_periods']) . "',\n\t\t\t\ttwentyfourhour_format_area = '" . protect_data_sql($_POST['twentyfourhour_format_area']) . "',\n\t\t\t\tmax_booking='" . $max_booking . "',\n\t\t\t\tdisplay_days = '" . $display_days . "'\n\t\t\t\tWHERE id={$id_area}"; if (grr_sql_command($sql) < 0) { fatal_error(0, get_vocab('update_area_failed') . grr_sql_error()); $ok = 'no'; } } else { $sql = "INSERT INTO " . TABLE_PREFIX . "_area SET\n\t\t\t\tarea_name='" . protect_data_sql($area_name) . "',\n\t\t\t\taccess='" . protect_data_sql($access) . "',\n\t\t\t\torder_display='" . protect_data_sql($area_order) . "',\n\t\t\t\tip_adr='" . protect_data_sql($ip_adr) . "',\n\t\t\t\tcalendar_default_values = 'n',\n\t\t\t\tduree_max_resa_area = '" . protect_data_sql($duree_max_resa_area) . "',\n\t\t\t\tmorningstarts_area = '" . protect_data_sql($_POST['morningstarts_area']) . "',\n\t\t\t\teveningends_area = '" . protect_data_sql($_POST['eveningends_area']) . "',\n\t\t\t\tresolution_area = '" . protect_data_sql($_POST['resolution_area']) . "',\n\t\t\t\tduree_par_defaut_reservation_area = '" . protect_data_sql($_POST['duree_par_defaut_reservation_area']) . "',\n\t\t\t\teveningends_minutes_area = '" . protect_data_sql($_POST['eveningends_minutes_area']) . "',\n\t\t\t\tweekstarts_area = '" . protect_data_sql($_POST['weekstarts_area']) . "',\n\t\t\t\tenable_periods = '" . protect_data_sql($_POST['enable_periods']) . "',\n\t\t\t\ttwentyfourhour_format_area = '" . protect_data_sql($_POST['twentyfourhour_format_area']) . "',\n\t\t\t\tdisplay_days = '" . $display_days . "',\n\t\t\t\tmax_booking='" . $max_booking . "',\n\t\t\t\tid_type_par_defaut = '-1'\n\t\t\t\t"; if (grr_sql_command($sql) < 0) { fatal_error(1, "<p>" . grr_sql_error()); } $id_area = grr_sql_insert_id(); } // Affectation e un site if (Settings::get("module_multisite") == "Oui") { $sql = "delete from " . TABLE_PREFIX . "_j_site_area where id_area='" . $id_area . "'"; if (grr_sql_command($sql) < 0) { fatal_error(0, "<p>" . grr_sql_error() . "</p>"); } $sql = "INSERT INTO " . TABLE_PREFIX . "_j_site_area SET id_site='" . $id_site . "', id_area='" . $id_area . "'"; if (grr_sql_command($sql) < 0) { fatal_error(0, "<p>" . grr_sql_error() . "</p>"); } } #Si area_name est vide on le change maintenant que l'on a l'id area if ($area_name == '') { $area_name = get_vocab("match_area") . " " . $id_area;
} 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); } }
/** 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; }
calendar_default_values = 'n', duree_max_resa_area = '".protect_data_sql($duree_max_resa_area)."', morningstarts_area = '".protect_data_sql($_POST['morningstarts_area'])."', eveningends_area = '".protect_data_sql($_POST['eveningends_area'])."', resolution_area = '".protect_data_sql($_POST['resolution_area'])."', duree_par_defaut_reservation_area = '".protect_data_sql($_POST['duree_par_defaut_reservation_area'])."', eveningends_minutes_area = '".protect_data_sql($_POST['eveningends_minutes_area'])."', weekstarts_area = '".protect_data_sql($_POST['weekstarts_area'])."', enable_periods = '".protect_data_sql($_POST['enable_periods'])."', twentyfourhour_format_area = '".protect_data_sql($_POST['twentyfourhour_format_area'])."', display_days = '".$display_days."', max_booking='".$max_booking."', id_type_par_defaut = '-1' "; if (grr_sql_command($sql) < 0) fatal_error(1, "<p>" . grr_sql_error()); $id_area = grr_sql_insert_id("".TABLE_PREFIX."_area", "id"); } // Affectation à un site if (getSettingValue("module_multisite") == "Oui") { $sql = "delete from ".TABLE_PREFIX."_j_site_area where id_area='".$id_area."'"; if (grr_sql_command($sql) < 0) fatal_error(0, "<p>".grr_sql_error()."</p>"); $sql = "INSERT INTO ".TABLE_PREFIX."_j_site_area SET id_site='".$id_site."', id_area='".$id_area."'"; if (grr_sql_command($sql) < 0) fatal_error(0, "<p>".grr_sql_error()."</p>"); } #Si area_name est vide on le change maintenant que l'on a l'id area if ($area_name == '') { $area_name = get_vocab("match_area")." ".$id_area; grr_sql_command("UPDATE ".TABLE_PREFIX."_area SET area_name='".protect_data_sql($area_name)."' WHERE id=$id_area"); } #on crée ou recrée ".TABLE_PREFIX."_area_periodes pour le domaine
$message_error = send_mail($id_first_resa,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, $beneficiaire, $beneficiaire_ext, $name, $type, $description, $option_reservation,$overload_data, $entry_moderate, $rep_jour_c, $statut_entry); $new_id = grr_sql_insert_id("".TABLE_PREFIX."_entry", "id"); if (getSettingValue("automatic_mail") == 'yes') { // Modification if(isset($id) and ($id!=0)) if ($send_mail_moderate) $message_error = send_mail($new_id,5,$dformat); else $message_error = send_mail($new_id,2,$dformat); // Création else if ($send_mail_moderate) $message_error = send_mail($new_id,5,$dformat); else $message_error = send_mail($new_id,1,$dformat); }