<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
if(!(($_SESSION['admin_person']=="person") or ($_SESSION['login_status']<=4 and $result_permission['p1']==3) )){
exit();
}
include("include/time_inc.php");
$officer=$_SESSION['login_user_id'];
$directory='modules/person/upload_files/bonus/'; //ที่เก็บไไฟล์
if (substr($directory,-1)!="/" && $directory!=""){
$directory.="/";
}
$file_array=array();
$dir = @opendir($directory);
$i=0;
while($file = readdir($dir))
{
if($file!=".." && $file!="." && $file!="Thumbs.db" && $file!="index.html")
{
$file_array[$i]=$file;
$i++;
}
}
rsort($file_array);
function getSize($fileSize){
// อ่านขนาดของไฟล์
if ( $fileSize >= 1073741824 ){
$size = round( $fileSize/1024/1024/1024 , 3 )." Gb" ;
}elseif ( $fileSize >= 1048576 ){
$size = round( $fileSize/1024/1024 , 3 )." Mb" ;
}elseif ( $fileSize >= 1024 ){
$size = round( $fileSize/1024 , 3 )." Kb" ;
}else{
$size = $fileSize." bytes" ;
}
return $size;
}
//ส่วนเพิ่มข้อมูล
if( isset($_FILES['userfile']) ){
file_upload();
}
//ฟังชั่นupload
function file_upload() {
echo "<center>";
$uploaddir = 'modules/person/upload_files/bonus/'; //ที่เก็บไไฟล์
$uploadfile = $uploaddir.basename($_FILES['userfile']['name']);
$basename = basename($_FILES['userfile']['name']);
$strlen_userfile=strlen($_FILES['userfile']['name'])-4;
if(substr($basename,-3)=="txt" or substr($basename,-3)=="TXT"){
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
echo "<img src='images/sleep.gif' border=0><br>
<b><font color=#6A6A6A>ร ะ บ บ ส่ ง ไ ฟ ล์ </font>".$_FILES['userfile']['name']." เสร็จเรียบร้อยแล้ว น ะ ค่ ะ</font>";
echo "<meta http-equiv=refresh content=1;URL=?option=person&task=bonus>";
}else{
echo "<img src='images/sleep.gif' border=0><br>
<br>".$_FILES['userfile']['name']." <font color=red>โปรดอ่านคำอธิบายอีกครั้ง</font>";
}
echo "</center>";
echo "<br>";
}
//ส่วนลบข้อมูล
if($index==2){
@unlink($_GET[delfile]);
echo "<meta http-equiv=refresh content=0;URL=?option=person&task=bonus>";
}
//ส่วนการแสดงผล
if( !($index==9) ){
echo "<form Enctype=multipart/form-data method='post' name='frm1'>";
echo "<br>";
echo "<Center>";
echo "<font color='#006666' size='3'><strong>นำเข้าไฟล์ แจ้งผลการเลื่อนเงินเดือน</strong></font>";
echo "<br><br>";
echo "<Table Border='0' class='myTableForm'>";
echo "<tr align='left'>";
echo "<Td ></Td><td align='right'>ไฟล์ </td>";
echo "<td align='left'><input name='userfile' type='file'></td>";
echo "</tr>";
echo "<tr><td></td><td></td><td>";
echo "<input type='hidden' value='$school_code'>";
echo "<INPUT TYPE='submit' value=' ส่งไฟล์ ' class='myButton'>";
echo "</td></tr>";
echo "</Table>";
//แสดงไฟล์ที่ Upload ไว้
echo "<br>";
echo "<table width=80% class='myTableSky' align='center'>"
."<th align=center><b>ชื่อไฟล์ ( ขนาด )</b></th>"
."<th align=center><b>ชื่อไฟล์ ( ขนาด )</b></th>"
."<th align=center><b>ชื่อไฟล์ ( ขนาด )</b></th>"
."<th align=center><b>ชื่อไฟล์ ( ขนาด )</b></th>";
echo "<tr>";
for($i=0; $i<sizeof($file_array); $i++)
{
if($i%4==0){
echo "<td valign=top width='25%'> <font color=#8080FF>";
echo "<a href='$directory$file_array[$i]' target='_blank'>$file_array[$i]</a> (".getSize(filesize($directory.$file_array[$i])).")";
$file=$directory.$file_array[$i];
echo "</font> -<a href='?option=person&task=bonus&index=2&delfile=$file' onClick='return Conf(this)'>ลบ</a></td>";
}else if($i%4==1){
echo "<td valign=top width='25%'> <font color=#8080FF>";
echo "<a href='$directory$file_array[$i]' target='_blank'>$file_array[$i]</a> (".getSize(filesize($directory.$file_array[$i])).")";
$file=$directory.$file_array[$i];
echo "</font> -<a href='?option=person&task=bonus&index=2&delfile=$file' onClick='return Conf(this)'>ลบ</a></td>";
}else if($i%4==2){
echo "<td valign=top width='25%'> <font color=#8080FF>";
echo "<a href='$directory$file_array[$i]' target='_blank'>$file_array[$i]</a> (".getSize(filesize($directory.$file_array[$i])).")";
$file=$directory.$file_array[$i];
echo "</font> -<a href='?option=person&task=bonus&index=2&delfile=$file' onClick='return Conf(this)'>ลบ</a></td>";
}else if($i%4==3){
echo "<td valign=top width='25%'> <font color=#8080FF>";
echo "<a href='$directory$file_array[$i]' target='_blank'>$file_array[$i]</a> (".getSize(filesize($directory.$file_array[$i])).")";
$file=$directory.$file_array[$i];
echo "</font> -<a href='?option=person&task=bonus&index=2&delfile=$file' onClick='return Conf(this)'>ลบ</a></td>";
echo "</tr>";
}
}
echo "</table>";
echo "<hr size='1' width=70%>";
echo "<table width=70% border=0 align=center>";
echo "<Tr><Td align='left'><font size=3><strong>คำอธิบาย</strong></font></Td></Tr>";
echo "<Tr><Td align='left'>1. ข้อมูลที่จะนำเข้าเป็นไฟล์ประเภท TEXT ซึ่งได้จากการแปลงไฟล์ EXCEL (SAVE AS = รูปแบบ Tab delimited และ Endcoding=utf-8)</Td></Tr>";
echo "<Tr><Td align='left'><font color=red><strong>***</font> ตั้งชื่อไฟล์เป็น ปี พศ-ครั้งที่ <font color=red><strong>ตัวอย่าง</strong></font> ไฟล์ปี 2562 เลื่อนครั้งที่ 1 ตั้งชื่อเป็น <font color=red><strong>2562-1.txt</strong></font> / ไฟล์ปี 2562 เลื่อนครั้งที่ 2 ตั้งชื่อเป็น <font color=red><strong>2562-2.txt</strong></font></Td></Tr>";
echo "<Tr><Td align='left'>2. ไฟล์ที่จะนำเข้าต้องมีหัวสดมภ์ ในแถว(ROW) ที่ 1</Td></Tr>";
echo "<Tr><Td align='left'>3. สดมภ์(COLUMN) ที่ 1 เลขประจำตัวประชาชน 13 หลัก</Td></Tr>";
echo "<Tr><Td align='left'>4. สดมภ์(COLUMN) ที่ 2 ชื่อ - สกุล</Td></Tr>";
echo "<Tr><Td align='left'>5. สดมภ์(COLUMN) ที่ 3 ตำแหน่ง</Td></Tr>";
echo "<Tr><Td align='left'>6. สดมภ์(COLUMN) ที่ 5 กรณีเจ้าหน้าที่ สพท.(ใช้ชื่อกลุ่ม หรือ สพท.) กรณีสถานศึกษา (ใช้ชื่อ โรงเรียน xx)</Td></Tr>";
echo "<Tr><Td align='left'>7. สดมภ์(COLUMN) ที่ 6 - xx เป็นข้อมูลที่ต้องการแจ้งให้ผู้ใช้ทราบ</Td></Tr>";
echo "<Tr><Td align='left'><font size=3><strong>Ex. ตารางไฟล์ข้อมูล</strong></font></Td></Tr>";
echo "<Tr><Td align='left'>";
echo "<table width=100% class=myTableListAcc align=center>";
echo "<tr>";
echo "<td width=150>เลขประชาชน</td>";
echo "<td width=250>ชื่อ - สกุล</td>";
echo "<td width=100>ตำแหน่ง</td>";
echo "<td width=100>กลุ่ม/สถานศึกษา</td>";
echo "<td width=100>อื่นๆ ...</td>";
echo "</tr><tr>";
echo "<td>123456789012</td>";
echo "<td>นาย มณฑล พร้อมสันเทียะ</td>";
echo "<td>รักษาการผู้อำนวยการกลุ่ม</td>";
echo "<td>กลุ่มส่งเสริมการศึกษาทางไกลฯ</td>";
echo "<td>...</td>";
echo "</tr>";
ecHo "</table>";
echo "</td></tr>";
echo "</table>";
echo "</form>";
echo "<br><br>";
}
?>
<script language="JavaScript">
function Conf(object) {
if (confirm("ยื น ยั น ! คุณต้องการทำรายการนี้ - ใช่ หรือ ไม่") ==true) {
return true;
}
return false;
}
</script>