<?php
require_once("Classes/initializer.php");

//Getting data
 $DataPassed = unserialize(urldecode($_GET['Data']));
 $USER_BROWSER ="";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
	<!--[if gte mso 9]>
	<xml>
		<o:OfficeDocumentSettings>
		<o:AllowPNG/>
		<o:PixelsPerInch>96</o:PixelsPerInch>
		</o:OfficeDocumentSettings>
	</xml>
	<![endif]-->
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta name="format-detection" content="date=no" />
	<meta name="format-detection" content="address=no" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="x-apple-disable-message-reformatting" />
    <!--[if !mso]><!-->
	<link href="https://fonts.googleapis.com/css?family=Muli:400,400i,700,700i" rel="stylesheet" />
    <!--<![endif]-->
	<title>BVI Staycation</title>
	<!--[if gte mso 9]>
	<style type="text/css" media="all">
		sup { font-size: 100% !important; }
	</style>
	<![endif]-->
 

	<script>
function check(form){
    if (form.message.value.trim() == ""){

		alert("The text area must be filled out.");
    return false;
	}
       
}
</script>

	<style type="text/css" media="screen">
		/* Linked Styles */
		body { padding:0 !important; margin:0 !important; display:block !important; min-width:100% !important; width:100% !important; background:#001736; -webkit-text-size-adjust:none }
		a { color:#66c7ff; text-decoration:none }
		p { padding:0 !important; margin:0 !important } 
		img { -ms-interpolation-mode: bicubic; /* Allow smoother rendering of resized image in Internet Explorer */ }
		.mcnPreviewText { display: none !important; }

		.HideForm {display:none}

				
		/* Mobile styles */
		@media only screen and (max-device-width: 480px), only screen and (max-width: 480px) {
			.mobile-shell { width: 100% !important; min-width: 100% !important; }
			.bg { background-size: 100% auto !important; -webkit-background-size: 100% auto !important; }
			
			.text-header,
			.m-center { text-align: center !important; }
			
			.center { margin: 0 auto !important; }
			.container { padding: 20px 10px !important }
			
			.td { width: 100% !important; min-width: 100% !important; }

			.m-br-15 { height: 15px !important; }
			.p30-15 { padding: 30px 15px !important; }

			.m-td,
			.m-hide { display: none !important; width: 0 !important; height: 0 !important; font-size: 0 !important; line-height: 0 !important; min-height: 0 !important; }

			.m-block { display: block !important; }

			.fluid-img img { width: 100% !important; max-width: 100% !important; height: auto !important; }

			.column,
			.column-top,
			.column-empty,
			.column-empty2,
			.column-dir-top { float: left !important; width: 100% !important; display: block !important; }

			.column-empty { padding-bottom: 10px !important; }
			.column-empty2 { padding-bottom: 30px !important; }

			.content-spacing { width: 15px !important; }
		}
	</style>
</head>
<body class="body" style="padding:0 !important; margin:0 !important; display:block !important; min-width:100% !important; width:100% !important; background:#001736; -webkit-text-size-adjust:none;">
<?php
 
                                                   //  var_dump($_REQUEST);
                                                     
                                                     //Setting Global Variables on Landing 


                                                    //  echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";

                                                    // $browser = get_browser(null, true);
                                                    // echo($browser['browser']);
                                                   
                                                                                                    

																		
																		 
																			
																			



														if ( isset($_POST['submit'])) {
															// $message = test_input($_POST["message"]);
															$Bus_id = test_input($_POST["Bus_id"]);
                                                            $User_id = test_input($_POST["User_id"]);
                                                            $Itinerary_id = test_input($_POST["Itinerary"]);
															$Package_id = test_input($_POST["Package_id"]);
                                                            $SecureCode = test_input($_POST["SecureCode"]);
                                                            $Date_FROM = test_input($_POST["Date_FROM"]);
                                                            $Date_TO = test_input($_POST["Date_TO"]);
                                                            
                                                            //we



															///we  check if the secure code was used
															$Code = SecureReply::find_by_SecureCode ($SecureCode, "");

															//print_r($Code );

															  if ($Code->Used == 'No') {

																//we get the activitivy
                                                                  $itinerary = Itinerary::find_by_id ($Itinerary_id,"");
                                                    
                                                                    $itinerary->Confirmation="DECLINED";
                                                                    $itinerary ->save();
                                                                  

																// $msg->Bus_id = 	$Bus_id ;
																// $msg->User_id = $User_id;
																// // $msg->Message = addslashes(trim($message));
																// $msg->Package_id =$Package_id;
																// $msg->Reply ='Yes';
																// $msg->save();
																 $Code->Used = 'Yes';
																  $Code->save();

																//now we should send 
																//PN to the user

																 //time to inform client that has been skipped
																$CustomerData =array(
																	"Msg"=> Business::getBUS_Name ( $Bus_id).", has DECLINED your booking. We have removed this activity from your Itinerary." ,
																	'header'=>'ACTIVITY CONFIRMED',
																	"Action" => "Update",
																	"Players" => array (Customer::GetOneSignal(  $User_id ) ),
																	"OneSignalData"=>array( "Action"=>"NewMessage"),
																 
																);


															 
																OneSignalsendMessage($CustomerData);



													

															  
															
															 } else {
                                                                $noMessage = true;
                                                               
															  }
															
       
                                                            

															// echo "<h2>$message</h2>";
															// echo "<h2>$Bus_id </h2>";
															// echo "<h2>$User_id</h2>";
															// echo "<h2>$Package_id</h2>";
															// echo "<h2>$SecureCode</h2>";


														
													 
														}else {
                                                                                                                        
                                                            // $user_agent = $_SERVER['HTTP_USER_AGENT']; 
                                                            // if (preg_match('/MSIE/i', $user_agent)) { 
                                                            // $USER_BROWSER = "Internet Explorer";
                                                            // }
                                                            // if (preg_match('/Firefox/i', $user_agent)) { 
                                                            //     $USER_BROWSER = "FireFox";
                                                            // }
                                                            // if (stripos( $user_agent, 'Chrome') !== false)
                                                            // {
                                                            //     $USER_BROWSER = "Google Chrome";
                                                            // }

                                                            // elseif (stripos( $user_agent, 'Safari') !== false)
                                                            // {
                                                            //     $USER_BROWSER = "Safari";
                                                            // }
                                                            // if (preg_match('/Opera/i', $user_agent)) { 
                                                            //     $USER_BROWSER = "Opera";
                                                            // }
                                                        
                                                                            
                                                            //$noMessage = "Your messages was not delivered. This link was previously used.";
                                                            // sleep(3);
                                                            // header("Location: BVIS_Promo.php/");
                                                        }
														
														function test_input($data) {
														  $data = trim($data);
														  $data = stripslashes($data);
														  $data = htmlspecialchars($data);
														  return $data;
														}
                                                            ?>
                                                            
	
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#09c5d6">
		<tr>
			<td align="center" valign="top">
				<table width="650" border="0" cellspacing="0" cellpadding="0" class="mobile-shell">
					<tr>
						<td class="td container" style="width:650px; min-width:650px; font-size:0pt; line-height:0pt; margin:0; font-weight:normal; padding:55px 0px;">
							<!-- Header -->
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td class="p30-15" style="padding: 0px 30px 30px 30px;">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<th class="column-top" width="145" style="font-size:0pt; line-height:1pt; padding:0; margin:0; font-weight:normal; vertical-align:top;">
													<table width="100%" border="0" cellspacing="0" cellpadding="0">
														<tr>
															<td class="img m-center" style="font-size:0pt; line-height:0pt; text-align:left;"><img src="images/BVITBW.png" width="130" border="0" alt="BVI Tourist Board" /></td>
														</tr>
													</table>
												</th>
												<th class="column-empty" width="1" style="font-size:0pt; line-height:0pt; padding:0; margin:0; font-weight:normal; vertical-align:top;"></th>
												<th class="column" style="font-size:0pt; line-height:0pt; padding:0; margin:0; font-weight:normal;">
													<table width="100%" border="0" cellspacing="0" cellpadding="0">
														<tr>
															<td class="text-header" style="color:#475c77; font-family:'Muli', Arial,sans-serif; font-size:12px; line-height:16px; text-align:right;"><a href="#" target="_blank" class="link2" style="color:#475c77; text-decoration:none;"><span class="link2" style="color:#475c77; text-decoration:none;">Powered by the BVI Tourist Board</span></a></td>
														</tr>
													</table>
												</th>
											</tr>
										</table>
									</td>
								</tr>
							</table>
							<!-- END Header -->

							<!-- Intro -->
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td style="padding-bottom: 10px;">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td class="tbrr p30-15" style="padding: 60px 30px; border-radius:26px 26px 0px 0px;" bgcolor="#fffff">
													<table width="100%" border="0" cellspacing="0" cellpadding="0">
														<tr>
															<td class="h1 pb25" style="color:#fff; font-family:'Muli', Arial,sans-serif; font-size:40px; line-height:46px; text-align:center; padding-bottom:25px;">
																<img style="margin:auto" src="http://bvistaycationdeals.com//BVI_Staycation-DB/images/staylogoColor.png" alt="BVI Staycation" width="80%"  style="display: block;" />
</td>
														</tr>

															<!-- Button -->
															<tr>
																<td align="center">
																	<table class="center" border="0" cellspacing="0" cellpadding="0" style="text-align:center;">
																		<tr>


																			<td class="pink-button text-button" style="color:#164175; font-family:'Muli', Arial,sans-serif; font-size:20px;text-align:center; border-radius:22px; font-weight:bold;">
                                                                            
                                                                            
                                                                            
	<?php
																		// 	if (!isset($_POST['submit'])) {
																		// 		 echo ("<h1>WELCOME</h1>	");
																		// 	}


																		// 	if (isset($_POST['submit'])) {
																		// 		if ( isset($noMessage)	) {
																		// 			echo ("<h3>Message could not be sent!</h3>");
																		// 		} else {
																		// 			echo ("<h1>THANK YOU!</h1>	");
																		// 		}
																				
																				 
																		//    }
																		   
																			
																		 
																			
																			?>
																			
                                                                            
                                                                            
                                                                            
                                                                            
                                                                                <h1 style="margin-bottom: 43px; line-height: 50px !important"><?php  if (!isset($_POST['submit'])) {  echo(Business::ShowBUS_Name ($DataPassed["Bus_id"]) );  }  ?>  </h1>
                                                                                <h1 style="margin-bottom: 43px;"><?php  if (isset($_POST['submit'])) {  echo("THANK YOU!");  }  ?> </h1>

                                                                               <p class="<?php  if (isset($_POST['submit'])) { echo ('HideForm'); } ?>"  style="line-height: 5px; font-size: 17px;  line-height: 19px !important"> Sorry to know that you wont be able to confirm the bookinbg for <?php if (!isset($_POST['submit'])) { echo( Customer::showCustomerName ($DataPassed["User_id"])); } ?>. <br /><br /><br /> Kindly use the action button below to confirm. <br /> </p> <br />
 
																			
																				
																			</td>
																		</tr>
																	</table>
																</td>
															</tr>
															<!-- END Button -->

														<tr>
															<td class="text-center pb25" style="color:#0e264b; font-family:'Muli', Arial,sans-serif; font-size:16px; line-height:30px; text-align:center; padding-bottom:25px;">
									 
														
<br /> 
															   <br />   
													
															</td>
														</tr>
													
													</table>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
							<!-- END Intro -->

							<!-- Article / Full Width Image + Title + Copy + Button -->
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									
									<td style="padding-bottom: 10px;">
										<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#0e264b">
											
											<tr>
												<td class="p30-15" style="padding: 50px 30px;">
													<table width="100%" border="0" cellspacing="0" cellpadding="0">
						 
														<tr>
															<td class="text pb20" style="color:#ffffff; font-family:Arial,sans-serif; font-size:14px; line-height:26px; text-align:left; padding-bottom:20px;">
															
            
														


															<form class="<?php  if (isset($_POST['submit'])) { echo ('HideForm'); } ?>"  required name="myForm"  method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" onsubmit="return check(this)">  


                                                            <h1 for="meeting-time">Do you really  want <br />to decline this booking?</h1>
                                                            <p>THIS CANNOT BE UNDONE</p>
                                                            <br /> 

<!-- 
                                                                        <fieldset style="padding: 23px;" class="<?php  if ( $USER_BROWSER == "Safari" || $USER_BROWSER == "FireFox"  ) { echo ('HideForm'); } ?>">
                                                            <label for="meeting-time"> FROM:</label>
                                                                <input type="datetime-local" id="Date_FROM"  name="Date_FROM" value="<?php  if (!isset($_POST['submit'])) {Itinerary::ShowSuggested_Date($DataPassed["Itinerary"]); } ?>"
                                                                    min="<?php  if (!isset($_POST['submit'])) {Itinerary::ShowSuggested_Date($DataPassed["Itinerary"]); } ?>" >
                                                                                                            
                                                                    <br /> <br /> 
                                                                     <br />

                                                                     <label for="meeting-time">TO:&nbsp; &nbsp; &nbsp; </label>

                                                                    <input type="datetime-local" id="Date_TO"  name="Date_TO" value="<?php  if (!isset($_POST['submit'])) {Itinerary::ShowTo_Date($DataPassed["Itinerary"]); } ?>"
                                                                        min="<?php  if (!isset($_POST['submit'])) {Itinerary::ShowTo_Date($DataPassed["Itinerary"]); } ?>" >
                 
                                                                        </fieldset> -->

															<!-- <input type="text" name="name"> -->
															
															<br>
															<input type="hidden" name="Bus_id" id="Bus_id" value="<?php echo ($DataPassed["Bus_id"] ); ?>" />
															<input type="hidden" name="User_id" id="User_id" value="<?php  echo ($DataPassed["User_id"]); ?>" />
															<input type="hidden" name="Package_id" id="Package_id" value="<?php  echo ($DataPassed["Package_id"]); ?>" />
                                                            <input type="hidden" name="SecureCode" id="SecureCode" value="<?php  echo ($DataPassed["SecureCode"]); ?>" />
                                                            <input type="hidden" name="Itinerary" id="Itinerary" value="<?php  echo ($DataPassed["Itinerary"]); ?>" />



                                                            <br /> 
                                                                     <br />

                                                            <input required style="background:#ec0000; color:#c1cddc; font-family:'Muli', Arial,sans-serif; font-size:14px; line-height:18px; padding:12px 30px; text-align:center; border-radius:22px; font-weight:bold;color:#fff; text-decoration:none; margin-top: 20px" 
                                                            type="submit" name="submit" value="DECLINE"><br>
															</form>

															<?php  if (isset($_POST['submit'])) {
																	if ( isset($noMessage)	) {
																		echo ("This link was previously used. We already notify the user.");
																	} else {
																		echo ('Thanks for confirming. <br> We will notify the user.'); 
																	}
																	

																
																 } ?>
															
															</td>
														</tr>
														<!-- Button -->
														<tr>
															<td align="left">
															
															</td>
														</tr>
														<!-- END Button -->
													</table>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
							<!-- END Article / Full Width Image + Title + Copy + Button -->


							<!-- Footer -->
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td class="p30-15 bbrr" style="padding: 50px 30px; border-radius:0px 0px 26px 26px;" bgcolor="#fff">
										<table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<!-- <td align="center" style="padding-bottom: 30px;">
													<table border="0" cellspacing="0" cellpadding="0">
														<tr>
															<td class="img" width="55" style="font-size:0pt; line-height:0pt; text-align:left;"><a href="#" target="_blank"><img src="images/ico_facebook.jpg" width="38" height="38" border="0" alt="" /></a></td>
															<td class="img" width="55" style="font-size:0pt; line-height:0pt; text-align:left;"><a href="#" target="_blank"><img src="images/ico_twitter.jpg" width="38" height="38" border="0" alt="" /></a></td>
															<td class="img" width="55" style="font-size:0pt; line-height:0pt; text-align:left;"><a href="#" target="_blank"><img src="images/ico_instagram.jpg" width="38" height="38" border="0" alt="" /></a></td>
															<td class="img" width="38" style="font-size:0pt; line-height:0pt; text-align:left;"><a href="#" target="_blank"><img src="images/ico_linkedin.jpg" width="38" height="38" border="0" alt="" /></a></td>
														</tr>
													</table>
												</td> -->
											</tr>
											<tr>
												<td class="text-footer1 pb10" style="color:#0e264b; font-family:'Muli', Arial,sans-serif; font-size:16px; line-height:20px; text-align:center; padding-bottom:10px;">
													To get more exposure <br/> encourage your clients to download</td>
											</tr>
											<tr>
												<td class="text-footer2" style="color:#8297b3; font-family:'Muli', Arial,sans-serif; font-size:12px; line-height:26px; text-align:center;">
													<b> BVI Staycation App</b> </td>
											</tr>
											
												<td class="text-footer2" style="color:#8297b3; font-family:'Muli', Arial,sans-serif; font-size:12px; line-height:26px; text-align:center;">
													 <img src="images/stores.png" width="80%"/></td>
											</tr>
											
										</table>
									</td>
								</tr>
								<tr>
									<td class="text-footer3 p30-15" style="padding: 40px 30px 0px 30px; color:#475c77; font-family:'Muli', Arial,sans-serif; font-size:12px; line-height:18px; text-align:center;">
									&copy; <?php echo date("Y"); ?> BVI Tourist Board
 
									</td>
								</tr>
							</table>
							<!-- END Footer -->
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>

	<?php
 
echo $comment;
 
?>


</body>
</html>


