Skip to content

Commit

Permalink
Appointments are now accessible to the doctors
Browse files Browse the repository at this point in the history
  • Loading branch information
tiller1010 committed Jun 2, 2019
1 parent 98f82b1 commit f258503
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 24 deletions.
26 changes: 17 additions & 9 deletions appointment_handler.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php

$subject = $_GET['subject'];
$message = $_GET['message'];
session_start();

$_SESSION['subject'] = $_GET['subject'];
$_SESSION['message'] = $_GET['message'];

//The days of the week are in regular expression form to be case insensitive
$days_of_week = ["/Sunday/i", "/Monday/i", "/Tuesday/i", "/Wednesday/i", "/Thursday/i", "/Friday/i", "/Saturday/i"];

function hello(){
echo 'hello';
}

include('header.html');

require('connect_db.php');
Expand All @@ -22,14 +28,16 @@
if(preg_match($day, "$row[availability] <br>")){
//Trimmed slashes from day to display
$trimmed_day = str_replace('/i', '', substr_replace($day,'',0,1));
//Creates a hidden drop down list for each available time. Then links to the handler page once selected
echo "<td class='day'><span class='dropdown-menu-btn'>$trimmed_day
<select class='dropdown-menu' style='visibility: hidden;'>
<option>1:00</option>
<option>1:30</option>
<option>2:00</option>
<option>5:30</option>
<option>6:00</option>
<option>6:30</option>
<select class='dropdown-menu' style='visibility: hidden;' onchange='location = this.value;'>
<option value='appointment_handler.php'>Select a time</option>
<option value='appointment_submit.php?time=1:00&day=$trimmed_day&doctor=$row[last_name]'>1:00</option>
<option value='appointment_submit.php?time=1:30&day=$trimmed_day&doctor=$row[last_name]'>1:30</option>
<option value='appointment_submit.php?time=2:00&day=$trimmed_day&doctor=$row[last_name]'>2:00</option>
<option value='appointment_submit.php?time=5:30&day=$trimmed_day&doctor=$row[last_name]'>5:30</option>
<option value='appointment_submit.php?time=6:00&day=$trimmed_day&doctor=$row[last_name]'>6:00</option>
<option value='appointment_submit.php?time=6:30&day=$trimmed_day&doctor=$row[last_name]'>6:30</option>
</select>
</span></td>";
}
Expand Down
25 changes: 24 additions & 1 deletion dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,30 @@

session_start();

//Prevent users from reaching page without doctor validation
if(!isset($_SESSION['doctor_validate'])){
require('login_tools.php');
load();
}

include('header.html');

echo "Welcome to the dashboard, $_SESSION[first_name]";
echo "<br>";
echo "<a href='logout.php'>Logout</a>";
echo "<br>";

require('connect_db.php');

//Query database for appointments
$q = "SELECT * FROM appointments WHERE doctor = '$_SESSION[last_name]'";
$r = mysqli_query($dbc, $q);

echo "Welcome to the Dashboard $_SESSION[first_name]";
if(mysqli_num_rows($r) == 0){
echo "No new appointments.";
}
else{
while($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){
echo "$row[day] $row[time] with $row[doctor] <br>";
}
}
2 changes: 0 additions & 2 deletions doctor_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

<br>

<a href='register.php'>Register</a>

<?php

include('footer.html');
1 change: 0 additions & 1 deletion footer.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<footer>
<a href='doctor_login.php'>Doctor Sign In</a>
<h4>Website By Tyler Trout</h4>
</footer>
</body>
Expand Down
21 changes: 17 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
<?php

include('header.html');
include('logout_link.php');
echo "<a href='appointment.php'>Make an appointment today.</a>";
include('footer.html');
include('header.html');
include('logout_link.php');
echo "<a href='appointment.php'>Make an appointment today.</a>";
echo "<br>";
//Allow doctor to sign in, if they are already then link to dashboard
if(!isset($_SESSION['doctor_validate'])){
//Do not display doctor login if patient is logged in
if(!isset($_SESSION['user_id'])){
echo "<a href='doctor_login.php'>Doctor Sign In</a>";
}
}
else{
echo "<a href='dashboard.php'>Staff Dashboard</a>
<br>
<a href='logout.php'>Logout</a>";
}
include('footer.html');
2 changes: 1 addition & 1 deletion login_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@

}

//Apply DRY to this if it works
elseif($_POST['user-type'] == 'doctor'){

list($check, $data) = validate($dbc, $_POST['fullname'], $_POST['pass'], 'doctor');

if($check){
session_start();
$_SESSION['doctor_validate'] = true;
$_SESSION['first_name'] = $data['first_name'];
$_SESSION['last_name'] = $data['last_name'];

Expand Down
1 change: 1 addition & 0 deletions login_tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function validate($dbc, $user = '', $pwd = '', $usrType){
$q = "SELECT user_id, first_name, last_name FROM patients WHERE username = '$u' AND pass = SHA2('$p', 256)";
}
elseif($usrType == 'doctor'){
//Split fullname for query and session variable
$n = explode(' ', $u);
$f = $n[0];
$l = $n[1];
Expand Down
5 changes: 0 additions & 5 deletions logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

session_start();

if(!isset($_SESSION['user_id'])){
require('login_tools.php');
load();
}

include('header.html');

$_SESSION = array();
Expand Down
2 changes: 1 addition & 1 deletion scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ window.onload = function(){
dropDown.forEach((element) => {
element.addEventListener('click', () => {
let list = element.children[0];
list.style.visibility = (list.style.visibility == 'hidden') ? 'visible' : 'hidden';
list.style.visibility = 'visible';
})
})

Expand Down

0 comments on commit f258503

Please sign in to comment.