|
|
|
รบกวนสอบถามพอ insert อีก table และ update อีก table พร้อมกันหน่อยครับ |
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
include("header.php");
$objSql = "SELECT * FROM asset LEFT JOIN type ON (type.type_id = asset.type_id)
LEFT JOIN unit ON (unit.unit_id = asset.unit_id)
LEFT JOIN employee ON (employee.emp_id = asset.emp_id)
LEFT JOIN department ON (department.dept_id = asset.dept_id)
LEFT JOIN adminis ON (asset.asset_update_id=adminis.admin_id)
LEFT JOIN user ON (asset.asset_update_id=user.user_id)
$search ORDER BY asset_id ASC";
$objQuery = mysql_query($objSql) or die ("Not Query Database0");
$rows = mysql_num_rows($objQuery);
?>
<script>
function chkNull(){
//if(document.frmEdit.txtMatname.value == ""){
//alert("กรุณากรอกชื่อสินทรัพย์ !!");
//document.frmEdit.txtMatname.focus();
//return false;
//}
if(document.frmEdit.listType.value == "0"){
alert("กรุณาเลือกบริษัทที่จะทำการส่งซ่อม !!");
document.frmEdit.listType.focus();
return false;
}
if(document.frmEdit.repair_rootcause.value == ""){
alert("กรุณากรอกสาเหตุการแจ้งซ่อม !!");
document.frmEdit.repair_rootcause.focus();
return false;
}
//if(!document.frmEdit.txtMatlow.value.match(/^([0-9])+$/i)){
//alert("กรุณากรอกจุดสั่งซื้อวัสดุเป็นตัวเลขเท่านั้น !!");
//document.frmEdit.txtMatlow.focus();
//return false;
//}
if(document.frmEdit.radio.value == "0"){
alert("กรุณาเลือกสถานะ !!");
document.frmEdit.radio.focus();
return false;
}
//if(document.frmEdit.txtMatprice.value == ""){
//alert("กรุณากรอกราคาสินทรัพย์ !!");
//document.frmEdit.txtMatprice.focus();
//return false;
//}
//if(!document.frmEdit.txtMatprice.value.match(/^([0-9.,])+$/i)){
//alert("กรุณากรอกราคาสินทรัพย์เปนตัวเลขเท่านั้น !!");
//document.frmEdit.txtMatprice.focus();
//return false;
}
</script>
<script language="javascript">
// Start XmlHttp Object
function uzXmlHttp(){
var xmlhttp = false;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
xmlhttp = false;
}
}
if(!xmlhttp && document.createElement){
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
// End XmlHttp Object
function data_show(select_id,result){
var url = 'datarepair.php?select_id='+select_id+'&result='+result;
//alert(url);
xmlhttp = uzXmlHttp();
xmlhttp.open("get", url, false);
//xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); // set Header
xmlhttp.send(null);
if(result != "txtsupadd")
document.getElementById(result).innerHTML = xmlhttp.responseText;
else
$respArr = xmlhttp.responseText.split("|");
document.getElementById('txtsupadd').innerHTML = $respArr[0];
document.getElementById('txtsupcname').value = $respArr[1];
document.getElementById('txtsupemail').value = $respArr[2];
document.getElementById('txtsuptel').value = $respArr[3];
}
function setVal(){
document.getElementById('sup_id').value = document.getElementById('listType').value;
}
</script>
<script type="text/javascript">
function SelectRepairstatus(val){
document.getElementById('repair_status_value').value = val;
}
</script>
<?
$MaterialID = $_GET["asset_id"];
//echo $MaterialID;
$objQuery = mysql_query("SELECT * FROM asset WHERE asset_id = ".$MaterialID." ORDER BY asset_id DESC LIMIT 1") or die ("Not Query Database1");
$rows = mysql_num_rows($objQuery);
$year = date("Y")+543;
if($rows == 0){
$requestID = "R-".$year."/0001";
}else{
$objResult = mysql_fetch_array($objQuery);
$RepairID = $objResult["repire_id"];
$EmpID = $objResult["emp_id"];
$DeptID = $objResult["dept_id"];
$AssetID = $objResult["asset_id"];
$RepairStatus = $objResult["repair_status"];
$RepairStatus1 = $objResult["asset_status"];
$RepairID = intval(substr($requestID,8,11)+1);
if($RepairID < 10){
$RepairID = "R-".$year."/000".$RepairID;
}elseif($RepairID < 100){
$RepairID = "R-".$year."/00".$RepairID;
}elseif($RepairID < 1000){
$RepairID = "R-".$year."/0".$RepairID;
}else{
$RepairID = "R-".$year."/".$RepairID;
}
}
#Deasciption
echo "
<center>
<table id=\"tblDescription\">
<tr>
<td valign=\"top\">
<br>
<div id=\"titlePage\" align=\"center\">บำรุงรักษา</div>
<div id=\"titlePage\" align=\"left\">
<a href=\"repair.php\" id=\"btnLink\"><img src=\"../images/icons/undo-icon.png\">ย้อนกลับ</a>
</div>
<center>
<!--<form action=\"".$_SERVER["PHP_SELF"]."?material_id=".$objResult["asset_id"]."\" method=\"post\" id=\"frmEdit\" name=\"frmEdit\" onsubmit=\"return chkNull()\">-->
<form action=\"repair_edit_submit.php\" method=\"post\" id=\"frmEdit\" name=\"frmEdit\" onsubmit=\"return chkNull()\">
<table id=\"tblfrmEdit\">
<input type=\"hidden\" name=\"repair_id\" value=\"".$RepairID."\">
<input type=\"hidden\" name=\"asset_id\" value=\"".$AssetID."\">
<input type=\"hidden\" name=\"emp_id\" value=\"".$EmpID."\">
<input type=\"hidden\" id=\"sup_id\" name=\"sup_id\">
<input type=\"hidden\" name=\"dept_id\" value=\"".$DeptID."\">
<input type=\"hidden\" name=\"repair_update_id\" value=\"".$_SESSION["User_ID"]."\">
<input type=\"hidden\" name=\"repair_status_value\" id=\"repair_status_value\" value=\"\">
<input type=\"hidden\" name=\"material_id\" value=\"".$_GET["asset_id"]."\">
<tr height=\"30\">
<td width=\"40%\" align=\"right\" valign=\"middle\"><input name=\"key\" id=\"key\" type=\"hidden\" value=\"1\">รหัสการแจ้งซ่อม :</td>
<td align=\"left\" valign=\"middle\">".$RepairID."</td>
</tr>
<tr height=\"20\">
<td align=\"right\" valign=\"middle\">รหัสสินทรัพย์ :</td>
<td align=\"left\" valign=\"middle\"><textarea name=\"txtassetID\" id=\"txtassetID\" type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\" cols=\"30\" rows=\"1\"readonly>".$objResult["asset_id"]."</textarea>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"20\">
<td align=\"right\" valign=\"middle\">ชื่อสินทรัพย์ :</td>
<td align=\"left\" valign=\"middle\"><textarea name=\"txtassetname\" id=\"txtassetname\" type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\" cols=\"30\" rows=\"1\"readonly>".$objResult["asset_name"]."</textarea>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"10\">
<td align=\"right\" valign=\"middle\">แผนก :</td>
<td align=\"left\" valign=\"middle\"><textarea name=\"txtdept1\" id=\"txtdept1\" type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\" cols=\"30\" rows=\"1\"readonly>".$objResult["dept_name"]."</textarea>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"10\">
<td align=\"right\" valign=\"middle\">ชื่อผู้ครอบครองสินทรัพย์ :</td>
<td align=\"left\" valign=\"middle\"><textarea name=\"txtMatname1\" id=\"txtMatname1\" type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\" cols=\"30\" rows=\"1\"readonly>".$objResult["emp_name"]."</textarea>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"20\">
<td align=\"right\" valign=\"middle\">ชื่อผู้ทำการแจ้งซ่อม :</td>
<td align=\"left\" valign=\"middle\"><textarea name=\"txtRename\" id=\"txtRename\" type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\" cols=\"30\" rows=\"1\"readonly>".$_SESSION["User_Name"]." ".$_SESSION["User_Lastname"]."</textarea>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"50\">
</tr>
<tr height=\"30\">
<td align=\"right\" valign=\"middle\">บริษัทส่งซ่อม</td>
<td align=\"left\" valign=\"middle\"><select name=\"listType\" id=\"listType\"
onchange=\"data_show(this.value,'txtsupadd');setVal();\">
<option value=\"0\">--- เลือกบริษัท ---</option>
";
$objQuerytype = mysql_query("SELECT * FROM supplier WHERE sup_status = '1' ORDER BY sup_id ASC") or die ("Not Query Database2");
while($objResulttype = mysql_fetch_array($objQuerytype)){
echo "
<option value=\"".$objResulttype["sup_id"]."\"
";
if($objResulttype["sup_id"] == $objResult["sup_id"]){
echo "selected";
}
echo "
> ".$objResulttype["sup_name"]."</option>
";
}
echo "
</select>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"10\">
<td align=\"right\" valign=\"middle\">ที่อยู่ :</td>
<td align=\"left\" valign=\"middle\"><textarea name=\"txtsupadd\" id=\"txtsupadd\" type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\" cols=\"30\" rows=\"5\">".$objResult["sup_add"]."</textarea>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"30\">
<td align=\"right\" valign=\"middle\">ชื่อติดต่อ :</td>
<td align=\"left\" valign=\"middle\"><textarea name=\"txtsupcname\" id=\"txtsupcname\" type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\" cols=\"30\" rows=\"1\">".$objResult["sup_cname"]."</textarea>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"30\">
<td align=\"right\" valign=\"middle\">อีเมล :</td>
<td align=\"left\" valign=\"middle\"><textarea name=\"txtsupemail\" id=\"txtsupemail\" type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\" cols=\"30\" rows=\"1\">".$objResult["sup_email"]."</textarea>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"30\">
<td align=\"right\" valign=\"middle\">เบอร์โทรศัพ :</td>
<td align=\"left\" valign=\"middle\"><textarea name=\"txtsuptel\" id=\"txtsuptel\" title='รูปแบบ:xxxxxxxxxx' type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\" cols=\"30\" rows=\"1\">".$objResult["sup_tel"]."</textarea>
<span id=\"commentStar\"></span></td>
</tr>
<tr height=\"30\">
</tr>
<tr height=\"30\">
<td align=\"right\" valign=\"middle\">สาเหตุ :</td>
<td align=\"left\" valign=\"middle\"><input name=\"repair_rootcause\" id=\"repair_rootcause\" type=\"text\" onChange=\"javascript:this.value=this.value.toUpperCase();\">
<span id=\"commentStar\">*</span></td>
</tr>
<tr height=\"30\">
<td align=\"right\" valign=\"middle\">สถานะ :</td>
<td align=\"left\" valign=\"middle\">
<input name=\"repair_status\" id=\"repair_status\" type=\"radio\" value=\"1\" onchange=\"SelectRepairstatus(this.value);\">ใช้งาน
<input name=\"repair_status\" id=\"repair_status\" type=\"radio\" value=\"3\" onchange=\"SelectRepairstatus(this.value);\">ส่งซ่อมสินทรัพย์
<input name=\"repair_status\" id=\"repair_status\" type=\"radio\" value=\"4\" onchange=\"SelectRepairstatus(this.value);\">ยกเลิกการส่งซ่อมสินทรัพย์
</td>
</tr>
<tr height=\"30\">
<td align=\"right\" valign=\"middle\">อัพเดทล่าสุด :</td>
<td align=\"left\" valign=\"middle\">".convertDate(strtotime($objResult["asset_update"]))." ".convertTime(strtotime($objResult["asset_update"]))."</td>
</tr>
</tr>
</tr>
<tr height=\"30\">
<td align=\"right\" valign=\"middle\"></td>
<td align=\"left\" valign=\"middle\">
<input type=\"submit\" id=\"btnSubmit\" name=\"btnSubmit\" value=\"บันทึกข้อมูล\" onclick=\"return confirm('ยืนยันการบันทึกข้อมูล')\"/>
<input type=\"reset\" id=\"btnreset\" name=\"btnSubmit\" value=\"ยกเลิกข้อมูล\" onclick=\"return confirm('ยืนยันการยกเลิก')\"/></td>
</tr>
</table>
</form>
</center>
</td>
</tr>
</table>
";
include("../inc/inc_footer.php");
echo "
</center>
";
mysql_close();
function fncSubmit()
{
if(confirm('Confirm to submit')==true)
{
document.form1.submit();
}
}
?>
|
ประวัติการแก้ไข 2017-03-29 18:14:39
|
|
|
|
Date :
2017-03-29 18:13:30 |
By :
niranait |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หน้า repair_edit_submit สำหรับ บึนทึกข้อมูล
ตรง SQL update ไม่รู้ว่าต้องใส่ยังไง
Code (PHP)
<?php
#ประกาศเชื่อมต่อฐานข้อมูล
include("../inc/inc_config.php");
$RepairID = $_POST["repair_id"];
$AssetID = $_POST["asset_id"];
$EmpID = $_POST["emp_id"];
$SupID = $_POST["sup_id"];
$DeptID = $_POST["dept_id"];
$RootCase = $_POST["repair_rootcause"];
$RepairUpdateID = $_POST["repair_update_id"];
$RepairStatus = $_POST["repair_status"];
$RepairStatus1 = $objResult["asset_status"];
$MaterialID = $_POST["material_id"];
//echo $RepairStatus;
$objQuery = mysql_query("INSERT INTO repair(run_id,repair_id,asset_id,emp_id,sup_id,dept_id,repair_rootcause,repair_update,repair_update_id,repair_status)
VALUES (
null,
'".$RepairID."',
'".$AssetID."',
'".$EmpID."',
'".$SupID."',
'".$DeptID."',
'".$RootCase."',
now(),
'".$RepairUpdateID."',
'".$RepairStatus."')") or die ("Not Query Database3");
$objQuery1 = mysql_query("UPDATE asset SET
'".$RepairID."',
'".$RepairStatus1."',
WHERE asset_id = '".$_GET["asset_id"]."'") or die ("Not Query Database3");
if($objQuery == true){
echo "<script>alert('บึนทึกข้อมูลการแจ้งซ่อม ".$_GET["asset_id"]." สำเร็จ');window.location=\"repair.php?post_id=".$_GET["asset_id"]."\";</script>";
addLogfile($_SESSION["User_ID"],$_SESSION["User_Level"],"แก้ไขตำแหน่งงาน ".$_GET["post_id"]);
}else{
echo "<script>alert('บันทึกข้อมูลการแจ้งซ่อม ".$_GET["asset_id"]." ไม่สำเร็จ !!');window.location=\"repair_edit.php?post_id=".$_GET["asset_id"]."\";</script>";
}
mysql_close();
?>
|
ประวัติการแก้ไข 2017-03-29 18:17:14
|
|
|
|
Date :
2017-03-29 18:16:45 |
By :
niranait |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|