<?php 
include "scrinit.php";
include $menu;
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
table.myTable { border-collapse:collapse; }
table.myTable td, table.myTable th { border:1px solid black;padding:1px;font-size:10pt; }
<p style="font-size:10px;"></p>
</style>
<title>SMS Πρώτης Περιόδου</title>
</head>
<body>
<?php 

require("dbconnect.php");
$usr=$_SESSION['usr'];
$access=$_SESSION['access'];
$dt=$_SESSION['dt'];
$gym=$_SESSION['gym'];
if ($access <2 ) { echo " *** ΜΗ ΔΙΑΘΕΣΙΜΕΣ ΑΝΑΦΟΡΕΣ *** ";}
else
{

$sql1 = $dbcon->prepare("SELECT apoulimit,apoulimitb FROM parameters " );
	$sql1->execute();
	$row1=$sql1->fetch(PDO::FETCH_ASSOC);
	$arapout=$row1['apoulimit'];
	$arapoub=$row1['apoulimitb'];
// define the form into a variable
$fhtml = '<form method="post" >
<fieldset style="width:300px; ">
<br>
ΣΥΝΟΛΟ ΑΠΟΥΣΙΩΝ : <input type="text" name="arapout" value="'. $arapout. '" size="4" />
<br><br>
ΑΠΟΥΣΙΕΣ Β ΤΕΤΡΑΜ : <input type="text" name="arapoub" value="'. $arapoub. '" size="4" />
<br><br>
<input type="submit" name="submit1" value="Συνέχεια" > 
</fieldset>
</form>';

echo $fhtml;         // output /display the form
echo "<br>"."<br>";
if (isset($_POST['arapout'])) {
$arapout=$_POST['arapout'];
$arapoub=$_POST['arapoub'];
}

if (isset($_POST['arapout']))
{
   $art=$_POST['arapout'];
   $arb=$_POST['arapoub'];
   $sql1 = $dbcon->prepare("update parameters set apoulimit='$art',apoulimitb='$arb' " );
   $sql1->execute();
   $sqla = mysqli_query($con,"SELECT datexar FROM apousiesabakio " );
   $rowa = mysqli_fetch_array($sqla);
   $dx=$rowa['datexar'];
   $datexar=date('d-m-Y', strtotime($dx));
   ?>
   <form method="post" action="smsapou.php">
   <?php
   echo "<p>"."ΟΙ ΑΠΟΥΣΙΕΣ ΕΙΝΑΙ ΧΑΡΑΚΤΗΡΙΣΜΕΝΕΣ ΜΕΧΡΙ : ".date('d-m-Y', strtotime($rowa['datexar']))."</p>";
   echo "<table class='myTable' >
	<tr style='border:1px solid black' bgcolor='#d6ff73'  >
	<th>A/A</th>
	<th>ΜΗΤΡΩΟ</th>
	<th>ΤΜΗΜΑ</th>
	<th>ΜΑΘΗΤΗΣ / ΤΡΙΑ</th>
	<th>ΑΠ.ΑΒΑΚΙΟ ΜΕΧΡΙ  (".$datexar.") </th>
	<th>ΑΠ.ΑΒΑΚΙΟ B Τετρ </th>
	<th>Τηλέφωνο</th></tr>";

	
	$sql = mysqli_query($con,"SELECT mitroo,apousiestotal,apousiesbtotal,datexar FROM apousiesabakio WHERE apousiestotal> '$art' or apousiesbtotal > '$arb' order by apousiestotal DESC  " );
	$row = mysqli_fetch_array($sql);
    $i=1;
    while($row = mysqli_fetch_array($sql)) 
	{
	  
	  $mitr=$row['mitroo'];
	  $sqlt = mysqli_query($con,"SELECT eponimo,onoma,tmima,kinito FROM allstudentinfo WHERE mitroo='$mitr'  " );
	  $rowt = mysqli_fetch_array($sqlt);
	  if (mysqli_num_rows($sqlt) > 0)
	  {
		$mt[$i]=$mitr;
		$stname[$i]=$rowt['eponimo']." ".$rowt['onoma'];
		$name[$i]=$rowt['onoma'];
		$tmima[$i]=$rowt['tmima'];
		$apt[$i]=$row['apousiestotal'];
	    $apbt[$i]=$row['apousiesbtotal'];
		$kinito=$rowt['kinito'];
		echo "<tr>";
	    echo "<td>".$i. "</td>"; 
	    echo "<td>".$mt[$i]."</td>"; 
	    echo "<td>".$tmima[$i]."</td>"; 
	    echo "<td>".$stname[$i]."</td>";
	    echo "<td>".$apt[$i]."</td>";
	    echo "<td>".$apbt[$i]."</td>";
		$x=$kinito."/".$mt[$i]."/".$stname[$i]."/".$name[$i]."/".$apt[$i]."/".$apbt[$i];
		echo "<td>". "<input type='text' name='telef[]' value='$kinito' size='10'>"."<td>";
		echo "<td>". "<input type='checkbox' name='tsms[]' value='$x'  checked>" ."</td>";	
	    echo "</tr>"; 
	    $i++;  
      }
		  
    }
 echo "</table>";

?>
<input type='hidden' name='dateap' value=<?php echo $datexar;?> >
<br>
<input type="submit" value="ΑΠΟΣΤΟΛΗ ΜΗΝΥΜΑΤΩΝ" name="submit1">
</form>
<?php


}
}
?>
<br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού  </a>
</body>
</html>