<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
echo "<tr><td colspan='6'>";
?>
<form name="checkForm">
<?php
//บุคลากรเขต
$user=$_SESSION['login_user_id'];
//เขต
$sql_person = "select * from person_main where person_id='$user'";
$dbquery_person = mysqli_query($connect,$sql_person);
$result_person = mysqli_fetch_array($dbquery_person);
$total_pid = mysqli_num_rows($dbquery_person);
$position_code = $result_person['position_code'];
$department = $result_person['department'];
$pic = $result_person['pic'];
$fullname=$result_person['prename'].$result_person['name']." ".$result_person['surname'];
$responsible=$result_person['responsible'];
//หาตำแหน่ง
$sql_position = "select * from person_position where position_code='$position_code' ";
$dbquery_position = mysqli_query($connect,$sql_position);
$result_position = mysqli_fetch_array($dbquery_position);
$position_name = $result_position['position_name'];
//หาหน่วยงาน
$sql_workgroup = "select * from system_workgroup where workgroup='$department' ";
$dbquery_workgroup = mysqli_query($connect,$sql_workgroup);
$result_workgroup = mysqli_fetch_array($dbquery_workgroup);
$school_name = $result_workgroup['workgroup_desc'];
?>
<?php if($total_pid > 0){ //เฉพาะบุคลากรเขต ?>
<?php
echo "<center>";
echo "<h3>ลงเวลาปฏิบัติราชการ</h3>";
//$date =date("Y-m-d H:i:s");
//กำหนดวันเดือนปีไทย
$thai_w=array("อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์");
$thai_n=array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
$w=$thai_w[date("w")];
$d=date("d");
$n=$thai_n[date("n") -1];
$y=date("Y") +543;
$t=date("เวลา H นาฬิกา i นาที s วินาที");
$t2=date("เวลา H. i น.");
$date_thai = "$d $n $y";
echo "<h3>วันที่ $date_thai</h3>";
?>
<center><h1><input type="text" class="btn btn-warning btn-lg" name="txtTime" id="txtTime" width="200" maxlength="200" value="" /></h1></center>
<?php
/*echo "<h4>";
echo "$fullname $position_name";
echo "<br>$school_name";
echo "</h4>";
*/
?>
<script>
function show(){
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn="AM"
if (hours>=24)
dn="PM"
txt="ขณะนี้เวลา :: "
n="น."
if (hours>24)
hours=hours-24
if (hours==0)
hours=24
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
document.checkForm.txtTime.value=txt+""+hours+":"+minutes+":"
+seconds+" "+n
setTimeout("show()",1000)
}
show()
</script>
</form>
<?php
$p = (get_magic_quotes_gpc()) ? $_GET["p"] : addslashes($_GET["p"]);
$user=$_SESSION['login_user_id'];
$date_today = date("Y-m-d"); //เวลาปัจจุบัน
$sql = "SELECT
work_main.id,
work_main.work_date,
work_main.start_time,
work_main.end_time,
work_main.person_id,
work_main.`work`,
work_main.`comment`,
work_main.rec_date,
work_main.officer
FROM
work_main
WHERE
work_main.work_date = '$date_today' AND
work_main.person_id = '$user'";
$dbquery = mysqli_query($connect,$sql);
$result = mysqli_fetch_array($dbquery);
$total = mysqli_num_rows($dbquery);
$work_date = $result['work_date'];
$rec_date = $result['rec_date'];
$start_time = $result['start_time'];
$comment = $result['comment'];
if($p == "save"){ //บันทึกลงเวลา
//id work_date start_time end_time person_id work comment rec_date officer
//$person_id = $_POST['person_id'];
$comment = $_POST['comment'];
$date_today = date("Y-m-d"); //วันปัจจุบัน
$time_tody = date("H:i:s"); //เวลาปัจจุบัน
$datetime_today = date("Y-m-d H:i:s"); //วันเวลาปัจจุบัน
//ตรวจสอบค่าว่าง
if ($user =="") {
echo "<center><h2>ไม่กรอกข้อมูล ผู้ลงเวลา</h2> <br><input type=\"button\" value=\"กลับไปแก้ไข\" class=\"btn btn-primary btn-lg\" onClick=\"javascript:history.go(-1)\" ></center>" ;
exit () ;
}
if ($comment =="") {
echo "<center><h2>ยังไม่เลือกสถานที่ลงเวลา</h2> <br><input type=\"button\" value=\"กลับไปแก้ไข\" class=\"btn btn-primary btn-lg\" onClick=\"javascript:history.go(-1)\" ></center>" ;
exit () ;
}
if ($user > "" and $total ==0 and $comment > "") {
$sql2 = "insert into work_main (work_date,start_time,end_time,person_id,work,comment,rec_date,officer) values ('$date_today','$time_tody','$end_time','$user','1','$comment','$datetime_today','$user')";
$dbquery2 = mysqli_query($connect,$sql2);
echo" <center><h2>ลงเวลาเรียบร้อย</h2> <br> <input type=\"button\" value=\"กลับหน้าหลัก\" class=\"btn btn-primary btn-lg\" onClick=\"window.location='?option=work'\"></center> ";
}else{
echo" <center><h2>ลงเวลาไม่สำเร็จ</h2> <br> <input type=\"button\" value=\"กลับหน้าหลัก\" class=\"btn btn-primary btn-lg\" onClick=\"window.location='?option=work'\"></center> ";
}
} //end บันทึก
?>
<?php if($total==1 and $p !="save"){ // ลงเวลาแล้ว ?>
<?php
if($comment == 1){
$comment_txt ="ที่บ้าน";
}
if($comment == 2){
$comment_txt ="ที่สำนักงาน";
}
?>
<center><button type="button" class="btn btn-success btn-lg">ลงเวลาแล้ว :: <?php echo $comment_txt;?> :: <?php echo $start_time?> น.</button></center>
<?php } //ลงเวลาแล้ว ?>
<?php if($total==0 and $p !="save"){ // ถ้ายังไม่ลงเวลา ?>
<form id="form1" name="form1" method="post" action="?option=work&p=save">
<div class="form-check-inline"><h3>
<label class="form-check-label">
<input type="radio" class="form-check-input" name="comment" value="1" id="comment_0" checked/>ลงเวลาที่บ้าน</label></h3>
</div><br>
<div class="form-check-inline"><h3>
<label class="form-check-label">
<input type="radio" class="form-check-input" name="comment" value="2" id="comment_1" />ลงเวลาที่สำนักงาน</label></h3>
</div>
<h1><button type="submit" id="button" class="btn btn-primary btn-lg">คลิกลงเวลาปฏิบัติราชการ</button></h1>
</form>
<?php } //จบยังไม่ลงเวลา ?>
<?php } //จบเช็ค จนท.เขต ?>
<?php
//**
if(!($_SESSION['login_status']==5 or $_SESSION['login_status']==15)){
echo "<br>";
echo "<table border='0' width='98%' align='center'>";
$sql_menugroup = "select * from system_menugroup order by menugroup_order";
$dbquery_menugroup = mysqli_query($connect,$sql_menugroup);
While ($result_menugroup = mysqli_fetch_array($dbquery_menugroup)) {
echo "<tr bgcolor='#006666'><td colspan='3' class='tagline' align='left'>$result_menugroup[menugroup_desc]</td></tr>";
$sql_module = "select * from system_module where workgroup='$result_menugroup[menugroup]' and module_active='1' and (web_link != '1' or web_link is NULL) order by module_order";
$dbquery_module = mysqli_query($connect,$sql_module);
While ($result_module = mysqli_fetch_array($dbquery_module)){
if(($_SESSION['login_status']<=5) and ($result_module['where_work']<=1 or $result_module['where_work']==3)){
echo "<tr><td width='5%'></td><td align='left' width='50'><a href='?option=$result_module[module]'><img width='40' src='modules/$result_module[module]/images/$result_module[module]_logo.jpg' /></a></td><td align='left' class='tagline'><a href='?option=$result_module[module]'>$result_module[module_desc]</a></td></tr>";
if(!isset($_SESSION['module_name_'.$result_module['module']])){
$_SESSION['module_name_'.$result_module['module']]=$result_module['module_desc'];
}
}
else if(($_SESSION['login_status']>10 and $_SESSION['login_status']<16) and ($result_module['where_work']<1 or $result_module['where_work']>1)){
echo "<tr><td width='5%'></td><td align='left' width='50'><a href='?option=$result_module[module]'><img width='40' src='modules/$result_module[module]/images/$result_module[module]_logo.jpg' /></a></td><td align='left' class='tagline'><a href='?option=$result_module[module]'>$result_module[module_desc]</a></td></tr>";
if(!isset($_SESSION['module_name_'.$result_module['module']])){
$_SESSION['module_name_'.$result_module['module']]=$result_module['module_desc'];
}
}
else if(($_SESSION['login_status']==16) and ($result_module['where_work']==3)){
echo "<tr><td width='5%'></td><td align='left' width='50'><a href='?option=$result_module[module]'><img width='40' src='modules/$result_module[module]/images/$result_module[module]_logo.jpg' /></a></td><td align='left' class='tagline'><a href='?option=$result_module[module]'>$result_module[module_desc]</a></td></tr>";
if(!isset($_SESSION['module_name_'.$result_module['module']])){
$_SESSION['module_name_'.$result_module['module']]=$result_module['module_desc'];
}
}
}
}
echo "</table>";
} //end **
echo "</td></tr>";
?>
<tr>
<td colspan="6">
<table width="70%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr bgcolor="#26354A">
<td height="30" class="user" align="center"><a href=change_os.php>AMSS++ for Desktop</a></td>
</tr></table>
</td></tr>