<?php 
session_start();
?>
 <style>
.menuBottom {margin:0px 20px 0px 0px !important; padding-bottom:1px;}
.i-mobile {width:24px !important;padding:10px 0px 10px 0px;text-align:center;font-size:20px;}
.i-mobile2 {text-align:center;font-size:18px !important;font-weight:bold;}
</style>

<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=" ΑΠΟΣΤΟΛΗ MAIL ";
$MyFormName=str_replace('.php', '', basename($_SERVER['PHP_SELF']));
$tblName='mails';
$IDcField='IDMail';
$FocusField="Hmnia";
$RequiredField="SendTo";
$CloseType="Close1";
$ReturnTo='mail_list.php';
//include 'include/Header.php';
include 'myfunctions.php';
?>
 
<html > 
	<link rel="stylesheet" type="text/css" href="css/tab2023.css"  /> 	
	<link rel="stylesheet" href="css/tab2023.css">
 
<?php
  include 'include/del_yes_no.php';
 
?>
 
<?php



//========================================
//        Patients Record Read
//========================================

if(!isset($_SESSION['MailSendError'])){
	$_SESSION['MailSendError']="";
}



$closeCap=" Επιστροφή ";

$exitStyle="style='width:120px;text-align:center;'";
$i_m2="";
$newCaption="Νέο mail";	$saveCaption="Αποστολή";$delCaption="Διαγραφή";	
$printCaption="Εκτύπωση";$exitCaption="Έξοδος";$exitStyle="style='width:60px;'"; 

if(isMobile1()){
	$newCaption="&#10011;";	$saveCaption="&#10004;";$delCaption="&#10008;";	
	$printCaption="&#128424;"; $exitCaption="&#10094;";$exitStyle="style='width:60px;'";
$i_m2="i-mobile2";
} 

$IDc=0;$IDMail=0;$IDPelati=0;
$Hmnia= date_create('now')->format('d/m/Y'); 
$HmniaDateNum=0;
$SendFrom=''; $SendTo=''; $SendToCC=''; $SendToBCC=''; $Subject='';$Message="";
$EponymiaPelati="";
 
if($conn == false){
	 echo 'Δεν υπαρχει συνδεση...<br>';
	  dbConnect();
}
	 $IDc=!isset($_COOKIE[$IDcField]) ? 0 :  gConvertField($_COOKIE[$IDcField],'0'); 
   $query="SELECT * FROM ".$tblName . " WHERE ". $IDcField . "=" . $IDc ;
 
#  echo '<br>'. $query ;
$result = mysqli_query($conn, $query);
    $rs = mysqli_fetch_assoc($result);

$IDMail = $rs['IDMail'];
$IDPelati = gConvertField($rs['IDPelati'],0);
 
$EponymiaPelati= $rs['Pelatis_Eponymia']; 
 
 
$IDc=$IDMail;
$Hmnia=formatMyDate($rs['Hmnia'],"MySqlToGr", date_create('now')->format('d/m/Y')); 
$HmniaNum= $rs['HmniaNum'] ; 
$SendTo=$rs['SendTo'];
$SendToCC=$rs['SendToCC'];
$SendToBCC=$rs['SendToBCC'];
$Subject=$rs['Subject'] . "";
$Message=$rs['Message'] . ""; 
$Attachments=$rs['Attachments'] ;
 
if($IDc==0){$LeftCap="ΑΠΟΣΤΟΛΗ ΑΛΛΗΛΟΓΡΑΦΙΑΣ";}else{$LeftCap="Mail ";}

$UpToDate=-1;
$UpToDateChk="";
if($UpToDate==-1){$UpToDateChk='checked';} 
 
// ============================
   
// ============================
$ErrorDivShow="hidden";
$ErrorDivText=$_SESSION['MailSendError'];
if(!$_SESSION['MailSendError']=="") {$ErrorDivShow="";}

$_SESSION['MailSendError']="";

// ============================
$img_file = 'C:\gcs2000\Pel2012\logos\OfficeManagerLogo.2024.png';
$imgData = base64_encode(file_get_contents($img_file));
// Format the image SRC:  data:{mime};base64,{data};
$src = 'data: '.mime_content_type($img_file).';base64,'.$imgData;
echo '<img src="'.$src.'">';

$result = @mail( "6977310562@cosmote.gr" , 'Test SMS', "aaaaa bbbbb cccc" );
 if($result) {
   echo 'Message was sent to ' . $to;
 } else {
  echo 'Not all information was submitted.';
 }
 
?> 

 <form  name="<?php echo $MyFormName;?>" id="<?php echo $MyFormName;?>" method="post" > 
 <body  OnLoad="javascript:onLoadFocus();"  >

 <div id="aa" class="vsBoxNew" style="margin:10px 20px 10px 20px;"  >
   <h1> <?php echo $LeftCap?>
		<table class="hide1" width="100%" align="center" border="0" cellspacing="0" cellpadding="0" style="margin-top:1px;">
		<tr>
			<td style="font-weight:normal;width:120px; margin-top:-24px;" align="center" class="titleRight"><?php echo 'ID: '. $IDc;?> </td>
		</tr>  
		</table>
   </h1>
 </div> 
 
 <div id="" class="vsBoxNew " style="margin:10px 20px 10px 20px; padding:20px 10px;box-shadow: 1px 3px 8px #999999 ;"> 
		<div class="row">
			<div class="col-20"><label for="Hmnia">Ημερομηνία</label></div>
			<div class="col-20">
				<div class="vscombo-div">
				  <input class="datepicker" type="text" id="Hmnia" name="Hmnia" value="<?php echo $Hmnia;?>" >
				  <a class="vscombo_date_button" name="Hmnia_Button" id="Hmnia_Button" ></a></input>
				</div>  
			</div>
			 
			<div class="col-60 r" style="position: relative; display: inline-flex;flex:right;" >
				<div style="position:absolute;top:-5;right:5;">
					<?php  input_yesno("Ενημερώθηκε", "UpToDateChk", "UpToDate", $UpToDate,"" )?> 
				</div>
			</div>
		</div>
		
		<div class="row" >
		<div class="col-20"><label for="SendTo">Παραλήπτης</label></div>
		<div class="col-10 hide1"><input type="text" id="IDPelati" name="IDPelati"  value="<?=$IDPelati;?>"></input></div>
		<div class="col-70" style="position: relative; display: inline;">
		<input type="text" id="SendTo" name="SendTo" placeholder='Πελάτης...'  onKeyUp="eponymia_upd();" value="<?= $SendTo;?>"  > 
		<a class="btnKartela" style="position:absolute;top:8;right:68;" onclick="javascript:pelatis_show();"> </a> 
		<a class="btnFind" style="position:absolute;top:8;right:40;" onclick="javascript:pelatis_select('');"> </a> 
		<a class="btnCancel" style="position:absolute;top:8;right:12;" onclick="javascript:pelatis_remove('');"> </a> 
		</input>
		</div>
		</div> 
 
		<div class="row">
			<div class="col-20"><label for="SendToCC">Κοινοποίηση</label></div>
			<div class="col-80"><input type="text" id="SendToCC" name="SendToCC" required value="<?php echo $SendToCC;?>"></div>
		</div>
		
		<div class="row">
			<div class="col-20"><label for="cboTameioCases">Θέμα</label></div>
			<div class="col-80"><input type="text" id="Subject" name="Subject" required value="<?php echo $Subject;?>"></div>
		</div>		
 
		<div class="row">
		<div class="col-20"><label for="Message">Μήνυμα</label></div>
		<div class="col-80">	
				<textarea name="Message" id="Message"  value="<?php echo $Message;?>" ><?php echo $Message;?></textarea>
		</div>
		</div>
		
 		<div <?php echo $ErrorDivShow ?> class="row">
		<div class="col-20"><label for="Message">Αποστολή</label></div>
		<div class="col-80">	
				<textarea style="color:red;" value="<?php echo $ErrorDivText;?>" ><?php echo $ErrorDivText;?></textarea>
		</div>
		</div>
 
 </div>
 
 
 <div border="0" class="menuBottom">
	<div class="col-100" style="float:right;text-align:right;">
	 <a id="btnNew" class="button blue add1 <?php echo $i_m2 ?>" > <?php echo $newCaption ?> </a> 
	 <a id="btnSend" class="button green save1 <?php echo $i_m2 ?>" onclick="javascript:SendTheMail();" > <?php echo $saveCaption ?> </a> 
	 <a id="btnDelete" class="button red delete1 <?php echo $i_m2 ?>"  > <?php echo $delCaption ?> </a> 
	 <a id="btnPrint" name="btnPrint" class="button orange <?php echo $i_m2 ?>"> <?php echo $printCaption ?> </a>
	 <a id="btnClose" name="btnClose" <?php echo $exitStyle; ?> class="button gray close1 <?php echo $i_m2 ?>"><?php echo $exitCaption;?></a>
	</div>
 </div>
 
 </body>
 
 <Div style="visibility:hidden; position:absolute; margin-left:150px; margin-top:-150px; top:-50; width:20%; " >
	  <input type="text" name="IDMail" id="IDMail" value="<?php echo $IDMail;?>"> 
	  <input type="text" name="UpToDate" id="UpToDate" value="<?php echo $UpToDate;?>"> 
	  <input type="text" name="HmniaDateNum" id="HmniaDateNum" value="<?php echo $HmniaDateNum;?>">
	  <input type="text" name="PageName" id="PageName" value="<?php echo $MyFormName.'.php';?>">
	  <input type="text" name="tblName" id="tblName" value="<?php echo $tblName;?>">
	  <input type="text" name="IDcField" id="IDcField" value="<?php echo $IDcField;?>">
	  <input type="text" name="IDc" id="IDc" value="<?php echo $IDc;?>">  
	  <input type="text" name="CloseType" id="CloseType" value="<?php echo $CloseType;?>">
 </div>	
				<!---   ΚΛΕΙΝΕΙ ΤΟ FRAME  visibility:hidden; --->
</form>

<!-- 
<div id="mpsearch" style="border:1px solid red;top:1px;min-height:200px;" ></div>
--> 
</html>  

<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 SendTheMail() {
    const form = document.getElementById('<?php echo $MyFormName;?>');
    form.addEventListener('submit', (event) => {
      event.preventDefault();
      // Perform validation and processing here
    });
	form.action="mailsend_and_save.php";
    form.submit();
  }
 
 
</script>


 