|
|
|
เขียน php+jquery mobile หลังจากที่บันทึกข้อมูลบางครั้งก็บันทึก บางครั้งก็ไม่บันทึก |
|
|
|
|
|
|
|
เอา code มาดูครับ
|
|
|
|
|
Date :
2013-10-28 14:48:58 |
By :
mangkunzo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chk_motor.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/jquery.screwdefaultbuttonsV2.js"></script>
<script type="text/javascript">
$(function(){
$('input:radio').screwDefaultButtons({
image: 'url("images/radioSmall.jpg")',
width: 20,
height: 1
});
});
</script>
<script language="JavaScript">
function dis()
{
var Rows = document.form1.count.value;
for(x=1;x<=Rows;x++)
{
var bill1 = document.getElementById("bill"+x+"_1");
var bill2 = document.getElementById("bill"+x+"_2");
var bill3 = document.getElementById("bill"+x+"_3");
var jing1 = document.getElementById("jing"+x+"_1");
var jing2 = document.getElementById("jing"+x+"_2");
var jing3 = document.getElementById("jing"+x+"_3");
var error = document.getElementById("error"+x+"_1");
if(bill1.checked == true && jing3.checked==true)
{
error.checked=true;
}
else if(bill1.checked == true && jing1.checked==true)
{
error.checked=false;
}
else if(bill2.checked == true && jing2.checked==true)
{
error.checked=false;
}
else if(bill1.checked == true && jing2.checked==true)
{
error.checked=false;
}
else if(bill3.checked == true && jing1.checked==true)
{
error.checked=false;
}
else if(bill2.checked == true && jing3.checked==true)
{
error.checked=true;
}
else if(bill3.checked == true && jing3.checked==true)
{
error.checked=true;
}
}
}
</script>
</head>
<body>
<form action="save_chkmotor.php?mID=<?=$_GET["mID"];?>&bID=<?=$_GET["bID"];?>&cID=<?=$_GET["cID"];?>" method="post" data-ajax="false" >
<div data-role="page">
<div data-role="header">
<h1>รายการรถตรวจสภาพ</h1>
</div><!-- /header -->
<div data-role="content" data-theme="c">
<table style="font-family: THSarabunNew; font-size:12px; text-shadow:none;" cellspacing="0">
<tr align="center" bgcolor="#989898" >
<th width="34" height="37">#</th>
<th width="127">รายการ</th>
<th width="206">ตามใบตรวจสภาพ</th>
<th width="225">ตามที่ตรวจจริง</th>
<!--<th width="77">รายการผิดพลาด</th>-->
</tr>
<?
include "connect.php";
$strSQL = "SELECT * FROM spare_store
WHERE
brand_id = '".$_GET["bID"]."' AND
class_id = '".$_GET["cID"]."'
ORDER BY idno ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$count = mysql_num_rows($objQuery);
$x=0;
while($objResult = mysql_fetch_array($objQuery))
{
$sp_code = $objResult["sp_code"];
$sp_name = $objResult["sp_name"];
$price = $objResult["price"];
$brand = $objResult["brand_id"];
$class = $objResult["class_id"];
$x++;
if($x%2==0)
{
$bg = "#CCCCCC";
}
else
{
$bg = "#FFFFFF";
}
?>
<tr bgcolor="<?=$bg;?>">
<td class="ui-table-priority-1"><b><?=$x;?>.</b></td>
<td class="ui-table-priority-1" align="left"><?=$sp_name?></td>
<input name="strno" type="hidden" value="<?=$_GET["mID"];?>" />
<input name="brand" type="hidden" value="<?=$brand;?>" />
<input name="class" type="hidden" value="<?=$class;?>" />
<input name="sp_code[<?=$x;?>]" type="hidden" value="<?=$sp_code;?>" />
<input name="sp_name[<?=$x;?>]" type="hidden" value="<?=$sp_name;?>" />
<input name="price[<?=$x;?>]" type="hidden" value="<?=$price;?>" />
<td class="ui-table-priority-1" align="center">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-type="horizontal" >
<input type="radio" name="bill[<?=$x;?>]" id="bill<?=$x;?>_1" value="1" onclick="dis()" data-mini="true"/>
<label for="bill<?=$x;?>_1">ใช้ได้</label>
<input type="radio" name="bill[<?=$x;?>]" id="bill<?=$x;?>_2" value="2" onclick="dis()" data-mini="true"/>
<label for="bill<?=$x;?>_2">ชำรุด</label>
<input type="radio" name="bill[<?=$x;?>]" id="bill<?=$x;?>_3" value="3" onclick="dis()" data-mini="true"/>
<label for="bill<?=$x;?>_3">ไม่มี</label>
</fieldset>
</div>
</td>
<td align="center">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-type="horizontal" >
<input type="radio" name="jing[<?=$x;?>]" id="jing<?=$x;?>_1" value="1" onClick="dis()" data-mini="true"/>
<label for="jing<?=$x;?>_1">ใช้ได้</label>
<input type="radio" name="jing[<?=$x;?>]" id="jing<?=$x;?>_2" value="2" onclick="dis()" data-mini="true"/>
<label for="jing<?=$x;?>_2">ชำรุด</label>
<input type="radio" name="jing[<?=$x;?>]" id="jing<?=$x;?>_3" value="3" onclick="dis()" data-mini="true"/>
<label for="jing<?=$x;?>_3">ไม่มี</label>
</fieldset>
</div>
</td>
<!-- <td>
<input type="checkbox" name="error[<?=$x;?>]" id="error<?=$x;?>_1" value="1" onClick="dis()" data-mini="true"/>
</td>
--> </tr>
<? } ?>
<tr>
<td colspan="5">
<input type="hidden" name="count" value="<?=$x;?>" />
<input type="submit" id="submit" value="บันทึกข้อมูล" data-role="button" data-inline="true" data-theme="b" data-mini="true"/>
</td>
</tr>
</table>
</div>
<div data-role="footer">
<h4>COPYRIGHT</h4>
</div><!-- /footer -->
</div>
</form>
</body>
save_chkmotor.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<?
include "connect.php";
$error = $_POST["error"];
$count = $_POST["count"];
$strno = $_POST["strno"];
$sp_code = $_POST["sp_code"];
$sp_name = $_POST["sp_name"];
$drive = $_POST["drive"];
$bill = $_POST["bill"];
$jing = $_POST["jing"];
$error = $_POST["error"];
$price = $_POST["price"];
$brand = $_POST["brand"];
$class = $_POST["class"];
$type = $_POST["type"];
$emp_no = $_POST["emp_no"];
$strSQL = "SELECT * FROM prtran
INNER JOIN brand ON brand.brand_id = prtran.brand_id
INNER JOIN class ON class.class_id = prtran.class_id
INNER JOIN col1 ON col1.color_id1 = prtran.col1
INNER JOIN col2 ON col2.color_id2 = prtran.col2
WHERE strno = '$strno'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
$brand_name = $objResult["brand_name"];
$class_name = $objResult["class_name"];
$color_name1 = $objResult["color_name1"];
$color_name2 = $objResult["color_name2"];
?>
<div data-role="page">
<div data-role="header" data-theme="a">
<h1>สรุปรายการรถตรวจสภาพ</h1>
</div><!-- /header -->
<div data-role="content" >
<table >
<tr>
<td width="86" align="left">เลขเครื่อง </td>
<td width="142" align="left"><?=$strno ;?></td>
<td width="46" align="left">ยี่ห้อ</td>
<td width="171" align="left"><?=$brand_name;?></ttdh>
</tr>
<tr>
<td align="left">รุ่น</td>
<td align="left"><?=$class_name ;?></td>
<td align="left">สี</td>
<td align="left"><?=$color_name1;?>/<?=$color_name2;?></td>
</tr>
</table>
<table>
<tr>
<th align="left">รายการอะไหล่</th>
<th>ตามใบตรวจ</th>
<th>ตามที่ตรวจจริง</th>
<th>รายการผิดพลาด</th>
<th>ราคา</th>
</tr>
<?
$strSQL = "UPDATE potran SET ";
$strSQL .="status = 'T' ";
$strSQL .="WHERE strno = '$strno' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Update [".mysql_error()."]";
}
for($x=1;$x<=$count;$x++)
{
if($bill[$x] != "")
{
$strSQL = "SELECT Max(idno) as maxid FROM chk_store ";
$objQuery = mysql_query($strSQL)or die ("select error");
$objResult = mysql_fetch_array($objQuery);
$idno = $objResult['maxid']+1;
$strSQL = "INSERT INTO chk_store (idno,strno,sp_code,sp_name,bill,jing,error,price)
VALUES('$idno','$strno','".$sp_code[$x]."','".$sp_name[$x]."','".$bill[$x]."','".$jing[$x]."','".$error[$x]."','".$price[$x]."') ";
$objQuery = mysql_query($strSQL);
if($bill[$x] == '1' && $jing[$x] == '1')
{
$error = 'ตรงตามใบตรวจสภาพ';
}else if($bill[$x] == '1' && $jing[$x] == '2')
{
$error = 'ผิดพลาด';
}else if($bill[$x] == '1' && $jing[$x] == '3')
{
$error = 'ผิดพลาด';
}else if($bill[$x] == '2' && $jing[$x] == '1')
{
$error = 'ตรงตามใบตรวจสภาพ';
}else if($bill[$x] == '2' && $jing[$x] == '2')
{
$error = 'ตรงตามใบตรวจสภาพ';
}else if($bill[$x] == '2' && $jing[$x] == '3')
{
$error = 'ผิดพลาด';
}else if($bill[$x] == '3' && $jing[$x] == '3')
{
$error = 'ตรงตามใบตรวจสภาพ';
}else if($bill[$x] == '3' && $jing[$x] == '2')
{
$error = 'ตรงตามใบตรวจสภาพ';
}
else if($bill[$x] == '3' && $jing[$x] == '3')
{
$error = 'ตรงตามใบตรวจสภาพ';
}
if($jing[$x] == '1')
{
$jing[$x] = 'ใช้ได้';
}else if($jing[$x] == '2')
{
$jing[$x] = 'ชำรุด';
}else if($jing[$x] == '3')
{
$jing[$x] = 'ไม่มี';
}
if($bill[$x] == '1')
{
$bill[$x] = 'ใช้ได้';
}else if($bill[$x] == '2')
{
$bill[$x] = 'ชำรุด';
}else if($bill[$x] == '3')
{
$bill[$x] = 'ไม่มี';
}
?>
<tr>
<td align="left"><?=$sp_name[$x];?></td>
<td align="left"><?=$bill[$x];?></td>
<td align="left"><?=$jing[$x];?></td>
<td align="left"><?=$error;?></td>
<td align="left">
<?
if($error[$x] == '1'){
echo $price[$x];
}else
echo '0.00';
?>
</td>
<?
}
}
?> </tr>
<tr>
<td colspan="4" align="center">ราคารวม (บาท)</td>
</tr>
</table>
</div>
<div align="center">
<a href="assignstore.php" data-role="button" data-inline="true" data-theme="b" data-mini="true"/>บันทึกข้อมูล</a>
<a href="edit_chk_motor.php?mID=<?=$strno;?>" data-role="button" data-inline="true" data-theme="b" data-mini="true"/>แก้ไขข้อมูล</a>
</div>
</div>
|
ประวัติการแก้ไข 2013-10-28 14:57:06
|
|
|
|
Date :
2013-10-28 14:55:48 |
By :
PALM26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|