002.
<html>
003.
004.
<script language=
"javascript"
>
005.
function
confirmsave(){
006.
if
(confirm(
'คุณต้องการยืนยันการรับเข้าสินค้า ใช่หรือไม่ ?'
)==true){
007.
document.form1.submit();
008.
}
else
{
009.
return
false;
010.
}
011.
}
012.
013.
$(
function
() {
014.
015.
var
calcqty =
function
(max,a,b,c) {
016.
var
sum = parseInt(a) + parseInt(b) + parseInt(c);
017.
return
sum;
018.
}
019.
$(
'[name="_txtQty[]"]'
).on(
'change paste'
,
function
(e) {
020.
var
max = parseInt($(this).parent().parent().attr(
'data-maxqty'
));
021.
var
qty = parseInt($(this).val());
022.
var
qty2 = parseInt($(this).parent().parent().find(
'[name="_txtQty2[]"]'
).val());
023.
var
qty3 = parseInt($(this).parent().parent().find(
'[name="_txtQty3[]"]'
).val());
024.
var
sum = calcqty(max,qty,qty2,qty3);
025.
$(this).parent().parent().find(
'.sum'
).text( sum );
026.
if
(sum > max) {
027.
alert(
'คุณกรอกเกินจำนวนที่สั่ง สูงสุดคือ '
+ max);
028.
}
029.
});
030.
031.
$(
'[name="_txtQty2[]"]'
).on(
'change paste'
,
function
(e) {
032.
var
max = parseInt($(this).parent().parent().attr(
'data-maxqty'
));
033.
var
qty = parseInt($(this).val());
034.
var
qty2 = parseInt($(this).parent().parent().find(
'[name="_txtQty[]"]'
).val());
035.
var
qty3 = parseInt($(this).parent().parent().find(
'[name="_txtQty3[]"]'
).val());
036.
var
sum = calcqty(max,qty,qty2,qty3);
037.
$(this).parent().parent().find(
'.sum'
).text( sum );
038.
if
(sum > max) {
039.
alert(
'คุณกรอกเกินจำนวนที่สั่ง สูงสุดคือ '
+ max);
040.
}
041.
});
042.
$(
'[name="_txtQty3[]"]'
).on(
'change paste'
,
function
(e) {
043.
var
max = parseInt($(this).parent().parent().attr(
'data-maxqty'
));
044.
var
qty = parseInt($(this).val());
045.
var
qty2 = parseInt($(this).parent().parent().find(
'[name="_txtQty2[]"]'
).val());
046.
var
qty3 = parseInt($(this).parent().parent().find(
'[name="_txtQty[]"]'
).val());
047.
var
sum = calcqty(max,qty,qty2,qty3);
048.
$(this).parent().parent().find(
'.sum'
).text( sum );
049.
if
(sum > max) {
050.
alert(
'คุณกรอกเกินจำนวนที่สั่ง สูงสุดคือ '
+ max);
051.
}
052.
});
053.
});
054.
</script>
055.
056.
057.
058.
<body>
059.
<form name=
"form1"
action=
"main.php?action=ordersreceiveddata"
method=
"post"
onSubmit=
"return confirmsave();"
>
060.
<table width=
"800"
border=
"0"
cellpadding=
"3"
cellspacing=
"3"
>
061.
<tr>
062.
<td
class
=
"style3"
>รายการตรวจรับสินค้าผลิตเสร็จ</td>
063.
</tr>
064.
</table>
065.
<table width=
"800"
border=
"1"
cellpadding=
"3"
cellspacing=
"1"
class
=
"customers"
>
066.
<tr
class
=
"styleheadtd1"
>
067.
<th
class
=
"style1"
width=
"110"
>เลขที่ใบสั่งผลิต</th>
068.
<th
class
=
"style1"
width=
"90"
>วันที่สั่งผลิต</th>
069.
<th
class
=
"style1"
width=
"220"
>ช่วงเวลา</th>
070.
<th
class
=
"style1"
width=
"70"
>รหัสเตา</th>
071.
<th
class
=
"style1"
width=
"150"
>รายการสินค้า</th>
072.
<th
class
=
"style1"
width=
"100"
>จำนวนที่สั่งผลิต</th>
073.
<th
class
=
"style1"
width=
"50"
>เกรดA</th>
074.
<th
class
=
"style1"
width=
"50"
>เกรดB</th>
075.
<th
class
=
"style1"
width=
"50"
>เสีย</th>
076.
<th
class
=
"style1"
width=
"50"
>รวม</th>
077.
<th
class
=
"style1"
width=
"50"
>รับ</th>
078.
</tr>
079.
<?
080.
$d
=(
'MachineID'
);
081.
$dd
=
date
(
'Y-m-d H:i:s'
);
082.
$str
=
"SELECT * FROM orders WHERE IsStatus = '1'"
;
083.
$result
= mysql_query(
$str
)
or
die
(mysql_error());
084.
$i
=0;
085.
086.
while
(
$row
= mysql_fetch_array(
$result
)){
087.
$rowP
= GetByPrimaryKey(
"product"
,
"ProductID"
,
$row
[
'ProductID'
]);
088.
$row
[
'EndDate'
];
089.
if
(
$row
[
'EndDate'
]<=
$dd
)
090.
{
091.
echo
"<tr data-maxqty='$row[Qty]'>"
;
092.
echo
"<td align='center' valign='top'>"
.
$row
[
'OrderID'
] .
"</td>"
;
093.
echo
"<td align='center' valign='top'>"
. ConvertDateToDMY(
$row
[
'OrderDate'
]) .
"</td>"
;
094.
echo
"<td align='center' valign='top'>"
. date_format(date_create(
$row
[
'OrderDate'
]),
"H:i"
) .
' น. - '
. date_format(date_create(
$row
[
'EndDate'
]),
"H:i"
) .
' น. '
.
"</td>"
;
095.
echo
"<td align='center' valign='top'>"
.
$row
[
'MachineID'
] .
"</td>"
;
096.
echo
"<td align='left' valign='top'>"
.
$rowP
[
'Name'
] .
"</td>"
;
097.
echo
"<td align='center' valign='top'>"
.
$row
[
'Qty'
] .
"</td>"
;
098.
echo
"<td align='right' valign='top'><input type='text' name='_txtQty[]' value='0' size='10' style='text-align:right'></td>"
;
099.
echo
"<td align='right' valign='top'><input type='text' name='_txtQty2[]' value='0' size='10' style='text-align:right'></td>"
;
100.
echo
"<td align='right' valign='top'><input type='text' name='_txtQty3[]' value='0' size='10' style='text-align:right'></td>"
;
101.
echo
"<td><span class='sum'>0</span></td>"
;
102.
echo
"<td align='center' valign='top'><input type='checkbox' name='_chkSelect[$i]'></td>"
;
103.
104.
echo
"</tr>"
;
105.
}
106.
echo
"<input type='hidden' name='_txtOrderID[]' value='$row[OrderID]'>"
;
107.
echo
"<input type='hidden' name='_txtProductID[]' value='$row[ProductID]'>"
;
108.
109.
if
(
$_REQUEST
[
'sum'
]>(
$row
[
'Qty'
]));
110.
{
111.
echo
"<script> alert('จำนวนมากเกินไป'); window.history.back(); </script>"
;
112.
exit
();
113.
}
114.
115.
$i
++;
116.
}
117.
118.
?>
119.
</table>
120.
<br>
121.
<table width=
"800"
border=
"0"
cellpadding=
"3"
cellspacing=
"3"
>
122.
<tr>
123.
<td align=
"right"
><input type=
"submit"
name=
"_btnSave"
value=
"ยืนยันรายการ"
></td>
124.
</tr>
125.
</table>
126.
</form>
127.
</body>
128.
</html>