IMMREX7
<?php $__env->startSection('content'); ?>
<div class="row clearfix">
<div class="col-sm-5">
<div class="card">
<div class="header">
<h2><strong>Assign Class</strong></h2>
</div>
<div class="body">
<?php if(isset($teacherclass)): ?>
<?php echo Form::model($teacherclass, ['method' => 'PATCH', 'action' => ['School\AssignClassController@update', $teacherclass->idTeacherClass], 'class' => 'form-horizontal']); ?>
<?php else: ?>
<?php echo Form::open(['url' => 'school/asignclass', 'class' => 'form-horizontal','id'=>'assignclassform']); ?>
<?php endif; ?>
<div class="row clearfix">
<div class="col-sm-4 form-control-label required">
<label for="classname">Teacher</label>
</div>
<div class="col-sm-7">
<div class="form-group">
<?php echo Form::select('idEmployee',$teachers,null,['class' => 'form-control show-tick ms select2']); ?>
<?php if($errors->has('idEmployee')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idEmployee')); ?></strong>
</label>
<?php endif; ?>
<span id='teachererror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label required">
<label for="classname">Class</label>
</div>
<div class="col-sm-7">
<div class="form-group">
<?php echo Form::select('idClass',$classes,null,['class' => 'form-control show-tick ms select2']); ?>
<?php if($errors->has('idClass')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idClass')); ?></strong>
</label>
<?php endif; ?>
<span id='classerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-4 form-control-label required">
<label for="classname">Section</label>
</div>
<div class="col-sm-7">
<div class="form-group">
<?php if(isset($teacherclass)): ?>
<?php echo Form::select('idSection',$section,null,['class' => 'form-control show-tick ms select2']); ?>
<?php else: ?>
<div id="idSection" style="border:1px solid #ccc; width:200px; height: 110px; overflow-y: scroll;">
</div>
<!--<select name='idSection' class="form-control show-tick ms select2"></select>-->
<?php if($errors->has('idSection')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idSection')); ?></strong>
</label>
<?php endif; ?>
<?php endif; ?>
<span id='sectionerror'></span>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
<?php if(isset($teacherclass)): ?>
<?php echo Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']); ?>
<?php else: ?>
<?php echo Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-btn']); ?>
<?php endif; ?>
<?php echo Form::close(); ?>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-7">
<div class="card">
<div class="header">
<h2><strong>List Of Assign Classes</strong></h2>
</div>
<div class="body table-responsive">
<?php echo Form::open(['method' => 'GET', 'action' => ['School\AssignClassController@index'], 'class' => 'form-horizontal']); ?>
<div class="row clearfix">
<div class="col-sm-3 form-control-label">
<label for="classname">Financial Year</label>
</div>
<div class="col-sm-5">
<div class="form-group">
<?php echo Form::select('idFinancialYear',fys(),null,['class' => 'form-control show-tick ms']); ?>
</div>
</div>
<div class="col-sm-2">
<?php echo Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']); ?>
</div>
</div>
<?php echo Form::close(); ?>
<br>
<table class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead>
<tr>
<th>S. No.</th>
<th>Class</th>
<th>Section</th>
<th>Teacher</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
<?php $__currentLoopData = $teacherclasses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<tr>
<th scope="row"><?php echo e($i); ?></th>
<td><?php echo e(isset($value->classM->className) ? $value->classM->className : ' '); ?></td>
<td><?php echo e(isset($value->section->sectionName) ? $value->section->sectionName : 'All'); ?></td>
<td><?php if(isset($value->teacher)): ?><?php echo e($value->teacher->firstName); ?> <?php echo e($value->teacher->lastName); ?> <?php endif; ?></td>
<td>
<a href="<?php echo e(url('school/asignclass/' . $value->idTeacherClass . '/edit')); ?>" class="btn btn-raised btn-info waves-effect btn-round">Edit </a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="<?php echo e($value->idTeacherClass); ?>" data-type="confirm">DELETE</button>
</td>
</tr>
<?php $i++; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
$(document).ready(function() {
$('select[name="idClass"]').on('change', function() {
var classID = $(this).val();
if(classID) {
$.ajax({
url: "<?php echo e(url('/school/class')); ?>"+'/' +classID + "/sections",
type: "GET",
dataType: "json",
success:function(data) {
$('#idSection').empty();
$('#idSection').append('<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;"><label style="margin-right:42px;"><strong>Select All</label></strong><input type="checkbox" class="select-all" id="selectall"></div>');
$.each(data, function(key, value) {
$('#idSection').append('<div class="checkbox-inline" style="padding-left:10px;"><label style="margin-right:100px;">'+value+'</label><input type="checkbox" name="sections['+key+']"></div>');
});
}
});
}else{
$('select[name="idSection"]').empty();
}
});
});
$(document).on('click', '.select-all', function(){
var checkAll = this.checked;
if(checkAll === true){
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
}else{
$('input[type=checkbox]').each(function () {
this.checked = checkAll;
});
}
});
$(document).on('click', '.js-sweetalert', function (e) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
e.preventDefault();
var id = $(this).data('id');
swal({
title: "Are you sure?",
text: "Are You sure you want to delete this Assignment!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "<?php echo e(url('/school/asignclass/')); ?>" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "This Assignment has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
$('#assignclassform').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#assignclassform')[0]);
$("#submit-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "<?php echo e(url('school/asignclass')); ?>",
processData: false,
contentType: false,
data:formData,
dataType: 'json',
success:function(data){
if( data[Object.keys(data)[0]] === 'SUCCESS' ){
$("#submit-btn").prop('disabled', true);
window.location = "<?php echo e(url('school/asignclass')); ?>";
}
else { //False Case: With error msg
$("#msg").html(data); //$msg is the id of empty msg
}
},
error: function(data){
if( data.status === 422 ) {
$("#submit-btn").prop('disabled', false);
var errors = data.responseJSON.errors;
var errorHtml = '<div class="alert alert-danger"><ul>';
$('#formerrors').html(errorHtml);
if(errors['idClass']=== undefined){
$( '#classerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idClass']+'</strong></span>';
$( '#classerror' ).html( errorname );
}
if(errors['idSection']=== undefined){
$( '#sectionerror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idSection']+'</strong></span>';
$( '#sectionerror' ).html( errorname );
}
if(errors['idEmployee']=== undefined){
$( '#teachererror' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idEmployee']+'</strong></span>';
$( '#teachererror' ).html( errorname );
}
}
}
});
return false;
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('schools.school_layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Copyright © 2021 -