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">
{!! Form::open(['method' => 'GET', 'action' => ['School\Hostel\AttendanceController@create'], 'class' => 'form-horizontal']) !!}
<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">Floor </label>
</div>
<div class="col-sm-2">
<div class="form-group">
{!! Form::select('idFloor',$floor,null,['class' => 'form-control show-tick ms select2','required'=>'required']) !!}
@if ($errors->has('idFloor'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idFloor') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-1 form-control-label">
<?php if(isset($_GET['idRoom'])){
$sec = $_GET['idRoom'];
echo '<input type="hidden" value='.$sec.' id="testsec">'; }?>
<label for="classname">Room</label>
</div>
<div class="col-sm-2">
<div class="form-group">
<select id='idRoom' name='idRoom' class="form-control show-tick ms" required="required"></select>
@if ($errors->has('idRoom'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idRoom') }}</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;">
{!! Form::open(['url' => 'school/hostelattendance', 'class' => 'form-horizontal']) !!}
<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');
?>
@if($tdate->dayOfWeek == '0')
<td> <span style="color:green; font-weight: bold;">{{$i}} <br>
SUNDAY</span></td>
@else<td>
{{$i}}
<br> <input type="checkbox" id="dayselectall{{$i}}" onclick="selectAllStudentOfDay({{$i}})">
</td>
@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');
$a_exist = DB::table('hostel_attendance')->where('Enrollment_Number','=',$var->ecNo)
->where('idSchool','=',$var->idSchool)
->whereDate('date','=',$jdate)
->where('idType','=','M')
->first();
?>
<td>
@if($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
$tp = DB::table('hostel_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="idFloor"]').on('change', function() {
var roomID = $(this).val();
if(roomID) {
$.ajax({
url: "{{url('/school/floor') }}"+'/' +roomID + "/rooms",
type: "GET",
dataType: "json",
success:function(data) {
$('#idRoom').empty();
$('#idRoom').append('<option value="">--Select--</option>');
$.each(data, function(key, value) {
$('#idRoom').append('<option value="'+key+'">'+value+'</option>');
});
}
});
}else{
$('select[name="idRoom"]').empty();
}
});
var cur_room = $('select[name="idFloor"]').val();
if (cur_room) {
$.ajax({
url: "{{url('/school/floor') }}"+'/' +cur_room + "/rooms",
type: "GET",
dataType: "json",
success:function(data) {
$('#idRoom').empty();
$('#idRoom').append('<option value="">--Select--</option>');
$.each(data, function(key, value) {
$('#idRoom').append('<option value="'+key+'">'+value+'</option>');
});
}
});
}
jQuery(document).ready(function() {
setTimeout(function() {
var j = $('#testsec').val();
console.log(j);
$('select[name="idRoom"] option[value="' + j + '"]').attr("selected","selected");
}, 1000);
});
});
</script>
@stop
Copyright © 2021 -