<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
include("include/time_inc.php");
$officer=$_SESSION['login_user_id'];
$sql="select * from person_position order by position_code";
$dbquery=mysqli_query($connect,$sql);
While ($result=mysqli_fetch_array($dbquery)){
$position_ar[$result['position_code']]=$result['position_name'];
}
$sql="select * from system_workgroup order by workgroup_order";
$dbquery=mysqli_query($connect,$sql);
while ($result=mysqli_fetch_array($dbquery)){
$department_ar[$result['workgroup']]=$result['workgroup_desc'];
}
$sql="select * from person_sch_position order by position_code";
$dbquery=mysqli_query($connect,$sql);
While ($result=mysqli_fetch_array($dbquery)){
$position_sch_ar[$result['position_code']]=$result['position_name'];
}
$sql="select * from system_school order by school_code";
$dbquery=mysqli_query($connect,$sql);
while ($result=mysqli_fetch_array($dbquery)){
$school_ar[$result['school_code']]=$result['school_name'];
}
echo "<br />";
if(!(($index==1) or ($index==5))){
$year_thai=$_REQUEST['year']+543;
echo "<table width='50%' border='0' align='center'>";
echo "<tr align='center'><td><font color='#006666' size='3'><strong>ข้อมูลบุคลากรเกษียณอายุราชการ ปี ".$year_thai."</td></tr>";
echo "</table>";
}
//ส่วนการแสดงผล
$index="";
echo "<form id='frm1' name='frm1'>";
echo "<table width='95%' align='center' border=0><tr>";
echo "<td>";
echo "</td><td align='right'>";
echo "เลือกปี เกษียณอายุราชการ ";
echo "<select name=\"retire_year\" onChange=location.href='?option=person&task=retire_report&year='+this.options[this.selectedIndex].value;>";
$sql="select * from person_detail group by end_day";
$dbquery=mysqli_query($connect,$sql);
while ($result=mysqli_fetch_array($dbquery)){
$retire_year=substr($result['end_day'],0,4);
$retire_year_thai=$retire_year+543;
if($_REQUEST['year']==""){
echo "<option value=$retire_year>ปี $retire_year_thai</option>";
}else{
if($_REQUEST['year']==$retire_year){
echo "<option value=$retire_year selected>ปี $retire_year_thai</option>";
}else{
echo "<option value=$retire_year>ปี $retire_year_thai</option>";
}
}
}
echo "</select>";
echo "</td></tr></table>";
echo "<table width='95%' align='center' class=myTableSky>";
echo "<th width='70'>ที่</th><th>ชื่อ</th><th>ตำแหน่ง</th><th>หน่วยงาน</th><th width='120'>รายละเอียดบุคคล</th>";
//บุคลากรในสำนักงาน
$sql="SELECT * FROM person_detail, person_main WHERE person_detail.person_id=person_main.person_id AND YEAR(person_detail.end_day)='$_REQUEST[year]' AND person_main.status='0' ORDER BY person_main.department, person_main.position_code ";
$dbquery=mysqli_query($connect,$sql);
$num_row=mysqli_num_rows($dbquery);
$N=1;
if($num_row!='0'){
while ($result=mysqli_fetch_array($dbquery)){
$id=$result['id'];
$person_id=$result['person_id'];
$prename=$result['prename'];
$name= $result['name'];
$surname=$result['surname'];
$position_code= $result['position_code'];
$department= $result['department'];
echo "<Tr><Td align=center>$N</Td><Td align='left'>$prename $name $surname</Td><Td align='center'>";
if(isset($position_ar[$position_code])){
echo $position_ar[$position_code];
}
echo "</Td><Td align='center'>";
if(isset($department_ar[$department])){
echo $department_ar[$department];
}
echo "</Td>";
//ค้นหาว่ามีการสร้างข้อมูลหรือยัง
$sql_detail="select * from person_detail where person_id='$person_id' ";
$dbquery_detail=mysqli_query($connect,$sql_detail);
$num=mysqli_num_rows($dbquery_detail);
if($num==0){
//ส่วนของรายละเอียด
echo "<Td align='center'> </Td>";
}else{
//ส่วนของรายละเอียด
echo "<Td align='center'><a href='modules/person/person_detail.php?person_id=$person_id' class='dialogify'><img src=images/my-icons/list.png width=28 border='0' title='รายละเอียด ข้อมูลบุคคล'></a></Td>";
}
echo "</Tr>";
$N++;
}
}else{
echo "<tr><td colspan=5 align=center>ไม่มีข้อมูล - บุคลากรในสำนักงาน</td></tr>";
}
//บุคลากรในสถานศึกษา
$sql="SELECT * FROM person_detail, person_sch_main WHERE person_detail.person_id=person_sch_main.person_id AND YEAR(person_detail.end_day)='$_REQUEST[year]' AND person_sch_main.status='0' ORDER BY person_sch_main.school_code, person_sch_main.position_code ";
$dbquery=mysqli_query($connect,$sql);
$num_row_sch=mysqli_num_rows($dbquery);
if($num_row_sch!='0'){
While ($result=mysqli_fetch_array($dbquery)){
$id=$result['id'];
$person_id=$result['person_id'];
$prename=$result['prename'];
$name= $result['name'];
$surname=$result['surname'];
$position_sch_code= $result['position_code'];
$school_code= $result['school_code'];
$person_order= $result['person_order'];
echo "<Tr><Td align=center>$N</Td><Td align='left'>$prename $name $surname</Td><Td align='center'>";
if(isset($position_sch_ar[$position_code])){
echo $position_sch_ar[$position_code];
}
echo "</Td>";
echo "<Td align='center'>";
if(isset($school_ar[$school_code])){
echo $school_ar[$school_code];
}
// ส่วนบุคลากรขยาย ปฎิบัติงานในโรงเรียนรอง
$sql_other="select system_school.school_name from person_sch_other left join system_school on person_sch_other.school_code=system_school.school_code where person_id='$result[person_id]' ";
$dbquery_other=mysqli_query($connect,$sql_other);
$num_other=mysqli_num_rows($dbquery_other);
if($num_other!=0){
echo " <font color=#008000>และ</font><div align=left><font color=red><ol>";
while($result_other=mysqli_fetch_array($dbquery_other)){
echo "<li>".$result_other[school_name]."</li>";
}
echo "</font></ol></div>";
}
echo "</Td>";
//ค้นหาว่ามีการสร้างข้อมูลหรือยัง
$sql_detail="select * from person_detail where person_id='$person_id' ";
$dbquery_detail=mysqli_query($connect,$sql_detail);
$num=mysqli_num_rows($dbquery_detail);
if($num==0){
//ส่วนของรายละเอียด
echo "<Td align='center'> </Td>";
}else{
//ส่วนของรายละเอียด
echo "<Td align='center'><a href='modules/person/person_detail_sch.php?person_id=$person_id' class='dialogify'><img src=images/my-icons/list.png width=28 border='0' title='รายละเอียด ข้อมูลบุคคล'></a></Td>";
}
echo "</Tr>";
$N++;
}
}else{
echo "<tr><td colspan=5 align=center>ไม่มีข้อมูล - บุคลากรในสถานศึกษา</td></tr>";
}
echo "</Table>";
echo "<br><br><br>";
?>
<script type="text/javascript" src="css/scrolltop/scrolltopcontrol.js"></script>
<link rel="stylesheet" href="./jquery/themes/ui-lightness/jquery.ui.all.css">
<script src="./jquery/jquery-1.5.1.js"></script>
<script src="./jquery/external/jquery.bgiframe-2.1.2.js"></script>
<script src="./jquery/ui/jquery.ui.core.js"></script>
<script src="./jquery/ui/jquery.ui.widget.js"></script>
<script src="./jquery/ui/jquery.ui.mouse.js"></script>
<script src="./jquery/ui/jquery.ui.draggable.js"></script>
<script src="./jquery/ui/jquery.ui.position.js"></script>
<script src="./jquery/ui/jquery.ui.resizable.js"></script>
<script src="./jquery/ui/jquery.ui.dialog.js"></script>
<script type="text/javascript">
/*
* jQuery UI Dialog: Load Content via AJAX
* http://salman-w.blogspot.com/2013/05/jquery-ui-dialog-examples.html
*/
jQuery.noConflict();
jQuery(function() {
jQuery("#dialog").dialog({
height: 580,
width: 650,
minHeight: 580,
minWidth: 650,
autoOpen: false,
show: "blind",
hide: "explode",
modal: true,
resizable: false,
});
jQuery(".dialogify").click(function(e) {
e.preventDefault();
jQuery("#dialog").html("");
jQuery("#dialog").dialog("option", "title", "Loading...").dialog("open");
jQuery("#dialog").load(this.href, function() {
jQuery(this).dialog("option", "title", "ข้อมูลบุคลากร");
//jQuery(this).dialog("option", "title", jQuery(this).find("h1").text());
//jQuery(this).find("h1").remove();
});
});
});
</script>
<div id="dialog"></div>