 
<?php $__env->startSection('title', 'Add User'); ?>
<?php $__env->startSection('content'); ?>
    <!-- push external head elements to head -->
    <?php $__env->startPush('head'); ?>
        <link rel="stylesheet" href="<?php echo e(asset('plugins/select2/dist/css/select2.min.css')); ?>">
        <link href='https://fonts.googleapis.com/css?family=Josefin Sans' rel='stylesheet'>
    <?php $__env->stopPush(); ?>

<?php 
    $getstatecodedata = DB::table('state_master')->get();
    $getdistrictcodedata = DB::table('district_master')->get();
    $getartcenterdata = DB::table('art_centre_master')->get();
?>
    <div class="container-fluid">
    	<div class="page-header">
            <div class="row align-items-end">
                <div class="col-lg-8">
                    <div class="page-header-title">
                        <i class="ik ik-user-plus bg-blue"></i>
                        <div class="d-inline">
                            <h5><?php echo e(__('Add User')); ?></h5>
                            <span><?php echo e(__('Create new user, assign roles & permissions')); ?></span>
                        </div>
                    </div>
                </div>
                <div class="col-lg-4">
                    <nav class="breadcrumb-container" aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">
                                <a href="<?php echo e(url('dashboard')); ?>"><i class="ik ik-home"></i></a>
                            </li>
                            <li class="breadcrumb-item">
                                <a href="#"><?php echo e(__('Add User')); ?></a>
                            </li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>
        <div class="row">
            <?php echo $__env->make('include.message', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
            <div class="col-md-12">
                <div class="card ">
                    <div class="card-header">
                        <h3><?php echo e(__('Add user')); ?></h3>
                    </div>
                    <div class="card-body">
                        <form class="forms-sample" method="POST" action="<?php echo e(route('create-user')); ?>" >
                        <?php echo csrf_field(); ?>
                            <div class="row">
                                <div class="col-sm-6">

                                    <div class="form-group">
                                        <label for="name"><?php echo e(__('Username')); ?><span class="text-red">*</span></label>
                                        <input id="name" type="text" class="form-control <?php $__errorArgs = ['name'];
$__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); ?>" name="name" value="" placeholder="Enter user name" required>
                                        <div class="help-block with-errors"></div>

                                        <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                            </span>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                    <div class="form-group">
                                        <label for="email"><?php echo e(__('Email')); ?><span class="text-red">*</span></label>
                                        <input id="email" type="email" class="form-control <?php $__errorArgs = ['email'];
$__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); ?>" name="email" value="<?php echo e(old('email')); ?>" placeholder="Enter email address" required>
                                        <div class="help-block with-errors" ></div>

                                        <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                            </span>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                   
                                    <div class="form-group">
                                        <label for="password"><?php echo e(__('Password')); ?><span class="text-red">*</span></label>
                                        <input id="password" type="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); ?>" name="password" placeholder="Enter password" required>
                                        <div class="help-block with-errors"></div>

                                        <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                            </span>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    </div>
                                    <div class="form-group">
                                        <label for="password-confirm"><?php echo e(__('Confirm Password')); ?><span class="text-red">*</span></label>
                                        <input id="password-confirm" type="password" class="form-control" name="password_confirmation" placeholder="Retype password" required>
                                        <div class="help-block with-errors"></div>
                                    </div>
                                    <div class="form-group">
                                        <label for="emp_code"><?php echo e(__('Employee Code')); ?></label>
                                        <input type="text" class="form-control" id="emp_code" name='emp_code' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->emp_code); ?>' <?php } ?> placeholder="Enter Employee Code" required>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="role"><?php echo e(__('Assign Role')); ?><span class="text-red">*</span></label>
                                        <?php echo Form::select('role', $roles, null,[ 'class'=>'form-control select2', 'placeholder' => 'Select Role','id'=> 'role', 'required'=> 'required']); ?>

                                    </div>
                                    <div class="form-group">
                                        <label for="state_code"><?php echo e(__('State Code')); ?></label>
                                        <select name='state_code' id="state_code" class='form-control' value='Select Option' required>
                                            <option value="">Select State Code</option>
                                            <?php foreach($getstatecodedata as $getstatecode){ ?>
                                             <option value='<?php echo $getstatecode->state_code; ?>' <?php if(!empty($showdata)): ?> <?php echo e($showdata[0]->state_code == $getstatecode->state_code ? 'selected' : ''); ?> <?php endif; ?> ><?php echo $getstatecode->state_code; ?></option>
                                             <?php } ?>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label for="dist_code"><?php echo e(__('District Code')); ?></label>
                                        <select name='dist_code' id="dist_code" class='form-control' value='Select Option' required>
                                            <option value="">Select District Code</option>
                                        </select>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label for="art_centre_code"><?php echo e(__('ART Center')); ?></label>
                                        <select name="art_centre_code[]" id="art_centre_code" class="form-control" value="Select Option" multiple="" required>
                                            <option value="">Select ART Center</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-12 table-responsive">
                                    <label><?php echo e(__('Permissions')); ?></label>
                                    <table class="table table-bordered p-3">
                                        <thead>
                                            <tr>
                                                <th style="width: 20%">Form Name</th>
                                                <th style="width: 20%">Add</th>
                                                <th style="width: 20%">View</th>
                                                <th style="width: 20%">Modify</th>
                                                <th style="width: 20%">Delete</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td>Client Registration</td>
                                                <td style="min-width: 100px;">
                                                    <select name='client_reg_add' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td style="min-width: 100px;">
                                                    <select name='client_reg_view' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td style="min-width: 100px;">
                                                    <select name='client_reg_modify' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td style="min-width: 100px;">
                                                    <select name='client_reg_delete' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Client Mapping</td>
                                                <td>
                                                    <select name='client_map_add' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='client_map_view' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='client_map_modify' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='client_map_delete' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Outreach Input</td>
                                                <td>
                                                    <select name='outreach_add' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='outreach_view' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='outreach_modify' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='outreach_delete' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Calling Input</td>
                                                <td>
                                                    <select name='calling_add' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='calling_view' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='calling_modify' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='calling_delete' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>EAC Input</td>
                                                <td>
                                                    <select name='eac_add' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='eac_view' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='eac_modify' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='eac_delete' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Data Entry Operator</td>
                                                <td>
                                                    <select name='doe_add' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='doe_view' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='doe_modify' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td>
                                                    <select name='doe_delete' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>Report</td>
                                                <td>
                                                    <select name='report_view' class='form-control permission_select' required>
                                                        <option value="Yes">Yes</option>
                                                        <option value="No">No</option>
                                                    </select>
                                                </td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <button type="submit" class="btn btn-primary"><?php echo e(__('Submit')); ?></button>
                                    </div>
                                </div>
                            </div>
                        
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- push external js -->
    <?php $__env->startPush('script'); ?> 
        <script src="<?php echo e(asset('plugins/select2/dist/js/select2.min.js')); ?>"></script>
        <script type="text/javascript">
            $(document).ready(function() {  
                $(".permission_select").select2({minimumResultsForSearch: -1});
            });
            $( "#role" ).change(function() { 
                var role = $(this).val();
                var state_code = $('#state_code').val();
                var dist_code = $('#dist_code').val();
                $.ajax({
                    type: "POST",
                    url: "<?php echo e(url('getdistrict')); ?>",
                    data: {dist_code:dist_code,state_code:state_code,role:role, _token: '<?php echo e(csrf_token()); ?>' },
                    dataType: "json",
                    success: function(res) { 
                        $('#art_centre_code').html(res.arthtml);
                    },
                    error: function (jqXHR, exception) {

                    }
                });
            });
            $( "#state_code" ).change(function() { 
                var state_code = $(this).val();
                var role = $('#role').val();
                $.ajax({
                    type: "POST",
                    url: "<?php echo e(url('getdistrict')); ?>",
                    data: {state_code:state_code,role:role, _token: '<?php echo e(csrf_token()); ?>' },
                    dataType: "json",
                    success: function(res) { 
                        $('#dist_code').html(res.html);
                        $('#art_centre_code').html(res.arthtml);
                    },
                    error: function (jqXHR, exception) {

                    }
                });
            });
            $( "#dist_code" ).change(function() { 
                var dist_code = $(this).val();
                var role = $('#role').val();
                var state_code = $('#state_code').val();
                $.ajax({
                    type: "POST",
                    url: "<?php echo e(url('getartcenter')); ?>",
                    data: {dist_code:dist_code,state_code:state_code,role:role, _token: '<?php echo e(csrf_token()); ?>' },
                    dataType: "json",
                    success: function(res) { 
                        $('#art_centre_code').html(res.html);
                    },
                    error: function (jqXHR, exception) {

                    }
                });
            });
        </script>
         <!--get role wise permissiom ajax script-->
        <script src="<?php echo e(asset('js/get-role.js')); ?>"></script>
    <?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/yrgdmc/public_html/treatment/resources/views/create-user.blade.php ENDPATH**/ ?>