-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddstock.php
251 lines (228 loc) · 8.86 KB
/
addstock.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<html>
<head>
<meta charset="utf-8">
<title>Add Stock</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js">
</script>
</head>
<style>
body,
h1 {
font-family: "Raleway", sans-serif
}
body,
html {
height: 100%
}
.bgimg {
min-height: 100%;
background-position: center;
background-size: cover;
}
.top {
background-color: #333;
overflow: hidden;
}
.top a {
float: left;
color: #ffffff;
text-align: center;
padding: 14px 16px;
font-size: 17px;
}
.top a:hover {
background-color: #ddd;
color: black;
}
.top a.active {
background-color: #A64564;
color: white;
}
.pp {
margin-top: 95px;
font-size: 23px;
text-align: center;
}
.ppp {
margin-top: 30px;
text-align: center;
margin-bottom: 30px;
}
</style>
<body>
<?php
session_start();
if(!isset($_SESSION['username']))
{
header("location:login.php?msg=Please Login");
}
$username=$_SESSION['username'];
if(isset($_GET['name']))
{
$name=$_GET['name'];
$id=$_GET['id'];
$prize=$_GET['prize'];
$quantity=$_GET['quantity'];
$catagory=$_GET['catagory'];
$minstock=$_GET['minstock'];
$username=$_SESSION['username'];
try
{
$dbhandler = new PDO('mysql:host=localhost;dbname=dm_project','root','');
//echo "Connection is established...<br/>";
$dbhandler->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$query=$dbhandler->prepare("INSERT INTO stock(name,id,prize,quantity,catagory,username,minstock) VALUES (?,?,?,?,?,?,?) ");
$query->execute(array($name,$id,$prize,$quantity,$catagory,$username,$minstock));
header("location:addstock.php?msg=Item Inserted Sucessfully");
}
catch(PDOException $e)
{
//echo $e->getMessage();
if($e->errorInfo[1]==1062)
{
header("location:addstock.php?msg=id is already Taken");
}
die();
}
}
?>
<div style="padding-top: 7px;"></div>
<div class="top">
<a href="dashboard.php">Dashboard</a>
<a class="active" href="addstock.php">Add Stock</a>
<a href="viewstock.php">View and Manage Stock</a>
<a href="feedback.php">Feedback</a>
<a href="logout.php">Logout</a>
</div>
<div class="teal lighten-2">
<h6 style="padding-top: 7px;color:black;" class="center large">Welcome <?php echo $username;?> !!! you are logged in !!</h6>
<div id="chart" class="card-panel lighten-2 z-depth-1" style="background: #333;color: white;">
<table>
<tr class="row">
<td class="col s6">
<form class="form-inline my-2 my-lg-0" action="searchbyname.php">
<table>
<tr class="row">
<td class="col s1">
<i class="material-icons white">search</i>
</td>
<td class="col s9">
<input style="color: white;" class="form-control mr-sm-1" type="search" placeholder="Search by names" aria-label="Search" name="name" >
</td>
<td class="col s2">
<input type="submit" class="btn btn-outline-success my-2 my-sm-0" value="search">
</td>
</tr>
</table>
</form>
</td>
<td class="col s6">
<form class="form-inline my-2 my-lg-0" action="searchbycat.php">
<table>
<tr class="row">
<td class="col s1">
<i class="material-icons white">search</i>
</td>
<td class="col s9">
<input style="color: white;" class="form-control mr-sm-1" type="search" placeholder="Search by catagories" aria-label="Search" name="catagory" >
</td>
<td class="col s2">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col s8">
<?php
if(isset($_GET['msg']))
{
?>
<p class="error"><h4> <?php echo " ".$_GET['msg'];?> </h4></p>
<?php
}
?>
<div class="row" style= "padding-top: 4%;padding-right: 4%;padding-left: 4%;">
<form action="addstock.php" class="col s12">
<div class="row">
<div class="input-field col s6">
<input name="name" id="stock_name" type="text" required placeholder="Enter stock name">
<label for="stock_name">Stock Name</label>
</div>
<div class="input-field col s6">
<input id="stock_id1" type="number" name="id" required placeholder="Enter unique Id">
<label for="stock_id1">Id</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="stock_cat" type="text" name="catagory" required placeholder="Enter catagory of stock">
<label for="stock_cat">Catagory</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="stock_prize" type="number" name="prize" required placeholder="Enter prize per each item">
<label for="stock_prize">Prize</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="stock_quantity" type="number" name="quantity" required placeholder="Enter current quantity">
<label for="stock_quantity">Quantity</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="stock_empty" type="number" name="minstock" required placeholder="Enter minimum amount of stock required">
<label for="stock_empty">Minimum required stock</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input class="btn green" type="submit" value="submit">
<input class="btn blue" type="reset" value="reset">
</div>
</div>
</form>
</div>
<p style="padding-left: 5.5%;">
<a href="viewstock.php">Click to view stock records.</a>
</p>
</div>
</div>
<script>
var date = new Date();
var d = date.getDay();
yr = date.getFullYear();
mon = date.getMonth() + 1;
dt = date.getDate();
var str = "d";
if (d == 0)
str = "Sunday";
if (d == 1)
str = "Monday";
if (d == 2)
str = "Tuesday";
if (d == 3)
str = "Wednesday";
if (d == 4)
str = "Thursday";
if (d == 5)
str = "Friday";
if (d == 6)
str = "Saturday";
var s=["JAN","FEB","MARCH","APRIL","MAY","JUNE","JULY","SEPT","OCT","NOV","DEC"];
document.getElementById("date").innerHTML = "It's" + str;
document.getElementById("day").innerHTML = dt + " " + s[mon-1];
</script>
</body>
</html>