-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbillout.php
138 lines (124 loc) · 4.2 KB
/
billout.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
<?php
session_start();
if(!isset($_SESSION['userId']))
{
header('location:login.php');
}
?>
<?php require "assets/function.php" ?>
<?php require 'assets/db.php';?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo siteTitle(); ?></title>
<?php require "assets/autoloader.php" ?>
<style type="text/css">
<?php include 'css/customStyle.css'; ?>
</style>
<?php
$notice="";
?>
</head>
<body style="background: #ECF0F5;padding:0;margin:0">
<div class="content2">
<div class="well well-sm" style="width: 77%;margin:auto;margin-top: 33px;">
<div class="well well-sm center"><h1><?php echo siteName(); ?></h1></div>
</div>
<br>
<div class="well well-sm" style="width: 77%;margin: auto;">
<table class="table table-bordered table-striped">
<tr>
<th>Name of Purchaser</th>
<td><?php echo $_POST['name'] ?></th>
<th>Contact Number</th>
<td><?php echo $_POST['contact'] ?></th>
</tr>
<tr>
<th>Bill Generated At:</th>
<td><?php echo date("Y-m-d h:i:sa"); ?></td>
<th>Transaction made by</th>
<td><?php echo adminName(); ?></td>
</tr>
<tr>
<th colspan="4" class="center"><h3>Purchase Item Details</h3></th>
</tr>
<tr>
<th>#</th>
<th>Medicine Name</th>
<th>Per Unit Price</th>
<th>Quantity</th>
</tr>
<?php
$i=$total=0;
foreach ($_SESSION['bill'] as $row)
{
$i++;
echo "<tr>";
echo "<td>$i</td>";
echo "<td>$row[name]</td>";
echo "<td>Rs. $row[price]</td>";
echo "<td>$row[qty]</td>";
echo "</tr>";
$total = $total + $row['price']*$row['qty'];
}
?>
<tr>
<td colspan="3" style="text-align: right;">Gross Total</td><th><?php echo $total; ?></th>
</tr>
<tr>
<td colspan="3" style="text-align: right;">Discournt</td><th style="border-bottom: 1px solid blue;"><?php echo $_POST['discount']; ?></th>
</tr>
<tr>
<td colspan="3" style="text-align: right;border-right: 1px solid blue">Gross Total</td><th style="border: 1px solid blue;"><?php echo $total-$_POST['discount']; ?></th>
</tr>
<tr>
<td class="center" colspan="4"><button class="btn btn-primary" onclick="window.print()">Print</button> <a href="index.php"><button class="btn btn-success">Go Back</button></a></td>
</tr>
</table>
</div>
</div>
<div id="billOut" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Purchaser Information</h4>
</div>
<div class="modal-body"> <form method="POST" action="billout.php">
<div style="width: 77%;margin: auto;">
<div class="form-group">
<label for="some" class="col-form-label">Name</label>
<input type="text" name="name" class="form-control" id="some" required>
</div>
<div class="form-group">
<label for="some" class="col-form-label">Contact</label>
<input type="text" name="contact" class="form-control" id="some" required>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" name="safeIn">View Bill</button>
</div>
</form>
</div>
</div>
</div>
<?php
$total = $total-$_POST['discount'];
if (!$con->query("insert into sold (name,contact,discount,amount,item,userId) values ('$_POST[name]','$_POST[contact]','$_POST[discount]','$total','$i','$_SESSION[userId]')"))
{
echo "Error is:".$con->error;
}
if (isset($_POST['billInfo']))
{
unset($_SESSION['bill']);
$_SESSION['bill'] = array();
}
?>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){$(".rightAccount").click(function(){$(".account").fadeToggle();});});
</script>