-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstock_pharmacist.php
executable file
·133 lines (120 loc) · 5.22 KB
/
stock_pharmacist.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
<?php
session_start();
include_once('connect_db.php');
if(isset($_SESSION['username'])){
$id=$_SESSION['pharmacist_id'];
$user=$_SESSION['username'];
}else{
header("location:http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."index.php");
exit();
}
if(isset($_POST['submit'])){
$sname=$_POST['drug_name'];
$cat=$_POST['category'];
$des=$_POST['description'];
$com=$_POST['company'];
$sup=$_POST['supplier'];
$qua=$_POST['quantity'];
$cost=$_POST['cost'];
$sta="Available";
$sql=mysql_query("INSERT INTO stock(drug_name,category,description,company,supplier,quantity,cost,status,date_supplied)
VALUES('$sname','$cat','$des','$com','$sup','$qua','$cost','$sta',NOW())");
if($sql>0) {header("location:http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/stock_pharmacist.php");
}else{
$message1="<font color=red>Registration Failed, Try again</font>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $user;?>Agadi Sunrise Hospital</title>
<link rel="stylesheet" type="text/css" href="style/mystyle.css">
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="style/table.css" type="text/css" media="screen" />
<script src="js/function.js" type="text/javascript"></script>
<style>#left-column {height: 477px;}
#main {height: 477px;}</style>
</head>
<body>
<div id="content">
<div id="header">
<h1><a href="#"><img src="images/ash.gif"></a>Agadi Sunrise Hospital</h1></div>
<div id="left_column">
<div id="button">
<ul>
<li><a href="pharmacist.php">Dashboard</a></li>
<li><a href="prescription.php">Prescription</a></li>
<li><a href="stock_pharmacist.php">Stock</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div>
</div>
<div id="main">
<div id="tabbed_box" class="tabbed_box">
<h4>Manage Stock</h4>
<hr/>
<div class="tabbed_area">
<ul class="tabs">
<li><a href="javascript:tabSwitch('tab_1', 'content_1');" id="tab_1" class="active">View Stock</a></li>
<li><a href="javascript:tabSwitch('tab_2', 'content_2');" id="tab_2">Add Medicine</a></li>
</ul>
<div id="content_1" class="content">
<?php echo $message;
echo $message1;
?>
<?php
/*
View
Displays all data from 'Stock' table
*/
// connect to the database
include_once('connect_db.php');
// get results from database
$result = mysql_query("SELECT * FROM stock")
or die(mysql_error());
// display data in table
echo "<table border='1' cellpadding='3'>";
echo "<tr><th>ID</th><th>Name</th><th>Category</th><th>Description</th><th>Status </th><th>Date </th><th>Delete</th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['stock_id'] . '</td>';
echo '<td>' . $row['drug_name'] . '</td>';
echo '<td>' . $row['category'] . '</td>';
echo '<td>' . $row['description'] . '</td>';
echo '<td>' . $row['status'] . '</td>';
echo '<td>' . $row['date_supplied'] . '</td>';?>
<td><a href="delete_stock.php?stock_id=<?php echo $row['stock_id']?>"><img src="images/delete-icon.jpg" width="24" height="24" border="0" /></a></td>
<?php
}
// close table>
echo "</table>";
?>
</div>
<div id="content_2" class="content">
<!--Add Drug-->
<?php echo $message;
echo $message1;
?>
<form name="myform" onsubmit="return validateForm(this);" action="stock_pharmacist.php" method="post" >
<table width="420" height="106" border="0" >
<tr><td align="center"><input name="drug_name" type="text" style="width:170px" placeholder="Drug Name" required="required" id="drug_name" /></td></tr>
<tr><td align="center"><input name="category" type="text" style="width:170px" placeholder="Category" required="required" id="category"/></td></tr>
<tr><td align="center"><input name="description" type="text" style="width:170px" placeholder="Description" required="required" id="description" /></td></tr>
<tr><td align="center"><input name="company" type="text" style="width:170px" placeholder="Manufacturing Company" required="required" id="company" /></td></tr>
<tr><td align="center"><input name="supplier" type="text" style="width:170px" placeholder="Supplier" required="required" id="supplier" /></td></tr>
<tr><td align="center"><input name="quantity" type="text" style="width:170px" placeholder="Quantity" required="required" id="quantity" /></td></tr>
<tr><td align="center"><input name="cost" type="text" style="width:170px" placeholder="Unit Cost" required="required" id="cost" /></td></tr>
<tr><td align="center"><input name="submit" type="submit" value="Submit" id="submit"/></td></tr>
</table>
</form>
</div>
</div>
</div>
</div>
<div id="footer" align="Center">Developed by IT$ MINE</div>
</div>
</body>
</html>