<?php include("cn.php");?>
<?php $title = "Booking Detail";?>
<!DOCTYPE html>
<html lang="en">


<!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<?php include("head-tag.php");?>
<?php include("info.php");?>
<?php 
       $sql_1 = mysqli_query($connect,"select * from app_users where
        Id = '".$_SESSION["userid"]."' ");
        $data_1 = mysqli_fetch_assoc($sql_1);
?>


<body>

<div class="inner-wrapper">

<?php include("pre-loader.php");?>

<?php include("header.php");?>

<?php
$user="";

$sql = mysqli_query($connect, "SELECT rentedcars.*, cars.car_name AS car_title, cars.car_nameplate AS car_number, 
driver.driver_name as driver_name, driver.driveramount_enable as driveramount_enable
FROM rentedcars 
INNER JOIN cars ON cars.car_id = rentedcars.car_id
LEFT JOIN driver ON driver.driver_id = rentedcars.driver_id
WHERE `BookingNumber`='".$_GET['id']."'");

$data = mysqli_fetch_assoc($sql);
$user = $data['AppUser'];

$sql1 = mysqli_query($connect, "SELECT * FROM app_users 
WHERE `Id`='".$user."'");

$customer = mysqli_fetch_assoc($sql1);

$user = $data['driver_id'];

$sql1= "SELECT * FROM app_users INNER JOIN driver ON driver.driver_id = app_users.DriverId WHERE app_users.DriverId='".$user."'";

$sql1 = mysqli_query($connect, $sql1);

$driver = mysqli_fetch_assoc($sql1);

?>
 <div class="page-wrapper">
    <div class="container-fluid">
        <div class="row">
<div class="col-xl-3 col-lg-3 col-md-3 theiaStickySidebar">
    <aside class="sidebar sidebar-user">
        <div class="card ctm-border-radius shadow-sm">
            <div class="card-body py-4">
                <div class="row">
                    <div class="col-md-12 mr-auto text-left">
                        <div class="custom-search input-group">
                            <div class="custom-breadcrumb">
                                <ol class="breadcrumb no-bg-color d-inline-block p-0 m-0 mb-2">
                                    <li class="breadcrumb-item d-inline-block"><a href="index.php" class="text-dark">Home</a></li>
                                    <li class="breadcrumb-item d-inline-block active"><?php echo $title?></li>
                                </ol>
                                <h4 class="text-dark">Booking Detail</h4>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</aside>
</div>            
<div class="col-xl-9 col-lg-9 col-md-9 ctm-border-radius shadow-sm card ">
<div class="col-md-12" style="float: none; margin: 2 auto; padding: 0;">
    <br>
    <br>

<div>
<form role="form" method="POST" action="ajax/receiveCash.php">
     <div bgcolor="#ffffff" style="color: #333; height: 100%; width: 100%;" height="100%" width="100%">
    <table bgcolor="#ffffff" cellspacing="0" style="border-collapse: collapse; padding: 5px; width: 100%;" width="100%">
        <tbody>
            <tr>
                <td width="5px" style="padding: 0;"></td>
                <td style="clear: both; display: block; margin: 0 auto; max-width: 600px; padding: 5px 0;">
                    <table width="100%" cellspacing="0" style="border-collapse: collapse;">
                        <tbody>
                            <tr>
                                <td style="padding: 0;">
                                    <a
                                        href="#"
                                        style="color: #348eda;"
                                        target="_blank"
                                    >
                                        <?php echo $companylogo;?>
                                    </a>
                                </td>
                               
                                <td style="color: #999; font-size: 12px; padding: 2; text-align: right; margin:5px;" align="right">
                                     <h4 style="margin: 0;"><span class="il"><?php echo $companyname;?></h4></span>
                                    <p style="color: #666; font-size: 12px; font-weight: normal; margin-bottom: 5px;">
                                       <span>TRN# <a href="#"><?php echo $companytrn;?></a></span><br>
                                       <span> <a href="#"><?php echo $companyaddress;?></a></span><br>
                                        <span><a href="#"><?php echo $companyphone;?></a></span>
                                    
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
                <td width="5px" style="padding: 0;"></td>
            </tr>

            <tr>
                <td width="5px" style="padding: 0;"></td>
                <td bgcolor="#FFFFFF" style="border: 1px solid #000; clear: both; display: block; margin: 0 auto; max-width: 600px; padding: 0;">
                    <table width="100%" style="background: #f9f9f9; border-bottom: 1px solid #eee; border-collapse: collapse; color: #999;">
                        <tbody>
                            <tr>
                                <td>
                                    <strong style="color: #333; font-size: 16px;">
                                    Booking #:
                                    <?php echo $data['BookingNumber']?>
                                    </strong>
                                    <input type="text" name="userid" id="userid" value="<?php echo $_SESSION['userid'];?>" hidden/>
                                    <input type="text" name="driverid" id="driverid" value="<?php echo $_SESSION['driverid'];?>" hidden/>
                                    <input type="text" name="bookingno" id="bookingno" value="<?php echo $data['BookingNumber'];?>" hidden/>
                                </td>
                                <td>
                                    <strong style="color: #333; font-size: 16px;">
                                    Date:
                                    <?php echo date("d-m-Y", strtotime($data['rent_start_date']));?><br/>
                                    Time:
                                    <?php echo date("H:i:s", strtotime($data['rent_start_date']));?>
                                    </strong>
                                </td>
                            </tr>
                            
                            <tr>
                                <td>
                                <strong style="color: #333; font-size: 18px;">
                                <?php echo $data['status'];?>
                                </strong>
                                </td>
                                
                                <td>
                                <strong style="color: #333; font-size: 18px;">
                                <?php echo $data['PaymentStatus'];?>
                                </strong>
                                </td>
                           </tr>
                        </tbody>
                    </table>
                </td>
                <td style="padding: 0;"></td>
                <td width="10px" style="padding: 0;"></td>
            </tr>
            <tr>
                <td width="5px" style="padding: 0;"> 
                
                </td>
                <td style="border: 1px solid #000; border-top: 0; clear: both; display: block; margin: 0 auto; max-width: 600px; padding: 0;">
                    <table cellspacing="0" style="border-collapse: collapse; border-left: 1px solid #000; margin: 0 auto; max-width: 600px;">
                        <tbody>
                            <tr>
                              
                                <td valign="top"  style="padding: 5px;">
                                    <h1
                                        style="
                                            border-bottom: 1px solid #000;
                                            color: #000;
                                            font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
                                            font-size: 36px;
                                            font-weight: bold;
                                            line-height: 1.2;
                                            margin: 0;
                                            margin-bottom: 10px;
                                            padding-bottom: 5px;
                                           
                                        "
                                    >
                                        Electronic Booking
                                    </h1>
                                    <CENTER>
                                        <?php 
                                        include "./widget/qrcode.php";
                                        /*echo 
                                    '<a href="./print2.php?id='.$data['BookingNumber'].'" class="btn btn-theme button-1 text-white ctm-border-radius lnr lnr-printer" 
                                    style="background-color: green; border-bottom: 0px;"> </a>';*/
                                    ?>
                                    </CENTER>
                                    
                                    <table cellspacing="0" width="100%" style="border-collapse: collapse; margin-bottom: 20px;">
                                        <tbody>
                                            <tr>
                                                <td style="padding: 5px 0;">Driver Name:</td>
                                                <td align="right" style="padding: 5px 0;"> <?php echo $data['driver_name'];?></td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 5px 0;">Customer Name:</td>
                                                <td align="right" style="padding: 5px 0;"> <?php echo $customer['Name'];?></td>
                                            </tr>
                                             <tr>
                                                <td style="padding: 5px 0;">Email:</td>
                                                <td align="right" style="padding: 5px 0;"> <?php echo $customer['Email'];?></td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 5px 0;">Phone:</td>
                                                <td align="right" style="padding: 5px 0;"> <?php echo $customer['Phone'];?></td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 5px 0;">Company/Hotel:</td>
                                                <td align="right" style="padding: 5px 0;"> <?php echo $data['customer_hotel'];?></td>
                                            </tr>
                                            
                                            <tr>
                                                <td style="padding: 5px 0;">Room:</td>
                                                <td align="right" style="padding: 5px 0;"> <?php echo $data['customer_room'];?></td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 5px 0;">Flight Detail:</td>
                                                <td align="right" style="padding: 5px 0;"> <?php echo $data['customer_flight'];?></td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 5px 0;">Car</td>
                                                <td align="right" style="padding: 5px 0;">  <?php echo $data['car_title'];?></td>
                                            </tr>
                                            
                                            <tr>
                                                <td style="padding: 5px 0;">Car Number</td>
                                                <td align="right" style="padding: 5px 0;">  <?php echo $data['car_number'];?></td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 5px 0;">Amount</td>
                                                <td align="right" style="padding: 5px 0;">  <?php echo $data['fare'];?></td>
                                            </tr>
                                            
                                            <tr>
                                                <td style="padding: 5px 0;">Pick Up Location:</td>
                                                <td align="right" style="padding: 5px 0;"> <?php echo $data['pickup'];?></td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 5px 0;">Drop Off Location:</td>
                                                <td align="right" style="padding: 5px 0;">
                                                    <!--<input type="text" name="destination" id ="destination" value="'.$data['Destination'].'" placeholder="destination" required/>-->
                                                    <?php 
                                                    if ($data['PaymentStatus']=="Un-paid" && !is_null($data['EndTime']))
                                                {
                                                            if($_SESSION['driverid']>0  ){
                                                            echo '
                                                            <input type="text" name="destination" id ="destination" value="'.$data['Destination'].'" placeholder="destination" required/>
                                                            <br>';
                                                    }
                                                }
                                                elseif ($data['PaymentStatus']=="By Room" && !is_null($data['EndTime']))
                                                {
                                                            if($_SESSION['driverid']>0  ){
                                                            echo '
                                                            <input type="text" name="destination" id ="destination" value="'.$data['Destination'].'" placeholder="destination" required/>
                                                            <br>';
                                                    }
                                                }
                                                elseif ($data['PaymentStatus']=="By Cash" && !is_null($data['EndTime']))
                                                {
                                                            if($_SESSION['driverid']>0  ){
                                                            echo '
                                                            <input type="text" name="destination" id ="destination" value="'.$data['Destination'].'" placeholder="destination" required/>
                                                            <br>';
                                                    }
                                                }
                                                elseif ($data['PaymentStatus']=="By Credit Card" && !is_null($data['EndTime']))
                                                {
                                                            if($_SESSION['driverid']>0  ){
                                                            echo '
                                                            <input type="text" name="destination" id ="destination" value="'.$data['Destination'].'" placeholder="destination" required/>
                                                            <br>';
                                                    }
                                                }
                                                elseif ($data['PaymentStatus']=="By Hotel" && is_null($data['EndTime'])  && !is_null($data['StartTime']))
                                                {
                                                            if($_SESSION['driverid']>0  ){
                                                            echo '
                                                            <input type="text" name="destination" id ="destination" value="'.$data['Destination'].'" placeholder="destination" required/>
                                                            <br>';
                                                    }
                                                }
                                                else
                                                {
                                                            echo $data['Destination'];
                                                }
                                                    ?>
                                                    </td>
                                            </tr>
                                            
                                            <?php 
                                                if (!is_null($data['StartTime']))
                                                {    
                                                    echo
                                                    '
                                                    <tr>
                                                    <td style="padding: 5px 0;">Trip Started At:</td>
                                                    <td align="right" style="cpadding: 5px 0;">'.date("d-m-Y H:i:s", strtotime($data['StartTime'])).'</td>
                                                    </tr>
                                                    ';
                                                }
                                            ?>
                                             
                                            <!--<tr>-->
                                            <!--    <td style="padding: 5px 0;">Charges:</td>-->
                                            <!--    <td align="right" style="padding: 5px 0;"><?php echo '@ '.$data['fare'].' / '.$data['charge_type'];?></td>-->
                                            <!--</tr>-->
                                            <?php 
                                                if (!is_null($data['EndTime']))
                                                {
                                                    
                                                    // echo '
                                                    // <tr>
                                                    // <td style="padding: 5px 0;">Duration</td>
                                                    // <td align="right" style="padding: 5px 0;"> '.$data['duration'].' '.$data['charge_type'].'</td>
                                                    // </tr>';
                                                    
                                                    echo '
                                                    <tr>
                                                    <td style="padding: 5px 0;">Trip Ended At:</td>
                                                    <td align="right" style="padding: 5px 0;">'.date("d-m-Y H:i:s", strtotime($data['EndTime'])).'</td>
                                                    </tr>
                                                    ';
                                                }
                                                ?>
                                            
                                            <tr>
                                                <?php 
                                                if ($data['status']=="Completed")
                                                {
                                                if ($data['PaymentStatus']=="Un-paid")
                                                echo '
                                                <div><td style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;">Amount (AED.)</td>
                                                <td align="right" style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;"></div> 
                                                ';
                                                else if ($data['PaymentStatus']=="By Room")
                                                echo '
                                                <div><td style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;">Amount (AED.)</td>
                                                <td align="right" style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;"></div> 
                                                ';
                                                else if ($data['PaymentStatus']=="By Cash")
                                                echo '
                                                <div><td style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;">Amount (AED.)</td>
                                                <td align="right" style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;"></div> 
                                                ';
                                                
                                                else if ($data['PaymentStatus']=="By Credit Card")
                                                echo '
                                                <div><td style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;">Amount (AED.)</td>
                                                <td align="right" style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;"></div> 
                                                ';
                                                
                                                else
                                                echo '
                                                <td style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;">Amount Paid (AED.)</td>
                                                <td align="right" style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;"> ';
                                                }
                                                
                                                    if ($data['PaymentStatus']=="Un-paid" && is_null($data['EndTime']))
                                                {
                                                    echo '
                                                    Trip in Progress
                                                    ';
                                                }
                                                else if ($data['PaymentStatus']=="By Room" && is_null($data['EndTime']))
                                                {
                                                    echo '
                                                    Trip in Progress
                                                    ';
                                                }
                                                    else if ($data['PaymentStatus']=="By Cash" && is_null($data['EndTime']))
                                                {
                                                    echo '
                                                    Trip in Progress
                                                    ';
                                                }
                                                    else if ($data['PaymentStatus']=="By Credit Card" && is_null($data['EndTime']))
                                                {
                                                    echo '
                                                    Trip in Progress
                                                    ';
                                                }
                                                else if ($data['PaymentStatus']=="By Hotel" && is_null($data['EndTime']))
                                                {
                                                            
                                                            
                                               
                                                }
                                             
                                                else if ($data['PaymentStatus']=="Un-paid" && !is_null($data['EndTime']))
                                                {
                                                            
                                                                if( $driveramountbookings==1 && $data["driveramount_enable"] == "enable"){
                                                            
                                                                   echo '
                                                            <input type="text" name="amount" id="Amount" value="'.$data['fare'].'" placeholder="trip charges" required/>
                                                            <br>';
                                                                
                                                                }
                                                                else{
                                                                
                                                            echo 'AED. '.$data['fare'] . '<input type="hidden" name="amount" id="Amount" value="'.$data['fare'].'"/>';
                                                            
                                                    }
                                                            
                                                            
                                                            
                                                }
                                                else if ($data['PaymentStatus']=="By Room" && !is_null($data['EndTime']))
                                                {
                                                            
                                                                if( $driveramountbookings==1 && $data["driveramount_enable"] == "enable"){
                                                            
                                                                   echo '
                                                            <input type="text" name="amount" id="Amount" value="'.$data['fare'].'" placeholder="trip charges" required/>
                                                            <br>';
                                                                
                                                                }
                                                                else{
                                                                
                                                            echo 'AED. '.$data['fare'] . '<input type="hidden" name="amount" id="Amount" value="'.$data['fare'].'"/>';
                                                            
                                                    }
                                                            
                                                            
                                                            
                                                }
                                                else if ($data['PaymentStatus']=="By Cash" && !is_null($data['EndTime']))
                                                {
                                                            
                                                                if( $driveramountbookings==1 && $data["driveramount_enable"] == "enable"){
                                                            
                                                                   echo '
                                                            <input type="text" name="amount" id="Amount" value="'.$data['fare'].'" placeholder="trip charges" required/>
                                                            <br>';
                                                                
                                                                }
                                                                else{
                                                                
                                                            echo 'AED. '.$data['fare'] . '<input type="hidden" name="amount" id="Amount" value="'.$data['fare'].'"/>';
                                                            
                                                    }
                                                            
                                                            
                                                            
                                                }
                                                else if ($data['PaymentStatus']=="By Credit Card" && !is_null($data['EndTime']))
                                                {
                                                            
                                                                if( $driveramountbookings==1 && $data["driveramount_enable"] == "enable"){
                                                            
                                                                   echo '
                                                            <input type="text" name="amount" id="Amount" value="'.$data['fare'].'" placeholder="trip charges" required/>
                                                            <br>';
                                                                
                                                                }
                                                                else{
                                                                
                                                            echo 'AED. '.$data['fare'] . '<input type="hidden" name="amount" id="Amount" value="'.$data['fare'].'"/>';
                                                            
                                                    }
                                                            
                                                            
                                                            
                                                }
                                                else{
                                                    echo '
                                                            AED. '.$data['fare'].'
                                                            </td>
                                                            ';
                                                }
                                                
                                                
                                                ?>
                                                
                                            </tr>
                                        
                                            <tr>
                                                    <?php 
                                                if (is_null($data['StartTime']))
                                                {
                                                
                                                if ($_SESSION['driverid']>0)
                                                {
                                                    if ($data['driver_id']!=$_SESSION['driverid'])
                                                        header( "refresh:0;url=index.php");
                                                    echo 
                                                    '
                                                    <td>
                                                    <br>
                                                    <input type="button" name="starttrip" id ="starttrip" value="Start Trip Now" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                    </td>
                                                    <td>
                                                    <br>
                                                    <input type="button" name="cancelridedriver" id ="cancelridedriver" value="Cancel Ride" class="btn btn-danger text-white ctm-border-radius"/>
                                                    </td>
                                                    ';
                                                }
                                                else if ($_SESSION['userid']>0)
                                                    echo 
                                                    '
                                                    <td colspan="2">
                                                    <br>
                                                    <input type="button" name="cancelridecustomer" id ="cancelridecustomer" value="Cancel Trip" class="btn btn-danger text-white ctm-border-radius"/>
                                                    </td>
                                                    ';
                                                }
                                                else if ($data['PaymentStatus']=="Un-paid" && is_null($data['EndTime']))
                                                {
                                                    echo 
                                                    
                                                    '
                                                    <td colspan="2">
                                                    <br>
                                                    <input type="button" name="endtrip" id ="endtrip" value="End Trip Now" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                    </td>
                                                    ';
                                                }
                                                else if ($data['PaymentStatus']=="By Room" && is_null($data['EndTime']))
                                                {
                                                    echo 
                                                    
                                                    '
                                                    <td colspan="2">
                                                    <br>
                                                    <input type="button" name="endtrip" id ="endtrip" value="End Trip Now" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                    </td>
                                                    ';
                                                }
                                                else if ($data['PaymentStatus']=="By Cash" && is_null($data['EndTime']))
                                                {
                                                    echo 
                                                    
                                                    '
                                                    <td colspan="2">
                                                    <br>
                                                    <input type="button" name="endtrip" id ="endtrip" value="End Trip Now" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                    </td>
                                                    ';
                                                }
                                                else if ($data['PaymentStatus']=="By Credit Card" && is_null($data['EndTime']))
                                                {
                                                    echo 
                                                    
                                                    '
                                                    <td colspan="2">
                                                    <br>
                                                    <input type="button" name="endtrip" id ="endtrip" value="End Trip Now" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                    </td>
                                                    ';
                                                }
                                                else if ($data['PaymentStatus']=="By Hotel" && is_null($data['EndTime']))
                                                {
                                                    if($driveramountbookings==1 && $data["driveramount_enable"] == "enable"){
                                                      echo '
                                                <td style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;">Amount (AED.)</td>
                                                <td align="r-+ight" style="border-bottom: 2px solid #000; border-top: 2px solid #000; font-weight: bold; padding: 5px 0;">
                                                            <input type="text" name="amount" id="Amount" value="'.$data['fare'].'" placeholder="trip charges" required/></td>
                                                            <br>'; 
                                                    }
                                                    else{
                                                        echo '
                                                            <input type="hidden" name="amount" id="Amount" value="'.$data['fare'].'"/>"
                                                            
                                                            '; 
                                                            echo '
                                                            AED. '.$data['fare'].'
                                                            </td>
                                                            ';
                                                    }
                                                    echo 
                                                    
                                                    '
                                                    <tr>
                                                    <td colspan="2">
                                                    <input type="button" name="endtrip" id ="endtrip" value="End Trip Now" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                    </td>
                                                    </tr>
                                                    ';
                                                }
                                                else if ($data['PaymentStatus']=="Un-paid" && !is_null($data['EndTime']))
                                                {
                                                            if($_SESSION['driverid']>0){
                                                            echo '
                                                            <td colspan="2">
                                                            <br>
                                                            <select class="form-control custom-select" name="pay_option" onchange="ShowPRDiv()" id="pay_option" required>
                                                                <option value=""  disabled>-- Select Pay Option --</option>
                                                                <option value="cash" selected>Cash</option>
                                                                <option value="card"  id="optionCard">Credit Card</option>
                                                            </select>
                                                        
                                                            
                                                            
                                        <br><br>
                                                    <div id="PaymentReferenceDiv" style="display:none">
                                                        <label>Payment Reference Number:</label>
                                                        <input type=" " name="PaymentReference" id="PaymentReference" value="" placeholder=""/>
                                                    </div>
                                        <br>
                                        
                                                            <input type="submit" name="collectcash" id ="collectcash" value="Collect Payment" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                        
                                                            </td>
                                                            ';
                                                            }
                                                }
                                                else if ($data['PaymentStatus']=="By Room" && !is_null($data['EndTime']))
                                                {
                                                            if($_SESSION['driverid']>0){
                                                            echo '
                                                            <td colspan="2">
                                                            <br>
                                                            
                                                            <input type="hidden" value="room" name="pay_option">
                                                       
                                        <br>
                                        
                                                            <input type="submit" name="collectcash" id ="collectcash" value="Collect Payment" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                        
                                                            </td>
                                                            ';
                                                            }
                                                }
                                                else if ($data['PaymentStatus']=="By Cash" && !is_null($data['EndTime']))
                                                {
                                                            if($_SESSION['driverid']>0){
                                                            echo '
                                                            <td colspan="2">
                                                            <br>
                                                            
                                                            <input type="hidden" value="cash" name="pay_option">
                                                       
                                        <br>
                                        
                                                            <input type="submit" name="collectcash" id ="collectcash" value="Collect Payment" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                        
                                                            </td>
                                                            ';
                                                            }
                                                }
                                                else if ($data['PaymentStatus']=="By Credit Card" && !is_null($data['EndTime']))
                                                {
                                                            if($_SESSION['driverid']>0){
                                                            echo '
                                                            <td colspan="2">
                                                            <br>
                                                            
                                                            <input type="hidden" value="card" name="pay_option">
                                                        
                                                            
                                                            
                                                    <div>
                                                        <label>Payment Reference Number:</label>
                                                        <input type=" " name="PaymentReference" id="PaymentReference" value="" placeholder=""/>
                                                    </div>
                                        <br>
                                        
                                                            <input type="submit" name="collectcash" id ="collectcash" value="Collect Payment" class="btn btn-theme text-white ctm-border-radius btn-block"/>
                                                        
                                                            </td>
                                                            ';
                                                            }
                                                }
                                                
                                                else
                                                {
                                                            echo '
                                                           <td colspan="2">
                                                           <a href="./print5.php?id='.$data['BookingNumber'].'" class="btn btn-theme button-1 text-white ctm-border-radius mt-4 lnr lnr-printer">Receipt</a>
                                                           <a href="./print1.php?id='.$data['BookingNumber'].'" class="btn btn-danger text-white ctm-border-radius mt-4 lnr lnr-printer">Invoice</a>
                                                           </td>
                                                           ';
                                                }?>
                                                
                                            </tr>
                                        </tbody>
                                                
                                        
                                    </table>
                                   
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
                <td width="2px" style="padding: 10;"></td>
            </tr>

        </tbody>
    </table>
    </div>
    <br>
    <br>
</form>
        
      </div>
</div>
</div>
        </div>
    </div>
</div>    	 

<script>

let PaymentReferenceDiv = document.querySelector("#PaymentReferenceDiv");
let optionCard = document.querySelector("#optionCard");
let PayOption = document.querySelector("#pay_option");

function ShowPRDiv (){
if(PayOption.options[PayOption.selectedIndex] == optionCard){
    PaymentReferenceDiv.style.display = "block";
}else{
    PaymentReferenceDiv.style.display = "none";
}
}


// function getBaseUrl() {
//     var re = new RegExp(/^.*\//);
//     return re.exec(window.location.hostname);
// }

// $(document).ready(function(){
    
// $(document).on('click','#cancelridecustomer', function() { 
    
//     // $('#cancelridecustomer').prop('disabled', true);
    
//     // alert( "Handler for .click() called." );
//     var url1 = './ajax/cancelRideCustomer.php';

//       // proceed with form submission
//       $.ajax({
//       	url: url1,
//       	type: 'post',
//       	data: {
//       		'id' : $('#userid').val(),
//       		'BookingNo' : $('#bookingno').val(),
      		
//       	},
//       	success: function(response){
//       		alert('Trip Cancelled.');
//       		location.reload();
//       		// windows.location.href?id=$('#bookingno').val();
//       	}
//     });
// });


$(document).on('click','#cancelridedriver', function() { 

        var url1 = './ajax/cancelRideDriver.php';
        
        alert('Ride Cancel called');
      // proceed with form submission
      $.ajax({
      	url: url1,
      	type: 'post',
      	data: {
      	    'id' : <?php echo $_SESSION['driverid'];?>,
      		'Tag' : "end",
      		'BookingNo' : $('#bookingno').val(),
      		'amount' : "$('#Amount').val()",
      	},
      	success: function(response){
      		alert('Ride Cancelled');
      		window.location.replace("index.php");
      		location.reload();
      		// windows.location.href?id=$('#bookingno').val();
      	}
    });
});

$(document).on('click','#starttrip', function() { 
    
    // $('#starttrip').prop('disabled', true);
    
    var url1 = './ajax/tripstartend.php';

      // proceed with form submission
      $.ajax({
      	url: url1,
      	type: 'post',
      	data: {
      		'Tag' : "start",
      		'BookingNo' : $('#bookingno').val(),
      		'amount' : "<?php echo $data["fare"] ?>",
      		
      	},
      	success: function(response){
      		alert('Trip Started');
      		location.reload();
      		// windows.location.href?id=$('#bookingno').val();
      	}
    });
});

$(document).on('click','#endtrip', function() { 
    
    // $('#endtrip').prop('disabled', true);
    
    var url1 = './ajax/tripstartend.php';
    <?php if($data["PaymentStatus"] == "By Hotel" && $driveramountbookings==1 && $data["driveramount_enable"] == "enable"){
      		    ?> 
      		    
      		    let ajaxValue = $("#Amount").val();
      		    let destinationValue =  $("#destination").val();
      		    <?php
      		}else{ ?>
      		    let ajaxValue = <?php echo $data["fare"]?>;
      		    let destinationValue = "<?php echo $data["Destination"]?>:";
      		
      		<?php } ?>
      		

    

    $.ajax({
      	url: url1,
      	type: 'post',
      	data: {
      		'Tag' : "end",
      		'BookingNo' : $('#bookingno').val(),
      		'amount' : ajaxValue,
      		'destination': destinationValue,
      		
      	},
      	success: function(response){
      		alert('Trip Ended');
      		// windows.location.href?id=$('#bookingno').val();
      		location.reload();
      	}
    });
     
});

/*
$(document).on('click','#collectcash', function() { 

        var url1 = './ajax/receiveCash.php';
      // proceed with form submission
      $.ajax({
      	url: url1,
      	type: 'post',
      	data: {
      	    'id' : <?php echo $_SESSION['driverid'];?>,
      		'Tag' : "end",
      		'BookingNo' : $('#bookingno').val(),
      		'amount' : $('#Amount').val(),
      	},
      	success: function(response){
      		alert('Collection Recorded');
      		location.reload();
      		// windows.location.href?id=$('#bookingno').val();
      	}
    });
});
*/
</script>

<?php include("scripts.php");?>
    
<div class="sidebar-overlay" id="sidebar_overlay"></div>
</div>
</body>
</html>