# Attendance
resources / views / Attendance /
# Index.Blade
resources / views / Attendance / index.blade.php
@extends('layouts.master')
@section('page-title') Attendance @endsection
@section('content')
<div class="mb-2">
<nav aria-label="breadcrumb" class="bg-white p-2 shadow-sm rounded">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item active" aria-current="page">Attendance /</li>
</ol>
</nav>
</div>
<div class="card border-0 shadow-sm rounded">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<h4 class="fw-bold text-black-50 mb-0">
<i class="fa-solid fa-layer-group me-1"></i>Attendance Lists
</h4>
<div class="">
@can('Create Attendance')
<a href="{{ route('attendance.create') }}" class="btn btn-outline-primary">
<i class="fa-solid fa-square-plus"></i>
</a>
@endcan
<a href="{{ route('attendance.pdf') }}"
target="_blank"
class="btn btn-primary ms-3">
<i class="fa-solid fa-file-download"></i>
</a>
</div>
</div>
<hr>
<table class="table table-hover w-100" id="employee-table">
<thead class="bg-primary text-white">
<tr>
<th class="no-sort no-search">Control</th>
<th class="text-nowrap">Employee Name</th>
<th>Date</th>
<th>Check In Time</th>
<th>Check Out Time</th>
<th class="no-sort no-search">Action</th>
<th>Date</th>
</tr>
</thead>
</table>
</div>
</div>
@endsection
@section('js')
<script>
$(document).ready(function (){
let table = $('#employee-table').DataTable({
//for pdf start
dom: 'Bfrtip',
buttons: [
// 'copy', 'csv', 'excel', 'pdf', 'print',
{
extend: 'pdfHtml5',
text: '<i class="fa-solid fa-file-pdf me-1"></i> PDF',
orientation: 'portrait',
pageSize: 'A4',
title: 'Attendance Record',
className: 'bg-primary text-white border-0 shadow-sm rounded',
exportOptions: {
columns : [1, 2, 3, 4]
},
customize: function (doc) {
//Remove the title created by datatTables
doc.content.splice(0,1);
var now = new Date();
var jsDate = now.getDate()+'-'+(now.getMonth()+1)+'-'+now.getFullYear();
var jsDateTime = now.getDate() + "/"
+ (now.getMonth()+1) + "/"
+ now.getFullYear() + " - "
+ now.getHours() + ":"
+ now.getMinutes() + ":"
+ now.getSeconds();
doc.pageMargins = [20,50,20,30];
doc.defaultStyle.fontSize = 8;
doc.styles.tableHeader.fontSize = 8;
doc.styles.tableBodyEven.alignment = 'center';
doc.styles.tableBodyOdd.alignment = 'center';
doc['header']=(function() {
return {
columns: [
{
alignment: 'left',
// italics: true,
text: 'Attendance',
fontSize: 14,
// margin: [10,0]
},
{
alignment: 'right',
fontSize: 10,
text: 'Report Time: ' + jsDateTime
}
],
margin: [20,20,20,10]
}
});
doc['footer']=(function(page, pages) {
return {
columns: [
{
alignment: 'left',
text: '',
},
{
alignment: 'right',
text: ['page ', { text: page.toString() }, ' of ', { text: pages.toString() }]
}
],
margin: [20,0,20,10]
}
});
var objLayout = {};
objLayout['hLineWidth'] = function(i) { return .5; };
objLayout['vLineWidth'] = function(i) { return .5; };
objLayout['hLineColor'] = function(i) { return '#aaa'; };
objLayout['vLineColor'] = function(i) { return '#aaa'; };
objLayout['paddingLeft'] = function(i) { return 4; };
objLayout['paddingRight'] = function(i) { return 4; };
doc.content[0].layout = objLayout;
doc.content[0].table.widths = ['30%', '10%', '30%', '30%']; // '25%' //100%/4 columns
}
},
{
extend: 'pageLength',
className: 'bg-primary text-white border-0 shadow-sm rounded ms-2',
},
{
text: '<i class="fa-solid fa-refresh"></i>',
className: 'bg-primary text-white border-0 shadow-sm rounded ms-2',
action: function (e, dt, node, config){
dt.ajax.reload(null, false);
}
}
],
lengthMenu: [
[10, 25, 50, 100, 300, 500],
['Show 10 rows', 'Show 25 rows', 'Show 50 rows', 'Show 100 rows', 'Show 300 rows', 'Show 500 rows']
],
// for pdf end
ajax: '{{ route('attendance.dataTable') }}',
columns: [
{ data: 'plus_icon', name: 'plus_icon' },
{ data: 'employee_name', name: 'employee_name' },
{ data: 'Indate', name: 'Indate' },
{ data: 'checkIn_time', name: 'checkIn_time' },
{ data: 'checkOut_time', name: 'checkOut_time' },
{ data: 'action', name: 'action' },
{ data: 'created_at', name: 'created_at' },
],
order: [[ 6, "desc"]],
columnDefs: [
{
"targets": [ 0 ],
"class": "control"
},
{
"targets": [6], // hidden can use
"visible": false
},
{
"targets": 'no-sort',
"orderable": false
},
{
"targets": 'no-search',
"searchable": false
},
{
"targets": 'hidden',
"visible": false
}
],
});
$(document).on('click','.delete-btn', function (e){
e.preventDefault();
let id = $(this).data('id');
let name = $(this).data('name');
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#f15858',
confirmButtonText: 'Delete'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
method: "DELETE",
url: `/checkin-checkout/attendance/${id}`,
}).done(function (res){
Swal.fire(
'Deleted!',
"<span class='fw-bold text-black'>"+ name +"</span>" + " has been deleted.",
'success'
);
table.ajax.reload();
});
}
})
});
});
</script>
@endsection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Demo

# Create.Blade
resources / views / Attendance / create.blade.php
@extends('layouts.master')
@section('page-title') Attendance @endsection
@section('content')
<div class="mb-2">
<nav aria-label="breadcrumb" class="bg-white p-2 shadow-sm rounded">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item">
<a href="{{ route('department.index') }}" class="text-decoration-none">Attendance</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Create New Attendance</li>
</ol>
</nav>
</div>
<div class="card border-0 shadow-sm rounded">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<h4 class="fw-bold text-black-50 mb-0">
<i class="fa-solid fa-square-plus me-1"></i>Create New Attendance
</h4>
<a href="{{ route('attendance.index') }}" class="btn btn-outline-primary">
<i class="fa-solid fa-list"></i>
</a>
</div>
<hr>
<form action="{{ route('attendance.store') }}"
method="post" id="create-department"
class="row justify-content-center py-2">
@csrf
<div class="col-12 col-md-8">
@if(session()->get('Fail'))
<div class="text-center alert alert-danger">
<small class="text-danger">{{ session()->get('Fail') }}</small>
</div>
@endif
<div class="mb-3">
<select class="form-select form-select-lg"
id="employee_name_select"
data-placeholder="Choose Employee's Name"
name="user">
<option></option>
@forelse($employees as $e)
<option value="{{ $e->id }}"
@if( old('user') == $e->id) selected @endif>
{{ $e->name }} ( {{ $e->employee_id }} )
</option>
@empty
@endforelse
</select>
</div>
<div class="form-floating mb-3">
<input type="date" class="form-control"
id="date" name="date" placeholder="date">
<label for="date">Date</label>
</div>
<div class="form-floating mb-3">
<input type="text" class="form-control timePicker"
id="checkIn" name="checkIn"
value="{{ old('checkIn') }}"
placeholder="title">
<label for="checkIn">CheckIn Time</label>
</div>
<div class="form-floating mb-3">
<input type="text" class="form-control timePicker"
id="checkOut" name="checkOut"
value="{{ old('checkOut') }}"
placeholder="title">
<label for="checkOut">checkOut Time</label>
</div>
</div>
<div class="col-12 col-md-6 my-3">
<button class="btn btn-primary w-100">Save Department</button>
</div>
</form>
</div>
</div>
@endsection
@section('js')
{!! JsValidator::formRequest('App\Http\Requests\StoreCheckInCheckOutRequest','#create-department') !!}
<script>
$( '#employee_name_select' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
allowClear: true
} );
$('#date').daterangepicker({
"singleDatePicker": true,
"showDropdowns": true,
"autoApply": true,
"drops": "up",
"locale": {
"format": "YYYY-MM-DD",
}
});
$('.timePicker').daterangepicker({
"singleDatePicker": true,
"autoApply": true,
"timePicker": true,
"timePicker24Hour": true,
"timePickerSeconds": true,
"drops": "up",
"locale": {
"format": "HH:mm:ss",
}
}).on('show.daterangepicker', function (ev, picker){
$('.calendar-table').hide();
});
</script>
@endsection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Edit.Blade
resources / views / Attendance / edit.blade.php
@extends('layouts.master')
@section('page-title') Attendance @endsection
@section('content')
<div class="mb-2">
<nav aria-label="breadcrumb" class="bg-white p-2 shadow-sm rounded">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item">
<a href="{{ route('attendance.index') }}" class="text-decoration-none">Attendance</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Edit Attendance</li>
</ol>
</nav>
</div>
<div class="card border-0 shadow-sm rounded">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<h4 class="fw-bold text-black-50 mb-0">
<i class="fa-solid fa-square-plus me-1"></i>
Create New Attendance
</h4>
<a href="{{ route('attendance.index') }}" class="btn btn-outline-primary">
<i class="fa-solid fa-list"></i>
</a>
</div>
<hr>
<form action="{{ route('attendance.update', $checkInCheckOut->id) }}"
method="post" id="create-department"
class="row justify-content-center py-2">
@csrf
@method('put')
@if(session()->get('Fail'))
<div class="text-center alert alert-danger">
<small class="text-danger">{{ session()->get('Fail') }}</small>
</div>
@endif
<div class="col-12 col-md-8">
<div class="mb-3">
<select class="form-select form-select-lg"
id="employee_name_select"
data-placeholder="Choose Employee's Name"
name="user">
<option></option>
@forelse($employees as $e)
<option value="{{ $e->id }}"
@if( old('user', $checkInCheckOut->user_id) == $e->id) selected @endif>
{{ $e->name }} ( {{ $e->employee_id }} )
</option>
@empty
@endforelse
</select>
</div>
<div class="form-floating mb-3">
<input type="text" class="form-control"
id="date" name="date"
value="{{ \Carbon\Carbon::parse($checkInCheckOut->Indate)->format('Y-m-d') }}"
placeholder="date">
<label for="date">Date</label>
</div>
<div class="form-floating mb-3">
<input type="text" class="form-control timePicker"
id="checkIn" name="checkIn"
value="{{ old('checkIn', \Carbon\Carbon::parse($checkInCheckOut->checkIn_time)->format("H:i:s")) }}"
placeholder="title">
<label for="checkIn">CheckIn Time</label>
</div>
<div class="form-floating mb-3">
<input type="text" class="form-control timePicker"
id="checkOut" name="checkOut"
value="{{ old('checkOut', \Carbon\Carbon::parse($checkInCheckOut->checkOut_time)->format("H:i:s")) }}"
placeholder="title">
<label for="checkOut">checkOut Time</label>
</div>
</div>
<div class="col-12 col-md-6 my-3">
<button class="btn btn-primary w-100">Update Attendance</button>
</div>
</form>
</div>
</div>
@endsection
@section('js')
{!! JsValidator::formRequest('App\Http\Requests\StoreCheckInCheckOutRequest','#create-department') !!}
<script>
$( '#employee_name_select' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
placeholder: $( this ).data( 'placeholder' ),
allowClear: true
} );
$('#date').daterangepicker({
"singleDatePicker": true,
"showDropdowns": true,
"autoApply": true,
"drops": "up",
"value": 'hahah',
"locale": {
"format": "YYYY-MM-DD",
}
});
$('.timePicker').daterangepicker({
singleDatePicker: true,
autoApply: true,
timePicker: true,
timePicker24Hour: true,
timePickerSeconds: true,
drops: "up",
locale: {
"format": "HH:mm:ss",
}
}).on('show.daterangepicker', function (ev, picker){
picker.container.find('.calendar-table').hide();
});
</script>
@endsection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# User.Blade
resources / views / Attendance / user.blade.php
@extends('layouts.master')
@section('page-title') Attendance Scan @endsection
@section('content')
<div class="card border-0 shadow-sm rounded">
<div class="card-body text-center">
<img src="{{ asset('assets/Images/QR code_Monochromatic.png') }}" alt="" class="" style="width: 250px;">
<p class="text-black-50 mb-0 fw-bold">Please Scan Attendance QR.</p>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary my-3"
data-bs-toggle="modal"
data-bs-target="#scanner">
Scan
</button>
</div>
</div>
<div class="card border-0 shadow-sm rounded mt-3">
<div class="card-body">
<div class="row mb-3">
<div class="col-12 col-md-4 ">
<div class="">
@php
$monthArr = ["January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"];
@endphp
<label for="month" class="text-black-50">Choose Month</label>
<select name="month" id="month" class="form-select select-2 select-month">
@foreach($monthArr as $key=>$month)
@php
if ($key<9){
$number = "0".$key+1;
}else{
$number = $key+1;
}
@endphp
<option value="{{ $number }}" @if(now()->format('m') == $number) selected @endif>{{ $month }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-12 col-md-4 ">
<div class="">
<label for="year" class="text-black-50">Choose Year</label>
<select name="year" id="year" class="form-select select-2 select-year">
@for($i = 0; $i<5; $i++)
<option value="{{ now()->subYear($i)->format('Y') }}" @if(now()->format('Y') == now()->subYear($i)->format('Y') ) selected @endif>
{{ now()->subYear($i)->format('Y') }}
</option>
@endfor
</select>
</div>
</div>
<div class="col-12 col-md-4 align-items-end d-flex">
<button class="btn btn-primary w-100 filter-btn mt-3 mt-md-0">Filter Attendance Datas</button>
</div>
</div>
<div class="">
<h4 class="fw-bold text-primary mb-0">Attendance Over View</h4>
</div>
<hr>
<div class="overViewTableRender">
</div>
</div>
</div>
<div class="card border-0 shadow-sm rounded mt-3">
<div class="card-body">
<div class="">
<h4 class="fw-bold text-primary mb-0">Payroll Lists</h4>
</div>
<hr>
<div class="payRollTableRender">
{{-- Data Table Render Area --}}
</div>
</div>
</div>
{{-- Data Tabel Start --}}
<div class="card border-0 shadow-sm rounded mt-3">
<div class="card-body">
<div class="">
<h4 class="mb-0 text-primary fw-bold">Attendance Records</h4>
</div>
<hr>
<table class="table table-hover w-100" id="employee-table">
<thead class="bg-primary text-white">
<tr>
<th class="no-sort no-search">Control</th>
<th class="text-nowrap">Employee Name</th>
<th>Date</th>
<th>Check In Time</th>
<th>Check Out Time</th>
</tr>
</thead>
</table>
</div>
</div>
{{-- Data Tabel End --}}
<!-- Modal -->
<div class="modal fade" id="scanner"
tabindex="-1"
aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Scan Attendance QR code</h5>
<button type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close">
</button>
</div>
<div class="modal-body">
<video id="qr_ocde" class="w-100"></video>
</div>
<div class="modal-footer">
<button type="button"
class="btn btn-secondary"
data-bs-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
@endsection
@section('js')
<script>
$(document).ready(function (){
// =============== QR Scanner Start ===============
let videoElem = document.getElementById('qr_ocde');
let modeal = document.getElementById('scanner');
let qrScanner = new QrScanner(videoElem, function (result){
console.log(result);
if(result){
$(modeal).modal('hide');
qrScanner.stop();
$.ajax({
url: "{{ route('attendance.qrScanStore') }}",
type: 'POST',
data: {
hash_value: result,
}
}).done(function (res){
if (res.status == 'Success'){
Toast.fire({
icon: 'success',
title: res.message,
});
}else {
Toast.fire({
icon: 'warning',
title: res.message,
});
}
});
}
});
modeal.addEventListener('shown.bs.modal', function (event) {
qrScanner.start();
});
modeal.addEventListener('hidden.bs.modal', function (event) {
qrScanner.stop();
});
// =============== QR Scanner End ===============
// =============== DataTable Start ===============
let table = $('#employee-table').DataTable({
ajax: '{{ route('attendance.mydataTable') }}',
columns: [
{ data: 'plus_icon', name: 'plus_icon' },
{ data: 'employee_name', name: 'employee_name' },
{ data: 'Indate', name: 'Indate' },
{ data: 'checkIn_time', name: 'checkIn_time' },
{ data: 'checkOut_time', name: 'checkOut_time' },
],
order: [[ 2, "desc"]],
columnDefs: [
{
"targets": [ 0 ],
"class": "control"
},
{
"targets": 'no-sort',
"orderable": false
},
{
"targets": 'no-search',
"searchable": false
},
{
"targets": 'hidden',
"visible": false
}
],
});
// =============== DataTable End ===============
// =============== OverView Table Start ===============
$( '.select-2' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
} );
function attendanceOverViewTableRender(){
let month = $('.select-month').val();
let year = $('.select-year').val();
$.ajax({
url: `/myattendance/attendance-overview-table?month=${month}&year=${year}`,
type: 'GET',
}).done(function (res){
$('.overViewTableRender').html(res);
});
// to render SSD Table
table.ajax.url(`/myattendance/data-table/ssd?month=${month}&year=${year}`).load();
}
attendanceOverViewTableRender();
// =============== OverView Table End ===============
// =============== Payroll Table Start ===============
function payRollTableRender(){
let month = $('.select-month').val();
let year = $('.select-year').val();
$.ajax({
url: `/mypayroll/datas/payrolltable?month=${month}&year=${year}`,
type: 'GET',
}).done(function (res){
$('.payRollTableRender').html(res);
});
}
payRollTableRender();
// =============== Payroll Table End ===============
$('.filter-btn').click(function (){
attendanceOverViewTableRender();
payRollTableRender();
});
});
</script>
@endsection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# Demo

# Overview.Blade
resources / views / Attendance / overView.blade.php
@extends('layouts.master')
@section('page-title') Attendance @endsection
@section('content')
<div class="mb-2">
<nav aria-label="breadcrumb" class="bg-white p-2 shadow-sm rounded">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item">
<a href="{{ route('attendance.index') }}" class="text-decoration-none">Attendance</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Attendance Overview</li>
</ol>
</nav>
</div>
<div class="card border-0 shadow-sm rounded">
<div class="card-body">
<div class="row mb-3">
<div class="col-12 col-md-4 col-lg-3">
<div class="">
<label for="name" class="text-black-50">Enter Employee Name</label>
<input type="text" id="name" class="form-control employee_name">
</div>
</div>
<div class="col-12 col-md-4 col-lg-3">
<div class="">
@php
$monthArr = ["January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"];
@endphp
<label for="month" class="text-black-50">Choose Month</label>
<select name="month" id="month" class="form-select select-2 select-month">
@foreach($monthArr as $key=>$month)
@php
if ($key<9){
$number = "0".$key+1;
}else{
$number = $key+1;
}
@endphp
<option value="{{ $number }}" @if(now()->format('m') == $number) selected @endif>{{ $month }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-12 col-md-4 col-lg-3">
<div class="">
<label for="year" class="text-black-50">Choose Year</label>
<select name="year" id="year" class="form-select select-2 select-year">
@for($i = 0; $i<5; $i++)
<option value="{{ now()->subYear($i)->format('Y') }}" @if(now()->format('Y') == now()->subYear($i)->format('Y') ) selected @endif>
{{ now()->subYear($i)->format('Y') }}
</option>
@endfor
</select>
</div>
</div>
<div class="col-12 col-md-4 col-lg-3 align-items-end d-flex">
<button class="btn btn-primary w-100 filter-btn mt-3 mt-md-0">
Filter Attendance Datas
</button>
</div>
</div>
<div class="overViewTableRender">
{{-- Data Table Render Area --}}
</div>
</div>
</div>
@endsection
@section('js')
<script>
$(document).ready(function (){
$( '.select-2' ).select2( {
theme: "bootstrap-5",
width: $( this ).data( 'width' ) ? $( this ).data( 'width' ) : $( this ).hasClass( 'w-100' ) ? '100%' : 'style',
} );
});
function attendanceOverViewTableRender(){
let employee_name = $('.employee_name').val();
let month = $('.select-month').val();
let year = $('.select-year').val();
$.ajax({
url: `/attendance/attendance-overview-table?employee_name=${employee_name}&month=${month}&year=${year}`,
type: 'GET',
}).done(function (res){
$('.overViewTableRender').html(res);
});
}
attendanceOverViewTableRender();
$('.filter-btn').click(function (){
attendanceOverViewTableRender();
});
</script>
@endsection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# AttendanceOverViewTable.blade
resources / views / Attendance / attendanceOverViewTable.blade.php
<div class="table-responsive">
<table class="table table-hover table-bordered mb-0">
<thead class="">
<tr class="bg-primary text-white">
<th class="text-nowrap">Employee Name</th>
@foreach($periods as $period)
<th class="text-center @if($period->format('D') == "Sat" || $period->format('D') == "Sun") bg-danger text-white @endif">
{{ $period->format('d') }}
<hr class="m-0">
{{ $period->format('D') }}
</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach($employees as $employee)
<tr>
<td>{{ $employee->name }}</td>
@foreach($periods as $period)
@php
// sart-> 09, end->06, bs->12, be->1
$office_start_time = $period->format('Y-m-d').' '.$companySetting->office_start_time;
$office_end_time = $period->format('Y-m-d').' '.$companySetting->office_end_time;
$break_start_time = $period->format('Y-m-d').' '.$companySetting->break_start_time;
$break_end_time = $period->format('Y-m-d').' '.$companySetting->break_end_time;
$checkin_icon = "";
$checkout_icon = "";
$attendance = collect($attendances)
->where('user_id', $employee->id)
->where('Indate', $period->format('Y-m-d'))
->first();
if ($attendance){
// Morning
if (!is_null($attendance->checkIn_time)){
if ($attendance->checkIn_time <= $office_start_time){
$checkin_icon = "<i class='fa-solid fa-check-circle text-success'></i>";
}elseif ($attendance->checkIn_time > $office_start_time
&&
$attendance->checkIn_time < $break_start_time){
$checkin_icon = '<i class="fa-solid fa-check-circle text-warning"></i>';
}else{
$checkin_icon = '<i class="fa-solid fa-times-circle text-danger"></i>';
}
}else{
$checkin_icon = '<i class="fa-solid fa-times-circle text-danger"></i>';
}
// Evening
if (!is_null($attendance->checkOut_time)){
if ($attendance->checkOut_time <= $break_end_time){
$checkout_icon = '<i class="fa-solid fa-times-circle text-danger"></i>';
}elseif ($attendance->checkOut_time > $break_end_time
&&
$attendance->checkOut_time < $office_end_time){
$checkout_icon = '<i class="fa-solid fa-check-circle text-warning"></i>';
}else{
$checkout_icon = "<i class='fa-solid fa-check-circle text-success'></i>";
}
}else{
$checkout_icon = '<i class="fa-solid fa-times-circle text-danger"></i>';
}
}
@endphp
<td class="text-center @if($period->format('D') == "Sat" || $period->format('D') == "Sun") bg-danger text-white @endif">
<div class="">
{!! $checkin_icon !!}
</div>
<div class="">
{!! $checkout_icon !!}
</div>
</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Demo
