Path : /var/www/html/smart_kpp2_v2/modules/person/
File Upload :
Current File : /var/www/html/smart_kpp2_v2/modules/person/person_report1_mobile.php

<?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'];
}
echo "<br />";
if(!(($index==1) or ($index==5))){
	echo "<center>";
	echo "<font color='#006666'><strong>ข้อมูลบุคลากรในสำนักงานเขตพื้นที่การศึกษา</strong><br>
		</font>เรียงลำดับตามรหัสกลุ่ม/ตำแหน่ง";
	echo "</center><br>";
}

//ส่วนการแสดงผล
$index="";
echo "<form id='frm1' name='frm1'>";
echo "<table width='95%' align='center' border=0><tr>";
echo "<td>";
echo "</td><td align='right'>";
echo "<select name=\"department\" onChange=location.href='?option=person&task=person_report1_mobile&workgroup='+this.options[this.selectedIndex].value;>";
echo "<option value=''>ทุกคน</option>";
$sql="select * from system_workgroup order by id";
$dbquery=mysqli_query($connect,$sql);
while ($result=mysqli_fetch_array($dbquery)){
	if($_REQUEST['workgroup']==""){
		echo "<option value=$result[workgroup]>$result[workgroup_desc]</option>"; 
	}else{
		if($_REQUEST['workgroup']==$result['workgroup']){
			echo "<option value=$result[workgroup] selected>$result[workgroup_desc]</option>"; 
		}else{
			echo "<option value=$result[workgroup]>$result[workgroup_desc]</option>"; 
		}
	}
}
echo "</select>";
echo "</td></tr></table>";

if( $_REQUEST['workgroup'] == "" ){
	$sql="select * from person_main where status='0' order by department,position_code,person_order";
}else{
	$sql="select * from person_main where department='$_REQUEST[workgroup]' and status='0' order by department,position_code,person_order";
}
$dbquery=mysqli_query($connect,$sql);

echo  "<table width='95%' align='center' class=myTableSky>";
echo "<th>ชื่อ</th><th>รายละเอียด</th>";
$N=1;
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='left'>$prename&nbsp;$name&nbsp;&nbsp;$surname <br>";
	if(isset($position_ar[$position_code])){		
		echo $position_ar[$position_code];
	}
	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'>&nbsp;</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++;
}
echo "</Table>";
echo "<br />";

//ส่วนรายงานสรุป
	echo "<center>";
	echo "<font color='#006666'><strong>สรุปสารสนเทศจำนนวนบุคลากร - จำแหนกประเภท</strong></font>";

	echo  "<table width='95%' align='center' class='myTableOrange'>";
	echo "<th>ตำแหน่ง</th><th width='80'>จำนวน</th>";
	$person_num=0;
	$sql="select * from person_position order by position_code";
	$dbquery=mysqli_query($connect,$sql);
	while ($result=mysqli_fetch_array($dbquery)){
		$id=$result['id'];
		$position_code= $result['position_code'];
		$position_name= $result['position_name'];
		//หาจำนวนคนในตำแหน่ง
		if( $workgroup != '' ){
			$sql_sum="select count(id) as member_num from person_main where department='$workgroup' and status='0' and position_code='$position_code'";
		}else{
			$sql_sum="select count(id) as member_num from person_main where status='0' and position_code='$position_code'";
		}
		$dbquery_sum=mysqli_query($connect,$sql_sum);
		$result_sum=mysqli_fetch_array($dbquery_sum);
		$person_num=$person_num+$result_sum['member_num'];
		if($result_sum[member_num] > 0){
			echo "<Tr><Td align=left>$position_name</Td><Td align=center>$result_sum[member_num]</Td></Tr>";
		}
	}
	echo "<Tr><Td align=center><strong>รวม</strong></Td><Td align=center><strong>$person_num</strong></Td></Tr>";
	echo "</Table>";

	//ประเภทเพศ - การศึกษา
	echo "<table class='myTableGreen' width=95% align='center'>";
	echo "<th>เพศ</th><th width='80'>จำนวน</th>";
	if( $workgroup != '' ){
		$sql="select count(*) as man from person_main, person_detail where person_main.person_id=person_detail.person_id AND person_main.status='0' AND person_detail.sex='1' AND person_main.department='$workgroup'";
	}else{
		$sql="select count(*) as man from person_main, person_detail where person_main.person_id=person_detail.person_id AND person_main.status='0' AND person_detail.sex='1' ";
	}
	$dbquery=mysqli_query($connect,$sql);
	$result_man=mysqli_fetch_array($dbquery);
	echo "<tr><td>ชาย</td><td align=center>".$result_man['man']."</td></tr>";
	if( $workgroup != '' ){
		$sql="select count(*) as women from person_main, person_detail where person_main.person_id=person_detail.person_id AND person_main.status='0' AND person_detail.sex='2' AND person_main.department='$workgroup'";
	}else{
		$sql="select count(*) as women from person_main, person_detail where person_main.person_id=person_detail.person_id AND person_main.status='0' AND person_detail.sex='2' ";
	}
	$dbquery=mysqli_query($connect,$sql);
	$result_women=mysqli_fetch_array($dbquery);
	echo "<tr><td>หญิง</td><td align=center>".$result_women['women']."</td></tr>";
	$total_sex=$result_man['man']+$result_women['women'];
	echo "<tr><td align=center><strong>รวม</strong></td><td align=center><strong>".$total_sex."</strong></td></tr>";

	echo "<th>ระดับการศึกษา</th><th width='80'>จำนวน</th>";
	$sql="select * from person_education_class";
	$dbquery=mysqli_query($connect,$sql);
	$education_class_num='0';
	while($result=mysqli_fetch_array($dbquery)){
		$education_class=$result['code'];
		if( $workgroup != '' ){
			$sql_count="select count(*) as education_class from person_main, person_detail where person_main.person_id=person_detail.person_id AND person_main.status='0' AND person_detail.education_class='$education_class' AND person_main.department='$workgroup'";
		}else{
			$sql_count="select count(*) as education_class from person_main, person_detail where person_main.person_id=person_detail.person_id AND person_main.status='0' AND person_detail.education_class='$education_class' ";
		}
		$dbquery_count=mysqli_query($connect,$sql_count);
		$result_education_class=mysqli_fetch_array($dbquery_count);
		echo "<tr><td>".$result['name']."</td><td align=center>".$result_education_class['education_class']."</td></tr>";
		$education_class_num=$education_class_num+$result_education_class['education_class'];
	}
	echo "<tr><td align=center><strong>รวม</strong></td><td align=center><strong>".$education_class_num."</strong></td></tr>";
	echo "</table>";

	//ประเภทวิทยฐานะ
	echo "<table class='myTableBlue' width=95%>";
	echo "<th>วิทยะฐานะ</th><th width='80'>จำนวน</th>";
	$sql="select * from person_position_class";
	$dbquery=mysqli_query($connect,$sql);
	$position_class_num='0';
	while($result=mysqli_fetch_array($dbquery)){
		$position_class=$result['code'];
		if( $workgroup != '' ){
			$sql_count="select count(*) as position_class from person_main, person_detail where person_main.person_id=person_detail.person_id AND person_main.status='0' AND person_detail.position_class='$position_class' AND person_main.department='$workgroup'";
		}else{
			$sql_count="select count(*) as position_class from person_main, person_detail where person_main.person_id=person_detail.person_id AND person_main.status='0' AND person_detail.position_class='$position_class' ";
		}
		$dbquery_count=mysqli_query($connect,$sql_count);
		$result_position_class=mysqli_fetch_array($dbquery_count);
		echo "<tr><td>".$result['name']."</td><td align=center>".$result_position_class['position_class']."</td></tr>";
		$position_class_num=$position_class_num+$result_position_class['position_class'];
	}
	echo "<tr><td align=center><strong>รวม</strong></td><td align=center><strong>".$position_class_num."</strong></td></tr>";
	echo "</table>";
echo "<br><br>";
echo "</center>";
?>
<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: 400,
			width: 320,
			minHeight: 400,
			minWidth: 320,
			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>