|
|
|
|
|
|
Ajouter une réservation d'un local
|
|
|
?>
check_security(1);
?>
//':: handle the action
/*********************************************LE SWITCH****************************************/
switch ($action) {
/*********************************** SELECT *********************************************/
case "select_edit_events" :
$b_error=false;
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" :
$b_error=false;
validate_edit_events();
validate_time();
if ($b_error) {
$recurring_end = 0;
$entry_type = 0;
$error_list["invalid"]="Vérifier le format des entrées.";
}else {
if ((strlen($recurring_end)==0) or ($entry_type=="")) {
$recurring_end = datevalue($dt_start);
$entry_type=0;
}else
$recurring_end = datevalue($recurring_end);
validate_reservation();
if (!$b_error){
db_insert_edit_events();
add_eventoccurs();
}//else echo $error_list["invalid"]="Vérifier le format des entrées";
}
break;
/**********************************************MODIFIER*******************************/
case "update_edit_events" :
if (isset($_REQUEST["recurring_update"])) {
$recurring_update=$_REQUEST["recurring_update"];
}else $recurring_update = 1;
/******************************************/
if ($recurring_update==1) {
$b_error=false;
validate_edit_events();
validate_time();
if ((strlen($recurring_end)==0) or ($entry_type=="")) {
$recurring_end=datevalue($dt_start); //faire exploser dt_start dans la fonction
$entry_type=0;
}
else {
$recurring_end=datevalue($recurring_end);
}
validate_Update(); // verifie les données a mettre a jour
if ((!$b_error) && ($id<>""))
db_update_edit_events() ;
if (!$b_error) {
$dt_start=$dt_start." 00:00:00";
$dt_end=$dt_end." 00:00:00";
$sqlU="UPDATE eventsoccur SET ";
$sqlU.="dt_occur='".$dt_start."', ";
$sqlU.="tm_start='".$tm_start."', ";
$sqlU.="tm_end='".$tm_end."', ";
$sqlU.="event_name='".$event_name."', ";
$sqlU.="description='".$description."', ";
$sqlU.="location=".$location.", ";
$sqlU.="Organisme=".$Organisme.", ";
$sqlU.="NomC='".$NomC."', ";
$sqlU.="PrenomC='".$PrenomC."', ";
$sqlU.="TelC='".$TelC."', ";
$sqlU.="EmailC='".$EmailC."', ";
$sqlU.="Cout='".$Cout."', ";
$sqlU.="Tax=".$Tax." "; //car format TinyInt
$sqlU.=" WHERE id = ".$id."";
mysql_query($sqlU)
or DIE ("Could not perform UPDATE to table ".mysql_errno().": ".mysql_error());
$msg_list["updsingle"]= "Enregistrement modifié";
}else $msg_list["updsingle"]= "Modification impossible :Vérifiez les horaires S.V.P.";
mysql_query("DELETE FROM eventsoccur WHERE event_id=".$event_id."")
or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
if (!$b_error)
add_eventoccurs();
}else { /*********************Reccuring_update=0*********************/
if (isset($_REQUEST["dt_occur"]))
$dt_occur=$_REQUEST["dt_occur"];
else $dt_occur="";
mysql_query("DELETE FROM eventsoccur WHERE id=".$id."")
or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
$b_error=false;
validate_edit_events();
validate_time();
if ((strlen($recurring_end)==0) or ($entry_type=="")) {
$recurring_end=$dt_occur; //faire exploser dt_start dans la fonction
$dt_start=$dt_occur;
$entry_type=0;
}
else {
$recurring_end=datevalue($recurring_end);
}
if (!$b_error){
db_insert_edit_Events();
add_eventoccurs();
}
}
break;
/************************************************DELETE****************************************/
case "delete_edit_events" :
// delete the requested key database record
$b_error=false;
if ($id<>"") {
if (isset($_REQUEST["recurring_update"]))
$recurring_update=$_REQUEST["recurring_update"];
else $recurring_update=0;
if ($recurring_update==1) {
$event_id=$_REQUEST["event_id"];
mysql_query("DELETE FROM eventsoccur WHERE event_id=".$event_id."")
or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
mysql_query("DELETE FROM events WHERE event_id=".$event_id."")
or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
}else db_delete_edit_Events();
$msg_list["db_delete_edit_Events"]="Le champ a été supprimé.";
}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) L'edition
$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 = ".$_SESSION["CodeAdmin"]."))");
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";
?>