<?php
include "scrinit.php";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</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);
}
</script>
<style>
body {
    font: 0.8em/1.1em Verdana, Geneva, Arial, Helvetica, sans-serif;
    background-color:#FFF; }

#wrap {
   font-size: 1em/1.1em;
   width: 1060px;
   padding: 15px;
   margin: 0 auto; 
   background-color: #fff;
   position: relative; }

/* These styles create the dropdown menus. */
#navbar {
   margin: 0;
   padding: 0;
   height: 1.2em; }
#navbar li {
   list-style: none;
   float: left; }
#navbar li a {
   display: block;
   padding: 3px 8px;
   background-color: #5e8ce9;
   color: #fff;
   text-decoration: none; }
#navbar li ul {
   display: none; 
   width: 15em; /* Width to help Opera out */
   background-color: #69f;}
#navbar li:hover ul, #navbar li.hover ul {
   display: block;
   position: absolute;
   margin: 0;
   padding: 0; }
#navbar li:hover li, #navbar li.hover li {
   float: none; }
#navbar li:hover li a, #navbar li.hover li a {
   background-color: #69f;
   border-bottom: 1px solid #fff;
   color: #000; }
#navbar li li a:hover {
   background-color: #8db3ff; }

#header h1 img { 
border: none; 
}
</style>
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:2px;font-size:12pt; }
<p style="font-size:14px;"></p>
</style>   
</head>
<body>

<br /><br />
<div id="wrap">
<h3>ΔΙΑΧΕΙΡΙΣΗ ΔΡΑΣΤΗΡΙΟΤΗΤΑΣ</h3>
<ul id="navbar">

<li class='has-sub'><a href=<?php echo $menu;?> ><span>ΕΠΙΣΤΡΟΦΗ</span></a>
   </li> 
<li class='has-sub'><a href='#'><span>|</span></a>
   </li> 
<li class='has-sub'><a href='#' onClick="popupCenter('anakoinosidrasi.php?cod=<?php echo $code; ?>')"><span>ΑΝΑΚΟΙΝΩΣΗ </span></a>
   </li>  
 <li class='has-sub'><a href='#'><span>|</span></a>
   </li> 
<li class='has-sub'><a href='editdr.php?cod=<?php echo $code; ?>'><span>ΔΙΟΡΘΩΣΗ </span></a>
</li> 
 <li class='has-sub'><a href='#'><span>|</span></a>
   </li> 
<li class='has-sub'><a href='copydr.php?cod=<?php echo $code; ?>'><span>ΑΝΤΙΓΡΑΦΗ </span></a>
   </li>    
 <li class='has-sub'><a href='#'><span>|</span></a>
</li> 
<li class='has-sub'><a href='deldr.php?cod=<?php echo $code; ?>'><span>ΔΙΑΓΡΑΦΗ </span></a>
   </li>    
 <li class='has-sub'><a href='#'><span>|</span></a>
 </li>         
<li class='has-sub'><a href='#'><span><?php echo "Date: ".date('d-m-Y');?> </span></a>
   </li> 
 
</div>
<?php

require("dbconnect.php");
$name=$_SESSION['n'];
$gym=$_SESSION['gym'];
$_SESSION['code']=$code;
$result = $dbcon->prepare("SELECT pmp,tmima,p1,p2,p3,p4,p5,p6,p7,p8,p9 FROM ekdilosistu WHERE code = ? ");
$result->execute([$code]);
$rowcount=$result->rowCount();

$sql=$dbcon->prepare("SELECT  onoma,date,perapo,permexri,teacher FROM ekdilosi WHERE  code =?" );
$sql->execute([$code]);
$row1 = $sql->fetch(PDO::FETCH_ASSOC);
$perapo=$row1['perapo'];
$permexri=$row1['permexri'];
$dat=$row1['date'];
$ekd=$row1['onoma'];
$_SESSION['dat']=$dat;
$_SESSION['cod']=$code;
/////////////////////////////////////////////////////////

while($row = $result->fetch(PDO::FETCH_ASSOC))
{
	 for ($x=1; $x<=$gym; $x++) 
	 {
	    $p[$x]=0;
	 }
	 for ($x=$perapo; $x<=$permexri; $x++) 
	 {
	    $p[$x]=1;
	 }
     $sql1=$dbcon->prepare("UPDATE ekdilosistu SET p1=?,p2=?,p3=?,p4=?,p5=?,p6=?,p7=?,p8=?,p9=? WHERE code =?");
     $sql1->execute([$p[1],$p[2],$p[3],$p[4],$p[5],$p[6],$p[7],$p[8],$p[9],$code]);		
} 
$result = $dbcon->prepare("SELECT pmp,tmima,p1,p2,p3,p4,p5,p6,p7,p8,p9 FROM ekdilosistu WHERE code = ? ");
$result->execute([$code]);
$rowcount=$result->rowCount();
////////////////////////////////////////////////////////////
if($rowcount <= 0)
{
    echo "ΔΕΝ ΕΧΟΥΝ ΕΠΙΛΕΓΕΙ ΜΑΘΗΤΕΣ";
    include "epmathnew.php";
}
else 
{
    include "listst.php";
}
?>
</body>
</html>