
<?php $__env->startSection('title'); ?> বিষয় | TESTPAPER <?php $__env->stopSection(); ?>
<?php $__env->startSection('department'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('department.index'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('styles'); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('main_content_section'); ?>
<div class="row py-3 ps-2">
	<div class="heading d-flex justify-content-start">
		<h3><span>বিষয়ের তালিকা</span></h3>
	</div>
</div>

<div class="table_wrapper py-1 card min-vh-100">
	<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">
				<div class="d-flex align-items-center">
					<p class="mb-0"><a href="<?php echo e(route('subject')); ?>"
							class="text-primary py-2 px-3">সব(<?php echo e($allSubjectCount); ?>)</a></p>
					<p class="mb-0"><a href="<?php echo e(route('active-subject-list')); ?>"
							class="text-primary py-2 px-3">সক্রিয়(<?php echo e($activeSubjectCount); ?>)</a></p>
					<p class="mb-0"><a href="<?php echo e(route('inactive-subject-list')); ?>"
							class="active py-2 px-3">নিষ্ক্রিয়(<?php echo e($subjects->count()); ?>)</a></p>
				</div>
				<div>
					<a href="#" class="btn btn-success rounded-0 d-flex align-items-center px-2 border-0"
						data-bs-toggle="modal" data-bs-target="#addSubject"><span class="">নতুন বিষয়</span></a>
				</div>
			</div>
		</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" id="title"><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 = $subjects; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
					<?php if(isset($item) && $item != null): ?>

					<tr class="">
						<td><?php echo e($loop->index+1); ?></td>
						<td>
							<?php if($item->subject_image != null): ?>
							<img src="<?php echo e(asset('backend/images/subject/'.$item->subject_image)); ?>" height="50" width="70"
								alt="">
							<?php else: ?>
							<img src="<?php echo e(asset('backend/images/subject/default/default.jpg')); ?>" height="50" width="70"
								alt="">
							<?php endif; ?>
						</td>

						<td>
							<div class="row_title">
								<strong><a href="#"><?php echo e($item->subject_name); ?></a></strong>
							</div>
							<div class="row-actions">
								<span><button class="edit_class_modal border-0 bg-transparent" value="<?php echo e($item->id); ?>"
										onclick="updateSubject(<?php echo e($item->id); ?>)"> সম্পাদন </button> | </span>

								<span><a href="<?php echo e(route('subject.delete', ['id'=>$item->id])); ?>"
										class="row-delete"><span class="trash text-danger">ডিলিট</span> | </a></span>

								<?php if($item->status == true): ?>
								<span><a class="text-warning" href="<?php echo e(route('subject-inactive', $item->id)); ?>">নিস্ক্রিয়</a></span>
								<?php else: ?>
								<span><a class="text-success" href="<?php echo e(route('subject-active', $item->id)); ?>">সক্রিয়</a></span>
								<?php endif; ?>
							</div>
						</td>

						<td class="custom-text-left">
							<b>Class: </b> <span><?php echo e($item->classData->class_name); ?></span><br>
							<b>Department: </b><span><?php echo e($item->departmentData->department_name); ?></span>
						</td>

						<td class="my-auto">
							<?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="updateSubject<?php echo e($item->id); ?>" 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>
								<form action="<?php echo e(route('subject.update',$item->id)); ?>" method="post"
									enctype="multipart/form-data">
									<?php echo csrf_field(); ?>
									<div class="modal-body p-0">
										<div class="row px-4 my-4">
											<div class="col-md-6 mb-3">
												<div class="form-group">
													<label for="subject_name">বিষয়ের নাম <span
															class=" text-danger">(required)</span>
													</label>
													<input type="text" name="subject_name" required
														class="form-control form-control-solid" placeholder="বিষয়ের নাম"
														value="<?php echo e($item->subject_name); ?>">
												</div>

												<?php $__errorArgs = ['subject_name'];
$__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-md-6 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($item->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-md-6 mb-3">
												<div class="form-group">
													<label for="name">বইয়ের ছবি</label>
													<input type="file" class=" form-control" name="subject_image"
														id="subject_image">
												</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-md-6 mb-3">
												<div class="form-group custom-select2-form">
													<label for="name">বিভাগের নাম <span
															class=" text-danger">(required)</span> </label>
													<select id="department_id<?php echo e($item->id); ?>" name="department_id"
														class="form-select select2" required>
														<option 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>
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-danger"
											data-bs-dismiss="modal">Discard</button>
										<button type="submit" class="btn btn-primary">Update</button>
									</div>
								</form>
							</div>
						</div>
					</div>

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


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


</div>


<div class="modal fade" id="addSubject" 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>
			<form action="<?php echo e(route('subject.store')); ?>" method="post" enctype="multipart/form-data">
				<?php echo csrf_field(); ?>
				<div class="modal-body p-0">
					<div class="row px-4 my-4">
						<div class="col-md-6 mb-3">
							<div class="form-group">
								<label for="subject_name">বিষয়ের নাম <span class=" text-danger">(required)</span>
								</label>
								<input type="text" name="subject_name" required class="form-control form-control-solid"
									placeholder="বিষয়ের নাম">
							</div>

							<?php $__errorArgs = ['subject_name'];
$__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-md-6 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-md-6 mb-3">
							<div class="form-group">
								<label for="name">বইয়ের ছবি <span class=" text-danger">(required)</span></label>
								<input type="file" class=" form-control" name="subject_image" id="subject_image"
									required>
							</div>

							<?php $__errorArgs = ['subject_image'];
$__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-md-6 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" 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>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Discard</button>
					<button type="submit" class="btn btn-primary">Save</button>
				</div>
			</form>
		</div>
	</div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
	$(document).ready(function(){
    $("#classname_id").select2({
      dropdownParent: $('#addSubject')
    });
    $("#department_id").select2({
      dropdownParent: $('#addSubject')
    })
  });

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

  //Toget class wise depertment...
  function classWiseDeptForCreate(){
	var classname_id = $("#classname_id").val();
	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>');
				});
			},
		});
	}  
}; 
 
//Toget class wise depertment...
  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>');
				});
			},
		});
	}  
}; 
</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/subject/inActiveList.blade.php ENDPATH**/ ?>