
<?php $__env->startSection('title'); ?>পোষ্ট সেটিং  | TESTPAPER <?php $__env->stopSection(); ?>
<?php $__env->startSection('class'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('class.index'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('styles'); ?>
<?php $__env->stopSection(); ?>

<!-- BEGIN: Content-->
<?php $__env->startSection('main_content_section'); ?>
<div class="row py-3 ps-2">
  <div class="heading d-flex justify-content-start heading-margin-bottom-minus">
    <h3 class="mb-0"><span>পোষ্ট সেটিং</span></h3>
  </div>
</div>


<div class="table_wrapper py-1 card">
  <div class="row my-2 aggregate-section-div">
    <div class="px-3 ">
      <div class=" d-flex justify-content-between align-items-center aggregate-section border-0">
        <div class="d-flex align-items-center py-1 d-none d-sm-block">
          <p class="mb-0"><a href="<?php echo e(route('default-post-setting.index')); ?>"
              class="text-primary  py-2 px-3 active">সব (<?php echo e($allDefaultPostData->count()); ?>)</a></p>
          
        </div>
        <div class="d-none d-sm-block">
          <?php if(Auth::user()->can('post-setting-access')): ?> 
            <a href="javascript:void(0)" class="btn btn-success rounded-0 d-flex align-items-center px-2 border-0"
              data-bs-toggle="modal" data-bs-target="#postSetting"><span class="">নতুন পোষ্ট সেটিং</span></a>
          <?php endif; ?>
        </div>
      </div>

      <?php if(Auth::user()->can('post-setting-access')): ?> 
        <div class="mt-2 btn btn-success d-block rounded-0 d-sm-none" data-bs-toggle="modal"
          data-bs-target="#postSetting">নতুন পোষ্ট সেটিং</div>
      <?php endif; ?>
    </div>
  </div>



  <div class="row px-3">
    <div class="table-container table-responsive">
      <table id="" class="table table-bordered">
        <thead class="text-uppercase">
          <tr class="me-3">

            <th class="text-center" scope="col"><span>শ্রেণি</span></th>
            <th class="text-center" scope="col"><span> বিভাগ </span></th>
            <th class="text-center" scope="col"><span> বিষয় </span></th> 
            <th class="text-center" scope="col"><span> অধ্যায় </span></th> 
            <th class="text-center" scope="col"><span> আইডি </span></th>
            <th class="text-center" scope="col"><span> বর্তমান অবস্থা </span></th> 


          </tr>
        </thead>
        <tbody class="text-center">

          <?php $__currentLoopData = $defaultPostData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
          <?php if(isset($item) && $item != null): ?>
          <tr class="">
            <td>
                <?php echo e($item->classData->class_name); ?>

                <div class="row-actions">
                    <?php if(Auth::user()->can('post-setting-access')): ?> 
                      <span><button href="javascript:void(0)" class="border-0 bg-transparent" onclick="editPostSetting(<?php echo e($item->id); ?>)"
                          value="<?php echo e($item->id); ?>"> <span class="text-primary">সম্পাদন</span>  | </button></span>
                    <?php endif; ?>


                        <?php if(Auth::user()->can('post-setting-access')): ?> 
                          <span><a href="<?php echo e(route('default-post-setting.destroy',$item->id)); ?>" class="row-delete"><span
                            class="trash text-danger"> ডিলিট </span> | </a></span>
                        <?php endif; ?>

                          <?php if($item->status == true): ?>
                          <span><a class="text-warning" href="<?php echo e(route('default-post-setting.inactive', $item->id)); ?>">নিস্ক্রিয়</a></span>
                          <?php else: ?>
                          <span><a class="text-success" href="<?php echo e(route('default-post-setting.active', $item->id)); ?>">সক্রিয়</a></span>
                          <?php endif; ?>
                </div>
            </td>
            <td><?php echo e($item->departmentData->department_name); ?></td>
            <td><?php echo e($item->subjectData->subject_name); ?></td>
            <td><?php echo e($item->chapterData->chapter_name); ?></td>
            <td>
              <div class="row_title">
                <strong><a href="#"><?php echo e($item->id); ?></a></strong>
              </div>
            </td>
            <td>
                <?php if($item->status == true): ?>
                <span class="badge bg-success">সক্রিয়</span>
                <?php else: ?>
                <span class="badge bg-danger">নিষ্ক্রিয়</span>
                <?php endif; ?>
              </td>
          </tr>

          
        <div class="modal fade" id="editPostSetting<?php echo e($item->id); ?>" tabindex="-1" aria-labelledby="editPostSetting" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered max-width-1000px">
            <div class="modal-content">
                <div class="modal-header">
                <h1 class="modal-title fs-5" id="editPostSetting">সম্পাদন পোষ্ট সেটিং</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body p-0">
                <form action="<?php echo e(route('default-post-setting.update', $item->id)); ?>" method="post" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('put'); ?>
                    <div class="row px-4 my-4">

                    <div class="col-md-6 h-100">
                        <div class="col mb-3">
                        <div class="form-group custom-select2-form">
                            <label for="classname_id">শ্রেণির নাম <span class=" text-danger">(required)</span>
                            </label>
                            <select name="classname_id" id="classname_id<?php echo e($item->id); ?>" class="form-select select2"
                            onchange="classWiseDeptForUpdate(<?php echo e($item->id); ?>)" required>
                            <option value="" selected disabled> শ্রেণি সিলেক্ট করুন </option>
                            <?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $class): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($class->id); ?>" <?php echo e($class->id == $item->classname_id ? "selected":""); ?>>
                                <?php echo e($class->class_name); ?>

                            </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <?php $__errorArgs = ['classname_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class=text-danger><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="col mb-3">
                            <div class="form-group custom-select2-form">
                                <label for="subject_id">বিষয়ের নাম <span class=" text-danger">(required)</span> </label>
                                <select id="subject_id<?php echo e($item->id); ?>" name="subject_id" class="form-select select2" onchange="subWiseSubForUpdate(<?php echo e($item->id); ?>)" required>
                                <option value="" selected disabled> বিষয় সিলেক্ট করুন </option>
                                    <?php $__currentLoopData = $subjects; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $subject): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($subject->id); ?>" <?php echo e($subject->id == $item->subject_id ? "selected":""); ?>>
                                    <?php echo e($subject->subject_name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <?php $__errorArgs = ['subject_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class=text-danger><?php echo e($message); ?></span>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                    </div>

                    <div class="col-md-6 h-100">
                            <div class="col mb-3">
                                <div class="form-group custom-select2-form">
                                <label for="name">বিভাগের নাম<span class=" text-danger">(required)</span> </label>
                                <select name="department_id" id="department_id<?php echo e($item->id); ?>" class="form-select select2"
                                    onchange="deptWiseSubForUpdate(<?php echo e($item->id); ?>)" required>
                                    <option value="" selected disabled> বিভাগ সিলেক্ট করুন </option>
                                    <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($department->id); ?>" <?php echo e($department->id == $item->department_id ? "selected":""); ?>>
                                    <?php echo e($department->department_name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                </div>
            
                                <?php $__errorArgs = ['department_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <span class=text-danger><?php echo e($message); ?></span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>

                            <div class="col mb-3">
                                <div class="form-group custom-select2-form">
                                    <label for="chapter_id">অধায়ের নাম <span class=" text-danger">(required)</span> </label>
                                    <select id="chapter_id<?php echo e($item->id); ?>" name="chapter_id" class="form-select select2" required>
                                    <option value="" selected disabled> অধ্যায় সিলেক্ট করুন </option>
                                    <?php $__currentLoopData = $chapters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $chapter): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($chapter->id); ?>" <?php echo e($chapter->id == $item->chapter_id ? "selected":""); ?>>
                                    <?php echo e($chapter->chapter_name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>

                                <?php $__errorArgs = ['chapter_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <span class=text-danger><?php echo e($message); ?></span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                    </div>
                    </div>
                    <div class="modal-footer">
                    <div class="">
                        <button type="submit" class="btn btn-success">সংরক্ষন</button>
                        <button type="button" class="btn btn-danger" data-bs-dismiss="modal">বাতিল</button>
                    </div>
                    </div>
                </form>
                </div>
            </div>
            </div>
        </div>


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


        </tbody>
      </table>
    </div>

    
  </div>


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


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

<div class="modal fade" id="postSetting" tabindex="-1" aria-labelledby="oneInputModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered max-width-1000px">
      <div class="modal-content">
        <div class="modal-header">
          <h1 class="modal-title fs-5" id="oneInputModalLabel">নতুন পোষ্ট সেটিং</h1>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body p-0">
          <form action="<?php echo e(route('default-post-setting.store')); ?>" method="post" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
            <div class="row px-4 my-4">

              <div class="col-md-6 h-100">
                <div class="col mb-3">
                  <div class="form-group custom-select2-form">
                    <label for="classname_id">শ্রেণির নাম <span class=" text-danger">(required)</span>
                    </label>
                    <select name="classname_id" id="classname_id" class="form-select select2"
                      onchange="classWiseDeptForCreate()" required>
                      <option value="" selected disabled> শ্রেণি সিলেক্ট করুন </option>
                      <?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $class): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <option value="<?php echo e($class->id); ?>" <?php echo e(old('classname_id') == $class->id ? "selected" : ""); ?>>
                        <?php echo e($class->class_name); ?>

                      </option>
                      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                  </div>
                  <?php $__errorArgs = ['classname_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                  <span class=text-danger><?php echo e($message); ?></span>
                  <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>

                <div class="col mb-3">
                    <div class="form-group custom-select2-form">
                        <label for="subject_id">বিষয়ের নাম <span class=" text-danger">(required)</span> </label>
                        <select id="subject_id" name="subject_id" class="form-select select2" onchange="subWiseSubForCreate()" required>
                        <option value="" selected disabled> বিষয় সিলেক্ট করুন </option>

                        </select>
                    </div>
                    <?php $__errorArgs = ['subject_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <span class=text-danger><?php echo e($message); ?></span>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
              </div>

              <div class="col-md-6 h-100">
                    <div class="col mb-3">
                        <div class="form-group custom-select2-form">
                          <label for="name">বিভাগের নাম <span class=" text-danger">(required)</span> </label>
                          <select name="department_id" id="department_id" class="form-select select2"
                            onchange="deptWiseSubForCreate()" required>
                            <option value="" selected disabled> বিভাগ সিলেক্ট করুন </option>
      
                          </select>
                        </div>
      
                        <?php $__errorArgs = ['department_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class=text-danger><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                      </div>

                    <div class="col mb-3">
                        <div class="form-group custom-select2-form">
                            <label for="chapter_id">অধায়ের নাম <span class=" text-danger">(required)</span> </label>
                            <select id="chapter_id" name="chapter_id" class="form-select select2" required>
                            <option value="" selected disabled> অধ্যায় সিলেক্ট করুন </option>

                            </select>
                        </div>

                        <?php $__errorArgs = ['chapter_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class=text-danger><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
              </div>
            </div>
            <div class="modal-footer">
              <div class="">
                <button type="submit" class="btn btn-success">সংরক্ষন</button>
                <button type="button" class="btn btn-danger" data-bs-dismiss="modal">বাতিল</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
</div>






<?php $__env->stopSection(); ?>
<!-- END: Content-->

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


<script>
  $(document).ready(function(){
          $(document).on('click', '.edit_user_modal', function(){
              $rowId = $(this).val();
              $('#editoneInputModalCenter').modal('show');
              $.ajax({
                  type:'GET',
                  url:'users-edit/'+$rowId,
                  success:function(response){
                      $rowId = response.id;
                      $name = response.name;
                      $email = response.email;
                      $mobile = response.mobile;
                      $('#edit_id').val($rowId);
                      $('#edit_name').val($name);
                    $('#edit_email').val($email);
                    $('#edit_mobile').val($mobile);
                  }
                  
                });
            });
        });

</script>


<script>

// select 2 

$(document).ready(function(){
    $("#classname_id").select2({
      dropdownParent: $('#postSetting')
    });
    $("#department_id").select2({
      dropdownParent: $('#postSetting')
    })
    $("#subject_id").select2({
      dropdownParent: $('#postSetting')
    })
    $("#chapter_id").select2({
      dropdownParent: $('#postSetting')
    })
  });


    //To get class wise depertment...

    function classWiseDeptForCreate(){
    var classname_id = $("#classname_id").val();
    // alert(classname_id);
    if(classname_id){
      $.ajax({
        url: "<?php echo e(url('/get_department/')); ?>/" + classname_id,
        type:"GET",
        dataType:"json",
        success:function(data){
          $("#department_id").empty();
          $("#department_id").append('<option value="" selected disabled>বিভাগ সিলেক্ট করুন</option>');
          $.each(data,function(key,value){
            $("#department_id").append('<option value="'+value.id+'">'+value.department_name+'</option>');
          });
        },
      });
    }  
  };


  //To get depertment wise subject...

    function deptWiseSubForCreate(){
      var department_id = $("#department_id").val();
      if(department_id){
        $.ajax({
        url: "<?php echo e(url('/get_subject/')); ?>/" + department_id,
        type:"GET",
        dataType:"json",
        success:function(data){
            $("#subject_id").empty();
            $("#subject_id").append('<option value="" selected disabled>বিষয় সিলেক্ট করুন</option>');
            $.each(data,function(key,value){
                
                $("#subject_id").append('<option value="'+value.id+'">'+value.subject_name+'</option>');
            });
          },
        });
      }  
    };


  //To get Chapter, Subject wise.

    function subWiseSubForCreate(){
      var subject_id = $("#subject_id").val();
      if(subject_id){
        $.ajax({
        url: "<?php echo e(url('/get_chapter/')); ?>/" + subject_id,
        type:"GET",
        dataType:"json",
        success:function(data){
            $("#chapter_id").empty();
            $("#chapter_id").append('<option value="" selected disabled>অধ্যায় সিলেক্ট করুন</option>');
            $.each(data,function(key,value){                
                $("#chapter_id").append('<option value="'+value.id+'">'+value.chapter_name+'</option>');
            });
          },
        });
      }  
    };



//To show update modal...
  function editPostSetting(id) {
    $("#editPostSetting"+id).modal('show');
    $("#classname_id"+id).select2({
      dropdownParent: $('#editPostSetting'+id)
    })
    $("#department_id"+id).select2({
      dropdownParent: $('#editPostSetting'+id)
    })
    $("#subject_id"+id).select2({
      dropdownParent: $('#editPostSetting'+id)
    })
    $("#chapter_id"+id).select2({
      dropdownParent: $('#editPostSetting'+id)
    })
  }



//To get class wise depertment... update purpose
function classWiseDeptForUpdate(id){
  var classname_id = $("#classname_id"+id).val();
  if(classname_id){
    $.ajax({
      url: "<?php echo e(url('/get_department/')); ?>/" + classname_id,
      type:"GET",
      dataType:"json",
      success:function(data){
        $("#department_id"+id).empty();
        $("#department_id"+id).append('<option value="" selected disabled>বিভাগ সিলেক্ট করুন</option>');
        $.each(data,function(key,value){
          $("#department_id"+id).append('<option value="'+value.id+'">'+value.department_name+'</option>');
        });
        $("#subject_id"+id).empty();
        $("#subject_id"+id).append('<option value="" selected disabled>বিষয় সিলেক্ট করুন</option>');
        $("#chapter_id"+id).empty();
        $("#chapter_id"+id).append('<option value="" selected disabled>অধ্যায় সিলেক্ট করুন</option>');
      },
    });
  }  
}; 


//To get depertment wise subject... update purpose
function deptWiseSubForUpdate(id){
  var department_id = $("#department_id"+id).val();
  if(department_id){
    $.ajax({
    url: "<?php echo e(url('/get_subject/')); ?>/" + department_id,
    type:"GET",
    dataType:"json",
    success:function(data){
        $("#subject_id"+id).empty();
        $("#subject_id"+id).append('<option value="" selected disabled>বিষয় সিলেক্ট করুন</option>');
        $.each(data,function(key,value){
            
            $("#subject_id"+id).append('<option value="'+value.id+'">'+value.subject_name+'</option>');
        });
      },
    });
  }  
};

  //To get Chapter, Subject wise. update purpose

  function subWiseSubForUpdate(id){
      var subject_id = $("#subject_id"+id).val();
      if(subject_id){
        $.ajax({
        url: "<?php echo e(url('/get_chapter/')); ?>/" + subject_id,
        type:"GET",
        dataType:"json",
        success:function(data){
            $("#chapter_id"+id).empty();
            $("#chapter_id"+id).append('<option value="" selected disabled>অধ্যায় সিলেক্ট করুন</option>');
            $.each(data,function(key,value){                
                $("#chapter_id"+id).append('<option value="'+value.id+'">'+value.chapter_name+'</option>');
            });
          },
        });
      }  
    };


</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH E:\Project\Personal-Project\Office-Project\update\test-paper-final\resources\views/admin/setting/post/index.blade.php ENDPATH**/ ?>