|
|
|
|
|
|
Ajouter une réservation d'un local
|
|
|
check_security(1);
?>
if (isset($_REQUEST["do_search"]))
$do_search = $_REQUEST["do_search"];
else $do_search ="";
if (isset($_REQUEST["sortby"]))
$sortby = $_REQUEST["sortby"];
else $sortby ="";
//''' request form keys and inputs
if (isset($_REQUEST["id"]))
$id = $_REQUEST["id"];
else $id ="";
//':: request action
if (isset($_REQUEST["action"]))
$action = strtolower($_REQUEST["action"]);
else $action ="";
if (isset($_REQUEST["tm_start"]))
$tm_start = $_REQUEST["tm_start"];
if (isset($_REQUEST["tm_end"]))
$tm_end = $_REQUEST["tm_end"];
if (isset($_REQUEST["event_id"]))
$event_id = $_REQUEST["event_id"];
//':: handle the action
if (!isset($recurring)) $recurring="";
/*********************************************LE SWITCH****************************************/
switch ($action) {
/***********************************selectionner*********************************************/
case "select_edit_events" :
//' select the requested key record from database
if ($id <> "")
db_select_edit_Events();
else {
$b_error = true;
$error_list["edit_edit_Events"]="Spécifier l’enregistrement.";
}
break;
/*******************************************Ajouter ********************************/
case "insert_edit_events" :
validate_edit_events();
validate_time();
if ($b_error == true) {
$recurring_end = 0;
$recurring = 0;
$error_list["invalid"]="Vérifier le format des entrées.";
}else {
if ((strlen($recurring_end)==0) or ($recurring=="")) {
$recurring_end = datevalue($dt_start);
$recurring=0;
}elseif (isDate($recurring_end))
$recurring_end = datevalue($recurring_end);
validate_reservation();
if (!$b_error) {
db_insert_edit_events();
if (!$b_error)
add_eventoccurs();
else
$error_list["invalid"]="Vérifier le format des entrées.";
}
}
break;
/**********************************************MODIFIER*******************************/
case "update_edit_events" :
echo "ligne 244 tm_start=".$tm_start;
validate_edit_events(); // correct
validate_time();
if ((strlen($recurring_end)==0) or ($recurring=="")) {
echo "ligne 248 dt_start".$dt_start."dt_end".$dt_end." ";
echo "ligne 249 recurring=".$recurring." ";
$dt_start=str_replace("/","-",$dt_start); echo "ligne 250 dt_start =".$dt_start;
$recurring_end=datevalue($dt_start); echo "ligne 251 recurring_end=".$recurring_end." ";
} /*****************Tres important a debuger tres vite****/
elseif (isDate($recurring_end)) {
$recurring_end= str_replace("/","-",$recurring_end);
$recurring_end=datevalue($recurring_end);
}
/*****************************************************************************/
validate_Update(); echo "ligne 259";
/*****************************************************************************/
if (isset($_REQUEST["recurring_update"]))
$recurring_update=$_REQUEST["recurring_update"];
if ((!$b_error) AND ($id<>"")) {
db_update_edit_events() ;
if ($recurring_update==1) {
mysql_query("DELETE FROM EventsOccur WHERE event_id=".to_sql($event_id,"number")) or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
if (!$b_error)
add_eventoccurs();
}else{
mysql_query("UPDATE EventsOccur SET dt_occur=".to_sql($dt_start,"absdate").",tm_start=". to_sql($tm_start,"absdate").", tm_end=".to_sql($tm_end,"absdate").", event_name=".to_sql($event_name,"text").", description=".to_sql($description,"text").", location=".to_sql($location,"text").",Organisme=".to_sql($Organisme,"text").",NomC=".to_sql($NomC,"text").",PrenomC=".to_sql($PrenomC,"text").",TelC=".to_sql($TelC,"text").",EmailC=".to_sql($EmailC,"text").",Cout=".to_sql($Cout,"text").",Tax=".to_sql($Tax,"text").", b_register=".to_sql($b_register,"number").", alert=".to_sql($alert,"number")." WHERE id = ".to_sql($id,"number"));
$msg_list["updsingle"]= "Enregistrement modifié";
}
}
break;
/************************************************DELETE****************************************/
case "delete_edit_events" :
//' delete the requested key database record
if ($id<>"") {
$recurring_update=$_REQUEST["recurring_update"];
if ($recurring_update==1) {
$event_id=$_REQUEST["event_id"];
mysql_query("DELETE FROM EventsOccur WHERE event_id=".to_sql($event_id,"number"))or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
mysql_query("DELETE FROM Events WHERE event_id=".to_sql($event_id,"number")) or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
}else{ db_delete_edit_events();
}
Header("Location: upd_events.php?msg=Enregistrement+supprimer+".$event_id."");
}else {
$b_error=true;
$error_list["delete"]="Pas d'enregistrement pour supprimer.";
}
break;
}
/**********************************************FIN DU SWITCH*********************************/
//':: handle the default case(s) (ignores value of action parameter)
$CodeAdmin = $_SESSION["CodeAdmin"];
if ($id <> "") {
//':: check user permission
if ($_SESSION["accesslevel"] < 3) {
$rs = mysql_query("SELECT id, Events.event_id FROM Events, EventsOccur WHERE ((Events.event_id = EventsOccur.event_id) AND (id = ".$id.") AND (CodeAdmin = ".to_sql($_SESSION["CodeAdmin"],"number")."))");
if (!$rs) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($rs)==0) {
$cannot_update = true;
$msg_list["noaccess"]= "Détail.";
}
$b_select_edit_events = true;
mysql_free_result($rs);
}else{
$b_select_edit_events = true;
}
}else{
get_defaults_edit_events();
}
display_errs();
display_msg();
if ($b_select_edit_events) db_select_edit_events();
$b_hide_edit_Events=false;
if (!$b_hide_edit_Events) {
?>
//':: end hide form if
}
//':: assure that any db resources are freed
//on error resume next
mysql_free_result($rs);
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
include "../include/footer.inc";
?>