<?php

    function KrediKartiRezervasyonSave($ref_no,$toplam_tutar=''){

        $deg        =   substr(md5(uniqid(rand())), 0, 10);
        //if($taksit=="HH")print " ".$yaz;
        $odeme      =   "Kredi Kart";
        $deg = substr(md5(uniqid(rand())), 0, 10);

        $save = mysql_query("insert into siparis (
                            refno,
							ad,
							il,
							ilce,
							cep,
							tel,
							firma,
							email,
							adres,
							tarih,
							odeme,
							uid,
							ustsid,
							toplam_tutar
							)values(
							 '" . $ref_no . "',
							 '" .$_POST['ad'] . "',
							 '" . $_POST['il'] . "',
							 '" . $_POST['ilce'] . "',
							 '" .$_POST['telefon']. "',
							 '" .$_POST['telefon'] . "',
							 'Annex',
							 '" . $_POST['msn'] . "',
							 '" . $_POST['adres'] . "',
							 '" . time() . "',
							 '" . $odeme . "',
							 '" .$_POST['otel'] . "',
							 '" . $deg . "',
							'" . number_format($toplam_tutar,2,',','') . "')
			 ");

		if($save){
			$uid = mysql_insert_id();
		$rezervasyon =	mysql_query("insert into rezervasyon (uid,tarih,tarih2,oda,kisi,toplam_tutar,sbt,otelid,bilgi) values
			 (
			 '$uid',
			 '" . $_POST['date1'] . "',
			 '" . $_POST['date2'] . "',
			 '" . $_POST['cocuk'] . "',
			 '" . $_POST['kisiler'] . "',
			 '" .  number_format($toplam_tutar,2,',','') . "',
			 '".$deg."',
			 '" . $_POST['otel'] . "',
			 '" . $_POST['bilgin'] . "'
			 )");
			if($rezervasyon){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}

    }


    function MailGonder($ref_no,$cart_name=false,$toplam_para){

        $mail           = new PHPMailer();

        $mail->IsSMTP();
		$mail->CharSet = "UTF-8";
        $mail->From     = "smtp@exelsiorhotels.com";
        $mail->Sender   = "smtp@exelsiorhotels.com";
        $mail->FromName = "www.exelsiorhotels.com";
        $mail->Host     = "mail.exelsiorhotels.com";
        $mail->SMTPAuth = true;
        $mail->Username = "smtp@exelsiorhotels.com";
        $mail->Password = "Reservation-2016";
        $mail->WordWrap = 50;
        $mail->IsHTML(true);
        $mail->Subject  = "Exelsior Annex Rezervasyon";

        $body = "<style type='text/css'>
				<!--
				.style1 {color: #FF0000}
				-->

				</style>
<style type='text/css'>
<!--
.style12 {
	color: #FFFFFF;
	font-weight: bold;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
}
.style3 {
	font-size: 12px;
	font-family: Arial, Helvetica, sans-serif;
	color: #993300;
	font-weight: bold;
}
.icerikYazi{
	font-family:Tahoma;
	color:#333333;
	font-size:13px;
}
.metin_beyaz{
font-family:arial;
font-size:12px;
color:#ffffff;
}
-->
</style>
<table width='398' border='0' align='center' cellpadding='2' cellspacing='2' bgcolor='#FFFFFF' class='style3' style='border:1px solid #CCCCCC'>
  <tr align='center' bgcolor='#E59E20'>
    <td height='21' colspan='2' bgcolor='#00612e'> <span class='style12'>Exelsior Annex Reservation</span></td>
  </tr>
  <tr bgcolor='#FFFFCC'>
    <td height='9' align='left' valign='top' bgcolor='#FFFFFF'>Hotel Name</td>
    <td height='9' align='left' valign='top' bgcolor='#FFFFFF'>Exelsior Annex</td>
  </tr>

  <tr bgcolor='#FFFFCC'>
    <td height='9' align='left' valign='top' bgcolor='#FFFFFF'>Bank Ref No</td>
    <td width='262' height='9' align='left' valign='top' bgcolor='#FFFFFF'>" . $ref_no . "</td>
  </tr>

  <tr bgcolor='#FFFFCC'>
    <td height='9' align='left' valign='top' bgcolor='#FFFFFF'>Ref No</td>
    <td width='262' height='9' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['reservation_no'] . "</td>
  </tr>

  <tr bgcolor='#FFFFCC'>
    <td height='9' align='left' valign='top' bgcolor='#FFFFFF'>First /Last Name	</td>
    <td width='262' height='9' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['ad'] . "</td>
  </tr>
  <tr bgcolor='#FFFFCC'>
    <td height='9' align='left' valign='top' bgcolor='#FFFFFF'>Check-in<br>Check-out </td>
    <td height='9' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['date1'] . " <br> " . $_POST['date2'] . "</td>
  </tr>
  <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>Country</td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['ulke'] . "</td>
  </tr>
  <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>City</td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['il'] . "</td>
  </tr>
    <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'> State/Province </td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['ilce'] . "</td>
  </tr>

      <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'> Card Name </td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" .$cart_name . "</td>
  </tr>
  <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'> Phone </td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['telefon'] . "</td>
  </tr>


   <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'> Adress </td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['adres'] . "</td>
  </tr>


   <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>Request </td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['istek'] . "</td>
  </tr>

    <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'> E-Mail </td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['msn'] . "</td>
  </tr>


   <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'> Room Type </td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['roomType'] . "</td>
  </tr>

   <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'> Room Amount </td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" . $_POST['room_amount'] . "</td>
  </tr>

   <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'> Adult </td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>" .$_POST['kisiler'] . "</td>
  </tr>

  <tr bgcolor='#FFFFCC'>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>Price</td>
    <td height='20' align='left' valign='top' bgcolor='#FFFFFF'>".$toplam_para." TRY</td>
  </tr>

</table>

	</div><br><font face=\"Tahoma\" style=\"font-size: 9pt\">This Message Sender : <b>" . $_SERVER['REMOTE_ADDR'] . "</font></b>\n";


        $textBody = "This Mail Nothing View,Please Change To Mail Setting to View HTML..";

        $mail->Body = $body;
        $mail->AltBody = $textBody;
        $mail->AddAddress("reservation@exelsiorhotels.com");
        $mail->AddAddress("info@exelsiorhotels.com");
        $mail->AddAddress($_POST['msn']);

        if ($mail->Send()){
            $mail->ClearAddresses();
            $mail->ClearAttachments();
            return true;
        }else{
            $mail->ClearAddresses();
            $mail->ClearAttachments();
            return false;
        }


    }
