<?php
session_start();
ob_start();
include "logo.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">

function popupCenter(pageURL, title, w, h) {
    var left = (screen.width / 2)  - (w / 2);
    var top  = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=800, height=800, top='+top+', left='+left);
document.forms["carservice"].submit();	
}

function submitform()
{
    document.forms["carservice"].submit();
}

function pop_up(url){
window.open(url,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=800,height=800,directories=no,location=no') 
}

</script>
</head>

<body>
<?php

require("dbconnect.php");

$dt=date("Y-m-d");

$name = $_SESSION['n'];
$vdpmp=$_SESSION['usr'];

echo "ΗΜΕΡΟΜΗΝΙΑ : ".$dt;
echo "<br>";echo "<br>"; 
echo " ΒΟΗΘΟΣ : ".$name;
echo "<br>";echo "<br>";
if (isset($_POST['pini'])){	
$am=$_SESSION['am'];
$pini=$_POST['pini'];
$tim=$_POST['tim'];
$etimo=$_POST['etimo'];	

$kath=$_SESSION['kath'];
$per=$_SESSION['per'];
$datet=$_SESSION['datet'];

$sql = mysqli_query($con,"SELECT MAX(timoriacode) FROM timoria " );
$row = mysqli_fetch_array($sql);
$mtim=$row['MAX(timoriacode)']+1;

mysqli_query($con,"INSERT INTO timoria (timoriacode, stu_id, dateappl, peramount,vd) VALUES ('$mtim', '$am','$dt', '$pini','$vdpmp') ");



foreach ($tim as $t) {

mysqli_query($con,"UPDATE apousies SET timoriacode=$mtim WHERE mitroo='$am' AND dateout='$datet[$t]' AND period='$per[$t]' AND kath <> ' ' ") ; 

}


echo "Η ποινή ".$pini." περιόδων ".$etimo." έχει καταχωρηθεί για το μαθητή/τρια: ".$_SESSION['stname'];
$_SESSION['pini']=$pini;
$_SESSION['tim']=$tim;
$_SESSION['mtim']=$mtim;
$_SESSION['mitroo']=$am;
$_SESSION['mitr']=$am;
$_SESSION['etimo']=$etimo;
}

?>
<br /><br />	
<input type=button onClick=pop_up("smskath.php") value="Αποστολή SMS">
<input type=button onClick=pop_up("epistoli.php") value="Δημιουργία Επιστολής">
<input type=button onClick=pop_up("mathitisp2d.php") value="Δελτίο Αποβολής">
<br /><br />
<a  href="index.php" style="color:blue "  >  Επιστροφή στο Μενού  </a>	
<a  href="timoria1.php" style="color:blue "  >  Επιστροφή στην προηγούμενη οθόνη  </a>
</body>
</html>