<?php
include "scrinit.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ΑΠΟΥΣΙΟΛΟΓΙΟ ΕΚΠΑΙΔΕΥΤΙΚΟΥ</title>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:11pt; }
<p style="font-size:11px;"></p>
</style>
<!-- Be sure to place the above styles (i.e. everything between the <style></style> tags) into the document 'head' (i.e. between the <head></head> tags. Everything below goes inside the <body></body> tags) -->

</head>
<body>


<?php 
require("dbconnect.php");
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];
$usr=$_SESSION['usr'];

$sql=$dbcon->prepare("select Name from teachers where PMP=?");
$sql->execute([$usr]);
$row=$sql->fetch(PDO::FETCH_ASSOC);
$teach=$row['Name'];
echo "ΚΑΘΗΓΗΤΗΣ/ΤΡΙΑ : ";
echo "<font face='arial' size='4pt'> $teach </font> ";
echo "<br>"."<br>" ;
$teacher=$teach;
if(isset($_POST['dt'])){
$dt=$_POST['dt'];}
$day = date('D', strtotime($dt));
$_SESSION['day']=$day;
if ($day=="Sat" or $day=="Sun")
{
    echo "<br>"."ΔΕΝ ΥΠΑΡΧΟΥΝ ΜΑΘΗΜΑΤΑ ΣΗΜΕΡΑ"."<br>";
}
else 
{
include "apousiologioproc.php";

$today=date('Y-m-d');

$sql2 = $dbcon->prepare("SELECT date,teacher,posted,code FROM apousiologio WHERE teacher=? AND date=? " );
$sql2->execute([$usr,$today]);
$row2=$sql2->fetch(PDO::FETCH_ASSOC);
$set= $sql2->rowCount();
if ($set == 0) 
{
    $sql1 = "INSERT INTO  apousiologio (date,teacher,posted,time) VALUES ('$today','$usr',0,current_time())";

	if (mysqli_query($con, $sql1)) 
		{
			
        } 
		else 
		{
            echo "Error: " . $sql1 . "<br>" . mysqli_error($con);
        }

}
else
{
   $code1=$row2['code'];
   $sql1 = $dbcon->prepare("UPDATE  apousiologio SET lastchange=?,lasttime=CURRENT_TIME()  WHERE teacher=? AND code=? " );
   $sql1->execute([$today,$usr,$code1]);

}
}

?>
