Disable appointment selection for days off

This commit is contained in:
coolneng 2020-07-15 18:58:41 +02:00
parent 88c06ce169
commit 92cb51ae60
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
7 changed files with 57 additions and 8 deletions

View File

@ -26,6 +26,13 @@ function listHolidays($pdo){
}
function listCalendarSettings($pdo){
$doctor = fetchDoctor($pdo);
$calendar_settings = fetchCalendarSettings($pdo, $doctor);
return $calendar_settings;
}
function appointmentCreation(){
$data = $_POST;
$pdo = connectDatabase();

View File

@ -22,19 +22,29 @@
},
selectAllow: function(selectInfo){
var daysOff = null;
var holidays = null;
$.ajax({
url: 'holiday_feed.php',
url: 'holiday_feed.php' + queryString,
async: false,
dataType: 'json',
success: function (json) {
holidays = json;
}
});
$.ajax({
url: 'calendar_settings_feed.php' + queryString,
async: false,
dataType: 'json',
success: function (json) {
daysOff = json;
}
});
var date = selectInfo.start._d;
var formatted_date = date.toISOString().substr(0, 10);
var found = holidays.find(el => el.start === formatted_date);
if(found == null){
var foundHoliday = holidays.find(el => el.start === formatted_date);
var foundDayOff = daysOff.find(el => el === date.getDay());
if(foundDayOff == null && foundHoliday == null){
return true;
}
return false;

View File

@ -33,6 +33,12 @@ function holidayDeletion()
function calendarConfig()
{
$data = $_POST;
if (!isset($data["sabado_habil"])){
$data["sabado_habil"] = 0;
}
if (!isset($data["domingo_habil"])){
$data["domingo_habil"] = 0;
}
$pdo = connectDatabase();
configureCalendar($pdo, $data);
closeDatabase($pdo);

View File

@ -0,0 +1,28 @@
<?php
include 'appointment_management.php';
function formatArray($data){
$settings = array();
if(!$data["sabado_habil"]){
array_push($settings, 6);
}
if(!$data["domingo_habil"]){
array_push($settings, 0);
}
return $settings;
}
function fetchDatabase(){
$pdo = connectDatabase();
$data = listCalendarSettings($pdo);
closeDatabase($pdo);
return $data;
}
$result = fetchDatabase();
$events = formatArray($result);
echo json_encode($events);
?>

View File

@ -68,7 +68,7 @@
</div>
<div class="input-group">
<label>Duración de cita por defecto</label>
<input type="number" name="duracion_cita_por_defecto" value="">
<input type="number" name="duracion_cita_por_defecto" value="60" step="30">
</div>
<div class="input-group">
<button class="btn" type="submit" name="configure" >Guardar</button>

View File

@ -359,10 +359,10 @@ function configureCalendar($pdo, $data)
} 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=?";
duracion_cita_por_defecto=? 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"]]);
$data["duracion_cita_por_defecto"], $data["medico"]]);
}
return "Calendario configurado con éxito";
}

View File

@ -7,11 +7,9 @@ function formatArray($data){
foreach($data as $row){
$events[] = array(
"id" => $row["id"],
"title" => "Festivo",
"start" => $row["fecha_festivo"],
"description" => $row["tipo_festivo"],
"doctor" => $row["nombre"],
"groupId" => "holidays",
"rendering" => "background",
"color" => "#ffa6a3",
);