MMCT TEAM
Server IP : 82.112.239.40  /  Your IP : 18.217.142.228
Web Server : LiteSpeed
System : Linux in-mum-web1676.main-hosting.eu 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64
User : u641149403 ( 641149403)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u641149403/domains/cabz4you.com/public_html/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u641149403/domains/cabz4you.com/public_html/admin/list_booking.php
<style type="text/css">
	.listbooking{
		position: absolute;
		top: 60px;
		right: 230px;
	}
	.listbooking i{
		border: 1px solid #000;
	}
	.mkact{
		display: block !important;
	}
	.modal-content .btn-sm{
		display: none;
	}
	tfoot{
		background: #232325;
		text-transform: uppercase;
		color: #fff;
	}
	tfoot th{
		padding: 11px!important;
	}
	.btn-green{
		background: #22bb33!important;
		color: #fff!important;
	}
	.color_white{
		color: #fff!important;
	}
	.btn-orange{
		background: orange!important;
		color: #fff!important;
	}
	.w-100{
		color: #fff!important;
	}

	.searchable input {
		width: 100%;
		/*height: 50px;*/
		margin-top: 2px;
		font-size: 14px;
		padding: 6px;
		-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
		-moz-box-sizing: border-box; /* Firefox, other Gecko */
		box-sizing: border-box; /* Opera/IE 8+ */
		display: block;
		font-weight: 400;
		line-height: 1.6;
		color: #495057;
		background-color: #fff;
		background-clip: padding-box;
		border: 1px solid #ced4da;
		border-radius: .25rem;
		transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
		background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right .75rem center/8px 10px;
	}
	.searchable ul {
		display: none;
		list-style-type: none;
		background-color: #fff;
		border-radius: 0 0 5px 5px;
		border: 1px solid #add8e6;
		border-top: none;
		max-height: 180px;
		margin: 0;
		overflow-y: scroll;
		overflow-x: hidden;
		padding: 0;
	}
	.searchable ul li {
		padding: 7px 9px;
		border-bottom: 1px solid #e1e1e1;
		cursor: pointer;
		color: #6e6e6e;
	}
	.searchable ul li.selected {
		background-color: #e8e8e8;
		color: #333;
	}
	.search_list{
		position: absolute;
		z-index: 1000;
	}
	input::-webkit-input-placeholder {
		font-size: 15px;
	}
	input:focus{
		border: 1px solid #e2e2e2!important;
	}
	.input-group .form-control:focus{
		border: 1px solid #e2e2e2!important;
	}
	.card .dataTables_wrapper .table td, .card .dataTables_wrapper .table th{
		padding: 8px 20px!important;
		text-align: center!important;
	}
	.bg_success{
		background: #0bc736!important;
	}
	.bg_success td{
		color: #fff;
	}
	table label{
		font-size: .8125rem!important;
		padding: 10px!important;
		margin-bottom: 0;
		width: 100%;
	}
	.cancel_types,#penalty_amount{
		display: none;
	}

	.list-style-desc{
		padding-left: 20px;
	}
	.list-style-desc li{
		list-style: disc!important;
		margin-bottom: 3px;
	}
	#view_modal table td{
		white-space: normal;
	}
</style>
<?php
require_once 'header.php';
require_once 'navbar.php';
if(!isset($_GET['type']))
{
	header("location:404");
}

if (isset($_POST['notify'])) {
	$book_id=$_POST['notify'];
	$sql="select booking_from,booking_to from bookings where id=$book_id";
	$result = $conn->query($sql);
	$book = $result->fetch_assoc();

	$date=date('Y-m-d h:i:s');
	$admin_user_id=$_SESSION['session_login'];
	$sql=$conn->query("INSERT INTO user_role_activity(booking_id,user_id,type,created_at) VALUES ('$booking_id','$admin_user_id','Notify','$date')");

	$title="New Outstation Booking";
	$content=$book['booking_from']." to ".$book['booking_to'];
	pushapi($title,$content,$link,$book_id);
}

if($_SERVER["REQUEST_METHOD"] == "POST")
{
	if(isset($_POST['commition']))
	{
		$time_stamp = date('Y-m-d H:i:s');
		$commition=$_POST['commition'];
		$booking_id=$_POST['pass_id'];
		$sql="update bookings set admin_commission=$commition,status='vendor_pass',time_stamp='$time_stamp' where id=$booking_id";
		if($conn->query($sql)===true)
		{
			$date=date('Y-m-d h:i:s');
			$admin_user_id=$_SESSION['session_login'];
			$sql=$conn->query("INSERT INTO user_role_activity(booking_id,user_id,type,created_at) VALUES ('$booking_id','$admin_user_id','Booking Pass','$date')");

			$success=true;
			$sql="select booking_from,booking_to from bookings where id=$booking_id";
			$result = $conn->query($sql);
			$book = $result->fetch_assoc();

			$title="New Outstation Booking";
			$content=$book['booking_from']." to ".$book['booking_to'];
			pushapi($title,$content,$link,$booking_id);
		}
	}

	if(isset($_POST['ccbooking_id']) && isset($_POST['ccvendor_id'] ))
	{
		$vendor_id=$_POST['ccvendor_id'];
		$booking_id=$_POST['ccbooking_id'];
		$driver_id=$_POST['new_driver'];
		$cab_id=$_POST['new_cab'];
		if($driver_id>0 && $cab_id > 0)
		{
			$sql="update bookings set driver_id=$driver_id,cab_id=$cab_id where id=$booking_id";
			if($conn->query($sql)===true)
			{
				$date=date('Y-m-d h:i:s');
				$admin_user_id=$_SESSION['session_login'];
				$sql=$conn->query("INSERT INTO user_role_activity(booking_id,user_id,type,created_at) VALUES ('$booking_id','$admin_user_id','Assign Driver and Cab','$date')");
				$success=true;
			}
			else
			{
				$error=true;
			}
		}
		else
		{
			$error=true;
		}
	}
	if(isset($_POST['custom_vendor']))
	{
		$custom_vendor=$_POST['custom_vendor'];
		$booking_id=$_POST['custom_id'];
		
		$commition=$_POST['comission'];

		$select_vendor = $conn->query("SELECT *,vendor_login.contact as vendor_contact FROM bookings INNER JOIN vendor_profile ON vendor_profile.vendor_id=bookings.vendor_id INNER JOIN vendor_login ON vendor_login.id=bookings.vendor_id LEFT JOIN drivers ON drivers.id=bookings.driver_id WHERE bookings.id=$booking_id AND bookings.vendor_id!=$custom_vendor AND bookings.vendor_id!=0 AND bookings.vendor_id!=''");
		if ($select_vendor->num_rows>0) {
			$fetch_data = $select_vendor->fetch_assoc();
			$vendor_contact = $fetch_data['vendor_contact'];
			
$msg = "Hi ЁЯСЛ ".$fetch_data['full_name']." inform that BOOKING ID: C4U".$booking_id." DEL-".$fetch_data['d_l_no']." ".$fetch_data['booking_from']." To, ".$fetch_data['booking_to']." ".$fetch_data['cab_type']." ".$fetch_data['trip_type']." TRIP Date ".$fetch_data['pickup_date']." Time ".$fetch_data['pickup_time'].". 

BOOKING has been Assigned

Thanks For 
Cabz4you.";
whatsapp($vendor_contact,$msg);

		}

		$sql="update bookings set admin_commission=$commition,vendor_id=$custom_vendor,status='confirmed' where id=$booking_id";
		if($conn->query($sql)===true)
		{
			$date=date('Y-m-d h:i:s');
			$admin_user_id=$_SESSION['session_login'];
			$sql=$conn->query("INSERT INTO user_role_activity(booking_id,user_id,type,created_at) VALUES ('$booking_id','$admin_user_id','Assign Vendor','$date')");

			$res=$conn->query("SELECT * FROM vendor_login LEFT JOIN vendor_profile ON vendor_profile.vendor_id=vendor_login.id WHERE id=$custom_vendor");
			$vendor_data = $res->fetch_assoc();
			$vendor_contact = $vendor_data['contact'];
			$booking_data = $conn->query("SELECT bookings.*,payment_log.txn_amount FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id WHERE bookings.id=$booking_id");
			$bookings = $booking_data->fetch_assoc();

			$included_exclude='';
			if ($bookings['toll_tax']==0) {
				$included_exclude.="Toll Tax - Included \n";
			}else{
				$included_exclude.="Toll Tax - Excluded \n";
			}
			if ($bookings['state_tax']==0) {
				$included_exclude.="State Tax - Included \n";
			}else{
				$included_exclude.="State tax - Excluded \n";
			}
			if ($bookings['parking']==0) {
				$included_exclude.="Parking - Included \n";
			}else{
				$included_exclude.="Parking - Excluded";
			}
			
$vendor_amount = $bookings['price']-$bookings['admin_commission'];
$msg = "Hi ЁЯСЛ ".$vendor_data['full_name']." inform that BOOKING ID: C4U".$booking_id." ".$bookings['booking_from']." To, ".$bookings['booking_to']." ".$bookings['cab_type']." ".$bookings['trip_type']." Trip Date ".$bookings['pickup_date']." Time ".$bookings['pickup_time'].". 

BOOKING has been Assigned

Important ЁЯдФ information тД╣я╕П

Please Update Car ЁЯЪЧ & Driver Details...

30 minutes ЁЯТп Penalties..

".$included_exclude."

Airport Entry тЫФ charge Etc,

Distance  ".$bookings['distance']."Kms.

рдХреГрдкрдпрд╛ рдзреНрдпрд╛рди рд░рд╣реЗ рдХрд╕реНрдЯрдорд░ рдХреА рдЯреНрд░рд┐рдк рд╕реНрдЯрд╛рд░реНрдЯ рдХрд░рддреЗ рд╕рдордп рдФрд░ рдЯреНрд░рд┐рдк рдПрдВрдб рдХрд░рддреЗ рд╕рдордп рдУрдЯреАрдкреА рд╡реЗрд░реАрдлрд╛рдИ рдХрд░рдирд╛ рдЖрд╡рд╢реНрдпрдХ рд╣реИ рдФрд░ рдЕрдкрдиреЗ рдСрдбреЛрдореАрдЯрд░ рдХреА рдлреЛрдЯреЛ рдЦреАрдВрдЪрдХрд░ рдЯреНрд░рд┐рдк рд╕реНрдЯрд╛рд░реНрдЯ рдХрд░рддреЗ рд╕рдордп рдФрд░ рдЯреНрд░рд┐рдк рдРрдб рдХрд░рддреЗ рд╕рдордп рд╣рдореЗрдВ рдЗрд╕ рд╡реНрд╣рд╛рдЯреНрд╕рдПрдк рдирдВрдмрд░ рдкрд░ рднреЗрдЬреЗрдВ рдРрд╕рд╛ рди рдХрд░рдиреЗ рдкрд░ рд░реБ300 рд╕реЗ тВ╣500 рддрдХ рдХреА рдкреЗрдирд▓реНрдЯреА рд▓рдЧ рд╕рдХрддреА рд╣реИ

Thanks For
Cabz4u Team";
whatsapp($vendor_contact,$msg);

			$time_stamp=date('Y-m-d H:i:s');
			$query=$conn->query("SELECT * FROM vendor_profile WHERE vendor_id=$custom_vendor");
			$row=$query->fetch_assoc();
			$wallet_amount = $row['w_amount'];

			$sql="update vendor_profile set w_amount=w_amount-$commition where vendor_id=$custom_vendor";
			if($conn->query($sql)===true)
			{
		             // booking confirm id24 id
				$sql="Insert into transaction_log(vendor_id,amount,txn_type,action,wallet_amount,time) values($custom_vendor,$commition,'Debit','Charges for booking confirmation give by admin','$wallet_amount','$time_stamp')";
				if($conn->query($sql)===true)
				{
					$success=true;
				}
			}
		}
		else
		{
			$error=true;
		}
		
	}
}
$type=test_input($_GET['type']);
$current_time=date('Y-m-d H:i:s');
if($_POST['date']){
	$date = explode('-', $_POST['date']);
	$date1 = date('Y-m-d', strtotime($date[0]));
	$date2 = date('Y-m-d', strtotime($date[1]));
	$filter="AND DATE(time_stamp) BETWEEN '$date1' AND '$date2'";

}else{
	$filter='';
}

switch($type)
{
	
	case "pending":
	$one=true;
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE bookings.status='booked' $filter ORDER BY bookings.pickup_date DESC";
	
	break;

	case "all":
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE bookings.status!='' $filter ORDER BY bookings.pickup_date DESC";
	break;

	case "post_booking":
	$sql = "select bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* from bookings,payment_log,users where users.id=bookings.user_id and  payment_log.txn_status is true and bookings.id=payment_log.booking_id and bookings.booking_type='Vendor App' and company_type IS NULL $filter order by bookings.pickup_date desc";
	break;

	case "vendor_pass":
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE bookings.status='vendor_pass' AND TIMESTAMP(`pickup_date`, `pickup_time`)>='$current_time' $filter ORDER BY bookings.pickup_date DESC";
	
	break;
	case "cancelled":
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE bookings.status='cancelled' $filter ORDER BY bookings.pickup_date DESC";
	
	break;
	case "completed":
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE bookings.status='completed' $filter ORDER BY bookings.pickup_date DESC";

	break;
	case "new":
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE bookings.booking_type!='Admin' AND seen=0 $filter ORDER BY bookings.pickup_date DESC";

	break;
	case "expired":
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE bookings.status='vendor_pass' AND TIMESTAMP(`pickup_date`, `pickup_time`)<'$current_time' $filter ORDER BY bookings.pickup_date DESC";

	break;
	case "complete_request":
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE bookings.booking_request=1 $filter ORDER BY bookings.pickup_date DESC";

	break;
	case "profit":
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE incentive < admin_commission $filter ORDER BY bookings.pickup_date DESC";

	break;
	case "loss":
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE incentive > admin_commission $filter ORDER BY bookings.pickup_date DESC";

	break;
	default:
	$sql="SELECT bookings.*,bookings.id as bk_id,payment_log.txn_amount,payment_log.booking_id,users.* FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE bookings.status='confirmed' $filter ORDER BY bookings.pickup_date DESC";
	
}
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
	while($row = $result->fetch_assoc()) {
		$table_data[]=$row;
	}
}

$sql="select * from vendor_profile,vendor_login where vendor_login.id=vendor_profile.vendor_id";
$res=$conn->query($sql);
while($row=$res->fetch_assoc())
{
	$vendors[]=$row;
}
?>
<style>
	/*.daterange{
		position: absolute;
	    top: 60px;
	    left: 125px;
	    z-index: 1000;
	}*/
	.listbooking{
		position: static;
	}
</style>
<!-- Page content -->
<div class="container-fluid pt-8">
	<div class="page-header mt-0  p-3">
		<h3 class="mb-sm-0 text-capitalize"><?= str_replace('_', ' ', $type);?> Bookings</h3>
		<ol class="breadcrumb mb-0">
			<li class="breadcrumb-item"><a href="#"><i class="fa fa-home"></i></a></li>
			<li class="breadcrumb-item active" aria-current="page"><?=str_replace('_', ' ', $type);?> Bookings</li>
		</ol>
	</div>
	<?php
	if(isset($success))
	{
		?>
		<div class="alert alert-success" id="success">Success! Your Request has been submited.</div>
		<?php
	}
	else if(isset($error))
	{
		?>
		<div class="alert alert-danger" id="success">Error! Your Request could not be submited.</div>
		<?php
	}
	?>
	<div class="alert " id="msg" style="display:none"></div>
	<div class="card shadow">
		<div class="card-body">
			<?php
			if(isset($table_data))
			{
				?>
				<div class="row">
					<div class="col-lg-4">
						<form method="post">
							<div class="input-group daterange">
								<input id="reportrange" type="text" name="date" class="form-control" placeholder="Search">
								<i class="ni ni-calendar-grid-58"></i>
								<div class="input-group-append">
									<button class="btn btn-success" type="submit">Go</button>
								</div>
							</div>
						</form>
					</div>
					<?php if($filter!=''){ ?>
						<div class="col-lg-2 text-right">
							<a class="btn btn-danger" href="">Remove Filter</a>
						</div>
					<?php } ?>
					<div class="col-lg-6">
						<div class="listbooking d-flex align-items-center justify-content-end">
							<h4 class="badge badge-dark mb-0 py-2 px-3 mr-4 text-uppercase"><?= str_replace('_', ' ', $type);?>&nbsp; : <?=$result->num_rows?></h4>
							<span class="mr-2">
								<i class="fas fa-square text-white"></i> ADMIN
							</span>
							<span class="mr-2">
								<i class="fas fa-square bg-danger text-danger"></i> VENDOR
							</span>
						</div>
					</div>
				</div>

				<div class="table-responsive" style="overflow-x:auto;">
					
					<table id="example" class="table text-center table-striped table-bordered text-nowrap">
						<thead class="">
							<tr>
								<th class="wd-15p">S.No</th>
								<th class="wd-15p">View</th>
								<th class="wd-10p">action</th>
								<th class="wd-15p">Booking ID</th>
								<?php if($type=='post_booking' || $type=='all'){?>
									<th class="wd-15p">Status</th>
								<?php } ?>
								<th class="wd-15p">From </th>
								<th class="wd-15p">To</th>
								<th class="wd-15p">Booking Stop</th>
								<th class="wd-15p">Package</th>
								<th class="wd-15p">Company Booking ID</th>
								<th class="wd-15p">Company Booking Type</th>
								<th class="wd-20p">Name</th>
								<th class="wd-20p">Contact</th>
								<th class="wd-20p">Email</th>
								<th class="wd-20p">Trip type</th>
								<th class="wd-20p">Cab Type</th>
								<th class="wd-15p">Pickup Date</th>
								<th class="wd-20p">pickup time</th>
								<th class="wd-20p">Drop Date</th>
								<th class="wd-15p">Amount</th>
								<th class="wd-15p">Advance Amount</th>
								<th class="wd-15p">Balance Amount</th>
								<th class="wd-15p">Incentive</th>
								<th class="wd-15p">Admin Commission</th>
								<th class="wd-15p">Loss</th>
								<th class="wd-15p">Profit</th>
								<th class="wd-15p">Vendor Commission</th>
								<th class="wd-15p">Pickup Address</th>
								<th class="wd-15p">Drop Address</th>
								<th class="wd-15p">Toll Tax</th>
								<th class="wd-15p">State Tax</th>
								<th class="wd-15p">Parking</th>
								<th class="wd-15p">Night Charge</th>
								<th class="wd-15p">Extra Price</th>
								<th class="wd-15p">Carrier</th>
								<th class="wd-15p">Pet</th>
								<th class="wd-15p">Driver App</th>
								<th class="wd-15p">Extra Requirement</th>
								<th class="wd-15p">Billing Name</th>
								<th class="wd-15p">GST No.</th>
								<th class="wd-15p">Amenities</th>
								<th class="wd-15p">Remark</th>
								<th class="wd-15p">Booking Type</th>
								<th class="wd-15p">Post Vendor ID</th>
								<th class="wd-15p">Post Vendor Name</th>
								<th class="wd-15p">Post Vendor Contact</th>
								<?php if ($type!='pending' && $type!='vendor_pass') { ?>
									<th class="wd-15p">Accept Vendor id</th>
									<th class="wd-15p">Accept Vendor Name</th>
									<th class="wd-15p">Accept Vendor Contact</th>
									<!-- <th class="wd-15p">Agent id</th> -->
									<th class="wd-15p">cab Id</th>
									<th class="wd-15p">Driver id</th>
								<?php } ?>
								<th class="wd-15p">Posted Date/Time</th>
								<?php if ($type!='pending') { ?>
									<th class="wd-15p">Accepted Date/Time</th>
									<?php if($type=='completed'){ ?>
										<th class="wd-15p">Completed Date/Time</th>
									<?php } if($type=='cancelled'){ ?>
										<th class="wd-15p">Cancelled Date/Time</th>
									<?php } } ?>
									<th>Comment</th>
								</tr>
							</thead>
							<tfoot>
								<tr>
									<th class="wd-15p">S.No</th>
									<th class="wd-15p">View</th>
									<th class="wd-10p">action</th>
									<th class="wd-15p">Booking ID</th>
									<?php if($type=='post_booking' || $type=='all'){?>
										<th class="wd-15p">Status</th>
									<?php } ?>
									<th class="wd-15p">From </th>
									<th class="wd-15p">To</th>
									<th class="wd-15p">Booking Stop</th>
									<th class="wd-15p">Package</th>
									<th class="wd-15p">Company Booking ID</th>
									<th class="wd-15p">Company Booking Type</th>
									<th class="wd-20p">Name</th>
									<th class="wd-20p">Contact</th>
									<th class="wd-20p">Email</th>
									<th class="wd-20p">Trip type</th>
									<th class="wd-20p">Cab Type</th>
									<th class="wd-15p">Pickup Date</th>
									<th class="wd-20p">pickup time</th>
									<th class="wd-20p">Drop Date</th>
									<th class="wd-15p">Amount</th>
									<th class="wd-15p">Advance Amount</th>
									<th class="wd-15p">Balance Amount</th>
									<th class="wd-15p">Incentive</th>
									<th class="wd-15p">Admin Commission</th>
									<th class="wd-15p">Loss</th>
									<th class="wd-15p">Profit</th>
									<th class="wd-15p">Vendor Commission</th>
									<th class="wd-15p">Pickup Address</th>
									<th class="wd-15p">Drop Address</th>
									<th class="wd-15p">Toll Tax</th>
									<th class="wd-15p">State Tax</th>
									<th class="wd-15p">Parking</th>
									<th class="wd-15p">Night Charge</th>
									<th class="wd-15p">Extra Price</th>
									<th class="wd-15p">Carrier</th>
									<th class="wd-15p">Pet</th>
									<th class="wd-15p">Driver App</th>
									<th class="wd-15p">Extra Requirement</th>
									<th class="wd-15p">Billing Name</th>
									<th class="wd-15p">GST No.</th>
									<th class="wd-15p">Amenities</th>
									<th class="wd-15p">Remark</th>
									<th class="wd-15p">Booking Type</th>
									<th class="wd-15p">Post Vendor ID</th>
									<th class="wd-15p">Post Vendor Name</th>
									<th class="wd-15p">Post Vendor Contact</th>
									<?php if ($type!='pending' && $type!='vendor_pass') { ?>
										<th class="wd-15p">Accept Vendor id</th>
										<th class="wd-15p">Accept Vendor Name</th>
										<th class="wd-15p">Accept Vendor Contact</th>
										<!-- <th class="wd-15p">Agent id</th> -->
										<th class="wd-15p">cab Id</th>
										<th class="wd-15p">Driver id</th>
									<?php } ?>
									<th class="wd-15p">Posted Date/Time</th>
									<?php if ($type!='pending') { ?>
										<th class="wd-15p">Accepted Date/Time</th>
										<?php if($type=='completed'){ ?>
											<th class="wd-15p">Completed Date/Time</th>
										<?php } if($type=='cancelled'){ ?>
											<th class="wd-15p">Cancelled Date/Time</th>
										<?php } } ?>
										<th>Comment</th>
									</tr>
								</tfoot>
								<tbody>
									<?php
									$x=1;
									foreach($table_data as $hh)
									{
										if ($hh['booking_type']=='Website') {
											$color = 'bg_success';
											$text_color='text-white';
										}elseif($hh['company_type']!=''){
											$color = 'bg-warning text-white';
											$text_color='text-white';
										}elseif($hh['booking_type']=='Vendor App'){
											$color = 'bg-danger text-white';
											$text_color='text-white';
										}else{
											$color = 'none';
											$text_color='';
										}
										$loss = 0;
										$profit = 0;
										if ($hh['incentive']>$hh['admin_commission']) {
											$loss = $hh['incentive']-$hh['admin_commission'];
										}else{
											$profit = $hh['admin_commission']-$hh['incentive'];
										}
										$admin_data=$conn->query("SELECT * FROM user_role_activity WHERE booking_id='".$hh['bk_id']."'");
										?>
										<tr class="<?php echo $color; ?>" id="row<?=$hh['bk_id'];?>">
											<td><?=$x;?></td>
											<td class="action">
												<?php if ($type=='new') { ?>
													<button type="button" onclick="removebooking(<?=$hh['bk_id'];?>)" class="badge badge-danger btn-sm"><i class="fa fa-times"></i></button>
												<?php } ?>
												<a href="#" class="badge view_btn btn-sm" style="background: #000;color: #fff!important;padding: 5px;"><i class="fas fa-pencil-alt"></i></a>
												<?php if($admin_data->num_rows>0){ ?>
													<a href="javascript:void[0]" class="badge btn-sm" data-toggle="tooltip" title="User Activity" onclick="get_role_data(<?=$hh['bk_id'];?>)" style="background: #000;color: #fff!important;padding: 5px;"><i class="fas fa-eye"></i></a>
												<?php } ?>
											</td>
											<td class="buttons">
												<div class="dropdown">
													<button class="btn btn-primary btn-sm dropdown-toggle" type="button" data-toggle="dropdown">Action
														<span class="caret"></span></button>
														<ul class="dropdown-menu p-2" id="buttons">
															<?php
															if($hh['status']=='booked')
															{
																?>
																<li>

																	<li><button id="<?=$hh['bk_id'];?>" onclick="confirm_booking(this.value,this.id)" value="pass" class="btn btn-orange w-100 color_white text-white" type="button">
																		Pass
																	</button></li>
																	<li><button id="<?=$hh['bk_id'];?>" onclick="confirm_booking(this.value,this.id);" value="custom" class="btn btn-primary w-100 color_white mt-1 mb-1" type="button">
																		Custom
																	</button></li>
																	<li><button id="<?=$hh['bk_id'];?>" onclick="cancel_booking(this.id);" class="btn btn-danger mt-1 mb-1 w-100 color_white" type="button" data-toggle="modal" data-target="#cancel_modal">
																		Cancel Ride
																	</button></li>
																	<li id="edit_book"><a  href="edit_bookings?token=<?=$hh['bk_id'];?>"  class="btn btn-green w-100 mt-1 mb-1" >Edit booking
																	</a></li>
																	<?php
																}
																if($hh['status']=='confirmed')
																{
																	if($hh['driver_id']==0 && $hh['cab_id']==0)
																	{
																		?>
																		<li> <button onclick="change_driver(this.id,this.value)" id="<?=$hh['vendor_id'];?>" value="<?=$hh['bk_id'];?>" class="w-100 btn btn-primary mt-1 mb-1" type="button">Change Driver & Cab 
																		</button></li>
																		<li> <button  onclick="complete(this.value)" value="<?=$hh['bk_id'];?>" class="btn btn-primary mt-1 mb-1 w-100" type="button">Complete Ride 
																		</button></li>
																		<?php
																	}
																	else
																	{
																		?>
																		<li> <button onclick="change_driver(this.id,this.value)" id="<?=$hh['vendor_id'];?>" value="<?=$hh['bk_id'];?>" class="w-100 btn btn-primary mt-1 mb-1" type="button">Change Driver & Cab 
																		</button></li>
																		<li> <button  onclick="complete(this.value)" value="<?=$hh['bk_id'];?>" class="btn btn-primary mt-1 mb-1 w-100" type="button">Complete Ride 
																		</button></li>
																		<li> <button  onclick="passinfo(this.value)" value="<?=$hh['bk_id'];?>" class="btn btn-orange w-100 mt-1 mb-1" type="button">Information Pass
																		</button></li>
																		<?php
																	}
																	?>
																	<li> <button id="<?=$hh['bk_id'];?>" onclick="confirm_booking(this.value,this.id);" value="custom" class="btn btn-primary w-100 mt-1 mb-1" type="button"><?php
																	if($hh['vendor_id']==0)
																	{
																		echo "Add Vendor";
																	}
																	else
																	{
																		echo "Change Vendor";
																	}
																	?>
																</button></li>
																<li><button id="<?=$hh['bk_id'];?>" onclick="cancel_booking(this.id);" class="btn btn-danger mt-1 mb-1 w-100" type="button" data-toggle="modal" data-target="#cancel_modal">
																	Cancel Ride
																</button></li>
																<li id="edit_book"><a  href="edit_bookings?token=<?=$hh['bk_id'];?>"  class="btn btn-green mt-1 mb-1 w-100" >Edit booking
																</a></li>
																<?php
															}
															else if($hh['status']=='vendor_pass')
															{
																?>
																<li>
																	<form method="post" class="mb-1">
																		<button  value="<?=$hh['bk_id'];?>" class="btn btn-orange w-100 color_white text-white" type="submit" name="notify">
																			Notify
																		</button></form></li>
																		<li>  	<button id="<?=$hh['bk_id'];?>" onclick="confirm_booking(this.value,this.id);" value="custom" class="btn btn-primary mt-1 mb-1 w-100" type="button">
																			<?php
																			if($hh['vendor_id']==0){
																				echo  "Custom Vendor";
																			}
																			else
																			{
																				echo "Change Vendor";
																			}
																		?>	</button></li>
																		<li>	<button id="<?=$hh['bk_id'];?>" onclick="cancel_booking(this.id);" class="btn btn-danger mt-1 mb-1 w-100" type="button" data-toggle="modal" data-target="#cancel_modal">
																			Cancel Ride
																		</a></li>
																		<li id="edit_book"><a  href="edit_bookings?token=<?=$hh['bk_id'];?>"  class="btn btn-green w-100 mt-1 mb-1">Edit booking
																		</a>
																	</li>
																	<?php
																}  
																?>
																<?php
																if($hh['status']=='completed'){ ?>
																	<?php if($hh['post_by_id']!='' && $hh['post_by_id']!=0){ ?>
																		<li><button id="<?=$hh['bk_id']?>" onclick="commissiong_log(this.value,this.id);" value="<?= $hh['post_by_id']; ?>" amount="<?=$hh['admin_commission']?>" class="btn btn-icon w-100 btn-green mt-1 mb-1" type="button">
																			Vendor Commission
																		</button></li>
																	<?php } ?>
																	<li><a href="print.php?id=<?=$hh['bk_id'];?>" class="btn mt-1 mb-1 w-100" type="button" style="background:#5bc0de;color: #fff;">Bill with GST  
																	</a></li>
																	<li><a href="invoice.php?id=<?=$hh['bk_id'];?>" class="btn w-100 mt-1 mb-1" type="button" style="background:#5bc0de;color: #fff;">Bill without GST  
																	</a></li>
																<?php } ?>

																<?php if ($hh['customer_details']==0) {
																	$customer_details = 'Show Customer Details';
																}else{
																	$customer_details = 'Hide Customer Details';
																}
																?>
																<li>
																	<button onclick="customer_detail_hide_show(<?=$hh['bk_id']?>,<?=$hh['customer_details']?>);" class="btn w-100 btn-green mt-1 mb-1" type="button"><?=$customer_details?></button>
																</li>

																<li>
																	<button onclick="comment_box(<?=$hh['bk_id']?>,'<?=$hh['comment']?>');" class="btn btn-icon w-100 btn-green mt-1 mb-1" type="button" data-toggle="modal" data-target="#comment_modal">Comment</button>
																</li>
															</ul>
														</div>
													</td>
													<td class="list_booking">C4U<?=$hh['bk_id'];?></td>
													<?php if($type=='post_booking' || $type=='all'){
														if ($hh['status']=='vendor_pass') {
															echo '<td class="status"><label class="badge badge-primary">Not Assigned</label></td>';
														}elseif ($hh['status']=='booked') {
															echo '<td class="status"><label class="badge badge-warning">Pending</label></td>';
														}elseif ($hh['status']=='confirmed') {
															echo '<td class="status"><label class="badge badge-info">Processing</label></td>';
														}elseif ($hh['status']=='completed') {
															echo '<td class="status"><label class="badge badge-success">Completed</label></td>';
														}else{
															echo '<td class="status"><label class="badge badge-danger">Cancel</label></td>';
														}
													}
													?>
													<td class="from"><?=$hh['booking_from']?></td>
													<td class="to"><?=$hh['booking_to'];?></td>

													<td class="booking_stop"><?php 
													$i=1;
													if (!empty($hh['booking_stops'])) {
														$booking_stop=explode('/', $hh['booking_stops']);
														foreach($booking_stop as $booking_s){
															echo $i++.'. '.$booking_s.'<br>';
														}
													}
													?>
												</td>
												<td class="pid"><?=$hh['pid'];?></td>
												<td class="company_booking_id"><?=$hh['company_booking_id'];?></td>
												<td class="company_booking_type"><?=$hh['company_booking_type'];?></td>
												<?php if($hh['company_type']!=''){ ?>
													<td class="name"><?=$hh['cust_name'];?></td>
													<td class="contact"><?=$hh['cust_mob'];?></td>
													<td class="email"><?=$hh['cust_email'];?></td>
												<?php }else{ ?>
													<td class="name"><?=$hh['name'];?></td>
													<td class="contact"><?=$hh['contact'];?></td>
													<td class="email"><?=$hh['email'];?></td>
												<?php } ?>
												<td class="trip_type"><?=$hh['trip_type'];?></td>
												<td class="cab_type"><?=$hh['cab_type'];?></td>
												<td class="pickup_date"><?=date('d-m-Y', strtotime($hh['pickup_date']));?></td>
												<td class="pickup_time"><?=date("h:i A",strtotime($hh['pickup_time']));?></td>
												<td class="drop_date">
													<?php
													if($hh['drop_date'] == 0)
													{
														echo "<b>N.A.</b>";
													}
													else
													{
														echo date('d-m-Y', strtotime($hh['drop_date']));
													}
													?>
												</td>
												<td class="amount"><?=$hh['price']+$hh['incentive'];?></td>
												<td class="advance_amount"><?=$hh['txn_amount'];?></td>
												<td class="balance_amount"><?=($hh['price']+$hh['incentive'])-$hh['txn_amount'];?></td>
												<td class="incentive"><?=$hh['incentive'];?></td>
												<td class="commission" id="com<?=$hh['booking_id'];?>"><?=$hh['admin_commission'];?></td>
												<td class="loss"><?=$loss;?></td>
												<td class="profit"><?=$profit;?></td>
												<td><?=$hh['vendor_commission']; ?></td>
												<td class="pickup_address"><?=$hh['pickup_address'];?></td>
												<td class="drop_address"><?=$hh['drop_add'];?></td>
												<td class="toll_tax">
													<?php if($hh['toll_tax']==1) echo "Excluding"; else echo "Including" ?>
												</td>
												<td class="state_tax">
													<?php if($hh['state_tax']==1) echo "Excluding"; else echo "Including" ?>
												</td>
												<td class="parking">
													<?php if($hh['parking']==1) echo "Excluding"; else echo "Including" ?>
												</td>
												<td class="night_charge"><?=$hh['night_charge'];?></td>
												<td class="extra_price"><?=$hh['extra_price'];?></td>
												<td class="carrier"><?php if($hh['carrier']==1){ echo 'Yes';}else{ echo "No";} ?></td>
												<td class="pet"><?=$hh['pet']?></td>
												<td class="driver_app"><?php echo $hh['driver_app']; ?></td>
												<td class="extra_requirement"><?=$hh['extra_requirement'];?></td>
												<td class="billing_name"><?=$hh['billing_name'];?></td>
												<td class="gst_no"><?=$hh['gst_no'];?></td>
												<td class="amenities">
													<ul class="list-style-desc">
														<?php 
														$amenities_id =$hh['amenities'];
														$amenities = $conn->query("SELECT * FROM amenities WHERE id IN($amenities_id)");
														while ($amenity = mysqli_fetch_array($amenities)) {
															echo "<li>".$amenity['note'].$amenity['price']."</li>";
														}
														?>
													</ul>
												</td>
												<td class="remark"><?=$hh['remark'];?></td>
												<td class="booking_type"><?=$hh['booking_type'];?></td>
												<?php
												$vendor_id=$hh['vendor_id'];
												$sql="select * from vendor_login,vendor_profile where vendor_profile.vendor_id=$vendor_id and vendor_login.id=$vendor_id";
												$res = $conn->query($sql);
												$vendr = $res->fetch_assoc();

												if ($hh['post_by_id'] != 0 && $hh['post_by_id'] != '') {
													$post_by_id = $hh['post_by_id'];

													$sql = "SELECT * FROM vendor_profile INNER JOIN vendor_login ON vendor_profile.vendor_id=vendor_login.id WHERE vendor_id='" . $post_by_id . "'";
													$result = $conn->query($sql);
													$vv = $result->fetch_assoc();
													?>
													<td class="post_vendor_id"><a class="text-white" href="edit_vendor?token=<?=$hh['post_by_id']; ?>" target="_blank"><?=$hh['post_by_id']; ?></a></td>
													<td class="post_vendor_name"><?=$vv['full_name']?></td>
													<td class="post_vendor_contact"><?=$vv['contact']?></td>
												<?php }else{ ?>
													<td></td>
													<td></td>
													<td></td>
												<?php } ?>
												<?php if ($type!='pending' && $type!='vendor_pass'){  ?>

													<?php
													$vendor_id=$hh['vendor_id'];
													$sql="select * from vendor_login,vendor_profile where vendor_profile.vendor_id=$vendor_id and vendor_login.id=$vendor_id";
													$res = $conn->query($sql);
													$vendr = $res->fetch_assoc();
													if($hh['company_type']==''){ ?>
														<td class="accept_vendor_id"><a class="<?=$text_color;?>" href="edit_vendor?token=<?=$hh['vendor_id'];?>" target="_blank"><?=$hh['vendor_id'];?></a></td>
														<td class="accept_vendor_name"><input type="hidden" id="vendorname<?php echo $hh['bk_id'] ?>" value="<?php echo $hh['vendor_id'] ?>">
															<?php echo $vendr['full_name'] ?>
														</td>
														<td class="accept_vendor_contact">
															<?php echo $vendr['contact'] ?>
														</td>
													<?php }else{ ?>
														<td class="accept_vendor_id"><?=$hh['company_type'];?> - <?=$hh['vendor_id'];?></td>
														<td class="accept_vendor_name"><input type="hidden" id="vendorname<?php echo $hh['bk_id'] ?>" value="<?php echo $hh['vendor_id'] ?>"><?=$hh['vendor_name']?></td>
														<td class="accept_vendor_contact"><?=$hh['vendor_phone']?></td>
													<?php } ?>
													<!-- <td><a href="edit_agent?token=<?=$hh['agent_id'];?>" target="_blank"><?=$hh['agent_id'];?></a></td> -->
													<?php
													if($hh['cab_id']!=0 && $hh['driver_id']!=0 && $hh['company_type']=='')
													{
														$cab=$hh['cab_id'];
														$k=$hh['driver_id'];
														$sql="select driver_name,contact,cab_name as cc,rc_no from drivers,cabs where cabs.id= $cab and drivers.id=$k;";
														$result = $conn->query($sql);
														$ss = $result->fetch_assoc();
														?>
														<td class="cab_detail"><?=$ss['cc'].", ".$ss['rc_no'];?></td>
														<td class="driver_detail"><?=$ss['driver_name'].",".$ss['contact'];?></td>
													<?php }elseif($hh['company_type']!=''){ ?>
														<td><?=$hh['cabno']?></td>
														<td><?=$hh['drivername']?></td>
													<?php }else{ ?>
														<td class="cab_detail">Cab Not Found.</td>
														<td class="driver_detail">Driver Not Found.</td>
														<?php
													} }
													?>
													<td class="time_stamp"><?=date("d-m-Y h:i A",strtotime($hh['time_stamp']));?></td>
													<?php if ($type!='pending') { ?>
														<td class="accept_time"><?=date("d-m-Y h:i A",strtotime($hh['accept_time']));?></td>
														<?php if($type=='completed'){ ?>
															<td class="completed_time"><?=date("d-m-Y h:i A",strtotime($hh['completed_time']));?></td>
														<?php } if($type=='cancelled'){ ?>
															<td class="cancelled_time"><?=date("d-m-Y h:i A",strtotime($hh['cancelled_time']));?></td>
														<?php } } ?>

														<td class="comment comment<?=$hh['bk_id']?>"><?=$hh['comment']?></td>

													</tr>
													<?php
													$x++;
												}
												?>
											</tbody>
										</table>
									</div>
									<?php
								}
								else
								{
									echo "<h2>No Record Found.</h2>";
								}
								?>
							</div>
						</div>
					</div>
					<!--Add Modal To Display-->
					<div class="modal fade" id="confirm" style="z-index:99999999">
						<div class="modal-dialog">
							<div class="modal-content" style="width:108%!important">
								<div class="card-header">
									<button type="button" class="close" data-dismiss="modal" aria-label="Close">
										<span aria-hidden="true">&times;</span>
									</button>
									<div class="alert alert-danger"   id="error" style="display:none">Error! Your Request could not be submited.</div>
									<h4 style="text-align: left">Pass this ride to all vendors</h4><div class="col-md-6 float-right" id="alert"></div>
								</div> 
								<form method="post" id="add_vendor">
									<div class="modal-body" id="display-modal">
										<!-- div when the admin pass the ride all vendor-->
										<div class="row" id="pass" style="display:none">
											<form method="post">
												<div class="col-md-12">
													<label>Enter your commission :</label><input  type="text" class="form-control" id="cccoo" name="commition" required>
													<input  type="hidden" name="pass_id" id="pass_id" required>
													<input  type="hidden" name="admin_bid" id="admin_bid" value="none" required>
												</div>
												<div class="col-md-12">
													<br>
													<button type="submit" name="request" id="pass_id" class="btn btn-primary"style="float:right" >Add</button>
												</div>
											</form>
										</div>
										<!-- div when the admin select the custom vendor-->
										<form method="post">
											<div class="row" id="custom" style="display:none">
												<div class="col-md-6">
													<label>Please Select Custom Vendor:</label>
													<input  type="hidden" name="custom_id" style="float:right" id="custom_id" required>
													<!--<input type="hidden" class="form-control w-100"  name="custom_vendor" id="vendor">-->
													<!--<div class="form-group searchable">-->
														<!--	<input type="text" placeholder="Select Vendor" class="select_vendor" onkeyup="filterFunction(this,event)" required>-->
														<!--	<ul class="search_list"> -->
															<?php
															foreach($vendors as $vendor)
															{
																?>
																<!--<li class="selectItem" value="<?=$vendor['id'];?>"><?=$vendor['contact']." - ".$vendor['full_name'];?></li>-->
																<?php
															}
															?>
															<!--	</ul>-->
															<!--</div>-->
															<select name="custom_vendor" data-placeholder="Select Vendor" class="select2 form-control">
																<option value="0">Select Vendor</option>
																<?php
																foreach ($vendors as $vendor)
																{
																	?>
																	<option value="<?=$vendor['id'];?>"><?=$vendor['contact']." - ".$vendor['full_name'];?></option>
																	<?php
																}
																?>
															</select>
														</div>
														<div class="col-md-6">
															<label>Please Enter your Commission:</label>
															<input type="number" class="form-control" id="commission" name="comission" value="0" style="height:38px!important">
														</div>
														<div class="col-md-12">
															<br>
															<button type="submit"  name="request" id="add" class="btn btn-primary" style="float:right">Add</button>
														</div>
													</div>
												</form>
											</div>
										</form>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal-dialog -->
							</div>		
							<!--Add Modal To Display-->
							<div class="modal fade" id="change" style="z-index:99999999">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="card-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
												<span aria-hidden="true">&times;</span>
											</button>
											<div class="alert alert-danger"   id="error2" style="display:none">Error! Your Request could not be submited.</div>
											<h4 style="text-align: left">Asign Driver and Cab to this booking</h4><div class="col-md-6 float-right" id="alert"></div>
										</div> 
										<form method="post">
											<div class="modal-body">
												<div class="row" id="custom" >
													<div class="col-md-6">
														<select name="new_cab" id="cccabs" data-placeholder="Select Cab" class="select2 form-control">
															<option>Select cab</option>
														</select>
													</div>
													<input type="hidden" name="ccbooking_id" id="ccbooking_id">
													<input type="hidden" name="ccvendor_id" id="ccvendor_id">
													<div class="col-md-6">
														<select name="new_driver" id="ccdriver" data-placeholder="Select Driver" class="select2 form-control">
															<option>Select Driver</option>
														</select>
													</div>
												</div>
											</div>
											<div class="modal-footer">
												<button type="submit" name="request" id="add" class="btn btn-primary" style="float:right">Asign</button>
												<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
											</div>
										</form>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal-dialog -->
							</div>
							<div class="modal fade" id="cancel_modal" style="z-index:99999999">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="card-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
												<span aria-hidden="true">&times;</span>
											</button>
											<div class="alert alert-danger"   id="error2" style="display:none">Error! Your Request could not be submited.</div>
											<h4 style="text-align: left">Mention Reason For Cancellation</h4><div class="col-md-6 float-right" id="alert"></div>
										</div> 
										<form method="post" id="cancel_modal_reason">
											<div class="modal-body">
												<div class="row" id="custom" >

													<div class="col-md-12 mb-3">
														<div class="form-check-inline">
															<label><input type="radio" class="booking_status form-check-input" name="booking_status" value="cancel" checked>Parmanent Cancel</label>
														</div>
														<div class="form-check-inline">
															<label><input type="radio" class="booking_status form-check-input" name="booking_status" value="new">Create New Booking</label>
														</div>
													</div>
													<div class="col-lg-12 cancel_types">
														<div class="form-check-inline">
															<label><input type="checkbox" class="form-check-input refund_commission" name="refund" value="Cancel With Refund">Cancel With Refund</label>
														</div>
													</div>
													<div class="col-lg-12 cancel_types">
														<label>Cancellation Type</label>
														<select name="cancel_type" class="form-control cancellation_type" onchange="cancel_tye(this.value)">
															<option value="Cancel Without Penalty">Cancel Without Penalty</option>
															<option value="Cancel With Penalty">Cancel With Penalty</option>
														</select>
													</div>
													<div class="col-lg-12 mt-2" id="penalty_amount">
														<label>Penalty Amount</label>
														<input type="number" value="0" class="form-control penalty_amount" name="penalty_amount">
													</div>

													<div class="col-md-12 mt-2">
														<label>Cancel Reason (Optional)</label>
														<input type="text" class="form-control" id="reason_cancel">
													</div>
													<input type="hidden" id="cancel_reason_booking_id">
												</div>
											</div>
											<div class="modal-footer">
												<button type="submit" class="btn btn-primary" style="float:right">Submit</button>
												<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
											</div>
										</form>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal-dialog -->
							</div>

							<div class="modal fade" id="comment_modal">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="card-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
												<span aria-hidden="true">&times;</span>
											</button>
											<h4 style="text-align: left">Comment</h4><div class="col-md-6 float-right" id="alert"></div>
										</div> 
										<form method="post" id="comment_form">
											<div class="modal-body">
												<div class="row">

													<div class="col-md-12 mb-3">
														<label>Enter Your Comment</label>
														<textarea class="form-control" id="comment_field" name="comment" rows="3" required></textarea>
													</div>
													<input type="hidden" name="comment_booking_id" id="comment_booking_id">
												</div>
											</div>
											<div class="modal-footer">
												<button type="submit" class="btn btn-primary" style="float:right">Submit</button>
												<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
											</div>
										</form>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal-dialog -->
							</div>



							<!--Add Modal To Display-->
							<div class="modal fade" id="commissiong_log" style="z-index:99999999">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="card-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
												<span aria-hidden="true">&times;</span>
											</button>
											<div id="alert2"></div>
											<h4 style="text-align: left">Add Post Vendor Commission</h4>
											<div class="col-md-6 float-right" id="alert"></div>
										</div>
										<form method="post" id="add_vendor_commission">
											<div class="modal-body" id="display-modal">
												<div class="row">
													<div class="col-md-12">
														<label>Admin commission :</label>
														<input type="hidden" name="post_vendor_id" id="post_vendor_id">
														<input type="hidden" name="post_booking_id" id="post_booking_id">
														<input type="text" class="form-control" name="post_admin_commission" id="post_admin_commission" required>
													</div>
													<div class="col-md-12">
														<label>Enter Post Vendor commission :</label>
														<input type="text" class="form-control" name="post_vendor_commission" required>
													</div>
													<div class="col-md-12">
														<label>Message :</label>
														<textarea class="form-control" name="message" rows="3"></textarea>
													</div>
													<div class="col-md-12">
														<br>
														<button type="submit" class="btn btn-primary" style="float:right">Add Commission</button>
													</div>
												</div>
											</div>
										</form>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal-dialog -->
							</div>

							<?php 
							require_once 'footer.php';
							require_once 'datatable.php';
							?>							
							<!-- Adon Scripts -->
							<!-- Core -->
							<script src="assets/plugins/jquery/dist/jquery.min.js"></script>
							<script src="assets/js/popper.js"></script>
							<script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
							<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
							<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
							<script>
								$(".select2").select2({
								});
							</script>
							<!-- Optional JS -->
							<script src="assets/plugins/chart.js/dist/Chart.min.js"></script>
							<script src="assets/plugins/chart.js/dist/Chart.extension.js"></script>
							<!-- Data tables -->
							<script src="assets/plugins/datatable/jquery.dataTables.min.js"></script>
							<script src="assets/plugins/datatable/dataTables.bootstrap4.min.js"></script>
							<script src="assets/plugins/datatable/dataTables.responsive.min.js"></script>
							<script src="assets/plugins/datatable/responsive.bootstrap4.min.js"></script>
							<!-- Fullside-menu Js-->
							<script src="assets/plugins/toggle-sidebar/js/sidemenu.js"></script>
							<!-- Custom scroll bar Js-->
							<script src="assets/plugins/customscroll/jquery.mCustomScrollbar.concat.min.js"></script>
							<!-- Adon JS -->
							<?php include('datatable.php');?>
							<script src="assets/js/custom.js"></script>
							<script src="assets/js/datatable.js"></script>
							<script>


	//function for Vendor Commission
								function commissiong_log(post_vendor_id,booking_id) {
									var admin_commission = $('#com'+booking_id).text();
									$('#commissiong_log').modal('show');
									$('.dtr-bs-modal').modal('hide');
									$('#post_vendor_id').val(post_vendor_id);
									$('#post_booking_id').val(booking_id);
									$('#post_admin_commission').val(admin_commission);
								}

								$('#add_vendor_commission').submit(function(e) {
									e.preventDefault();
									$.ajax({
										url: "ajax_commission_log.php",
										type: "POST",
										data: $("#add_vendor_commission").serialize(),
										success: function(response) {
											if(response == 1) {
												$('#alert2').html('<span class="p-1 m-1 alert alert-success">Successfully Added.</span>').show()
												setTimeout(function(){
													$('#alert2').hide();
													$('#commissiong_log').modal("hide");
												}, 2000)
											}
											else {
												$('#alert2').html('<span class="p-1 m-1 alert alert-danger">Something Wrong, can\'t add.</span>').show()
												setTimeout(function(){
													$('#alert2').hide()
												}, 2000)
											}
											$('#add_vendor_commission').trigger("reset");
										}
									})
								})




								var i;
		//function for pass the informatio between user and driver
								function passinfo(str)
								{
									var confir=confirm("Are you sure to pass information to this ride?");
									if(confir)
									{
										$.ajax({
											type:"POST",
											url:"ajax_passinfo.php",
											data:{
												'booking_id':str,
											},
											success:function(data)
											{
												var x = JSON.parse(data);
												if(x.msg=="ok")
												{
													$(".dtr-bs-modal").modal('toggle');
													$("#msg").addClass(" alert-success");
													$("#msg").css('display','block');
													$("#msg").text("Success! Ride information successfully passed");
												}
											}
										});
									}
								}
	//change driver and cab

								function change_driver(vendor,booking)
								{
									$("#ccbooking_id").val(booking);
									$("#ccvendor_id").val(vendor);
									$('#change').modal('show');
									$.ajax({
										type:"POST",
										url:"fetch_data.php",
										data:{
											'booking_id':booking,
											'vendor_id':vendor,
										},
										success:function(data)
										{
											var obj =JSON.parse(data);
											if(obj.cabmsg=='ok')
											{
												$.each( obj.cabs, function( key, value ) {
													$('#cccabs').append('<option value="'+value.id+'">'+value.cab_name+','+value.rc_no+'</option>');
												});
											}
											else
											{
												alert("Cab not found for this vendor");
												$('#change').modal('hide');
												$('#cccabs option[value]').remove();
											}
											if(obj.drivermsg=='ok')
											{
												$.each( obj.drivers, function( key, value ) {
													$('#ccdriver').append('<option value="'+value.id+'">'+value.driver_name+','+value.contact+'</option>');
												});
											}
											else
											{
												alert("Driver not found for this vendor");
												$('#change').modal('hide');
												$('#ccdriver option[value]').remove();
											}
										}
									});
								}


	//complate ride

								function complete(str)
								{
									var confir=confirm("Are you sure to complete to this ride?");
									if(confir)
									{
										$.ajax({
											type:"POST",
											url:"ajax_complete.php",
											data:{
												'booking_id':str,
											},
											success:function(data)
											{
												var x = JSON.parse(data);
												if(x.msg=="ok")
												{
													location.reload(); 
												}
												else
												{
													$(".dtr-bs-modal").modal('toggle');
													$("#msg").addClass(" alert-danger");
													$("#msg").show();
												}
											}
										});
									}
								}


	//function for click booking confirm
								function confirm_booking(str,ee)
								{
									var comm="#com"+ee;
									var val=$(comm).html();
									if(str=='pass')
									{
										$('#cccoo').val(val);
										$('#pass').show();
										$('#custom').hide();
										$('#confirm').modal('show');
										document.getElementById('pass_id').value=ee;
										if($('.add_bid'+ee).is(":checked")){
											var bid_amt=($('input.bid_amt'+ee).eq(1)).val();
											document.getElementById('admin_bid').value=bid_amt;
										}
										else{
											document.getElementById('admin_bid').value='none';
										}
									}
									else if(str=='custom')
									{
										$('#custom').show();
										$('#pass').hide();
										$('#confirm').modal('show');
										$('#commission').val(val);
										document.getElementById('custom_id').value=ee;
									}
								}

	//function for cancel the booking
								function cancel_booking(booking_id)
								{
									$("#cancel_reason_booking_id").val(booking_id);
								}

								$("#cancel_modal_reason").submit(function(e){
									e.preventDefault();
									var confir=confirm("Are you sure to cancel this ride");
									if(confir)
									{
										$("#loader").show();
										var booking_status = $(".booking_status:checked").val();
										var refund_commission = $(".refund_commission:checked").val();
										var cancellation_type = $(".cancellation_type").val();
										var penalty_amount = $(".penalty_amount").val();

										$.ajax({
											type:"POST",
											url:"ajax_cancel_booking.php",
											data:{
												'cancel_id': $("#cancel_reason_booking_id").val(),
												'reason_for_cancel': $("#reason_cancel").val(),
												'booking_status': booking_status,
												'cancellation_type': cancellation_type,
												'penalty_amount': penalty_amount,
												'refund_commission': refund_commission,
											},
											success:function(data)
											{
												$("#loader").hide();
												$('#cancel_modal').modal('hide');
												if(data=="ok")
												{
													$(".dtr-bs-modal").modal('toggle');
													$("#msg").addClass(" alert-success");
													$("#msg").css('display','block');
													$("#msg").text("Succes! Your booking has been cancelled")
													setTimeout(function(){
														location.reload()
													}, 2000)
												}
												else
												{
													$(".dtr-bs-modal").modal('toggle');
													$("#msg").addClass(" alert-danger");
													$("#msg").show();
													$("#msg").text(x.msg);
												}
											}
										});
									}
								})

								$('.booking_status').click(function(){
									var val = $('.booking_status:checked').val();
									if (val=='new') {
										$('.cancel_types').show();
									}else{
										$('.cancel_types').hide();
									}
								})

								function cancel_tye(e){
									if (e=='Cancel With Penalty') {
										$('#penalty_amount').show();
									}else{
										$('#penalty_amount').hide();
									}
								}
							</script>
							<script>
								function check_bid(ee){
									if($('.add_bid'+ee).is(":checked")){
										$('.bid_amt'+ee).show(200);
									}
									else{
										$('.bid_amt'+ee).hide(200);
									}
								}
							</script>
							<div class="modal fade" id="view_modal" 
							tabindex="-1" 
							aria-labelledby="exampleModalLabel" 
							aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content">
									<div class="modal-header">
										<h3 class="modal-title" 
										id="exampleModalLabel">
										Details 
									</h3>
									<button type="button" 
									class="close" 
									data-dismiss="modal" 
									aria-label="Close">
									<span aria-hidden="true">
										├Ч
									</span>
								</button>
							</div>
							<div class="modal-body">
								<table class="table table-bordered">
									<tr>
										<th class="wd-15p">Booking Id</th>
										<td id="book_id" class="pl-5 ml-5"> </td>
										<tr>
											<tr>
												<th class="wd-15p">From</th>
												<td id="from" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">To</th>
												<td id="to" class="pl-5 ml-5"></td>
											</tr>

											<tr>
												<th class="wd-15p">Booking Stop</th>
												<td id="booking_stop" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Package</th>
												<td id="pid" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Company Booking ID</th>
												<td id="company_booking_id" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Company Booking Type</th>
												<td id="company_booking_type" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Pickup Date</th>
												<td id="pickup_date" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Drop Date</th>
												<td id="drop_date" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Pickup Time</th>
												<td id="pickup_time" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Cab Type</th>
												<td id="cab_type" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Trip Type</th>
												<td id="trip_type" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Name</th>
												<td id="name" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Contact</th>
												<td id="contact" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Email</th>
												<td id="email" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Alt Contact</th>
												<td id="alt_contact" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Amount</th>
												<td id="amount" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Advance Amount</th>
												<td id="advance_amount" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Balance Amount</th>
												<td id="balance_amount" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Incentive</th>
												<td id="incentive" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Your Commission</th>
												<td id="commissions" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Loss</th>
												<td id="loss" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Profit</th>
												<td id="profit" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Pickup Address</th>
												<td id="pickup_address" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Drop Address</th>
												<td id="drop_address" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Toll Tax</th>
												<td id="toll_tax" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">State Tax</th>
												<td id="state_tax" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Parking</th>
												<td id="parking" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Night Charge</th>
												<td id="night_charge" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Extra Price</th>
												<td id="extra_price" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Carrier</th>
												<td id="carrier" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Pet</th>
												<td id="pet" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Ariver App</th>
												<td id="driver_app" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Extra Requirement</th>
												<td id="extra_requirement" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Billing Name</th>
												<td id="billing_name" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">GST No.</th>
												<td id="gst_no" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Amenities</th>
												<td id="amenities" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Remark</th>
												<td id="remark" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Booking Type</th>
												<td id="booking_type" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Post Vendor ID</th>
												<td id="postvendor_id" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Post Vendor Name</th>
												<td id="post_vendor_name" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Post Vendor Contact</th>
												<td id="post_vendor_contact" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Accept Vendor ID</th>
												<td id="accept_vendor_id" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Accept Vendor Name</th>
												<td id="accept_vendor_name" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Accept Vendor Contact</th>
												<td id="accept_vendor_contact" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Cab Details</th>
												<td id="cab_detail" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Driver Details</th>
												<td id="driver_detail" class="pl-5 ml-5"></td>
											</tr>
											<tr>
												<th class="wd-15p">Posted Date/Time</th>
												<td id="time_stamp" class="pl-5 ml-5"></td>
											</tr>
											<?php if ($type!='pending') { ?>
												<tr>
													<th class="wd-15p">Accepted Date/Time</th>
													<td id="accept_time" class="pl-5 ml-5"></td>
												</tr>
												<?php if($type=='completed'){ ?>
													<tr>
														<th class="wd-15p">Completed Date/Time</th>
														<td id="completed_time" class="pl-5 ml-5"></td>
													</tr>
												<?php } if($type=='cancelled'){ ?>
													<tr>
														<th class="wd-15p">Cancelled Date/Time</th>
														<td id="cancelled_time" class="pl-5 ml-5"></td>
													</tr>
												<?php } } ?>
												<tr>
													<th class="wd-15p">Comment</th>
													<td id="comment" class="pl-5 ml-5"></td>
												</tr>





											</table>
											<button type="button" 
											class="btn btn-warning btn-sm" 
											data-toggle="modal"
											data-target="#exampleModal">
											Proceed
										</button>
									</div>
								</div>
							</div>
						</div>

						<div class="modal fade" id="view_role_modal" tabindex="-1" aria-labelledby="roleModalLabel" aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content">
									<div class="modal-header">
										<h3 class="modal-title text-center" style="width: 100%;" id="roleModalLabel">Booking ID : <span id="bookID"> </span></h3>

										<button type="button" class="close" data-dismiss="modal" aria-label="Close">
											<span aria-hidden="true">├Ч</span>
										</button>
									</div>

									<div class="modal-body">
										<table id="role_data_modal" class="table table-bordered">
											<thead>
												<tr>
													<th>Name</th>
													<th>Role</th>
													<th>Type</th>
												</tr>
											</thead>
											<tbody>
												<!-- Data will be appended here -->
											</tbody>
										</table>

									</div>
								</div>
							</div>
						</div>

					</div>
					<script type="text/javascript">

						$('.view_btn').click(function (e){
							e.preventDefault();
    			// alert('hello');
							var	book_id =$(this).closest('tr').find('.list_booking').text();
							var	from =$(this).closest('tr').find('.from').text();
							var	to =$(this).closest('tr').find('.to').text();
							var booking_stop =$(this).closest('tr').find('.booking_stop').text();
							var pid =$(this).closest('tr').find('.pid').text();
							var company_booking_id =$(this).closest('tr').find('.company_booking_id').text();
							var company_booking_type =$(this).closest('tr').find('.company_booking_type').text();
							var	pickup_date =$(this).closest('tr').find('.pickup_date').text();
							var	drop_date =$(this).closest('tr').find('.drop_date').text();
							var	pickup_time =$(this).closest('tr').find('.pickup_time').text();
							var	cab_type =$(this).closest('tr').find('.cab_type').text();
							var	trip_type =$(this).closest('tr').find('.trip_type').text();
							var	name =$(this).closest('tr').find('.name').text();
							var	contact =$(this).closest('tr').find('.contact').text();
							var	email =$(this).closest('tr').find('.email').text();
							var	alt_contact =$(this).closest('tr').find('.alt_contact').text();
							var	amount =$(this).closest('tr').find('.amount').text();
							var	advance_amount =$(this).closest('tr').find('.advance_amount').text();
							var	balance_amount =$(this).closest('tr').find('.balance_amount').text();
							var	incentive =$(this).closest('tr').find('.incentive').text();
							var	commission =$(this).closest('tr').find('.commission').text();
							var	loss =$(this).closest('tr').find('.loss').text();
							var	profit =$(this).closest('tr').find('.profit').text();
							var	pickup_address =$(this).closest('tr').find('.pickup_address').text();
							var	drop_address =$(this).closest('tr').find('.drop_address').text();
							var	toll_tax =$(this).closest('tr').find('.toll_tax').text();
							var	state_tax =$(this).closest('tr').find('.state_tax').text();
							var	parking =$(this).closest('tr').find('.parking').text();
							var	night_charge =$(this).closest('tr').find('.night_charge').text();
							var	extra_price =$(this).closest('tr').find('.extra_price').text();
							var	carrier =$(this).closest('tr').find('.carrier').text();
							var	pet =$(this).closest('tr').find('.pet').text();
							var	driver_app =$(this).closest('tr').find('.driver_app').text();
							var	extra_requirement =$(this).closest('tr').find('.extra_requirement').text();
							var	billing_name =$(this).closest('tr').find('.billing_name').text();
							var	gst_no =$(this).closest('tr').find('.gst_no').text();
							var	amenities =$(this).closest('tr').find('.amenities').html();
							var	remark =$(this).closest('tr').find('.remark').text();
							var	booking_type =$(this).closest('tr').find('.booking_type').text();
							var	post_vendor_id =$(this).closest('tr').find('.post_vendor_id').text();
							var	post_vendor_name =$(this).closest('tr').find('.post_vendor_name').text();
							var	post_vendor_contact =$(this).closest('tr').find('.post_vendor_contact').text();
							var	accept_vendor_id =$(this).closest('tr').find('.accept_vendor_id').text();
							var	accept_vendor_name =$(this).closest('tr').find('.accept_vendor_name').text();
							var	accept_vendor_contact =$(this).closest('tr').find('.accept_vendor_contact').text();
							var	cab_detail =$(this).closest('tr').find('.cab_detail').text();
							var	driver_detail =$(this).closest('tr').find('.driver_detail').text();
							var	time_stamp =$(this).closest('tr').find('.time_stamp').text();
							var	accept_time =$(this).closest('tr').find('.accept_time').text();
							var	completed_time =$(this).closest('tr').find('.completed_time').text();
							var	cancelled_time =$(this).closest('tr').find('.cancelled_time').text();
							var	comment =$(this).closest('tr').find('.comment').text();

							$('#book_id').html(book_id);
							$('#from').html(from);
							$('#to').html(to);
							$('#booking_stop').html(booking_stop);
							$('#pid').html(pid);
							$('#company_booking_id').html(company_booking_id);
							$('#company_booking_type').html(company_booking_type);
							$('#pickup_date').html(pickup_date);
							$('#drop_date').html(drop_date);
							$('#pickup_time').html(pickup_time);
							$('#cab_type').html(cab_type);
							$('#trip_type').html(trip_type);
							$('#name').html(name);
							$('#contact').html(contact);
							$('#email').html(email);
							$('#alt_contact').html(alt_contact);
							$('#amount').html(amount);
							$('#advance_amount').html(advance_amount);
							$('#balance_amount').html(balance_amount);
							$('#incentive').html(incentive);
							$('#commissions').html(commission);
							$('#loss').html(loss);
							$('#profit').html(profit);
							$('#pickup_address').html(pickup_address);
							$('#drop_address').html(drop_address);
							$('#toll_tax').html(toll_tax);
							$('#state_tax').html(state_tax);
							$('#parking').html(parking);
							$('#night_charge').html(night_charge);
							$('#extra_price').html(extra_price);
							$('#carrier').html(carrier);
							$('#pet').html(pet);
							$('#driver_app').html(driver_app);
							$('#extra_requirement').html(extra_requirement);
							$('#billing_name').html(billing_name);
							$('#gst_no').html(gst_no);
							$('#amenities').html(amenities);
							$('#time_stamp').html(time_stamp);
							$('#remark').html(remark);
							$('#booking_type').html(booking_type);
							$('#postvendor_id').html(post_vendor_id);
							$('#post_vendor_name').html(post_vendor_name);
							$('#post_vendor_contact').html(post_vendor_contact);
							$('#accept_vendor_id').html(accept_vendor_id);
							$('#accept_vendor_name').html(accept_vendor_name);
							$('#accept_vendor_contact').html(accept_vendor_contact);
							$('#cab_detail').html(cab_detail);
							$('#driver_detail').html(driver_detail);
							$('#comment').html(comment);
							$('#view_modal').modal('show');
						});
					</script>

					<script type="text/javascript">
						function filterFunction(that, event) {
							let container, input, filter, li, input_val;
							container = $(that).closest(".searchable");
							input_val = container.find("input").val().toUpperCase();
							if (["ArrowDown", "ArrowUp", "Enter"].indexOf(event.key) != -1) {
								keyControl(event, container)
							} else {
								li = container.find("ul li");
								li.each(function (i, obj) {
									if ($(this).text().toUpperCase().indexOf(input_val) > -1) {
										$(this).show();
									} else {
										$(this).hide();
									}
								});
								container.find("ul li").removeClass("selected");
								setTimeout(function () {
									container.find("ul li:visible").first().addClass("selected");
								}, 100)
							}
						}
						function keyControl(e, container) {
							if (e.key == "ArrowDown") {
								if (container.find("ul li").hasClass("selected")) {
									if (container.find("ul li:visible").index(container.find("ul li.selected")) + 1 < container.find("ul li:visible").length) {
										container.find("ul li.selected").removeClass("selected").nextAll().not('[style*="display: none"]').first().addClass("selected");
									}
								} else {
									container.find("ul li:first-child").addClass("selected");
								}
							} else if (e.key == "ArrowUp") {
								if (container.find("ul li:visible").index(container.find("ul li.selected")) > 0) {
									container.find("ul li.selected").removeClass("selected").prevAll().not('[style*="display: none"]').first().addClass("selected");
								}
							} else if (e.key == "Enter") {
								container.find("input").val(container.find("ul li.selected").text()).blur();
								onSelect(container.find("ul li.selected").text())
							}
							container.find("ul li.selected")[0].scrollIntoView({
								behavior: "smooth",
							});
						}
						function onSelect(val) {
							(val)
						}
						$(".searchable input").focus(function () {
							$(this).closest(".searchable").find("ul").show();
							$(this).closest(".searchable").find("ul li").show();
						});
						$(".searchable input").blur(function () {
							let that = this;
							setTimeout(function () {
								$(that).closest(".searchable").find("ul").hide();
							}, 300);
						});
						$(document).on('click', '.searchable ul li', function () {
							$(this).closest(".searchable").find("input").val($(this).text()).blur();
							onSelect($(this).text())
						});
						$(".searchable ul li").hover(function () {
							$(this).closest(".searchable").find("ul li.selected").removeClass("selected");
							$(this).addClass("selected");
						});
						$(document).ready(function() {
							$(".selectItem").click(function() {
								var itemValu = $(this).val();
								$("#vendor").val(itemValu);
							});
						});



// new booking with notification sound

						function removebooking(id){
							$.ajax({
								type: 'POST',
								url: "check_new_booking.php",
								data:{'booking_id':id},
								success: function (response) {
									console.log(response); 
									location.reload();
								}
							});
						}

					</script>

					<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
					<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />
					<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>

					<script>
						$(function() {

							var start = moment().subtract(29, 'days');
							var end = moment();

							function cb(start, end) {
								$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
							}

							$('#reportrange').daterangepicker({
								startDate: start,
								endDate: end,
								ranges: {
									'Today': [moment(), moment()],
									'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
									'Last 7 Days': [moment().subtract(6, 'days'), moment()],
									'Last 30 Days': [moment().subtract(29, 'days'), moment()],
									'This Month': [moment().startOf('month'), moment().endOf('month')],
									'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
								}
							}, cb);

							cb(start, end);

						});

						function get_role_data(booking_id){
							$('#bookID').text('C4U'+booking_id);
							$.ajax({
								url: "get_role_data.php",
								type: "POST",
								data: {
									booking_id: booking_id,
								},
								success: function (response) {
									var data = JSON.parse(response); 
									var table = $('#role_data_modal tbody');

									table.empty();

									for (var i = 0; i < data.length; i++) {
										var role_name = data[i].role_name ? data[i].role_name : 'Master Admin';

										var row = '<tr>'; 
										row += '<td>' + data[i].user_name + '</td>';
										row += '<td>' + role_name + '</td>';
										row += '<td>' + data[i].type + '</td>'; 
										row += '</tr>';
										table.append(row);
									}
									$('#view_role_modal').modal('show');
								}
							})

						}


						$(document).ready(function(){
							$('[data-toggle="tooltip"]').tooltip();
						});

						function comment_box(booking_id,comment){
							$('#comment_booking_id').val(booking_id);
							$('#comment_field').val(comment);
						}

						$("#comment_form").submit(function(e){
							e.preventDefault();

							$("#loader").show();

							$.ajax({
								type:"POST",
								url:"ajax_booking_comment.php",
								data:  new FormData(this),
								contentType: false,
								cache: false,
								processData:false,
								success:function(data)
								{
									$("#loader").hide();
									$('#comment_modal').modal('hide');
									if(data=="ok")
									{
										$("#msg").addClass(" alert-success");
										$("#msg").css('display','block');
										$("#msg").text("Succes! Comment added successfully.")
										setTimeout(function(){
											location.reload()
										}, 2000)
									}
									else
									{
										$("#msg").addClass(" alert-danger");
										$("#msg").show();
										$("#msg").text("Something wrong!...");
									}
								}
							});
						})



						function customer_detail_hide_show(booking_id, status) {
							$("#loader").show();
							if (status==0) {
								status = 1;
							}else{
								status = 0;
							}
							$.ajax({
								type: "POST",
								url: "ajax_booking_comment.php",
								data: {
									bk_id: booking_id,
									status: status,
								},
								success: function (data) {
									$("#loader").hide();
									$('#comment_modal').modal('hide');

									if (data.trim() === "ok") {
										$("#msg").removeClass("alert-danger").addClass("alert-success");
										$("#msg").css('display', 'block').text("Success! Comment added successfully.");

										setTimeout(function () {
											location.reload();
										}, 2000);
									} else {
										$("#msg").removeClass("alert-success").addClass("alert-danger");
										$("#msg").show().text("Something went wrong! Please try again.");
									}
								}
							});
						}

					</script>

MMCT - 2023