IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Manual</strong> Attendance</h2>
</div>
<div class="body">
@if(isset($bus))
{!! Form::open(['method' => 'GET', 'action' => ['School\BusAttendanceController@create'], 'class' => 'form-horizontal']) !!}
@else
{!! Form::open(['method' => 'GET', 'action' => ['School\AttendanceController@create'], 'class' => 'form-horizontal']) !!}
@endif
<div class="row clearfix">
<div class="col-sm-1 form-control-label required">
<label for="classname">Month</label>
</div>
<div class="col-sm-2">
<div class="form-group">
{!! Form::select('idMonth',getMonths(),$current_month->idMonth,['class' => 'form-control show-tick ms select2']) !!}
@if ($errors->has('idMonth'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idMonth') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-1 form-control-label required">
<label for="classname">Class </label>
</div>
<div class="col-sm-2">
<div class="form-group">
{!! Form::select('idClass',$classes,null,['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-1 form-control-label">
<label for="classname">Section</label>
<?php if(isset($_GET['idSection'])){
$sec = $_GET['idSection'];
echo '<input type="hidden" value='.$sec.' id="testsec">'; }?>
</div>
<div class="col-sm-2">
<div class="form-group">
<select id='idSection' name='idSection' class="form-control show-tick ms" required="required"></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-2">
{!! Form::submit('SHOW',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
</div>
{!! Form::close() !!}
</div>
</div>
@if($month)
<div class="body table-responsive" style="padding-top: 0px;">
@if(isset($bus))
{!! Form::open(['url' => 'school/bus-attendance', 'class' => 'form-horizontal']) !!}
@else
{!! Form::open(['url' => 'school/attendance', 'class' => 'form-horizontal']) !!}
@endif
<div style="float:right;">
{!! Form::submit('SAVE',['class' => 'btn btn-raised btn-success btn-round waves-effect']) !!}
<a class="btn btn-raised btn-danger btn-round waves-effect js-sweetalert" href="{{url('/school/smstopresent/'.$month->idMonth.'/'.$sec)}}">SEND SMS TO PRESENT STUDENTS</a>
<a class="btn btn-raised btn-danger btn-round waves-effect js-sweetalert" href="{{url('/school/smstoabsent/'.$month->idMonth.'/'.$sec)}}">SEND SMS TO ABSENT STUDENTS</a>
</div>
<input type="hidden" name='idType' value="M">
<input type="hidden" name='idMonth' value="{{$month->idMonth}}">
<table class="table table-bordered" id="manual-attendance">
<thead>
<tr>
<?php $noOfdays = $month->noOfDays;
$now = Carbon\Carbon::now();
$m = $month->idMonth;
$y = $now->year;
?>
<th>EC No.</th>
<th>Name</th>
@for($i=1; $i<=$noOfdays;$i++)
<?php $dt = $i.'-'.$m.'-'.$y;
$tdate = Carbon\Carbon::parse($dt);
$jdate = $tdate->format('Y-m-d');
$v = \App\Holiday::where('idSchool','=',Auth::guard('school')->user()->idSchool)
->whereNull('idClass')
->whereDate('fromDate', '<=', $jdate)
->whereDate('toDate', '>=', $jdate)
->first();
$indiv = \App\Holiday::where('idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('idClass',$idClass)
->whereDate('fromDate', '<=', $jdate)
->whereDate('toDate', '>=', $jdate)
->first();
?>
@if($school->idCountry == 1)
@if($tdate->dayOfWeek == '0')
<td> <span style="color:green; font-weight: bold;">{{$i}} <br>
SUNDAY</span></td>
@elseif($v!=null)
<td><span style="color:green; font-weight: bold;">{{$i}} <br>
{{$v->holidayName}}</span></td>
@elseif($indiv!=null)
<td><span style="color:green; font-weight: bold;">{{$i}} <br>
{{$indiv->holidayName}}</span></td>
@else
<td>
{{$i}}
<br> <input type="checkbox" id="dayselectall{{$i}}" onclick="selectAllStudentOfDay({{$i}})">
</td>
@endif
@else
@if($tdate->dayOfWeek == '5')
<td> <span style="color:green; font-weight: bold;">{{$i}} <br>
FRIDAY</span></td>
@elseif($v!=null)
<td><span style="color:green; font-weight: bold;">{{$i}} <br>
{{$v->holidayName}}</span></td>
@elseif($indiv!=null)
<td><span style="color:green; font-weight: bold;">{{$i}} <br>
{{$indiv->holidayName}}</span></td>
@else
<td>
{{$i}}
<br> <input type="checkbox" id="dayselectall{{$i}}" onclick="selectAllStudentOfDay({{$i}})">
</td>
@endif
@endif
@endfor
<th>TP</th>
<th>TA</th>
</tr>
</thead>
<tbody>
@if(count($students)>0)
@foreach($students as $var)
<tr>
<td>{{$var->ecNo}}</td>
<td>{{$var->firstName}} {{$var->middleName}} {{$var->lastName}}</td>
@for($i=1; $i<=$noOfdays;$i++)
<?php $dt = $i.'-'.$m.'-'.$y;
$tdate = Carbon\Carbon::parse($dt);
$jdate = $tdate->format('Y-m-d');
$v = \App\Holiday::where('idSchool','=',$var->idSchool)
->whereNull('idClass')
->whereDate('fromDate', '<=', $jdate)
->whereDate('toDate', '>=', $jdate)
->first();
$indiv = \App\Holiday::where('idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('idClass',$idClass)
->whereDate('fromDate', '<=', $jdate)
->whereDate('toDate', '>=', $jdate)
->first();
if(isset($bus))
$a_exist = \App\BusAttendance::where('enrollmentNo','=',$var->ecNo)
->where('idSchool','=',$var->idSchool)
->whereDate('created_on','=',$jdate)
->where('isAutomatic','=','M')
->first();
else
$a_exist = \App\Attendance::where('Enrollment_Number','=',$var->ecNo)
->where('idSchool','=',$var->idSchool)
->whereDate('date','=',$jdate)
->where('idType','=','M')
->first();
?>
<td>
@if($tdate->dayOfWeek == '0')
<span></span>
@elseif($v!=null)
<span></span>
@elseif($indiv!=null)
<span></span>
@elseif($a_exist !=null)
<input type="hidden" name="students[{{$dt}}][{{$var->ecNo}}][ecNo]" value="{{$var->ecNo}}">
<input type="checkbox" name='students[{{$dt}}][{{$var->ecNo}}][present]' value="{{$var->ecNo}}" checked="checked">
@else
<input type="hidden" name="students[{{$dt}}][{{$var->ecNo}}][ecNo]" value="{{$var->ecNo}}">
<input type="checkbox" name='students[{{$dt}}][{{$var->ecNo}}][present]' value="{{$var->ecNo}}" class="selectchk{{$i}}">
@endif
</td>
@endfor
<td>
<?php
if(isset($bus))
$tp = \App\BusAttendance::where('idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('create_month','=',$month->idMonth)
->where('enrollmentNo','=',$var->ecNo)
->where('isAutomatic','=','M')
->get();
else
$tp = \App\Attendance::where('idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('idMonth','=',$month->idMonth)
->where('Enrollment_Number','=',$var->ecNo)
->where('idType','=','M')
->get();
$total_present = $tp->count()
?>
{{$total_present }}
</td>
<td>{{$ta = $month->noOfDays - $total_present}}</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
{!! Form::close() !!}
@endif
</div>
</div>
</div>
@stop
@section('script')
<script>
$('#manual-attendance').DataTable({
// scrollY: "500px",
scrollX: true,
// scrollCollapse: true,
paging:false,
fixedColumns: {
left: 2,
// right: 1
}
});
function selectAllStudentOfDay(key) {
//alert(key);
var select_all = document.getElementById("dayselectall" + key);
var checkboxes = document.getElementsByClassName("selectchk" + key);
select_all.addEventListener("change", function(e){
for (i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = select_all.checked;
}
});
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].addEventListener('change', function(e){ //".checkbox" change
//uncheck "select all", if one of the listed checkbox item is unchecked
if (this.checked == false){
select_all.checked = false;
}
//check "select all" if all checkbox items are checked
if (document.querySelectorAll('.selectchk:checked').length == checkboxes.length){
select_all.checked = true;
}
});
}
}
$(document).ready(function() {
$('select[name="idClass"]').on('change', function() {
var classID = $(this).val();
if(classID) {
$.ajax({
url: "{{url('/school/class') }}"+'/' +classID + "/sections",
type: "GET",
dataType: "json",
success:function(data) {
$('#idSection').empty();
$('#idSection').append('<option value="">--Select--</option>');
$.each(data, function(key, value) {
$('#idSection').append('<option value="'+key+'">'+value+'</option>');
});
}
});
}else{
$('select[name="idSection"]').empty();
}
});
var cur_class = $('select[name="idClass"]').val();
if (cur_class) {
$.ajax({
url: "{{url('/school/class') }}"+'/' +cur_class + "/sections",
type: "GET",
dataType: "json",
success:function(data) {
$('#idSection').empty();
$('#idSection').append('<option value="">--Select--</option>');
$.each(data, function(key, value) {
$('#idSection').append('<option value="'+key+'">'+value+'</option>');
});
}
});
}
jQuery(document).ready(function() {
setTimeout(function() {
var j = $('#testsec').val();
console.log(j);
$('select[name="idSection"] option[value="' + j + '"]').attr("selected","selected");
}, 1000);
});
// $('select[name="idSection"]').on('change', function() {
// var monthID = $( "#idMonth option:selected" ).val();
// var sectionID = $( "#idSection option:selected" ).val();
// if(sectionID) {
// $.ajax({
// url: "{{url('/school/section') }}"+'/' +monthID+'/'+sectionID + "/attendance",
// type: "GET",
// dataType: "json",
// success:function(data) {
// $('#attendanceTable').empty();
// $('#attendanceTable').append('<table class="table"><thead><th>EC No.</th><th>Name</th></thead><tbody id="tbody"></tbody></table>');
// $.each(data, function(key, value) {
// $('#tbody').append('<tr><td>'+value['ecNo']+'</td><td>'+value['firstName']+' '+value['lastName']+'</td>\n\
// <td></td></tr>');
// });
// }
// });
// }
// });
});
//$(document).on('click', '.js-sweetalert', function (e) {
// $.ajaxSetup({
// headers: {
// 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
// }
// });
// e.preventDefault();
// var monthid = $(this).data('monthid');
// var secid = $(this).data('sectionid');
// swal({
// title: "Are you sure?",
// text: "Are You sure you want to send message to all absent students!",
// type: "warning",
// showCancelButton: true,
// confirmButtonColor: "#DD6B55",
// confirmButtonText: "Yes, Send it!",
// closeOnConfirm: true
// },
// function() {
// // console.log('here');
// $.ajax({
// type: "GET",
// url: "{{url('/school/smstoabsent/')}}" +"/"+monthid+'/'+secid,
// data: {monthid:monthid,secid:secid}
//
// })
// .done(function(data) {
// swal({
// title: "Success",
// text: "SMS has been sent successfully",
// type: "success"
// },function() {
// location.reload();
// });
// })
// .error(function(data) {
// swal("Oops", "We couldn't connect to the server!", "error");
// });
// return false;
// });
//});
</script>
@stop
Copyright © 2021 -