Begin Page Content
<div class="container-fluid">
    <div class="row column_title">
        <div class="col-md-12">
            <div class="page_title">
                <h2>All Users</h2>
            </div>
        </div>
    </div>

    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <!-- <h6 class="m-0 font-weight-bold text-primary">DataTables Example</h6> -->
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered" id="songTable" width="100%" cellspacing="0">
                    <thead class="thead-dark">
                        <tr>
                            <th>Name</th>
                            <th>Email</th>
                            <th>Address</th>
                            
                            <th>Type</th>
                            <th>Photo</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>
  <tr class="odd">

                            <td class="sorting_1">Asad Ullah</td>

                         
                            <td>asadullah9555@gmail.com</td>
                            <td> Some locations </td>
                            <td>Free</td>

                            <td>
                                                                <img class="img-thumbnail" src="http://placehold.jp/100x100.png">
                                                            </td>
                            <td>
                                                                <a class="icon" style="text-decoration: none;" href="http://137.184.111.69/unitree/customer/userLogs/qvbs2v9BBBbQNOrZ6Kp6k8uoNST2">
                                    <button class="btn btn-info btn-block mt-2">User Details</button>
                                </a>
                                <a class="icon" style="text-decoration: none;" href="http://137.184.111.69/unitree/customer/editcustomer/qvbs2v9BBBbQNOrZ6Kp6k8uoNST2">
                                    <button class="btn btn-secondary btn-block mt-2">Reset Password</button>
                                </a>
                                <button type="button" class="btn d-none btn-warning btn-block mt-2" data-toggle="modal" data-target="#exampleModal" onclick="showModal('qvbs2v9BBBbQNOrZ6Kp6k8uoNST2','Asad Ullah');">Send Warning</button>

                                
                                
                                                                <button class="btn btn-danger  btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" 
                                                                	disabled="" 
                                                                onclick="showConfirmation('qvbs2v9BBBbQNOrZ6Kp6k8uoNST2','Asad Ullah', 'banCustomer ');">Suspend User</button>
                                                                                                <button class="btn btn-danger d-none btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" onclick="showConfirmation('qvbs2v9BBBbQNOrZ6Kp6k8uoNST2','Asad Ullah', 'suspendCustomer');">Deactivate User</button>
                                
                                <button disabled="" class="btn btn-danger btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" onclick="showConfirmation('qvbs2v9BBBbQNOrZ6Kp6k8uoNST2','Asad Ullah', 'deleteCustomer');">Delete User
                                    Account</button>
                                
                            </td>
                        </tr>
                        <?php
                        /*
                        if (!empty($customerlist)) {



                            $count = 1;
                            foreach ($customerlist["user"] as $id => $customerlists) {
                            // echo "<pre>";
                            // print_r($customerlists);
                            // echo "</pre>";

                        ?>
                        <tr>

                            <td><?php echo $customerlists['firstName'] . " " . $customerlists['lastName']; ?></td>

                         
                            <td><?php echo output($customerlists['email']); ?></td>
                            <td> <?php echo output($customerlists['address']); ?></td>
                            <td><?php echo date('Y-m-d', $customerlists['dob'] / 1000); ?></td>

                            <td>
                                <?php if ($customerlists['image'] != "") { ?>
                                <a href="<?= $customerlists['image'] ?>" target="_blank">
                                    <img class="img-thumbnail" width="100" height="100" src="<?php echo output($customerlists['image']); ?>">
                                </a>
                                <?php } else { ?>
                                <img class="img-thumbnail" src="http://placehold.jp/100x100.png">
                                <?php } ?>
                            </td>
                            <td>
                                <?php if ($permissions != "ReadOnly") { ?>
                                <a class="icon" style="text-decoration: none;" href="<?php echo base_url(); ?>customer/userLogs/<?php echo output($id); ?>">
                                    <button class="btn btn-info btn-block mt-2">User Details</button>
                                </a>
                                <a class="icon" style="text-decoration: none;" href="<?php echo base_url(); ?>customer/editcustomer/<?php echo output($id); ?>">
                                    <button class="btn btn-secondary btn-block mt-2">Reset Password</button>
                                </a>
                                <button type="button" class="btn d-none btn-warning btn-block mt-2" data-toggle="modal" data-target="#exampleModal" onclick="showModal('<?php echo output($id); ?>','<?=$customerlists['firstName']?> <?=$customerlists['lastName']?>');">Send Warning</button>

                                <?php if ($customerlists['BannerImage'] != "") { ?>
                                <button class="btn btn-danger  btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" onclick="showConfirmation('<?php echo output($id); ?>','<?=$customerlists['firstName']?> <?=$customerlists['lastName']?>', 'deleteBanner');">Remove Banner</button>
                                <?php } ?>

                                <?php if ($customerlists['image'] != "") { ?>
                                <button class="btn btn-danger d-none btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" onclick="showConfirmation('<?php echo output($id); ?>','<?=$customerlists['firstName']?> <?=$customerlists['lastName']?>', 'deleteImage');">Remove Profile Photo</button>
                                <?php } ?>

                                <?php if (isset($customerlists["isBanned"]) && $customerlists["isBanned"] == true) {
                                            ?>
                                <button class="btn btn-success d-none btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" onclick="showConfirmation('<?php echo output($id); ?>','<?=$customerlists['firstName']?> <?=$customerlists['lastName']?>', 'unBanCustomer');">Unban User</button>
                                <?php
                                            } else {
                                            ?>
                                <button class="btn btn-danger d-none btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" onclick="showConfirmation('<?php echo output($id); ?>','<?=$customerlists['firstName']?> <?=$customerlists['lastName']?>', 'banCustomer');">Ban User</button>
                                <?php
                                            } ?>
                                <?php if ($customerlists["isActive"] === false) {
                                            ?>
                                <button class="btn btn-success d-none btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" onclick="showConfirmation('<?php echo output($id); ?>','<?=$customerlists['firstName']?> <?=$customerlists['lastName']?>', 'unSuspendCustomer');">Activate User</button>
                                <?php
                                            } else {
                                            ?>
                                <button class="btn btn-danger d-none btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" onclick="showConfirmation('<?php echo output($id); ?>','<?=$customerlists['firstName']?> <?=$customerlists['lastName']?>', 'suspendCustomer');">Deactivate User</button>
                                <?php
                                            } ?>

                                <button class="btn btn-danger btn-block mt-2" data-toggle="modal" data-target="#exampleModa2" onclick="showConfirmation('<?php echo output($id); ?>','<?=$customerlists['firstName']?> <?=$customerlists['lastName']?>', 'deleteCustomer');">Delete User
                                    Account</button>
                                <?php } ?>

                            </td>
                        </tr>
                        <?php }
                        }
*/

                         ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</div>
<!-- /.container-fluid -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <form method="post" action="<?=base_url('customer/sendWarning')?>">
        <input id="user-id" type="hidden" name="userid" value="" />
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Send Warning to "<spna id="user-name"></spna>"
                    </h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form>

                        <div class="form-group">
                            <label for="message-text" class="col-form-label">Warning Message:</label>
                            <textarea class="form-control" id="message-text" rows="5" name="message" required></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-primary">Send Warning</button>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="modal fade" id="exampleModa2" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <form method="get" name="cform" action="">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel2"></h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                    <button type="submit" class="btn btn-primary" id="submitBtn"></button>
                </div>
            </div>
        </div>
    </form>
</div>
<script>
function showModal(userid, username) {
    document.getElementById('user-name').innerText = username;
    document.getElementById('user-id').value = userid;
}

function showConfirmation(userid, username, action) {
    let url = "";
    let message = "";
    let btnTitle = "";
    switch (action) {
        case 'deleteBanner':
            url = "<?php echo base_url(); ?>customer/deleteBanner/" + userid;
            message = "Are you sure you want to remove banner of user '" + username + "'?";
            btnTitle = "Remove Banner";
            break;
        case 'deleteImage':
            url = "<?php echo base_url(); ?>customer/deleteImage/" + userid;
            message = "Are you sure you want to remove profile phot of user '" + username + "'?";
            btnTitle = "Remove Profile Photo";
            break;
        case 'banCustomer':
            url = "<?php echo base_url(); ?>customer/banCustomer/" + userid;
            message = "Are you sure you want to ban user '" + username + "'?";
            btnTitle = "Ban User";
            break;
        case 'unBanCustomer':
            url = "<?php echo base_url(); ?>customer/unBanCustomer/" + userid;
            message = "Are you sure you want to Unbanned user '" + username + "'?";
            btnTitle = "Unban User";
            break;
        case 'suspendCustomer':
            url = "<?php echo base_url(); ?>customer/suspendCustomer/" + userid;
            message = "Are you sure you want to deactivate user '" + username + "'?";
            btnTitle = "Deactivate User";
            break;
        case 'unSuspendCustomer':
            url = "<?php echo base_url(); ?>customer/unSuspendCustomer/" + userid;
            message = "Are you sure you want to activate user '" + username + "'?";
            btnTitle = "Activate User";
            break;
        case 'deleteCustomer':
            url = "<?php echo base_url(); ?>customer/deleteCustomer/" + userid;
            message = "Are you sure you want to delete user '" + username + "'?";
            btnTitle = "Delete User";
            break;
        default:
            return false;
    }

    document.getElementById('exampleModalLabel2').innerText = message;
    document.getElementById('submitBtn').innerText = btnTitle;
    document.cform.action = url;
}
</script>