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\EmpAttendanceController@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']) !!}
@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">Department </label>
</div>
<div class="col-sm-2">
<div class="form-group">
{!! Form::select('idDepartment',$departments,null,['class' => 'form-control show-tick ms']) !!}
@if ($errors->has('idDepartment'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idDepartment') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-1 form-control-label">
<label for="classname">Designation</label>
<?php if(isset($_GET['idDesignation'])){
$sec = $_GET['idDesignation'];
echo '<input type="hidden" value='.$sec.' id="testsec">'; }?>
</div>
<div class="col-sm-2">
<div class="form-group">
<select id='idDesignation' name='idDesignation' class="form-control show-tick ms"></select>
@if ($errors->has('idDesignation'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idDesignation') }}</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/empattendance', 'class' => 'form-horizontal']) !!}
<div style="float:right;">
{!! Form::submit('SAVE',['class' => 'btn btn-raised btn-success btn-round waves-effect']) !!}
<!--<button class="btn btn-raised btn-danger btn-round waves-effect js-sweetalert" data-monthid="{{$month->idMonth}}" data-sectionid ='{{$sec}}' data-type="confirm">SEND SMS TO ABSENT STUDENTS</button>-->
<!--<a href="{{url('/school/smstoabsent/'.$month->idMonth.'/'.$sec.'/')}}" class="js-sweetalert btn btn-raised btn-danger btn-round waves-effect">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">
<thead>
<tr>
<?php $noOfdays = $month->noOfDays;
$now = Carbon\Carbon::now();
$m = $now->month;
$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)
->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>
@else
<td>{{$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>
@else
<td>{{$i}}</td>
@endif
@endif
@endfor
<th>TP</th>
<th>TA</th>
</tr>
</thead>
<tbody>
@if(count($employees)>0)
@foreach($employees as $var)
<tr>
<td>{{$var->enrollmentNo}}</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)
->whereDate('fromDate', '<=', $jdate)
->whereDate('toDate', '>=', $jdate)
->first();
$intime_exist = \App\EmpAttendance::where('Enrollment_Number','=',$var->enrollmentNo)
->where('idSchool','=',$var->idSchool)
->whereDate('date','=',$jdate)
->where('status','=','IN')
->first();
if($intime_exist !=null){
$intime = $intime_exist->TimeStamp->format('H:i');
}
$outtime_exist = \App\EmpAttendance::where('Enrollment_Number','=',$var->enrollmentNo)
->where('idSchool','=',$var->idSchool)
->whereDate('date','=',$jdate)
->where('status','=','OUT')
->first();
if($outtime_exist !=null){
$outtime = $outtime_exist->TimeStamp->format('H:i');
}
?>
<td class="demo-masked-input" width='200px;'>
@if($tdate->dayOfWeek == '0')
<span></span>
@elseif($v!=null)
<span></span>
@elseif($intime_exist !=null && $outtime_exist!=null)
<input type="text" name='employees[{{$var->enrollmentNo}}][{{$dt}}][inTime]' value="{{$intime}}">
<input type="text" name='employees[{{$var->enrollmentNo}}][{{$dt}}][outTime]' value="{{$outtime}}">
@else
<!--<input type="checkbox" name='employees[{{$dt}}][]' value="{{$var->enrollmentNo}}">-->
<div class="form-group"> <input type="text" name='employees[{{$var->enrollmentNo}}][{{$dt}}][inTime]' class="time24" placeholder="In Time"></div>
<br><div class="form-group"><input type="text" name='employees[{{$var->enrollmentNo}}][{{$dt}}][outTime]' class="time24" placeholder="Out Time"></div>
@endif
</td>
@endfor
<td>
<?php $tp = \App\EmpAttendance::where('idSchool', '=', Auth::guard('school')->user()->idSchool)
->where('idMonth','=',$month->idMonth)
->where('Enrollment_Number','=',$var->enrollmentNo)
->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>
$(document).ready(function() {
$('select[name="idDepartment"]').on('change', function() {
var deptID = $(this).val();
if(deptID) {
$.ajax({
url: "{{url('/school/departments') }}"+'/' +deptID + "/designations",
type: "GET",
dataType: "json",
success:function(data) {
$('#idDesignation').empty();
$('#idDesignation').append('<option value="">--Select--</option>');
$.each(data, function(key, value) {
$('#idDesignation').append('<option value="'+key+'">'+value+'</option>');
});
}
});
}else{
$('select[name="idDesignation"]').empty();
}
});
var cur_dept = $('select[name="idDepartment"]').val();
if (cur_dept) {
$.ajax({
url: "{{url('/school/departments') }}"+'/' +cur_dept + "/designations",
type: "GET",
dataType: "json",
success:function(data) {
$('#idDesignation').empty();
$('#idDesignation').append('<option value="">--Select--</option>');
$.each(data, function(key, value) {
$('#idDesignation').append('<option value="'+key+'">'+value+'</option>');
});
}
});
}
jQuery(document).ready(function() {
setTimeout(function() {
var j = $('#testsec').val();
console.log(j);
$('select[name="idDesignation"] option[value="' + j + '"]').attr("selected","selected");
}, 1000);
});
});
$(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 employees!",
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 -