This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visits.php
179 lines (169 loc) · 5.38 KB
/
visits.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
session_start();
if ( !isset($_SESSION['usr_id']) || !isset($_SESSION['username']) ) {
header('Location: /login/'); //User is not logged in. Redirect them to login page.
exit;
}
if ((isset($_GET['id']))&& (is_numeric($_GET['id']))) { //runs only if GET request AND ID is given in url that is numeric.
$page = isset($_GET['page']) ? $_GET['page']: 1;
$limit = isset($_GET['limit']) ? $_GET['limit']: 10;
$id= $_GET['id']; //get id from url
require_once($_SERVER['DOCUMENT_ROOT'].'/classes/Modify.php');
$modvisit = new Modify();
$visits = Array(); //defines empty array.
$queries = ["SELECT COUNT(*) as num FROM visits WHERE client_id=(?)", "SELECT visit_id,date,diagnosis FROM visits WHERE client_id=(?) ORDER BY date ASC", "SELECT first_name,last_name FROM clients WHERE client_id=(?)"];
for ($i=0; $i<3; $i++){
$out = $modvisit->add($queries[$i], 'i', $id,1);
if ($i==1) {
while ($row = $out->fetch_row()) {
array_push($visits, $row); //we will treat the array as an (array/stack) of arrays.
}
} else {
$result = $out->fetch_assoc();
if ($i==0) {
$count = $result['num'];
}
$result = $modvisit->htmlarrayescape($result); //prevent XSS injection.
}
}
if ($count == 0) {
$number_of_records = 0;
} else {
$number_of_records=$count;
}
require($_SERVER['DOCUMENT_ROOT'].'/utility/pages_calc.php');
$list = str_replace('?page=', '?id='.$id.'&page=', $list);
//print_r($visits); DEBUG OUTPUT.
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Visits</title>
<link rel="stylesheet" href="/css/bulma.css">
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
</head>
<body>
<nav class="navbar is-danger">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item" href="/index.php">Patients DB</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="menyoo">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="menyoo" class="navbar-menu">
<div class="navbar-end">
<a href="/logout.php" class="navbar-item"><i class="fas fa-sign-out-alt"></i> Logout</a>
</div>
</div>
</div>
</nav>
<section class="hero">
<div class="hero-body">
<div class="container">
<nav class="breadcrumb" aria-label="breadcrumbs">
<p class="is-pulled-right is-relative"><a class="button is-primary is-rounded" href="/visit.php?cid=<?=$id?>"><i class="far fa-calendar-plus"></i> Add Visit</a></p>
<ul>
<li><a href="/index.php">Home</a></li>
<li><a href="/info.php?id=<?=$id?>" ><?=$result['first_name']?> <?=$result['last_name']?></a></li>
<li class="is-active"><a href="#" aria-current="page">Visits</a></li>
</ul>
</nav>
</div>
<section class="section">
<div class="container">
<nav class="level">
<div class="level-left">
<div class="level-item">
<?php echo $list;?>
</div>
<div class="level-item">
<button class="button is-warning" id="SendServBtn" style="display:none;">Commit</button>
</div>
</div>
<div class="level-right">
<div class="level-item">
<h2 class="subtitle">Records/page : </h2>
<div class="dropdown is-up is-hoverable">
<div class="dropdown-trigger">
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu7">
<span><?=$limit;?></span>
<span class="icon is-small">
<i class="fas fa-angle-up" aria-hidden="true"></i>
</span>
</button>
</div>
<div class="dropdown-menu" id="dropdown-menu7" role="menu">
<div class="dropdown-content">
<a class="dropdown-item" href="/visits.php?page=<?=$page;?>&limit=100&id=<?=$id?>">
<p>100</p>
</a>
<a class="dropdown-item" href="/visits.php?page=<?=$page;?>&limit=50&id=<?=$id?>">
<p>50</p>
</a>
<a class="dropdown-item" href="/visits.php?page=<?=$page;?>&limit=20&id=<?=$id?>">
<p>20</p>
</a>
<a class="dropdown-item" href="/visits.php?page=<?=$page;?>&limit=10&id=<?=$id?>">
<p>10</p>
</a>
</div>
</div>
</div>
</div>
<div class="level-item">
<button class="button is-info" id="test" onclick="OnDelete(this)">Delete Mode: Off</button>
</div>
</div>
</nav>
<table class="table is-bordered is-hoverable is-fullwidth" id="patients_tb">
<thead>
<colgroup>
<col width="50%">
<col width="60%">
</colgroup>
</thead>
<tr>
<th>Date</th>
<th>Diagnosis</th>
</tr>
<tbody>
<?php if ($number_of_records != 0 ) {
while ($row = array_pop($visits)) {
$row = Modify::htmlarrayescape($row); //prevent XSS injection.
?>
<tr>
<td><a href="/visit.php?id=<?=$row[0]?>"><?=str_replace("-","/",Modify::dateconv($row[1]))?></a><input type="hidden" value="<?=$row[0]?>" name="visit_id"></td>
<td><a href="/visit.php?id=<?=$row[0]?>"><?=$row[2]?></a></td>
</tr>
<?php } } else { ?>
<tr>
<td colspan="2"><center><p>Hmm. It's very lonely here!</p></center></td>
<?php }; ?>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</div>
</section>
<!-- Burger Menu if mobile device -->
<script src="/js/nav_burger.js"></script>
<script>
var csrftoken =<?php echo "'".$_SESSION['token']."'" ?>;
var choosetable = "1";
var set_mode = 1;
</script>
<script src="/js/index/delete_entries.js"></script>
</body>
</html>