
<?php $__env->startSection('title'); ?>
    Users
<?php $__env->stopSection(); ?>

<?php
    $user = auth()->user();
    $res    = $user->getResidential($user->id);
    $residential_id = $res->residential_id;
    $arr_res = explode(',', $residential_id);

    $sql = "SELECT * FROM role_user WHERE ";
    $i = 0;
    foreach($arr_res as $res_id) {           
        $sql .= ($i == 0) ? " FIND_IN_SET($res_id, residential_id) " : " OR FIND_IN_SET($res_id, residential_id)";
        $i++;
    }

    $userList = DB::select($sql);
?>
<?php $__env->startSection('content'); ?>
<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
    <div class="d-flex flex-column-fluid pb-20">
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                    <!-- Datatable (JS in datatable-custom.js) -->
                    <table class="table table-bordered mt-15 table_pm_staff_settings table-hover" id="pm_staff_settings">
                        <thead>
                            <tr>
                                <th>#</th>                                                         
                                <th>Name</th>
                                <th>Email</th>
                                <th>Contact</th>
                                <th>Role</th>
                                <th>Project</th>                           
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php
                            $count = 0;
                            
                        ?>
                        <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                            // $residential = DB::select("SELECT * FROM residential WHERE id IN ($residential_id) order by name asc"); 

                            $role = $user->getRole($user->id);     
                            $status = ($user->status) == 0 ? "Inactive" : "Active";                  
                            $count++;
                        ?>
                            <tr>
                                <td><?php echo e($count); ?></td>                                
                                <td style="text-align:left;"><?php echo e($user->name); ?></td>
                                <td><?php echo e($user->email); ?></td>
                                <td><?php echo e($user->tel); ?></td>
                                <td style="text-align:left;"><?php echo e($role->name); ?></td>
                                <td>Arte Cheras</td>      
                                <td><?php echo e($status); ?></td>
                                <td></td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>                            
                        </tbody>
                    </table>
                </div>

                <div class="col-sm-12 mt-5">
                    <a href="" class="btn btn-primary font-weight-bold" data-toggle="modal" data-target="#add_User">Add User</a>
                </div>
            </div>


            <!-- Modal Edit User -->
            <div class="modal fade" id="edit_User" tabindex="-1" role="dialog" aria-labelledby="edit_User" aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered modal-xl" role="document">
                    <div class="modal-content">
                        <div class="modal-body">
                            <div class="row">
                                <div class="col-sm-12 text-center">
                                    <i class="fas fa-exclamation-circle text-danger font-size-h1"></i>
                                    <p class="font-size-h3 mt-3">Are you sure to update the user?</p>
                                    <h3>Cyndy Wong</h3>
                                    <form>
                                        <table class="table table_editUser table-bordered">
                                            <tr>
                                                <th>Project</th>
                                                <th>Role</th>
                                                <th>Name</th>
                                                <th>Contact</th>
                                                <th>Email</th>
                                                <th>Status</th>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <select class="form-control selectpicker" data-size="3">
                                                        <option>Arte Cheras</option>
                                                        <option>Arte MK</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select class="form-control selectpicker" data-size="3">
                                                        <option>Site Office Admin</option>
                                                        <option>Stock Officer</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <input class="form-control" type="text" value="Cyndy Wong">
                                                </td>
                                                <td>
                                                    <input class="form-control" type="text" value="012-225 9887">
                                                </td>
                                                <td>
                                                    <input class="form-control" type="email" value="cyndy.wong@kpm.com.my">
                                                </td>
                                                <td>
                                                    <select class="form-control selectpicker" data-size="3">
                                                        <option>Active</option>
                                                        <option>Inactive</option>
                                                    </select>
                                                </td>
                                            </tr>
                                        </table>
                                    </form>
                                </div>
                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-light-success font-weight-bold">Confirm</button>
                            <button type="button" class="btn btn-light-primary font-weight-bold" data-dismiss="modal">Cancel</button>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Modal Add User -->
            <div class="modal fade" id="add_User" tabindex="-1" role="dialog" aria-labelledby="add_User" aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered modal-xl" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title">Add User</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <i aria-hidden="true" class="ki ki-close"></i>
                            </button>
                        </div>
                        <div class="modal-body">
                            
                            <div id="kt_repeater_1">
                                <div class="form-group row mb-0">
                                    <div class="col-sm-12">
                                        <table class="table table-bordered table_add_user">
                                            <tr>
                                                <th>Project</th>
                                                <th>Role</th>
                                                <th>Name</th>
                                                <th>Contact</th>
                                                <th>Email</th>
                                                <th>Action</th>
                                            </tr>
                                            <tbody data-repeater-list="">
                                                <tr data-repeater-item="">
                                                    <td>
                                                        <select class="form-control selectpicker" data-size="3">
                                                            <option selected disabled>Select Project</option>
                                                            <option>Arte Cheras</option>
                                                            <option>Arte MK</option>
                                                        </select>
                                                    </td>
                                                    <td>
                                                        <select class="form-control selectpicker" data-size="3">
                                                            <option selected disabled>Select Role</option>
                                                            <option>Site Office Admin</option>
                                                            <option>Stock Officer</option>
                                                        </select>
                                                    </td>
                                                    <td><input type="text" class="form-control" placeholder="Staff Name" /></td>
                                                    <td><input type="text" class="form-control" placeholder="Contact" /></td>
                                                    <td><input type="email" class="form-control" placeholder="Email" /></td>
                                                    <td>
                                                        <a href="javascript:;" data-repeater-delete=""
                                                            class="btn btn-sm font-weight-bolder btn-light-danger">
                                                            <i class="fas fa-trash-alt"></i>
                                                        </a>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <div class="col-sm-12">
                                        <a href="javascript:;" data-repeater-create="" class="btn btn-sm font-weight-bolder btn-light-primary">
                                            <i class="la la-plus"></i>Add
                                        </a>
                                    </div>
                                </div>
                            </div>


                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-light-success font-weight-bold">Confirm</button>
                            <button type="button" class="btn btn-light-primary font-weight-bold" data-dismiss="modal">Cancel</button>
                        </div>
                    </div>
                </div>
            </div>

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

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\laravel\inventory\resources\views/admin/users/index.blade.php ENDPATH**/ ?>