<?php $__env->startSection('content'); ?>

<div class="content-wrapper">
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0">Permissions Details</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Home</a></li>
                        <li class="breadcrumb-item"><a href="<?php echo e(route('users.list')); ?>">Team Member List</a></li>
                        <li class="breadcrumb-item active">Permission Details</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <div class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <!-- Default box -->
                    <div class="card">
                        <div class="card-header">
                            <!-- <h3 class="card-title">Select Members For </h3> -->
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                                    <i class="fas fa-minus"></i>
                                </button>
                            </div>
                        </div>
                        <div class="card-body">
                            <form method="post" action="<?php echo e(route('users.updatepermission')); ?>" name="form"
                                enctype="multipart/form-data">
                                <?php echo csrf_field(); ?>
                                <input type='hidden' name="CustomerID" value="<?php echo e($users->CustomerID); ?>">
                                <div class="form-group">
                                    <div class="row">
                                        <div class="col-lg-3 col-6">
                                            <div class="inner">
                                                <lable><b>Team Member : </b></lable>&nbsp;<?php echo e($users->CustomerName); ?>

                                                <input type="hidden" name="CustomerID" value="<?php echo e($users->CustomerName); ?>" readonly>
                                            </div>
                                        </div>
                                        <div class="col-lg-3 col-6">
                                            <div class="inner">
                                                <lable><b> Customer Id : </b></lable>&nbsp;<?php echo e($users->CustomerID); ?>

                                                <input type="hidden" name="CustomerID" value="<?php echo e($users->CustomerID); ?>" readonly>
                                            </div>
                                        </div>
                                        
                                    </div>
                                    <table id="example2" class="table table-bordered table-hover dataTable dtr-inline"
                                        aria-describedby="example2_info">
                                        <thead>
                                            <tr>
                                                <th>
                                                    Permissions
                                                </th>
                                                <th>

                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0" name="Contact_Share">
                                                    Contact_Share
                                                </td>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0">
                                                    <input type="checkbox"  $selected name="Contact_Share"
                                                        class="btn bg-gradient-success btn-sm" value="1" <?php if((isset($permissions)) && ($permissions->Contact_Share == "1")): ?>
                                                        checked <?php endif; ?>>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0" name="Call_Contact">
                                                    Call_Contact
                                                </td>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0">
                                                    <input type="checkbox" name="Call_Contact"
                                                        class="btn bg-gradient-success btn-sm" value="1" <?php if((isset($permissions)) && ($permissions->Call_Contact == "1")): ?>
                                                        checked <?php endif; ?>>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0" name="Send_Whatsapp">
                                                    Send_Whatsapp
                                                </td>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0">
                                                    <input type="checkbox" name="Send_Whatsapp"
                                                        class="btn bg-gradient-success btn-sm" value="1" <?php if((isset($permissions)) && ($permissions->Send_Whatsapp == "1")): ?>
                                                        checked <?php endif; ?>>
                                                </td>
                                            </tr>

                                            <tr>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0" name="Save_Contact">
                                                    Save_Contact
                                                </td>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0">
                                                    <input type="checkbox" name="Save_Contact"
                                                        class="btn bg-gradient-success btn-sm" value="1" <?php if((isset($permissions)) && ($permissions->Save_Contact == "1")): ?>
                                                        checked <?php endif; ?>>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0" name="Export_Excel">
                                                    Export_Excel
                                                </td>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0">
                                                    <input type="checkbox" name="Export_Excel"
                                                        class="btn bg-gradient-success btn-sm" value="1"  <?php if((isset($permissions)) && ($permissions->Export_Excel == "1")): ?>
                                                        checked <?php endif; ?>>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0" name="location_config">
                                                    Enable Location
                                                </td>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0">
                                                    <input type="checkbox" name="location_config"
                                                        class="btn bg-gradient-success btn-sm" value="1"  <?php if((isset($users)) && ($users->location_config == "1")): ?> checked <?php endif; ?>>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0" name="send_email">
                                                    Send Email
                                                </td>
                                                <td class="dtr-control sorting_1" style="border-bottom: 2px solid;"
                                                    tabindex="0">
                                                    <input type="checkbox" name="send_email"
                                                        class="btn bg-gradient-success btn-sm" value="1"  <?php if((isset($permissions)) && ($permissions->send_email == "1")): ?> checked <?php endif; ?>>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <div class="card-footer">
                                        <button type="submit" class="btn btn-primary">Submit</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="card">
                        <div class="card-header">
                           <h3 class="card-title">Change Password </h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                                    <i class="fas fa-minus"></i>
                                </button>
                            </div>
                        </div>
                        <div class="card-body">
                            <form method="post" action="<?php echo e(route('users.update_user_password')); ?>" name="form"
                                enctype="multipart/form-data">
                                <?php echo csrf_field(); ?>
                                <input type='hidden' name="CustomerID" value="<?php echo e($users->CustomerID); ?>">
                                <div class="form-group">
                                    <div class="col-4">
                                        <label for="">New Password</label>
                                        <input type="Password" name="password"
                                            class="form-control <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" id="password"
                                            placeholder="Enter NewPassword" value="" required
                                            autocomplete="current-password">

                                        <?php if($errors->has('password')): ?>
                                        <div class="form-text text-danger">
                                            <?php echo e($errors->first('password')); ?>

                                        </div>
                                        <?php endif; ?>

                                        <label for="">Confirm Password</label>
                                        <input type="Password" name="password_confirmation" class="form-control"
                                            placeholder="Enter Conform Password"
                                            class="form-control <?php $__errorArgs = ['password_confirmation'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                            value="" required autocomplete="current-password">
                                    </div>
                                </div>
                                <div class="card-footer">
                                    <button type="submit" class="btn btn-primary">Update</button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="card">
                        <div class="card-header">
                            <h3 class="card-title">Division </h3>
                            <div class="card-tools">
                                <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                                    <i class="fas fa-minus"></i>
                                </button>
                            </div>
                        </div>
                        <div class="card-body">
                            <form method="post" action="<?php echo e(route('users.divisionUpdate')); ?>" name="form"
                                  enctype="multipart/form-data">
                                <?php echo csrf_field(); ?>
                                <input type='hidden' name="CustomerID" value="<?php echo e($users->CustomerID); ?>">
                                <div class="form-group">
                                    <div class="col-6">
                                        <label for="">Division</label>
                                        <select class="form-control custom-select" name="divisions[]" id="division_id">
                                            <option></option>
                                        </select>
                                        <?php $__errorArgs = ['divisions'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <div class="error"><?php echo e($message); ?></div>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                </div>
                                <div class="card-footer">
                                    <button type="submit" class="btn btn-primary">Update</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal" tabindex="-1" role="dialog" id="modalieventlist">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
            <h5 class="modal-title">User List</h5>
            </div>
            <div class="modal-body">
                <div class="card-body">
                    <form action="<?php echo e(route('users.add_customer_id')); ?>" method="post">
                        <?php echo csrf_field(); ?>
                        <input type="hidden" value="customer_id" name="db_customer_id" id="modaldb_CustomerID">
                        <div class="table-responsive text-nowrap">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>Customer Id</th>
                                        <th>User Name</th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody class="table-border-bottom-0" id="replace_user">
                                </tbody>
                            </table>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                <button type="submit" class="btn btn-primary">Submit</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function replace_user(elm) {
    // var id = $(elm).attr('data-id');
    var db_CustomerID = $(elm).attr('data-CustomerID');
    $.ajax({
        url: "<?php echo e(url('ajax/get_userlist')); ?>",
        type: "GET",
        data: {
            db_CustomerID: db_CustomerID,
        },

        success: function(response) {
            if (response) {
                $("#replace_user").html('');
                $.each(response['data'], function(i, item) {

                    html =  `<tr>
                                <td>
                                    ` + item['CustomerID'] + `
                                </td>
                                <td>
                                    ` + item['CustomerName'] + `
                                </td>
                                <td>
                                    <input type="radio" name="CustomerID"  id="CustomerName" value=" ` + item['CustomerID'] + `" required>
                                </td>
                             </tr>`;
                    $("#replace_user").append(html);
                    $('#modaldb_CustomerID').val(db_CustomerID);
                    $("#modalieventlist").modal('show');
                });
            } else {
                alert('no data found!')
            }
        },
        error: function(error) {
            console.log(error);
        }
    });
}
</script>
<script>
    $(document).ready(function() {
        $("#division_id").select2({
            placeholder: "Select Division",
            multiple: false,
        });
        setDivisions();
    });

    function setDivisions() {
        var divisionIds = <?php echo json_encode($selectedDivisionIdsString); ?>;
        var divisions = <?php echo $divisions; ?>;

        var options = [];
        var divisionId = $('#division_id');
        divisionId.html(''); // Clear existing options

        $.each(divisions, function(index, value) {
            var selected = divisionIds.includes(value.id.toString());
            var option = new Option(value.name, value.id, false, selected);
            divisionId.append(option);
            options.push({id:value.id,text:value.name});
        });

        divisionId.trigger({
            type: 'select2:select',
            params: {
                data: options
            }
        });

        divisionId.val(divisionIds).trigger('change');
    }
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/asojsoftcaps/public_html/frenzincrm.asojsoftcaps.com/frenzincrm/resources/views/users/permissionsdetails.blade.php ENDPATH**/ ?>