-
Notifications
You must be signed in to change notification settings - Fork 0
/
pharm-pos2.php
165 lines (129 loc) · 3.79 KB
/
pharm-pos2.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="nav2.css">
<link rel="stylesheet" type="text/css" href="form3.css">
<link rel="stylesheet" type="text/css" href="table2.css">
<title>
New Sales
</title>
</head>
<body>
<div class="sidenav">
<h2 style="font-family:Arial; color:white; text-align:center;"> ONLINE PHARMACY </h2>
<a href="pharmmainpage.php">Dashboard</a>
<a href="pharm-inventory.php">View Inventory</a>
<a href="pharm-pos1.php">Add New Sale</a>
<button class="dropdown-btn">Customers
<i class="down"></i>
</button>
<div class="dropdown-container">
<a href="pharm-customer.php">Add New Customer</a>
<a href="pharm-customer-view.php">View Customers</a>
</div>
</div>
<?php
include "config.php";
session_start();
$sql="SELECT E_FNAME from EMPLOYEE WHERE E_ID='$_SESSION[user]'";
$result=$conn->query($sql);
$row=$result->fetch_row();
$ename=$row[0];
?>
<div class="topnav">
<a href="logout1.php">Logout(signed in as <?php echo $ename; ?>)</a>
</div>
<center>
<div class="head">
<h2> SALES INVOICE</h2>
</div>
</center>
<table align='right' id='table1'>
<tr>
<th>Medicine ID</th>
<th>Medicine Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Total Price</th>
<th>Action</th>
</tr>
<?php
if(isset($_GET['sid'])) {
$sid=$_GET['sid'];}
if(empty($sid))
{
$sql ="SHOW TABLE STATUS LIKE 'sales'";
if(!$result = $conn->query($sql)){
die('There was an error running the query [' . $conn->error . ']');
}
$row = $result->fetch_assoc();
$sid=$row['Auto_increment']-1;
}
if(!empty($sid)) {
$qry1 = "SELECT med_id,sale_qty,tot_price FROM sales_items where sale_id=$sid";
$result1 = $conn->query($qry1);
$sum=0;
if ($result1->num_rows > 0) {
while($row1 = $result1->fetch_assoc()) {
$medid=$row1["med_id"];
$qry2 = "SELECT med_name,med_price FROM meds where med_id=$medid";
$result2 = $conn->query($qry2);
$row2=$result2->fetch_row();
echo "<tr>";
echo "<td>" . $row1["med_id"]. "</td>";
echo "<td>" . $row2[0] . "</td>";
echo "<td>" . $row1["sale_qty"]. "</td>";
echo "<td>" . $row2[1] . "</td>";
echo "<td>" . $row1["tot_price"]. "</td>";
echo "<td align=center>";
echo "<a name='delete' class='button1 del-btn' href=pharm-pos-delete.php?mid=".$row1['med_id']."&slid=".$sid.">Delete</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
}
}
?>
<div class="one" style="background-color:white;">
<form method=post>
<a name='pos1' class='button1 view-btn' href=pharm-pos1.php?sid=".$sid.">Go Back to Sales Page</a>
<input type='submit' name='custadd' value='Complete Order'><br>
</form>
</div>
<?php
if(isset($_POST['custadd'])) {
$res=mysqli_query($conn,"SET @p0=$sid;");
$res=mysqli_query($conn,"CALL `TOTAL_AMT`(@p0,@p1);") or die(mysqli_error($conn));
$res=mysqli_query($conn,"SELECT @p1 as TOTAL;");
while($row=mysqli_fetch_array($res))
{
$tot=$row['TOTAL'];
}
echo "<table align='right' id='table1'>
<tr style='background-color: #f2f2f2;'>
<td>Total</td>
<td>";echo $tot;
echo "</td>
</tr>
</table>";
}
?>
</body>
<script>
var dropdown = document.getElementsByClassName("dropdown-btn");
var i;
for (i = 0; i < dropdown.length; i++) {
dropdown[i].addEventListener("click", function() {
this.classList.toggle("active");
var dropdownContent = this.nextElementSibling;
if (dropdownContent.style.display === "block") {
dropdownContent.style.display = "none";
} else {
dropdownContent.style.display = "block";
}
});
}
</script>
</html>