IMMREX7
<?php $__env->startSection('content'); ?>
<div class="row clearfix">
<div class="card">
<div class="header">
<h2><strong><?php if(isset($type)): ?>Update <?php else: ?> Create <?php endif; ?> Exams</strong></h2>
</div>
<div class="alert alert-danger" role="alert" id="msg" style="display: none;">
</div>
<div class="body">
<?php if(isset($type)): ?>
<?php echo Form::model( $type, ['url' => 'school/mark/exam-create/'.$type->idExam, 'method' => 'POST','class'=>'form-horizontal'] ); ?>
<?php else: ?>
<?php echo Form::open(['url' => 'school/marks/exam-create','class'=>'form-horizontal','id'=>'form']); ?>
<?php endif; ?>
<div class="row clearfix">
<div class="col-sm-3">
<div class="form-group">
<?php if(isset($type)): ?>
<label for="classname"><strong>Exam Name</strong></label><br>
<?php echo Form::select('examName',$examtype,$type->idType,['class' => 'form-control show-tick ms select2',"id"=>'exam_type']); ?>
<?php else: ?>
<label for="classname"><strong>Select Exam</strong></label><br>
<?php echo Form::select('examName',$examtype,['class' => 'form-control show-tick ms select2','required'=>'required']); ?>
<?php endif; ?>
<?php if($errors->has('examName')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('examName')); ?></strong>
</label>
<?php endif; ?>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php if(isset($type)): ?>
<label for="classname"><strong>For Class</strong></label><br>
<?php echo Form::select('idClass',$classes,$type->idClass,['class' => 'form-control show-tick ms select2','required'=>'required']); ?>
<?php else: ?>
<label for="classname"><strong>Select Class</strong></label><br>
<?php echo Form::select('idClass',$classes,['class' => 'form-control show-tick ms select2','required'=>'required']); ?>
<?php endif; ?>
<?php if($errors->has('idClass')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idClass')); ?></strong>
</label>
<?php endif; ?>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php if(isset($type)): ?>
<label for="classname"><strong>Section</strong></label><br>
<?php if(isset($type->sectionName)): ?>
<?php echo Form::select('idSection',$section,$type->idSection,['class' => 'form-control show-tick ms select2','required'=>'required']); ?>
<?php else: ?>
<label for="idSectionAll" style="color:green"> All Classes </label><br>
<?php endif; ?>
<?php else: ?>
<label for="classname"><strong>Select Section</strong></label><br>
<input type="checkbox" id="idSectionAll" name="idSectionAll" value="selectall">
<label for="idSectionAll" style="color:green"> Select All </label><br>
<select name="sections[]" multiple="multiple" id="idSection">
</select>
<?php endif; ?>
<?php if($errors->has('idSection')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idSection')); ?></strong>
</label>
<?php endif; ?>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<?php if(isset($type)): ?>
<label for="classname"><strong>Subjects</strong></label><br>
<?php if(count(json_decode($type->subjects,true)) == count($subject)): ?>
<input type="checkbox" id="idSubjectAll" name="idSubjectAll" value="selectall" checked>
<?php else: ?>
<input type="checkbox" id="idSubjectAll" name="idSubjectAll" value="selectall">
<?php endif; ?>
<label for="idSubjectAll" style="color:green"> Select All </label><br>
<select name="subjects[]" multiple="multiple" id="idSubject">
<?php $__currentLoopData = $subject; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($value); ?>" <?php if(in_array($value, json_decode($type->subjects,true))) echo 'selected';?>><?php echo e($key); ?></option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php else: ?>
<label for="classname"><strong>Select Subject</strong></label><br>
<input type="checkbox" id="idSubjectAll" name="idSubjectAll" value="selectall">
<label for="idSubjectAll" style="color:green"> Select All </label><br>
<select name="subjects[]" multiple="multiple" id="idSubject">
</select>
<?php endif; ?>
<?php if($errors->has('idSection')): ?>
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong><?php echo e($errors->first('idSection')); ?></strong>
</label>
<?php endif; ?>
</div>
</div>
</div>
<div class="header">
<h2><strong>Total Marks</strong></h2>
</div>
<div class="row clearfix">
<table class="table col-sm-6">
<thead>
<tr>
<th>Subject</th>
<th>Theory</th>
<th>Pratical</th>
<th>Please tick if pratical is not available</th>
</tr>
</thead>
<?php if(isset($type)): ?>
<tbody id="marks_list">
<?php
foreach(json_decode($type->marks,true) as $points){
$k = $points["id"];
?>
<tr id="subject_<?php echo e($k); ?>">
<td>
<input class="form-control" type="hidden" name="marks[<?php echo e($k); ?>][id]" value="<?php echo e($k); ?>"/>
<?php echo Form::text('marks['.$k.'][subject]',$points["subject"],['class' => 'form-control','readonly'=>'readonly','placeholder'=>'Subjects']); ?>
</td>
<td>
<?php echo Form::number('marks['.$k.'][theory]',$points["theory"],['class' => 'form-control','required'=>'required','placeholder'=>'Marks']); ?>
</td>
<td>
<?php echo Form::number('marks['.$k.'][pratical]',$points["pratical"],['class' => 'form-control','placeholder'=>'Marks', 'id' => 'praticals_text_'.$k ]); ?>
</td>
<td style="text-align:left;vertical-align: middle;">
<?php if($points["pratical"] == 'nil'): ?>
<input type="checkbox" id="praticals_<?php echo e($k); ?>" data-id="<?php echo e($k); ?>" name="marks[<?php echo e($k); ?>][pratical]" value="nil" onchange="disablePraticals(this)" checked >
<?php else: ?>
<input type="checkbox" id="praticals_<?php echo e($k); ?>" data-id="<?php echo e($k); ?>" name="marks[<?php echo e($k); ?>][pratical]" value="nil" onchange="disablePraticals(this)">
<?php endif; ?>
</td>
</tr>
<?php
}
?>
</tbody>
<?php else: ?>
<tbody id="marks_list">
</tbody>
<?php endif; ?>
</table>
</div>
<div class="header">
<h2><strong>Grades</strong></h2>
</div>
<div class="row clearfix">
<table class="table col-sm-6">
<thead>
<tr>
<th></th>
<th>Grade Name</th>
<th>From Marks</th>
<th>To Marks</th>
<!--<th>Publish Time</th>-->
<th></th>
</tr>
</thead>
<?php if(isset($type)): ?>
<tbody id="optional_list">
<?php
$i = 1;
foreach(json_decode($type->grades,true) as $points){
?>
<tr>
<td class="sno"><?php echo e($i); ?></td>
<td>
<?php echo Form::text('grades['.$i.'][name]',$points["name"],['class' => 'form-control','required'=>'required','placeholder'=>'Grade Name']); ?>
</td>
<td>
<?php echo Form::number('grades['.$i.'][from]',$points["from"],['class' => 'form-control','required'=>'required','placeholder'=>'Marks']); ?>
</td>
<td>
<?php echo Form::number('grades['.$i.'][to]',$points["to"],['class' => 'form-control','required'=>'required','placeholder'=>'Marks']); ?>
</td>
<td style="text-align:right;vertical-align: middle;">
<input type="button" class="btn btn-sm btn-danger" value="Delete" id="remove_row">
</td>
</tr>
<?php
$i++;
}
?>
</tbody>
<?php else: ?>
<tbody id="optional_list">
<?php $i = 1; ?>
<tr>
<td class="sno"><?php echo e($i); ?></td>
<td>
<?php echo Form::text('grades[1][name]',null,['class' => 'form-control','required'=>'required','placeholder'=>'Grade Name']); ?>
</td>
<td>
<?php echo Form::number('grades[1][from]',null,['class' => 'form-control','required'=>'required','placeholder'=>'Marks']); ?>
</td>
<td>
<?php echo Form::number('grades[1][to]',null,['class' => 'form-control','required'=>'required','placeholder'=>'Marks']); ?>
</td>
</tr>
<?php $i++; ?>
</tbody>
<?php endif; ?>
<tr>
<td colspan="4" style="text-align: right"><input type="button" class="add-row btn btn-sm btn-success" value="Add New"></td>
</tr>
</table>
</div>
<div class="row clearfix">
<?php echo Form::submit('SAVE',['class' => 'btn btn-raised btn-primary btn-round waves-effect' ,'style'=>'width: 150px; max-width: 254px;']); ?>
</div>
<?php echo Form::close(); ?>
</div>
</div>
<div class="card">
<div class="header">
<h2><strong>List of Exams</strong></h2>
</div>
<div class="body table-responsive">
<table class="table table-bordered table-striped table-hover js-basic-example dataTable" id="marks_types">
<thead>
<tr>
<th>S.NO.</th>
<th>Name</th>
<th>Class</th>
<th>Section</th>
<th>Marks</th>
<th>Subject</th>
<th>Grade</th>
<th>Action</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
function disablePraticals(selectObject){
var praticals = document.getElementById("praticals_"+$(selectObject).attr("data-id"));
if (praticals.checked) {
document.getElementById("praticals_text_"+$(selectObject).attr("data-id")).readOnly = true;
}else{
document.getElementById("praticals_text_"+$(selectObject).attr("data-id")).readOnly = false;
}
}
$(document).ready(function() {
if ( $.fn.dataTable.isDataTable( '#marks_types' ) ) {
table = $('#marks_types').DataTable();
table.destroy();
table = $('#marks_types').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "<?php echo e(url('school/marks/exam-create')); ?>"
});
}
$('#idSection').multiselect({
listWidth: 200,
cssEven: false,
cssOdd: false,
});
$('#idSubject').multiselect({
listWidth: 200,
cssEven: false,
cssOdd: false,
});
var i = $('.sno:last').text();
$(".add-row").click(function(){
i++;
var markup = '<tr><td class="sno">'+i+'</td>\
<td><input class="form-control" type="text" name="grades['+i+'][name]" required="required" placeholder = "Name"><span id="depterror'+i+'"></span></td>\n\
\n\<td><input class="form-control" type="number" name="grades['+i+'][from]" required="required"></td>\n\
\n\<td><input class="form-control" type="number" name="grades['+i+'][to]" required="required"></td>\n\
<td style="text-align:right;vertical-align: middle;"><input type="button" class="btn btn-sm btn-danger" value="Delete" id="remove_row"></td></tr>';
$("#optional_list").append(markup);
});
$('#optional_list').on('click', 'input[type="button"]', function () {
$(this).closest('tr').remove();
i = $('.sno:last').text();
});
var subjects = [];
$('select[name="idClass"]').on('change', function() {
var classID = $(this).val();
$.ajax({
url: "<?php echo e(url('/school/class')); ?>"+'/' +classID + "/sections",
type: "GET",
dataType: "json",
success:function(data) {
$('#idSectionAll').prop('checked', false);
$('#idSection_checklist ul').empty();
$.each(data, function(key, value) {
$('#idSection_checklist ul').append('<li tabindex="0" class=""><input type="checkbox" value="'+key+'" name="idSection[]" id="idSection_'+key+'"><label for="idSection_'+key+'" class="leaveRoomForCheckbox">'+value+'</label></li>');
});
}
});
$.ajax({
url: "<?php echo e(url('/school/class')); ?>"+'/' +classID + "/subjects",
type: "GET",
dataType: "json",
success:function(data) {
$('#idSubjectAll').prop('checked', false);
$('#idSubject_checklist ul').empty();
subjects = data;
$.each(data, function(key, value) {
$('#idSubject_checklist ul').append('<li tabindex="0" class=""><input type="checkbox" value="'+key+'" name="idSubject[]" id="idSubject_'+key+'"><label for="idSubject_'+key+'" class="leaveRoomForCheckbox">'+value+'</label></li>');
});
}
});
});
$('#praticals').change(function() {
if(this.checked) {
$("#pratical_marks").prop("readonly", true);
}else{
$("#pratical_marks").prop("readonly", false);
}
});
$('#idSectionAll').change(function() {
if(this.checked) {
$("#idSection_checklist").addClass('checklistHighlighted');
$("#idSection_checklist ul").children().addClass('checked');
$("#idSection_checklist ul li input[type=checkbox]").each(function(e) {
$(this).prop('checked', true);
});
}else{
$("#idSection_checklist").removeClass('checklistHighlighted');
$("#idSection_checklist ul").children().removeClass('checked');
$("#idSection_checklist ul li input[type=checkbox]").each(function(e) {
$(this).prop('checked', false);
});
}
});
$('#idSubjectAll').change(function() {
if(this.checked) {
$("#idSubject_checklist").addClass('checklistHighlighted');
$("#idSubject_checklist ul").children().addClass('checked');
$("#idSubject_checklist ul li input[type=checkbox]").each(function(e) {
$(this).prop('checked', true);
});
$.each(subjects, function(key, value) {
var k = key;
var markup = '<tr id="subject_'+k+'">\
<td><input class="form-control" type="hidden" name="marks['+k+'][id]" value="'+k+'"/><input class="form-control" type="text" name="marks['+k+'][subject]" required="required" placeholder= "Subject" value="'+value+'" readonly><span id="depterror'+i+'"></span></td>\n\
\n\<td><input class="form-control" type="number" name="marks['+k+'][theory]" required="required"></td>\n\
\n\<td><input class="form-control" type="number" name="marks['+k+'][pratical]" required="required" id="praticals_text_'+k+'"></td>\n\
<td style="text-align:left;vertical-align: middle;"><input type="checkbox" id="praticals_'+k+'" name="marks['+k+'][pratical]" data-id="'+k+'" value="nil" onchange="disablePraticals(this)"></td></tr>';
$("#marks_list").append(markup);
});
}else{
$("#idSubject_checklist").removeClass('checklistHighlighted');
$("#idSubject_checklist ul").children().removeClass('checked');
$("#idSubject_checklist ul li input[type=checkbox]").each(function(e) {
$(this).prop('checked', false);
});
$.each(subjects, function(key, value) {
$('#subject_'+key+'').remove();
});
}
});
$('#idSubject_checklist').on('change', 'input[type=checkbox]', function(event) {
var k = $(this).val();
if($(this).is(':checked')){
$.each(subjects, function(key, value) {
if(key == k){
var markup = '<tr id="subject_'+k+'">\
<td><input class="form-control" type="hidden" name="marks['+k+'][id]" value="'+k+'"/><input class="form-control" type="text" name="marks['+k+'][subject]" required="required" placeholder= "Subject" value="'+value+'" readonly><span id="depterror'+i+'"></span></td>\n\
\n\<td><input class="form-control" type="number" name="marks['+k+'][theory]" required="required"></td>\n\
\n\<td><input class="form-control" type="number" name="marks['+k+'][pratical]" id="praticals_text_'+k+'"></td>\n\
<td style="text-align:left;vertical-align: middle;"><input type="checkbox" id="praticals_'+k+'" name="marks['+k+'][pratical]" value="nil" onchange="disablePraticals(this)"></td></tr>';
$("#marks_list").append(markup);
}
});
}else{
$('#subject_'+k+'').remove();
}
});
$("button[data-id=idSection").hide();
$("button[data-id=idSubject").hide();
$("#idSection_actionButtons").hide();
$("#idSubject_actionButtons").hide();
});
$(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 Exam!",
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/marks/exam-create/')); ?>" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Exam has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
// Saving form data
$('#form').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#form')[0]);
$("#submit-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "<?php echo e(url('school/marks/exam-create')); ?>",
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/marks/exam-create')); ?>";
}
else {
$("#submit-btn").prop('disabled', false);
$("#msg").empty(); //False Case: With error msg
$("#msg").append(data[Object.keys(data)[0]]);
$("#msg").css('display','block'); //$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);
$.each(errors, function (key, value) {
if (key.split(".")[1] + '.typeName' === key.split(".")[1] + '.' + key.split(".")[2])
{
errordept = '<span class="help-block">' + value + '</span>';
$('#depterror' + key.split(".")[1]).html(errordept);
}
});
}
}
});
return false;
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('schools.school_layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Copyright © 2021 -