-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathexport_absensi.php
111 lines (98 loc) · 2.63 KB
/
export_absensi.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
<?php
// Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Export Data Absensi Ke Excel</title>
</head>
<body>
<style type="text/css">
body{
font-family: sans-serif;
}
table{
margin: 20px auto;
border-collapse: collapse;
}
table th,
table td{
border: 1px solid #3c3c3c;
padding: 3px 8px;
}
a{
background: blue;
color: #fff;
padding: 8px 10px;
text-decoration: none;
border-radius: 2px;
}
</style>
<?php
include('config/db.php');
?>
<?php
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=DataAbsensi.xls");
?>
<left>
<h1>Data Absensi PT Graha Sumber Prima Elektronik</h1>
</left>
<table border="1">
<tr>
<th>No</th>
<th>Nama Pegawai</th>
<th>NIP</th>
<th>Waktu Masuk</th>
<th>Waktu Keluar</th>
<th>Telat</th>
<th>Kamera</th>
<th>Status</th>
<th>Divisi</th>
</tr>
<?php
$sqlemp = "SELECT *, employee.divisi FROM `face_absensi` JOIN employee ON face_absensi.nama_pegawai=employee.nama_pegawai ";
$sqlemp .= "WHERE 1 ";
if (strlen($_SESSION['valuedivisi'])>=1) {
if ($_SESSION['valuedivisi']=='All') {
$sqlemp .= " ";
$total_pages_sql .= " ";
}else {
$div=$_SESSION['valuedivisi'];
$sqlemp .= "AND divisi='$div' ";
$total_pages_sql .= "AND divisi='$div' ";
}
}
if (strlen($_SESSION['from'])>5) {
$date = new DateTime($_SESSION['from']);
$dt1=$date->format('Y-m-d'); // To match MySQL date format
$sqlemp .= "AND DATE(face_absensi.waktu_masuk)>= '$dt1' " ;
$total_pages_sql .= "AND DATE(face_absensi.waktu_masuk)>= '$dt1' ";
}
if (strlen($_SESSION['to'])>5) {
$date = new DateTime($_SESSION['to']);
$dt2=$date->format('Y-m-d'); // To match MySQL date format
$sqlemp .= "AND DATE(face_absensi.waktu_masuk)<= '$dt2' " ;
$total_pages_sql .= "AND DATE(face_absensi.waktu_masuk)<= '$dt2' ";
}
$sqlemp .= "ORDER BY face_absensi.waktu_masuk ";
$query = $con->query($sqlemp);
$noe=1;
while ($row = $query->fetch_assoc()) {
echo '<tr>';
echo '<td>'. $noe++ . '</td>';
echo '<td>'. $row['nama_pegawai'] . '</td>';
echo '<td>'. $row['employee_id'] . '</td>';
echo '<td>'. $row['waktu_masuk'] . '</td>';
echo '<td>'. $row['waktu_keluar'] . '</td>';
echo '<td>'. $row['selisih_waktu'] . '</td>';
echo '<td>'. $row['kamera'] . '</td>';
echo '<td>'. $row['note'] . '</td>';
echo '<td>'. $row['divisi'] . '</td>';
echo '</tr>';
}
?>
</table>
</body>
</html>