<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>KVS DIGITAL - E-VOTING SYSTEM</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
 <!-- Favicons -->
  <link href="assets/img/kvs.png" rel="icon">
  <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
  
    <!-- Vendor CSS Files -->
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="assets/vendor/icofont/icofont.min.css" rel="stylesheet">
  <link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <link href="assets/vendor/owl.carousel/assets/owl.carousel.min.css" rel="stylesheet">
  <link href="assets/vendor/venobox/venobox.css" rel="stylesheet">
  <link href="assets/vendor/aos/aos.css" rel="stylesheet">

  <!-- Template Main CSS File -->
  <link href="assets/css/style.css" rel="stylesheet">
  
<style>
  /* Base for label styling */
[type="checkbox"]:not(:checked),
[type="checkbox"]:checked {
  position: absolute;
  left: -9999px;
}
[type="checkbox"]:not(:checked) + label,
[type="checkbox"]:checked + label {
  position: relative;
  padding-left: 25px;
  cursor: pointer;
}

/* checkbox aspect */
[type="checkbox"]:not(:checked) + label:before,
[type="checkbox"]:checked + label:before {
  content: '';
  position: absolute;
  left:0; top: 2px;
  width: 27px; height: 27px;
  border: 1px solid #aaa;
  background: #f8f8f8;
  border-radius: 3px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3)
}
/* checked mark aspect */
[type="checkbox"]:not(:checked) + label:after,
[type="checkbox"]:checked + label:after {
  content: 'X';
  position: absolute;
  top: 3px; left: 4px;
  font-size: 28px;
  line-height: 0.8;
  color: #09ad7e;
  transition: all .2s;
}
/* checked mark aspect changes */
[type="checkbox"]:not(:checked) + label:after {
  opacity: 0;
  transform: scale(0);
}
[type="checkbox"]:checked + label:after {
  opacity: 1;
  transform: scale(1);
}
/* disabled checkbox */
[type="checkbox"]:disabled:not(:checked) + label:before,
[type="checkbox"]:disabled:checked + label:before {
  box-shadow: none;
  border-color: #bbb;
  background-color: #ddd;
}
[type="checkbox"]:disabled:checked + label:after {
  color: #999;
}
[type="checkbox"]:disabled + label {
  color: #aaa;
}
/* accessibility */
[type="checkbox"]:checked:focus + label:before,
[type="checkbox"]:not(:checked):focus + label:before {
  border: 1px dotted blue;
}
</style>

  </head>
<body>
<!-- ======= Header ======= -->
  <header id="header" class="fixed-top">
    <div class="container d-flex align-items-center">
      
      <div class="logo mr-auto">      
        
        <!-- Uncomment below if you prefer to use an image logo -->
         
          <h1 class="text-light"><a href="index.html">KVSDigital E- VOTING</a></h1>
        </a>
      </div>

      <nav class="nav-menu d-none d-lg-block">
        <ul>
          <li class="active"><a href="index.php">Home</a></li>
          <li class="get-started"><a href="#features">LOGOUT</a></li>
        </ul>
      </nav><!-- .nav-menu -->

    </div>
  </header><!-- End Header -->

<div class="container-fluid">
    <br><br><br><br><br><br><br><br><hr> 
  <section class="features contact">
   
 
 <div class="section-title"><h2>PILIHANRAYA MAJLIS PERWAKILAN PELAJAR KOLEJ VOKASIONAL SEPANG <? echo date("Y");?></h2><br>
 <h3>SELAMAT DATANG <?php echo $_SESSION["name"];?></h3>
 <h4>PASTIKAN ANDA MENGUNDI 15 CALON</h4></div>
 </section>

  <?php   

   include 'dbconn.php';


//CHECK STUDENT STATUS
if (isset($_GET['ic'])) {    
   $ic=$_GET['ic'];
}

if (isset($_POST['submit1'])){
$ic=$_POST["var"];

}


//check FOR IF STUDENT EXIST BASED ON IC
$student = "SELECT * FROM tblstudent WHERE studentIC = '641109106272'";
$result1= mysqli_query($conn,$student);
 $row1= mysqli_fetch_assoc($result1);

$status =  $row1[voteStatus];


//SELECT ALL CANDIDATE 
  $sql = "SELECT * FROM tblcandidate";
 $result = mysqli_query($conn, $sql);

if (!$result) {
    echo "Error".mysqli_error($conn);
}

    while($row = mysqli_fetch_assoc($result)) {

?>

    <form name="checkbox" action="undian4.php" method="post" onsubmit="return checkboxes()">
    <input type="hidden" name="var" value="<?=$ic?>"/>
     
   
              
               <div class="col-xl-2 col-lg-3 col-md-4 col-sm-6">
                    <p><?php echo $row[candN];?> </p> 
                    <p><?php echo $row[candCourse];?></p>
            
                     <p><img src="<?php echo $row[image];?>" style="width:220px;height:200px;"/> </p>
                     <p><input type="checkbox" id="test<?php echo $row[candID];?>" name="check[]" value="<?php echo $row[candID];?>"  onclick="chkChecks('check[]')">
                  <label for="test<?php echo $row[candID];?>"></label></p><br><br>
               </div>       
               
               

        
 <?php

}

?>    

<div class="text-center"><button type="submit" name="submit1" class="btn btn-primary"><h2>Hantar Undian Anda</h2></div>
 
</form>

</div>

<script type="text/javascript">

function chkChecks(nme) {
var isChecked = 0;
var c = document.getElementsByName(nme);
for (var i = 0; i < c.length; i++) {
if (c[i].checked) {
isChecked ++;

if (isChecked >10) {  // maximum of seven checkboxes - change as required
alert ('ANDA HANYA BOLEH MENGUNDI TIDAK LEBIH DARI 10 CALON');

c[i].checked = false;
return false;
}
}
}
}

function countCheck(nme) {
 var isChecked = 0;
var c = document.getElementsByName(nme);
for (var i = 0; i < c.length; i++) {
if (c[i].checked) {
isChecked ++;
}

alert ('anda pasti');
return false;

}
}

function checkboxes()
   {
    var inputElems = document.getElementsByTagName("input"),
     count = 0;

     for (var i=0; i<inputElems.length; i++) {
        if (inputElems[i].type == "checkbox" && inputElems[i].checked == true){
           count++;

        }
     }
     if(count!=10){
      alert('SILA UNDI 10 CALON');
      return false;
      }
      
      
  }

</script>


</div>
</body>
</html>
