IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="card">
<div class="header">
<h2><strong>Add Marks</strong></h2>
</div>
<div class="alert alert-danger" role="alert" id="msg" style="display: none;">
</div>
<div class="body">
{!! Form::open(['url' => 'school/marks/create','class'=>'form-horizontal']) !!}
<div class="row clearfix">
<div class="col-sm-3">
<div class="form-group">
<label for="classname"><strong>Select Exam</strong></label><br>
{!! Form::select('examName',$examtype,['class' => 'form-control show-tick ms select2','required'=>'required']) !!}
@if ($errors->has('examName'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('examName') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label for="classname"><strong>Select Class</strong></label><br>
{!! Form::select('idClass',$classes,['class' => 'form-control show-tick ms select2','required'=>'required']) !!}
@if ($errors->has('idClass'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idClass') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label for="classname"><strong>Select Section</strong></label><br>
@if($isSectionAll == "Y")
<input type="checkbox" id="idSectionAll" name="idSectionAll" value="selectall" checked>
@else <input type="checkbox" id="idSectionAll" name="idSectionAll" value="selectall">
@endif
<label for="idSectionAll" style="color:green"> Select All </label><br>
<select name="sections[]" multiple="multiple" id="idSection">
@if(isset($sections))
@if(count($sections))
@foreach($sections as $key => $value)
<option value="{{$value}}" <?php if(in_array($value, $idSections)) echo 'selected';?>>{{$key}}</option>
@endforeach
@endif
@endif
</select>
@if ($errors->has('idSection'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idSection') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label for="classname"><strong>Select Subject</strong></label><br>
@if($isSubjectAll == "Y")
<input type="checkbox" id="idSubjectAll" name="idSubjectAll" value="selectall" checked>
@else <input type="checkbox" id="idSubjectAll" name="idSubjectAll" value="selectall">
@endif
<label for="idSubjectAll" style="color:green"> Select All </label><br>
<select name="subjects[]" multiple="multiple" id="idSubject">
@if(isset($subjects))
@if(count($subjects))
@foreach($subjects as $key => $value)
<option value="{{$value}}" <?php if(in_array($value, $idSubject)) echo 'selected';?>>{{$key}}</option>
@endforeach
@endif
@endif
</select>
@if ($errors->has('idSection'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idSection') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-3">
<div class="form-group">
<label for="classname"><strong>Select Student</strong></label><br>
@if($isStudentAll == "Y")
<input type="checkbox" id="idStudentAll" name="idStudentAll" value="selectall" checked>
@else @if(isset($students)) <input type="checkbox" id="idStudentAll" name="idStudentAll" value="selectall">
@else <input type="checkbox" id="idStudentAll" name="idStudentAll" value="selectall" style="opacity:0">
@endif
@endif
<label for="idStudentAll" style="color:green"> Select All </label><br>
<select name="idStudent[]" multiple="multiple" id="idStudent">
@if(isset($students))
@if(count($students))
@foreach($students as $key => $value)
<option value="{{$value}}" <?php if(in_array($value, $idStudent)) echo 'selected';?>>{{$key}}</option>
@endforeach
@endif
@endif
</select>
@if ($errors->has('idStudent'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idStudent') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label for="classname" style="padding-bottom: 26px;"><strong>Entry Type</strong></label>
{!! Form::select('type',[''=>'--Select--','grade'=>'Enter Grade','marks'=>'Enter Marks'],['class' => 'form-control show-tick ms select2','required'=>'required']) !!}
@if ($errors->has('type'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idClass') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix" style="margin-left:10px;">
{!! Form::submit('Generate Data',['class' => 'btn btn-raised btn-primary btn-round waves-effect' ,'style'=>'width: 150px; max-width: 254px;']) !!}
</div>
{!! Form::close() !!}
</div>
</div>
<div class="card">
<div class="header">
<h2><strong>Results</strong></h2>
</div>
{!! Form::open(['url' => 'school/marks/add-marks','class'=>'form-horizontal','method'=>'post']) !!}
@if(isset($type))
<input type="hidden" value="{{$type->idType}}" name="idType"/>
<input type="hidden" value="{{$type->idExam}}" name="idExam"/>
@endif
<div class="body table-responsive">
@php $sub = 0;@endphp
@if(isset($totalStudents))
<table class="table table-bordered" id="manual-marks">
<thead>
<tr>
<th>EC No.</th>
<th>Name</th>
@if(isset($subjects))
@foreach($subjects as $key => $value)
@if(in_array($value, $idSubject))
@php $sub++;@endphp
<th>{{$key}}</th>
<th></th>
<th></th>
<th></th>
<th></th>
@endif
@endforeach
@endif
</tr>
</thead>
<tbody>
@foreach($totalStudents as $student)
@if(in_array($student->idStudent, $idStudent))
<tr data-id="{{$student->ecNo}}">
<td>{{$student->ecNo}}</td>
<td>{{$student->firstName}} {{$student->lastName}}</td>
@if(isset($subjects))
@foreach($subjects as $key => $value)
@if(in_array($value, $idSubject))
@php $dataEntry = \App\ExamSheet::where('idStudent',$student->idStudent)->where('idSubject',$value)->where('idExam',$type->idType)->first(); @endphp
@php
$totalMarks = null;
if(isset($marks[$value]))
$totalMarks = $marks[$value];
@endphp
@if($idResult == "marks")
<td style="max-width:100px;">
<input class="form-control" value="{{$student->idStudent}}" data-id ="{{$student->ecNo}}_{{$value}}" id="students_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][students]" type="hidden"/>
@if($totalMarks != null)
<input class="form-control" value="{{$totalMarks['theory']}}" data-id ="{{$student->ecNo}}_{{$value}}" id="marks_theory_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][marks_theory]" type="hidden"/>
<input class="form-control" value="{{$totalMarks['pratical']}}" data-id ="{{$student->ecNo}}_{{$value}}" id="marks_pratical_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][marks_pratical]" type="hidden"/>
@endif
<input class="form-control" placeholder="Theory" data-id ="{{$student->ecNo}}_{{$value}}" id="theory_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][theory]" type="text" style="width:80px;" @if(isset($dataEntry->marks)) value="{{$dataEntry->marks}}" @endif></td>
@if($totalMarks['pratical'] == "nil")
<td style="max-width:100px;"><input class="form-control" placeholder="Pratical" data-id ="{{$student->ecNo}}_{{$value}}" id="pratical_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][pratical]" type="text" style="width:80px;" readonly></td>
@else
<td style="max-width:100px;"><input class="form-control" placeholder="Pratical" data-id ="{{$student->ecNo}}_{{$value}}" id="pratical_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][pratical]" type="text" style="width:80px;" @if(isset($dataEntry->pratical)) value="{{$dataEntry->pratical}}" @endif <?php if($totalMarks != null) { if($totalMarks['pratical'] == null) echo 'readonly';} else echo 'readonly';?> ></td>
@endif
<td style="max-width:100px;"><input class="form-control" placeholder="Total" id="total_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][total]" type="text" style="width:80px;" @if(isset($dataEntry->total)) value="{{$dataEntry->total}}" @endif readonly></td>
<td style="max-width:100px;">
<select class="form-control show-tick ms select2" style="width:80px;" id="grade_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][grade]">
<?php
echo' <option value=""disabled>-Grade-</option>';
foreach(json_decode($type->grades,true) as $grade){
if(isset($dataEntry->grade)) {
if($dataEntry->grade == $grade['name'])
echo' <option value="'.$grade['name'].'" selected>'.$grade['name'].'</option>';
else
echo' <option value="'.$grade['name'].'">'.$grade['name'].'</option>';
}else
echo' <option value="'.$grade['name'].'">'.$grade['name'].'</option>';
}
?>
</select>
</td>
<td style="max-width:80px;"><select class="form-control show-tick ms select2" name="data[{{$student->ecNo}}][{{$value}}][status]"><option value="P" @php if(isset($dataEntry->attendance)) { if($dataEntry->attendance == "P") echo 'selected'; }@endphp>P</option><option value="A" @php if(isset($dataEntry->attendance)) {if($dataEntry->attendance == "A") echo 'selected'; } @endphp >A</option></select></td>
@else
<td style="max-width:100px;">
<input class="form-control" value="{{$student->idStudent}}" data-id ="{{$student->ecNo}}_{{$value}}" id="students_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][students]" type="hidden"/>
@if($totalMarks != null)
<input class="form-control" value="{{$totalMarks['theory']}}" data-id ="{{$student->ecNo}}_{{$value}}" id="marks_theory_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][marks_theory]" type="hidden"/>
<input class="form-control" value="{{$totalMarks['pratical']}}" data-id ="{{$student->ecNo}}_{{$value}}" id="marks_pratical_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][marks_pratical]" type="hidden"/>
@endif
<input class="form-control" placeholder="Theory" name="data[{{$student->ecNo}}][{{$value}}][theory]" type="text" style="width:80px;" readonly></td>
<td style="max-width:100px;"><input class="form-control" placeholder="Pratical" name="data[{{$student->ecNo}}][{{$value}}][pratical]" type="text" style="width:80px;" readonly></td>
<td style="max-width:100px;"><input class="form-control" placeholder="Total" name="data[{{$student->ecNo}}][{{$value}}][total]" type="text" style="width:80px;" readonly></td>
<td style="max-width:100px;">
<select class="form-control show-tick ms select2" style="width:80px;" id="grade_{{$student->ecNo}}_{{$value}}" name="data[{{$student->ecNo}}][{{$value}}][grade]">
<?php
echo' <option value=""disabled>-Grade-</option>';
foreach(json_decode($type->grades,true) as $grade){
if(isset($dataEntry->grade)) {
if($dataEntry->grade == $grade['name'])
echo' <option value="'.$grade['name'].'" selected>'.$grade['name'].'</option>';
else
echo' <option value="'.$grade['name'].'">'.$grade['name'].'</option>';
}else
echo' <option value="'.$grade['name'].'">'.$grade['name'].'</option>';
}
?>
</select>
</td>
<td style="max-width:80px;"><select class="form-control show-tick ms select2" name="data[{{$student->ecNo}}][{{$value}}][status]"><option value="present">P</option><option value="absent">A</option></select></td>
@endif
@endif
@endforeach
@endif
</tr>
@endif
@endforeach
</tbody>
</table>
@endif
</div>
@if(isset($totalStudents))
<div class="row clearfix" style="margin-left:10px;">
{!! Form::submit('Save Data',['class' => 'btn btn-raised btn-primary btn-round waves-effect' ,'style'=>'width: 150px; max-width: 254px;']) !!}
</div>
@endif
{!! Form::close() !!}
</div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
console.log($.fn.dataTable.isDataTable( '#manual-marks' ));
if ( $.fn.dataTable.isDataTable( '#manual-marks' ) ) {
table = $('#manual-marks').DataTable();
table.destroy();
table = $('#manual-marks').DataTable({
scrollX: true,
paging:false,
fixedColumns: {
left: 2,
}
});
}else{
@if($sub > 2)
table = $('#manual-marks').DataTable({
scrollX: true,
paging:false,
fixedColumns: {
left: 2,
}
});
@else
$('#manual-marks').DataTable();
@endif
}
$('#idSection').multiselect({
listWidth: 200,
cssEven: false,
cssOdd: false,
});
$('#idSubject').multiselect({
listWidth: 200,
cssEven: false,
cssOdd: false,
});
$('#idStudent').multiselect({
listWidth: 200,
cssEven: false,
cssOdd: false,
});
$('select[name="idClass"]').on('change', function() {
var classID = $(this).val();
$.ajax({
url: "{{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: "{{url('/school/class') }}"+'/' +classID + "/subjects",
type: "GET",
dataType: "json",
success:function(data) {
$('#idSubjectAll').prop('checked', false);
$('#idSubject_checklist ul').empty();
$.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>');
});
}
});
});
$(document).on('click', '#idSection_checklist', function(){
var sectionIds = [];
$("input:checkbox[name='idSection[]']:checked").each(function () {
sectionIds.push($(this).val());
});
if (sectionIds.length > 0) {
$.ajax({
url: "{{url('/school/sec') }}"+'/' +sectionIds + "/students",
type: "GET",
dataType: "json",
success:function(data) {
$('#idStudentAll').prop('checked', false);
$('#idStudent_checklist ul').empty();
$('#idStudentAll').css('opacity', 0);
$.each(data, function(key, value) {
$('#idStudentAll').css('opacity', 1);
$('#idStudent_checklist ul').append('<li tabindex="0" class=""><input type="checkbox" value="'+key+'" name="idStudent[]" id="idSubject_'+key+'"><label for="idStudent_'+key+'" class="leaveRoomForCheckbox">'+value+'</label></li>');
});
}
});
}else{
$('#idStudentAll').prop('checked', false);
$('#idStudentAll').css('opacity', 0);
$('#idStudent_checklist ul').empty();
}
});
$('#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);
});
var sectionIds = [];
$("#idSection_checklist ul li input[type=checkbox]").each(function(e) {
sectionIds.push($(this).val());
});
$.ajax({
url: "{{url('/school/sec') }}"+'/' +sectionIds + "/students",
type: "GET",
dataType: "json",
success:function(data) {
$('#idStudentAll').css('opacity', 0);
$('#idStudentAll').prop('checked', false);
$('#idStudent_checklist ul').empty();
$.each(data, function(key, value) {
$('#idStudentAll').css('opacity', 1);
$('#idStudent_checklist ul').append('<li tabindex="0" class=""><input type="checkbox" value="'+key+'" name="idStudent[]" id="idSubject_'+key+'"><label for="idStudent_'+key+'" class="leaveRoomForCheckbox">'+value+'</label></li>');
});
}
});
}else{
$('#idStudent_checklist ul').empty();
$('#idStudentAll').prop('checked', false);
$("#idSection_checklist").removeClass('checklistHighlighted');
$("#idSection_checklist ul").children().removeClass('checked');
$("#idSection_checklist ul li input[type=checkbox]").each(function(e) {
$(this).prop('checked', false);
});
$('#idStudentAll').css('opacity', 0);
}
});
$('#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);
});
}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);
});
}
});
$('#idStudentAll').change(function() {
if(this.checked) {
$("#idStudent_checklist").addClass('checklistHighlighted');
$("#idStudent_checklist ul").children().addClass('checked');
$("#idStudent_checklist ul li input[type=checkbox]").each(function(e) {
$(this).prop('checked', true);
});
}else{
$("#idStudent_checklist").removeClass('checklistHighlighted');
$("#idStudent_checklist ul").children().removeClass('checked');
$("#idStudent_checklist ul li input[type=checkbox]").each(function(e) {
$(this).prop('checked', false);
});
}
});
$("button[data-id=idSection]").hide();
$("button[data-id=idSubject]").hide();
$("button[data-id=idStudent]").hide();
$("#idSection_actionButtons").hide();
$("#idSubject_actionButtons").hide();
$("#idStudent_actionButtons").hide();
});
</script>
@if(isset($type))
<script>
(function() {
"use strict";
$("#manual-marks").on("change", "input", function() {
var row = $(this).closest("tr");
var id = $(this).data('id');
var theory = 0;
if(row.find("#marks_theory_"+id).val() != null)
theory = parseFloat(row.find("#marks_theory_"+id).val());
var extra =0;
if(row.find("#marks_pratical_"+id).val() != null)
extra = parseFloat(row.find("#marks_pratical_"+id).val());
console.log(id);
var marks = parseFloat(row.find("#theory_"+id).val());
if(theory < marks){
alert("Marks are greater than allocated marks.");
row.find("#theory_"+id).val("");
row.find("#total_"+id).val("");
}else{
var pratical = parseFloat(row.find("#pratical_"+id).val());
if(isNaN(pratical))
{
pratical = 0;
var total = marks + pratical;
row.find("#total_"+id).val(isNaN(total) ? "" : total);
}
else{
if(extra < pratical){
alert("Marks are greater than allocated marks.");
row.find("#pratical_"+id).val("");
ow.find("#total_"+id).val(marks);
}else{
var total = marks + pratical;
row.find("#total_"+id).val(isNaN(total) ? "" : total);
}
}
}
});
})();
</script>
@endif
@stop
Copyright © 2021 -