diff --git a/src/holiday.php b/src/calendar.php
similarity index 83%
rename from src/holiday.php
rename to src/calendar.php
index 751cf5d..12caa70 100644
--- a/src/holiday.php
+++ b/src/calendar.php
@@ -11,9 +11,10 @@
@@ -43,7 +44,7 @@
Editar
- Borrar
+ Borrar
|
diff --git a/src/holiday_management.php b/src/calendar_management.php
similarity index 76%
rename from src/holiday_management.php
rename to src/calendar_management.php
index bfa1443..403668a 100644
--- a/src/holiday_management.php
+++ b/src/calendar_management.php
@@ -26,6 +26,15 @@ function holidayDeletion(){
header('location: calendar.php');
}
+
+function calendarConfig(){
+ $data = $_POST;
+ $pdo = connectDatabase();
+ configureCalendar($pdo, $data);
+ closeDatabase($pdo);
+ header('location: calendar.php');
+}
+
if (isset($_POST["create"])) {
holidayCreation();
}
@@ -38,3 +47,7 @@ if (isset($_POST["edit"])) {
if (isset($_GET["delete"])) {
holidayDeletion();
}
+
+if (isset($_POST["configure"])) {
+ calendarConfig();
+}
diff --git a/src/calendar_setup_form.php b/src/calendar_setup_form.php
new file mode 100644
index 0000000..dab3349
--- /dev/null
+++ b/src/calendar_setup_form.php
@@ -0,0 +1,67 @@
+
+
+
+
+ Gestión de usuarios
+
+
+
+
+
+
+
+
+
diff --git a/src/database.php b/src/database.php
index 5fa3fc2..2a41d89 100644
--- a/src/database.php
+++ b/src/database.php
@@ -247,4 +247,34 @@ function fetchLoginData($pdo, $data){
return $data;
}
+function checkExistingCalendar($pdo, $data){
+ $query = "SELECT * from calendario WHERE medico=?";
+ $result = $pdo->prepare($query);
+ $result->execute([$data["medico"]]);
+ $data = $result->fetch();
+ return $data;
+}
+
+
+function configureCalendar($pdo, $data){
+ $existing = checkExistingCalendar($pdo, $data);
+ if(!$existing){
+ $query = "INSERT INTO calendario
+ (hora_inicio_mañana, hora_fin_mañana, hora_inicio_tarde, hora_fin_tarde,
+ horario, sabado_habil, domingo_habil, duracion_cita_por_defecto, medico)
+ VALUES (?,?,?,?,?,?,?,?,?)";
+ $pdo->prepare($query)->execute([$data["hora_inicio_mañana"], $data["hora_fin_mañana"], $data["hora_inicio_tarde"],
+ $data["hora_fin_tarde"], $data["horario"], $data["sabado_habil"], $data["domingo_habil"],
+ $data["duracion_cita_por_defecto"], $data["medico"]]);
+ } else {
+ $query = "UPDATE calendario SET hora_inicio_mañana=?, hora_fin_mañana=?,
+ hora_inicio_tarde=?, hora_fin_tarde=?, horario=?, sabado_habil=?, domingo_habil=?,
+ duracion_cita_por_defecto=?, medico=? WHERE medico=?";
+ $pdo->prepare($query)->execute([$data["hora_inicio_mañana"], $data["hora_fin_mañana"], $data["hora_inicio_tarde"],
+ $data["hora_fin_tarde"], $data["horario"], $data["sabado_habil"], $data["domingo_habil"],
+ $data["duracion_cita_por_defecto"], $data["medico"], $data["medico"]]);
+ }
+ return "Calendario configurado con éxito";
+}
+
?>
diff --git a/src/holiday_create_form.php b/src/holiday_create_form.php
index a9d9fb0..8ff02be 100644
--- a/src/holiday_create_form.php
+++ b/src/holiday_create_form.php
@@ -6,7 +6,6 @@
-
@@ -16,7 +15,7 @@
$pdo = connectDatabase();
$doctors = listDoctors($pdo);
?>
-