<?php $__env->startSection('content'); ?>
<?php
use App\Models\WorkDepartments;
use App\Models\Employess;
?>
<style>
@charset  "UTF-8";

.container {
  position: relative;
  display: block;
  width: 600px;
}

details {
  position: relative;
  width: auto;
  height: auto;
  overflow: hidden;
  max-height: 2.5em !important;
  transition: all 0.1s ease;
        padding: 65px;
    text-align: center;
}
details ::-webkit-details-marker {
  display: none;
    
}
details > summary {
  position: relative;
  margin-top: 0.25em;
  color: white;
  padding: 0.1em 0.5em 0.2em;
    background: linear-gradient(45deg, #8d0909, black);
        padding: 20px;
    text-align: center;
}
details > summary:before {
  content: "⊞";
  color: #eee;
  font-size: 0.5em;
  margin-right: 0.5em;
        padding: 20px;
    text-align: center;
}
details[open] > summary {
     background: #1f7633;
    color: #fff;
        padding: 20px;
    text-align: center;
}
details[open] > summary:before {
  content: "⊟";
  color: #ccc;
        padding: 20px;
    text-align: center;
}

.folder {
  margin: 0 0 0.5em 0.86em;
  padding: 0.5em 0em 0.5em 1.5em;
  border-left: 0.1em #ccc dotted;
  border-bottom: 0.1em #ccc dotted;
}
.folder p {
  margin: 0;
}

details[open] {
  height: auto;
  max-height: 99em !important;
  transition: all 1.2s ease;
        padding: 20px;
    text-align: center;
        overflow: scroll;
}

details:not([open]) .folder {
  height: 0px !important;
        padding: 20px;
    text-align: center;
}
</style>    
  <title><?php echo e(trans('admin.Work_Departments')); ?></title>

   <main id="js-page-content" role="main" class="page-content">
                        <ol class="breadcrumb page-breadcrumb">
                            <li class="breadcrumb-item"><a href="index.html"><?php echo e(trans('admin.HR')); ?></a></li>  
                            <li class="breadcrumb-item active"><?php echo e(trans('admin.Work_Departments')); ?></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-lg-12">
                                <div id="panel-2" class="panel">
                                    
                                    <div class="panel-hdr">
                                        <h2>
                                            <span class="fw-300"><i><?php echo e(trans('admin.AddNew')); ?></i></span>
                                        </h2>
                                    </div>
                                    <div class="panel-container show">         
                                        <div class="panel-content">
                                             <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('اضافه قسم عمل')): ?>   
                  <form class="form-row" action="<?php echo e(url('AddWorkDepartments')); ?>" method="post" enctype="multipart/form-data">
                                                <?php echo csrf_field(); ?>

                       <?php echo view('honeypot::honeypotFormFields'); ?>
                                                <div class="form-group col-md-2">
                                    <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Arabic_Name')); ?></label>
                    <input type="text" name="Arabic_Name" value="<?php echo e(old('Arabic_Name')); ?>" id="simpleinput" class="form-control" required>
                                                </div>
                      
                                          <div class="form-group col-md-2">
                                    <label class="form-label" for="simpleinput"><?php echo e(trans('admin.English_Name')); ?></label>
                    <input type="text" name="English_Name" value="<?php echo e(old('English_Name')); ?>" id="simpleinput" class="form-control" required>
                                                </div>
                                        <div class="form-group col-md-2">
                                    <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Budget')); ?></label>
                    <input type="number" step="any" name="Budget" value="<?php echo e(old('Budget')); ?>" id="simpleinput" class="form-control" required>
                                                </div>
                      
                      
                                                <div class="form-group col-md-3">
                                                    <label class="form-label" for=""> <?php echo e(trans('admin.Department')); ?> </label>
                           <select  class="select2 form-control w-100"  name="Parent">
                                      <option value=""><?php echo e(trans('admin.Department')); ?></option>
                                              <?php $__currentLoopData = $itemss; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $par): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                 <option value="<?php echo e($par->id); ?>">
                               
                                <?php echo e(app()->getLocale() == 'ar' ?$par->Arabic_Name :$par->English_Name); ?>

                               </option>
                                               <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </div>
                   
            
                                                <div class="form-group col-md-2 buttons mt-4">
                              <button type="submit" class="btn btn-primary"> <i class="fal fa-folder"></i> <?php echo e(trans('admin.Save')); ?></button>
                                                </div>
                                            </form>
                                               <?php endif; ?> 
                                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('حذف قسم عمل')): ?> 
                                                        <button type="button" class="btn btn-primary btn-1" data-toggle="modal" data-target="#default-example-modal-center"><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-primary btn-2" data-toggle="modal" data-target="#default-example-modal-lg-edit"><i class="fal fa-edit"></i></button>
                                                        <?php endif; ?>                            
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
   
                        <div class="row">
                            <div class="col-lg-12">
                                <div id="panel-1" class="panel">
                                    <div class="panel-hdr">
                                        <h2>
                                         <span class="fw-300"><i><?php echo e(trans('admin.Work_Departments')); ?></i></span>
                                        </h2>
                  
                                    </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">
                           
                                                       

  <details open="open">


    <summary><?php echo e(app()->getLocale() == 'ar' ?$Presdient->Arabic_Name :$Presdient->English_Name); ?></summary>
    <div class="folder">
        
      <li style="font-size: 20px; color: darkred">
       <?php echo e(app()->getLocale() == 'ar' ?$Emp->Name :$Emp->NameEn); ?>     
        </li>
        
    <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>    
      <details>
        <summary><?php echo e(app()->getLocale() == 'ar' ?$item->Arabic_Name :$item->English_Name); ?></summary>
          <?php    $Emps=Employess::where('Department',$item->id)->orderBy('id','asc')->get(); ?>
          <?php $__currentLoopData = $Emps; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $emp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
          <li style="font-size: 20px; color: darkred">
          
                <?php echo e(app()->getLocale() == 'ar' ?$emp->Name :$emp->NameEn); ?>  
          </li>
          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
          
          <?php   $Subs=WorkDepartments::where('Parent',$item->id)->get();  ?>
          
            <?php echo $__env->make('admin.HR.ChildsWorkDepartment',['Subs' => $Subs], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    
      </details>
   <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
  </details>

 
                                            
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
       
       
             <!-- Modal Edit-->
                    <div class="modal fade" id="default-example-modal-lg-edit" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog modal-lg" 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">
                                                   <div class="form-group col-md-3">
                                                    <label class="form-label" for=""> <?php echo e(trans('admin.Department')); ?> </label>
                           <select  class="select2 form-control w-100"  id="ParentChoiceEdit" onchange="ParentEdit()">
                                      <option value=""><?php echo e(trans('admin.Department')); ?></option>
                                              <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $par): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                 <option value="<?php echo e($par->id); ?>">  <?php echo e(app()->getLocale() == 'ar' ?$par->Arabic_Name :$par->English_Name); ?></option>
                                               <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </div>
                                    
                                    <form action="<?php echo e(url('EditWorkDepartments')); ?>" method="post">
                                        <?php echo csrf_field(); ?>

                                              <?php echo view('honeypot::honeypotFormFields'); ?>
                                        <div class="form-row">
                                        <input type="hidden" name="ID" id="ID">    
                                        <div class="form-group col-lg-3">
                                            <label class="form-label" for="simpleinput"><?php echo e(trans('admin.Arabic_Name')); ?></label>
                                            <input type="text" name="Arabic_Name" id="Arabic_Name"  class="form-control" required>
                                        </div>
                                        <div class="form-group col-lg-3">
                                     <label class="form-label" for="simpleinput"> <?php echo e(trans('admin.English_Name')); ?></label>
                          <input type="text" name="English_Name"  id="English_Name" class="form-control" >
                                        </div>
                                                              <div class="form-group col-lg-3">
                                     <label class="form-label" for="simpleinput"> <?php echo e(trans('admin.Budget')); ?></label>
                          <input type="number" step="any" name="Budget"  id="Budget" class="form-control" >
                                        </div>
                                            
                                               <div class="form-group col-lg-3">
                                     <label class="form-label" for="simpleinput"> <?php echo e(trans('admin.Department')); ?></label>
                          <input type="text"   id="Parent" class="form-control"  readonly >
                          <input type="hidden"   id="ParentHide" class="form-control" name="ParentCurrent" >
                                        </div>    
                                                        <div class="form-group col-md-3">
                                                    <label class="form-label" for=""> <?php echo e(trans('admin.Department_Change')); ?> </label>
                           <select  class="select2 form-control w-100"  name="Parent" >
                                      <option value=""><?php echo e(trans('admin.Department')); ?></option>
                                              <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $par): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
             <option value="<?php echo e($par->id); ?>">
                               
                              <?php echo e(app()->getLocale() == 'ar' ?$par->Arabic_Name :$par->English_Name); ?>   
                               </option>
                                               <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </div>            
                                            
                                        </div>
                                    <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo e(trans('admin.Close')); ?></button>
                                    <button type="submit" class="btn btn-primary"> <?php echo e(trans('admin.Save')); ?></button>
                                </div>        
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>

                  
             
                   <!-- Modal Delete-->
                    <div class="modal fade" id="default-example-modal-center" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog modal-lg" 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">
                                                   <div class="form-group col-md-3">
                                                    <label class="form-label" for=""> <?php echo e(trans('admin.Department')); ?> </label>
                           <select  class="select2 form-control w-100"  id="ParentChoiceDelete" onchange="ParentDelete()">
                                      <option value=""><?php echo e(trans('admin.Department')); ?></option>
                                              <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $par): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                 <option value="<?php echo e($par->id); ?>">  <?php echo e(app()->getLocale() == 'ar' ?$par->Arabic_Name :$par->English_Name); ?></option>
                                               <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </div>
                                    
                                    <form action="<?php echo e(url('DeleteWorkDepartments')); ?>" method="get">
                                              <?php echo view('honeypot::honeypotFormFields'); ?>
                                        <div class="form-row">
                                        <input type="hidden" name="ID" id="IDD">    
                                        </div>
                                    <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo e(trans('admin.Close')); ?></button>
                                    <button type="submit" class="btn btn-danger"> <?php echo e(trans('admin.Delete')); ?></button>
                                </div>        
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>

                 
                    </main>


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


<?php $__env->startPush('js'); ?>
    <style>
.boc-dark {
    background-color: #554f84;
    font: 13px/28px Helvetica,"Segoe UI",Arial,sans-serif;
}
</style>
        <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/fa-brands.css')); ?>">
        <link rel="stylesheet" media="screen, print" href="<?php echo e(asset('Admin/css/miscellaneous/treeview/treeview.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/orgchart.js')); ?>"></script>
      
      <!-- Search Selecet -->
 <script>
        $(document).ready(function()
        {
            $(function()
            {
                $('.select2').select2();

                $(".select2-placeholder-multiple").select2(
                {
                    placeholder: "Select State"
                });
                $(".js-hide-search").select2(
                {
                    minimumResultsForSearch: 1 / 0
                });
                $(".js-max-length").select2(
                {
                    maximumSelectionLength: 2,
                    placeholder: "Select maximum 2 items"
                });
                $(".select2-placeholder").select2(
                {
                    placeholder: "Select a state",
                    allowClear: true
                });

                $(".js-select2-icons").select2(
                {
                    minimumResultsForSearch: 1 / 0,
                    templateResult: icon,
                    templateSelection: icon,
                    escapeMarkup: function(elm)
                    {
                        return elm
                    }
                });

                function icon(elm)
                {
                    elm.element;
                    return elm.id ? "<i class='" + $(elm.element).data("icon") + " mr-2'></i>" + elm.text : elm.text
                }

    
        
  $('#account').select2({
    placeholder: "select...",
    ajax: {
        type: "GET",
        dataType: 'json',
        url: 'AllMainAccounts',
        processResults: function (data) {
          return {
            results: $.map(data, function(obj, index) {
              return { id: index, text: obj };
            })
          };
            
            	console.log(data);
            
        },
        data: function (params) {  
          var query = {
            search: params.term
          };
          if (params.term == "*") query.items = [];
          return { json: JSON.stringify( query ) }
        }
    }
  });

    
$('#account').on('select2:select', function (e) {
	console.log("select done", e.params.data);
});
           
     

             
            });
        });



    </script>


<!-- Edit -->
<script>
    
      function  ParentEdit(){
   
   var countryId = $('#ParentChoiceEdit').val();

       
                     if(countryId) {
                         $.ajax({
                             url: 'EditDepartment',
                             type:"GET",
                             data:{
                                 countryId:countryId,
                             },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },
   
                             success:function(data) {
                               
                     
                       $('#Arabic_Name').val(data.Ar); 
                       $('#English_Name').val(data.En); 
                       $('#Parent').val(data.parentName); 
                       $('#ParentHide').val(data.parent); 
                       $('#Budget').val(data.budget); 

                       $('#ID').val(data.d); 

                    
                                 
   
                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     } else {
   
                         $('select[name="state"]').empty();
                     }
       
       
           
   
   }   




</script>
<!-- Delete -->
<script>
    
      function  ParentDelete(){
   
   var countryId = $('#ParentChoiceDelete').val();

       
                     if(countryId) {
                         $.ajax({
                             url: 'EditDepartment',
                             type:"GET",
                             data:{
                                 countryId:countryId,
                             },
                             dataType:"json",
                             beforeSend: function(){
                                 $('#loader').css("visibility", "visible");
                             },
   
                             success:function(data) {
                               

                       $('#IDD').val(data.d); 

                             },
                             complete: function(){
                                 $('#loader').css("visibility", "hidden");
                             }
                         });
                     } else {
   
                         $('select[name="state"]').empty();
                     }
       
       
           
   
   }   




</script>



<?php $__env->stopPush(); ?>
<?php echo $__env->make('admin.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/MAMP/htdocs/laravel/ERP/resources/views/admin/HR/WorkDepartments.blade.php ENDPATH**/ ?>