hjkhghopjkertteerterterterertertrtoirh
bnmbertsurhetertertertertertertertpdf'tdfg
/
var
/
www
/
mycipl.in
/
public_html
/
Upload FileeE
HOME
<?php // Start session session_start(); // Establish a connection to your database using MySQLi $connection = new mysqli("localhost", "mycipllive", "2dZpcVNwVYjIBzT", "mycipl_live"); // Check connection if ($connection->connect_error) { die("Connection failed: " . $connection->connect_error); } // Calculate the starting serial number $i = 1; // Get yesterday's date in the format 'YYYY-MM-DD' $yest_date = date('Y-m-d', strtotime('-1 day')); // If yesterday is Sunday, get records from two days before (Friday) if (date('D', strtotime($yest_date)) === 'Sun') { $yest_date = date('Y-m-d', strtotime('-2 days', strtotime($yest_date))); } // Build the query to get employees who missed entering a timesheet for yesterday $query = "SELECT em.rec_id, em.emp_id, em.first_name, em.last_name, em.branch, dm.department FROM employee_master em LEFT JOIN timesheet_master tm ON em.rec_id = tm.emp_id LEFT JOIN emp_dept_master edm ON em.rec_id = edm.emp_id LEFT JOIN department_master dm ON edm.dept_id = dm.rec_id WHERE em.status = 1 AND tm.task_date = $yest_date AND tm.emp_id IS NULL AND edm.status = 1 AND dm.status = 1"; // echo $query;exit; // Execute the query $result = $connection->query($query); print_r($result);exit; // Start building the HTML message $msg = '<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Missing Timesheet Report</title> </head> <body> <div style="margin: 20px;"> <table style="width: 100%; border-collapse: collapse;" border="1"> <thead> <tr> <td colspan="5" style="padding: 8px; border: 1px solid black; text-align: center; background-color: #f0f0f0;"> Employees Missing Timesheet Entry - ' . $yest_date . ' </td> </tr> <tr> <th style="padding: 8px; border: 1px solid black;">S.No</th> <th style="padding: 8px; border: 1px solid black;">Employee ID</th> <th style="padding: 8px; border: 1px solid black;">Employee Name</th> <th style="padding: 8px; border: 1px solid black;">Branch</th> </tr> </thead> <tbody>'; // Initialize variable to track the current department $currentDepartment = ''; if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { // Check if the department has changed if ($currentDepartment !== $row['department']) { $currentDepartment = $row['department']; // Add a new row for the department $msg .= '<tr> <td colspan="4" style="padding: 8px; border: 1px solid black; text-align: center; background-color: #f0f0f0;">' . $currentDepartment . ' Department</td> </tr>'; } // Add employee data $msg .= '<tr> <td style="padding: 8px; border: 1px solid black;">' . $i++ . '</td> <td style="padding: 8px; border: 1px solid black;">' . $row['emp_id'] . '</td> <td style="padding: 8px; border: 1px solid black;">' . $row['first_name'] . ' ' . $row['last_name'] . '</td> <td style="padding: 8px; border: 1px solid black;">' . $row['branch'] . '</td> </tr>'; } } else { $msg .= '<tr> <td colspan="4" style="padding: 8px; border: 1px solid black; text-align: center;">No employees missed timesheet entry on ' . $yest_date . '.</td> </tr>'; } $msg .= '</tbody> </table> </div> </body> </html>'; echo $msg;exit; // Prepare the email subject and headers $subject = 'Employees Missing Timesheet Entry - ' . $yest_date; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Admin <admin@yourdomain.com>' . "\r\n"; // Send the email mail('jayakumar@colaninfotech.com', $subject, $msg, $headers); // Close connection $connection->close();