-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_sales.php
152 lines (142 loc) · 4.11 KB
/
print_sales.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
<?php
include 'db_connect.php';
if(isset($_GET['id'])){
$qry = $conn->query("SELECT * FROM sales_list where id=".$_GET['id'])->fetch_array();
foreach($qry as $k => $val){
$$k = $val;
}
$inv = $conn->query("SELECT * FROM inventory where type=2 and form_id=".$_GET['id']);
if($customer_id > 0){
$cname = $conn->query("SELECT * FROM customer_list where id = $customer_id ");
$cname = $cname->num_rows > 0 ? $cname->fetch_array()['name']: "Guest";
}else{
$cname = "Guest";
}
}
$product = $conn->query("SELECT * FROM product_list order by name asc");
while($row=$product->fetch_assoc()):
$prod[$row['id']] = $row;
endwhile;
?>
<div class="container-fluid" id="print-sales">
<style>
table{
border-collapse: collapse;
}
.wborder{
border:1px solid gray;
}
.bbottom{
border-bottom: 1px solid black
}
td p , th p{
margin: unset
}
.text-center{
text-align: center
}
.text-right{
text-align: right
}
.clear{
padding: 10px
}
#uni_modal .modal-footer{
display: none;
}
</style>
<table width="100%">
<tr>
<th class="text-center">
<p>
<b>Receipt</b>
</p>
</th>
</tr>
<tr>
<td class="clear"> </td>
</tr>
<tr>
<td>
<table width="100%">
<tr>
<td width="20%" class="text-right">Customer :</td>
<td width="40%" class="bbottom"><?php echo ucwords($cname) ?></td>
<td width="20%" class="text-right">Date :</td>
<td width="20%" class="bbottom"><?php echo date("Y-m-d",strtotime($date_updated)) ?></td>
</tr>
<tr>
<td width="20%" class="text-right">Reference Number :</td>
<td width="80%" class="bbottom" colspan="3"><?php echo $ref_no ?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="clear"> </td>
</tr>
<tr>
<table width="100%">
<tr>
<th width="20%" class="wborder">Qty</th>
<th width="30%" class="wborder">Product</th>
<th width="25%" class="wborder">Unit Price</th>
<th width="25%" class="wborder">Amount</th>
</tr>
<?php
while($row = $inv->fetch_assoc()):
foreach(json_decode($row['other_details']) as $k=>$v){
$row[$k] = $v;
}
?>
<tr>
<td class="wborder text-center">
<?php echo $row['qty'] ?>
</td>
<td class="wborder">
<p class="pname">Name: <b><?php echo $prod[$row['product_id']]['name'] ?></b></p>
<p class="pdesc"><small><i>Description: <b><?php echo $prod[$row['product_id']]['description'] ?></b></i></small></p>
</td>
<td class="wborder text-right"><?php echo number_format($row['price'],2) ?></td>
<td class="wborder text-right"><?php echo number_format($row['price'] * $row['qty'],2) ?></td>
</tr>
<?php endwhile;?>
<tr>
<th class="text-right wborder" colspan="3">Total</th>
<th class="text-right wborder" ><?php echo number_format($total_amount) ?></th>
</tr>
<tr>
<th class="text-right wborder" colspan="3">Discount</th>
<th class="text-right wborder" ><?php echo number_format($amount_discount) ?></th>
</tr>
<tr>
<th class="text-right wborder" colspan="3">After Discount</th>
<th class="text-right wborder" ><?php echo number_format($discount_amount) ?></th>
</tr>
</table>
</tr>
<tr>
<td class="clear"> </td>
</tr>
</table>
</div>
<hr>
<div class="text-right">
<div class="col-md-12">
<div class="row">
<button type="button" class="btn btn-sm btn-primary" id="print"><i class="fa fa-print"></i> Print</button>
<button type="button" class="btn btn-sm btn-secondary" onclick="location.reload()"><i class="fa fa-plus"></i> New Sales</button>
</div>
</div>
</div>
<script>
$('#print').click(function(){
var _html = $('#print-sales').clone();
var newWindow = window.open("","_blank","menubar=no,scrollbars=yes,resizable=yes,width=700,height=600");
newWindow.document.write(_html.html())
newWindow.document.close()
newWindow.focus()
newWindow.print()
setTimeout(function(){;newWindow.close();}, 1500);
})
</script>