<?php
session_start();
include ("include/db.php");
include ("include/setting.php");
include ("include/security.php");

//data pengguna
$user=$_SESSION["username"];
$dataPengguna=mysqli_query($con,"select * from tbl_invigilator where invigilator_u_id='$user'");  //sql query
$showDataPengguna=mysqli_fetch_array($dataPengguna); //put data into array

$gambar1=$showDataPengguna["invigilator_pic"];
$gambar2=$showDataPengguna["invigilator_pic_type"];
$nama1=$showDataPengguna["invigilator_name"];
$nama2=$showDataPengguna["invigilator_username"];
$u_id1=$showDataPengguna["invigilator_u_id"];
$status1=$showDataPengguna["status"];
$city1=$showDataPengguna["invigilator_city"];
$state1=$showDataPengguna["invigilator_state"];
$email1=$showDataPengguna["invigilator_email"];

?>


<!DOCTYPE html>
<html lang="en">

<head>

<meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title><?php echo $site_code;?> | Register New Semester</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="plugins/iCheck/square/blue.css">
  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">

</head>
<body class="hold-transition skin-blue sidebar-mini">
<!-- Site wrapper -->
<div class="wrapper">

  <header class="main-header">
    <!-- Logo -->
    <a href="index2.php" class="logo">
      <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><b><img src="images/<?php echo $site_logo; ?>" width="30" height="30"></b></span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b><?php echo $site_code; ?></b></span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </a>

      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">
          <li class="dropdown user user-menu">
            <a href="#" class="fa fa-gears" data-toggle="dropdown">
            </a>
            <ul class="dropdown-menu">
              <!-- User image -->
              <li class="user-header">
               
               <?php

         echo '<img src="data:'.$gambar2.';base64,'.base64_encode($gambar1) .'" class="img-circle" />';
         ?>
               
               
               

                <p>
                  <small><strong><?php echo $nama1; ?></strong></small>
                  <small><?php echo $u_id1?></small>
                  <small><?php echo $email1; ?></small>
                </p>

              </li>
              
              <!-- Menu Footer-->
              <li class="user-footer">
                <div class="pull-left">
                  <a href="profile.php" class="btn btn-default btn-flat">Profile</a>
                </div>
                <div class="pull-right">
                  <a href="logout.php" class="btn btn-default btn-flat">Sign out</a>
                </div>
              </li>
            </ul>
          </li>
         <!-- Control Sidebar Toggle Button -->
          
        </ul>
      </div>
    </nav>
  </header>

  <!-- =============================================== -->

  <!-- Left side column. contains the sidebar -->
  <aside class="main-sidebar" >
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
      <!-- Sidebar user panel -->
      <div class="user-panel">
        <div class="pull-left image">
          <?php
         echo '<img src="data:'.$gambar2.';base64,'.base64_encode($gambar1) .'" class="img-circle" />';
         ?>
        </div>
        <div class="pull-left info">
          <p><?php echo $nama2; ?></p>
          <a href="#"><i class="fa fa-circle text-success"></i> <?php echo $status1;?></a>
        </div>
      </div>
      <!-- sidebar menu: : style can be found in sidebar.less -->
      <ul class="sidebar-menu" data-widget="tree">
        
        <?php 
        include ("include/menu.php");
        ?>
        
        
      </ul>
    
    
    
    
    </section>
    <!-- /.sidebar -->
  </aside>

  <!-- =============================================== -->

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">


<body class="w3-white">


<!-- Page content -->
<div class="w3-content" style="max-width:1100px;">

 <h1>
        Register New Semester
</h1>
<ol class="breadcrumb">
        <li><a href="index2.php"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="index2.php">Semester Setting</a></li>
        <li class="active">Register New Semester</li>
      </ol>
  <div class="update-box-body">   


  <div class="register-box-body">
                        <?php
            
            if (!(isset($_POST ["sem_code"])))
            {
              ?>
                            
                        <form role="form" method="post" enctype="multipart/form-data">
                        
                            <fieldset>
                            
                            <div class="form-group">
                            <label>Semester Code (example: 20184)</label>
                                    <input class="form-control" placeholder="Semester ID" name="sem_code" type="text" required autocomplete"off">
                                </div>

                            <div class="form-group">
                            <label>Semester Name (example: SESI 1 2018/2019)</label>
                                    <input class="form-control" placeholder="Semester Name" name="sem_name" type="text" required autocomplete"off">
                                </div>

                            <div class="form-group">
                            <label>Semester Info (example: SEPTEMBER - JANUARY)</label>
                                    <input class="form-control" placeholder="Semester Info" name="sem_info" type="text" required autocomplete"off">
                                </div>      

                                <!-- Change this to a button or input when using this as a form -->
                                
                                <input type="submit" class="btn btn-lg btn-success btn-block" value="Register">
                                <a href="index2.php" class="btn btn-lg btn-danger btn-block">Cancel</a>
                                
                            </fieldset>
                        </form>
                        
                       <?php
            }
            else
            {
              
              //get data from input
              $sem_code=$_POST["sem_code"];
              $sem_name=$_POST["sem_name"];
              $sem_info=$_POST["sem_info"];
              //check duplicate
              
              $data=mysqli_query($con, "SELECT * FROM tbl_semester where sem_code='$sem_code'");
              $bil_rekod=mysqli_num_rows($data);
              $show=mysqli_fetch_array($data);
              if ($bil_rekod!=0)
              {
              
              
              ?>
                            
                            <div class="alert alert-danger">
                               Semester already existed in the system. <a href="admin_semestersetting_reg_semester.php" class="alert-link">Click here</a> to try again.
                            </div>
                           
                         <?php
              }

              else 
              {
//$dateregister=date("Y-m-d");                
//insert data into database   
mysqli_query($con,"INSERT INTO tbl_semester (sem_code,sem_name,sem_info) values ('$sem_code','$sem_name','$sem_info')")or die (mysqli_error($con));               
                
                
                
                ?>
                
                <div class="alert alert-success">
                              New semester Successfully registered. <a href="admin_semestersetting_reg_semester.php" class="alert-link">Click here</a> to register more semesters.
                            </div>
            <?php
              }}
              ?>
            
             
  
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  
  <footer class="main-footer"  style="background-color:#222d32;">
    <div class="pull-right hidden-xs">
      
      <b>Version</b> 1.0.0
    </div>
    <strong>Copyright &copy; 2018 <a href="profile_dev.php">EXAMS</a>.</strong> All right reserved to respective owner. No part may be published without written permission.
  </p></footer>


<!-- jQuery 3 -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<script>
  $(document).ready(function () {
    $('.sidebar-menu').tree()
  })
   </script>

    <!-- Bootstrap Core JavaScript -->
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="dist/js/sb-admin-2.js"></script>

</body>

</html>
