001.
<?php
include
'header.php'
; ?>
002.
<?
if
(
empty
(
$_SESSION
[
'user_id'
])) {
003.
echo
"<meta http-equiv='refresh' content='0;url=index.php'/>"
;
004.
exit
();
005.
}
006.
$ID
=
$_REQUEST
[id];
007.
$user_dep
=
$_SESSION
[user_dep_id];
008.
if
(
$ID
==
''
){?>
009.
<h2>คณะกรรมการบริหารความเสี่ยง</h2>
010.
<? }?>
011.
<H1><small>รายงานความเสี่ยงทั้งหมด</small></H1>
012.
<ol
class
=
"breadcrumb"
>
013.
<li><a href=
"index.php"
><i
class
=
"fa fa-home"
></i> หน้าหลัก</a></li>
014.
<li
class
=
"active"
><i
class
=
"fa fa-envelope"
></i> รายงานความเสี่ยงทั้งหมด</li>
015.
</ol>
016.
<form role=
"search"
action=
'session_search.php'
method=
'post'
>
017.
<div
class
=
"form-group input-group"
>
018.
<input type=
'search'
name=
'take_detail'
placeholder=
'ค้นหาความเสี่ยง...'
value=
''
class
=
"form-control"
>
019.
<input type=
'hidden'
name=
'method'
value=
'take_detail5'
>
020.
<span
class
=
"input-group-btn"
>
021.
<button
class
=
"btn btn-default"
type=
"submit"
><i
class
=
"fa fa-search"
></i></button>
022.
</span>
023.
</div>
024.
</form>
025.
<div
class
=
"row"
>
026.
<div
class
=
"col-lg-12"
>
027.
<div
class
=
"panel panel-primary"
>
028.
<div
class
=
"panel-heading"
>
029.
<h3
class
=
"panel-title"
><i
class
=
"fa fa-star"
></i> รายงานความเสี่ยงทั้งหมด</h3>
030.
</div>
031.
032.
<div
class
=
"panel-body"
>
033.
<?php
034.
035.
036.
function
page_navigator(
$before_p
,
$plus_p
,
$total
,
$total_p
,
$chk_page
){
037.
global
$e_page
;
038.
global
$querystr
;
039.
040.
$ID
=
$_REQUEST
[id];
041.
$urlfile
=
"Recurrence_risk.php"
;
042.
$per_page
=10;
043.
$num_per_page
=
floor
(
$chk_page
/
$per_page
);
044.
$total_end_p
=(
$num_per_page
+1)*
$per_page
;
045.
$total_start_p
=
$total_end_p
-
$per_page
;
046.
$pPrev
=
$chk_page
-1;
047.
$pPrev
=(
$pPrev
>=0)?
$pPrev
:0;
048.
$pNext
=
$chk_page
+1;
049.
$pNext
=(
$pNext
>=
$total_p
)?
$total_p
-1:
$pNext
;
050.
$lt_page
=
$total_p
-4;
051.
if
(
$chk_page
>0){?>
052.
<a href=
"<?=$urlfile?>?s_page=<?=$pPrev.$querystr?>&&id=<?=$ID;?>"
class
=
"naviPN"
>Prev</a>
053.
<?}
054.
for
(
$i
=
$total_start_p
;
$i
<
$total_end_p
;
$i
++){
055.
$nClass
=(
$chk_page
==
$i
)?
"class='selectPage'"
:
""
;
056.
if
(
$e_page
*
$i
<=
$total
){?>
057.
<a href=
"<?=$urlfile;?>?s_page=<?=$i.$querystr;?>&&id=<?=$ID;?>"
<?=
$nClass
;?> ><?=
intval
(
$i
+1);?></a>
058.
<?}
059.
}
060.
if
(
$chk_page
<
$total_p
-1){?>
061.
<a href=
"<?=$urlfile?>?s_page=<?=$pNext.$querystr?>&&id=<?$ID;?>"
class
=
"naviPN"
>Next</a>
062.
<?}
063.
}
064.
if
(
$ID
==
''
){
065.
if
(
$_SESSION
[take_detail] !=
''
) {
066.
$Search
= trim(
$_SESSION
[take_detail]);
067.
echo
"แสดงคำที่ค้นหา : "
.
$Search
;
068.
069.
$q
= "select
count
(t1.takerisk_id)
as
num_risk, s1.name
as
sub_name, c1.name
as
cate_name, t1.recycle from takerisk t1
070.
inner join subcategory s1 on t1.subcategory=s1.subcategory
071.
inner join category c1 on t1.category=c1.category
072.
where (t1.recycle=
'N'
and
t1.subcategory=s1.subcategory)
and
s1.name like
'%$Search%'
and
t1.subcategory !=
''
073.
order by num_risk desc";
074.
}
else
{
075.
$q
= "select
count
(t1.takerisk_id)
as
num_risk, s1.name
as
sub_name, c1.name
as
cate_name, t1.recycle from takerisk t1
076.
inner join subcategory s1 on t1.subcategory=s1.subcategory
077.
inner join category c1 on t1.category=c1.category
078.
where t1.recycle=
'N'
and
t1.subcategory=s1.subcategory
and
t1.subcategory !=
''
079.
group by sub_name order by num_risk desc";
080.
}
081.
}
elseif
(
$ID
==
'1'
){
082.
if
(
$_SESSION
[take_detail] !=
''
) {
083.
$Search
= trim(
$_SESSION
[take_detail]);
084.
echo
"แสดงคำที่ค้นหา : "
.
$Search
;
085.
086.
$q
= "select
count
(t1.takerisk_id)
as
num_risk, s1.name
as
sub_name, c1.name
as
cate_name, t1.recycle from takerisk t1
087.
inner join subcategory s1 on t1.subcategory=s1.subcategory
088.
inner join category c1 on t1.category=c1.category
089.
where (t1.recycle=
'N'
and
t1.subcategory=s1.subcategory)
and
s1.name like
'%$Search%'
and
t1.subcategory !=
''
090.
and
t1.res_dep=
$user_dep
order by num_risk desc";
091.
}
else
{
092.
$q
= "select
count
(t1.takerisk_id)
as
num_risk, s1.name
as
sub_name, c1.name
as
cate_name, t1.recycle from takerisk t1
093.
inner join subcategory s1 on t1.subcategory=s1.subcategory
094.
inner join category c1 on t1.category=c1.category
095.
where t1.recycle=
'N'
and
t1.subcategory=s1.subcategory
and
t1.subcategory !=
''
and
t1.res_dep=
$user_dep
096.
group by sub_name order by num_risk desc";
097.
}
098.
}
099.
$qr
=mysql_query(
$q
);
100.
if
(
$qr
==
''
){
exit
();}
101.
$total
=mysql_num_rows(
$qr
);
102.
103.
$e_page
=10;
104.
if
(!isset(
$_GET
[
's_page'
])){
105.
$_GET
[
's_page'
]=0;
106.
}
else
{
107.
$chk_page
=
$_GET
[
's_page'
];
108.
$_GET
[
's_page'
]=
$_GET
[
's_page'
]*
$e_page
;
109.
}
110.
$q
.=
" LIMIT "
.
$_GET
[
's_page'
].
",$e_page"
;
111.
$qr
=mysql_query(
$q
);
112.
if
(mysql_num_rows(
$qr
)>=1){
113.
$plus_p
=(
$chk_page
*
$e_page
)+mysql_num_rows(
$qr
);
114.
}
else
{
115.
$plus_p
=(
$chk_page
*
$e_page
);
116.
}
117.
$total_p
=
ceil
(
$total
/
$e_page
);
118.
$before_p
=(
$chk_page
*
$e_page
)+1;
119.
echo
mysql_error();
120.
?>
121.
122.
<div
class
=
"table-responsive"
>
123.
<a
class
=
"btn btn-success"
download=
"recurrence_risk.xls"
href=
"#"
onClick=
"return ExcellentExport.excel(this, 'datatable', 'Sheet Name Here');"
>Export to Excel</a><br><br>
124.
125.
<table id=
"datatable"
class
=
"table table-bordered table-hover table-striped tablesorter"
>
126.
<TR>
127.
<th width=
'5%'
rowspan=
"3"
align=
"center"
valign=
"middle"
><CENTER><p>ลำดับ <i
class
=
"fa fa-sort"
></i></p></CENTER></th>
128.
<th width=
'50%'
rowspan=
"3"
align=
"center"
valign=
"middle"
><CENTER><p>รายการ <i
class
=
"fa fa-sort"
></i></p></CENTER></th>
129.
<th width=
'25%'
rowspan=
"3"
align=
"center"
valign=
"middle"
><CENTER><p>ด้าน <i
class
=
"fa fa-sort"
></i></p></CENTER></th>
130.
<th colspan=
"15"
><CENTER><p>ระดับความรุนแรง(จำนวนครั้ง)<i
class
=
"fa fa-sort"
></i></p></CENTER></th>
131.
</TR>
132.
<TR>
133.
<th colspan=
"9"
><center>ทางคลินิก(A-I)</center> <center>
134.
</center></th>
135.
<th colspan=
"5"
><center>ทั่วไป(1-5)</center></th>
136.
<th rowspan=
"2"
><center>รวมทั้งหมด</center></th>
137.
</TR>
138.
<TR>
139.
<th align=
"center"
>A</th>
140.
<th align=
"center"
>B</th>
141.
<th align=
"center"
>C</th>
142.
<th align=
"center"
>D</th>
143.
<th align=
"center"
>E</th>
144.
<th align=
"center"
>F</th>
145.
<th align=
"center"
>G</th>
146.
<th align=
"center"
>H</th>
147.
<th align=
"center"
>I</th>
148.
<th align=
"center"
>1</th>
149.
<th align=
"center"
>2</th>
150.
<th align=
"center"
>3</th>
151.
<th align=
"center"
>4</th>
152.
<th align=
"center"
>5</th>
153.
</TR>
154.
<?
155.
$i
= 1;
156.
while
(
$total_risk
= mysql_fetch_assoc(
$qr
)) {
157.
if
(
$bg
==
"#F4F4F4"
) {
158.
$bg
=
"#FFFFFF"
;
159.
}
else
{
160.
$bg
=
"#F4F4F4"
;
161.
} ?>
162.
<?
163.
<tr>
164.
<td><center><?= (
$chk_page
*
$e_page
) +
$i
?></center></td>
165.
<td><?=
$total_risk
[sub_name]; ?></td>
166.
<td><center><?=
$total_risk
[cate_name]; ?></center></td>
167.
<td> </td>
168.
<td> </td>
169.
<td> </td>
170.
<td> </td>
171.
<td> </td>
172.
<td> </td>
173.
<td> </td>
174.
<td> </td>
175.
<td> </td>
176.
<td> </td>
177.
<td> </td>
178.
<td> </td>
179.
<td> </td>
180.
<td> </td>
181.
<td align=
"center"
><?=
$total_risk
[num_risk]; ?></td>
182.
</tr>
183.
184.
<?
185.
$i
++;
186.
}
187.
?>
188.
189.
</table>
190.
</div>
191.
</div>
192.
</div>
193.
<?php
194.
if
(
$total
> 0) {
195.
echo
mysql_error();
196.
?>
197.
<div
class
=
"browse_page"
>
198.
199.
<?php
200.
201.
page_navigator(
$before_p
,
$plus_p
,
$total
,
$total_p
,
$chk_page
);
202.
203.
echo
" <font size='2'>มีจำนวนทั้งหมด <B>$total รายการ</B> จำนวนหน้าทั้งหมด "
;
204.
echo
$count
=
ceil
(
$total
/ 10) .
" <B>หน้า</B></font>"
;
205.
}
206.
?>
207.
</div>
208.
209.
<?php
include
'footer.php'
; ?>