<?php 
session_start();
if($_SESSION['CheckPWD']==false){ header("Location: login.php"); }
	
$myTopCaption_Text="ΗΜΕΡΟΛΟΓΙΟ © 2020";
$MyFormName=str_replace('.php', '', basename($_SERVER['PHP_SELF']));
$MyADDFormName="notesADD";$w=800;$h=400;
$MyIDFieldName="IDNote";
$tblName='notes';
$ListExist=true;
$prefix="notesList_";
 
$RecsPP_fld=$prefix.'RecsPP';
$HmApoCookieName=$prefix.'HmApo';
$HmEosCookieName=$prefix.'HmEos'; 
if(! isset($_COOKIE[$RecsPP_fld]) ) {$RecsPP=10;} else { $RecsPP=$_COOKIE[$RecsPP_fld];}
if(! isset($_COOKIE[$HmApoCookieName])) {$HmApo= date_create('now')->format('d/m/Y');} else { $HmApo=$_COOKIE[$HmApoCookieName];} 
if(! isset($_COOKIE[$HmEosCookieName])) {$HmEos=date_create('now')->format('d/m/Y'); } else { $HmEos=$_COOKIE[$HmEosCookieName];}
 
$FindWhat1 = trim(filter_input(INPUT_GET, $prefix.'FindWhat', FILTER_SANITIZE_SPECIAL_CHARS));
     $pgNo = trim(filter_input(INPUT_GET, $prefix.'pgNo', FILTER_SANITIZE_SPECIAL_CHARS));
 	  if(is_numeric($pgNo)){	 } else { $pgNo=1;} 

include 'include\Header.php';	 
#include 'css/my_menu_area.php';
include 'myFunctions.php';
include '_RecsNoMax_Div.php';

$now = new DateTime();
$now= $now->format('d/m/Y'); 

$simera2=date_olografos($now); 
 
?> 
  <link href="logos/ApplicationLogo.png" rel="shortcut icon" type="image/x-icon"> 
  <link rel="stylesheet" href="css/search2020.css" />
  <link rel="stylesheet" href="css/vsButtons.css" /> 
  <link rel="stylesheet" href="css/style2020.css" /> 
<head>
	<title>vs Contracts</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="">
</head>

  <section class="settings"  >
    <header class="settings-header">
      <a href="index.html" class="icon-prev">Previous</a>
      <a href="index.html" class="icon-close">Close</a>
      <h2>Settings</h2>
    </header>
	
    <form action="index.html" method="post" class="settings-form">
      <h3>General</h3>
      <label class="icon-wifi">
        <input type="checkbox" name="wifi" value="1" checked>
        <span class="settings-switch"><span class="settings-switch-handle"></span></span>
        <strong>Wi-Fi</strong>
        Wireless Local Area Network
      </label>
      <label class="icon-gps">
        <input type="checkbox" name="gps" value="1">
        <span class="settings-switch"><span class="settings-switch-handle"></span></span>
        <strong>Location Services</strong>
        Global Positioning System
      </label>
    </form>

 </section>
 
  <section class="settings"  > 
<form id="<?php echo $MyFormName;?>" name="<?php echo $MyFormName;?>">
 <body OnLoad="document.<?php echo $MyFormName.'.'.$prefix ?>FindWhat.focus();">

  <header class="settings-header">
		<a href="index.html" class="icon-prev">Previous</a>
		<a href="index.html" class="icon-close">Close</a> 
		<h2 id="hmnia_caption"> <?php echo $simera2 ?> </h2>
  </header>
	<h3> 
	<table class="hideOnPrint MenuBarForGridList" border="0"  > 
		<tr  style="valign:center;" >
			<td width="100%" style="padding-right:4px; display: flex;" >	
			  <a href="javascript:OpenFormADD_onWin(0);" class="button new">Νέα Εγγραφή</a>
			  <a href="javascript:refresh('<?php echo $prefix ?>');" class="button refresh">Ανανέωση</a>
			  <a href="javascript:window.print();" title=" Εκτύπωση Κατάστασης " class="button print">Εκτύπωση</a> 
 
				<div class="btn-vs-group" style="margin-left:10px;">
				  <a id="calendar_day" href="#" class="button2" title=" Ημέρα " ></a>
				  <a id="calendar_week" href="#" class="button2" title=" Εβδομάδα "></a>
				  <a id="calendar_month" href="#" class="button2" title=" Μήνας "></a>
				  <a id="calendar_prv" href="#" class="button2" title=" Προηγούμενη Ημέρα "></a>
				    <?php 
						HmApoEosButtonMake( $HmApo,  $HmEos);
					?>
				  <a id="calendar_next" href="#" class="button2" title=" Επόμενη Ημέρα "></a>
				  <a id="calendar_select" href="#" class="button2" title=" Επιλογή Περιόδου "></a>
				</div>				
				</td>
				<td style=" width:25% ;">
				  <div class="search">
					  <input type="text" name="<?php echo $prefix ?>FindWhat" id="<?php echo $prefix ?>FindWhat" class="searchTerm"   placeholder="Αναζήτηση..." value="<?php echo $FindWhat1;?>"  onfocus="gotoEndOfText(this);"  >
					  <button class="searchButton"  onclick="submitForm('<?php echo $prefix ?>');" ></button >
				  </div>
			    </td>
		</tr>	  
	</table>	
	
<div class="sticky">
  <table class="gridList"  > 
   <tr>
	<td class="c1 w40">AA</td>
	<td class="c1 w100"> ΗΜΕΡΟΜΗΝΙΑ</td>
	<td class="c1"> ΑΙΤΙΟΛΟΓΙΑ</td>
	<td class="c1 w200"> ΣΗΜΕΙΩΣΕΙΣ</td> 
	<td class="c1 w40"> ΟΚ</td> 
  </tr> 
</table>
</div>
 
 <table class="gridListNoCaption"  > 
<?php
 
 $start_date=formatMyDate($HmApo,"GrToMySql"); 
  $end_date=formatMyDate($HmEos,"GrToMySql"); 
 
 $query=" SELECT * FROM ". $tblName .
		" WHERE Concat(Aitiologia, ' ', IFNULL(Sxolia,'')) LIKE '%" . $FindWhat1 ."%'" . 
		" AND Hmnia BETWEEN '" . $start_date . "' AND '" . $end_date . "' " .
		" ORDER BY Hmnia ";
 
// echo ('<script> document.getElementById("hmnia_caption").innerHTML="'.$simera2.'"</script>') ;

  $num_rows=RecordsCount($conn,$query);
   $FromRec=($pgNo-1)*$RecsPP ;
     $pgMax=intval($num_rows/$RecsPP)+1;
    $query = $query .  ' LIMIT ' .$FromRec . ', ' . $RecsPP ;

// echo  $query;
//echo "aaaaa " . $_SESSION['inValues']['DB_SERVER'] ; //['DB_SERVER'];

   $result = mysqli_query($conn, $query);
 
 echo ('<script> document.getElementById("'.$RecNo_fld.'").value='.$num_rows.'</script>') ;
 echo ('<script> document.getElementById("'.$pgNo_fld.'").value='.$pgNo.'</script>') ;
 echo ('<script> document.getElementById("'.$pgMax_fld.'").value='.$pgMax.'</script>') ;
 
$iRow=($pgNo-1)*$RecsPP;

 while ($rs = mysqli_fetch_array($result)) {
 //$rs = mb_convert_encoding($rs, 'greek' );
$iRow +=1;
 
$IDNote = $rs['IDNote'];
$Hmnia=formatMyDate($rs['Hmnia'],"MySqlToGr");
$Aitiologia = $rs['Aitiologia'];
$isDone=$rs['isDone'];
$Sxolia = $rs['Sxolia'];

$isDoneChk='unckecked';
if($isDone==-1){$isDoneChk='checked';} 

// ========================================
//  notes List
// ========================================
 
    echo "<tr class='tablerowdata' onclick='javascript:OpenFormADD_onWin($IDNote);'> ";
    echo "<td class='c1 w40'>$iRow</td>";
	echo "<td class='c1 w100'>$Hmnia</td>";
    echo "<td>$Aitiologia</td>";
	echo "<td class='w200'>$Sxolia</td>";
	echo "<td class='c1 w40'><input size ='1' type='checkbox' $isDoneChk ></td>";	
    echo "</tr>";   
 }
 
for ($x = $iRow+1; $x <= $pgNo*$RecsPP; $x++) {
    echo "<tr class='tablerowdata'  onclick='javascript:OpenFormADD_onWin(0);'> ";
    echo "<td class='c1 w40' > </td>";
	echo "<td class='c1 w100'></td>";
    echo "<td></td>";
	echo "<td class='w200'> </td>";
    echo "<td class='w40'> </td>";	
    echo "</tr>";
 }	
 

?>
</table>

<table class="gridListFooter"   border="0"  cellspacing="0" cellpadding="0" align="center" valign="bottom">
	<tr>
		<td align="left" width="100px" class="styleRecs">&nbsp; Εγγραφές/Σελ:</td>
		<td align="left" width="60px"><?php  cboRecsPerPage($RecsPP,  $prefix);?> </td>
		<td align="center" class="styleRecs">Βρέθηκαν <?php echo $num_rows;?> Eγγραφές</td>
		<td align='right' width="220px"><?php ButtonsNavigation($frn, $pgNo, $pgMax, $prefix);?></td>
	</tr>
</table>
</h3>
  </section> 
	
 
</body>
 
</form> 
 
<?php 
  include 'HmApoEos.php';
  include 'js\vsFunctions.js';
  if ($ListExist==true){ include 'js\RecsNextPrv.js'; }
  include 'include\Footer2020.php';
?>
 



