001.
<?php
002.
ini_set
(
'display_errors'
, 1);
003.
error_reporting
(~0);
004.
005.
include
(
"dbConnect.php"
);
006.
$conn1
= bc();
007.
$conn2
= wms();
008.
$conn3
= bcinfo();
009.
010.
session_start();
011.
$name
=
$_SESSION
[
'name'
];
012.
$_SESSION
[
'member_status'
] =
$_POST
[
'member_status'
];
013.
if
(
$_SESSION
[
'member_status'
] !=
"RETAIL"
)
014.
015.
016.
if
(
$_SESSION
[
'name'
] ==
""
){
017.
header(
"location: index.php"
);
018.
}
019.
020.
021.
022.
$message
=
''
;
023.
if
(isset(
$_POST
[
"add_to_cart"
])){
024.
if
(isset(
$_COOKIE
[
"shopping_cart"
])){
025.
$cookie_data
=
stripcslashes
(
$_COOKIE
[
'shopping_cart'
]);
026.
$cart_data
= json_decode(
$cookie_data
, true);
027.
}
else
{
028.
$cart_data
=
array
();
029.
}
030.
$item_id_list
= array_column(
$cart_data
,
'item_code'
);
031.
if
(in_array(
$_POST
[
"hidden_code"
],
$item_id_list
) && in_array(
$_POST
[
"hidden_unit"
],
$item_id_list
)){
032.
foreach
(
$cart_data
as
$keys
=>
$values
){
033.
if
(
$cart_data
[
$keys
][
"item_code"
] ==
$_POST
[
"hidden_code"
] &&
$cart_data
[
$keys
][
"unit"
] ==
$_POST
[
"hidden_unit"
]){
034.
$cart_data
[
$keys
][
"qty"
] =
$cart_data
[
$keys
][
"qty"
] +
$_POST
[
"qty"
];
035.
}
036.
}
037.
}
else
{
038.
$item_array
=
array
(
039.
'item_code'
=>
$_POST
[
"hidden_code"
],
040.
'qty'
=>
$_POST
[
"qty"
],
041.
'unit'
=>
$_POST
[
"unit"
],
042.
'price'
=>
$_POST
[
"hidden_price"
]
043.
);
044.
$cart_data
[] =
$item_array
;
045.
}
046.
$item_data
= json_encode(
$cart_data
, JSON_UNESCAPED_UNICODE);
047.
setcookie(
'shopping_cart'
,
$item_data
, time() + (86400 * 30));
048.
header(
"location: sales_order.php?success=1"
);
049.
}
050.
051.
052.
053.
054.
055.
if
(isset(
$_GET
[
"search_item_barcode"
])){
056.
if
(isset(
$_COOKIE
[
"shopping_cart"
])){
057.
$cookie_data
=
stripcslashes
(
$_COOKIE
[
'shopping_cart'
]);
058.
$cart_data
= json_decode(
$cookie_data
, true);
059.
}
else
{
060.
$cart_data
=
array
();
061.
}
062.
$qty
=
"1"
;
063.
$price
=
"100"
;
064.
$item_id_list
= array_column(
$cart_data
,
'item_code'
);
065.
if
(in_array(
$_POST
[
"item_no_barcode"
],
$item_id_list
) && in_array(
$_POST
[
"item_packing_barcode"
],
$item_id_list
)){
066.
067.
}
else
{
068.
$item_array
=
array
(
069.
'item_code'
=>
$_POST
[
"item_no_barcode"
],
070.
'unit'
=>
$_POST
[
"item_packing_barcode"
]
071.
);
072.
$cart_data
[] =
$item_array
;
073.
}
074.
$item_data
= json_encode(
$cart_data
, JSON_UNESCAPED_UNICODE);
075.
setcookie(
'shopping_cart'
,
$item_data
, time() + (86400 * 30));
076.
header(
"location: sales_order.php?success=1"
);
077.
}
078.
079.
080.
081.
082.
if
(isset(
$_GET
[
"action"
])){
083.
if
(
$_GET
[
"action"
] ==
"delete"
){
084.
$cookie_data
=
stripslashes
(
$_COOKIE
[
'shopping_cart'
]);
085.
$cart_data
= json_decode(
$cookie_data
, true);
086.
foreach
(
$cart_data
as
$keys
=>
$values
){
087.
if
(
$cart_data
[
$keys
][
'item_code'
] ==
$_GET
[
"code"
] &&
$cart_data
[
$keys
][
'unit'
] ==
$_GET
[
"unit"
]){
088.
unset(
$cart_data
[
$keys
]);
089.
$item_data
= json_encode(
$cart_data
, JSON_UNESCAPED_UNICODE);
090.
setcookie(
"shopping_cart"
,
$item_data
, time() + (86400 * 30));
091.
header(
"location: sales_order.php"
);
092.
}
093.
}
094.
}
095.
if
(
$_GET
[
"action"
] ==
"clear"
){
096.
$cookie_data
=
stripslashes
(
$_COOKIE
[
'shopping_cart'
]);
097.
$cart_data
= json_decode(
$cookie_data
, true);
098.
if
(
is_array
(
$cart_data
) ||
is_object
(
$cart_data
)){
099.
foreach
(
$cart_data
as
$keys
=>
$values
){
100.
setcookie(
"shopping_cart"
,
""
,
"Thu, 01 Jan 1970 00:00:00 GMT"
);
101.
header(
"location: sales_order.php"
);
102.
}
103.
}
104.
}
105.
}
106.
?>
107.
108.
<!DOCTYPE html>
109.
<html lang=
"th"
>
110.
<head>
111.
<meta charset=
"UTF-8"
>
112.
<meta http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
113.
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
114.
117.
<link href=
"lib/jquery-ui.min.css?v=<?php echo filemtime('lib/jquery-ui.min.css'); ?>"
type=
"text/css"
rel=
"stylesheet"
>
118.
<link href=
"lib/style.css?v=<?php echo filemtime('lib/style.css'); ?>"
rel=
"stylesheet"
>
119.
<link href=
"lib/autocomplete.css?v=<?php echo filemtime('lib/autocomplete.css'); ?>"
rel=
"stylesheet"
>
120.
<link href=
"icon/favicon.ico"
rel=
"shortcut icon"
>
122.
123.
<script src=
"lib/jquery-1.9.1.min.js?v=<?php echo filemtime('lib/jquery-1.9.1.min.js'); ?>"
type=
"text/javascript"
></script>
124.
<script src=
"lib/jquery-ui.min.js?v=<?php echo filemtime('lib/jquery-ui.min.js'); ?>"
type=
"text/javascript"
></script>
125.
<script src=
"lib/jquery.ui.autocomplete.scroll.min.js?v=<?php echo filemtime('lib/jquery.ui.autocomplete.scroll.min.js'); ?>"
type=
"text/javascript"
></script>
126.
<script src=
"lib/jquery.ui.autocomplete.scroll.js?v=<?php echo filemtime('lib/jquery.ui.autocomplete.scroll.js'); ?>"
type=
"text/javascript"
></script>
127.
<script>
128.
129.
function
CheckItem(item) {
130.
if
(item.name.value ==
""
) {
131.
return
false;
132.
}
133.
}
134.
function
CheckMember() {
135.
let member_status =
"WHOLESALE"
;
136.
let member = document.getElementById(
"member"
).value;
137.
document.getElementById(
"member_status"
).value = member_status;
138.
}
139.
140.
$(document).ready(
function
(){
141.
$(
"#purchase"
).click(
function
() {
142.
alert(
"บันทึกข้อมูลเรียบร้อยแล้ว"
);
143.
});
144.
});
145.
$(document).ready(
function
(){
146.
$(
"#cancel"
).click(
function
() {
147.
alert(
"แจ้งยกเลิกเรียบร้อยแล้ว"
);
148.
});
149.
});
150.
151.
function
CountStock() {
152.
let stock = prompt(
"กรุณาป้อนสต๊อกที่นับได้"
,
"0"
);
153.
const
code = document.getElementById(
"code"
).value;
154.
const
description = document.getElementById(
"hidden_description"
).value;
155.
localStorage.setItem(
"CountStock"
, stock);
156.
location.replace(
"add_to_purchase_2_sales_order.php?code="
+ code +
"&name="
+ description +
"&stock="
+ stock);
157.
}
158.
159.
window.onafterprint =
function
() {
160.
var
c = document.cookie.split(
"; "
);
161.
for
(i in c)
162.
document.cookie =/^[^=]+/.
exec
(c[i])[0]+
"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"
;
163.
location.replace(
"sales_order.php"
);
164.
}
165.
</script>
166.
<title>ค้นหาสินค้า</title>
167.
</head>
168.
<body
class
=
"order"
style=
"width: auto; max-height: 10rem;"
>
169.
<!-- Menu -->
170.
<ul id=
"menu"
class
=
"noprint"
>
171.
<li><a href=
"order_purch.php"
>หน้าหลัก</a></li>
172.
<li><a href=
"order_to_purchase.php"
>รายการรอสั่งซื้อ</a></li>
173.
<li><a href=
"order_to_delete.php"
>รายการสั่งยกเลิกแล้ว</a></li>
174.
<li><a href=
"#"
>ใบสั่งขาย</a></li>
175.
<li
class
=
"right"
><a href=
"check_logout.php"
>ออกจากระบบ</a></li>
176.
<li
class
=
"right"
><a><?php
echo
"[ "
.
$name
.
" ]"
; ?></a></li>
177.
<a href=
"#"
onclick=
"window.print();"
class
=
"right"
style=
"width: 30px;"
>
178.
<i
class
=
"fas fa-print"
style=
"padding-top: 18px;"
><span id=
"span"
></span></i>
179.
</a>
180.
</ul>
181.
<!-- Content -->
182.
<div id=
"grad"
style=
"max-height: 100vh"
>
183.
<div id=
"content"
style=
"margin-left: 2.5%;"
>
184.
<div id=
"grid"
>
185.
<form name=
"search_member"
method=
"post"
>
186.
<div
class
=
"search-member"
style=
"margin-top: 55px; margin-left: 30%;"
>
187.
<input type=
"text"
name=
"member"
id=
"member"
class
=
"search_item"
placeholder=
"ชื่อลูกค้า"
autocomplete=
"off"
onkeydown=
"CheckMember()"
>
188.
<input type=
"text"
name=
"member_status"
id=
"member_status"
class
=
"search_item"
value=
"Retail"
>
189.
190.
</div>
191.
<input type=
"submit"
style=
"display: none;"
>
192.
</form>
193.
<form name=
"search_item_barcode"
class
=
"form-search"
method=
"post"
action=
"sales_order_cart.php"
>
194.
<div
class
=
"search-text noprint"
style=
"margin-top: 10px; margin-left: 40%; float: left;"
>
195.
<input type=
"text"
id=
"search_item_barcode"
name=
"Barcode"
class
=
"search_item"
placeholder=
"จำนวน*บาร์โค้ด"
autocomplete=
"off"
autofocus>
196.
</div>
197.
<input type=
"submit"
name=
"search_item_barcode"
style=
"display: none;"
>
198.
</form>
199.
<!-- SEARCH ITEM -->
200.
<form
class
=
"form-search"
method=
"post"
onsubmit=
"return CheckItem(this)"
>
201.
<div
class
=
"search-item noprint"
>
202.
<div
class
=
"search-text"
>
203.
<input type=
"text"
id=
"search_item"
name=
"Code"
class
=
"search_item"
placeholder=
"ชื่อสินค้า | รหัสสินค้า | บาร์โค้ด"
autocomplete=
"off"
>
204.
</div>
205.
<div
class
=
"search-button"
style=
"margin-left: 0px;"
>
206.
<input style=
"display: none;"
type=
"submit"
class
=
"submit"
value=
"ค้นหา"
>
207.
</div>
208.
</div>
209.
</form>
210.
</div>
211.
212.
<!-- INITIAL VAR -->
213.
<?php
214.
$strKeyword
= null;
215.
if
(isset(
$_POST
[
"Code"
])){
216.
$strKeyword
=
$_POST
[
"Code"
];
217.
?>
218.
<!-- CONTENT ITEM -->
219.
<form method=
"post"
class
=
"noprint"
>
220.
<table width=
"90%"
border=
"1"
class
=
"table"
>
221.
<tr align=
"center"
>
222.
<th width=
"10%"
>รหัสสินค้า</th>
223.
<th width=
"32%"
>ชื่อสินค้า</th>
224.
<th width=
"8%"
>สต๊อก</th>
225.
<th width=
"13%"
>แจ้งสั่งล่าสุด</th>
226.
<th width=
"6%"
>สั่งโดย</th>
227.
<th width=
"8%"
>แจ้งสั่งซื้อ</th>
228.
<th width=
"6%"
>จำนวน</th>
229.
<th width=
"8%"
>หน่วย</th>
230.
<th width=
"5%"
>เพิ่ม</th>
231.
</tr>
232.
<?php
233.
if
(
strpos
(
$strKeyword
,
"|"
)){
234.
$strKeyword
=
explode
(
"|"
,
$strKeyword
);
235.
$strKeyword
=
$strKeyword
[1];
236.
}
237.
$qq
=
explode
(
" "
,
$strKeyword
);
238.
$sql8
=
"SELECT TOP(1) item_no, uom_barcode, description, item_uom FROM product_uom WITH (NOLOCK) WHERE uom_barcode != '' AND item_no LIKE '%"
.
$strKeyword
.
"%' OR uom_barcode LIKE '%"
.
$strKeyword
.
"%' OR"
;
239.
$i
= 0;
240.
foreach
(
$qq
as
$aa
){
241.
if
(
$i
!= 0){
242.
$sql8
.=
" AND "
;
243.
}
244.
$sql8
.=
" description LIKE '%"
.
$aa
.
"%'"
;
245.
$i
++;
246.
}
247.
$view1
= sqlsrv_query(
$conn2
,
$sql8
);
248.
while
(
$data1
= sqlsrv_fetch_array(
$view1
)){
249.
$code
=
$data1
[
"item_no"
];
250.
$name
=
$data1
[
"description"
];
251.
?>
252.
<tr>
253.
<input type=
"hidden"
id=
"code"
value=
"<?php echo $data1["
item_no
"]; ?>"
>
254.
<input type=
"hidden"
id=
"hidden_description"
value=
"<?php echo $data1["
description
"]; ?>"
>
255.
<td align=
"center"
><?php
echo
$data1
[
"item_no"
]; ?></td>
256.
<td><?php
echo
$data1
[
"description"
];?></td>
257.
<td align=
"center"
id=
"show-stock"
onmouseover=
"showForm();"
onmouseout=
"hideForm();"
><?php
258.
$sql4
=
"SELECT SUM(qty_avail) AS Qty FROM pallet_location P WITH (NOLOCK) WHERE item_no = '"
.
$code
.
"' GROUP BY warehouse "
;
259.
$view4
= sqlsrv_query(
$conn2
,
$sql4
);
260.
$sql5
=
"SELECT uom FROM pallet_location WHERE item_no = '"
.
$code
.
"'"
;
261.
$view5
= sqlsrv_query(
$conn2
,
$sql5
);
262.
$total
= 0;
263.
$uom
=
""
;
264.
$sql9
=
"SELECT MAX(item_qty) AS Max FROM product_uom WITH (NOLOCK) WHERE item_no ='"
.
$code
.
"' AND uom_barcode != ''"
;
265.
$view9
= sqlsrv_query(
$conn2
,
$sql9
);
266.
if
(
$data9
= sqlsrv_fetch_array(
$view9
)){
267.
$sql10
=
"SELECT item_packing FROM product_uom WITH (NOLOCK) WHERE item_no = '"
.
$code
.
"' AND item_qty = '"
.
$data9
[
"Max"
].
"' AND uom_barcode != ''"
;
268.
$view10
= sqlsrv_query(
$conn2
,
$sql10
);
269.
if
(
$data5
= sqlsrv_fetch_array(
$view5
)){
270.
while
(
$data4
= sqlsrv_fetch_array(
$view4
)){
271.
$total
+=
$data4
[
"Qty"
];
272.
}
273.
if
(
$data10
= sqlsrv_fetch_array(
$view10
)){
274.
if
(
fmod
(
$total
,
$data9
[
"Max"
]) == 0){
275.
echo
number_format(
$total
/
$data9
[
"Max"
]).
" "
.
$data5
[
"uom"
];
276.
}
else
{
277.
echo
number_format(
$total
/
$data9
[
"Max"
], 0,
""
,
","
).
"."
.number_format(
fmod
(
$total
,
$data9
[
"Max"
]), 0,
""
,
""
).
" "
.
$data10
[
"item_packing"
];
278.
}
279.
}
280.
}
281.
}
282.
?></td>
283.
<td><?php
284.
$sql2
=
"SELECT date, name FROM order_purchase WITH (NOLOCK) WHERE itemcode = '"
.
$code
.
"'"
;
285.
$view2
= sqlsrv_query(
$conn3
,
$sql2
);
286.
$name_query
=
""
;
287.
if
(
$data2
= sqlsrv_fetch_array(
$view2
)){
288.
echo
$data2
[
"date"
]->format(
'd-m-Y H:i'
).
" น."
;
289.
$name_query
=
$data2
[
"name"
];
290.
}
291.
?></td>
292.
<td align=
"center"
><?php
echo
$name_query
; ?></td>
293.
<td align=
"center"
>
294.
<a id=
"purchase"
class
=
"btn btn-info"
onclick=
"CountStock()"
>แจ้งสั่งซื้อ</a>
295.
</td>
296.
<td>
297.
<input type=
"number"
min=
"1"
value=
"1"
name=
"qty"
id=
"qty"
style=
"width: 100%; height: 30px; float: right;"
>
298.
</td>
299.
<td align=
"center"
id=
"show-price"
onmouseover=
"showForm();"
onmouseout=
"hideForm();"
>
300.
<select name=
"unit"
id=
"unit"
style=
"width: 100%; height: 30px;"
>
301.
<?php
302.
$sql12
=
"SELECT DISTINCT item_packing, item_qty FROM product_uom WITH (NOLOCK) WHERE client = '001' AND item_packing != 'PALLET' AND item_no = '"
.
$code
.
"'"
;
303.
$view12
= sqlsrv_query(
$conn2
,
$sql12
);
304.
while
(
$data12
= sqlsrv_fetch_array(
$view12
)){
305.
$unit
=
$data12
[
"item_packing"
];
306.
?>
307.
<option value=
"<?php echo $data12['item_packing']; ?>"
><?php
echo
$data12
[
"item_packing"
]; ?></option>
308.
<?php
309.
}
310.
?>
311.
</select>
312.
</td>
313.
<td align=
"center"
>
314.
<input type=
"submit"
name=
"add_to_cart"
class
=
"btn btn-success"
value=
"เพิ่ม"
>
315.
</td>
316.
<input type=
"hidden"
name=
"hidden_code"
value=
"<?php echo $code; ?>"
>
317.
<input type=
"hidden"
name=
"hidden_unit"
value=
"<?php echo $unit; ?>"
>
318.
</tr>
319.
<?php
320.
}
321.
?>
322.
</table>
323.
</form>
324.
<div id=
"show-detail-stock"
style=
"left: 44%; position: fixed; top: auto; color: white;"
>
325.
<?php
326.
$sql6
=
"SELECT warehouse, SUM(qty_avail) AS QtyAvailable FROM pallet_location WITH (NOLOCK) WHERE item_no = '"
.
$code
.
"' GROUP BY warehouse"
;
327.
$sql7
=
"SELECT uom FROM pallet_location WITH (NOLOCK) WHERE item_no = '"
.
$code
.
"'"
;
328.
$view6
= sqlsrv_query(
$conn2
,
$sql6
);
329.
$view7
= sqlsrv_query(
$conn2
,
$sql7
);
330.
while
(
$data7
= sqlsrv_fetch_array(
$view7
)){
331.
while
(
$data6
= sqlsrv_fetch_array(
$view6
)){
332.
?>
333.
<div
class
=
"column"
>
334.
<?php
echo
$data6
[
"warehouse"
].
" / "
.number_format(
$data6
[
"QtyAvailable"
], 2,
'.'
,
','
).
" "
.
$data7
[
"uom"
].
"<br>"
;?>
335.
</div>
336.
<?php
337.
}
338.
}
339.
?>
340.
</div>
341.
<div id=
"show-detail-price"
style=
"left: 85%; position: fixed; top: auto;"
>
342.
<?php
343.
$sql11
= "SELECT DISTINCT order_no, item_no, uom, unit_price
344.
FROM sale_pricelist_detail WITH (NOLOCK)
345.
WHERE client =
'001'
AND order_no =
'RETAIL'
AND item_no =
'".$code."'
OR order_no =
'WHOLESALE'
AND item_no =
'".$code."'
";
346.
$view11
= sqlsrv_query(
$conn2
,
$sql11
);
347.
while
(
$data11
= sqlsrv_fetch_array(
$view11
)){
348.
$unitprice
=
$data11
[
"unit_price"
];
349.
echo
(
$data11
[
"order_no"
] ==
"RETAIL"
?
"ราคาปลีก "
:
"ราคาส่ง "
).
""
.
$data11
[
"uom"
].
"ละ "
.number_format(
$data11
[
"unit_price"
], 2,
'.'
,
','
).
" บาท"
.
"<br>"
;
350.
}
351.
?>
352.
<input type=
"hidden"
name=
"hidden_price"
value=
"<?php echo $unitprice; ?>"
>
353.
</div>
354.
355.
<?php
356.
}
357.
358.
$uom_barcode
=
""
;
359.
$item_no_barcode
=
""
;
360.
$item_packing_barcode
=
""
;
361.
$item_qty_barcode
=
""
;
362.
if
(isset(
$_POST
[
"Barcode"
])){
363.
$barcode
=
$_POST
[
"Barcode"
];
364.
$sql14
= "SELECT DISTINCT uom_barcode, item_no, item_packing, item_qty FROM product_uom WITH (NOLOCK)
365.
WHERE client =
'001'
AND item_packing !=
'PALLET'
AND uom_barcode =
'".$barcode."'
";
366.
$view14
= sqlsrv_query(
$conn2
,
$sql14
);
367.
if
(
$data14
= sqlsrv_fetch_array(
$view14
)){
368.
$uom_barcode
=
$data14
[
"uom_barcode"
];
369.
$item_no_barcode
=
$data14
[
"item_no"
];
370.
$item_packing_barcode
=
$data14
[
"item_packing"
];
371.
$item_qty_barcode
=
$data14
[
"item_qty"
];
372.
?>
373.
<input type=
"text"
name=
"uom_barcode"
value=
"<?php echo $uom_barcode; ?>"
>
374.
<input type=
"text"
name=
"item_no_barcode"
value=
"<?php echo $item_no_barcode; ?>"
>
375.
<input type=
"text"
name=
"item_packing_barcode"
value=
"<?php echo $item_packing_barcode; ?>"
>
376.
<input type=
"text"
name=
"item_qty_barcode"
value=
"<?php echo $item_qty_barcode; ?>"
>
377.
<?php
378.
}
379.
}
380.
381.
?>
382.
383.
384.
<!--
385.
<div style=
"clear: both"
></div><br>
386.
<h2 align=
"center"
>รายการสั่งสินค้า</h2>
387.
<div
class
=
"table-responsive"
style=
"margin-bottom: 0%;"
388.
<?php
echo
$message
; ?>
389.
<div align=
"right"
>
390.
<a href=
"sales_order.php?action=clear"
class
=
"noprint"
>
391.
<b>ล้างตระกร้า</b>
392.
</a>
393.
</div>
394.
<table id=
"count"
class
=
"table table-bordered"
>
395.
<tr align=
"center"
>
396.
<th width=
"15%"
>รหัส</th>
397.
<th width=
"45%"
>ชื่อ</th>
398.
<th width=
"5%"
>จำนวน</th>
399.
<th width=
"10%"
>หน่วย</th>
400.
<th width=
"10%"
>ราคาต่อหน่วย</th>
401.
<th width=
"10%"
>ราคารวม</th>
402.
<th width=
"5%"
class
=
"noprint"
>ลบ</th>
403.
</tr>
404.
405.
<?php
406.
if
(isset(
$_COOKIE
[
"shopping_cart"
])){
407.
$total
= 0;
408.
$member_status
=
"RETAIL"
;
409.
410.
$cookie_data
=
stripslashes
(
$_COOKIE
[
'shopping_cart'
]);
411.
$cart_data
= json_decode(
$cookie_data
, true);
412.
if
(
is_array
(
$cart_data
) ||
is_object
(
$cart_data
)){
413.
foreach
(
$cart_data
as
$keys
=>
$values
){
414.
$sql13
= "SELECT DISTINCT SPD.unit_price, PM.description FROM sale_pricelist_detail AS SPD WITH (NOLOCK)
415.
INNER JOIN product_master AS PM WITH (NOLOCK) ON PM.item_no = SPD.item_no
416.
WHERE SPD.client =
'001'
AND SPD.order_no =
'".$member_status."'
AND SPD.item_no =
'".$values["item_code"]."'
AND SPD.uom =
'".$values["unit"]."'
";
417.
$query13
= sqlsrv_query(
$conn2
,
$sql13
);
418.
if
(
$data13
= sqlsrv_fetch_array(
$query13
)){
419.
?>
420.
<tr id=
"product"
>
421.
<td><?php
echo
$values
[
"item_code"
]; ?></td>
422.
<td><?php
echo
$data13
[
"description"
]; ?></td>
423.
<td align=
"center"
><?php
echo
number_format(
$values
[
"qty"
], 0,
"."
,
","
); ?></td>
424.
<td align=
"center"
><?php
echo
$values
[
"unit"
]; ?></td>
425.
<td align=
"center"
><?php
echo
number_format(
$data13
[
"unit_price"
], 0,
"."
,
","
).
" บาท"
; ?></td>
426.
<td align=
"right"
><?php
echo
number_format(
$values
[
"qty"
] *
$data13
[
"unit_price"
], 0,
"."
,
","
).
" บาท"
; ?></td>
427.
<td
class
=
"noprint"
align=
"center"
>
428.
<a href=
"sales_order.php?action=delete&code=<?php echo $values["
item_code
"]; ?>&unit=<?php echo $values["
unit
"]; ?>"
>
429.
<span
class
=
"text-danger"
>ลบ</span>
430.
</a>
431.
</td>
432.
</tr>
433.
<?php
434.
$total
=
$total
+ (
$values
[
"qty"
] *
$data13
[
"unit_price"
]);
435.
}
436.
}
437.
}
438.
?>
439.
<tr>
440.
<td colspan=
"5"
align=
"right"
>ยอดสุทธิ</td>
441.
<td align=
"right"
><?php
echo
number_format(
$total
, 2,
"."
,
","
).
" บาท"
; ?></td>
442.
</tr>
443.
<?php
444.
}
else
{
445.
echo
'<tr><td colspan="5" align="center">ไม่มีสินค้าในตะกร้า</td></tr>'
;
446.
}
447.
448.
?>
449.
</table>
450.
<div style=
"margin-top: 0px; align: center;"
>
451.
<font name=
"remark"
id=
"remark"
>หมายเหตุ :</font>
452.
<textarea name=
"textarea"
id=
"textarea"
cols=
"100%"
rows=
"1"
style=
"border: none; overflow: hidden;"
></textarea>
453.
</div>
454.
</div>
455.
</div>
456.
</div>
457.
</body>
458.
</html>
459.
<script type=
"text/javascript"
>
460.
461.
$(
function
() {
462.
$(
"#search_item"
).autocomplete({
463.
source:
"search_item.php"
,
464.
minLength: 2,
465.
select:
function
(event, ui) {
466.
467.
if
(ui.item){
468.
$(event.target).val(ui.item.value);
469.
}
470.
471.
$(event.target.form).submit();
472.
},
473.
maxShowItems: 15
474.
});
475.
});
476.
477.
$(
function
() {
478.
$(
"#member"
).autocomplete({
479.
source:
"search_member.php"
,
480.
minLength: 2,
481.
select:
function
(event, ui) {
482.
if
(ui.item){
483.
$(event.target).val(ui.item.value);
484.
}
485.
486.
},
487.
maxShowItems: 10
488.
});
489.
});
490.
491.
$(
"#show-stock"
).hover(
function
() {
492.
$(
"#show-detail-stock"
).css({
"display"
:
"block"
});
493.
},
function
() {
494.
$(
"#show-detail-stock"
).css({
"display"
:
"none"
});
495.
});
496.
497.
$(
"#show-price"
).hover(
function
() {
498.
$(
"#show-detail-price"
).css({
"display"
:
"block"
});
499.
},
function
() {
500.
$(
"#show-detail-price"
).css({
"display"
:
"none"
});
501.
});
502.
503.
$(document).ready(
function
() {
504.
var
TableRowCount = null;
505.
TableRowCount = $(
"#count tr:not(:first-child):not(:last-child)"
).length;
506.
document.getElementById(
"span"
).innerHTML = TableRowCount;
507.
});
508.
</script>