-
Notifications
You must be signed in to change notification settings - Fork 0
/
sale-print.php
184 lines (176 loc) · 6.17 KB
/
sale-print.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
<?php include("inc_connect.php");?>
<?php
$SQL = "select * from tb_sale where sale_id='".$_GET["sale_id"]."'";
$result = mysqli_query($mysqli, $SQL) or die(mysqli_error($mysqli).$SQL);
$tmp = mysqli_fetch_array($result);
$SQL = "select * from tb_customer where cus_id='".$tmp["cus_id"]."'";
$result = mysqli_query($mysqli, $SQL) or die(mysqli_error($mysqli).$SQL);
$tmp1 = mysqli_fetch_array($result);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>ใบเสร็จรับเงิน</title>
</head>
<body>
<center><h2>ใบเสร็จรับเงิน</h2></center>
<p align="center">ชื่อร้านค้า ที่อยู่ เบอร์โทรศัพท์</p>
<table width="100%" border="0">
<tr>
<td valign="top"><table width="100%" border="0">
<tr>
<td colspan="2"><h3>ข้อมูลลูกค้า</h3></td>
</tr>
<tr>
<td width="25%">ชื่อ-นามสกุล : </td>
<td> <?php print $tmp1["name"]?></td>
</tr>
<tr>
<td>ที่อยู่ : </td>
<td> <?php print $tmp1["address"]?></td>
</tr>
<tr>
<td nowrap>เบอร์โทรศัพท์ : </td>
<td> <?php print $tmp1["phone"]?></td>
</tr>
<tr>
<td>อีเมล์ : </td>
<td> <?php print $tmp1["email"]?></td>
</tr>
</table></td>
<td valign="top" width="40%"><table width="100%" border="0">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="35%" nowrap>เลขที่ใบเสร็จ : </td>
<td> <?php print str_pad($tmp["sale_id"], 5, "0", STR_PAD_LEFT);?></td>
</tr>
<tr>
<td>วันที่/เวลา : </td>
<td> <?php print show_datetime($tmp["lastupdate"])?> น.</td>
</tr>
</table></td>
</tr>
</table>
<h3>ข้อมูลสินค้า</h3>
<table width="100%" border="1" cellpadding="5" cellspacing="0">
<tr align="center">
<td width="10%"><strong>ลำดับ</strong></td>
<td><strong>รายการ</strong></td>
<td width="20%"><strong>ราคา</strong></td>
<td width="20%"><strong>จำนวน</strong></td>
<td width="20%"><strong>รวมราคา</strong></td>
</tr>
<?php
$SQL = "select d.*, p.name from tb_sale_detail as d, tb_product as p where d.sale_id='".$tmp["sale_id"]."' and d.code=p.code";
$result = mysqli_query($mysqli, $SQL) or die(mysqli_error($mysqli).$SQL);
$i = 0;
while($tmp1 = mysqli_fetch_array($result)) {
$i++;
?>
<tr>
<td align="center"><?php print $i?></td>
<td><?php print $tmp1["name"]?></td>
<td align="right"><?php print $tmp1["price"]?></td>
<td align="right"><?php print $tmp1["qty"]?></td>
<td align="right"><?php print $tmp1["total"]?></td>
</tr>
<?php } ?>
<tr align="right">
<td colspan="4"><strong>ค่าขนส่ง : </strong></td>
<td><strong><?php print number_format($tmp["delivery"],2)?></strong></td>
</tr>
<tr align="right">
<td colspan="4"><strong>ส่วนลด : </strong></td>
<td><strong><?php print number_format($tmp["discount"],2)?></strong></td>
</tr>
<tr align="right">
<td colspan="4"><strong>รวมเป็นเงินทั้งสิ้น : (<?php print Convert(number_format($tmp["grand"],2))?>) </strong></td>
<td><strong><?php print number_format($tmp["grand"],2)?></strong></td>
</tr>
</table>
<p align="left"> </p>
<table width="100%" border="0">
<tr>
<td align="center">ลงชื่อ ....................................... ผู้รับ </td>
<td align="center">ลงชื่อ ....................................... ผู้ขาย</td>
</tr>
<tr>
<td align="center">..........................................</td>
<td align="center">........................................</td>
</tr>
<tr>
<td align="center">วันที่ ...........................................</td>
<td align="center">วันที่ ...........................................</td>
</tr>
</table>
<p> </p>
</body>
</html>
<?php
function Convert($amount_number)
{
$amount_number = number_format($amount_number, 2, ".","");
$pt = strpos($amount_number , ".");
$number = $fraction = "";
if ($pt === false)
$number = $amount_number;
else
{
$number = substr($amount_number, 0, $pt);
$fraction = substr($amount_number, $pt + 1);
}
$ret = "";
$baht = ReadNumber ($number);
if ($baht != "")
$ret .= $baht . "บาท";
$satang = ReadNumber($fraction);
if ($satang != "")
$ret .= $satang . "สตางค์";
else
$ret .= "ถ้วน";
return $ret;
}
function ReadNumber($number)
{
$position_call = array("แสน", "หมื่น", "พัน", "ร้อย", "สิบ", "");
$number_call = array("", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า");
$number = $number + 0;
$ret = "";
if ($number == 0) return $ret;
if ($number > 1000000)
{
$ret .= ReadNumber(intval($number / 1000000)) . "ล้าน";
$number = intval(fmod($number, 1000000));
}
$divider = 100000;
$pos = 0;
while($number > 0)
{
$d = intval($number / $divider);
$ret .= (($divider == 10) && ($d == 2)) ? "ยี่" :
((($divider == 10) && ($d == 1)) ? "" :
((($divider == 1) && ($d == 1) && ($ret != "")) ? "เอ็ด" : $number_call[$d]));
$ret .= ($d ? $position_call[$pos] : "");
$number = $number % $divider;
$divider = $divider / 10;
$pos++;
}
return $ret;
}
?>
<script>
window.print();
</script>