<?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");}

$tblName='symvolaia';
$FocusField='btnClose'; 
// $PageName= basename($_SERVER['PHP_SELF']);
$MyFormName=str_replace('.php', '', basename($_SERVER['PHP_SELF']));
$RequiredField="Eponymia";
$myTopCaption_Text="ΣΥΜΒΟΛΑΙΑ";
$closeCap=" Επιστροφή ";
$IDcField="IDSymvolaiou";
$CloseType="GoBack";
include 'include/header.php';	
 
//========================================
 
# echo "<br><br>======>>>>>>> Session IdSymvolaiou: " .$_SESSION['IDSymvolaiou'] ;
# print_r($_SESSION); 

$IDSymvolaiou = 0;$IDc = 0;$IDPelati = 0;$IDApp= 0;
$EponymiaPelati='';$Eponymia='';$AFM='';$Tilefono='';$Kinito='';$email='';
$ApplicationName='';
$ApplicationCustomerVer='';
$SerialNo='';$License='';;$ActivateEndDate="";
$ActivateStartDateNum=0;$ActivateEndDateNum=0;$ActivateUses=0;$isActive=0;$Message='';$Sxolia='' ;
$isActiveChk='unckecked';

$HmEggrafis= date_create('now')->format('d/m/Y'); 
// $ActivateStartDate=formatMyDate(date(),"MySqlToGr")

if($conn == false){
	 echo 'Δεν υπαρχει συνδεση...<br>';
	// dbConnect();
}
#   $IDc = trim(filter_input(INPUT_GET, 'IDc', FILTER_SANITIZE_SPECIAL_CHARS));
   $IDc = gConvertField($_COOKIE['IDSymvolaiou'], '0');
 $query = "SELECT * FROM symvolaia WHERE IDSymvolaiou=" . $IDc ;
$result = mysqli_query($conn, $query);
    $rs = mysqli_fetch_assoc($result);

$IDSymvolaiou = gConvertField($rs['IDSymvolaiou'],0);
$IDc =$IDSymvolaiou ;
$IDPelati=gConvertField($rs['IDPelati'],0);
$IDApp=gConvertField($rs['IDApp'],0);
$EponymiaPelati=$rs['Eponymia'];
$Eponymia=$EponymiaPelati;
$AFM=$rs['AFM'];$DOY=$rs['DOY'];
$Tilefono=$rs['Tilefono']; $Kinito=$rs['Kinito']; $email=$rs['email'];
$ApplicationName=$rs['ApplicationName'];$ApplicationCustomerVer=$rs['ApplicationCustomerVer'];
$SerialNo=$rs['SerialNo']; $License=$rs['LicenseNo'];
$HmEggrafis=formatMyDate($rs['HmEggrafis'],"MySqlToGr");
$ActivateStartDate=formatMyDate($rs['ActivateStartDate'],"MySqlToGr");
$ActivateEndDate=formatMyDate( $rs['ActivateEndDate'],"MySqlToGr");
$ActivateStartDateNum = $rs['ActivateStartDateNum'];
$ActivateEndDateNum = $rs['ActivateEndDateNum'];
$ActivateUses=$rs['ActivateUses'];
$isActive=$rs['isActive'];
$Terminal=$rs['Terminal'];
$Sxolia=$rs['Sxolia']  ;

if(RecordsCount($conn, $query)==0) {
	$HmEggrafis= date_create('now')->format('d/m/Y'); 
	$ActivateStartDate=$HmEggrafis;
	$ActivateEndDate=formatMyDate( date('Y-m-d', strtotime('+1 year')),"MySqlToGr");
	$ActivateStartDateNum =formatMyDate($ActivateStartDate,"GrTo_YYYYMMDD");
	$ActivateEndDateNum =formatMyDate($ActivateEndDate,"GrTo_YYYYMMDD");
	$ActivateUses=120;
	$License=1;
	$isActive=-1;
}

$isActiveChk='unckecked';
if($isActive==-1){$isActiveChk='checked';} 
 
// ============================
         $nn=0;
// ============================
include 'include/buttons_bar_top.php';  
?> 
<html > 
 
<form name="<?= $MyFormName;?>" id="<?= $MyFormName;?>" method="post" action=""> 
 <body  OnLoad="javascript:onLoadFocus();"  >
 
 <div id="block_container" > 
 <div id="bloc1" class="fieldset2  " > 
	<h1>ΣΤΟΙΧΕΙΑ ΠΕΛΑΤΗ</h1> 

	<div class="row"  >
		<div class="col-20"><label class="b" for="EponymiaPelati">Επωνυμία</label></div>
		<div class="col-10 hide1"><input type="text" id="IDPelati" name="IDPelati"  value="<?=$IDPelati;?>"></div>
		<div class="col-70" style="position: relative; display: inline;">
		<input type="text" id="EponymiaPelati" name="EponymiaPelati" required placeholder='Πελάτης...'  onKeyUp="eponymia_upd();" value="<?= $EponymiaPelati;?>"  > 
		<a class="btnKartela" style="position:absolute;top:8;right:78;" onclick="javascript:pelatis_show();"> </a> </input>
		<a class="btnFind" style="position:absolute;top:8;right:44;" onclick="javascript:pelatis_select('');"> </a> </input>
		<a class="btnCancel" style="position:absolute;top:8;right:12;" onclick="javascript:pelatis_remove('');"> </a> </input>
		</input>
		</div>	
	</div>
	
	<div class="row" >
			<?php input_field_2080('20','20','ΑΦΜ', 'AFM', $AFM, false); ?>
			<?php input_field_2080('20','40','ΔΟΥ', 'DOY', $DOY, false); ?>
	</div>	
 
	<div class="row"  >
		<div class="col-20"><label for="Tilefono"><a class="phone"></a> Τηλέφωνο</label></div>
		<div class="col-30"><input type="text" id="Tilefono" name="Tilefono" value="<?= $Tilefono;?>"></div>
		<div class="col-15"><label for="Kinito">Κινητό</label></div>
		<div class="col-35"><input type="text" id="Kinito" name="Kinito" value="<?= $Kinito;?>"></div>
	</div>		
	<div class="row">	
		<div class="col-20"><label for="email"><a class="email"></a> email</label></div>
		<div class="col-80"><input type="text" id="email" name="email" value="<?= $email;?>"></div>
	</div>	

	<div class="row">
		<div class="col-20"><label for="Tilefono">Τερματικά</label></div>
		<div class="col-80"><textarea id="Terminal" name="Terminal" style="font-size:0.8em; resize:none; min-height:60px;max-height: 100%;padding:10px;"  value="<?= $Terminal;?>" ><?= $Terminal;?></textarea></div>
	</div>	
 
	<div class="row">
		<div class="col-20"><label for="HmEggrafis">1ο Συμβόλαιο</label></div>
		<div class="col-30">
			<div class="vscombo-div">
			 <input class="datepicker" type="text" id="HmEggrafis" name="HmEggrafis" required value="<?= $HmEggrafis;?>" />
			 <a class="vscombo_date_button" name="Hmnia_Button1" id="Hmnia_Button1" ></a></input>
			</div>
		</div>	
 
	</div>	
	
</div>

 		<!-- =============================== basika stoixeia part2 =======================-->
 <div id="bloc2" class="fieldset2 "  > 
	<h1>ΣΤΟΙΧΕΙΑ ΕΦΑΡΜΟΓΗΣ</h1> 
	
		<div class="row">
		<div class="col-20"><label class="b" for="cboApplicationName">Εφαρμογή</label></div>
		<div class="col-10 hide1"><input type="text" id="IDApp" name="IDApp"  value="<?= $IDApp;?>"></div>
		<div class="col-70">
				<select id="cboApplicationName" name="cboApplicationName" data-size="10" required title="Επιλογή εφαρμογής..." onclick="javascript:comboChange(this,'ApplicationName','IDApp');" style="margin:3px 0 2px 0;"> 
					<?php AppsComboBoxMake($conn, $ApplicationName); ?>
				</select>
		</div>
		</div>
	
	<div class="row">
		<div class="col-20"><label for="ActivateStartDate">Έναρξη</label></div>
		<div class="col-30">
			<div class="vscombo-div">
			 <input class="datepicker" type="text" id="ActivateStartDate" name="ActivateStartDate" required value="<?= $ActivateStartDate;?>" />
			 <a class="vscombo_date_button" name="Hmnia_Button1" id="Hmnia_Button1" ></a></input>
			</div>
		</div>
		
		<div class="col-20"><label for="ActivateEndDate">Λήξη</label></div>
		<div class="col-30">
			<div class="vscombo-div">
			  <input class="datepicker" type="text" id="ActivateEndDate" name="ActivateEndDate" required value="<?= $ActivateEndDate;?>" />
			  <a class="vscombo_date_button" name="Hmnia_Button" id="Hmnia_Button" ></a></input>
			</div> 
		</div>		
	</div>	
	
	<div class="row">
		<div class="col-20"><label for="ApplicationCustomerVer">Έκδοση</label></div>
		<div class="col-30"><input type="text" id="ApplicationCustomerVer" name="ApplicationCustomerVer" value="<?= $ApplicationCustomerVer;?>"></div>
		<div class="col-10"><label for="ActivateUses">Χρήσεις</label></div>
		<div class="col-40"><input type="text" id="ActivateUses" name="ActivateUses" value="<?= $ActivateUses;?>"></div>
	</div>
	
	<div class="row">
		<div class="col-20"><label for="SerialNo">Serial No</label></div>
		<div class="col-50"><input type="text" id="SerialNo" name="SerialNo" value="<?= $SerialNo;?>"></div>
		<div class="col-10"><label for="License">Άδειες</label></div>
		<div class="col-20"><input type="text" id="License" name="License" value="<?= $License;?>"></div>
	</div>
 	<div class="row">
		<div class="col-20"><label for="isActiveChk">Συμβόλαιο Ενεργό</label></div>
		<div class="col-80">	
				<?php  input_yesno_only("Εφαρμογή Ενεργή", "isActiveChk", "isActive", $isActive,"" )?> 
		</div>
	</div>	
	<div class="row">
		<div class="col-20"><label for="Sxolia">Σημειώσεις-Παρατηρήσεις</label></div>
		<div class="col-80">
		<textarea name="Sxolia" id="Sxolia" style="font-size:0.9em; resize:none; min-height:140px;max-height: 100%;padding:10px;"  value="<?= $Sxolia;?>" ><?= $Sxolia;?></textarea>
		</div>
	</div>
 
 

 
 <br>
</div>
</div>        
</body>

 
<?php
 # include 'include/buttons_bar_down.php';
?>

	 <Div style="visibility:hidden;  position:absolute; margin-left:150px; margin-top:-500; top:50; width:15%; float:inline;" >
		  <input type="text" name="IDSymvolaiou" id="IDSymvolaiou"   value="<?= $IDSymvolaiou;?>">
		  <input type="text" name="Eponymia" id="Eponymia" value="<?= $Eponymia;?>">  
		  <input type="text" name="ApplicationName" id="ApplicationName" value="<?= $ApplicationName;?>">
		  <input type="text" name="ActivateStartDateNum" id="ActivateStartDateNum" value="<?= $ActivateStartDateNum;?>">
		  <input type="text" name="ActivateEndDateNum" id="ActivateEndDateNum" value="<?= $ActivateEndDateNum;?>">
		  <input type="text" name="Message" id="Message" value="<?= $Message;?>">
		  <input type="text" name="isActive" id="isActive" value="<?= $isActive;?>">
		  <input type="text" name="PageName" id="PageName" value="<?= $MyFormName.'.php';?>">
		  <input type="text" name="tblName" id="tblName" value="<?= $tblName;?>">
		  <input type="text" name="IDcField" id="IDcField" value="<?= $IDcField;?>">
		  <input type="text" name="IDc" id="IDc" value="<?= $IDc;?>">
		  <input type="text" name="CloseType" id="CloseType" value="<?= $CloseType;?>">
	 </div>	
</form>

<?php
  include 'include/del_yes_no.php';
    
?> 

<script language="JavaScript" type="text/JavaScript">

  var ep = document.getElementById("Eponymia");
ep.addEventListener("keypress", function(event) {
  if (event.key === 'Enter') {
	   event.preventDefault(); 
	   var fw="?pelates_select@FindWhat="+ep.value;
       cbo_select('pelates',fw);
   }
});
 
function myBlurFunction() {
   alert("Δεν έχει γίνει αποθήκευση της καρτέλας. Να γίνει αποθήκευση της καρτέλλας; ");
}
 
function HmniaCheck(e){
 	//var hm1=document.getElementById("ActivateStartDate").value;
	var d0 = e.value.split('/');
	var myNum= pad(d0[2],4) + pad(d0[1],2)  + pad(d0[0],2) ; 
	var mySqlDate = d0[2]+"/"+d0[1]+"/"+d0[0];
	var myJvDate  = d0[1]+"/"+d0[0]+"/"+d0[2];
	//var myEndDate=d0[0] +"/"+d0[1] +"/"+ YearEnd.toString();
	var newDate = new Date(mySqlDate);	 
	var month = newDate.getMonth() + 1;
	var day = newDate.getDate(); 
	var year = newDate.getFullYear()+1;
	var endDate=pad(day,2) + "/" + pad(month,2) + "/" + pad(year,4);
   // var endDateNum=pad(year,4)+ pad(month,2)+pad(day,2);
 
	if(isValidDate(myJvDate)){
		document.getElementById(e.name+"Num").value=myNum;
		document.getElementById("ActivateEndDate").value=endDate;
	//	document.getElementById("ActivateEndDateNum").value=endDateNum;
		}else{
		alert("Λάθος ημερομηνία..."); 
		e.focus();
		}	   
}	

 
</script>
 
<script type="text/javascript" src="js/mycheck.js"></script>
<script type="text/javascript" src="js/datepicker.js"></script>  
<script language="JavaScript" type="text/JavaScript">
function pel_upd(){ pelatis_update(
document.getElementById("IDPelati").value);
eponymia_upd();
}

function eponymia_upd(){
 document.getElementById("Eponymia").value=document.getElementById("EponymiaPelati").value; 
}

</script>
<?php 
 include 'include/footer2020.php';
?> 
</html>

 
 