|
|
|
อยากสร้างตาราง ให้มีลูกของตารางนั้นครับ เช่น 1 > 1.1,1.2 2>2.1,2.2 ครับ |
|
|
|
|
|
|
|
Code (PHP)
<style type = "text/css">
setdetail2 {background-color: #99FF66;border-color: #FFFFFF;border-style: outset ;border-width: 2;color: none;font-size: 8pt;font-family:Arial,sans-serif;font-weight: none ;text-align: none; }
</style>
<form name="work_order" method="post" action="config_work_order.php">
<?$text=" โปรดเลือก";?>
<input type="hidden" name="mode" value="<?echo $mode?>">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="100%" colspan="4" align="center" class=h1><b>แจ้งปัญหาการซ่อม</b></td>
</tr>
<tr>
<td width="20%" class = h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>เบอร์รถ : </b></td>
<td width="25%">
<input type="text" name="truck_number" value="<?if(isset($frm["truck_number"])){echo $frm["truck_number"];}else{echo "";}?>" readonly class="txtbox">
<input type="hidden" name="truck_id" value="<?if(isset($frm["truck_id"])){echo $frm["truck_id"];}else{echo "";}?>">
<!-- <input type="hidden" name="car_margue" value="<?if(isset($frm["car_margue"])){echo $frm["car_margue"];}else{echo "";}?>">
<input type="hidden" name="truck_version" value="<?if(isset($frm["truck_version"])){echo $frm["truck_version"];}else{echo "";}?>"> -->
<?if(isset($mode)&&$mode=="search_add"){?>
<input type="button" name="bt_search_car_id" value="ค้นหา" onclick="search_car_id();" >
<?}?>
</td>
<td width="20%" class=h2>ผู้ประกอบการ</td>
<td width="25%">
<input type="text" name="company_name" value="<?if(isset($frm["company_name"])){echo $frm["company_name"];}else{echo "";}?>" readonly class=txtbox size="25">
<input type="hidden" name="company_id" value="<?if(isset($frm["company_id"])){echo $frm["company_id"];}else{echo "";}?>">
</td>
</tr>
<tr>
<td width="20%" class=h2>ทะเบียนรถ</td>
<td width="25%">
<input type="text" name="truck_province" value="<?if(isset($frm["truck_province"])){echo $frm["truck_province"];}else{echo "";}?>" readonly class="txtbox" size="5">
<input type="text" name="truck_license" value="<?if(isset($frm["truck_license"])){echo $frm["truck_license"];}else{echo "";}?>" readonly class="txtbox" size="10">
</td>
<td width="20%" class=h2>ผู้ผลิต/ยี่ห้อ</td>
<td width="25%">
<input type="text" name="car_margue_name" value="<?if(isset($frm["car_margue_name"])){echo $frm["car_margue_name"];}else{echo "";}?>" class=txtbox readonly>
<input type="hidden" name="car_margue" value="<?if(isset($frm["car_margue"])){echo $frm["car_margue"];}else{echo "";}?>" size="10">
</td>
</tr>
<tr>
<td width="20%" class=h2>แบบ/รุ่น</td>
<td width="25%">
<input type="text" name="truck_version_name" value="<?if(isset($frm["truck_version_name"])){echo $frm["truck_version_name"];}else{echo "";}?>" class=txtbox readonly>
<input type="hidden" name="truck_version" value="<?if(isset($frm["truck_version"])){echo $frm["truck_version"];}else{echo "";}?>" size="10">
</td>
<td width="20%" class=h2>สีรถ</td>
<td width="25%">
<input type="hidden" name="truck_color_id" value="<?if(isset($frm["truck_color_id"])){echo $frm["truck_color_id"];}else{echo "";}?>" size="10">
<input type="text" name="truck_color_name" value="<?if(isset($frm["truck_color_name"])){echo $frm["truck_color_name"];}else{echo "";}?>" readonly class="txtbox" size="10">
</td>
</tr>
<tr>
<td width="20%" class=h2>หมายเลขเครื่องยนต์</td>
<td width="25%">
<input type="text" name="car_motor" value="<?if(isset($frm["car_motor"])){echo $frm["car_motor"];}else{echo "";}?>" readonly class="txtbox" size="10">
</td>
<td width="20%" class=h2>หมายเลขถังเครื่องยนต์</td>
<td width="25%">
<input type="text" name="car_cussy_id" value="<?if(isset($frm["car_cussy_id"])){echo $frm["car_cussy_id"];}else{echo "";}?>" readonly class="txtbox" size="10">
</td>
</tr>
<tr>
<td width="20%" class=h2>เลขไมล์สะสม (กม.)</td>
<td width="25%">
<input type="text" name="mile_cumulative" value="<?if(isset($frm["mile_cumulative"])){echo $frm["mile_cumulative"];}else{echo "";}?>" readonly class="txtbox">
</td>
<td width="20%" class=h2>เลขไมล์ที่เข้าซ่อม (กม.)</td>
<td width="25%">
<input type="text" name="mile_repair" value="<?if(isset($frm["mile_repair"])){echo $frm["mile_repair"];}else{echo "";}?>" size="10" onkeypress="return is_number();" maxlength="10" <?if(isset($mode)&&$mode=="insert"){echo "readonly";}?> <?if(isset($mode)&&$mode=="insert"){?>class="txtbox"<?}?>>
</td>
</tr>
<tr>
<td width="20%" class=h2>ผู้ขอซ่อม/ผู้แจ้งซ่อม</td>
<td width="25%">
<input type="text" name="user_request_repair" value="<?if(isset($frm["user_request_repair"])){echo $frm["user_request_repair"];}else{echo $name. " ".$surname;}?>" readonly class="txtbox">
<input type="hidden" name="log_user" value="<?if(isset($frm["log_user"])){echo $frm["log_user"];}else{echo $userlogin;}?>">
</td>
<td width="20%" class=h2>ผู้ควบคุม/ผู้รับแจ้ง</td>
<td width="25%">
<input type="text" name="user_notify" value="<?if(isset($frm["user_notify"])){echo $frm["user_notify"];}else{echo $name." ".$surname;}?>" readonly class="txtbox">
</td>
</tr>
<tr>
<td width="20%" class=h2>เอกสารที่เกี่ยวข้อง</td>
<td width="25%">
<input type="text" name="document_ref" value="<?if(isset($frm["document_ref"])){echo $frm["document_ref"];}else{echo "";}?>" <?if(isset($mode)&&$mode=="insert"){echo "readonly";}?> <?if(isset($mode)&&$mode=="insert"){?>class=txtbox<?}?> size="10" maxlength="10">
</td>
<td width="20%" class=h2>ประเภทการซ่อม
</td>
<td width="25%">
<select name="type_pm" <?if(isset($mode)&&$mode=="insert"){echo "disabled";}?>>
<option value="">-- โปรดเลือก --</option>
<option value="1"
<?if(isset($frm["type_pm"])&&$frm["type_pm"]=="1"){
echo "selected";
}?>
>-- ปกติ --</option>
<option value="2"
<?if(isset($frm["type_pm"])&&$frm["type_pm"]=="2"){
echo "selected";
}?>
>-- อุบัติเหตุ --</option>
</select>
<input type="hidden" name="type_pm2" value="<?if(isset($frm["type_pm"])){echo $frm["type_pm"];}else{echo "";}?>">
</td>
</tr>
<tr>
<td width="20%" class=h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>แผนงานซ่อมบำรุง : </b></td>
<td width="25%">
<!-- <input type="text" name="maintenance_id" value="<?if(isset($frm["maintenance_id"])){echo $frm["maintenance_id"];}else{echo "";}?>" class="txtbox" readonly> -->
<?if(isset($frm["truck_id"])){
$select_pm="select * from pm_schedule_maintenance where status='1' and truck_id='".$frm["truck_id"]."' ";
$query_pm=db_query($select_pm);
}?>
<select name="pm_id" <?if(isset($mode)&&$mode=="insert"){echo "disabled";}?>>
<option>-- <?echo $text?> ---</option>
<?if(isset($frm["truck_id"])){
while($result_pm=db_fetch_array($query_pm)){?>
<option value="<?echo $result_pm["pm_id"]?>"
<?if(isset($frm["pm_id"])&&$frm["pm_id"]==$result_pm["pm_id"]){
echo "selected";
}?>
><?echo number_format($result_pm["set_mile_repair"]);?>กม.</option>
<?}?>
<?}?>
</select>
<input type="hidden" name="pm_id2" value="<?if(isset($frm["pm_id"])){echo $frm["pm_id"];}else{echo "";}?>">
<!-- <input type="button" name="bt_search_pm" value="ค้นหา" onclick="search_pm_id();"> -->
</td>
<td width="20%" class=h2>อาการ/เหตุผล ที่ขอซ่อม</td>
<td width="25%">
<textarea name="comment" cols="40" rows="3" <?if(isset($mode)&&$mode=="insert"){echo "disabled";}?>><?if(isset($frm["comment"])){echo $frm["comment"];}else{echo "";}?></textarea>
<input type="hidden" name="comment2" value="<?if(isset($frm["comment"])){echo $frm["comment"];}else{echo "";}?>">
</td>
</tr>
<tr>
<td width="20%" class=h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>วัน/เวลา ที่เข้าซ่อม : </b></td>
</td>
<td width="25%">
<input type="text" name="operate_date" value=<?if(isset($frm["operate_date"])){echo $frm["operate_date"];}else{echo $thisdate;}?> readonly size="10" class=txtbox>
<script language="javascript">
if(!document.layers){
document.write("<input type=button name='operation_date2' onclick='popUpCalendar(this, work_order.operate_date, \"yyyy-mm-dd\")' <?if(isset($mode)&&$mode=='insert'){echo 'disabled';}?> value='เลือกวัน' style='font-size:11px'>");
}
</script>
<select name="hour_sel" <?if(isset($mode)&&$mode=="insert"){echo "disabled";}?>>
<?for($i=0;$i<=23;$i++){?>
<?if($i<10){
$i="0".$i;
}?>
<option value="<?echo $i?>"
<?if(isset($frm["hour_sel"])&&$frm["hour_sel"]==$i){
echo "selected";
}?>
><?echo $i;?></option>
<?}?>
</select>
<input type="hidden" name="hour_sel2" value="<?if(isset($frm["hour_sel"])){echo $frm["hour_sel"];}else{echo "";}?>">
<select name="min_sel" <?if(isset($mode)&&$mode=="insert"){echo "disabled";}?>>
<?for($j=0;$j<=59;$j++){?>
<?if($j<10){
$j="0".$j;
}?>
<option value="<?echo $j?>"
<?if(isset($frm["min_sel"])&&$frm["min_sel"]==$j){
echo "selected";
}?>
><?echo $j;?></option>
<?}?>
</select>
<input type="hidden" name="min_sel2" value="<?if(isset($frm["min_sel"])){echo $frm["min_sel"];}else{echo "";}?>">
</td>
<?if(isset($mode)&&$mode=="insert"){?>
<td class=h2><b>วัน/เวลา ที่คาดว่าจะเสร็จ</b></td>
<?
$hour_expect=$frm["hour_sel"]+3;
$date_expect=$frm["operate_date"];
if($hour_expect>23){
$hour_expect=$hour_expect-24;
$hour_expect="0".$hour_expect;
$sql="select '".$frm["operate_date"]."' + INTERVAL 1 DAY as date_expect ";
$query=db_query($sql);
$result=db_fetch_array($query);
$date_expect=$result["date_expect"];
}
?>
<td>
<input type="text" name="date_expect" value="<?echo $date_expect;?>" readonly class=txtbox size="10">
<select name="hour_expect" readonly>
<option value="<?echo $hour_expect?>"><?echo $hour_expect?></option>
</select>
<select name="min_expect" readonly>
<option value="<?echo $frm["min_sel"]?>"><?echo $frm["min_sel"]?></option>
</select>
</td>
<?}?>
</tr>
<?if(isset($mode)&&$mode=="insert"){?>
<?if(!isset($sim_small)){$sim_small=0;}?>
<input type="hidde1n" name="rowtwo0_sim_small" value="<?echo $sim_small;?>">
<input type="hidde1n" name="rowtwo1_sim_small" value="<?echo $sim_small;?>">
<table id="attach_tbl_sim_small" width="100%" border="1" align="center" cellpadding="1" cellspacing="1" bgcolor="FFFFFF">
<tr>
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">No</td>
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">ประเภทงานซ่อมบำรุง</td>
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">ชื่องานซ่อมบำรุง</td>
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">จำนวน</td>
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">หน่วย</td>
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">ราคา</td>
<!-- <td bgcolor="#CCFFFF" class = setdetail nowrap align="center">ส่วนลด %</td> -->
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">ราคาสุทธิ</td>
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">ประเภทการดูแลรักษา</td>
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">หมายเหตุ</td>
<td bgcolor="#CCFFFF" class = setdetail nowrap align="center">สถานะ</td>
<td><input type="button" name="add_row_sim_small" onclick="{addRowtwo(this.form,0, this.form.rowtwo0_sim_small , this.form.rowtwo1_sim_small )}" value=" + "></td>
<td><input type="button" name="del_file_sim_small" value=" - " onclick="delRowtwo(this.form , this.form.rowtwo0_sim_small , this.form.rowtwo1_sim_small , 0,<?if(!isset($ckd0))$ckd0=0;echo$ckd0;?>);"></td>
</tr>
<script language="javascript">
var Tempitem=new Array();
</script>
<?$sql_item="select * from pm_maintenance_item where pm_id='".$frm["pm_id"]."' ";
$query_item=db_query($sql_item);
$num_item=db_num_rows($query_item);
$count_item=1;
$row=1;?>
<?while($result_item=db_fetch_array($query_item)){?>
<tr>
<td><?echo $count_item++;?></td>
<?db_connect($CFG->dbhost_fleet, $CFG->dbname_fleet, $CFG->dbuser_fleet, $CFG->dbpass_fleet);
$select_type="select description,level_id from pm_oc_profile_truck_detail where status='1' and extend_value='624' and parent_level_id!='1' and level_id='".$result_item["pm_type"]."' order by level_id";
$query_type=db_query($select_type);
?>
<td>
<select name="pm_type<?echo $row?>">
<?$result_type=db_fetch_array($query_type);?>
<option value="<?echo $result_type["level_id"];?>"><?echo $result_type["description"];?></option>
</select>
</td>
<td>
<?$select_name="select description,level_id,value from pm_oc_profile_truck_detail where status='1' and parent_level_id='".$result_item["pm_type"]."' and parent_level_id!='1' and level_id='".$result_item["pm_name"]."' order by level_id ";
$query_name=db_query($select_name);
?>
<select name="pm_name<?echo $row?>" >
<?$result_name=db_fetch_array($query_name);?>
<option value="<?echo $result_name["level_id"]?>"><?echo $result_name["description"];?></option>
</select>
</td>
<td class=setdetail>
<input type="text" name="amount<?echo $row;?>" value="<?echo $result_item["amount"]?>" size="10" onkeypress="return is_number();" >
</td>
<td>
<select name="unit_id<?echo $row;?>">
<option value="<?echo $result_item["pm_unit"]?>"><?echo search_config_detail_truck($result_item["pm_unit"]);?></option>
</select>
</td>
<td class=setdetail>
<input type="text" name="value<?echo $row;?>" value="0" readonly class=txtbox size="10">
</td>
<!-- <td class=setdetail>
</td> -->
<input type="hidden" name="discount_value<?echo $row?>" value="0">
<td class=setdetail>
<input type="text" name="value_net<?echo $row?>" value="0" class=txtbox size="10" readonly>
</td>
<td>
<select name="pm_type_id<?echo $row?>">
<option value="<?echo $result_item["pm_type_id"]?>"><?echo search_config_detail_truck($result_item["pm_type_id"]);?></option>
</select>
</td>
<td><textarea name="comment<?echo $row?>" readonly><?echo $result_item["comment"]?></textarea>
</td>
<td nowrap>
<input type="checkbox" name="status_pm<?echo $row?>" checked onclick="sum_total()"> เลือก (ใช้งาน)
</td>
<?if(!isset($sim_item)){$sim_item=0;}?>
<input type="hidde1n" name="rowitem0[<?echo $row;?>]" value="<?echo $sim_item;?>">
<input type="hidde1n" name="rowitem1[<?echo $row;?>]" value="<?echo $sim_item;?>">
<td><input type="button" name="add_row_item<?echo $row;?>" onclick="{addRowitem(this.form,0,document.work_order.elements['rowitem0['+<?echo $row;?>+']'],document.work_order.elements['rowitem1['+<?echo $row;?>+']'],<?echo $row;?>)}" value=" + "></input></td>
<td></td>
</tr>
<tr>
<td colspan="10">
<table name="attach_tbl[<?echo $row;?>]" id="attach_tbl<?echo $row;?>" width="100%" border="0">
<tr>
<td> </td>
<td bgcolor="#99FF66" class = setdetail nowrap align="center">ลำดับ</td>
<td bgcolor="#99FF66" class = setdetail nowrap align="center">ประเภทอะไหล่</td>
<td bgcolor="#99FF66" class = setdetail nowrap align="center">ชื่ออะไหล่</td>
<td bgcolor="#99FF66" class = setdetail nowrap align="center">จำนวน</td>
<td bgcolor="#99FF66" class = setdetail nowrap align="center">หน่วย</td>
<td bgcolor="#99FF66" class = setdetail nowrap align="center">ราคา</td>
<td bgcolor="#99FF66" class = setdetail nowrap align="center">ส่วนลด %</td>
<td bgcolor="#99FF66" class = setdetail nowrap align="center">ราคาสุทธิ</td>
<td bgcolor="#99FF66" class = setdetail nowrap align="center">หมายเหตุ</td>
</tr>
</table>
</td>
</tr>
<script language="javascript">
Tempitem[<?echo $row;?>]=attach_tbl<?echo $row;?>;
</script>
<?$row++?>
<?}?>
</tr>
<script language="javascript">
var Temptwo=new Array();
Temptwo[0] = attach_tbl_sim_small;
</script>
<?////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////?>
<?if(!isset($sim_promotion)){$sim_promotion=0;}?>
<input type="hidden" name="rowtwo0_sim_promotion" value="<?echo $sim_promotion;?>">
<input type="hidden" name="rowtwo1_sim_promotion" value="<?echo $sim_promotion;?>">
<table id="attach_tbl_promotion" width = '100%' border="0" align = 'center' cellpadding = 1 cellspacing = 1 >
<tr align="center">
<td bgcolor="#FF0066" class = setdetail nowrap align="center">No</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">ประเภทงานซ่อมบำรุง</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">ชื่องานซ่อมบำรุง</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">จำนวน</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">หน่วย</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">ราคา</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">ส่วนลด %</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">ราคาสุทธิ</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">ประเภทการดูแลรักษา</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">หมายเหตุ</td>
<td bgcolor="#FF0066" class = setdetail nowrap align="center">สถานะ</td>
<td><input type="button" name="add_row_promotion" onclick="{addRowtwo_promotion(this.form,0, this.form.rowtwo0_sim_promotion , this.form.rowtwo1_sim_promotion )}" value=" + "></td>
<td><input type="button" name="del_row_promotion" value=" - " onclick="delRowtwo_promotion(this.form , this.form.rowtwo0_sim_promotion , this.form.rowtwo1_sim_promotion , 0,<?if(!isset($ckd0))$ckd0=0;echo$ckd0;?>);"></td>
</tr>
<script language="javascript">
var Temptwo_promotion=new Array();
Temptwo_promotion[0]=attach_tbl_promotion;
</script>
</table>
<input type="hidd1en" name="num_row" value="<?echo $num_item?>">
<input type="hidden" name="num_row_promotion" value="0">
</table>
<br>
<br>
<table width="100%">
<?db_connect($CFG->dbhost, $CFG->dbname, $CFG->dbuser, $CFG->dbpass);
$sql_part_value="select * from pm_maintenance_item where pm_id='".$frm["pm_id"]."' and status='1' ";
$query_part_value=db_query($sql_part_value);
$part_value=0;
while($result_part_value=db_fetch_array($query_part_value)){
db_connect($CFG->dbhost_fleet, $CFG->dbname_fleet, $CFG->dbuser_fleet, $CFG->dbpass_fleet);
$sql_oc_value="select value from pm_oc_profile_truck_detail where level_id='".$result_part_value["pm_name"]."' and parent_level_id='".$result_part_value["pm_type"]."' ";
$query_oc_value=db_query($sql_oc_value);
$result_oc_value=db_fetch_array($query_oc_value);
$part_value+=$result_part_value["amount"]*$result_oc_value["value"];
}
$part_value=rounds($part_value,2);
db_connect($CFG->dbhost, $CFG->dbname, $CFG->dbuser, $CFG->dbpass);
$value_after=$part_value;
$value_before_discount=$part_value;
$vat_value=($value_before_discount*7)/100;
$vat_value=rounds($vat_value,2);
$value_net=$value_before_discount+$vat_value;
$value_net=rounds($value_net,2);
?>
<tr>
<td width="20%" class=h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>ค่าซ่อม (บาท)</b>
</td>
<td>
<input type="text" name="part_value" value="<?echo $part_value;?>" class=txtbox onkeypress="return is_number();" readonly size="8">
</td>
<td width="20%" class=h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>โปรโมชั่น (บาท)</b></td>
<td ><input type="text" name="promotion_value" readonly class=txtbox size="8" value="0"></td>
</tr>
<tr>
<tr>
<td width="20%" class=h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>ค่าบริการ (บาท)</b>
</td>
<td>
<input type="text" name="service_value" value="<?if(isset($frm["service_value"])){echo $frm["service_value"];}else{echo "0";}?>" onkeypress="return is_number();" size="8" onkeypress="return is_number();" onblur="sum_total();">
</td>
<td width="20%" class=h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>ยอดเงินรวม (บาท)</b></td>
<td ><input type="text" name="value_after" readonly class=txtbox size="8" value="<?echo $value_after;?>"></td>
</tr>
<tr>
<td width="20%" class=h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>ยอดเงินรวมหักส่วนลด (บาท)</b></td>
<td ><input type="text" name="value_before_discount" readonly class=txtbox size="8" value="<?echo $value_before_discount;?>">
<input type="hidden" name="discount_value_net" value="0"></td>
<td width="20%" class=h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>ภาษีมูลค่าเพิ่ม 7% (บาท)</b></td>
<td ><input type="text" name="vat_value" readonly class=txtbox size="8" value="<?echo $vat_value;?>"></td>
</tr>
<tr>
<td width="20%" class=h2><b> <FONT SIZE="2" COLOR="#FF0000">**</FONT>ยอดรวมสุทธิ (บาท)</b></td>
<td ><input type="text" name="value_net" readonly class=txtbox size="8" value="<?echo $value_net;?>"></td>
</tr>
</table>
<?}//if mode?>
</table>
<br>
<center>
<input type="submit" name="submit" value="ยืนยันการบันทึก" onclick="return chk_submit();">
</form>
<?
db_connect($CFG->dbhost_fleet, $CFG->dbname_fleet, $CFG->dbuser_fleet, $CFG->dbpass_fleet);
$select_maintenance_id="select description,level_id from pm_oc_profile_truck_detail where status='1' and extend_value='624' and parent_level_id!='1' order by level_id";
$query_maintenance_id=db_query($select_maintenance_id);
$select_type="select distinct(pm_oc_profile_truck_detail.level_id),pm_oc_profile_truck_detail.description,inv_stock.equip_type_id from pm_oc_profile_truck_detail,inv_stock where inv_stock.equip_type_id =pm_oc_profile_truck_detail.level_id order by pm_oc_profile_truck_detail.level_id";
$query3=db_query($select_type);
?>
<script language="javascript">
var supported=(window.Option) ? 1 : 0;
var supported2=(window.Option) ? 1 : 0;
if(supported2){
var active;
var i = 0;
var j = 0;
var k = 0;
var text_check;
var ar2 = new Array();
ar2[0] = new Array();
ar2[i][j] = new makeoption("----<?echo $text;?>----","");
text_check="ALL";
<?while($result_maintenance_id=db_fetch_array($query_maintenance_id)){?>
if(k==0){
text_check="ALL";
}
k=1;
if(text_check!=<?echo $result_maintenance_id["level_id"];?>){
i++;
ar2[i] = new Array();
text_check=<?echo $result_maintenance_id["level_id"];?>;
j=0;
ar2[i][j] = new makeoption("----<?echo $text;?>----","");
j++;
}
if(text_check==<?echo $result_maintenance_id["level_id"];?>){
<?
$select_maintenance_id2="select level_id,description,value from pm_oc_profile_truck_detail where status='1' and parent_level_id='$result_maintenance_id[level_id]' and parent_level_id!='1' order by description ";
$query_maintenance_id2=db_query($select_maintenance_id2);
while($result_maintenance_id2=db_fetch_array($query_maintenance_id2)){?>
ar2[i][j] = new makeoption("<?echo $result_maintenance_id2['description'];?>","<?echo $result_maintenance_id2['level_id'];?>");
j++;
<?}?>
}
<?}?>
}
function numberOfRowtwo2(index){
if(Temptwo_promotion[index]){
return (Temptwo_promotion[index].rows.length);
}else{
return (-1)
}
}
function addRowtwo_promotion(form,index,row0,row1){
row=numberOfRowtwo2(index);
num=row;
row0.value=row;
var promotion_id = new Array();
var promotion_name = new Array();
promotion_value="";
<?$a=1;
echo "promotion_id[0]='';";
echo "promotion_name[0]='--- $text ---';";
$sql="select description,level_id,value from pm_oc_profile_truck_detail where parent_level_id='11' order by level_id ";
$query=db_query($sql);
while($result=db_fetch_array($query)){
echo "promotion_id[$a]='".$result["level_id"]."/".$result["value"]."';";
echo "promotion_name[$a]='".$result["description"]."';";
$a++;
}
echo "promotion_count=$a;";
?>
promotion_promotion_strings="<select style='font-family:Arial,sans-serif;font-size:8pt;' name='promotion_id"+num+"' id='promotion_id"+num+";>";
for(a=0;a<promotion_count;a++){
if(promotion_value==promotion_id[a]){
promotion_promotion_strings+="<option value='"+promotion_id[a]+"' selected>"+promotion_name[a]+"</option> ";
}else{
promotion_promotion_strings+="<option value='"+promotion_id[a]+"'>"+promotion_name[a]+"</option>";
}
}
promotion_promotion_strings+="</selecet>";
var unit_id=new Array();
var unit_description=new Array();
unit_value="";
<?$c=1;
echo "unit_id[0]='';";
echo "unit_description[0]='--- $text ---';";
$select_unit="select level_id,description from pm_oc_profile_truck_detail where status='1' and extend_value='527' and parent_level_id!='1' order by level_id ";
$query_unit=db_query($select_unit);
while($result_unit=db_fetch_array($query_unit)){
echo "unit_id[$c]='".$result_unit["level_id"]."';";
echo "unit_description[$c]='".$result_unit["description"]."';";
$c++;
}
echo "unit_count=$c;";
?>
unit_unit_strings="<select style='font-famaly:Arail,sans-serif;font-size:8pt;' name='unit_promotion_id"+num+"' id='unit_promotion_id"+num+"'>";
for(c=0;c<unit_count;c++){
if(unit_value==unit_id[c]){
unit_unit_strings+="<option value='"+unit_id[c]+"' selected>"+unit_description[c]+"</option>";
}else{
unit_unit_strings+="<option value='"+unit_id[c]+"'>"+unit_description[c]+"</option>";
}
}
unit_unit_strings+="</select>";
var type_pm_id=new Array();
var type_pm_description=new Array();
type_pm_value="";
<?
$d=1;
echo "type_pm_id[0]='';";
echo "type_pm_description[0]='--- $text ---';";
$select_type_pm="select level_id,description from pm_oc_profile_truck_detail where status='1' and extend_value='667' and parent_level_id!='1' order by level_id";
$query_type_pm=db_query($select_type_pm);
while($result_type_pm=db_fetch_array($query_type_pm)){
echo "type_pm_id[$d]='".$result_type_pm["level_id"]."';";
echo "type_pm_description[$d]='".$result_type_pm["description"]."';";
$d++;
}
echo "type_pm_count=$d;";
?>
pm_pm_strings="<select style='font-famaly:Arail,sans-serif;font-size:8pt;' name='pm_promotion_type_id"+num+"' id='pm_type_id"+num+"'>";
for(d=0;d<type_pm_count;d++){
if(type_pm_value==type_pm_id[d]){
pm_pm_strings+="<option value='"+type_pm_id[d]+"' selected>"+type_pm_description[d]+"</option>";
}else{
pm_pm_strings+="<option value='"+type_pm_id[d]+"'>"+type_pm_description[d]+"</option>";
}
}
pm_pm_strings+="</select>";
switch(index){
case 0:
Temptwo_promotion[index].insertRow ();
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].style.textAlign="";
Temptwo_promotion[index].rows[row].cells.item(0).innerHTML = "<td class=setdetail>"+num+".</td>";
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(1).innerHTML = "<td><input type='text' name='promotion_name"+num+"' value='โปรโมชั่นพิเศษ' readonly class=txtbox></td>";
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(2).innerHTML =promotion_promotion_strings;
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(3).innerHTML = "<td ><input type='text' id='amount_promotion"+num+"' name='amount_promotion"+num+"' value='1' onkeypress='return is_number();' onblur='sum_amount_promotion("+num+")' size='10'></td>";
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(4).innerHTML = unit_unit_strings;
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(5).innerHTML = "<td><input type='text' id='value_promotion"+num+"' name='value_promotion"+num+"' value='0' readonly class=txtbox size='10'></td>";
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(6).innerHTML = "<td ></td>";
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(7).innerHTML = "<td ><input type='text' id='value_net_promotion"+num+"' name='value_net_promotion"+num+"' value='0' readonly size='10' class='txtbox'></td>";
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(8).innerHTML = pm_pm_strings;
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(9).innerHTML = "<td ><textarea name='comment_promotion"+num+"' id='comment_promotion"+num+"'></textarea></td>";
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(10).innerHTML = "<td ><input type='checkbox' id='status_pm_promotion"+num+"' name='status_pm_promotion"+num+"' checked readonly size='10' onclick='sum_value_promotion()'>ใช้งาน</td>";
Temptwo_promotion[index].rows[row].insertCell ();
Temptwo_promotion[index].rows[row].cells.item(11).innerHTML ="<td><input type='hidden' id='discount_value_promotion"+num+"' name='discount_value_promotion"+num+"' value='0'></td>"
break;
}
document.work_order.elements.num_row_promotion.value=num;
}
function numberOfRowtwo(index) {
if (Temptwo[index])
return (Temptwo[index].rows.length);
else
return (-1);
}
function delRowtwo(form,row0,row1,index,fg){
var row = numberOfRowtwo(index);
if(row>1 &&( row0.value>row1.value || fg==0)){
Temptwo[index].deleteRow (-1);
row0.value=row0.value-1;
}
row = numberOfRowtwo(index);
document.work_order.elements.num_row.value=row-1;
sum_total();
}
function delRowtwo_promotion(form,row0,row1,index,fg){
var row = numberOfRowtwo2(index);
if(row>1 &&( row0.value>row1.value || fg==0)){
Temptwo_promotion[index].deleteRow (-1);
row0.value=row0.value-1;
}
row = numberOfRowtwo2(index);
document.work_order.elements.num_row_promotion.value=row-1;
sum_value_promotion();
}
function addRowtwo(form,index,row0 ,row1){
//แสดงตำแหน่งหน้าจอ
row=numberOfRowtwo(index);
num=(row/2)+0.5;
row0.value=row;
var type_id=new Array();
var type_discription=new Array();
type_value="";
<?
$a=1;
echo "type_id[0]='';";
echo "type_discription[0]='--- $text ---';";
$select_array="select level_id,description from pm_oc_profile_truck_detail where status='1' and extend_value='624' and parent_level_id!='1' order by level_id ";
$query_array=db_query($select_array);
while($result_array=db_fetch_array($query_array)){
echo "type_id[$a]='".$result_array["level_id"]."';";
echo "type_discription[$a]='".$result_array["description"]."';";
$a++;
}
echo "type_count=$a;";
?>
type_type_strings="<select style='font-famaly:Arail,sans-serif;font-size:8pt;' name='pm_type"+num+"' id='pm_type"+num+"' onchange='check_type(this.form,"+num+");'>";
for(a=0;a<type_count;a++){
if(type_value==type_id[a]){
type_type_strings+="<option value='"+type_id[a]+"' selected>"+type_discription[a]+"</option>";
}else{
type_type_strings+="<option value='"+type_id[a]+"'>"+type_discription[a]+"</option>";
}
}
type_type_strings+="</select>";
var name_id = new Array();
var name_discription = new Array();
name_value = '';
<?$b=1;
echo "name_id[0]='';";
echo "name_discription[0]='--- $text ---';";
echo "name_count=$b;";
?>
name_name_strings="<select style='font-family:Arial,sans-serif;font-size:8pt;' name='pm_name"+num+"' id='pm_name"+num+"'>";
for(b=0;b<name_count;b++){
if(name_value==name_id){
name_name_strings+="<option value='"+name_id+"' selected>"+name_discription+"</option>";
}else{
name_name_strings+="<option value='"+name_id+"'>"+name_discription+"</option>";
}
}
name_name_strings+="</select>";
var unit_id=new Array();
var unit_description=new Array();
unit_value="";
<?$c=1;
echo "unit_id[0]='';";
echo "unit_description[0]='--- $text ---';";
$select_unit="select level_id,description from pm_oc_profile_truck_detail where status='1' and extend_value='527' and parent_level_id!='1' order by level_id ";
$query_unit=db_query($select_unit);
while($result_unit=db_fetch_array($query_unit)){
echo "unit_id[$c]='".$result_unit["level_id"]."';";
echo "unit_description[$c]='".$result_unit["description"]."';";
$c++;
}
echo "unit_count=$c;";
?>
unit_unit_strings="<select style='font-famaly:Arail,sans-serif;font-size:8pt;' name='unit_id"+num+"' id='unit_id"+num+"'>";
for(c=0;c<unit_count;c++){
if(unit_value==unit_id[c]){
unit_unit_strings+="<option value='"+unit_id[c]+"' selected>"+unit_description[c]+"</option>";
}else{
unit_unit_strings+="<option value='"+unit_id[c]+"'>"+unit_description[c]+"</option>";
}
}
unit_unit_strings+="</select>";
var type_pm_id=new Array();
var type_pm_description=new Array();
type_pm_value="";
<?
$d=1;
echo "type_pm_id[0]='';";
echo "type_pm_description[0]='--- $text ---';";
$select_type_pm="select level_id,description from pm_oc_profile_truck_detail where status='1' and extend_value='667' and parent_level_id!='1' order by level_id";
$query_type_pm=db_query($select_type_pm);
while($result_type_pm=db_fetch_array($query_type_pm)){
echo "type_pm_id[$d]='".$result_type_pm["level_id"]."';";
echo "type_pm_description[$d]='".$result_type_pm["description"]."';";
$d++;
}
echo "type_pm_count=$d;";
?>
pm_pm_strings="<select style='font-famaly:Arail,sans-serif;font-size:8pt;' name='pm_type_id"+num+"' id='pm_type_id"+num+"'>";
for(d=0;d<type_pm_count;d++){
if(type_pm_value==type_pm_id[d]){
pm_pm_strings+="<option value='"+type_pm_id[d]+"' selected>"+type_pm_description[d]+"</option>";
}else{
pm_pm_strings+="<option value='"+type_pm_id[d]+"'>"+type_pm_description[d]+"</option>";
}
}
pm_pm_strings+="</select>";
switch(index){
case 0:
Temptwo[index].insertRow ();
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].style.textAlign="";
Temptwo[index].rows[row].cells.item(0).innerHTML ="<td>"+num+"</td>" ;
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(1).innerHTML ="<td>"+type_type_strings+"</td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(2).innerHTML ="<td>"+name_name_strings+"</td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(3).innerHTML = "<td><input type='text' id='amount"+num+"' name='amount"+num+"' value='1' onkeypress='return is_number();' size='10'></td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(4).innerHTML ="<td>"+unit_unit_strings+"</td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(5).innerHTML = "<td><input type='text' id='value"+num+"' name='value"+num+"' value='0' readonly class=txtbox size='10'></td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(6).innerHTML = "<td><input type='text' id='value_net"+num+"' name='value_net"+num+"' value='0' readonly size='10' class='txtbox'></td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(7).innerHTML = "<td>"+pm_pm_strings+"</td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(8).innerHTML = "<td><textarea name='comment"+num+"' id='comment"+num+"'></textarea></td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(9).innerHTML = "<td><input type='checkbox' id='status_pm"+num+"' name='status_pm"+num+"' checked readonly size='10' onclick='sum_total()'>ใช้งาน</td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(10).innerHTML ="<td><input type='hidden' id='discount_value"+num+"' name='discount_value"+num+"' value='0'></td>";
Temptwo[index].rows[row].insertCell ();
Temptwo[index].rows[row].cells.item(11).innerHTML ="<td><input type='hidden' name='rowitem0["+num+"]' value='<?if(isset($sim_item)){echo $sim_item;}else{echo '0';}?>'><input type='hidden' name='rowitem1["+num+"]' value='<?if(isset($sim_item)){echo $sim_item;}else{echo '0';}?>'><input type='button' name='add_row_item"+num+"' value=' + ' onclick=addRowitem(this.form,0,document.work_order.elements['rowitem0["+num+"]'],document.work_order.elements['rowitem1["+num+"]'],"+num+");></td>";
Temptwo[index].insertRow ();
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].style.backgroundColor="#99FF66";
Temptwo[index].rows[row+1].cells.item(0).innerHTML="<table name='attach_tbl["+num+"]' id='attach_tbl"+num+"' width='100%'><tr><td>ลำดับ</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(1).innerHTML="<td>ประเภทอะไหล่</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(2).innerHTML="<td>ชื่ออะไหล่</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(3).innerHTML="<td>จำนวน</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(4).innerHTML="<td>หน่วย</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(5).innerHTML="<td>ราคา</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(6).innerHTML="<td>ราคา</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(7).innerHTML="<td>ราคา</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(6).innerHTML="<td>ส่วนลด %</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(8).innerHTML="<td>ราคาสุทธิ</td>";
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].cells.item(9).innerHTML="<td>หมายเหตุ</td></tr></table></td></tr>";
Tempitem[num]=attach_tbl4;
alert(num);
/*Tempitem[num].insertRow ();
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(0).innerHTML = "<td></td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(1).innerHTML = "<td></td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(2).innerHTML ="<td></td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(3).innerHTML = "<td></td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(4).innerHTML ="<td></td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(5).innerHTML = "<td></td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(6).innerHTML = "<td></td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(7).innerHTML ="<td></td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(8).innerHTML = "<td></td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(9).innerHTML = "<td></td>";
*/
/* Tempitem[num].insertRow ();
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].style.textAlign="";
Tempitem[num].rows[0].cells.item(0).style.backgroundColor="#FFFFFF";
Tempitem[num].rows[0].cells.item(0).innerHTML = "";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].style.backgroundColor="#99FF66";
Tempitem[num].rows[0].cells.item(1).innerHTML = "<td>ลำดับ</td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(2).innerHTML ="<td>ประเภทอะไหล่</td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(3).innerHTML = "<td>ชื่ออะไหล่</td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(4).innerHTML ="<td>จำนวน</td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(5).innerHTML = "<td>หน่วย</td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(6).innerHTML = "<td>ราคา</td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(7).innerHTML ="<td>ส่วนลด %</td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(8).innerHTML = "<td>ราคาสุทธิ</td>";
Tempitem[num].rows[0].insertCell ();
Tempitem[num].rows[0].cells.item(9).innerHTML = "<td>หมายเหตุ</td></table></td></tr>";
*/
alert(num);
//
//alert(attacth_tbl4);
//var attach_tbl=new Array();
//var Tempitem=new Array();
break;
}
document.work_order.elements.num_row.value=num;
}
function search_car_id(){
locate='search_find_work_car_id_window.php?';
window2=open(locate,'DisplayWindows','location=no,toolbar=no,scrollbars=yes,width=700,height=600,status=yes');
window2.focus();
}
function search_pm_id(){
if(document.work_order.elements.type_pm.value=="1"){
truck_id=document.work_order.elements.truck_id.value;
truck_number=document.work_order.elements.truck_number.value;
locate='search_find_work_pm_id_window.php?truck_id='+truck_id+'&truck_number='+truck_number;
window2=open(locate,'DisplayWindows','location=no,toolbar=no,scrollbars=yes,width=700,height=600,status=yes');
window2.focus();
}else{
alert("กรุณาเลือกประเภทการซ่อม ปกติ");
}
}
function is_number(){
var keycode=window.event.keyCode;
if((keycode>=48&&keycode<=57) || keycode==8){
return true;
}else{
return false;
}
}
function chk_submit(){
if(document.work_order.elements.mode.value=="search_add"){
if(document.work_order.elements.type_pm.value!="2" ){
if(document.work_order.elements.truck_number.value=="" || document.work_order.elements.comment.value=="" || document.work_order.elements.mile_repair.value=="" || document.work_order.elements.document_ref.value=="" || document.work_order.elements.user_request_repair.value=="" || document.work_order.elements.maintenance_id.value=="" || document.work_order.elements.operate_date.value==""){
alert("กรุณากรอกข้อมูลให้ครบ");
return false;
}
}else{
if(document.work_order.elements.truck_number.value=="" || document.work_order.elements.comment.value=="" || document.work_order.elements.mile_repair.value=="" || document.work_order.elements.document_ref.value=="" || document.work_order.elements.user_request_repair.value=="" || document.work_order.elements.operate_date.value==""){
alert("กรุณากรอกข้อมูลให้ครบ");
return false;
}
}
}else{
count=0;
for(i=1;i<=document.work_order.elements.num_row.value;i++){
if(document.work_order.elements("pm_type"+i).value=="" || document.work_order.elements("pm_name"+i).value=="" || document.work_order.elements("amount"+i).value=="" || document.work_order.elements("value"+i).value=="" || document.work_order.elements("discount_per"+i).value=="" || document.work_order.elements("value_net"+i).value=="" || document.work_order.elements("pm_type_id"+i).value=="" || document.work_order.elements("unit_id"+i).value==""){
count++;
}
}
for(j=1;j<=document.work_order.elements.num_row_promotion.value;j++){
if(document.work_order.elements("amount_promotion"+j).value=="" || document.work_order.elements("discount_per_promotion"+j).value=="" || document.work_order.elements("promotion_id"+j).value=="" || document.work_order.elements("pm_promotion_type_id"+j).value=="" || document.work_order.elements("unit_promotion_id"+j).value==""){
count++;
}
}
if(count>0){
alert("กรุณากรอกข้อมูลให้ครบ");
return false;
}
}
if(confirm("ยืนยันการบันทึก")){
return true;
}else{
return false;
}
}
function check_type(form,row){
if(!supported2){
load(form,"pm_type"+row);
return;
}
var options = form.elements["pm_name"+row].options;
for(var i = options.length - 1; i > 0; i--){
options[i] = null;
}
var curAr = ar2[form.elements["pm_type"+row].selectedIndex];
for(var j = 0; j < curAr.length; j++){
options[j] = new Option(curAr[j].text, curAr[j].url);
}
options[0].selected = true;
}
function check_type2(form,row,num){
if(!supported3){
load(form,"type_name["+row+"]["+num+"]");
return;
}
var options= form.elements["pm_spares["+row+"]["+num+"]"];
for(var i = options.length - 1;i > 0;i--){
options[i] = null;
}
var curAr0=ar0[form.elements["type_name["+row+"]["+num+"]"].selectedIndex];
for(var j = 0;j<curAr0.length;j++){
options[j] = new Option(curAr0[j].text, curAr0[j].url);
}
options[0].selected=true;
}
/*function check_type2(form,row){
value=document.work_order.elements("pm_name"+row).value;
arr=value.split("/");
if(arr[1]!=undefined){
document.work_order.elements("value"+row).value=arr[1];
document.work_order.elements("discount_per"+row).value=0;
document.work_order.elements("value_net"+row).value=arr[1];
}else{
document.work_order.elements("value"+row).value=0;
document.work_order.elements("discount_per"+row).value=0;
document.work_order.elements("value_net"+row).value=0;
}
sum_total();
}*/
/*function sum_value_net(row){
if(document.work_order.elements("discount_per"+row).value!=""){
value_net=parseFloat(document.work_order.elements("value"+row).value)*parseInt(document.work_order.elements("amount"+row).value);
discount_value=(parseFloat(value_net)*parseFloat(document.work_order.elements("discount_per"+row).value))/100;
document.work_order.elements("discount_value"+row).value=parseFloat(discount_value);
value_net=parseFloat(value_net)-parseFloat(discount_value);
value_net=Math.round(value_net*Math.pow(10,2))/Math.pow(10,2);
document.work_order.elements("value_net"+row).value=parseFloat(value_net);
sum_total();
}else{
alert("กรุณากรอกข้อมูลให้ครบ");
document.work_order.elements("discount_per"+row).focus();
}
}*/
/*function sum_amount(row){
if(document.work_order.elements("amount"+row).value!=""){
value_net=parseInt(document.work_order.elements("amount"+row).value)*parseFloat(document.work_order.elements("value"+row).value);
discount_value=(parseFloat(document.work_order.elements("discount_per"+row).value)*parseFloat(value_net))/100;
document.work_order.elements("discount_value"+row).value=parseFloat(discount_value);
value_net=parseFloat(value_net)-parseFloat(discount_value);
document.work_order.elements("value_net"+row).value=parseFloat(value_net);
sum_total();
}else{
alert("กรุณากรอกข้อมูลให้ครบ");
document.work_order.elements("amount"+row).focus();
}
}*/
function makeoption(text, url){
this.text = text;
this.url = url;
}
/* function check_type3(form,row){
value=document.work_order.elements("promotion_id"+row).value;
arr=value.split("/");
document.work_order.elements("value_promotion"+row).value=arr[1];
document.work_order.elements("discount_per_promotion"+row).value=0;
document.work_order.elements("value_net_promotion"+row).value=arr[1];
sum_value_promotion();
} */
function sum_value_promotion(){
sum=0;
for(i=1;i<=document.work_order.elements.num_row_promotion.value;i++){
if(document.work_order.elements("status_pm_promotion"+i).checked==true){
//sum=parseFloat(sum)+parseFloat(document.work_order.elements("value_net_promotion"+i).value);
sum=parseFloat(sum)+parseFloat(document.work_order.elements("value_promotion"+i).value)*parseFloat(document.work_order.elements("amount_promotion"+i).value);
}
}
//alert(sum);
document.work_order.elements.promotion_value.value=parseFloat(sum);
sum_total();
}
function sum_amount_promotion(row){
if(document.work_order.elements("amount_promotion"+row).value!=""){
value_net=parseInt(document.work_order.elements("amount_promotion"+row).value)*parseFloat(document.work_order.elements("value_promotion"+row).value);
discount_value=(parseFloat(document.work_order.elements("discount_per_promotion"+row).value)*parseFloat(value_net))/100;
document.work_order.elements("discount_value_promotion"+row).value=parseFloat(discount_value);
value_net=parseFloat(value_net)-parseFloat(discount_value);
document.work_order.elements("value_net_promotion"+row).value=parseFloat(value_net);
sum_value_promotion();
}else{
alert("กรุณากรอกข้อมูลให้ครบ");
document.work_order.elements("amount_promotion"+row).focus();
}
}
function sum_value_net_promotion(row){
if(document.work_order.elements("discount_per_promotion"+row).value!=""){
value_net=parseFloat(document.work_order.elements("value_promotion"+row).value)*parseInt(document.work_order.elements("amount_promotion"+row).value);
discount_value=(parseFloat(value_net)*parseFloat(document.work_order.elements("discount_per_promotion"+row).value))/100;
document.work_order.elements("discount_value_promotion"+row).value=parseFloat(discount_value);
value_net=parseFloat(value_net)-parseFloat(discount_value);
value_net=Math.round(value_net*Math.pow(10,2))/Math.pow(10,2);
document.work_order.elements("value_net_promotion"+row).value=parseFloat(value_net);
sum_value_promotion();
}else{
alert("กรุณากรอกข้อมูลให้ครบ");
document.work_order.elements("discount_per_promotion"+row).focus();
}
}
function sum_total(){
//ค่างานซ่อม
sum=0;
for(i=1;i<=document.work_order.elements.num_row.value;i++){
if(document.work_order.elements("status_pm"+i).checked==true){
sum=parseFloat(sum)+parseFloat(document.work_order.elements("value"+i).value)*parseFloat(document.work_order.elements("amount"+i).value);
//sum=parseFloat(sum)+parseFloat(document.work_order.elements("value_net"+i).value);
}
}
document.work_order.part_value.value=parseFloat(sum);
//ยอดเงินรวม
if(document.work_order.elements.service_value.value!=""){
value_after=parseFloat(document.work_order.elements.part_value.value)+parseFloat(document.work_order.elements.service_value.value)+parseFloat(document.work_order.elements.promotion_value.value);
value_after=Math.round(value_after*Math.pow(10,2))/Math.pow(10,2);
document.work_order.elements.value_after.value=parseFloat(value_after);
}else{
alert("กรุณากรอกข้อมูลให้ครบ");
document.work_order.elements.service_value.focus();
}
//ยอดเงินรวมหักลดราคา
discount_value=0;
for(i=1;i<=document.work_order.elements.num_row.value;i++){
if(document.work_order.elements("status_pm"+i).checked==true){
discount_value=parseFloat(discount_value)+parseFloat(document.work_order.elements("discount_value"+i).value);
}
}
for(j=1;j<=document.work_order.elements.num_row_promotion.value;j++){
if(document.work_order.elements("status_pm_promotion"+j).checked==true){
discount_value=parseFloat(discount_value)+parseFloat(document.work_order.elements("discount_value_promotion"+j).value);
}
}
discount_value=Math.round(discount_value*Math.pow(10,2))/Math.pow(10,2);
document.work_order.elements.discount_value_net.value=parseFloat(discount_value);
value_before_discount=parseFloat(document.work_order.elements.value_after.value)-parseFloat(discount_value);
value_before_discount=Math.round(value_before_discount*Math.pow(10,2))/Math.pow(10,2);
document.work_order.elements.value_before_discount.value=value_before_discount;
//ภาษี
vat_rate=7;
vat_value=(parseFloat(document.work_order.elements.value_before_discount.value)*parseInt(vat_rate))/100;
vat_value=Math.round(vat_value*Math.pow(10,2))/Math.pow(10,2);
document.work_order.elements.vat_value.value=parseFloat(vat_value);
//ยอดรวม
value_net=parseFloat(vat_value)+parseFloat(document.work_order.elements.value_before_discount.value);
value_net=Math.round(value_net*Math.pow(10,2))/Math.pow(10,2);
document.work_order.elements.value_net.value=parseFloat(value_net);
}
function numberOfRowtwo3(row){
if(Tempitem[row]){
return (Tempitem[row].rows.length);
}else{
return (-1)
}
}
var supported3=window.Option ? 1 : 0;
if(supported3){
var active;
var i = 0;
var j = 0;
var k = 0;
var text_check;
var ar0 = new Array();
ar0[0] = new Array();
//ar0[i][j] = new makeoption("<?echo '-----โปรดเลือก----';?>","");
text_check="ALL";
<?while($result3=db_fetch_array($query3)){?>
if(k==0){
text_check="ALL";
}
k=1;
if(text_check!=<?echo $result3["level_id"];?>){
i++;
ar0[i] = new Array();
text_check=<?echo $result3["level_id"];?>;
j=0;
ar0[i][j] = new makeoption("<?echo '---โปรดเลือก ---';?>","");
j++;
}
if(text_check==<?echo $result3["level_id"];?>){
<?$select_date="select curdate() as date_now";
$query_date=db_query($select_date);
$result_date=db_fetch_array($query_date);
$date_now=$result_date["date_now"];
$stock_balance="select spares_id,price_sale from inv_spares_price where '$date_now' between date_start and date_end and type_id ='$result3[equip_type_id]' and status='1' ";
$query_stock_balance=db_query($stock_balance);
while($result_stock_balance=db_fetch_array($query_stock_balance)){
$description=search_config_detail_truck($result_stock_balance["spares_id"]);
?>
ar0[i][j] = new makeoption("<?echo $description;?>","<?echo $result_stock_balance['spares_id'].'/'.$result_stock_balance['price_sale'];?>");
j++;
<?}?>
}
<?}?>
}
function addRowitem(form,index,row0,row1,row){
num=numberOfRowtwo3(row);
row0.value=num;
//document.work_order["rowitem0["+row+"]"].value=parseInt(document.work_order["rowitem0["+row+"]"].value)+1;
//num=document.work_order["rowitem0["+row+"]"].value;
var spares_id=new Array();
var spares_description=new Array();
spares_value="";
<?$d=1;
echo "spares_id[0]='';";
echo "spares_description[0]='--- $text ---';";
//$select_date="select curdate() as date_now";
//$query_date=db_query($select_date);
//$result_date=db_fetch_array($query_date);
//$date_now=$result_date["date_now"];
//$select_spares="select spares_id,price_sale from inv_spares_price where '$date_now' between date_start and date_end and status='1' ";
//$query_spares=db_query($select_spares);
//while($result_spares=db_fetch_array($query_spares)){
// $spares_description=search_config_detail_truck($result_spares["spares_id"]);
// echo "spares_id[$d]='".$result_spares["spares_id"]."/".$result_spares["price_sale"]."';";
// echo "spares_description[$d]='".$spares_description."';";
// $d++;
//}
//echo "spares_count=$d;";
?>
spares_spares_strings="<select style='font-famaly:Arail,sans-serif;font-size:8pt;' name='pm_spares["+row+"]["+num+"]' id='pm_spares["+row+"]["+num+"]' onchange='relate(["+row+"],["+num+"])'>";
spares_spares_strings+="<option value='"+spares_id[0]+"' selected>"+spares_description[0]+"</option>";
//for(d=0;d<spares_count;d++){
// if(spares_value==spares_id[d]){
// spares_spares_strings+="<option value='"+spares_id[d]+"' selected>"+spares_description[d]+"</option>";
// }else{
// spares_spares_strings+="<option value='"+spares_id[d]+"'>"+spares_description[d]+"</option>";
// }
//}
spares_spares_strings+="</select>";
var type_code=new Array();
var type_detail=new Array();
type_value="";
<?
$e=1;
echo "type_code[0]='';";
echo "type_detail[0]='--- $text ---';";
$type_array="select distinct(pm_oc_profile_truck_detail.level_id),pm_oc_profile_truck_detail.description,inv_stock.equip_type_id from pm_oc_profile_truck_detail,inv_stock where inv_stock.equip_type_id =pm_oc_profile_truck_detail.level_id order by pm_oc_profile_truck_detail.level_id";
$query_array=db_query($type_array);
while($type_array=db_fetch_array($query_array)){
echo "type_code[$e]='".$type_array["level_id"]."';";
echo "type_detail[$e]='".$type_array["description"]."';";
$e++;
}
echo "type_count=$e;";
?>
type_spares_strings="<select style='font-family:Arial,sans-serif;font-size:8pt;' name='type_name["+row+"]["+num+"]' id='type_name["+row+"]["+num+"]' onchange='check_type2(this.form,"+row+","+num+");'>";
for(e=0;e<type_count;e++){
if(type_value==type_code){
type_spares_strings+="<option value='"+type_code[e]+"' selected>"+type_detail[e]+"</option>";
}else{
type_spares_strings+="<option value='"+type_code[e]+"'>"+type_detail[e]+"</option>";
}
}
type_spares_strings+="</select>";
var unit_id=new Array();
var unit_description=new Array();
unit_value="";
<?$f=1;
echo "unit_id[0]='';";
echo "unit_description[0]='--- $text ---';";
$select_unit="select level_id,description from pm_oc_profile_truck_detail where status='1' and extend_value='527' and parent_level_id!='1' order by level_id ";
$query_unit=db_query($select_unit);
while($result_unit=db_fetch_array($query_unit)){
echo "unit_id[$f]='".$result_unit["level_id"]."';";
echo "unit_description[$f]='".$result_unit["description"]."';";
$f++;
}
echo "unit_count=$f;";
?>
unit_unit_strings="<select style='font-famaly:Arail,sans-serif;font-size:8pt;' name='unit_promotion_id["+row+"]["+num+"]' id='unit_promotion_id["+row+"]["+num+"]'>";
for(f=0;f<unit_count;f++){
if(unit_value==unit_id[f]){
unit_unit_strings+="<option value='"+unit_id[f]+"' selected>"+unit_description[f]+"</option>";
}else{
unit_unit_strings+="<option value='"+unit_id[f]+"'>"+unit_description[f]+"</option>";
}
}
unit_unit_strings+="</select>";
alert(row);
alert(num);
switch(index){
case 0:
Tempitem[row].insertRow ();
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(0).innerHTML="";
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(1).innerHTML=""+row+"."+num+"";
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(2).innerHTML=""+type_spares_strings+"";
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(3).innerHTML=""+spares_spares_strings+"";
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(4).innerHTML="<input type='text' name='amount["+row+"]["+num+"]' size='10' value='1'>";
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(5).innerHTML=""+unit_unit_strings+"";
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(6).innerHTML="<input type='text' name='value["+row+"]["+num+"]' readonly class='txtbox' size='10'>";
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(7).innerHTML="<input type='text' name='discount_per["+row+"]["+num+"]' onkeypress='return is_number();' size='10'>";
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(8).innerHTML="<input type='text' name='value_net["+row+"]["+num+"]' readonly class='txtbox' size='10'>";
Tempitem[row].rows[num].insertCell ();
Tempitem[row].rows[num].cells.item(9).innerHTML="<textarea name='comment["+row+"]["+num+"]'></textarea>";
break;
}
}
function relate(row,num){
value=document.work_order.elements("pm_spares["+row+"]["+num+"]").value;
arr=value.split("/");
document.work_order.elements("value["+row+"]["+num+"]").value=arr[1];
}
</script>
คือผมจะลิส ข้อมูลมาได้ แล้ว
เมื่อกด แอด หัวใหญ่จะได้ลิส แถวที่สี่มา
เมื่อกดเลือก แถวที่สี เพื่อแสดงรายละเอียดย่อยๆ นั้น มันไปมองว่าถูกสร้างขึ้นใน table คนล่ะตัวกันทำให้แสดงออกมาลักษณะดั้งกล่าง
รบกวน ชี้แนะด้วยครับ
Tag : PHP
|
|
|
|
|
|
Date :
2011-03-22 18:36:49 |
By :
nut_ch31 |
View :
914 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เป็นผมทำใส่ grid ไปละครับ
|
|
|
|
|
Date :
2011-03-22 19:59:58 |
By :
SOUL |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือหลักๆ ของโปรแกรมนี้นะ่คัรบ มันจะ สร้าง table ขึ้นมาใน โดยสร้างใน cell0 ทำให้ รายละเอียดที่แอดในแถวที่สี่ตามรูปที่สาม ถูกสร้างใน cell0 ทำให้มันเป็นลักษณะดังกล่าว ในรูปที่สาม คือ ถ้าผมอยากจะสร้าง table ให้แสดงหมด ทั้งแถวเลย คือไม่สนใจ cell อ่าครับ จะทำได้ไหม
บรรทัด ที่ 0807-0810
Temptwo[index].insertRow ();
Temptwo[index].rows[row+1].insertCell ();
Temptwo[index].rows[row+1].style.backgroundColor="#99FF66";
Temptwo[index].rows[row+1].cells.item(0).innerHTML="<table name='attach_tbl["+num+"]' id='attach_tbl"+num+"' width='100%'><tr><td>ลำดับ</td>";
ผมอยากให้ table ถูกสร้างไปยังถึง cell สุดท้ายเรยอ่า ถ้าทำได้ผมก็น่าจะต่อได้แล้ว
|
|
|
|
|
Date :
2011-03-22 20:28:35 |
By :
nut_ch31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|