-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshowroom.php
169 lines (129 loc) · 5.37 KB
/
showroom.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
<?php
session_start();
if(!isset($_SESSION['Eid']))
header('location:login.php');
$Sid = $_GET['Sid'];
?>
<?php include "head.php"; ?>
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "supermarket";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "<h1><center>Items in Showroom</center></h1>";
$sql = "SELECT * FROM showroom_item_details natural join item where Showroom_ID = $Sid";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table class = 'table table-hover table-striped'><tr><th>Item ID</th><th>Item Name</th><th>Quantity</th><th>Price per unit</th><th>Total price</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["Item_ID"]. "</td><td>" . $row["Item_Name"]. "</td><td>" . $row["Quantity"] . "</td><td>Rs." . $row["Item_Unit_Price"] . " per " . $row["Item_Units"] ."</td><td>" . $row["Item_Unit_Price"] * $row["Quantity"]. "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
echo "<h1><center>Sale history</center></h1>";
$sql = "SELECT * FROM sale natural join sale_item_details natural join showroom natural join item natural join customer where Showroom_ID = $Sid";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table class = 'table table-hover table-striped'><tr><th>Item ID</th><th>Item Name</th><th>Customer ID</th><th>Customer Name</th><th>Quantity</th><th>Price per unit</th><th>Total price</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["Item_ID"]. "</td><td>" . $row["Item_Name"]. "</td><td>" . $row["Customer_ID"]. "</td><td>" . $row["Customer_Name"]. "</td><td>" . $row["Quantity"] . "</td><td>Rs." . $row["Item_Unit_Price"] . " per " . $row["Item_Units"] ."</td><td>" . $row["Item_Unit_Price"] * $row["Quantity"]. "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
echo "<h1><center>Restock history</center></h1>";
$sql = "SELECT * FROM restock natural join restock_item_details natural join item where Showroom_ID = $Sid";
// echo $sql;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table class = 'table table-hover table-striped'><tr><th>Item ID</th><th>Item Name</th><th>Godown ID</th><th>Quantity</th><th>Price per unit</th><th>Total price</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["Item_ID"]. "</td><td>" . $row["Item_Name"]. "</td><td>" . $row["Godown_ID"]. "</td><td>" . $row["Quantity"] . "</td><td>Rs." . $row["Item_Unit_Price"] . " per " . $row["Item_Units"] ."</td><td>" . $row["Item_Unit_Price"] * $row["Quantity"]. "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
echo "<h1><center>Employee details</center></h1>";
$sql = "SELECT * FROM showroom_employee_details natural join employee where Showroom_ID = $Sid";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table class = 'table table-hover table-striped'><tr><th>Employee ID</th><th>Employee Name</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["Employee_ID"]. "</td><td>" . $row["Employee_Name"]. "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>
<div class = "container-fluid row padding" >
<div class="col-lg-3 col-md-6 col-sm-6" >
<h3 style = "padding-left: 20%"><br>Add Employees : </h3>
</div>
<div class="col-lg-9 col-md-6 col-sm-6" >
<form method="post">
<label>Employee- ID</label>
<br>
<select name="id">
<?php
$mysqli = new mysqli($servername, $username, $password, $dbname);
$sqlSelect="SELECT * FROM employee";
$result = $mysqli-> query ($sqlSelect);
while ($row = mysqli_fetch_array($result)) {
$rows1[] = $row;
}
foreach ($rows1 as $row) {
print "<option value='" . $row['Employee_ID'] . "'>" .$row['Employee_ID']."(". $row['Employee_Name'] . ")</option>";
}
?>
</select>
<button type="submit" name="button1">Add</button>
</form>
</div>
</div>
<br>
<?php
if(isset($_POST['button1']))
{
$id = $_POST['id'];
$con = mysqli_connect("127.0.0.1","root","");
mysqli_select_db($con, "supermarket");
$q = "select * from showroom_employee_details where Showroom_ID = $Sid and Employee_ID = $id";
$result = mysqli_query($con, $q);
$n = mysqli_num_rows($result);
if($n != 0)
{
echo "Employee exists!!";
}
else
{
$q = "INSERT INTO `showroom_employee_details` VALUES ('$Sid', '$id')";
echo $q;
if(mysqli_query($con, $q))
{
echo "Employee Added Successfully!!";
header("location:showroom.php?Sid=".$Sid);
}
else
{
echo "Employee cannot be added!! Check Details entered";
}
}
}
?>