01.
<?
02.
session_start();
03.
include
"../include/config.inc.php"
;
04.
include
"../include/function.inc.php"
;
05.
06.
if
(
$action
==
"DamageManage"
){
07.
$Sq
=
"DELETE FROM caraccident WHERE JobID = '"
+
$JobID
+
"' "
;
08.
mysql_query(
$Sq
);
09.
$Sq
=
"OPTIMIZE TABLE caraccident"
;
10.
mysql_query(
$Sq
);
11.
for
(
$n
= 0;
$n
<
$NumDETAIL
;
$n
++){
12.
$s
=
"SELECT ID FROM caraccident ORDER BY ID DESC;"
;
13.
$r
= mysql_query(
$s
);
14.
$w
= mysql_fetch_array(
$r
);
15.
$cID
=
$w
[
'ID'
] + 1;
16.
17.
if
(
$DetailID
[
$n
] !=
""
){
18.
if
(
$DetailLeft
[
$n
] !=
"Y"
){
19.
$DetailLeft
[
$n
] =
"N"
;
20.
}
21.
if
(
$DetailRight
[
$n
] !=
"Y"
){
22.
$DetailRight
[
$n
] =
"N"
;
23.
}
24.
if
(
$DetailL
[
$n
] !=
"Y"
){
25.
$DetailL
[
$n
] =
"N"
;
26.
}
27.
if
(
$DetailM
[
$n
] !=
"Y"
){
28.
$DetailM
[
$n
] =
"N"
;
29.
}
30.
if
(
$DetailN
[
$n
] !=
"Y"
){
31.
$DetailN
[
$n
] =
"N"
;
32.
}
33.
if
(
$DetailH
[
$n
] !=
"Y"
){
34.
$DetailH
[
$n
] =
"N"
;
35.
}
36.
if
(
$DetailO
[
$n
] !=
"Y"
){
37.
$DetailO
[
$n
] =
"N"
;
38.
}
39.
if
(
$DetailX
[
$n
] !=
"Y"
){
40.
$DetailX
[
$n
] =
"N"
;
41.
}
42.
$Sq
=
"INSERT INTO caraccident (ID , JobID , DetailID , DetailName , DetailLeft , DetailRight , DetailL , DetailM , DetailN , DetailH , DetailO , DetailX) VALUES ('"
+
$cID
+
"' , '"
+
$JobID
+
"' , '"
+
$DetailID
[
$n
] +
"' , '"
+
$DetailName
[
$n
] +
"' , '"
+
$DetailLeft
[
$n
] +
"' , '"
+
$DetailRight
[
$n
] +
"' , '"
+
$DetailL
[
$n
] +
"' , '"
+
$DetailM
[
$n
] +
"' , '"
+
$DetailN
[
$n
] +
"' , '"
+
$DetailH
[
$n
] +
"' , '"
+
$DetailO
[
$n
] +
"' , '"
+
$DetailX
[
$n
] +
"');"
;
43.
mysql_query(
$Sq
);
44.
45.
46.
}
47.
}
48.
49.
$Sq
=
"UPDATE joborder SET TotalAmount = '"
.
$TotalAmount
.
"' , Driver = '"
.
$Driver
.
"' , Age = '"
.
$Age
.
"' , Occupation = '"
.
$Occupation
."' ,
50.
Relation =
'".$Relation."'
, Address =
'".addslashes($Address)."'
, Tel =
'".$Tel."'
, DrivingType =
'".$DrivingType."'
, DrivingLiense =
'".$DrivingLiense."'
,
51.
DrivingPlace =
'".$DrivingPlace."'
, DrivingStartDate =
'".convertdate_YYYYMMDD($DrivingStartDate)."'
,
52.
DrivingExprieDate =
'".convertdate_YYYYMMDD($DrivingExprieDate)."'
,
53.
Address2 =
'".addslashes($Address2)."'
, IdentityNumber =
'".$IdentityNumber."'
, IdentityPlace =
'".$IdentityPlace."'
,
54.
BrithDay =
'".convertdate_YYYYMMDD($BrithDay)."'
, CarriageBy =
'".$CarriageBy."'
, Cradle =
'".$Cradle."'
, Damage =
'".$Damage."'
55.
WHERE JobID =
'".$JobID."'
";
56.
mysql_query(
$Sq
);
57.
}
58.
?>