<?php $__env->startSection('content'); ?>
<?php
use Spatie\Permission\Models\Permission;
use App\Models\Modules;
use App\Models\PackPrem;
$Modules=Modules::orderBy('id','desc')->first();
?>
<style>

  @media  only screen and (max-width: 300px){
   #dt-basic-example{

    }}


@media  only screen and (max-width: 300px){
 .table-responsive{
        display:block;
        width:100%;
    }}
    @media  only screen and (min-width: 992px){
 .table-responsive{
        display:table;
        width:100%;
}}
.col-md-3{
        border: 1px solid #886ab5;
    border-radius: 13px;
    margin:4px;
}
</style>
  <title><?php echo e(trans('admin.AdminsPremations')); ?></title>

 <main id="js-page-content" role="main" class="page-content">
                        <ol class="breadcrumb page-breadcrumb">
                            <li class="breadcrumb-item"><a href="javascript:void(0);"> <?php echo e(trans('admin.Settings')); ?></a></li>
                            <li class="breadcrumb-item active"><?php echo e(trans('admin.AdminsPremations')); ?></li>
                            <li class="position-absolute pos-top pos-right d-none d-sm-block"><span
                                    class="js-get-date"></span></li>
                        </ol>
                        <div class="row">
                            <div class="col-xl-12">
                                <div id="panel-1" class="panel">
                                    <div class="panel-hdr">
                                        <h2>
                                            <span class="fw-300"><i><?php echo e(trans('admin.AdminsPremations')); ?></i></span>
                                        </h2>
                                        <div class="panel-toolbar">
                                              <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('اضافه صلاحيه')): ?>
                                            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#default-example-modal-lg"><?php echo e(trans('admin.AddNew')); ?></button>
                                            <?php endif; ?>
                                            <button class="btn btn-primary btn-sm mx-3" data-toggle="dropdown">Table Style</button>

                                                  <?php echo $__env->make('admin.layouts.toolbar', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                                        </div>
                                    </div>
                                    <div class="panel-container show">
                                   <span id="ex"> <?php echo $__env->make('admin.layouts.messages', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?></span>
                                        <div class="panel-content">
                                            <!-- datatable start -->
                                            <table class="table table-bordered table-responsive table-hover table-striped w-100">
                                                <thead class="bg-highlight">
                                                    <tr>
                                                        <th><?php echo e(trans('admin.Arabic_Name')); ?></th>
                                                        <th><?php echo e(trans('admin.English_Name')); ?></th>
                                                        <th><?php echo e(trans('admin.Details')); ?></th>
                                                        <th><?php echo e(trans('admin.Actions')); ?></th>

                                                    </tr>
                                                </thead>
                                                <tbody>
                                        <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <tr>
                                                        <td><?php echo e($r->name); ?></td>
                                                        <td><?php echo e($r->nameEn); ?></td>
                                                        <td>
                                                            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#default-example-modal-center-open<?php echo e($r->id); ?>">
                                                                <?php echo e(trans('admin.Premations')); ?>

                                                            </button>
                                                        </td>
                                                        <td class="text-center">


                                                 <?php if($r->name != 'Owner'): ?>
                                                             <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('حذف صلاحيه')): ?>
                                                            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#default-example-modal-center<?php echo e($r->id); ?>"><i class="fal fa-trash"></i></button>
                                                        <?php endif; ?>

                                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('تعديل صلاحيه')): ?>
                                                            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#default-example-modal-lg-edit<?php echo e($r->id); ?>"><i class="fal fa-edit"></i></button>
                                                        <?php endif; ?>
                                   <?php endif; ?>


                    <?php if($r->name == 'Owner' and auth()->guard('admin')->user()->email == 'Klar@test.com'): ?>

                                             <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('حذف صلاحيه')): ?>
                                                            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#default-example-modal-center<?php echo e($r->id); ?>"><i class="fal fa-trash"></i></button>
                                                        <?php endif; ?>

                                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('تعديل صلاحيه')): ?>
                                                            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#default-example-modal-lg-edit<?php echo e($r->id); ?>"><i class="fal fa-edit"></i></button>
                                                        <?php endif; ?>

                                            <?php endif; ?>



                                                        </td>
                                                    </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </tbody>
                                                <tfoot>
                                                    <tr>
                                                       <th><?php echo e(trans('admin.Arabic_Name')); ?></th>
                                                       <th><?php echo e(trans('admin.English_Name')); ?></th>
                                                        <th><?php echo e(trans('admin.Details')); ?></th>
                                                        <th><?php echo e(trans('admin.Actions')); ?></th>
                                                    </tr>
                                                </tfoot>
                                            </table>
                                            <?php echo e($roles->Links()); ?>

                                            <!-- datatable end -->
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Modal Add-->
                        <div class="modal fade" id="default-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
                            <div class="modal-dialog modal-xl" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title"><?php echo e(trans('admin.AddNew')); ?>  </h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                        </button>
                                    </div>


                                    <div class="modal-body">
                             <form action="<?php echo e(url('AddPrem')); ?>" method="post">
                                 <?php echo csrf_field(); ?>

                                            <div class="form-row">


                                                  <div class="col-md-6">
                                 <label><?php echo e(trans('admin.Arabic_Name')); ?></label>
                          <?php echo Form::text('name', null, array('class' => 'form-control')); ?>

                                                </div>

                                               <div class="col-md-6">
                                           <label><?php echo e(trans('admin.English_Name')); ?></label>
                          <?php echo Form::text('nameEn', null, array('class' => 'form-control')); ?>

                                                </div>


                            <div class="form-group col-lg-12">
                        <label><?php echo e(trans('admin.Premations')); ?></label> <br>
                        <label><?php echo e(trans('admin.All')); ?>


              <input type="checkbox" id="checkbox" onclick="CheckAll()">

                        </label>


                     <div class="row">
                            <?php $__currentLoopData = $permission; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                         <?php if($value->Parent == 0): ?>

             <?php     $CHILDs=DB::table('permissions')->where('Parent',$value->Main)->get(); ?>

                           <div class="col-md-12 mt-2 mb-2" style="color: #463a61;font-size: 35px;">
                                    <label>
                                 <?php echo e(app()->getLocale() == 'ar' ?$value->name :$value->nameEn); ?>

                               </label>
                <input type="checkbox" name="permission[]" onclick="CheckModule(<?php echo e($value->Main); ?>)" value="<?php echo e($value->id); ?>" class="name" id="n<?php echo e($value->Main); ?>" >
              <i class="fal fa-times" style="font-size: 17px;"></i>  <input type="checkbox"  onclick="UnCheckModule(<?php echo e($value->Main); ?>)" class="name" id="UN<?php echo e($value->Main); ?>" >
                         </div>

                         <div class="container">
                         <div class="row" style="border: 1px solid #886ab5;padding: 24px; border-radius:20px;">
                         <?php $__currentLoopData = $CHILDs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $child): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="col-md-3">
                                    <label style="font-size: 20px;">

                             <?php echo e(app()->getLocale() == 'ar' ?$child->name :$child->nameEn); ?>

                                    </label>
                 <input type="checkbox" name="permission[]" value="<?php echo e($child->id); ?>" class="name nn<?php echo e($child->Parent); ?>">
                         </div>
                         <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                        </div>
                         <hr>

                         <?php endif; ?>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>


                    </div>


                                            </div>

                                 <div class="form-row">
                         <button type="submit" class="btn btn-primary"><?php echo e(trans('admin.Save')); ?></button>
                                 </div>

                                          </form>

                                    </div>


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



          <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <!-- Modal Edit-->
                        <div class="modal fade" id="default-example-modal-lg-edit<?php echo e($r->id); ?>" tabindex="-1" role="dialog" aria-hidden="true">
                            <div class="modal-dialog modal-xl" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title"><?php echo e(trans('admin.Edit')); ?>  </h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                        </button>
                                    </div>
                                    <div class="modal-body">
                                       <form action="<?php echo e(url('EditPrem/'.$r->id)); ?>" method="post">
                                 <?php echo csrf_field(); ?>

                                            <div class="form-row">

                                                        <div class="col-md-6">
                  <label><?php echo e(trans('admin.Arabic_Name')); ?></label>
                   <?php echo Form::text('name', $r->name, array('class' => 'form-control')); ?>

                                                </div>


                                                        <div class="col-md-6">
    <label><?php echo e(trans('admin.English_Name')); ?></label>

                              <?php echo Form::text('nameEn', $r->nameEn, array('class' => 'form-control')); ?>

                                                </div>
                            <div class="form-group col-lg-12">
                   <label><?php echo e(trans('admin.Premations')); ?></label>
                             <label><?php echo e(trans('admin.All')); ?>


              <input type="checkbox" id="checkbox<?php echo e($r->id); ?>" onclick="CheckAllEdit(<?php echo e($r->id); ?>)">


                        </label>



                                <div class="row">




                            <?php $__currentLoopData = $permission; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if($value->Parent == 0): ?>


             <?php     $CHILDs=DB::table('permissions')->where('Parent',$value->Main)->get(); ?>


                        <div class="col-md-12 mt-2 mb-2" style="color: #463a61;font-size: 35px;">
                                                             <?php
$rolePermissions = DB::table("role_has_permissions")->where("role_has_permissions.role_id",$r->id)
->pluck('role_has_permissions.permission_id','role_has_permissions.permission_id')
->all();
                                ?>



<?php echo e(Form::checkbox('permission[]', $value->id, in_array($value->id, $rolePermissions) ? true : false, array('class' => 'nameEdit'))); ?>


                               <label>     <?php echo e(app()->getLocale() == 'ar' ?$value->name :$value->nameEn); ?>   </label>

                             <input type="checkbox" name="permission[]" onclick="CheckModuleEdit(<?php echo e($value->Main); ?>)" value="<?php echo e($value->id); ?>" class="name" id="nEdit<?php echo e($value->Main); ?>" >
              <i class="fal fa-times" style="font-size: 17px;"></i>  <input type="checkbox"  onclick="UnCheckModuleEdit(<?php echo e($value->Main); ?>)" class="name" id="UNEdit<?php echo e($value->Main); ?>" >
                             </div>

                             <div class="container">
                         <div class="row" style="border: 3px solid #453961;padding: 24px;">
                       <?php $__currentLoopData = $CHILDs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $child): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="col-md-4">

    <?php echo e(Form::checkbox('permission[]', $child->id, in_array($child->id, $rolePermissions) ? true : false, array('class' => 'nameEdit nnEdit'.$child->Parent))); ?>

             <label style="font-size: 20px;">   <?php echo e(app()->getLocale() == 'ar' ?$child->name :$child->nameEn); ?>      </label>
                             </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                 </div>
                                 </div>

                                    <?php endif; ?>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </div>



                    </div>


                                            </div>

                                 <div class="form-row">
                         <button type="submit" class="btn btn-primary"><?php echo e(trans('admin.SaveChanges')); ?></button>
                                 </div>

                                          </form>

                                    </div>

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


                          <!-- Modal Delete -->
                          <div class="modal fade" id="default-example-modal-center<?php echo e($r->id); ?>" tabindex="-1" role="dialog" aria-hidden="true">
                            <div class="modal-dialog modal-dialog-centered" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h4 class="modal-title">
                                             <?php echo e(trans('admin.RUSWDT')); ?> <strong>

                                             <?php echo e(app()->getLocale() == 'ar' ?$r->name :$r->nameEn); ?>

                                            </strong>
                                        </h4>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true"><i class="fal fa-times"></i></span>
                                        </button>
                                    </div>

                                    <div class="modal-footer">
                       <button type="button" class="btn btn-secondary" data-dismiss="modal"> <?php echo e(trans('admin.No')); ?></button>
                   <a href="<?php echo e(url('DeletePrem/'.$r->id)); ?>"  class="btn btn-primary"> <?php echo e(trans('admin.Yes')); ?></a>
                                    </div>
                                </div>
                            </div>
                        </div>


         <!--   Model Permission -->
         <div class="modal fade" id="default-example-modal-center-open<?php echo e($r->id); ?>" tabindex="-1" role="dialog"
              aria-hidden="true">
             <div class="modal-dialog modal-dialog-centered modal-xl" role="document">
                 <div class="modal-content">
                     <div class="modal-header">
                         <h4 class="modal-title">
                             <?php echo e(trans('admin.Premations')); ?>

                         </h4>
                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                             <span aria-hidden="true"><i class="fal fa-times"></i></span>
                         </button>
                     </div>
                     <div class="modal-body">

                         <div class="row">
                         <?php $__currentLoopData = $r->permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prem): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                 <?php if($prem->Main != 0): ?>
                                 <div class="col-md-12">
                                     <h2 style="color: darkred">
                                         <?php echo e(app()->getLocale() == 'ar' ?$prem->name :$prem->nameEn); ?>

                                     </h2>
                                 </div>

                                     <?php $__currentLoopData = $r->permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prem2): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                         <?php if($prem2->Parent == $prem->Main): ?>
                                             <div class="col-md-3">
                                                 <h6 style="color: #051b8a">
                                                     <?php echo e(app()->getLocale() == 'ar' ?$prem2->name :$prem2->nameEn); ?>

                                                    </h6>
                                             </div>
                                         <?php endif; ?>
                                     <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                 <?php endif; ?>
                         <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                         </div>


                     </div>
                     <div class="modal-footer">
                         <button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo e(trans('admin.Close')); ?></button>
                     </div>
                 </div>
             </div>
         </div></div>



     <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    </main>

<?php $__env->stopSection(); ?>

     <?php $__env->startPush('js'); ?>
         <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/datagrid/datatables/datatables.bundle.css')); ?>">
    <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/formplugins/select2/select2.bundle.css')); ?>">
    <script src="<?php echo e(asset('Admin/js/formplugins/select2/select2.bundle.js')); ?>"></script>
    <script src="<?php echo e(asset('Admin/js/datagrid/datatables/datatables.export.js')); ?>"></script>
    <script src="<?php echo e(asset('Admin/js/datagrid/datatables/datatables.bundle.js')); ?>"></script>


<script>
        //_fnFeatureHtmlLength();
        $(document).ready(function () {
            // Setup - add a text input to each footer cell
            $('#dt-basic-example thead tr').clone(true).appendTo('#dt-basic-example thead');
            $('#dt-basic-example thead tr:eq(1) th').each(function (i) {
                var title = $(this).text();
                $(this).html('<input type="text" class="form-control form-control-sm" placeholder="Search ' + title + '" />');

                $('input', this).on('keyup change', function () {
                    if (table.column(i).search() !== this.value) {
                        table
                            .column(i)
                            .search(this.value)
                            .draw();
                    }
                });
            });
            var table = $('#dt-basic-example').DataTable(
                {
                    responsive: true,
                    orderCellsTop: true,
                    fixedHeader: true,
                    lengthChange: true,

                    dom: "<'row mb-3'<'col-sm-12 col-md-3 d-flex align-items-center justify-content-start'f><'col-sm-12 col-md-9 d-flex align-items-center justify-content-end'B>>" +
                        "<'row'<'col-sm-12'tr>>" +
                        "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",

                    buttons: [
                        {
                            extend: 'pageLength',
                            className: 'btn-outline-default'
                        },
                        {
                            extend: 'colvis',
                            text: 'Column Visibility',
                            titleAttr: 'Col visibility',
                            className: 'btn-outline-default'
                        },
                        {
                            extend: 'pdfHtml5',
                            text: 'PDF',
                            titleAttr: 'Generate PDF',
                            className: 'btn-outline-danger btn-sm mr-1'
                        },
                        {
                            extend: 'excelHtml5',
                            text: 'Excel',
                            titleAttr: 'Generate Excel',
                            className: 'btn-outline-success btn-sm mr-1'
                        },
                        {
                            extend: 'csvHtml5',
                            text: 'CSV',
                            titleAttr: 'Generate CSV',
                            className: 'btn-outline-primary btn-sm mr-1'
                        },
                        {
                            extend: 'copyHtml5',
                            text: 'Copy',
                            titleAttr: 'Copy to clipboard',
                            className: 'btn-outline-primary btn-sm mr-1'
                        },
                        {
                            extend: 'print',
                            text: 'Print',
                            titleAttr: 'Print Table',
                            className: 'btn-outline-primary btn-sm'
                        }
                    ],
                });
            $('.js-thead-colors a').on('click', function () {
                var theadColor = $(this).attr("data-bg");
                console.log(theadColor);
                $('#dt-basic-example thead').removeClassPrefix('bg-').addClass(theadColor);
            });

            $('.js-tbody-colors a').on('click', function () {
                var theadColor = $(this).attr("data-bg");
                console.log(theadColor);
                $('#dt-basic-example').removeClassPrefix('bg-').addClass(theadColor);
            });

        });

    </script>


<script>
    function CheckAll() {
                             if($("#checkbox").prop("checked"))
                                {
                                    $(".name").prop("checked",true);


                                }else
                                if($("#checkbox").prop("checked",false))
                                {

                                    $(".name").prop("checked",false);


                                }
                                   }
       function CheckModule(r) {
                             if($("#n"+r).prop("checked"))
                                {
                                    $(".nn"+r).prop("checked",true);


                                }else
                                if($("#n"+r).prop("checked",false))
                                {

                                    $(".nn"+r).prop("checked",false);


                                }
                                   }
     function UnCheckModule(r) {
                             if($("#UN"+r).prop("checked"))
                                {
                                    $(".nn"+r).prop("checked",false);


                                }
                                   }
      function CheckAllEdit(r) {
                             if($("#checkbox"+r).prop("checked"))
                                {
                                    $(".nameEdit").prop("checked",true);


                                }else
                                if($("#checkbox"+r).prop("checked",false))
                                {

                                    $(".nameEdit").prop("checked",false);


                                }
                                   }


       function CheckModuleEdit(r) {
                             if($("#nEdit"+r).prop("checked"))
                                {
                                    $(".nnEdit"+r).prop("checked",true);


                                }else
                                if($("#nEdit"+r).prop("checked",false))
                                {

                                    $(".nnEdit"+r).prop("checked",true);


                                }
                                   }
     function UnCheckModuleEdit(r) {
                             if($("#UNEdit"+r).prop("checked"))
                                {
                                    $(".nnEdit"+r).prop("checked",false);


                                } else
                                if($("#nEdit"+r).prop("checked",true))
                                {

                                    $(".nnEdit"+r).prop("checked",false);


                                }
                                   }

                    </script>


     <?php $__env->stopPush(); ?>

<?php echo $__env->make('admin.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/klarapps/public_html/test.klarapps.com/resources/views/admin/AdminsPremations.blade.php ENDPATH**/ ?>