|
|
|
|
|
|
Ajouter une réservation d'un equipement
|
|
|
?>
check_security(1);
?>
//':: handle the action
/*********************************************LE SWITCH****************************************/
switch ($action) {
/*********************************** SELECT *********************************************/
case "select_edit_events" :
//' select the requested key record from database
$b_error=false;
if ($id <> "")
db_E_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(); //idem que pour locaux
validate_time(); //idem que pour locaux
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_equipement();
if (!$b_error) {
db_insert_edit_events_equipement();
add_E_eventoccurs();
}
/*else
$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();//idem que pour locaux
validate_time();//idem que pour locaux
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_E_Update();
if ((!$b_error) && ($id<>"")) {
db_E_update_edit_events() ;
}
if (!$b_error) {
$dt_start=$dt_start." 00:00:00";
$dt_end=$dt_end." 00:00:00";
$sqlU="UPDATE eventsequipementoccur 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 eventsequipementoccur WHERE event_id=".$event_id."")
or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
if (!$b_error)
add_E_eventoccurs();
}else {
if (isset($_REQUEST["dt_occur"]))
$dt_occur=$_REQUEST["dt_occur"];
else $dt_occur="";
mysql_query("DELETE FROM eventsequipementoccur 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_equipement();
add_E_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 eventsequipementoccur WHERE event_id=".$event_id."")
or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
mysql_query("DELETE FROM eventsequipement WHERE event_id=".$event_id."")
or DIE ("Could not perform DELETE to table ".mysql_errno().": ".mysql_error());
}else db_delete_edit_Events_equipement();
$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, eventsequipement.event_id FROM eventsequipement, eventsequipementoccur WHERE ((eventsequipement.event_id = eventsequipementoccur.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(); //idem
}
display_errs();
display_msg();
if ($b_select_edit_events)
db_E_select_edit_events();
$b_hide_edit_Events=false;
if (!$b_hide_edit_Events) {
?>
}
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
include "../include/footer.inc";
?>