01.
<?php
02.
header(
"Content-type:application/json; charset=UTF-8"
);
03.
header(
"Cache-Control: no-store, no-cache, must-revalidate"
);
04.
header(
"Cache-Control: post-check=0, pre-check=0"
, false);
05.
include
(
"db_connect.php"
);
06.
$mysqli
= connect();
07.
08.
09.
10.
11.
12.
$q
=
"SELECT * FROM calendar_sciencelab WHERE date(start)>='"
.
$_GET
['start
']."'
";
13.
$q
.=
" AND date(end)<='"
.
$_GET
['
end
']."'
AND code_equipment=
'$id'
ORDER by id";
14.
15.
$result
=
$mysqli
->query(
$q
);
16.
17.
while
(
$rs
=
$result
->fetch_object()){
18.
19.
switch
(
$rs
->status) {
20.
case
"new"
:
$color
=
"#FF0000"
;
break
;
21.
case
"yes"
:
$color
=
"#009900"
;
break
;
22.
case
"ไม่สามารถดำเนินการได้"
:
$color
=
"#999999"
;
break
;
23.
default
:
$color
=
"#FF9900"
;
break
;
24.
}
25.
26.
27.
28.
$json_data
[]=
array
(
29.
"id"
=>
$rs
->id,
30.
"title"
=>
$rs
->type.
","
.
$rs
->name.
","
.
$rs
->locate,
31.
"start"
=>
$rs
->start,
32.
"end"
=>
$rs
->
end
,
33.
"url"
=>
"detail.php?id="
.
$rs
->id,
34.
"color"
=>
$color
,
35.
36.
37.
38.
);
39.
40.
}
41.
42.
$json
= json_encode(
$json_data
);
43.
44.
if
(isset(
$_GET
[
'callback'
]) &&
$_GET
[
'callback'
]!=
""
){
45.
echo
$_GET
[
'callback'
].
"("
.
$json
.
");"
;
46.
}
else
{
47.
echo
$json
;
48.
}
49.
?>