<?php include('lock.php'); ?>
<?php include('config.php'); ?>

<style media='print'>
#prnBtn { display: none }
#bck { display: none }
#related_links { display: none }
</style>

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$date = date("d/m/Y");
$afi = '1000';
$id = $_GET['id'];

$datapr = mysqli_query($bd, "SELECT * FROM `oaed_thea` WHERE id='$id'") or die(mysqli_error($bd));

while ($rowtt = mysqli_fetch_array($datapr)) {
    $datein = date('d/m/Y', strtotime($rowtt['date_in']));
    $dateout = date('d/m/Y', strtotime($rowtt['date_out']));
    $ses = $rowtt['ar_symb'];
    $dian = $dateout - $datein;

    $date1 = date_create($rowtt['date_in']);
    $date2 = date_create($rowtt['date_out']);
    $diff = date_diff($date1, $date2)->format("%a");
    $simetoxi = $rowtt['simetoxi'];
    $imer = $diff + 1;

    $simm = ($rowtt['ar_ofel'] + 1) * ($simetoxi / $diff);

    $room = $rowtt['room'];
    $extra = $rowtt['extra'];
    $ar_of = ($rowtt['ar_ofel'] + 1);
?>
<p align="center"><input type="button" id='prnBtn' value="εκτύπωση" onClick="window.print()"></p>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>print deltio number</title>
<style type="text/css">
.style1 { font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 18px; }
.style4 { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; }
.style10 { font-family: Geneva, Arial, Helvetica, sans-serif; }
.style15 { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; }
.style16 { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; }
.style18 { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; }
</style>
</head>

<body>
<table width="714" border="0" align="center">
<tr>
<td height=""><div align="justify" class="style15">
<?php
$datadi = mysqli_query($bd, "SELECT * FROM `oaed_thea` WHERE id='$id'") or die(mysqli_error($bd));
while ($rowdi = mysqli_fetch_array($datadi)) {
    $of_di = $rowdi['name'];
    $room = $rowdi['room'];
    $am_di = $rowdi['amka'];
    $ar_di = $rowdi['epitagi'];
}

$dataa = mysqli_query($bd, "SELECT * FROM `oaed_thea` WHERE ar_symb='$ses' AND dik_ofel=2") or die(mysqli_error($bd));
while ($rowta = mysqli_fetch_array($dataa)) {
    $of_a = $rowta['name'];
    $room = $rowta['room'];
    $am_a = $rowta['amka'];
    $ar_a = $rowta['epitagi'];
}

$datb = mysqli_query($bd, "SELECT * FROM `oaed_thea` WHERE ar_symb='$ses' AND dik_ofel=3") or die(mysqli_error($bd));
while ($rowtb = mysqli_fetch_array($datb)) {
    $of_b = $rowtb['name'];
    $am_b = $rowtb['amka'];
    $ar_b = $rowtb['epitagi'];
}

$datc = mysqli_query($bd, "SELECT * FROM `oaed_thea` WHERE ar_symb='$ses' AND dik_ofel=4") or die(mysqli_error($bd));
while ($rowtc = mysqli_fetch_array($datc)) {
    $of_c = $rowtc['name'];
    $am_c = $rowtc['amka'];
    $ar_c = $rowtc['epitagi'];
}

$datd = mysqli_query($bd, "SELECT * FROM `oaed_thea` WHERE ar_symb='$ses' AND dik_ofel=5") or die(mysqli_error($bd));
while ($rowtd = mysqli_fetch_array($datd)) {
    $of_d = $rowtd['name'];
    $am_d = $rowtd['amka'];
    $ar_d = $rowtd['epitagi'];
}

$datee = mysqli_query($bd, "SELECT * FROM `oaed_thea` WHERE ar_symb='$ses' AND dik_ofel=6") or die(mysqli_error($bd));
while ($rowte = mysqli_fetch_array($datee)) {
    $of_e = $rowte['name'];
    $am_e = $rowte['amka'];
    $ar_e = $rowte['epitagi'];
}
?>
</div></td>
</tr>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<tr>
<td height="180" valign="top">
<div align="justify" class="style15">
<table width="550" align="center">
<?php if (mysqli_num_rows($dataa) == 0) { ?>
<tr class="style16"><td height="5"></td><td></td></tr>
<?php } ?>

<?php if (mysqli_num_rows($datadi) != 0) { ?>
<tr class="style16">
<td width="5">1.</td>
<td width="250" align="center"><?php echo $ar_di; ?></td>
<td width="250"><?php echo $of_di; ?></td>
</tr>
<?php } ?>

<?php if (mysqli_num_rows($datb) == 0) { ?>
<tr class="style16"><td height="18">&nbsp;</td><td>&nbsp;</td></tr>
<?php } ?>

<?php if (mysqli_num_rows($dataa) != 0) { ?>
<tr class="style16">
<td width="5">2.</td>
<td width="250" align="center"><?php echo $ar_a; ?></td>
<td width="250"><?php echo $of_a; ?></td>
</tr>
<?php } ?>

<?php if (mysqli_num_rows($datb) != 0) { ?>
<tr class="style16">
<td width="5">3.</td>
<td width="250" align="center"><?php echo $ar_b; ?></td>
<td width="250"><?php echo $of_b; ?></td>
</tr>
<?php } ?>

<?php if (mysqli_num_rows($datc) != 0) { ?>
<tr class="style16">
<td width="5">4.</td>
<td width="250" align="center"><?php echo $ar_c; ?></td>
<td width="250"><?php echo $of_c; ?></td>
</tr>
<?php } ?>

<?php if (mysqli_num_rows($datd) != 0) { ?>
<tr class="style16">
<td width="5">5.</td>
<td width="250" align="center"><?php echo $ar_d; ?></td>
<td width="250"><?php echo $of_d; ?></td>
</tr>
<?php } ?>

<?php if (mysqli_num_rows($datee) != 0) { ?>
<tr class="style16">
<td width="5">6.</td>
<td width="250" align="center"><?php echo $ar_e; ?></td>
<td width="250"><?php echo $of_e; ?></td>
</tr>
<?php } ?>
</table>
</div>
</td>
</tr>
</table>
</body>
</html>
<?php } // Τέλος του while ?>
