Mini Shell
<?php
include 'head.php';
if ($s_status_user == 3) {
header("Location: login.php");
}
?>
<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<html>
<script language="javascript">
window.onload = function () {
var a=document.getElementById('mytable'); // อ้างอิงตารางด้วยตัวแปร a
for(i=0;i<a.rows.length;i++){ // วน Loop นับจำนวนแถวในตาราง
if(i>0){ // ตรวจสอบถ้าไม่ใช่แถวหัวข้อ
if(i%2==1){ // ตรวจสอบถ้าไม่ใช่แถวรายละเอียด
a.rows[i].className=""; // กำหนด class แถวแรก
}else{
a.rows[i].className="info"; // กำหนด class แถวที่สอง
}
}else{ // ถ้าเป็นแถวหัวข้อกำหนด class
a.rows[i].className="active";
}
}
}
</script>
<!--
BODY TAG OPTIONS:
=================
Apply one or more of the following classes to get the
desired effect
|---------------------------------------------------------|
| SKINS | skin-blue |
| | skin-black |
| | skin-purple |
| | skin-yellow |
| | skin-red |
| | skin-green |
|---------------------------------------------------------|
|LAYOUT OPTIONS | fixed |
| | layout-boxed |
| | layout-top-nav |
| | sidebar-collapse |
| | sidebar-mini |
|---------------------------------------------------------|
-->
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<!-- Main Header -->
<?php include 'header.php'; ?>
<!-- Left side column. contains the logo and sidebar -->
<?php include 'leftside.php'; ?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
ประวัติการศึกษา
<small>จัดการข้อมูลประวัติการศึกษา</small>
</h1>
<ol class="breadcrumb">
<li><a href="education.php"><i class="fa fa-dashboard"></i> ข้อมูลประวัติการศึกษา</a></li>
<li class="active">ประวัติการศึกษา</li>
</ol>
</section>
<?php
$teacherID = $_GET['teacherID'];
$sql1 = "SELECT * FROM teacher AS t1 LEFT JOIN title_name AS t2 ON (t1.titleID = t2.titleID)
LEFT JOIN education AS t3 ON (t1.teacherID = t3.teacheredID )
LEFT JOIN level_education AS t4 ON (t3.levelID = t4.levelID)WHERE (`teacherID`='$teacherID') ";
$result = mysqli_query($link, $sql1);
$row = mysqli_fetch_assoc($result)
?>
<!-- Main content -->
<section class="content">
<a href="frm_education.php?teacherID=<?php echo $teacherID;?>" id="" class="btn btn-primary"><i class="fa fa-plus"></i> เพิ่มรายการ</a>
<br><br>
<!-- Your Page Content Here -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title"><i class="fa fa-graduation-cap"></i> ประวัติการศึกษา <span class="label label-success"><?php echo $row['titleName']; ?><?php echo $row['name']; ?> <?php echo $row['lastName']; ?></span></h3>
<div class="box-tools pull-right">
<!-- Buttons, labels, and many other things can be placed here! -->
<!-- Here is a label for example -->
</div><!-- /.box-tools -->
</div><!-- /.box-header -->
<div class="box-body">
<div class="box box-solid box-primary">
<div class="box-header">
<h3 class="box-title"><i class="fa fa-graduation-cap"></i> รหัสบุคลากร <?php echo $teacherID; ?></h3>
</div>
<div class="table-responsive">
<table id="mytable" class="table table-hover table-bordered">
<thead>
<tr>
<th style="text-align: center;">ลำดับที่</th>
<th>ระดับการศึกษา</th>
<th>วุฒิการศึกษา</th>
<th>วิชาเอก</th>
<th>ชื่อสถานบัน</th>
<th>อื่นๆ</th>
<th style="text-align: center;">เครื่องมือ</th>
</tr>
</thead>
<tbody>
<?php
$rows = 7;
$sql2 = "SELECT * FROM education where teacheredID = '$teacherID'";
$result = mysqli_query($link, $sql2);
$row = mysqli_num_rows($result);
$total_page = ceil($row/$rows);
if(empty($_GET['page'])){
$page=1;
} else {
$page=$_GET['page'];
}
if($page>=$total_page) $page=$total_page;
$start=($page-1)*$rows;
$sql3 = "SELECT * FROM teacher AS t1 LEFT JOIN title_name AS t2 ON (t1.titleID = t2.titleID)
LEFT JOIN education AS t3 ON (t1.teacherID = t3.teacheredID )
LEFT JOIN level_education AS t4 ON (t3.levelID = t4.levelID)WHERE (`teacherID`='$teacherID')order By t4.levelID ASC Limit $start,$rows ";
$result = mysqli_query($link, $sql3);
$i=1;
if($page > 1)
{
$i = ($rows * ($page-1)) + 1;
}
if(!empty($row)){
while ($row1 = mysqli_fetch_assoc($result)) { ?>
<tr>
<td style="text-align: center;"><?php echo $i; ?></td>
<td><?php echo $row1['levelName'] ?></td>
<td><?php echo $row1['degreeName'] ?></td>
<td><?php echo $row1['degreeSubject'] ?></td>
<td><?php echo $row1['degreeInstitution'] ?></td>
<td><?php echo $row1['other'] ?></td>
<td style="text-align: center;"><a id="<?php echo $row1['educationID']; ?>" class="btn btn-success btn-xs edit_data" title="แก้ไขข้อมูล" ><i class="fa fa-pencil"></i></a> <a href="" id="<?php echo $row1['educationID']; ?>" class="btn btn-danger btn-xs btn_del" title="ลบข้อมูล"><i class="fa fa-times"></i></a></td>
</tr>
<?php
$i++;
} ?>
<?php
}else if(empty($row)){
?>
<tr>
<td colspan="7"><div align="center"><i class="fa fa-folder-open"></i> ไม่พบข้อมูล</div></td>
</tr>
<?php } ?>
</tbody>
</table>
<nav aria-label="Page navigation">
<div class="text-center">
<ul class="pagination">
<li <?php if($page==1)echo'class="disabled"'; ?>>
<a href="show_education.php?teacherID=<?php echo $teacherID ?>&page=<?php echo $page-1; ?>"aria-label="Previous">« ก่อนหน้า
</a>
</li>
<?php for($i=1;$i<=$total_page;$i++) {
if($page-2>=2 and ($i>2and$i<$page-2)){
echo "<li><a href=>...</a></li>";
$i=$page-2;
}
if($page+5<=$total_page and ($i>=$page+3 and $i<=$total_page-2)){
echo "<li><a href=>...</a></li>";
$i=$total_page-1;
}
?>
<li <?php if($page==$i)echo'class="active"'; ?>><a href="show_education.php?teacherID=<?php echo $teacherID ?>&page=<?php echo $i; ?>"> <?php echo $i;?></a></li>
<?php } ?>
<li <?php if($page==$total_page)echo'class="disabled"'; ?>>
<a href="show_education.php?teacherID=<?php echo $teacherID ?>&page=<?php echo $page+1; ?>"aria-label="Previous"> ถัดไป »
</a>
</li>
</ul>
<ul class="pagination">
<li>
<a aria-label="Previous">
ทั้งหมด <span class="badge"><?php echo $row;?></span> รายการ
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<div class="modal fade" id="exampleModal" role="dialog" >
<div class="modal-dialog" >
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel">แก้ไขประวัติบุคลากร</h4>
</div>
<div class="modal-body">
<form method="post" id="form1" name="form1" action="insertmodal_education.php" novalidate>
<?php
$sqlmodal = "SELECT * FROM level_education";
$resultmodal = mysqli_query($link, $sqlmodal);
?>
<div class="form-group">
<input type="hidden" name="educationID" id="educationID">
<label>ระดับการศึกษา</label>
<select id="levelID" name="levelID" class="form-control select2" style="width: 100%;" data-smk-msg="กรุณาเลือก"required>
<option value="" >---กรุณาเลื่อก---</option>
<?php
while ($rowmodal = mysqli_fetch_array($resultmodal,MYSQLI_NUM)){
echo "<option value='$rowmodal[0]'>$rowmodal[1]</option>";
}
mysqli_close($link);
?>
</select>
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">วุฒิการศึกษา</label>
<input id="degreeName" name="degreeName" type="text" class="form-control" id="recipient-name" >
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">วิชาเอก</label>
<input id="degreeSubject" name="degreeSubject" type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">ชื่อสถานบัน</label>
<input id="degreeInstitution" name="degreeInstitution" type="text" class="form-control" id="recipient-name" data-smk-msg="กรุณากรอกชื่อสถานบัน"required>
</div>
<div class="form-group">
<label for="message-text" class="control-label">อื่นๆ</label>
<textarea id="other" name="other" class="form-control" id="message-text"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">ปิด</button>
<button type="submit" id="submit" name="submit" class="btn btn-primary">แก้ไขข้อมูล</button>
</div>
</form>
</div>
</div>
</div>
</div><!-- box-footer -->
</div><!-- /.box -->
<!-- Your Page Content Here -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<!-- Main Footer -->
<?php include 'footer.php'; ?>
</div>
<!-- ./wrapper -->
<!-- REQUIRED JS SCRIPTS -->
<!-- jQuery 2.2.3 -->
<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script src="bootstrap/js/smoke.min.js"></script>
<script src="bootstrap/js/sweetalert.min.js"></script>
<script>
$(document).ready(function(){
$(".btn_del").on("click",function(e) {
//delete confirm
var uid = $(this).attr('id');
swal({
title: "คุณแน่ใจหรือไม่ว่าต้องการลบข้อมูล?",
text: "คุณจะไม่สามารถกู้คืนข้อมูลนี้ได้อีก!",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#d33',
confirmButtonText: "ตกลง, ลบข้อมูล!",
cancelButtonText: "ยกเลิก..",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm) {
if (isConfirm) {
$.get("del_edu.php", {id : uid})
.done(function (data) {
if (data.status === "success") {
$.smkAlert({text: data.message, type: data.status});
} else {
$.smkAlert({text: data.message, type: data.status});
}
location.reload();
});
} else {
swal("ยกเลิก", "ข้อมูลของคุณยังไม่ถูกลบ :)", "error");
}
});
e.preventDefault();
});
});
</script>
<script>
$(document).ready(function(){
$('.edit_data').on("click",function(){
var id = $(this).attr("id");
$.ajax({
url:"edit_education.php",
type: "POST",
data:{id:id},
dataType:"json",
success:function(data){
console.log(JSON.stringify(data));
$('#educationID').val(data.educationID);
$('#levelID').val(data.levelID);
$('#degreeName').val(data.degreeName);
$('#degreeSubject').val(data.degreeSubject);
$('#degreeInstitution').val(data.degreeInstitution);
$('#other').val(data.other);
$('#exampleModal').modal('show');
}
/*,
error:function(xhr)
{
alert("An error occured: " + xhr.status + " " + xhr.statusText);
}
*/
});
});
});
</script>
<script>
$(document).ready(function(){
$('#submit').on("click",function(e) {
if ($('#form1').smkValidate()) {
$.post("insertmodal_education.php", $("#form1").serialize() )
.done(function( data ) {
if (data.status === "success") {
$.smkAlert({text: data.message , type: data.status});
} else {
$.smkAlert({text: data.message , type: data.status});
}
$('#exampleModal').modal('hide');
location.reload();
});
e.preventDefault();
}
e.preventDefault();
});
});
</script>
<!-- Optionally, you can add Slimscroll and FastClick plugins.
Both of these plugins are recommended to enhance the
user experience. Slimscroll is required when using the
fixed layout. -->
</body>
</html>
Zerion Mini Shell 1.0