<?php 
session_start();
if($_SESSION['CheckPWD']==false){ header("Location: login.php"); }
	
$myTopCaption_Text="ΗΜΕΡΟΛΟΓΙΟ © 2020";
$MyFormName=str_replace('.php', '', basename($_SERVER['PHP_SELF']));
$MyADDFormName="CalendarADD";$w=850;$h=480;
$MyIDFieldName="IDCalendar";
$tblName='calendar';
$ListExist=true;
$prefix="CalendarList_";
 
$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 '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" /> 
<head>
	<title>vs Contracts</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="">
</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 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>	

<?php 
     echo htmlentities($_SERVER['PHP_SELF']);
     echo "<br>";
     echo date("Y",time());
     echo "<br>";            
     $year =  2020; //date("Y",time()); 
     $month = 12 ; //date("m",time());                             
     echo "Ημέρες Μήνα: " . date('t',strtotime($year.'-'.$month.'-01')). "<br>";
     echo "Τελ. Δευτέρα: " . strtotime("last Monday")  . "<br>";

	
    echo "<br>";                            
    echo "==== > ". date('N',strtotime($year.'-'.$month.'-'.'30'));
    echo "<br>";    
    echo date('N',strtotime($year.'-'.$month.'-01'));
     
	                      
?>
     
 
<div class="sticky">
  <table class="gridList"  > 
   <tr>
	<td class="c1 w80"> ΩΡΑ </td>
	<td class="c1"> ΔΕΥΤΕΡΑ </td>
	<td class="c1"> ΤΡΙΤΗ </td>
	<td class="c1"> ΤΕΤΑΡΤΗ </td> 
	<td class="c1"> ΠΕΜΠΤΗ </td> 
	<td class="c1"> ΠΑΡΑΣΚΕΥΗ </td> 
	<td class="c1"> ΣΑΒΒΑΤΟ </td> 
	<td class="c1"> ΚΥΡΙΑΚΗ </td> 	
  </tr> 
</table>
</div>
 
 <table class="gridListNoCaption"  > 
<?php
 
 $start_date=formatMyDate($HmApo,"GrToMySql"); 
  $end_date=formatMyDate($HmEos,"GrToMySql"); 
 
      $flds="Appointment,Topos";
   $filter=filter_make($flds, $FindWhat1);
    $query=" SELECT * FROM ". $tblName . " " . $filter ; 
 
	if($filter==""){
	   $query.=" WHERE Hmnia BETWEEN '" . $start_date . "' AND '" . $end_date . "' ";
	}
	   $query.=" ORDER BY HmEnarxis, OraEnarxis ";

//echo date('d/m/Y',strtotime("-1 years")) . "<br>";
//echo  $query;
// $now=date_create();
//$simera2=date_olografos($now); 
 
// 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;
 
$IDCalendar = $rs['IDCalendar'];
$HmEnarxis=formatMyDate($rs['HmEnarxis'],"MySqlToGr");
$HmLixis=formatMyDate( $rs['HmLixis'],"MySqlToGr");

$OraEnarxis=$rs['OraLixis'];
$OraLixis=$rs['HmLixis'];

$OraEnarxis = $rs['OraEnarxis'];
$ActivateStartDate=formatMyDate($rs['ActivateStartDate'],"MySqlToGr");
$ActivateEndDate=formatMyDate( $rs['ActivateEndDate'],"MySqlToGr");
$RemindOraSeLepta =  $rs['RemindOraSeLepta'];
$RemindTimeBefore=$rs['RemindTimeBefore'];
$RemindType = $rs['RemindType'];
$Appointment = $rs['Appointment'];
$RemindType = $rs['RemindType'];
$RemindType = $rs['RemindType'];

$Finishing=$rs['Finishing'];

$Finishing='unckecked';
if($isActive==-1){$isActiveChk='checked';} 
$OraLabel=(7+$iRow) . ':00'  ;

// ========================================
//  Calendar List
// ========================================
 
    echo "<tr class='tablerowdata' onclick='javascript:OpenFormADD_onWin($IDCalendar);'> ";
    echo "<td class='c1 w80' >$OraLabel</td>";
	echo "<td><input size ='1' type='checkbox' $isActiveChk ></td>";
	echo "<td>$AFM</td>";
    echo "<td>$Eponymia</td>";
    echo "<td>$ActivateStartDate</td>";
	echo "<td>$ActivateEndDate</td>";
	echo "<td>$ApplicationName</td>";
	echo "<td>$Sxolia</td>";
    echo "</tr>";   
 }
 
for ($x = $iRow+1; $x <= $pgNo*$RecsPP; $x++) {
    echo "<tr class='tablerowdata' style='height:80px;'  onclick='javascript:OpenFormADD_onWin(0);'> ";
    echo "<td class='w80'> </td> <td> </td> <td> </td> <td> </td>";
    echo "<td> </td> <td> </td> <td> </td> <td> </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 'HmApoEos.php';
  include 'js\vsFunctions.js';
  if ($ListExist==true){ include 'js\RecsNextPrv.js'; }
  include 'include\Footer2020.php';
?>
 



