<style type="text/css">
@font-face {
    font-family: 'Sarabun';
    src:url('modules/idocument/fonts/Sarabun.ttf.woff') format('woff'),
        url('modules/idocument/fonts/Sarabun.ttf.svg#Sarabun') format('svg'),
        url('modules/idocument/fonts/Sarabun.ttf.eot'),
        url('modules/idocument/fonts/Sarabun.ttf.eot?#iefix') format('embedded-opentype'); 
    font-weight: normal;
    font-style: normal;
}


#JEDSADA
table tr.out th,
.out {
    background: #FF2200;
    font-weight:bold;
    color:#FFF;
}
/* odd items 1,3,5,7,... */
table tr.odd th,
.odd {
    background: #FFFFFF;
}

/* even items 2,4,6,8,... */
table tr.even th,
.even {
    background: #E5E5E5;
    /*background: #D5D5D5;*/
}

/* odd table rows 1,3,5,7,... */
table tr.odd th,
table tr.odd,
table tr.even th,
table tr.even {
    text-align:         left;
}

/* marked tbale rows */
table tr.marked th,
table tr.marked {
    background:   #FFCC99;
    color:   #000000;
}

/* hovered items */
.odd:hover,
.even:hover,
.hover {
    background: #CCFFCC;
    color: #000000;
}

/* hovered table rows */
table tr.odd:hover th,
table tr.even:hover th,
table tr.hover th {
    background:   #CCFFCC;
    color:   #000000;
}
input.button {
cursor: pointer;
}
label {cursor: pointer;}
input {cursor: pointer;}
.C{color:   darkgreen;}
.L{color:   RED;}
.W{color:   #999966;}
.S{color:   #CC33CC;}

@media print{
 #no_print{display:none;}
 }
#JEDSADA

</style>
<?php

$user_agent = $_SERVER['HTTP_USER_AGENT'];
function getOS() { 
    global $user_agent;
    $os_platform    =   "desktop";
    $os_array       =   array(
							'/windows nt 10.0/i'     =>  'Windows 10',
                            '/windows nt 6.3/i'     =>  'Windows 8.1',
                            '/windows nt 6.2/i'     =>  'Windows 8',
                            '/windows nt 6.1/i'     =>  'Windows 7',
                            '/windows nt 6.0/i'     =>  'Windows Vista',
                            '/windows nt 5.2/i'     =>  'Windows Server 2003/XP x64',
                            '/windows nt 5.1/i'     =>  'Windows XP',
                            '/windows xp/i'         =>  'Windows XP',
                            '/windows nt 5.0/i'     =>  'Windows 2000',
                            '/macintosh|mac os x/i' =>  'Mac OS X',
                            '/mac_powerpc/i'        =>  'Mac OS 9',
                            '/linux/i'              =>  'Linux',
                            '/ubuntu/i'             =>  'Ubuntu',
                            '/iphone/i'             =>  'iPhone',
                            '/ipod/i'               =>  'iPod',
                            '/ipad/i'               =>  'iPad',
                            '/android/i'            =>  'Android',
                            '/blackberry/i'         =>  'BlackBerry',
                            '/webos/i'              =>  'Mobile'
                        );
    foreach ($os_array as $regex => $value) { 
        if (preg_match($regex, $user_agent)) {
            $os_platform = $value;
				if(($os_platform=='Android') or ($os_platform=='BlackBerry') or ($os_platform=='iPhone') or ($os_platform=='iPad')){
				$os_platform="mobile";
				}
				else{
				$os_platform="desktop";
				}
        }
    }   
    return $os_platform;
}
$user_os = getOS();

if(!isset($_SESSION['workgroup'])){
$sql = "SELECT * FROM `system_workgroup` Where workgroup = (SELECT department FROM `person_main` where person_id = '". $_SESSION['login_user_id'] ."')";
//echo $sql;
//$sql = "SELECT * FROM `person_main` ";//department
$dbquery = mysqli_query($connect,$sql);	
$data = mysqli_fetch_assoc($dbquery);
@$_SESSION['workgroup'] =  $data['workgroup'];
@$_SESSION['workgroup_name'] =  $data['workgroup_desc'];
}
?>

<!-- Bootstrap Include -->
<link rel="stylesheet" type="text/css" href="./bootstrap-3.3.5-dist/css/bootstrap.min.css"> 
<link rel="stylesheet" type="text/css" href="./bootstrap-3.3.5-dist/css/datepicker.css"> 
<script src="./bootstrap-3.3.5-dist/js/jquery-1.11.3.min.js"></script> 
<script src="./bootstrap-3.3.5-dist/js/bootstrap.min.js"></script> 
<script src="./bootstrap-3.3.5-dist/js/bootstrap-confirmation.min.js"></script> 
<script src="./bootstrap-3.3.5-dist/js/bootstrap-datepicker.js"></script> 
<script src="./bootstrap-3.3.5-dist/js/jquery.dataTables.min.js"></script> 
<script src="./bootstrap-3.3.5-dist/js/dataTables.bootstrap.min.js
"></script> 
<script src="./bootstrap-3.3.5-dist/js/bootstrap-select.min.js"></script> 
<link rel="stylesheet" type="text/css" href="./bootstrap-3.3.5-dist/css/bootstrap-select.min.css"> 
<!--script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script> 
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap.min.js
"></script--> 

<script src="./ckeditor/ckeditor.js"></script>
<?php
if(isset($_GET['index'])){
$index=$_GET['index'];
}
else{
$index="";
}

//ผนวกเมนู
if($_SESSION['user_os']=='mobile'){
$module_menu_path="./modules/".$_REQUEST['option']."/menu_mobile.php";
}
else{
$module_menu_path="./modules/".$_REQUEST['option']."//menu.php";
}

//เช็คการเปิดใช้งานทะเบียน
$sql_start="select * from bookregister_year where year_active='1' and school_code is null";
$query_start=mysqli_query($connect,$sql_start);
$result_start=mysqli_fetch_array($query_start);

        if(!($result_start)){
        echo "<div align='center'>ยังไม่ได้กำหนดปีปฏิทินการทำงาน กรุณาแจ้งเจ้าหน้าที่ทะเบียน</div>";
        exit();
        }else{
            $_SESSION['bookregister_year'] = $result_start['year'] ;

            $sqlPosition = "SELECT * FROM `person_position`";
            $queryPosition=mysqli_query($connect,$sqlPosition);
            while($resultPosition=mysqli_fetch_array($queryPosition)){
                $Position[$resultPosition['position_code']] = $resultPosition['position_name'];
            }

        }
        
        if($result_start['start_send_num']==0){
        echo "<div align='center'>ทะเบียนหนังสือส่งไม่เปิดใช้งาน</div>";
        exit();
        }
        //ตั้งค่าเวลาลงทะเบียนไม่ให้เกินปี      
        $this_year=$result_start['year']-543;
        //$this_year=$result_start['year'];
        $now=time();
        $timestamp_end_year=mktime(23,59,59,12,31,$this_year);
        if($now>=$timestamp_end_year){
        echo "<div align='center'>ทะเบียนปีเก่าปิดโดยอัตโนมัติหลังสิ้นปี  เจ้าหน้าที่กรุณาตั้งปีใหม่เพื่อลงทะเบียน</div>";
        exit();
        }
    
if(file_exists($module_menu_path)){
require_once("$module_menu_path");
}
else{
die ("No MenuPage");
}

//ผนวกไฟล์
if($task!=""){
			$module_file_path="modules/$_REQUEST[option]/".$task;
			if(file_exists($module_file_path)){
			require_once("$module_file_path");
			}else{
			die ("No Page");
			}
}
else {
			$module_file_path="modules/$_REQUEST[option]/"."default.php";
			if(file_exists($module_file_path)){
			require_once("$module_file_path");
			}else{
			die ("No DefaultPage");
			}
}
?>
<link rel="stylesheet" type="text/css" href="css/mm_training.css">