-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissueindex.php
130 lines (100 loc) · 3.97 KB
/
issueindex.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
<!DOCTYPE html>
<?php include "config.php"?>
<html>
<head>
<title>ISSUE</title>
<link rel="stylesheet" type="text/css" href="flatly.css">
<!-- <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
--></head>
<body>
<?php
include "config.php";
// Check connection
static $numberOfErrors = 0;
static $totalPrice; // check whether all the medicine in prescription available.
static $mediarray;
function procedure($drugname, $mysqli,$needQty){
global $numberOfErrors;
global $totalPrice;
global $mediarray;
$select = "SELECT qty, total FROM medicine WHERE drugname = '$drugname'";
$result = $mysqli -> query($select);
if ($result->num_rows > 0){
while($row = $result->fetch_assoc()) {
if($row["qty"]> $needQty){
$cost = $row["total"]*$needQty;
$totalPrice = $totalPrice + $cost;
$mediarray[$drugname] = "$cost";
// echo "hariiiiiiiiiiiii"."<br>";
}else{
$numberOfErrors = $numberOfErrors + 1;
echo "<div class='alert alert-dismissible alert-warning'>
<button type='button' class='close' data-dismiss='alert'>×</button>
<h4 class='alert-heading'>Warning!</h4>
<p class='mb-0'>Drugname : $drugname , Not sufficient stock... <a href='orderstock.php' class='alert-link'>Want Order?</a>.</p>
</div>";
}
}
}else{
$numberOfErrors = $numberOfErrors + 1;
echo "<div class='alert alert-dismissible alert-danger'>"."<button type='button' class='close' data-dismiss='alert'>×</button>
<h4 class='alert-heading'>Warning!</h4><strong> Drugname : $drugname , Not available in stock</strong> <a href='orderstock.php' class='alert-link'>Want order?</a>"."</div>";
}
}
if(isset($_POST['submit'])){
$thepatientregnum = $_POST['regnum'];
$sql = "SELECT Medicines, Quantity, Frequency, Consumption_period FROM prescriptiondata WHERE prescriptionid = '$thepatientregnum'";
$result = $mysqli->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$drugname = $row["Medicines"];
$needQty = $row["Quantity"]*$row["Frequency"]*$row["Consumption_period"];
// echo "need qty :".$needQty."<br>";
procedure($drugname,$mysqli,$needQty);
}
echo "<div class='container'><table class='table table-hover'>
<thead>
<tr>
<th scope='col'>Drug Name</th>
<th scope='col'>Cost</th>
</tr>
</thead>
<tbody> ";
foreach($mediarray as $x => $x_value) {
echo "<tr class='table-success'>";
echo "<td>$x</td>";
echo "<td>$x_value</td>";
}
echo "<thead>
<tr>
<th scope='col'>Total Cost</th>
<th scope='col'>$totalPrice</th>
</tr>
</thead>";
echo "</tbody>
</table> </div>";
if($numberOfErrors > 0){
echo "<div class='alert alert-dismissible alert-primary'>
<button type='button' class='close' data-dismiss='alert'>×</button>
<h4 class='alert-heading'>Choose!</h4>
<strong>All not Available!</strong> <a href='paymentselect.php' class='alert-link'>Issue available?</a> <a href='cancel.php' class='alert-link'>Cancel Order?</a>
</div>";
}else{
echo "<div class='alert alert-dismissible alert-primary'>
<button type='button' class='close' data-dismiss='alert'>×</button>
<h4 class='alert-heading'>Issue</h4>
<strong></strong> <a href='paymentselect.php' class='alert-link'>Issue </a> <a href='cancel.php' class='alert-link'>Cancel Order?</a>
</div>";
}
}else{
echo "<div class='alert alert-dismissible alert-primary'>
<button type='button' class='close' data-dismiss='alert'>×</button>
<h4 class='alert-heading'>No Entry For the prescriptionid</h4>
</div>";
}
// echo $mediarray;
}
$mysqli->close();
?>
</body>
</html>