-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin-actions-medication.php
144 lines (129 loc) · 6.17 KB
/
admin-actions-medication.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
<?php
$stmt = $dbconn->prepare("SELECT * FROM Medication");
$meds = array();
if ($stmt->execute()) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$medid = $row['Medication_ID'];
$meds[$medid]['Medication_ID'] = $row['Medication_ID'];
$meds[$medid]['Name'] = $row['Name'];
$meds[$medid]['Maximaldose'] = $row['Maximal dose'];
$meds[$medid]['Form'] = $row['Form'];
$meds[$medid]['Activesubstance'] = $row['Active substance'];
$meds[$medid]['Sideeffect'] = $row['Side effect'];
}
}
?>
<div class="container" style="margin-top: 10px; padding-right: 200px; padding-left: 200px;">
<div class="btn-group btn-group-justified">
<a href="#" role="button" class="btn btn-info setfilter" id="setFilter">Set filter</a>
<a href="index.php?search=3" role="button" class="btn btn-info setfilter" id="unsetFilter">Unset filter</a>
</div>
</div>
<div style="margin: 10px;">
<div class="table-responsive">
<table class="table-primary datatable">
<thead>
<tr class="header">
<?php
echo "<th>Medication name</th>";
echo "<th>Maximal dose</th>";
echo "<th>Form</th>";
echo "<th>Active substance</th>";
echo "<th>Side effect</th>";
if(isset($_SESSION['usertype']) && $_SESSION['usertype'] == "A"){
echo "<th>Edit</th>";
echo "<th>Delete</th>";
}
echo "</tr>";
echo"</thead>";
echo"<tbody>";
foreach ($meds as $medid => $meddata) {
echo "<tr>";
echo "<td>".$meddata['Name']."</td>";
echo "<td>".$meddata['Maximaldose']."</td>";
echo "<td>".$meddata['Form']."</td>";
echo "<td>".$meddata['Activesubstance']."</td>";
echo "<td>".$meddata['Sideeffect']."</td>";
$med_id = $meddata['Medication_ID'];
if(isset($_SESSION['usertype']) && $_SESSION['usertype'] == "A"){
echo "<td><a href=\"#\" onclick=\"transferPhpArray($med_id, 'Medication')\" role=\"button\" data-toggle=\"modal\" data-id=\"1\" data-target=\"#editMedModal\" class=\"btn btn-info \"><span class=\"glyphicon glyphicon-edit\"></span></td>";
echo "<td><a href=\"#\" onclick=\"transferPhpArray($med_id, 'Medication')\" role=\"button\" data-toggle=\"modal\" data-target=\"#deleteMedModal\" class=\"btn btn-danger \"><span class=\"glyphicon glyphicon-trash\"></span></td>";
}
}
?>
</tr>
</tbody>
</table>
</div>
</div>
<?create_unsuccessful_delete_modal("medDel", "3", "The medication record you want to delete can't be deleted because of its assignment in administration of medications. Sorry.")?>
<div class="modal fade" id="editMedModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Edit medication</h4>
</div>
<div class="modal-body">
<form method="post" action="index.php?search=3">
<div class="form-row ">
<div class="form-group col-md-6" style="padding-left: 0px">
<label>Medication Name:</label>
<?php create_input("text", "form-control", "Name", "Enter Name", $arrayregex['Name'], $arrayinputerrormessages["Name"], isset($Name) ? $Name : "", "true", $errors, $arrayerrormessages, "readonly");?>
</div>
<div class="form-group col-md-6 form-width" style="padding-right: 0px">
<label>Maximal dose:</label>
<?php create_input("text", "form-control", "Maximaldose", "Enter maximal dose", $arrayregex['PosNum'], $arrayinputerrormessages["PosNum"], isset($Maximaldose) ? $Maximaldose : "", "true", $errors, $arrayerrormessages, "");?>
</div>
</div>
<div class="form-group">
<label>Form:</label>
<select id="Form" name="Form" class="form-control">
<?php add_options_from_array($arrayforms, "");?>
</select>
</div>
<div class="form-group">
<label>Active substance:</label>
<?php create_input("text", "form-control", "Activesubstance", "Enter active substance", $arrayregex['Activesubstance'], $arrayinputerrormessages["Activesubstance"], isset($Activesubstance) ? $Activesubstance : "", "true", $errors, $arrayerrormessages, "");?>
</div>
<div class="form-group">
<label>Side effect:</label>
<?php create_input("text", "form-control", "Sideeffect", "Set side effect", $arrayregex['Sideeffect'], $arrayinputerrormessages["Sideeffect"], isset($Sideeffect) ? $Sideeffect : "", "true", $errors, $arrayerrormessages, "list=\"medsubs\"");?>
<datalist id="medsubs">
<?php add_options_from_array($arraysideeffects, isset($Sideeffect) ? $Sideeffect : "")?>
</datalist>
</div>
<div class="form-group">
<input class="hidden" name="Medication_ID">
</div>
<button type="submit" name="edit-medication" class="btn btn-primary">Save changes</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="deleteMedModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Delete medication</h4>
</div>
<div class="modal-body">
<p class="modal-delete">Do you really want to delete medication record?</p>
<form method="post" action="index.php?search=3">
<div class="form-group">
<input class="hidden" name="Medication_ID_Delete">
</div>
<button type="submit" name="delete-medication" class="btn btn-danger">Confirm</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>