<?php
require_once($_SERVER['DOCUMENT_ROOT']."/hrm/config/config.php");
require_once($_SERVER['DOCUMENT_ROOT']."/hrm/base/recruit.php");
//require_once($_SERVER['DOCUMENT_ROOT']."/coms/stat.php");

if(isset($_REQUEST['shortlistID'])){
   $shortlist =  getShortlistByID($_REQUEST['shortlistID']);
   $applicantID = $shortlist['applicantID'];
   $jobID = $shortlist['jobID'];
   $tellephone = $shortlist['telephone'];
   $written = $shortlist['written'];
   $oral = $shortlist['oral'];
   $technical = $shortlist['technical'];
   $general = $shortlist['general'];
   $notes = $shortlist['notes'];
   $total = $tellephone+$written+$oral+$technical+$general;

    $candidate = getCanditateById($applicantID);
  $name = $candidate['fullname'];

  $job = getJobById($jobID);
  updateShortList("total",$total, $_REQUEST['shortlistID']);
}

if(isset($_POST['part1'])){
    updateShortList("telephone",$_POST['telephone'],$_REQUEST['shortlistID']);
    header("Refresh:0");
}
if(isset($_POST['part2'])){
    updateShortList("written",$_POST['written'], $_REQUEST['shortlistID']);
    header("Refresh:0");
}
if(isset($_POST['part3'])){
    updateShortList("oral",$_POST['oral'], $_REQUEST['shortlistID']);
    header("Refresh:0");
}
if(isset($_POST['part4'])){
    updateShortList("technical",$_POST['technical'], $_REQUEST['shortlistID']);
    header("Refresh:0");
}
if(isset($_POST['part5'])){
    updateShortList("general",$_POST['general'], $_REQUEST['shortlistID']);
    header("Refresh:0");
}
if(isset($_POST['part6'])){
    updateShortList("notes",$_POST['notes'], $_REQUEST['shortlistID']);
    header("Refresh:0");
}

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

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <link href="logo.png" rel="icon">
  <title>HRM - applicants</title>
  <link href="/hrm/views/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
  <link href="/hrm/views/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
  <link href="/hrm/views/css/ruang-admin.min.css" rel="stylesheet">
</head>

<body id="page-top">
  <div id="wrapper">
    <!-- Sidebar -->
    <?php
      include( $_SERVER['DOCUMENT_ROOT'].'/hrm/views/admin/sidebar.php');
    ?>
    <!-- Sidebar -->
    <div id="content-wrapper" class="d-flex flex-column">
      <div id="content">
        <!-- TopBar -->
        <?php
          include($_SERVER['DOCUMENT_ROOT'].'/hrm/views/admin/topbar.php');
        ?>
        <!-- Topbar -->

        <!-- Container Fluid-->
        <div class="container-fluid" id="container-wrapper">
          <div class="d-sm-flex align-items-center justify-content-between mb-4">
            <h4 class=" mb-0 text-primary">INTERVIEW FORM FOR  - <?php echo $name." - ".$job['jobName'] ;  ?></h4>
            <ol class="breadcrumb">
              <li class="breadcrumb-item"><a href="./">Home</a></li>
              <li class="breadcrumb-item active" aria-current="page">Dashboard</li>
            </ol>
          </div>

          <?php
            errorsP($errors);
            success($succcess);

          ?>

          <div class="row mb-3">
            <!-- top card -->
           
          <!-- end of top card -->

            <!-- forms  -->
            <div class="card col-xl-10 col-md-12 mb-4 p-3" id="bio">
        <h4>INTERVIEW FORM</h4> 
          <hr>
          <div id="telephone">
               <form action="" method="POST" class = "row">
                <!-- <div style="display: flex;"> -->

                <div class="form-group col-lg-4 mb-4">
                <label class="form-control btn-primary">TELEPHONE INTERVIEW</label>
                </div>
                    <div class="form-group col-lg-5 mb-4">
                      <input type="text" class="form-control" id="exampleInputLastName"
                       placeholder="" name="telephone" value="<?php echo $tellephone; ?>">
                    </div>
                    
                    <div class="form-group col-lg-2" >
                      <button type="submit" class="form-control btn-primary" name="part1" >SAVE</button>
                    </div>
                    

                    <hr> 
                </form>
                </div>

                <div id="telephone">
               <form action="" method="POST" class = "row">
                <!-- <div style="display: flex;"> -->

                <div class="form-group col-lg-4 mb-4">
                <label class="form-control btn-dark">WRITTEN INTERVIEW</label>
                </div>
                    <div class="form-group col-lg-5 mb-4">
                      <input type="text" class="form-control" id="exampleInputLastName"
                       placeholder="" name="written" value="<?php echo $written; ?>">
                    </div>
                    
                    <div class="form-group col-lg-2" >
                      <button type="submit" class="form-control btn-primary" name="part2" >SAVE</button>
                    </div>
                    

                    <hr> 
                </form>
                </div>


                <div id="telephone">
               <form action="" method="POST" class = "row">
                <!-- <div style="display: flex;"> -->

                <div class="form-group col-lg-4 mb-4">
                <label class="form-control btn-success">ORAL INTERVIEW</label>
                </div>
                    <div class="form-group col-lg-5 mb-4">
                      <input type="text" class="form-control" id="exampleInputLastName"
                       placeholder="" name="oral" value="<?php echo $oral; ?>">
                    </div>
                    
                    <div class="form-group col-lg-2" >
                      <button type="submit" class="form-control btn-primary" name="part3" >SAVE</button>
                    </div>
                    

                    <hr> 
                </form>
                </div>


                <div id="telephone">
               <form action="" method="POST" class = "row">
                <!-- <div style="display: flex;"> -->

                <div class="form-group col-lg-4 mb-4">
                <label class="form-control btn-info">TECHNICAL INTERVIEW</label>
                </div>
                    <div class="form-group col-lg-5 mb-4">
                      <input type="text" class="form-control" id="exampleInputLastName"
                       placeholder="" name="technical" value="<?php echo $technical; ?>">
                    </div>
                    
                    <div class="form-group col-lg-2" >
                      <button type="submit" class="form-control btn-primary" name="part4" >SAVE</button>
                    </div>
                    

                    <hr> 
                </form>
                </div>

                <div id="telephone">
               <form action="" method="POST" class = "row">
                <!-- <div style="display: flex;"> -->

                <div class="form-group col-lg-4 mb-4">
                <label class="form-control btn-warning">GENERAL ASSESSMENT</label>
                </div>
                    <div class="form-group col-lg-5 mb-4">
                      <input type="text" class="form-control" id="exampleInputLastName"
                       placeholder="" name="general" value="<?php echo $general; ?>">
                    </div>
                    
                    <div class="form-group col-lg-2" >
                      <button type="submit" class="form-control btn-primary" name="part5" >SAVE</button>
                    </div>
                    

                    <hr> 
                </form>
                </div>

                <div id= "comment">
                <div class="form-group col-lg-4 mb-4">
                <label class="form-control btn-danger">TOTAL SCORE = <?php echo $total; ?></label>
                </div>
                </div>

                <div id= "comment">
                <form action="" method="POST" class = "row" >
                <!-- <div style="display: flex;"> -->
                <div class="form-group col-lg-12 mb-4">
                    <label>INTERVIEWERS REMARKS </label>
                    <textarea type="text" class="form-control" id="superA"
                    placeholder="" name="notes" rows="10"><?php echo $notes; ?></textarea>
                </div>
                <div class="form-group col-lg-2" >
                      <button type="submit" class="form-control btn-primary" name="part6" >SAVE</button>
                    </div>
                </form>
                </div>


                </div>
            <!-- end of forms  -->





                </div>



          <!-- <div class="row">
            <div class="col-lg-12 text-center">
              <p>Do you like this template ? you can download from <a href="https://github.com/indrijunanda/RuangAdmin"
                  class="btn btn-primary btn-sm" target="_blank"><i class="fab fa-fw fa-github"></i>&nbsp;GitHub</a></p>
            </div>
          </div> -->

          <!-- Modal Logout -->
          <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabelLogout"
            aria-hidden="true">
            <div class="modal-dialog" role="document">
              <div class="modal-content">
                <div class="modal-header">
                  <h5 class="modal-title" id="exampleModalLabelLogout">Ohh No!</h5>
                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                  </button>
                </div>
                <div class="modal-body">
                  <p>Are you sure you want to logout?</p>
                </div>
                <div class="modal-footer">
                  <button type="button" class="btn btn-outline-primary" data-dismiss="modal">Cancel</button>
                  <a href="login.html" class="btn btn-primary">Logout</a>
                </div>
              </div>
            </div>
          </div>

        </div>
        <!---Container Fluid-->
      </div>
      <!-- Footer -->
      <footer class="sticky-footer bg-white">
        <div class="container my-auto">
          <div class="copyright text-center my-auto">
            <span>copyright &copy; <script> document.write(new Date().getFullYear()); </script> - developed by
              <b><a href="https://wintec.co.ke" target="_blank">wintec</a></b>
            </span>
          </div>
        </div>
      </footer>
      <!-- Footer -->
    </div>
  </div>

  <!-- Scroll to top -->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <script src="/hrm/views/vendor/jquery/jquery.min.js"></script>
  <script src="/hrm/views/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="/hrm/views/vendor/jquery-easing/jquery.easing.min.js"></script>
  <script src="/hrm/views/js/ruang-admin.min.js"></script>
  <script src="/hrm/views/vendor/chart.js/Chart.min.js"></script>
  <script src="/hrm/views/js/demo/chart-area-demo.js"></script>  
  <script type="text/javascript" src="/hrm/views/ckeditor/ckeditor.js"></script>

  <script>
    $(document).ready(function () {
      $('#dataTable').DataTable(); // ID From dataTable 
      $('#dataTableHover').DataTable(); // ID From dataTable with Hover
    });

    function sSustomer(){
      var target = document.getElementById('target').value;
      if( target == "specify"){
        document.getElementById("customer").style.display = "block";
        //alert("nimefikiwa");
      }else{
        document.getElementById("customer").style.display = "none";
      }
    }

    function tab(){
      document.getElementById("create").style.display = "none";
      document.getElementById("publish").style.display = "";
    }

    function tab1(){
      document.getElementById("create").style.display = "";
      document.getElementById("publish").style.display = "none";
    }

    CKEDITOR.replace( 'superA' );
    CKEDITOR.replace( 'superB' );
    CKEDITOR.replace( 'superC' );

    

    
  </script>
</body>

</html>