-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
351 lines (310 loc) · 10.2 KB
/
index.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<?php
include 'connection.php';
$sql = 'SELECT rate FROM gst where id=0';
$result = mysqli_query($con,$sql);
$roi = mysqli_fetch_row($result);
$sql2 = 'SELECT name,address FROM company where id=0';
$result2 = mysqli_query($con,$sql2);
$comp = mysqli_fetch_row($result2);
?>
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css">
<style type="text/css" media="print">
@page
{
size: landscape;
};
</style>
<script src="js/jquery-3.1.1.js"></script>
<script>
let subtotal;
$(document).ready(() => {
subtotal = 0.00;
document.getElementById("dt").value ="<?php echo date("Y-m-d")?>";
});
let abc = () => {
let item = document.getElementById("item").value;
let desc = document.getElementById("desc").value;
let rate = document.getElementById("rate").value;
let qty = document.getElementById("qty").value;
let tot = rate * qty;
let gstr = <?php echo $roi[0]?>;
let gst = tot * gstr / 100;
gst = Math.round(gst * 100) / 100;
let total = tot + gst;
total = Math.round(total * 100) / 100;
subtotal = subtotal + total;
subtotal = Math.round(subtotal * 100) / 100;
document.getElementById('total2').value = subtotal;
let amtpaid = document.getElementById('amtpaid').value;
let total3 = document.getElementById('total2').value;
total3 = Math.round(total3 * 100) / 100;
document.getElementById('balance').value = total3 - amtpaid;
let a = document.createElement("tr");
let b = document.createElement("td");
b.setAttribute('class', 'col-md-1');
let c = document.createTextNode(item);
b.appendChild(c);
a.appendChild(b);
b = document.createElement("td");
b.setAttribute('class', 'col-md-1');
c = document.createTextNode(desc);
b.appendChild(c);
a.appendChild(b);
b = document.createElement("td");
b.setAttribute('class', 'text-center');
c = document.createTextNode(rate);
b.appendChild(c);
a.appendChild(b);
b = document.createElement("td");
b.setAttribute('class', 'text-center');
c = document.createTextNode(qty);
b.appendChild(c);
a.appendChild(b);
b = document.createElement("td");
b.setAttribute('class', 'text-center');
c = document.createTextNode(tot);
b.appendChild(c);
a.appendChild(b);
b = document.createElement("td");
b.setAttribute('class', 'text-center');
c = document.createTextNode(gst);
b.appendChild(c);
a.appendChild(b);
b = document.createElement("td");
b.setAttribute('class', 'text-center');
c = document.createTextNode(total);
b.appendChild(c);
a.appendChild(b);
b = document.createElement("td");
b.setAttribute('class', 'text-center');
let del_button = document.createElement("button");
del_button.setAttribute('class', 'btn btn-default');
del_button.innerHTML = "Del";
del_button.addEventListener("click", function () {
var p = del_button.parentNode.parentNode;
p.parentNode.removeChild(p);
subtotal = subtotal - total;
subtotal = Math.round(subtotal * 100) / 100;
document.getElementById('total2').value = subtotal;
amtpaid = document.getElementById('amtpaid').value;
total3 = document.getElementById('total2').value;
let totalz = total3 - amtpaid;
totalz = Math.round(totalz * 100) / 100;
document.getElementById('balance').value = totalz;
});
b.appendChild(del_button);
a.appendChild(b);
let z = document.getElementById("tbody");
z.appendChild(a);
let frm = document.getElementsByName('form1')[0];
frm.reset();
};
$(document).on('click', '#print', () => {
document.getElementById('data2').style.display = 'none';
document.getElementById('print').style.display = 'none';
document.getElementById('data3').setAttribute('class', 'none');
document.getElementById('data4').setAttribute('class', 'none');
var tbl = document.getElementById("tbody");
if (tbl != null)
{
for (var i = 0; i < tbl.rows.length; i++)
tbl.rows[i].cells[7].style.display = "none";
}
window.print();
document.getElementById('data2').style.display = 'block';
document.getElementById('print').style.display = 'block';
document.getElementById('data3').setAttribute('class', 'container');
document.getElementById('data4').setAttribute('class', 'container');
if (tbl != null)
{
for (var i = 0; i < tbl.rows.length; i++)
tbl.rows[i].cells[7].style.display = "block";
}
});
$(document).on('blur', '#amtpaid', () => {
let amtpaid = document.getElementById('amtpaid').value;
let total3 = document.getElementById('total2').value;
let totalz = total3 - amtpaid;
totalz = Math.round(totalz * 100) / 100;
document.getElementById('balance').value = totalz;
});
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Invoice</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">
<a href="index.php">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li>
<a href="rate.php">Change Rate</a>
</li>
<li>
<a href="Companyname.php">Change Company Name</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" cla ss="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Account
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>
<a href="#">Login</a>
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<div class="well">
<div id="data3" class="container">
<h3><?php echo $comp[0]?> </h3>
<?php echo $comp[1]?>
</div>
</div>
<div class="container" id="data4">
<div class="col-md-3 col-sm-4">
<div class="panel panel-default">
<div class="panel-heading">Invoice</div>
<div class="panel-body">
<form>
<div class="form-group">
<label for="invoice">Invoice #:</label>
<input type="number" class="form-control" id="invoice">
</div>
<div class="form-group">
<label for="dt">Date:</label>
<input type="date" class="form-control" id="dt">
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body">
<form>
<div class="form-group">
<label for="total2">Total amt: Rs.</label>
<input type="number" class="form-control" id="total2" disabled>
</div>
<div class="form-group">
<label for="amtpaid">Amount paid: Rs.</label>
<input type="number" class="form-control" id="amtpaid">
</div>
<div class="form-group">
<label for="balance">Balance Due: Rs.</label>
<input type="number" class="form-control" id="balance" disabled>
</div>
</form>
</div>
</div>
</div>
<div class="col-md-9 col-sm-8">
<div id="data2">
<form class="form-inline" name="form1" id="form1">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="item">Item:</label>
<input type="text" class="form-control" id="item" name="item" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="desc">Description:</label>
<input type="text" class="form-control" id="desc" name="desc" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="rate">Rate: (in Rs.)</label>
<input type="number" class="form-control" id="rate" name="rate" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="qty">Quantity:</label>
<input type="number" class="form-control" id="qty" name="qty" required>
</div>
</div>
</div>
<div class="row">
<br>
</div>
<div class="row">
<center>
<input class="btn btn-default" type="submit" value="Submit" id="submit">
</center>
</div>
</form>
</div>
<div>
<table id="table" class="table table-bordered">
<thead>
<th class="text-center">Item:</th>
<th class="text-center">Description:</th>
<th class="text-center">Rate: <br>(in Rs.)</th>
<th class="text-center">Quantity:</th>
<th class="text-center">Price: <br>(in Rs.)</th>
<th class="text-center">GST: {<?php echo $roi[0]?>%}<br>(in Rs.) </th>
<th class="text-center">Total+GST: <br>(in Rs.)</th>
</thead>
<tbody id="tbody">
</tbody>
</table>
<div class="row">
<center>
<button class="btn btn-default" id="print">Print</button>
</center>
</div>
</div>
</div>
</div>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.validate.min.js"></script>
<script>
$("#form1").validate(
{
rules: {
// no quoting necessary
item: "required",
desc: "required",
rate: "required",
qty: "required",
// quoting necessary!
},
messages: {
item: "Item required",
desc: "Description Required",
rate: "Rate required",
qty: "Quantity required",
},
success: "valid",
submitHandler: function() { abc(); }
}
);
</script>
</body>
</html>