003.
<head>
004.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
005.
<script type=
"text/javascript"
src=
"../jQueryui/jQuery.js"
></script>
006.
<script type=
"text/javascript"
src=
"../jQueryui/jQuery-ui.js"
></script>
007.
008.
</head>
009.
010.
<form action=
"insertData.php"
method=
"post"
name=
"adminForm"
id=
"adminForm"
>
011.
<table
class
=
"adminlist"
>
012.
<thead>
013.
<tr>
014.
<th ><div
class
=
"titleleft"
> เพิ่มรายการซ่อม </div>
015.
<div
class
=
"titleright"
> <a href=
"#"
onclick=
"document.adminForm.task.value=''; document.adminForm.submit();"
>
016.
<div id=
"icon"
>
017.
<div
class
=
"icon-32-cancel"
></div>
018.
<div
class
=
"title"
>ยกเลิก</div>
019.
</div>
020.
</a> <a href=
"#"
onclick=
"save();"
>
021.
<div id=
"icon"
>
022.
<div
class
=
"icons-32-save"
></div>
023.
<div
class
=
"title"
>บันทึก</div>
024.
</div>
025.
</a> </div></th>
026.
</tr>
027.
</thead>
028.
</table>
029.
<fieldset
class
=
"adminform"
>
030.
<legend>ข้อมูลเบื้องต้น</legend>
031.
</fieldset>
032.
033.
034.
035.
<fieldset
class
=
"adminform"
>
036.
<legend>รายละเอียดการซ่อม</legend>
037.
038.
<table
class
=
"adminlist"
>
039.
<thead>
040.
<tr>
041.
<th width=
"90"
>วันที่</th>
042.
<th width=
"61"
>รหัส</th>
043.
<th width=
"87"
>เลขใบเสร็จ</th>
044.
<th width=
"87"
>รหัสอะไหล่</th>
045.
<th width=
"157"
>รายละเอียดการซ่อม</th>
046.
<th width=
"37"
>จำนวน</th>
047.
<th width=
"47"
>หน่วยละ</th>
048.
<th width=
"47"
>ลด</th>
049.
<th width=
"47"
>ยอดรวม</th>
050.
<th width=
"87"
>ผู้ตรวจรับรถ</th>
051.
<th width=
"87"
>สถานที่เข้าซ่อม</th>
052.
<th></th>
053.
</tr>
054.
</thead>
055.
<tbody id=
"repairlist"
>
056.
<tr>
057.
<td colspan=
"12"
>ยังไม่มีรายการใหม่ เพิ่มรายการใหม่ด้านล่าง</td>
058.
</tr>
059.
</tbody>
060.
<tr>
061.
<th width=
"90"
>วันที่</th>
062.
<th width=
"61"
>รหัส</th>
063.
<th width=
"87"
>เลขใบเสร็จ</th>
064.
<th width=
"87"
>รหัสอะไหล่</th>
065.
<th width=
"157"
>รายละเอียดการซ่อม</th>
066.
<th width=
"37"
>จำนวน</th>
067.
<th width=
"47"
>หน่วยละ</th>
068.
<th width=
"47"
>ลด</th>
069.
<th width=
"47"
>ยอดรวม</th>
070.
<th width=
"87"
>ผู้ตรวจรับรถ</th>
071.
<th width=
"87"
>สถานที่เข้าซ่อม</th>
072.
<th></th>
073.
</tr>
074.
<tr>
075.
<td><input type=
"text"
name=
"date_repair"
id=
"datepicker"
value=
""
class
=
"inputbox"
size=
"25"
maxlength=
"19"
style=
"width:65px !important;"
/>
076.
<img src=
"../image/calendar.png"
width=
"16"
height=
"16"
alt=
"logo"
longdesc=
"calendar.png"
/></td>
077.
<td><select name=
"rid"
id=
"rid"
style=
"width:60px !important;"
class
=
"inputbox"
size=
"1"
><option value=
"0"
selected=
"selected"
>R-ID</option><option value=
"7"
>เครื่องยนต์</option><option value=
"8"
>ห้องเครื่อง</option><option value=
"9"
>ระบบแอร์</option><option value=
"10"
>ระบบไฟฟ้า</option><option value=
"11"
>เบรค-ยาง-ล้อ</option><option value=
"12"
>ช่วงล่าง</option><option value=
"13"
>เกียร์เ-ฟืองท้าย</option><option value=
"14"
>ภายใน</option><option value=
"16"
>อุปกรณ์</option><option value=
"17"
>ความสะอาด</option><option value=
"18"
>เช็คระยะ-ระบบ</option><option value=
"19"
>เคลม Warranty</option><option value=
"20"
>เคลมประกันทำสีรถ</option></select></td>
078.
<td><input
class
=
"text_area"
type=
"text"
name=
"repair_number"
id=
"repair_number"
size=
"32"
maxlength=
"250"
style=
"width:80px !important;"
/></td>
079.
<td><input
class
=
"text_area"
type=
"text"
name=
"part_number"
id=
"part_number"
size=
"32"
maxlength=
"250"
style=
"width:80px !important;"
/></td>
080.
<td><input
class
=
"text_area"
type=
"text"
name=
"repair_detail"
id=
"repair_detail"
size=
"32"
maxlength=
"250"
style=
"width:150px !important;"
/></td>
081.
<td><input
class
=
"text_area"
type=
"text"
name=
"amount"
id=
"amount"
size=
"32"
maxlength=
"250"
style=
"width:30px !important;"
/></td>
082.
<td><input
class
=
"text_area"
type=
"text"
name=
"price_perunit"
id=
"price_perunit"
size=
"32"
maxlength=
"250"
style=
"width:40px !important;"
/></td>
083.
<td><input
class
=
"text_area"
type=
"text"
name=
"price_discount"
id=
"price_discount"
size=
"32"
maxlength=
"250"
style=
"width:40px !important;"
onchange=
"caldiscount();"
/></td>
084.
<td><input
class
=
"text_area"
type=
"text"
name=
"price_total"
id=
"price_total"
size=
"32"
maxlength=
"250"
style=
"width:40px !important;"
/></td>
085.
<td><input
class
=
"text_area"
type=
"text"
name=
"recive_by"
id=
"recive_by"
size=
"32"
maxlength=
"250"
style=
"width:80px !important;"
/></td>
086.
<td><input
class
=
"text_area"
type=
"text"
name=
"repair_at"
id=
"repair_at"
size=
"32"
maxlength=
"250"
style=
"width:80px !important;"
/></td>
087.
<td></td>
088.
</tr>
089.
<tr>
090.
<th >เลขไมล์</th>
091.
<td ><input
class
=
"text_area"
type=
"text"
name=
"mile"
id=
"mile"
size=
"32"
maxlength=
"10"
style=
"width:50px !important;"
/></td>
092.
<th >หมายเหตุ</th>
093.
<td colspan=
"6"
><input
class
=
"text_area"
type=
"text"
name=
"repair_remark"
id=
"repair_remark"
size=
"32"
maxlength=
"250"
style=
"width:450px !important;"
/></td>
094.
<td colspan=
"3"
><input name=
""
type=
"button"
value=
"เพิ่มลงในรายการ"
onclick=
"addlist();"
/></td>
095.
</tr>
096.
</table>
097.
</fieldset>
098.
<fieldset
class
=
"adminform"
>
099.
<table width=
"100%"
border=
"0"
cellspacing=
"1"
cellpadding=
"0"
>
100.
101.
</table>
102.
103.
</fieldset>
104.
<input type=
"hidden"
name=
"Itemid"
value=
"35"
/>
105.
<input type=
"hidden"
name=
"option"
value=
"com_car"
/>
106.
<input type=
"hidden"
name=
"task"
value=
""
/>
107.
<input type=
"hidden"
name=
"step"
value=
"1"
/>
108.
<input type=
"hidden"
name=
"c777fc3101862d44330268006e1e1480"
value=
"1"
/> <input type=
"hidden"
name=
"view"
value=
"repairadd"
/>
109.
</form>
110.
<script language=
"javascript"
>
111.
var
indexlist = 0;
112.
function
caldiscount(){
113.
var
form = document.getElementById(
'adminForm'
);
114.
var
check = true;
115.
var
value =form.price_discount.value;
116.
var
perc = false;
117.
118.
for
(
var
i=0;i <value.length; ++i)
119.
{
120.
var
new_key = value.charAt(i);
121.
if
(((new_key <
"0"
) || (new_key >
"9"
)) &&
122.
!(new_key ==
""
))
123.
{
124.
if
(new_key !=
"%"
){
125.
check = false;
126.
break
;
127.
}
else
{
128.
perc = true;
129.
}
130.
}
131.
}
132.
if
(!check){
133.
alert(
"ตัวเลขเท่านั้น เช่น 300 หรือ 10%"
);
134.
form.price_discount.value =
""
;
135.
form.price_discount.focus();
136.
137.
138.
}
else
{
139.
if
(perc){
140.
value = value.
substr
(0,value.length-1);
141.
value = parseInt(value,10);
142.
value = (parseInt(form.price_perunit.value,10)*parseInt(form.amount.value,10))*(value/100);
143.
}
144.
form.price_total.value = (parseInt(form.price_perunit.value,10)*parseInt(form.amount.value,10))-value;
145.
}
146.
}
147.
function
addlist(){
148.
var
form = document.getElementById(
'adminForm'
);
149.
if
(form.rid.selectedIndex == 0){
150.
alert(
"เลือกรหัสการซ่อม"
);
151.
}
else
{
152.
var
tr = document.getElementById(
'repairlist'
);
153.
154.
var
rcount = tr.rows.length;
155.
if
(rcount == 1){
156.
tr.deleteRow(0);
157.
}
158.
159.
160.
rcount = tr.rows.length;
161.
var
row = tr.insertRow(rcount);
162.
row.setAttribute(
"id"
,
"rows"
+indexlist);
163.
var
cell1 = row.insertCell(0);
164.
cell1.innerHTML = form.date_repair.value;
165.
var
cell1 = row.insertCell(1);
166.
cell1.innerHTML = form.rid[form.rid.selectedIndex].text;
167.
var
cell1 = row.insertCell(2);
168.
cell1.innerHTML = form.repair_number.value;
169.
var
cell1 = row.insertCell(3);
170.
cell1.innerHTML = form.part_number.value;
171.
var
cell1 = row.insertCell(4);
172.
cell1.innerHTML = form.repair_detail.value;
173.
var
cell1 = row.insertCell(5);
174.
cell1.innerHTML = form.amount.value;
175.
var
cell1 = row.insertCell(6);
176.
cell1.innerHTML = form.price_perunit.value;
177.
var
cell1 = row.insertCell(7);
178.
cell1.innerHTML = form.price_discount.value;
179.
var
cell1 = row.insertCell(8);
180.
cell1.innerHTML = form.price_total.value;
181.
var
cell1 = row.insertCell(9);
182.
cell1.innerHTML = form.recive_by.value;
183.
var
cell1 = row.insertCell(10);
184.
cell1.innerHTML = form.repair_at.value;
185.
var
cell1 = row.insertCell(11);
186.
187.
innervalue =
""
;
188.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][date_repair]" value="'
+form.date_repair.value+
'" />'
;
189.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][rid]" value="'
+form.rid[form.rid.selectedIndex].value+
'" />'
;
190.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][repair_number]" value="'
+form.repair_number.value+
'" />'
;
191.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][part_number]" value="'
+form.part_number.value+
'" />'
;
192.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][repair_detail]" value="'
+form.repair_detail.value+
'" />'
;
193.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][amount]" value="'
+form.amount.value+
'" />'
;
194.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][price_perunit]" value="'
+form.price_perunit.value+
'" />'
;
195.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][price_discount]" value="'
+form.price_discount.value+
'" />'
;
196.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][price_total]" value="'
+form.price_total.value+
'" />'
;
197.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][recive_by]" value="'
+form.recive_by.value+
'" />'
;
198.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][repair_at]" value="'
+form.repair_at.value+
'" />'
;
199.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][repair_remark]" value="'
+form.repair_remark.value+
'" />'
;
200.
innervalue +=
'<input type="hidden" name="repairlist['
+indexlist+
'][mile]" value="'
+form.mile.value+
'" />'
;
201.
innervalue +=
'<input name="" type="button" value="ลบ" onclick="removeRows(\''
+"rows
"+indexlist+'\');"
/>';
202.
cell1.innerHTML = innervalue;
203.
cell1.setAttribute(
"rowSpan"
,2);
204.
205.
rcount = tr.rows.length;
206.
row = tr.insertRow(rcount);
207.
cell1 = row.insertCell(0);
208.
cell1.innerHTML =
"เลขไมล์"
;
209.
cell1 = row.insertCell(1);
210.
cell1.innerHTML = form.mile.value;
211.
cell1 = row.insertCell(2);
212.
cell1.innerHTML =
"หมายเหตุ"
;
213.
cell1 = row.insertCell(3);
214.
cell1.innerHTML = form.repair_remark.value;
215.
cell1.setAttribute(
"colSpan"
,8);
216.
217.
indexlist++;
218.
219.
form.rid.selectedIndex=0;
220.
form.part_number.value=
""
;
221.
form.repair_detail.value=
""
;
222.
form.amount.value=
""
;
223.
form.price_perunit.value=
""
;
224.
form.price_discount.value=
""
;
225.
form.price_total.value=
""
;
226.
form.recive_by.value=
""
;
227.
form.repair_at.value=
""
;
228.
form.repair_remark.value=
""
;
229.
}
230.
}
231.
function
removeRows(rowid){
232.
var
tr = document.getElementById(
'repairlist'
);
233.
for
(
var
i=0;i<tr.rows.length;i++){
234.
if
(tr.rows[i].id == rowid){
235.
tr.deleteRow(i);
236.
tr.deleteRow(i);
237.
break
;
238.
}
239.
}
240.
241.
}
242.
function
gencarlist(id){
243.
if
(id.selectedIndex > 0){
244.
var
selectid = id[id.selectedIndex].value;
245.
var
carlist =
new
Array();
246.
var
carlicense = document.getElementById(
'carlicense'
);
247.
248.
var
oplength = carlicense.options.length;
249.
250.
while
(oplength){
251.
oplength = carlicense.options.length;
252.
for
(i=0;i<=oplength;i++){
253.
carlicense.options[i] = null;
254.
}
255.
}
256.
carlicense.options[0] =
new
Option(
'select car'
,
'0'
);
257.
for
(i=1;i<=carlist[selectid].length;i+=2){
258.
carlicense.options[(i+1)/2] =
new
Option(carlist[selectid][i],carlist[selectid][i-1]);
259.
}
260.
}
261.
}
262.
function
save(){
263.
document.adminForm.step.value=
'3'
;
264.
document.adminForm.submit();
265.
}
266.
</script>
267.
</div>
268.
269.
</body>
270.
<script type=
"text/javascript"
>
271.
$(
function
(){
272.
$(
"#datepicker"
).datepicker({ dateFormat:
"yy-mm-dd"
}).val(
'<? $date = date("Y-m-d");echo $date?>'
)
273.
274.
});
275.
</script></html>
276.
<link href=
"../jQueryui/jQuery-ui.css"
rel=
"stylesheet"
type=
"text/css"
/>