001.
<?php
require_once
(
'Connections/tast.php'
); ?>
002.
<?php
003.
if
(!function_exists(
"GetSQLValueString"
)) {
004.
function
GetSQLValueString(
$theValue
,
$theType
,
$theDefinedValue
=
""
,
$theNotDefinedValue
=
""
)
005.
{
006.
if
(PHP_VERSION < 6) {
007.
$theValue
= get_magic_quotes_gpc() ?
stripslashes
(
$theValue
) :
$theValue
;
008.
}
009.
010.
$theValue
= function_exists(
"mysql_real_escape_string"
) ? mysql_real_escape_string(
$theValue
) : mysql_escape_string(
$theValue
);
011.
012.
switch
(
$theType
) {
013.
case
"text"
:
014.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
015.
break
;
016.
case
"long"
:
017.
case
"int"
:
018.
$theValue
= (
$theValue
!=
""
) ?
intval
(
$theValue
) :
"NULL"
;
019.
break
;
020.
case
"double"
:
021.
$theValue
= (
$theValue
!=
""
) ? doubleval(
$theValue
) :
"NULL"
;
022.
break
;
023.
case
"date"
:
024.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
025.
break
;
026.
case
"defined"
:
027.
$theValue
= (
$theValue
!=
""
) ?
$theDefinedValue
:
$theNotDefinedValue
;
028.
break
;
029.
}
030.
return
$theValue
;
031.
}
032.
}
033.
034.
$editFormAction
=
$_SERVER
[
'PHP_SELF'
];
035.
if
(isset(
$_SERVER
[
'QUERY_STRING'
])) {
036.
$editFormAction
.=
"?"
. htmlentities(
$_SERVER
[
'QUERY_STRING'
]);
037.
}
038.
039.
if
((isset(
$_POST
[
"MM_insert"
])) && (
$_POST
[
"MM_insert"
] ==
"form_report_ploblem"
)) {
040.
$insertSQL
= sprintf(
"INSERT INTO repair (Machinetype,Problem,Station,Timestamp) VALUES (%s, %s)"
,
041.
GetSQLValueString(
$_POST
[
'Machinetype'
],
"text"
),
042.
GetSQLValueString(
$_POST
[
'Problem'
],
"text"
),
043.
GetSQLValueString(
$_POST
[
'Station'
],
"text"
),
044.
GetSQLValueString(
$_POST
[
'hiddenField'
],
"date"
));
045.
046.
mysql_select_db(
$database_tast
,
$tast
);
047.
$Result1
= mysql_query(
$insertSQL
,
$tast
)
or
die
(mysql_error());
048.
}
049.
050.
mysql_select_db(
$database_tast
,
$tast
);
051.
$query_Recordset1
=
"SELECT * FROM repair"
;
052.
$Recordset1
= mysql_query(
$query_Recordset1
,
$tast
)
or
die
(mysql_error());
053.
$row_Recordset1
= mysql_fetch_assoc(
$Recordset1
);
054.
$totalRows_Recordset1
= mysql_num_rows(
$Recordset1
);
055.
?>
056.
<html>
057.
<head>
058.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
059.
<title>แจ้งซ่อมออนไลน์</title>
060.
</head>
061.
<body>
062.
063.
<form action=
"<?php echo $editFormAction; ?>"
name=
"form_report_ploblem"
method=
"POST"
>
064.
065.
066.
<table border=
"1"
width=
"56%"
>
067.
<tr>
068.
<td colspan=
"2"
><center><h1>แจ้งซ่อมออนไลน์</h1></center></td>
069.
</tr>
070.
<tr>
071.
<td width=
"106"
valign=
"top"
>
072.
<center>
073.
<label
for
=
"textfield"
></label>
074.
<?php
075.
$handle
= @
fopen
(
"../Problem/Machine_items.txt"
,
"r"
);
076.
$mac_type
=
""
;
077.
if
(
$handle
) {
078.
$num_row
=0;
079.
while
((
$buffer
=
fgets
(
$handle
, 4096)) !== false) {
080.
$num_row
++;
081.
if
(
substr
(trim(
$buffer
),0,1)!=
"#"
&&
$num_row
>=2){
082.
083.
$mac_data
=
explode
(
","
,
$buffer
);
084.
if
(
$mac_type
!=
$mac_data
[0]){
085.
$mac_type
=
$mac_data
[0];
086.
echo
"<h3><a href='?tap=1&Machinetype="
.
$mac_data
[0].
"'>"
.
$mac_data
[0].
'</a></h3>'
;
087.
088.
089.
090.
}
091.
}
092.
}
093.
if
(!
feof
(
$handle
)) {
094.
echo
"Error: unexpected fgets() fail\n"
;
095.
}
096.
fclose(
$handle
);
097.
}
098.
?>
099.
</center></td>
100.
<td width=
"167"
valign=
"top"
>
101.
<p>
102.
103.
<?php
104.
if
(
$_GET
[
'Machinetype'
]!=
""
){
105.
106.
$handle
= @
fopen
(
"../Problem/Machine_items.txt"
,
"r"
);
107.
$mac_type
=
""
;
108.
if
(
$handle
) {
109.
while
((
$buffer
=
fgets
(
$handle
, 4096)) !== false) {
110.
if
(
substr
(trim(
$buffer
),0,1)!=
"#"
){
111.
112.
$mac_data
=
explode
(
","
,
$buffer
);
113.
114.
if
(urldecode(trim(
$_GET
[
'Machinetype'
]))==urldecode(trim(
$mac_data
[0]))){
115.
116.
echo
'
117.
<h3><input type=
"radio"
name=
"Problem"
id=
"radio"
value=
"'.$mac_data[1].'"
style=
"float:left;"
/>';
118.
echo
$mac_data
[1].
'</h3>'
;
119.
120.
121.
}
122.
}
123.
124.
}
125.
if
(!
feof
(
$handle
)) {
126.
127.
echo
"Error: unexpected fgets() fail\n"
;
128.
}
129.
fclose(
$handle
);
130.
}
131.
echo
' <p>
132.
133.
134.
135.
<input type=
"submit"
name=
"button"
id=
"button"
value=
"sent"
/>
136.
<input type=
"reset"
name=
"button2"
id=
"button2"
value=
"cancal"
>
137.
</p>';
138.
}
139.
140.
?>
141.
</p>
142.
<p>
143.
<input type=
"hidden"
name=
"hiddenField"
id=
"hiddenField"
>
144.
<input name=
"Station"
type=
"hidden"
value=
"555"
>
145.
</p></td>
146.
</tr>
147.
</table>
148.
<input type=
"hidden"
name=
"MM_insert"
value=
"form_report_ploblem"
>
149.
</form>
150.
151.
</body>
152.
</html>
153.
<?php
154.
mysql_free_result(
$Recordset1
);
155.
?>