$sid=$_GET['sid'];
$code=$_GET['code'];
date_default_timezone_set('Asia/Bangkok');
require_once("../amssplus_connect.php");	
mysqli_query($connect,"SET NAMES utf-8");
header('Content-Type: text/html; charset=tis-620');
$sql="select *,a.id as uid from person_sch_main a,system_school b,person_sch_position c 
	where 	a.school_code=b.school_code and a.position_code=c.position_code 
	and b.id='$sid' order by a.position_code";
$result0=mysqli_query($connect,$sql);
$db0=mysqli_fetch_array($result0); 
$nper=mysqli_num_rows($result0);
$sc=$db0[school_name];
$result=mysqli_query($connect,$sql);
$ubox='';
$ubox.="
ชื่อผู้ใช้งาน รร.$sc
	
	| ที่ | ชื่อ-สกุล | ตำแหน่ง";
$rw=1;
while ($db=mysqli_fetch_array($result)) {
	$uid=$db[uid];
	$ubox.=" | 
		| $rw | $db[name] $db[surname] | $db[position_name] | 
";
	$rw++;
}
if ($nper==0) { $new="[ เพิ่มชื่อผู้ใช้ ]"; 
} else { $new=''; }
$ubox.="
$new";
$sql="select *,a.id as uid from system_user a,person_sch_main b,system_school c 
	where 	a.person_id=b.person_id and b.school_code=c.school_code and c.id='$sid' 
	order by b.school_code";
$result=mysqli_query($connect,$sql);
$rbox.="ลงทะเบียนแล้วในระบบ AMSS++ 
	
	| ที่ | ชื่อ-สกุล | เจ้าหน้าที่";
$rw=1;
while ($db=mysqli_fetch_array($result)) {
	$scgrp=$db[school_group];
	$result3=mysqli_query($connect,"select person_id  from book_permission 
	where person_id='$db[person_id]' ");
	if ($db3=mysqli_fetch_array($result3)) { $bk='สารบรรณ รร.';	} else { $bk='-'; }
	$rbox.=" | 
		| $rw | $db[name] $db[surname] | $bk | 
";
	$rw++;
}
$rbox.="
";
echo "
	[ กลับหน้าเดิม ] | 
	[ ลงทะเบียนใช้งาน AMSS++ ]
	
	";
mysqli_close($connect);
?>