From a772b300df26b6606975a7e67525198651e131c4 Mon Sep 17 00:00:00 2001 From: coolneng Date: Mon, 13 Jul 2020 19:03:06 +0200 Subject: [PATCH] Show appointment information on click --- src/appointment.php | 8 ++++++++ src/appointment_feed.php | 4 +++- src/calendar.js | 39 ++++++++++++++++++++++----------------- src/database.php | 2 +- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/appointment.php b/src/appointment.php index 4e08580..47dc623 100644 --- a/src/appointment.php +++ b/src/appointment.php @@ -69,5 +69,13 @@
+ diff --git a/src/appointment_feed.php b/src/appointment_feed.php index 3a8b08f..7f6511c 100644 --- a/src/appointment_feed.php +++ b/src/appointment_feed.php @@ -17,8 +17,10 @@ function renameArray($data){ foreach($data as $row){ $events[] = array( "id" => $row["id"], - "title" => "Cita de " . $row["apellido"], + "title" => $row["apellido"] . ", " . $row["nombre"], "start" => $row["fecha"] . " " . $row["hora"], + "description" => $row["observaciones"], + "patient" => $row["documento_identificativo"], "end" => $row["fecha"] . " " . $row["end"], ); } diff --git a/src/calendar.js b/src/calendar.js index ce7f8d9..9c996ba 100644 --- a/src/calendar.js +++ b/src/calendar.js @@ -1,30 +1,35 @@ $(document).ready(function() { - var queryString = window.location.search; var calendar = $('#calendar').fullCalendar({ - editable: true, + editable: true, - header: { - left: 'prev,next,today', - right: 'month,agendaWeek,agendaDay' - }, + header: { + left: 'prev,next,today', + right: 'month,agendaWeek,agendaDay' + }, + events: "appointment_feed.php" + queryString, - events: "appointment_feed.php" + queryString, + selectable: true, - selectable: true, + selectHelper: true, - selectHelper: true, + select: function(start, end, allDay) { + $("#dialog-form").dialog({ modal: true, width:450}); + var date = $.fullCalendar.formatDate(start, 'YYYY-MM-DD'); + $("#fecha").val(date); + }, - select: function(start, end, allDay) { - - $("#dialog-form").dialog({ modal: true, width:450}); - - var date = $.fullCalendar.formatDate(start, 'YYYY-MM-DD'); - - $("#fecha").val(date); - } + eventClick: function(event) { + var start = $.fullCalendar.formatDate(event.start, 'HH:mm'); + var end = $.fullCalendar.formatDate(event.end, 'HH:mm'); + $("#event-patient").html("DNI/NIE: " + event.patient); + $("#event-description").html("Observaciones: " + event.description); + $("#event-start").html("Comienzo: " + start); + $("#event-end").html("Fin: " + end); + $("#event-info").dialog({title: event.title, width:450}); + } }); }); diff --git a/src/database.php b/src/database.php index 96bac8c..2cd40f0 100644 --- a/src/database.php +++ b/src/database.php @@ -370,7 +370,7 @@ function configureCalendar($pdo, $data) function fetchCalendarEvents($pdo, $doctor) { - $query = "SELECT cita.id, fecha, hora, duracion, medico, observaciones, apellido, documento_identificativo from cita + $query = "SELECT cita.id, fecha, hora, duracion, medico, observaciones, nombre, apellido, documento_identificativo from cita INNER JOIN paciente ON cita.paciente = paciente.id WHERE medico=?"; $result = $pdo->prepare($query);