-
Notifications
You must be signed in to change notification settings - Fork 0
/
daily-attendance-report.php
221 lines (197 loc) · 7.01 KB
/
daily-attendance-report.php
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
<?php
if (isset($_SERVER['HTTPS'])) {
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
} else {
$protocol = 'http';
}
$base_url = $protocol . "://" . $_SERVER['SERVER_NAME'] . '/' . (explode('/', $_SERVER['PHP_SELF'])[1]) . '/';
?>
<?php
require 'authentication.php'; // admin authentication check
// auth check
if ($user_id == NULL || $security_key == NULL) {
header('Location: index.php');
}
if (isset($_GET['delete_task'])) {
$action_id = $_GET['task_id'];
$sql = "DELETE FROM `task_info` WHERE `task_id` = :id";
$sent_po = "task-info.php";
$obj_admin->delete_data_by_this_method($sql, $action_id, $sent_po);
}
if (isset($_POST['add_task_post'])) {
$obj_admin->add_new_task($_POST);
}
$page_name = "Task_Info";
include("include/sidebar.php");
// include('ems_header.php');
?>
<?php $date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d') ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<div class="row">
<div class="col-md-12">
<div class="well well-custom rounded-0">
<div class="gap"></div>
<div class="row">
<div class="col-md-4">
<input max="<?php echo date('Y-m-d'); ?>" type="date" id="date" value="<?= $date ?>" class="form-control rounded-0">
</div>
<div class="col-md-4">
<button class="btn btn-primary btn-sm btn-menu" type="button" id="filter"><i class="glyphicon glyphicon-filter"></i> Filter</button>
<button class="btn btn-success btn-sm btn-menu" type="button" id="print"><i class="glyphicon glyphicon-print"></i> Print</button>
</div>
</div>
<p class="text-center">
<h3>Daily Attendance Report</h3>
</p>
<div class="gap"></div>
<div class="gap"></div>
<div class="table-responsive" id="printout">
<table class="table table-codensed table-custom">
<thead>
<tr>
<th>S.N.</th>
<th>Name</th>
<th>Task</th>
<th>In Time</th>
<th>Out Time</th>
<th>Total Duration</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT a.*, b.fullname, c.t_title FROM attendance_info a LEFT JOIN tbl_admin b ON(a.atn_user_id = b.user_id) LEFT JOIN task_info c ON (c.task_id = a.task_id) where ('{$date}' BETWEEN date(a.in_time) and date(a.out_time))
ORDER BY a.aten_id DESC";
// echo $sql;
$info = $obj_admin->manage_all_info($sql);
$serial = 1;
$num_row = $info->rowCount();
if ($num_row == 0) {
echo '<tr><td colspan="7">No Data found</td></tr>';
}
while ($row = $info->fetch(PDO::FETCH_ASSOC)) {
?>
<tr>
<td><?php echo $serial;
$serial++; ?></td>
<td><?php echo $row['fullname']; ?></td>
<td><?php echo $row['t_title']; ?></td>
<td><?php echo $row['in_time']; ?></td>
<td><?php echo $row['out_time']; ?></td>
<td><?php
if ($row['total_duration'] == null) {
$date = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$current_time = $date->format('d-m-Y H:i:s');
$dteStart = new DateTime($row['in_time']);
$dteEnd = new DateTime($current_time);
$dteDiff = $dteStart->diff($dteEnd);
echo $dteDiff->format("%H:%I:%S");
} else {
echo $row['total_duration'];
}
?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="well well-custom rounded-0">
<p class="text-center">
<h3>Daily Employee Attendance Report</h3>
</p>
<div class="gap"></div>
<div class="gap"></div>
<div class="table-responsive" id="printout">
<table class="table table-codensed table-custom">
<thead>
<tr>
<th>S.N.</th>
<th>Employee</th>
<th>Total Work</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(a.total_duration))) as totalWork, b.fullname
FROM attendance_info a
LEFT JOIN tbl_admin b ON(a.atn_user_id = b.user_id) where ('{$date}' BETWEEN date(a.in_time) and date(a.out_time))
GROUP BY b.fullname;";
$info = $obj_admin->manage_all_info($sql);
$serial = 1;
$num_row = $info->rowCount();
if ($num_row == 0) {
echo '<tr><td colspan="5">No Data found</td></tr>';
}
while ($row = $info->fetch(PDO::FETCH_ASSOC)) {
?>
<tr>
<td><?php echo $serial;
$serial++; ?></td>
<td><?php echo $row['fullname']; ?></td>
<td><?php echo $row['totalWork']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php
include("include/footer.php");
?>
<noscript>
<div>
<style>
body {
background-image: none !important;
}
.mb-0 {
margin: 0px;
}
</style>
<div style="line-height:1em">
<h4 class="mb-0 text-center"><b>Employee Task Management System</b></h4>
<h4 class="mb-0 text-center"><b>Daily Task Report</b></h4>
<div class="mb-0 text-center"><b>as of</b></div>
<div class="mb-0 text-center"><b><?= date("F d, Y", strtotime($date)) ?></b></div>
</div>
<hr>
</div>
</noscript>
<script type="text/javascript">
$(function() {
$('#filter').click(function() {
location.href = "./daily-attendance-report.php?date=" + $('#date').val()
})
$('#print').click(function() {
var h = $('head').clone()
var ns = $($('noscript').html()).clone()
var p = $('#printout').clone()
var base = '<?= $base_url ?>';
h.find('link').each(function() {
$(this).attr('href', base + $(this).attr('href'))
})
h.find('script').each(function() {
if ($(this).attr('src') != "")
$(this).attr('src', base + $(this).attr('src'))
})
p.find('.table').addClass('table-bordered')
var nw = window.open("", "_blank", "width:" + ($(window).width() * .8) + ",left:" + ($(window).width() * .1) + ",height:" + ($(window).height() * .8) + ",top:" + ($(window).height() * .1))
nw.document.querySelector('head').innerHTML = h.html()
nw.document.querySelector('body').innerHTML = ns[0].outerHTML
nw.document.querySelector('body').innerHTML += p[0].outerHTML
nw.document.close()
setTimeout(() => {
nw.print()
setTimeout(() => {
nw.close()
}, 200);
}, 200);
})
})
</script>