<?php
	session_start();

    require('connect.php');
    require('functions.php');

    $log=loggedin();
    if($log!==true)
    {
        
        header('Refresh:0 url=index.php');
        

    }
    else if($_SESSION['type']==="2")
    {
       header('Refresh:0 url=driver.php');
    }
    else if($_SESSION['type']==="3")
    {
       header('Refresh:0 url=admin.php');
    }
?>

<!DOCKTYPE html>
<html>
<head>
  <title>Abhi Cab</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.footer {
    color: white;
    background-color: black;
    margin-left: 0px;
    text-align: center;
    position:fixed;
    bottom: 0;
    height: 50px;
    width: 100%;
}
form {
      border: 3px solid #f1f1f1;
  }
#v{
	border: 3px solid #f1f1f1;
}
  input[type=text], input[type=time], input[type=number] {
      width: 100%;
      padding: 12px 20px;
      margin: 8px 0;
      display: inline-block;
      border: 1px solid #ccc;
      box-sizing: border-box;
      
      }
      
      .container {
  	  width:100%;
      padding: 16px;
  }
  
.vl {
    border-left: 1px solid white;
    height: 80px;
    
}


.container1 {
	width: auto;
	height: auto;
	margin-left: 10;
}

 button {
      background-color: #4CAF50;
      color: white;
      padding: 14px 20px;
      margin: 8px 0;
      border: none;
      cursor: pointer;
      width: 100%;
  }
  .cancelbtn {
      width:100%
      padding: 10px 18px;
      background-color: #f44336;
  }

  #driver {

    width:100%;
    height:100%;
    opacity:.95;
    top:70;
    left:0;

    position:fixed;
    background-color:#313131;
    
    

}

.colorc{

-webkit-animation:colorchange 3s 2 alternate;
      
      
    }

    @-webkit-keyframes colorchange {
      0% {
        
        color: blue;
      }
      30%{
          color: blue;
      }
      
      
      70% {
        
        color: red;
      }
      
     
      100% {
        
        color: green;
      }
    }






#ptext{
     margin-top: 15%;
     margin-left: 8%;
}


#move{
     position: relative;
  animation-name: example;
  animation-duration: 6s;
  animation-direction: reverse;
  left:1%; top:10%; 
  animation-iteration-count: 2;
}
@keyframes example {
  0%   {color: red;  left:0%; top:10%;}
  50%  { color: blue; left:40%; top:10%;}
  
  100% { color: red; left:0%; top:10%;}
}

</style>


<script type="text/javascript">
     function div_show() {
    document.getElementById('driver').style.display = "block";
}
//Function to Hide Popup
function div_hide() {
    document.getElementById('driver').style.display = "none";
}
</script>
</head>



<body style="overflow-x:hidden;background-size:100% 100%;background-repeat: no-repeat;bottom: 0;background-attachment: fixed;" background="images/bpay.jpg">

<div>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="padding: 0px margin:0px">
<div class="main" >
<div class="col-sm-6" >
<h1 align="left" style="margin-left:10px;" ><font color="white" size="15">   ABHI CAB</font>
  	<img src="images/logo.png" alt="google.com" width="100" height="50" align="left" style="margin-left:10px;">
  	</h1>
  	</div>
  	<div class="col-sm-6" style="margin-top:40px;">
    <ul class="nav navbar-nav navbar-right" style="margin-right:10px;">
    
      <li >
        <a href="index.php"> Home   <span class="glyphicon glyphicon-home"></span></a>
      </li>

        

      <li><a href="main.php">Book Now  <span class="glyphicon glyphicon-shopping-cart"></span></a></li>
      <li><a href="about_us.php">About Us</a></li>
      <li><a href="contact.php">Contact Us <span class="glyphicon glyphicon-earphone"></span></a></li>
	  	  <li><a href="logout.php">Log Out <span class="glyphicon glyphicon-earphone"></span></a></li>

	</ul>
	</div>
  </div>
</nav>
</div>


<div class="col-sm-12">
<div class="row">
	<div class="col-sm-1"></div>
	
	<div class="col-sm-6">
		<form  action="t.php" method="post" style="margin-top:100px; margin-bottom:100px; background-color:gray;">
    		<h3 style="margin-left:5%">PICK-UP AND CONTACT DETAILS</h3>
    		<div class="container">
    		
    			<div class="col-sm-12">
    				<label><b><font color="yellow" size="2">Name</font></b></label>
      				<input type="text" placeholder="Enter Name" name="name" required>
      				<hr>
	  			</div>
	  			
	  			<div class="col-sm-6">
	  				<label><b><font color="yellow" size="2">PHONE NUMBER</font></b></label>
      				<input type="number" placeholder="Enter Phone Number" name="phnumber" text-type="number" required>
	  			</div>
	  			<div class="col-sm-6">
	  				<label><b><font color="yellow" size="2">EMAIL</font></b></label>
      				<input type="text" placeholder="Enter Email" name="email" text-type="email" required>
	  			</div>
	  			
	  			<div class="col-sm-12">
	  				<label><b><font color="yellow" size="2">PICK-UP LOCATION</font></b></label>
      				<input type="text" placeholder="Enter Location" name="location" required>
      			</div>
	  			
	  			<div class="col-sm-12">
	  				<label><b><font color="yellow" size="2">PICK-UP TIME</font></b></label>
      				<input type="time" placeholder="Enter Pick Up Time" name="time" required>
      				<span style="margin-left:5px"><font size="2">Night charges may be applicable depending on the pick-up time.</font></span>
      			</div>
	  
			</div>
		
	</div>
	<?php
	
	$rate=$_SESSION["rate"];
	$distance=$_SESSION["dist"];
	$did=$_SESSION["favcolor"];
	$total=$rate * $distance;
	$date=$_SESSION["ddate"];
?>
	<div class="col-sm-4" style="background-color:gray; margin-top:100px; margin-bottom:100px;" id="v">
		
    <?php
	echo "
    		<div class='container' >
    			<div class='col-sm-6' >
    				<p align='center' ><font size='8'>".$distance."</font><font size='2'>km</font><br>
    				<font size='2' style='margin-left:10px'>Included km</font></p>
    				
    			</div>
    			
    			<div class='col-sm-1'>
					<div class='vl'></div>
				</div>
				<div class='col-sm-5' >
					<p align='center'><font size='2'>&#x20b9;</font><font size='8'>".$rate."</font><font size='2'>/km</font><br>
    				<font size='2' style='margin-left:0px'>Extra fare/Km</font></p>
    			</div>
    			<div class='col-sm-12'>
    				<div class='col-sm-6'>
    					<p align='left' style='margin-top:10px'><font size='6'>Total</font><p>
    				</div>
    				<div class='col-sm-6'>
						<p align='right'><font size='8' color='red'>&#x20b9;".$total."</font><font size='2'></font><br> 	
    				</div>
    			</div>
    			<hr>
    		</div>
    		<hr>
    		<div class='container1'>
    			<h4 align='center'><b><font color='yellow'>TERMS & CONDITIONS</font></b></h4>
    			<p><font size='2'><b>All-Inclusive Price.</b>No Need to pay toll and state tax to the driver</font></p>
    		</div>
    		<hr>
			
			<div class='container'>
    			<h4 align='left'><b><font color='white'>FARE BREAKUP</font></b></h4>
    			<div class='col-sm-8'>
    				<p><font size='3'>Vendor Base Fare</font></p>
    				
    			</div>
    			<div class='col-sm-4'>
    				<p align='right'><font size='3'>&#x20b9; ".$total."</font></p>
    				
    			</div>
    			
    			<div class='col-sm-8'>
    				<p><font size='3'>Total</font></p>
    				
    			</div>
    			<div class='col-sm-4'>
    				<p align='right'><font size='3'>&#x20b9; ".$total."</font></p>
    				
    			</div>
    			
    			<div class='col-sm-2'>
    				<input type='checkbox' style='margin-top:15px; margin-left:18px' name='check'>
    			</div>
    			
    			<div class='col-sm-10'>
    				<p><font size='1'>By clicking this button, I understand & agree with the Cancellation Policy, the Privacy Policy & Terms & Conditions of this MMT service.</font></p>
    			</div>
    			<button type='submit' class='cancelbtn' name='pay' >PAY 100% NOW & BOOK</button>
			</div>";
			?>
		</form>	  
          <!--<button  onclick="div_show()">PAY 100% NOW & BOOK</button>-->
	</div>

	<div class="col-sm-1"></div>
</div>
</div>

<!-- Footer -->
  <footer class="footer">
    <h5>Copyright &copy; 2019 AbhiCab.com</h5>
  </footer>
<?php
     require('connect.php');
     
     
     if(isset($_POST['pay']))
     {
          //echo '<script>alert("hello customer krushna");</script>';
          //echo '<script>alert("AFTER BUTTEN PRESS");</script>';
          if($_POST['check']=="" || $_POST['name']=="" || $_POST['phnumber']=="" ||$_POST['email']=="" || $_POST['location']=="" || $_POST['time']=="")
          {
               echo '<script>alert("All fields must be filled out");</script>';
               if($_POST['check']=="" || $_POST['name']!="" || $_POST['phnumber']!="" ||$_POST['email']!="" || $_POST['location']!="" || $_POST['time']!="")
               {
                    echo '<script>alert("Please accept the Terms & Conditions of this MMT service.");</script>';
                    
               }
          }
          else
          {
               $name=$_POST['name'];
               $name=test_input($name);
               $phnumber=$_POST['phnumber'];
               $phnumber=test_input($phnumber);
               $email=$_POST['email'];
               $email=test_input($email);
               $location=$_POST['location'];
               $location=test_input($location);
               $time=$_POST['time'];
               $time=test_input($time);
               $did=$_SESSION["favcolor"];
               $date=$_SESSION["ddate"];
      $cid = $_SESSION["CID"];

               $abhi = "SELECT * FROM customer where cid='".$cid."' AND cemail='".$email."'";
               $abhi=mysqli_query($con,$abhi);
               if($abhi)
               { 
                    $row = mysqli_fetch_array($abhi);
                    $cid=$row['CID'];
                    $insertcustdriv="INSERT INTO transaction (CID, LID, TID, TDATE) VALUES ('$cid', '$did', NULL, '$date')";
                    if(mysqli_query($con,$insertcustdriv))
                    {
                         header('Refresh:3 url=s.php');
                    }else{
          echo '<script>alert("transaction failed");</script>';
        }
                           


               }
               else
               {
                    echo '<script>alert("Please Enter proper details as given during registration");</script>';
                    
               }

          }
          
     }
?>


</body>
</html>
