<?php 
session_start();
?>
<head>
	<title>Visualsoft Office Manager - Συμβόλαια</title>
	<link href="logos/ofm1.ico" rel="shortcut icon" type="image/x-icon"> 
	<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>
<?php  
if($_SESSION['CheckPWD']==false){ header("Location: login.php"); }
	
$myTopCaption_Text="ΔΙΑΧΕΙΡΙΣΗ ΣΥΜΒΟΛΑΙΩΝ";
$MyFormName=str_replace('.php', '', basename($_SERVER['PHP_SELF']));
$MyADDFormName="symvolaia_add";
$tblName="symvolaia";
$MyIDFieldName="IDSymvolaiou";
$ListExist=true;
$prefix=$MyFormName."@";
$frmOpenNew='"'.$MyIDFieldName.'","0","'.$MyADDFormName.'",' ;
 
include 'include/top_vars.php';  
include_once 'include/header.php';
 
$simera2=date_olografos($now); 
 
?> 
<style>
.red {background: #FF5733;color:white;}
.green {background: #52BE80;color:white;}
.normal { }
</style>
 
<form id="<?php echo $MyFormName;?>" name="<?php echo $MyFormName;?>" autocomplete="off">
 <body OnLoad="document.<?php echo $MyFormName.'.'.$prefix ?>FindWhat.focus();">
 
 <div class="vsboxDetail hide1" >
	<h1> ΚΑΤΑΣΤΑΣΗ ΣΥΜΒΟΛΑΙΩΝ </h1>
 </div>
 <?php include 'include/top_grid_list_buttons.php';  ?>

<div class="scroll" style="margin-bottom:0px;padding-bottom:0px;width:100%;" > 
<div class="sticky">
  <table id="CustomerList" class="gridList" > 
   <tr  >
	<td class="r w50" >A/A<a onclick="grdsrt('IDSymvolaiou');" class="sortpic"/></td>
	<td class="c w80 hide1" >ΕΝΕΡΓΟΣ<a onclick="grdsrt('isActive');" class="sortpic"/></td>
	<td class="c w90 hide1">ΑΦΜ<a onclick="grdsrt('AFM');" class="sortpic"/></td> 
    <td>ΕΠΩΝΥΜΙΑ<a onclick="grdsrt('Eponymia');" class="sortpic"/></td>
    <td class="c w80">ΕΝΑΡΞΗ<a onclick="grdsrt('ActivateStartDate');" class="sortpic"/></td>
	<td class="c w80  hide1">ΛΗΞΗ<a onclick="grdsrt('ActivateEndDate');" class="sortpic"/></td>
	<td class="c">ΕΦΑΡΜΟΓΗ<a onclick="grdsrt('ApplicationName');" class="sortpic"/></td>
	<td class="hide1">TERMINALS <a onclick="grdsrt('Terminal');" class="sortpic"/></td>
	<td class='hide1'>ΠΑΡΑΤΗΡΗΣΕΙΣ</a></td>
  </tr> 
</table>
</div>
 
 <table class="gridListNoCaption"  > 
<?php
 $HmniaSimera= date_create('now')->format('d/m/Y'); 
 $HmniaSimeraNum=formatMyDate($HmniaSimera,"GrTo_YYYYMMDD");

#echo "HmniaSimeraNum= ". $HmniaSimeraNum;
  
 $start_date=formatMyDate($HmApo,"GrToMySql"); 
   $end_date=formatMyDate($HmEos,"GrToMySql"); 
  
    $flds="Eponymia,AFM,ApplicationName,Sxolia,Terminal";
 $filter=filter_make($flds, $FindWhat);
 $query=" SELECT * FROM ". $tblName . " " . $filter ; 
 	if($filter=='') {
		 $query.=" WHERE ActivateEndDate BETWEEN '" . $start_date . "' AND '" . $end_date . "' ";
	   }
  if($SortValue==''){$query=$query ." ORDER BY ActivateStartDate ";} else {$query=$query." ORDER BY " . $SortValue . " ";}

#echo $query ;

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

 while ($rs = mysqli_fetch_array($result)) {

$iRow +=1;
 
$IDSymvolaiou = $rs['IDSymvolaiou'];
$AFM=$rs['AFM'];
$Eponymia=$rs['Eponymia'];
$ActivateStartDate = $rs['ActivateStartDate'];
$ActivateStartDate=formatMyDate($rs['ActivateStartDate'],"MySqlToGr");
$ActivateEndDate=formatMyDate( $rs['ActivateEndDate'],"MySqlToGr");
$ActivateEndDateNum= $rs['ActivateEndDateNum'];
$ApplicationName =  $rs['ApplicationName'];
$Sxolia=$rs['Sxolia'];
$Terminal=$rs['Terminal'];
$isActive = $rs['isActive'];
$isActiveChk='unckecked';
if($isActive==-1){$isActiveChk='checked';} 
$frmOpen='"'.$MyIDFieldName.'","'.$IDSymvolaiou.'","'.$MyADDFormName.'",' ;
 
$endColorF="Normal";
$ActivateEndDateNum=formatMyDate($rs['ActivateEndDate'],"MySqlTo_YYYYMMDD");
 
if($HmniaSimeraNum>=$ActivateEndDateNum) {
	$endColorF="red";
}
$Diafora=$ActivateEndDateNum-$HmniaSimeraNum;
if($Diafora>0 && $Diafora<=10) {
	$endColorF="green";
}
#echo  $ActivateEndDateNum-$HmniaSimeraNum . "<br>";

// ========================================
//  Symvolaia List
// ========================================
  echo "<tr class='tablerowdata' onclick='javascript:OpenFormADD($frmOpen);'> ";
  echo "<td class='r w50'>$iRow</td>";
  echo "<td class='c w80 hide1'><input size ='1' type='checkbox' $isActiveChk ></td>";
  echo "<td class='c w90 hide1'>$AFM</td>";
  echo "<td>$Eponymia</td>";
  echo "<td class='c w80'>$ActivateStartDate</td>";
  echo "<td class='c w80 $endColorF hide1'>$ActivateEndDate</td>";
  echo "<td>$ApplicationName</td>";
  echo "<td class='l hide1'>$Terminal</td>";
  echo "<td class='hide1'>$Sxolia</td>";
  echo "</tr>";   
 }
 
for ($x = $iRow+1; $x <= $pgNo*$RecsPP; $x++) {
    echo "<tr class='tablerowdata' onclick='javascript:OpenFormADD($frmOpenNew);'> ";
    echo "<td class='w50'> </td> <td class='w80 hide1'> </td> <td class='w90 hide1'> </td> <td> </td>";
    echo "<td class='w80'> </td> <td class='w80 hide1'> </td> <td class='hide1'> </td>";
	echo "<td> </td> <td class='hide1'> </td>";
    echo "</tr>";
 }	
 

?>
</table>


<?php include 'include/recs_div_bottom.php'; ?>
 
</div>	
 
</body>
 
</form> 

<script type="text/javascript" src="js/mycheck.js"></script>  
<?php 
  include 'HmApoEos.php';
  include 'include/footer2020.php';
?>
 

