Create appointment dialog on click

This commit is contained in:
coolneng 2020-06-26 12:19:51 +02:00
parent b93df4005b
commit 21213f993d
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
6 changed files with 1359 additions and 51 deletions

View File

@ -8,6 +8,7 @@
<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"/>
<link rel="stylesheet" href="static/fullcalendar.css" type="text/css" media="screen"/> <link rel="stylesheet" href="static/fullcalendar.css" type="text/css" media="screen"/>
<link rel="stylesheet" href="static/jquery-ui.css" type="text/css" media="screen"/>
<script src="static/jquery-3.5.1.min.js"></script> <script src="static/jquery-3.5.1.min.js"></script>
<script src="static/jquery-ui.min.js"></script> <script src="static/jquery-ui.min.js"></script>
<script src="static/moment.min.js"></script> <script src="static/moment.min.js"></script>
@ -20,6 +21,8 @@
include 'database.php'; include 'database.php';
$pdo = connectDatabase(); $pdo = connectDatabase();
$list = listPatients($pdo);
$calendar_settings = fetchCalendarSettings($pdo, $doctor);
?> ?>
<?php if($_SESSION["user_type"] == 1): ?> <?php if($_SESSION["user_type"] == 1): ?>
<form name="select_doctor" method="post" action="appointment_management.php"> <form name="select_doctor" method="post" action="appointment_management.php">
@ -35,6 +38,31 @@
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php closeDatabase($pdo); ?> <?php closeDatabase($pdo); ?>
<div id="dialog-form" title="Añadir cita">
<form>
<div class="input-group">
<label for="hora">Hora</label>
<input type="time" name="hora" value="">
</div>
<div class="input-group">
<label for="duracion">Duración</label>
<input type="number" name="duracion" value="<?php echo $calendar_settings[8]; ?>" step="30">
</div>
<div class="input-group">
<label for="observaciones">Observaciones</label>
<input type="text" name="observaciones" value="">
</div>
<div class="input-group">
<select id="paciente" name="paciente">
<option>Seleccione un paciente</option>
<?php foreach ($patients as $row) : ?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[1]; ?></option>
<?php endforeach ?>
</select>
</div>
<button class="create_btn" type="submit" name="crear" >Añadir cita</button>
</form>
</div>
<div class="response"></div> <div class="response"></div>
<div id="calendar"></div> <div id="calendar"></div>
</body> </body>

View File

@ -31,18 +31,8 @@ function listHolidays(){
} }
function listCalendarSettings(){
$pdo = connectDatabase();
$doctor = fetchDoctor($pdo);
$calendar_settings = fetchCalendarSettings($pdo, $doctor);
closeDatabase($pdo);
return json_encode($events);
}
if (isset($_GET["list"])) { if (isset($_GET["list"])) {
listEvents(); listEvents();
listHolidays(); listHolidays();
listCalendarSettings();
header('location: appointment.php'); header('location: appointment.php');
} }

View File

@ -17,7 +17,7 @@
left: 'prev,next,today', left: 'prev,next,today',
center: 'title', center: 'patient',
right: 'month,agendaWeek,agendaDay' right: 'month,agendaWeek,agendaDay'
@ -47,36 +47,12 @@
select: function(start, end, allDay) { select: function(start, end, allDay) {
var title = prompt('Título: '); $("#dialog-form").dialog({ modal: true, patient: event.paciente, width:450});
var duration = prompt('Duración: ');
var start = $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss");
var end = $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss");
$.ajax({
url: 'appointment_management.php',
data: 'title='+ title+'&start='+ start +'&end='+ end,
type: "POST",
success: function(json) {
alert('Added Successfully');
}
});
calendar.fullCalendar('renderEvent', calendar.fullCalendar('renderEvent',
{ {
title: title,
start: start, start: start,
end: end, end: end,
@ -106,7 +82,7 @@
url: 'update_events.php', url: 'update_events.php',
data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id , data: 'patient='+ event.patient+'&start='+ start +'&end='+ end +'&id='+ event.id ,
type: "POST", type: "POST",
@ -122,9 +98,9 @@
eventClick: function(event) { eventClick: function(event) {
var decision = confirm("Do you really want to do that?"); element.click(function() {
});
if (decision) {
$.ajax({ $.ajax({
@ -142,7 +118,6 @@
}); });
}
}, },
@ -156,7 +131,7 @@
url: 'update_events.php', url: 'update_events.php',
data: 'title='+ event.title+'&start='+ start +'&end='+ end +'&id='+ event.id , data: 'patient='+ event.patient+'&start='+ start +'&end='+ end +'&id='+ event.id ,
type: "POST", type: "POST",

View File

@ -326,6 +326,9 @@ function fetchCalendarSettings($pdo, $doctor)
$result = $pdo->prepare($query); $result = $pdo->prepare($query);
$result->execute([$doctor]); $result->execute([$doctor]);
$data = $result->fetch(); $data = $result->fetch();
if(empty($data[8])){
$data[8] = 60;
}
return $data; return $data;
} }

View File

@ -14,6 +14,7 @@
$pdo = connectDatabase(); $pdo = connectDatabase();
$data = fetchReportData($pdo, $_GET["edit"]); $data = fetchReportData($pdo, $_GET["edit"]);
$list = listPatients($pdo);
?> ?>
<form name="create_form" method="post" action="report_management.php"> <form name="create_form" method="post" action="report_management.php">
<div class="input-group"> <div class="input-group">

1311
src/static/jquery-ui.css vendored Normal file

File diff suppressed because it is too large Load Diff