001.
<?php
002.
@session_start();
003.
004.
005.
006.
007.
008.
009.
if
(
$_SESSION
[
'user'
] ==
'admin'
)
010.
{
011.
include
(
"header01.php"
);
012.
}
013.
else
014.
{
015.
include
(
"header02.php"
);
016.
}
017.
018.
$part1
=
array
(0,5,6,8,9,10,15,16,18);
019.
$part2
=
array
(0,20,21,22,23);
020.
$part3
=
array
(0,25,28,29,30,31);
021.
$part4
=
array
(0,33,34,35,36,38,39,40);
022.
$part5
=
array
(0,42,44,45,46,47);
023.
$part6
=
array
(0,49);
024.
025.
$status
=
''
;
026.
027.
028.
$garfield
=
$_POST
[
'garfield'
];
029.
echo
$_FILES
[
"file"
][
"type"
];
030.
if
(isset(
$_POST
[
'$garfield'
])){
031.
032.
if
(
$_FILES
[
"file"
][
"type"
] ==
"application/vnd.ms-excel"
)
033.
{
034.
if
(
$_FILES
[
"file"
][
"error"
] > 0)
035.
{
036.
echo
"Return Code: "
.
$_FILES
[
"file"
][
"error"
] .
"<br>"
;
037.
}
038.
else
039.
{
040.
$status
=
"Upload: "
.
$_FILES
[
"file"
][
"name"
] .
"<br>"
;
041.
042.
$status
.=
"Size: "
. (
$_FILES
[
"file"
][
"size"
] / 1024) .
" KB<br><br>"
;
043.
044.
045.
046.
require_once
'../exceltest/reader.php'
;
047.
048.
049.
$data
=
new
Spreadsheet_Excel_Reader();
050.
051.
052.
$data
->setOutputEncoding(
'tis620'
);
053.
054.
$data
->read(
$_FILES
[
"file"
][
"tmp_name"
]);
055.
056.
error_reporting
(E_ALL ^ E_NOTICE);
057.
058.
echo
'</br>'
;
059.
060.
include
(
"../mysqlconnect.php"
);
061.
062.
063.
064.
065.
066.
$dup
= 0;
067.
$upl
= 0;
068.
069.
070.
for
(
$i
=3;
$data
->sheets[1][
'cells'
][
$i
][1] !=
''
;
$i
++)
071.
{
072.
073.
$stringSQL
=
"Insert into kubota_1747 "
;
074.
$stringSQL
.=
"(id, id_no, id_center, no_center, name_center, no_reference, no_store, name_store, customer_name, tel, age_car ,date_sent, time_sent, between_time, sex, data_detail,type, int_date, count, result, person, person_submit, week) "
;
075.
$stringSQL
.=
"values "
;
076.
$stringSQL
.=
"('"
.
$data
->sheets[1]['cells
'][$i][1] . "'
,
'" . $data->sheets[1]['
cells
'][$i][2] . "'
";
077.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][3] . "'
,
'" . $data->sheets[1]['
cells
'][$i][4] . "'
";
078.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][5] . "'
,
'" . $data->sheets[1]['
cells
'][$i][6] . "'
";
079.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][7] . "'
,
'" . $data->sheets[1]['
cells
'][$i][8] . "'
";
080.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][9] . "'
,
'" . $data->sheets[1]['
cells
'][$i][10] . "'
";
081.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][11] . "'
,
'" . $data->sheets[1]['
cells
'][$i][12] . "'
";
082.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][13] . "'
,
'" . $data->sheets[1]['
cells
'][$i][14] . "'
";
083.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][15] . "'
,
'" . $data->sheets[1]['
cells
'][$i][16] . "'
";
084.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][17] . "'
,
'" . $data->sheets[1]['
cells
'][$i][18] . "'
";
085.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][19] . "'
,
'" . $data->sheets[1]['
cells
'][$i][20] . "'
";
086.
$stringSQL
.=
",'"
.
$data
->sheets[1]['cells
'][$i][21] . "'
,
'" . $data->sheets[1]['
cells
'][$i][22] . "'
)";
087.
$result
= mysql_query(
$stringSQL
,
$conn
)
or
die
(mysql_error());
088.
$status
.=
'<font color=\'green\'>Uploaded.</font> -- > '
.
$data
->sheets[1][
'cells'
][
$i
][1] .
' - '
.
$data
->sheets[1][
'cells'
][
$i
][22] .
'<br>'
;
089.
$upl
++;
090.
}
091.
092.
mysql_close;
093.
094.
$status
.=
'<br>'
.
'<font color=\'green\'>Upload Process: Finish.</font>'
.
'<br>'
;
095.
$status
.=
'Uploaded: '
.
$upl
.
'<br>'
;
096.
$status
.=
'Duplicated: '
.
$dup
.
'<br>'
;
097.
}
098.
}
099.
else
100.
{
101.
$status
=
"<font color='red'>Status: Invalid file</font>"
;
102.
}
103.
}
104.
105.
?>
106.
<form action=
"upload1747.php"
method=
"post"
enctype=
"multipart/form-data"
>
107.
<table border=
"0"
cellpadding=
"0"
cellspacing=
"0"
width=
"1000"
>
108.
<tr>
109.
<td background=
"../images/body-head.jpg"
height=
"30"
> </td>
110.
</tr>
111.
<tr>
112.
<td background=
"../images/body-body.jpg"
height=
"300"
align=
"center"
>
113.
<table border=
"1"
cellpadding=
"0"
cellspacing=
"0"
width=
"900"
bordercolor=
"#C0C0C0"
style=
"border-width: 0px"
>
114.
<tr>
115.
<td width=
"224"
align=
"center"
style=
"border-style: none; border-width: medium"
>
116.
<a href=
"../upload1512.php"
style=
"text-decoration: none"
><img border=
"0"
src=
"../images/content32.png"
width=
"32"
height=
"32"
></a></td>
117.
<td width=
"224"
align=
"center"
style=
"border-style: none; border-width: medium"
>
118.
<a href=
"../uploadkaj.php"
style=
"text-decoration: none"
><img border=
"0"
src=
"../images/content32.png"
width=
"32"
height=
"32"
></a></td>
119.
<td width=
"225"
align=
"center"
style=
"border-style: none; border-width: medium"
>
120.
<a href=
"importdata1747.php"
><img border=
"0"
src=
"../images/content32.png"
width=
"32"
height=
"32"
></a></td>
121.
<td width=
"225"
align=
"center"
style=
"border-style: none; border-width: medium"
>
122.
<img border=
"0"
src=
"../images/content32.png"
width=
"32"
height=
"32"
></td>
123.
</tr>
124.
<tr>
125.
<td width=
"224"
align=
"center"
style=
"border-style: none; border-width: medium"
>
126.
<b><font size=
"2"
>โครงการ 1-5-12</font></b></td>
127.
<td width=
"224"
align=
"center"
style=
"border-style: none; border-width: medium"
>
128.
<b><font size=
"2"
>โครงการคุ้มอุ่นใจ</font></b></td>
129.
<td width=
"225"
align=
"center"
style=
"border-style: none; border-width: medium"
>
130.
<b><font size=
"2"
>โครงการ 1747</font></b></td>
131.
<td width=
"225"
align=
"center"
style=
"border-style: none; border-width: medium"
> </td>
132.
</tr>
133.
</table>
134.
135.
<p> </p>
136.
<p> </p>
137.
<p><b><font size=
"5"
>Upload File : รายชื่อโครงการ 1747</font></b></p>
138.
<table border=
"0"
cellpadding=
"0"
cellspacing=
"0"
width=
"510"
>
139.
<tr>
140.
<td height=
"30"
align=
"right"
> </td>
141.
</tr>
142.
<tr>
143.
<td height=
"30"
align=
"right"
>
144.
<p align=
"center"
>File : <input type=
"file"
name=
"file"
size=
"60"
></td>
145.
</tr>
146.
<tr>
147.
<td height=
"30"
align=
"right"
><input type=
"submit"
value=
" Submit "
name=
"B1"
style=
"float: right"
><input type=
"hidden"
name=
"garfield"
value=
"garfield"
></td>
148.
</tr>
149.
<tr>
150.
<td height=
"30"
align=
"left"
> </td>
151.
</tr>
152.
<tr>
153.
<td height=
"30"
align=
"left"
><font size=
"2"
><?
echo
$status
;?></font></td>
154.
</tr>
155.
</table>
156.
</td>
157.
</tr>
158.
<tr>
159.
<td background=
"../images/body-foot.jpg"
height=
"30"
> </td>
160.
</tr>
161.
</table>
162.
</form>
163.
164.
<?
165.
include
(
"footer01.php"
);
166.
?>