MMCT TEAM
Server IP : 82.112.239.40  /  Your IP : 3.145.164.105
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/booking_ajax.php
<?php
include('lib/config.php');

$type = $_REQUEST['type'];
$current_time=date('Y-m-d H:i:s');

switch($type)
{

    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";
    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'";
    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'";
    
    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'";
    
    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'";

    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";

    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'";

    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'";
    
}


// Fetch data
$result = $conn->query($sql);
$totalData = $result->num_rows;


// Server-side processing

if (!empty($_REQUEST['search']['value'])) {
    $sql .= " AND (full_name LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR id LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR contact LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR email LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR city LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR state LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR pincode LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR pan_on_name LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR pan_no LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR upi_id LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR timestamp LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR bank_name LIKE '%" . $_REQUEST['search']['value'] . "%' ";
    $sql .= " OR ifsc_code LIKE '%" . $_REQUEST['search']['value'] . "%' )";
}

$query = mysqli_query($conn, $sql);
$totalFiltered = mysqli_num_rows($query);



// Server-side processing
$sql .= " ORDER BY bookings.pickup_date DESC";
$sql .= " LIMIT " . $_REQUEST['start'] . ", " . $_REQUEST['length'];

$result = $conn->query($sql);
$totalFiltered = $totalData;

$data = array();
$serial = $_REQUEST['start'] + 1; // Serial number counter
while ($row = $result->fetch_assoc()) {

    $nestedData = array();

    $action = '<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">';
    
    if($row['status']=='booked')
    {

        $action .= '<li><button id="'.$row['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="'.$row['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="'.$row['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='.$row['bk_id'].'"  class="btn btn-green w-100 mt-1 mb-1" >Edit booking
        </a></li>';
    }
    if($row['status']=='confirmed')
    {
        if($row['driver_id']==0 && $row['cab_id']==0)
        {

            $action .= ' <li> <button onclick="change_driver(this.id,this.value)" id="'.$row['vendor_id'].'" value="'.$row['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="'.$row['bk_id'].'" class="btn btn-primary mt-1 mb-1 w-100" type="button">Complete Ride 
            </button></li>';

        }
        else
        {
            $action .= '<li> <button onclick="change_driver(this.id,this.value)" id="'.$row['vendor_id'].'" value="'.$row['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="'.$row['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="'.$row['bk_id'].'" class="btn btn-orange w-100 mt-1 mb-1" type="button">Information Pass
            </button></li>';

        }

        $action .= '<li> <button id="'.$row['bk_id'].'" onclick="confirm_booking(this.value,this.id);" value="custom" class="btn btn-primary w-100 mt-1 mb-1" type="button">';
        if($row['vendor_id']==0)
        {
            $action .= 'Add Vendor';
        }
        else
        {
         $action .= 'Change Vendor';
     }
     $action .= '</button></li>
     <li><button id="'.$row['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='.$row['bk_id'].'"  class="btn btn-green mt-1 mb-1 w-100" >Edit booking
     </a></li>';

 }
 else if($row['status']=='vendor_pass')
 {
     $action .= '<li>
     <form method="post" class="mb-1">
     <button  value="'.$row['bk_id'].'" class="btn btn-orange w-100 color_white text-white" type="submit" name="notify">
     Notify
     </button></form></li>
     <li><button id="'.$row['bk_id'].'" onclick="confirm_booking(this.value,this.id);" value="custom" class="btn btn-primary mt-1 mb-1 w-100" type="button">';

     if($row['vendor_id']==0){
       $action .= 'Custom Vendor';
   }
   else
   {
    $action .= 'Change Vendor';
}
$action .= '</button></li>
<li>    <button id="'.$row['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='.$row['bk_id'].'"  class="btn btn-green w-100 mt-1 mb-1">Edit booking
</a>
</li>';  
}
if($row['status']=='completed'){ 
    if($row['post_by_id']!='' && $row['post_by_id']!=0){ 
        $action .= '<li><button id="'.$row['bk_id'].'" onclick="commissiong_log(this.value,this.id);" value="'.['post_by_id'].'" amount="'.$row['admin_commission'].'" class="btn btn-icon w-100 btn-green mt-1 mb-1" type="button">
        Vendor Commission
        </button></li>';
    } 
    $action .= '<li><a href="print.php?id='.$row['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='.$row['bk_id'].'" class="btn w-100 mt-1 mb-1" type="button" style="background:#5bc0de;color: #fff;">Bill without GST  
    </a></li>';
}
$action .= '</ul></div>';

if($row['toll_tax']==1){
    $toll_tax = "Excluding"; 
}else{
    $toll_tax = "Including";
}
if($row['state_tax']==1){
    $state_tax = "Excluding"; 
}else{
    $state_tax = "Including";
}
if($row['parking']==0){
    $parking = "Excluding"; 
}else{
    $parking = "Including";
}

if ($hh['booking_type']=='Website') {
    $color = 'bg_success';
    $text_color='text-white';
}elseif($hh['booking_type']=='Vendor App'){
    $color = 'bg-danger text-white';
    $text_color='text-white';
}else{
    $color = 'none';
    $text_color='';
}







                    $nestedData[] = $serial++; // Serial number
// Custom action column
                    if ($type=='new') {
                        $nestedData[] = '<button type="button" onclick="removebooking('.$row['bk_id'].')" class="badge badge-danger btn-sm"><i class="fa fa-times"></i></button>
                        <a href="javascript:void[0]" class="badge view_btn btn-sm" style="background: #000;color: #fff!important;"><i class="fas fa-pencil-alt"></i></a>';
                    }else{
                        $nestedData[] = '<a href="javascript:void[0]" class="badge view_btn btn-sm" style="background: #000;color: #fff!important;"><i class="fas fa-pencil-alt"></i></a>';
                    }

                    $nestedData[] = $action;

                    $nestedData[] = 'C4U'.$row['bk_id'];
                    if($type=='post_booking' || $type=='all'){
                        if ($hh['status']=='vendor_pass') {
                            $nestedData[] =  '<td class="status"><label class="badge badge-primary">Not Assigned</label></td>';
                        }elseif ($hh['status']=='booked') {
                            $nestedData[] =  '<td class="status"><label class="badge badge-warning">Pending</label></td>';
                        }elseif ($hh['status']=='confirmed') {
                            $nestedData[] =  '<td class="status"><label class="badge badge-info">Processing</label></td>';
                        }elseif ($hh['status']=='completed') {
                            $nestedData[] =  '<td class="status"><label class="badge badge-success">Completed</label></td>';
                        }else{
                            $nestedData[] =  '<td class="status"><label class="badge badge-danger">Cancel</label></td>';
                        }
                    }

                        $nestedData[] = $row['booking_from'];
                        $nestedData[] = $row['booking_to'];
                        $nestedData[] = $row['name'];
                        $nestedData[] = $row['contact'];
                        $nestedData[] = $row['trip_type'];
                        $nestedData[] = $row['cab_type'];
                        $nestedData[] = date('d-m-Y', strtotime($row['pickup_date']));
                        $nestedData[] = date('h:i A', strtotime($row['pickup_time']));
                        $nestedData[] = date('d-m-Y', strtotime($row['drop_date']));
                        $nestedData[] = $row['email'];
                        $nestedData[] = $row['alt_contact'];
                        $nestedData[] = $row['price'];
                        $nestedData[] = $row['txn_amount'];
                        $nestedData[] = $row['price']-$row['txn_amount'];
                        $nestedData[] = $row['admin_commission'];
                        $nestedData[] = $row['vendor_commission'];
                        $nestedData[] = $row['pickup_address'];
                        $nestedData[] = $row['drop_add'];
                        $nestedData[] = $toll_tax;
                        $nestedData[] = $state_tax;
                        $nestedData[] = $parking;
                        $nestedData[] = $row['night_charge'];
                        $nestedData[] = $row['extra_price'];
                        $nestedData[] = $row['remark'];
                        $nestedData[] = $row['booking_type'];

                        if ($row['post_by_id'] != 0 && $row['post_by_id'] != '') {
                            $post_by_id = $row['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();

                            $nestedData[] = '<td class="post_vendor_id"><a class="text-white" href="edit_vendor?token='.$row['post_by_id'].'" target="_blank">'.$row['post_by_id'].'</a></td>';
                            $nestedData[] = '<td class="post_vendor_name">'.$vv['full_name'].'</td>';
                            $nestedData[] = '<td class="post_vendor_contact">'.$vv['contact'].'</td>';
                        }else{ 
                            $nestedData[] = '';
                            $nestedData[] = '';
                            $nestedData[] = '';
                        } 


                        if ($type!='pending' && $type!='vendor_pass'){

                            $nestedData[] = '<td class="accept_vendor_id"><a class="'.$text_color.'" href="edit_vendor?token='.$row['vendor_id'].'" target="_blank">'.$row['vendor_id'].'</a></td>';

                            $vendor_id=$row['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();

                            $nestedData[] = '<td class="accept_vendor_name"><input type="hidden" id="vendorname'.$row['bk_id'].'" value="'.$row['vendor_id'].'">'.$vendr['full_name'].'</td>';
                            $nestedData[] = '<td class="accept_vendor_contact">'.$vendr['contact'].'</td>';

                            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();
                                $nestedData[] = '<td class="cab_detail">'.$row['cc'].", ".$row['rc_no'].'</td>';
                                $nestedData[] = '<td class="driver_detail">'.$row['driver_name'].",".$row['contact'].'</td>';   
                            }
                            else
                            {

                                $nestedData[] = '<td class="cab_detail">Cab Not Found.</td>';
                                $nestedData[] = '<td class="driver_detail">Driver Not Found.</td>';

                            } }

                            $nestedData[] = date("d-m-Y h:i A",strtotime($row['time_stamp']));

                            if ($type!='pending') { 
                                $nestedData[] = '<td class="accept_time">'.date("d-m-Y h:i A",strtotime($row['accept_time'])).'</td>';
                                if($type=='completed'){ 
                                    $nestedData[] = '<td class="completed_time">'.date("d-m-Y h:i A",strtotime($row['completed_time'])).'</td>';
                                } if($type=='cancelled'){ 
                                 $nestedData[] = '<td class="cancelled_time">'.date("d-m-Y h:i A",strtotime($row['cancelled_time'])).'</td>';
                             } } 


                             $data[] = $nestedData;
                         }

// Prepare JSON data
                         $json_data = array(
                            "draw" => intval($_REQUEST['draw']),
                            "recordsTotal" => intval($totalData),
                            "recordsFiltered" => intval($totalFiltered),
                            "data" => $data
                        );

                         echo json_encode($json_data);
                         ?>

MMCT - 2023