-
Notifications
You must be signed in to change notification settings - Fork 13
/
detail_status.php
190 lines (160 loc) · 4.27 KB
/
detail_status.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
<!DOCTYPE html>
<html>
<head>
<title>How to Track Email Open or not using PHP</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<script src="js/jquery.min.js"></script>
<link rel="stylesheet" href="css/jquery.dataTables.min.css"></style>
<script type="text/javascript" src="js/jquery.dataTables.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class=" container">
<table class="table-responsive table table-bordered table-striped">
<tr>
<th class="text-center"><span>Email</span></th>
<th class="text-center"> <span>Subject</span></th>
</tr>
<tr>
<td class="text-center">
<span><?php if (isset($_POST["details"]) && !empty($_POST["details"])) {
echo $_POST["email_address"];
} else {
echo "No Data Available";
} ?> </span>
</td>
<td class="text-center">
<span><?php if (isset($_POST["details"]) && !empty($_POST["details"])) {
echo $_POST["email_subject"];
} else {
echo "No Data Available";
} ?></span>
</td>
</tr>
<tr>
<th class="text-center"> <span>Email ID Number</span></th>
<th class="text-center"> <span>Message</span></th>
</tr>
<tr>
<td class="text-center">
<span>
<?php if (isset($_POST["details"]) && !empty($_POST["details"])) {
echo $_POST["email_track_code"];
} else {
echo "No Data Available";
} ?>
</span>
</td>
<td class="text-center"><span><?php if (isset($_POST["details"]) && !empty($_POST["details"])) {
echo $_POST["email_body"];
} else {
echo "No Data Available";
} ?></span></td>
</tr>
</table></div>
<?php
$connect = new PDO("mysql:host=localhost;dbname=email_track_database", "root", "");
function fetch_email_track_data($connect,$email_track_code)
{
$query = "SELECT email_data.email_subject,email_data.email_address,email_data.email_body,email_data.email_track_code ,email_track.email_status,email_track.email_open_datetime
FROM email_data
LEFT JOIN email_track ON email_track.email_track_code = email_data.email_track_code WHERE email_data.email_track_code = ? ORDER BY email_track.email_open_datetime DESC";
$statement = $connect->prepare($query);
$statement->execute([$email_track_code]);
$result = $statement->fetchAll();
$total_row = $statement->rowCount();
$output = '
<div class="container">
<table id="myTable" class="table-responsive table table-bordered table-striped">
<thead>
<tr>
<th class="text-center"> <span>Status</span></th>
<th class="text-center"> <span>Open Datetime</span> </th>
</tr>
</thead>
<tbody>
';
if($total_row > 0)
{
foreach($result as $row)
{
$status = '';
if($row['email_status'] == 'yes')
{
$status = '<span class="label label-success">Open</span>';
}
else
{
$status = '<span class="label label-danger">Not Open</span>';
}
$output .= '
<tr>
<td class="text-center"> <span>'.$status.'</span></td>
<td class="text-center"> <span>'.$row["email_open_datetime"].'</span></td>
</tr>
';
}
}
else
{
$output .= '
<tr>
<td colspan="2" class="text-center"><span>No Email Send Data Found</span></td>
</tr>
';
}
$output .= '
<tbody>
<tfoot>
<tr>
<th class="text-center"> <span>Status</span></th>
<th class="text-center"> <span>Open Datetime</span> </th>
</tr>
</tfoot>
</table>
</div>';
return $output;
}
?>
<h2 class="text-center"> <span>History Logs</span></h2>
<?php
$email_track_code=$_POST["email_track_code"];
echo fetch_email_track_data($connect,$email_track_code);
?>
<style type="text/css">
body {
padding-top: 60px;
background: black;
}
@media (max-width: 980px) {
body {
padding-top: 20px;
background: black;
}
}
table { table-layout: fixed; }
span{
color: white;
}
th{
background: #110b42;
}
td{
background: #333;
}
label{
color:#ea0077;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$('#myTable').dataTable({
"lengthMenu": [ [5, 10, 15, 25, 40, -1], [5, 10, 15, 25, 40, "All"] ]
});
$(".dataTables_info").css({color:"white"});
$('.dataTables_paginate').css({'font-size': '150%' ,'font-weight': 'bold'});
});
</script>
<br>
</body>
</html>