<?php
include "scrinit.php";
include "logo.php";
require "dbconnect.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<link rel='stylesheet' type='text/css' href='multimcss.css' />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="script.js"></script> 
<script type="text/javascript">
function KeepCount()  
{ 
	var elements = document.getElementsByName("mathm[]");
    var total = 0;
	var div = document.getElementById("pn");
    var data = div.textContent;
    for(var i in elements) {
        var element = elements[i];
        if(element.checked) total++;
        if(total <> data) {
            alert("Έχετε  επιλέξει λάθος αριθμό μαθημάτων");
            element.checked = false;
            return false;    
        }
    }
} 

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=1000, height=1000, top='+top+', left='+left);
}  
</script>
<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:14px;"></p>
</style>
</head>
<body>
<?php
$usr=$_SESSION['usr'];
$namebd=$_SESSION['n'];
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];
$aranaforas=$_SESSION['aranaforas'];
$sql = mysqli_query($con,"SELECT mitroo,eidostimo,periodoi from kataggelia where aranaforas='$aranaforas'");
$row = mysqli_fetch_array($sql);
$mitr=$row['mitroo'];
$eidostimo=$row['eidostimo'];
$pini=$row['periodoi'];
if ($eidostimo==2)
	{
		$dp=ceil($pini/$gym);
	}
if ($eidostimo==1)
	{
		$dp=floor($pini/$gym);
	}

$sql = mysqli_query($con,"SELECT onoma, eponimo, tmima FROM allstudentinfo WHERE mitroo='$mitr' " );
$row = mysqli_fetch_array($sql);
$stname=$row['eponimo']." ".$row['onoma'];
$tmima=$row['tmima'];

$sqlx = mysqli_query($con,"SELECT DISTINCT a.date from apoboli as a,apobolientypo as e
 where e.timocode='$aranaforas' and e.entypoid=a.entypoid order by a.date");
 $day=array();
 $i=0;
 while($rowx = mysqli_fetch_array($sqlx))
 {
	$i++;
	$day[$i]=$rowx['date']; 
 }
	 
$sqlx = mysqli_query($con,"SELECT a.mathima from apoboli as a,apobolientypo as e
 where e.timocode='$aranaforas' and e.entypoid=a.entypoid order by a.id");
$mathm=array();
 $jj=0;
 while($rowx = mysqli_fetch_array($sqlx))
 {
	$jj++;
	$mathm[$jj]=$rowx['mathima']; 
 }	

?>
<h3>  ΕΝΤΥΠΟ ΑΠΟΒΟΛΗΣ </h3>
<?php 

$daymap = array('Κυριακή', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο');

echo "<b>". $stname. " (".$tmima." ,".$mitroo.")"."</b>"."<br>"."<br>" ;
echo  " Ποινή σε περιόδους = ".$pini." ( ".$dp." μέρες )"."<br>";
echo "<p>"."Ημερομηνία: ".date('d-m-Y', strtotime($dt))."</p>";
echo "<table class='myTable' >
<tr style='border:2px solid black;font-size:10px'  >
<tr>
<th></th>";
for ($k=1;$k<=$i;$k++)
{
	echo "<th>".$daymap[date('w', strtotime($day[$k]))]."</th>";
}
echo "<tr>";	
echo "<th>Περ.</th>";
for ($k=1;$k<=$i;$k++)
{
	echo "<th>".date('d-m-Y', strtotime($day[$k]))."</th>";
}
echo "<tr>";
$n=1;
for ($j=1;$j<=$gym;$j++)
{
	echo "<td>".$j."</td>";
	for ($k=1;$k<=$i;$k++)
    {
	   echo "<td>".$mathm[$n]."</td>";
	   $n++;
	}
	echo "</tr>";
}

echo "</table>";

echo "<br>"."<br>"."<br>";
	echo "Υπογραφή από Β.Δ";
	echo "<br>";
	echo "<br>";
	echo "....................................";
	echo "<br>"; 
	echo $namebd; 

		
?>
<br><br>
<button style="color:blue " onClick="window.print();window.onfocus=function(){ window.close();}">ΕΚΤΥΠΩΣΗ ΔΕΛΤΙΟΥ ΑΠΟΒΟΛΗΣ</button>





