|
|
|
|
|
|
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 ="";
echo "ici".$id;
//':: request action
if (isset($_REQUEST["action"]))
$action = lcase($_REQUEST["action"]);
else $action ="";
//':: handle the action
switch ($action) {
case "select_edit_events" :
//' select the requested key record from database
echo "ici1";
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;
//'******Update*******************************
case "update_edit_events" :
validate_edit_events();
validate_time();
if ((strlen($recurring_end)==0) or ($recurring=="")) {
$recurring_end=datevalue($dt_start);
$recurring=0;
}
elseif (isDate($recurring_end))
$recurring_end=datevalue($recurring_end);
validate_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;
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;
}
//':: handle the default case(s) (ignores value of action parameter)
$CodeAdmin = $_SESSION["CodeAdmin"];
if ($id <> "") {
echo "je suis la";
//':: 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();
//':: check if hide form var was set
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";
?>