<?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="ΠΕΛΑΤΕΣ";
$MyIDFieldName="IDBook";
$MyFormName=str_replace('.php', '', basename($_SERVER['PHP_SELF']));
$MyADDFormName="";
$tblName='pelates';
$ListExist=true;
$prefix="pelates_select@";
 
$RecsPP_fld=$prefix.'cboRecPP';
$HmApoCookieName=$prefix.'HmApo';
$HmEosCookieName=$prefix.'HmEos'; 
$SortCK=$prefix.'srt';
$SortField="";

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];}

if(!isset($_COOKIE[$SortCK])) {$SortField='';} else { $SortField=$_COOKIE[$SortCK];}

$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 'myfunctions.php';

?>

<link href="logos/ApplicationLogo.png" rel="shortcut icon" type="image/x-icon"> 
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,300italic,700&subset=latin,greek,greek-ext" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Fira+Sans" rel="stylesheet"> 
<link rel="stylesheet" type="text/css" href="css/all.css">
<link rel="stylesheet" href="css/search2020.css" />
<link rel="stylesheet" href="css/vsButtons.css" />  
<link rel="stylesheet" href="css/vsFrame2015.css" type="text/css" /> 
 
<?php
app_title();
?>

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

 <div class="vsboxDetail"  >

 <h1> ΑΝΑΖΗΤΗΣΗ ΠΕΛΑΤΗ </h1>  
 <div class="sticky">
	<table border="0" class="MenuBarForGridList hideOnPrint" > 
		<tr style="padding:0px !important;">
			  <td width="50%" >
				  <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>
			<td width="40%"   ></td> 
		</tr>	  
	</table>	

 <table id="CustomerList" class="gridList"  > 
   <tr>
	<td class="r w40">A/A</td>
	<td class="c w50">ΕΝΕΡΓΟΣ</td>
	<td class="c w90">ΑΦΜ</td> 
    <td>ΕΠΩΝΥΜΙΑ</td>
	<td class="w100"> ΠΟΛΗ </td>
	<td class="c w100"> ΚΙΝΗΤΟ </td>
  </tr> 
</table>


</div  >  
 <table class="gridListNoCaption"  > 
  
<?php

   $flds="Eponymia,Poli,Kinito,Til,TilErgasias1,AFM,invAFM, Message,Sxolia";
 $filter=filter_make($flds, $FindWhat1);
  $query="SELECT * FROM $tblName " . $filter. " ORDER BY Eponymia ";
 
  $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;
 
$IDPelati= $rs['IDPelati'];
$AFM=$rs['AFM'];
$DOY=$rs['DOY'];
$Eponymia=$rs['Eponymia'];
$Poli= $rs['Poli'];
$Til= $rs['Til'];
$TilErgasias1= $rs['TilErgasias1'];
$Kinito= $rs['Kinito'];
$email = trim($rs['email']);
$Sxolia=$rs['Sxolia'];
$isActive = $rs['isActive'];
$isActiveChk='unckecked';
if($isActive==-1){$isActiveChk='checked';} 
//if($Message!==''){$BackColor="Style='background:red;color:white;'";}else{$BackColor='';} 
// ========================================
//  Pelates List
// ========================================
    echo "<tr class='tablerowdata'  onclick=\"javascript:ReturnVal($IDPelati,'$Eponymia','$AFM','$DOY','$Til','$Kinito','$email')\"> ";
    echo "<td class='r w40' >$iRow</td>";
	echo "<td class='c w50'><input size ='1' type='checkbox' $isActiveChk ></td>";
	echo "<td class='c w90'>$AFM</td>";
    echo "<td >$Eponymia</td>";
    echo "<td class='w100'>$Poli</td>";
	echo "<td class='l w100'>$Kinito</td>";
    echo "</tr>";
 } 
for ($x = $iRow+1; $x <= $pgNo*$RecsPP; $x++) {
    echo "<tr class='tablerowdata'  '> ";
    echo "<td class='r w40' ></td>";
	echo "<td class='c w50'></td>";
	echo "<td class='c w90'></td>";
    echo "<td ></td>";
    echo "<td class='w100'></td>";
	echo "<td class='l w100'></td>";
    echo "</tr>";
 }	
 ?> 

</table>
<?php include 'include/recs_no_max_div.php'; ?>
<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> 

 <table border="0" width="99%" style="margin:0px 25px 0px 0px !important; padding-bottom:1px;">
	<tr>
	 <td width="90%" align="right" style="text-align:right ;" >  </td>
		<td style=" text-align:right; ">
			<a id="btnClose" href="javascript:window.close();" style="width:120px;text-align:center;" class="button ">&nbsp;Επιστροφή&nbsp;</a>		  
		</td>
	</tr>  
 </table>
 
<Script language="JavaScript" type="text/JavaScript">
function setfocus(elem) {
 var e=document.getElementById(elem) 
 e.focus(); e.selectionStart = e.selectionEnd = e.value.length;
}

function ReturnVal(IDPelati,Eponymia,AFM,DOY,Til,Kinito,email){
  window.opener.document.getElementById("IDPelati").value = IDPelati;  
  window.opener.document.getElementById("Eponymia").value = Eponymia; 
  window.opener.document.getElementById("AFM").value = AFM;
  window.opener.document.getElementById("DOY").value = DOY;  
  window.opener.document.getElementById("Tilefono").value = Til;
  window.opener.document.getElementById("Kinito").value = Kinito; 
  window.opener.document.getElementById("email").value = email; 
  window.close();
}
</script>

<script type="text/javascript" src="js/mycheck.js"></script>  
 
 


