<?php 
session_start();
if($_SESSION['CheckPWD']==false){ header("Location: login.php"); }

error_reporting(E_ALL); ini_set('display_errors', 1);

$myTopCaption_Text="ΣΗΜΕΙΩΣΕΙΣ ";
$MyFormName=str_replace('.php', '', basename($_SERVER['PHP_SELF']));
$MyADDFormName="notesADD";$w=800;$h=400;
$MyIDFieldName="IDNote";
$tblName='notes';
$ListExist=true;
$prefix="notesList_";
$FocusField=$prefix."FindWhat";
$IDcField="";
$RequiredField="";
 
$RecsPP_fld=$prefix.'RecsPP';
$chk_all_fld=$prefix.'isDoneCheck';
 
if(!isset($_COOKIE[$RecsPP_fld]) ) {$RecsPP=10;} else { $RecsPP=$_COOKIE[$RecsPP_fld];}
if(!isset($_COOKIE[$chk_all_fld]) ) {$chk_all_value="checked";} else { $chk_all_value=$_COOKIE[$chk_all_fld];} 
 
$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;} 
 

 
//echo " ********* " . $Periodos . " // $HmApoCookieName: " . $HmApo . " , $HmEosCookieName: " . $HmEos;

include_once 'include\Header.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" type="text/css" href="css/radioButtonsPeriod2.css" /> 
<link rel="stylesheet" type="text/css" href="css/YesNo.css" /> 
<link rel="stylesheet" href="css/checkbox/chkBoxStyle4.css">
<head>
 
	<title>vs Contracts</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="">
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
 
</head>

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

 <div class="vsboxDetail"  style="padding-bottom:0px;" >
 <h1 id="hmnia_caption"> <?php echo $simera2 ?> </h1>
   
	<table border="0" class="MenuBarForGridList hideOnPrint" > 
		<tr height="34px" 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> 
 
				<label class="mychk_container" style="height:30px;"> Εκκρεμή μόνο  
				  <input id="isDoneCheck" name="isDoneCheck" type="checkbox" <?php echo $chk_all_value ?>  onclick="javascript:chk_all_upd('<?php echo $MyFormName; ?>', this);" >
				  <span class="checkmark"></span>
				</label>
			  
		 </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="c w40">AA</td>
	<td class="c w100"> ΗΜΕΡΟΜΗΝΙΑ</td>
	<td class="c"> ΑΙΤΙΟΛΟΓΙΑ</td>
	<td class="c w200"> ΣΗΜΕΙΩΣΕΙΣ</td> 
	<td class="c w40"> ΟΚ</td> 
   </tr> 
  </table>
</div>
 
 <table class="gridListNoCaption"  > 
<?php
 
   $flds="Aitiologia,Sxolia ";
 $filter=filter_make($flds, $FindWhat1);
 $query=" SELECT * FROM ". $tblName . " " . $filter ; 
 	if($filter=='') {
      if($chk_all_value=='checked') { 		
			$query.=" WHERE isDone=0 ";}
 	   }
		 $query.=" ORDER BY Hmnia desc";
#echo $query;

// 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 ;
 
   $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='r w40'>$iRow</td>";
	echo "<td class='c w100'>$Hmnia</td>";
    echo "<td>$Aitiologia</td>";
	echo "<td class='w200'>$Sxolia</td>";
	echo "<td class='c 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='c w40' > </td>";
	echo "<td class='c 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($MyFormName, $pgNo, $pgMax, $prefix);?></td>
	</tr>
</table>
 
</div>	
 
</body>
 
</form> 
 
<?php 
 
  include 'js\vsFunctions.js';
  if ($ListExist==true){ include 'js\RecsNextPrv.js'; }
  include_once 'include\Footer2020.php';
?>
 
<script language="JavaScript" type="text/JavaScript">

function chk_all_upd(myFrm, c){
	
var fileName = location.pathname.split("/").slice(-1);

// alert(fileName);

 if(c.checked){ var chk_val="checked";}else{var chk_val="unchecked";}
	document.cookie =  '<?php echo $chk_all_fld?>=' + escape(chk_val);
	//document.location.href = myFrm+".php";
	document.location.href =fileName;
 }
</script>



