Add calendar configuration for each doctor

This commit is contained in:
coolneng 2020-06-22 01:49:49 +02:00
parent 229b03a3c9
commit 35d2b70ab6
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
6 changed files with 116 additions and 6 deletions

View File

@ -11,9 +11,10 @@
<body> <body>
<?php include 'navbar.php'; ?> <?php include 'navbar.php'; ?>
<div> <div>
<form method="post" action="holiday_management.php"> <form method="post" action="calendar_management.php">
<div class="search-group"> <div class="search-group">
<a href="holiday_create_form.php" class="create_btn" >Crear</a> <a href="holiday_create_form.php" class="create_btn" >Añadir festivo</a>
<a href="calendar_setup_form.php" class="create_btn" >Configurar calendario</a>
</div> </div>
</form> </form>
</div> </div>
@ -43,7 +44,7 @@
<a href="holiday_edit_form.php?edit=<?php echo $row[0]; ?>" class="edit_btn">Editar</a> <a href="holiday_edit_form.php?edit=<?php echo $row[0]; ?>" class="edit_btn">Editar</a>
</td> </td>
<td> <td>
<a href="holiday_management.php?delete=<?php echo $row[0]; ?>" class="del_btn">Borrar</a> <a href="calendar_management.php?delete=<?php echo $row[0]; ?>" class="del_btn">Borrar</a>
</td> </td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>

View File

@ -26,6 +26,15 @@ function holidayDeletion(){
header('location: calendar.php'); header('location: calendar.php');
} }
function calendarConfig(){
$data = $_POST;
$pdo = connectDatabase();
configureCalendar($pdo, $data);
closeDatabase($pdo);
header('location: calendar.php');
}
if (isset($_POST["create"])) { if (isset($_POST["create"])) {
holidayCreation(); holidayCreation();
} }
@ -38,3 +47,7 @@ if (isset($_POST["edit"])) {
if (isset($_GET["delete"])) { if (isset($_GET["delete"])) {
holidayDeletion(); holidayDeletion();
} }
if (isset($_POST["configure"])) {
calendarConfig();
}

View File

@ -0,0 +1,67 @@
<?php session_start(); ?>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Gestión de usuarios</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
</head>
<body>
<?php include 'navbar.php'; ?>
<?php
include 'database.php';
$pdo = connectDatabase();
$doctors = listDoctors($pdo);
?>
<form name="create_form" method="post" action="calendar_management.php">
<div class="input-group">
<select id="medico" name="medico">
<option>Seleccione un médico</option>
<?php foreach($doctors as $row) : ?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[1]; ?></option>
<?php endforeach ?>
</select>
</div>
<div class="input-group">
<label>Hora inicio mañana</label>
<input type="time" name="hora_inicio_mañana" value="">
</div>
<div class="input-group">
<label>Hora fin mañana</label>
<input type="time" name="hora_fin_mañana" value="">
</div>
<div class="input-group">
<label>Hora inicio tarde</label>
<input type="time" name="hora_inicio_tarde" value="">
</div>
<div class="input-group">
<label>Hora fin tarde</label>
<input type="time" name="hora_fin_tarde" value="">
</div>
<div class="select-input">
<label>Horario</label>
<select id="horario" name="horario">
<option value="mañana">mañana</option>
<option value="tarde">tarde</option>
<option value="completo">completo</option>
</select>
</div>
<div class="input-group">
<label>Sábado hábil</label>
<input type="checkbox" name="sabado_habil" value="1">
</div>
<div class="input-group">
<label>Domingo hábil</label>
<input type="checkbox" name="domingo_habil" value="1">
</div>
<div class="input-group">
<label>Duración de cita por defecto</label>
<input type="number" name="duracion_cita_por_defecto" value="">
</div>
<div class="input-group">
<button class="btn" type="submit" name="configure" >Guardar</button>
</div>
</form>
</body>

View File

@ -247,4 +247,34 @@ function fetchLoginData($pdo, $data){
return $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";
}
?> ?>

View File

@ -6,7 +6,6 @@
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="static/style.css" type="text/css" media="screen" /> <link rel="stylesheet" href="static/style.css" type="text/css" media="screen" />
<script src="validate_date.js"></script>
</head> </head>
<body> <body>
<?php include 'navbar.php'; ?> <?php include 'navbar.php'; ?>
@ -16,7 +15,7 @@
$pdo = connectDatabase(); $pdo = connectDatabase();
$doctors = listDoctors($pdo); $doctors = listDoctors($pdo);
?> ?>
<form name="create_form" method="post" action="holiday_management.php"> <form name="create_form" method="post" action="calendar_management.php">
<div class="input-group"> <div class="input-group">
<label>Fecha</label> <label>Fecha</label>
<input type="date" name="fecha_festivo" value=""> <input type="date" name="fecha_festivo" value="">

View File

@ -7,7 +7,7 @@
<li class="list"><a href="user.php">Usuarios</a></li> <li class="list"><a href="user.php">Usuarios</a></li>
<li class="list"><a href="patient.php">Pacientes</a></li> <li class="list"><a href="patient.php">Pacientes</a></li>
<li class="list"><a href="appointment.php">Citas</a></li> <li class="list"><a href="appointment.php">Citas</a></li>
<li class="list"><a href="holiday.php">Vacaciones</a></li> <li class="list"><a href="calendar.php">Calendario</a></li>
<?php endif; ?> <?php endif; ?>
<?php if($_SESSION["user_type"] == 2): ?> <?php if($_SESSION["user_type"] == 2): ?>
<li class="list"><a href="report.php">Informes</a></li> <li class="list"><a href="report.php">Informes</a></li>