<?php session_start(); error_reporting(E_ERROR | E_PARSE);
include("connection.php");  $id=$_REQUEST["id"];
date_default_timezone_set("Asia/Calcutta");

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

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title>Ghatal Municipality</title>
  <meta content="" name="description">
  <meta content="" name="keywords">

  <!-- Favicons -->
  <link href="assets/img/favicon.png" rel="icon">
  <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">

  <!-- Google Fonts -->
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,500,500i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">

  <!-- Vendor CSS Files -->
  <link href="assets/vendor/aos/aos.css" rel="stylesheet">
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
  <link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
  <link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">

  <!-- Template Main CSS File -->
  <link href="assets/css/style.css" rel="stylesheet">

  <!-- =======================================================
  * Template Name: Appland - v4.2.0
  * Template URL: https://bootstrapmade.com/free-bootstrap-app-landing-page-template/
  * Author: BootstrapMade.com
  * License: https://bootstrapmade.com/license/
  ======================================================== -->
</head>

<body onload="startTime()">

  <!-- ======= Header ======= -->
  <header id="header" class="fixed-top " style="background-color:#660000">
    <div class="container d-flex align-items-center justify-content-between" >

      <div class="logo" >
         <h1><a href="trade_1.php"><b> <font color="white">DEBENDRA</font></b></a></h1>
        <!-- Uncomment below if you prefer to use an image logo -->
        <!-- <a href="index.html"><img src="assets/img/logo.png" alt="" class="img-fluid"></a>-->
      </div>

      <nav id="navbar" class="navbar">
        <ul>
          <li><a class="nav-link scrollto" href="trade_1.php">Home</a></li>
         
        </ul>
        <i class="bi bi-list mobile-nav-toggle"></i>
      </nav><!-- .navbar -->

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

  <main id="main">

    <!-- ======= Breadcrumbs Section ======= -->
    <section class="breadcrumbs" style="background-color:#CCFFFF">
      <div class="container">

        <div class="d-flex justify-content-between align-items-center">
          <br><br><br>
         <form method="POST" name="form1" autocomplete="no-fill">
             <input type="text" name="student_id" placeholder="Student Id (OUT)"  style="width: 100%; height:40px; background-color:#FFFFCC" autofocus >
             <input type="submit" name="submit"  class="form-control" style="background-color:#66FFFF; width:10%; display:none"  >
         </form>
         
         
         <?php   
if(isset($_POST["submit"]))
        {
			$n=$_POST["student_id"];
		$s=mysqli_query($con,"select `class_id`,`student_fname`,`student_mname`,`student_lname`,`phone` from student where `student_id`='".$n."'");
		$sr=mysqli_fetch_array($s,MYSQLI_ASSOC);
		$sn=mysqli_num_rows($s);
		if($sn >0) {
		$class_id=$sr["class_id"];
		$student_fname=$sr["student_fname"];
		$student_mname=$sr["student_mname"];
		$student_lname=$sr["student_lname"];
	$x=0;
		$phone=$sr["phone"];
		$date=date('Y-m-d');
		$ct=date("h:ia");
$month=substr($date,5,2);
$year=substr($date,0,4);
$q=mysqli_query($con,"select id from attendance where `date`='".$date."' and `student_id`='".$n."'");
$qn=mysqli_num_rows($q); $x=1;
if($qn==0) {  
    mysqli_query($con,"insert into attendance (`student_id`,`class_name`,`section_name`,`roll_no`,`date`,`month`,`year`,`ac_session`,`present`,`out_time`) values ('".$n."','".$class_id."','".$section_name."','".$roll_no."','".$date."','".$month."','".$year."','".$ac_session."','1','".$ct."')");
} else {
mysqli_query($con,"update attendance set `out_time`='".$ct."',`present`='1' where `student_id`='".$n."'");
}

$ct=date("h:ia");
 $ch = curl_init();
$parampro['uname'] = "scriptlovers";
$parampro['password'] = "123456";
$parampro['sender'] = "KRVVSC";
$parampro['receiver'] =$phone;
$parampro['route'] = "TA";
$parampro['msgtype'] = "1";
  $parampro['tempid'] = "1207164128441601252";

$parampro['sms'] = $student_fname." reached school at ".$ct." - KRVV" ;

$sendsmspro = http_build_query($parampro);

//$urlpro="http://sendsms.designhost.in/index.php/smsapi/httpapi/?".$sendsmspro;

curl_setopt($ch, CURLOPT_URL, $urlpro);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $resultpro = curl_exec($ch); 
curl_close($ch);   







?> <center> <img src="https://media.tenor.com/0AVbKGY_MxMAAAAC/check-mark-verified.gif" width="70%"> </center>

<br> 
<b><font color="blue">Name : <?php 
echo $student_fname." ".$student_mname." ".$student_lname; ?><br>
Class : <?php echo $class_id;    ?><br>

</b></font>
<font color="red"><b><?php echo date("l jS \ F Y , h:i:s A");  ?></b></font><hr>

<audio autoplay >
  <source src="success.mp3" type="audio/mpeg">
</audio>

    <script type="text/javascript">
  setTimeout(function () { window.location.href="out.php"; }, 1000);
</script>



<?php
		} else
		{
		   ?><center><img src="sad.png" width="70%"><br><b><font color="red"><?php 
echo " Student not found"; ?></b></font></center><hr>
<audio autoplay >
  <source src="stop.mp3" type="audio/mpeg">
</audio>
 <script type="text/javascript">
 
  setTimeout(function () { window.location.href="out.php"; }, 2000);
</script>
<?php
		}
			}
?>				 
<center>
  <a href="index.php"><img src="https://static.vecteezy.com/system/resources/previews/010/149/009/original/home-icon-real-estate-sign-design-free-png.png" width="60"> </a>     &nbsp;&nbsp;&nbsp;  
    <img src="https://www.iconpacks.net/icons/1/free-settings-icon-778-thumb.png" width="70"> 
</center> 
<div id="txt"></div>
<script>
function startTime() {
  const today = new Date();
  let h = today.getHours();
  let m = today.getMinutes();
  let s = today.getSeconds();
  m = checkTime(m);
  s = checkTime(s);
  document.getElementById('txt').innerHTML =  h + ":" + m + ":" + s;
  setTimeout(startTime, 1000);
}

function checkTime(i) {
  if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
  return i;
}
</script>

         
         
    <!--    <center> <!--<img src="https://media.tenor.com/0AVbKGY_MxMAAAAC/check-mark-verified.gif" width="100%"> -->
      <!--  <img src="https://i.gifer.com/5D1O.gif" width="100%"> <br>
         <br><h4 style="color:#FF0000"><b>Place Scanner for Attendance</b></h4>
        </center><br>-->
       
        </div>

      </div>
    </section><!-- End Breadcrumbs Section -->
    
<script>
   // setTimeout(function(){
 //  window.location.reload();
}, 2000);
</script>
    <section id="contact" class="contact" style="background-color:#CCFFFF">
      <div class="container" data-aos="fade-up">

       

        <div class="row">

          <div class="col-lg-6">
	

          </div>
		 
        </div>
          </div>

        </div>
		 

      </div>
    </section><!-- End Contact Section -->


  </main><!-- End #main -->

  <!-- ======= Footer ======= -->
<!--  <footer id="footer">

    <div class="footer-newsletter">
      <div class="container">
        <div class="row justify-content-center">
          <div class="col-lg-6">
            <h4>Join Our Network</h4>
            <p>Join with our network and receive updates</p>
            <form action="subscribe.php" method="post">
              <input type="email" name="email"><input type="submit" value="Subscribe">
            </form>
          </div>
        </div>
      </div>
    </div>

    <div class="footer-top">
      <div class="container">
        <div class="row">

          <div class="col-lg-3 col-md-6 footer-contact">
            <h3>Contact</h3>
            <p>
              Srirampurt <br>
              Panskura<br>
              West bengal <br><br>
              <strong>Phone:</strong> +91 8961963301<br>
              <strong>Email:</strong> saikat3322@gmail.com<br>
            </p>
          </div>

          <div class="col-lg-3 col-md-6 footer-links">
            <h4>Useful Links</h4>
            <ul>
			<li><a class="bx bx-chevron-right" href="#hero">Home</a></li>
          <li><a class="bx bx-chevron-right" href="#features">About Me</a></li>
          <li><a class="bx bx-chevron-right" href="#gallery">Project</a></li>
		     <li><a class="bx bx-chevron-right" href="#contact">Contact</a></li>
          
             
            </ul>
          </div>

          <div class="col-lg-3 col-md-6 footer-links">
            <h4>Our Services</h4>
            <ul>
              <li><i class="bx bx-chevron-right"></i> <a href="#">School/College Projects</a></li>
              <li><i class="bx bx-chevron-right"></i> <a href="#">Various Courses</a></li>
              <li><i class="bx bx-chevron-right"></i> <a href="#">Web Development</a></li>
              
            </ul>
          </div>

          <div class="col-lg-3 col-md-6 footer-links">
            <h4>Our Social Networks</h4>
            <p>Find our Social Network</p>
            <div class="social-links mt-3">
              <a href="#" class="twitter"><i class="bx bxl-twitter"></i></a>
              <a href="#" class="facebook"><i class="bx bxl-facebook"></i></a>
              <a href="#" class="instagram"><i class="bx bxl-instagram"></i></a>
              <a href="#" class="google-plus"><i class="bx bxl-skype"></i></a>
              <a href="#" class="linkedin"><i class="bx bxl-linkedin"></i></a>
            </div>
          </div>
Terms and Conditions | Privacy Policy | Refunds/Cancellations
        </div>
      </div>
    </div>

    <div class="container py-4">
      <div class="copyright">
        &copy; Copyright <strong><span>< CWS /></span></strong>. All Rights Reserved
      </div>
      <div class="credits">
        <!-- All the links in the footer should remain intact. -->
        <!-- You can delete the links only if you purchased the pro version. -->
        <!-- Licensing information: https://bootstrapmade.com/license/ -->
        <!-- Purchase the pro version with working PHP/AJAX contact form: https://bootstrapmade.com/free-bootstrap-app-landing-page-template/ 
        Designed by <a href="#">Coding With Saikat</a>
      </div>
    </div>
	
  </footer>--><!-- End Footer -->

  <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>

  <!-- Vendor JS Files -->
  <script src="assets/vendor/aos/aos.js"></script>
  <script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="assets/vendor/glightbox/js/glightbox.min.js"></script>
  <script src="assets/vendor/php-email-form/validate.js"></script>
  <script src="assets/vendor/swiper/swiper-bundle.min.js"></script>

  <!-- Template Main JS File -->
  <script src="assets/js/main.js"></script>

</body>

</html>