MMCT TEAM
Server IP : 82.112.239.40  /  Your IP : 3.22.77.196
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/post-by-vendor.php
<style type="text/css">
	.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;
	}
	.dropdown-menu{
		/*background: -webkit-linear-gradient(left, #99CC00, #99CC00)!important;*/
		margin-top: 8px!important;
	}
	/*#buttons button,a{
		background: -webkit-linear-gradient(left, #99CC00, #99CC00)!important;
		color: #fff!important;
	}*/
	.dropdown-menu button:hover{
		color: #000!important;
	}
	.dropdown-menu label:hover{
		color: #000!important;
	}
	.dropdown-menu li input{
		color: #525456!important;
		font-weight: 600!important;
	}
	.dropdown-menu li button{
		color: #fff!important;
		font-weight: 600!important;
	}
	.dropdown-menu li #edit_booking{
		padding: 5px 6px!important;
	}
	/*.dropdown-menu button,a{
		padding: 6px!important;
		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;
	}
</style>
<?php
require_once 'header.php';
require_once 'navbar.php';
if(!isset($_GET['type']))
{
	header("location:404");
}
if($_SERVER["REQUEST_METHOD"] == "POST")
{
	if(isset($_POST['commition']))
	{
		$commition=$_POST['commition'];
		$booking_id=$_POST['pass_id'];
		$admin_bid=$_POST['admin_bid'];
		$recommended_bid=$_POST['recommended_bid'];
		if($admin_bid=='none'){
			$sql="update bookings set admin_commission=$commition,status='vendor_pass',bid_by='vendor',recommended_bid='$recommended_bid' where id=$booking_id";
		}
		else{
			$sql="update bookings set admin_commission=$commition,status='vendor_pass',bid_by='admin',admin_bid_price='$admin_bid' where id=$booking_id";
		}

		// $sql="update bookings set admin_commission=$commition,status='vendor_pass' where id=$booking_id";
		if($conn->query($sql)===true)
		{
			$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);
		}
	}
	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)
			{
				$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'];
		$sql="update bookings set admin_commission=$commition,vendor_id=$custom_vendor,status='confirmed' where id=$booking_id";
		if($conn->query($sql)===true)
		{
			$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) values($custom_vendor,$commition,'Debit','Charges for booking confirmation give by admin)";
				if($conn->query($sql)===true)
				{
					$success=true;
				}
			}
		}
		else
		{
			$error=true;
		}
		
	}
}
$type=test_input($_GET['type']);
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,payment_log,users where users.id=bookings.user_id and  payment_log.txn_status is true and bookings.status ='booked' and bookings.id=payment_log.booking_id and bookings.post_by_id!=0 and bookings.post_by_id!='' order by bookings.id desc";
}
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
	while($row = $result->fetch_assoc()) {
		$table_data[]=$row;
	}
}
//print_r($table_data);
/* $sql="select alternate_contact as contact,full_name,vendor_id,company_name from vendor_profile where vendor_id not in(select vendor_id from vendor_profile where LTRIM(RTRIM(alternate_contact)) = '') order by contact";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        $vendors[]=$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;
}
?>
<!-- Page content -->
<div class="container-fluid pt-8">
	<div class="page-header mt-0  p-3">
		<h3 class="mb-sm-0"><?=ucwords($type);?> Bookings</h3>
		<ol class="breadcrumb mb-0">
			<li class="breadcrumb-item"><a href="#"><i class="fe fe-home"></i></a></li>
			<li class="breadcrumb-item active" aria-current="page"><?=ucwords($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="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>
								<th class="wd-15p">From </th>
								<th class="wd-15p">To</th>
								<th class="wd-20p">Name</th>
								<th class="wd-20p">Contact</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-20p">EMail</th>
								<th class="wd-20p">Alt Contact</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">Your Commission</th>
								<th class="wd-15p">Pickup Address</th>
								<th class="wd-15p">Toll Tax</th>
								<th class="wd-15p">Night Charge</th>
								<th class="wd-15p">Remark</th>
								<th class="wd-15p">Booking Type</th>
								<?php if ($type!='pending' && $type!='vendor_pass') { ?>
									<th class="wd-15p">Vendor id</th>
									<th class="wd-15p">Vendor Name</th>
									<th class="wd-15p">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 } ?>
							</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>
								<th class="wd-15p">From </th>
								<th class="wd-15p">To</th>
								<th class="wd-20p">Name</th>
								<th class="wd-20p">Contact</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-20p">EMail</th>
								<th class="wd-20p">Alt Contact</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">Your Commission</th>
								<th class="wd-15p">Pickup Address</th>
								<th class="wd-15p">Toll Tax</th>
								<th class="wd-15p">Night Charge</th>
								<th class="wd-15p">Remark</th>
								<th class="wd-15p">Booking Type</th>
								<?php if ($type!='pending' && $type!='vendor_pass') { ?>
									<!-- <th class="wd-15p">Post Vendor Name</th> -->
									<th class="wd-15p">Vendor id</th>
									<th class="wd-15p">Vendor Name</th>
									<th class="wd-15p">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 } ?>
							</tr>
						</tfoot>
						<tbody>
							<?php
							$x=1;
							foreach($table_data as $hh)
							{
								if ($hh['booking_type']=='Website') {
									$color = 'bg_success';
								}else{
									$color = 'none';
								}
								?>
								<tr class="<?php echo $color; ?>" id="row<?=$hh['booking_id'];?>">
									<td><?=$x;?></td>
									<td class="action"><a href="#" class="badge view_btn" style="background: #000;color: #fff!important;"><i class="fas fa-pencil-alt"></i></a></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(isset($one))
													{
														?>
														<li>
															<input type="checkbox" name="add_bid" class="add_bid<?=$hh['booking_id'];?>" onclick="check_bid(<?=$hh['booking_id'];?>)" style="margin-left:6px;"><label class="pl-1">Pass With Bid</label>

															<input type="text" name="bid_amt" placeholder="Enter Bid Amount" class="mb-1 form-control bid_amt<?=$hh['booking_id'];?>" style="display: none"></li>

															<li><button id="<?=$hh['booking_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['booking_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['booking_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['booking_id'];?>"  class="btn btn-green w-100 mt-1 mb-1" >Edit booking
															</a></li>
															<?php
														}
														if($type=='processing')
														{
															if($hh['driver_id']==0 && $hh['cab_id']==0)
															{
																?>
																<li> <button onclick="change_driver(this.id,this.value)" id="<?=$hh['vendor_id'];?>" value="<?=$hh['booking_id'];?>" class="w-100 btn btn-primary mt-1 mb-1" type="button">Change Driver & Cab 
																</button></li>
																<?php
															}
															else
															{
																?>
																<li> <button  onclick="complete(this.value)" value="<?=$hh['booking_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['booking_id'];?>" class="btn btn-orange w-100 mt-1 mb-1" type="button">Information Pass
																</button></li>
																<?php
															}
															?>
															<li> <button id="<?=$hh['booking_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['booking_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['booking_id'];?>"  class="btn btn-green mt-1 mb-1 w-100" >Edit booking
														</a></li>
														<?php
													}
													else if($type=='vendor_pass')
													{
														?>
														<li>  	<button id="<?=$hh['booking_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['booking_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['booking_id'];?>"  class="btn btn-green w-100 mt-1 mb-1">Edit booking
														</a>
													</li>
													<?php
												}  
												?>
												<?php
												if($type=='completed'){ ?>
													<li><a href="print.php?id=<?=$hh['booking_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['booking_id'];?>" class="btn w-100 mt-1 mb-1" type="button" style="background:#5bc0de;color: #fff;">Bill without GST  
													</a></li>
												<?php } ?>
											</ul>
										</div>
									</td>
									<td class="list_booking">ROWT<?=$hh['bk_id'];?></td>
									<td class="from"><?=$hh['booking_from']?></td>
									<td class="to"><?=$hh['booking_to'];?></td>
									<td class="name"><?=$hh['name'];?></td>
									<td class="contact"><?=$hh['contact'];?></td>
									<td class="trip_type"><?=$hh['trip_type'];?></td>
									<td><?=$hh['cab_type'];?></td>
									<td class="pickup_date"><?=$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 $hh['drop_date'];
										}
										?>
									</td>
									<td class="email"><?=$hh['email'];?></td>
									<td class="alt_contact"><?=$hh['alt_contact'];?></td>
									<td class="amount"><?=$hh['price'];?></td>
									<td class="advance_amount"><?=$hh['txn_amount'];?></td>
									<td class="balance_amount"><?=$hh['price']-$hh['txn_amount'];?></td>
									<td class="commission" id="com<?=$hh['booking_id'];?>"><?=$hh['admin_commission'];?></td>
									<td class="pickup_address"><?=$hh['pickup_address'];?></td>
									<td class="toll_tax">
										<?php if($hh['toll_tax']) echo "Excluding"; else echo "Including" ?>
									</td>
									<td class="night_charge">
										<?=$hh['night_charge'];?>
									</td>
									<td class="remark"><?=$hh['remark'];?></td>
									<td class="booking_type"><?=$hh['booking_type'];?></td>
									<?php if ($type!='pending' && $type!='vendor_pass'){  ?>

										<!-- <td>
                                        <?php
                                        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();

                                            echo $vv['full_name'];
                                        }
                                        ?>

                                    </td> -->

										<td><a href="edit_vendor?token=<?=$hh['vendor_id'];?>" target="_blank"><?=$hh['vendor_id'];?></a></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();
										?>
										<td><input type="hidden" id="vendorname<?php echo $hh['bk_id'] ?>" value="<?php echo $hh['vendor_id'] ?>">
											<?php echo $vendr['full_name'] ?>
										</td>
										<td>
											<?php echo $vendr['contact'] ?>
										</td>
										<!-- <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)
										{
											$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><?=$ss['cc'].", ".$ss['rc_no'];?></td>
											<td><?=$ss['driver_name'].",".$ss['contact'];?></td>
											<?php
										}
										else
										{
											?>
											<td>Cab Not Found.</td>
											<td>Driver Not Found.</td>
											<?php
										} }
										?>
														
													</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 select2 w-100"  name="custom_vendor" id="vendor">
													<div class="form-group searchable">
														<!-- <label>Select Vendor</label> -->
														<input type="text" placeholder="Select Vendor" class="select2 select_vendor" onkeyup="filterFunction(this,event)" required>
														<ul class="search_list"> 
															<!-- <li class="selectvendor" value="all">All Vendor</li> -->
															<?php
															foreach($vendors as $vendor)
															{
																?>
																<li class="selectItem" value="<?=$vendor['id'];?>"><?=$vendor['contact']." - ".$vendor['full_name'];?></li>
																<?php
															}
															?>
														</ul>
													</div>
                       <!-- <select name="custom_vendor" class="form-control">
                           <option value="0"  >Select Vendor</option>
                            <?php
                            foreach ($vendors as $vendor)
                            {
                            ?>
                              <option value="<?=$vendor['vendor_id'];?>"><?=$vendor['full_name']." - ".$vendor['contact'];?></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"  class="form-control">
								<option value="0"  >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"  class="form-control">
								<option value="0"  >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">
							<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>
<?php 
require_once 'footer.php';
//require_once 'jslinks.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>
<!-- 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 -->
<script src="assets/js/custom.js"></script>
<script src="assets/js/datatable.js"></script>
<script>
	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');
				}
				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');
				}
			}
		});
	}
	
	
	//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)
		{
			$.ajax({
				type:"POST",
				url:"ajax_cancel_booking.php",
				data:{
					'cancel_id': $("#cancel_reason_booking_id").val(),
					'reason_for_cancel': $("#reason_cancel").val()
				},
				success:function(data)
				{
					$('#cancel_modal').modal('hide');
					var x = JSON.parse(data);
					if(x.msg=="ok")
					{
						$(".dtr-bs-modal").modal('toggle');
						$("#msg").addClass(" alert-success");
						$("#msg").css('display','block');
						$("#msg").text("Succes! Your booking has been cancelled");
						$("#row"+booking_id).remove();
					}
					else
					{
						$(".dtr-bs-modal").modal('toggle');
						$("#msg").addClass(" alert-danger");
						$("#msg").show();
						$("#msg").text(x.msg);
					}
				}
			});
		}
	})
</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">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">Your Commission</th>
					<td id="commission" 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">Toll Tax</th>
					<td id="toll_tax" 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">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">Action</th>
									<td id="buttons" class="pl-5 ml-5"></td>
									<td id="button1" class="pl-5 ml-5"></td>
									<td id="button2" class="pl-5 ml-5"></td>
									<td id="button3" class="pl-5 ml-5"></td>
									<td id="button4" class="pl-5 ml-5"></td>
								</tr>
								<tr>
									<th class="wd-15p">Cab Id</th>
									<td id="cab_id" class="pl-5 ml-5"></td>
								</tr>
								<tr>
									<th class="wd-15p">Driver Id</th>
									<td id="driver_id" 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>
	<script type="text/javascript">
		$(document).ready(function(){
			$('.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	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	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	commission =$(this).closest('tr').find('.commission').text();
    			var	pickup_address =$(this).closest('tr').find('.pickup_address').text();
    			var	toll_tax =$(this).closest('tr').find('.toll_tax').text();
    			var	night_charge =$(this).closest('tr').find('.night_charge').text();
    			var	remark =$(this).closest('tr').find('.remark').text();
    			var	booking_type =$(this).closest('tr').find('.booking_type').text();
    		// var	vendor_id =$(this).closest('tr').find('.vendor_id').text();
    		// var	cab_id =$(this).closest('tr').find('.cab_id').text();
    		// var	driver_id =$(this).closest('tr').find('.driver_id').text();
    		$('#book_id').html(book_id);
    		$('#from').html(from);
    		$('#to').html(to);
    		$('#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);
    		$('#commission').html(commission);
    		$('#pickup_address').html(pickup_address);
    		$('#toll_tax').html(toll_tax);
    		$('#night_charge').html(night_charge);
    		$('#remark').html(remark);
    		$('#booking_type').html(booking_type);
    		// $('#vendor_id').html(vendor_id);
    		// $('#cab_id').html(cab_id);
    		// $('#driver_id').html(driver_id);
    		$('#view_modal').modal('show');
    		// alert(book_id,from,to,pickup_date,drop_date);
    	});
		});
	</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);
			});
		});
// $(document).ready(function() {
//   $(".selectvendor").click(function() {
//     $("#vendor").val('all');
//   });
// });
</script>

MMCT - 2023