112 lines
3.3 KiB
PHP
112 lines
3.3 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Task Report</title>
|
|
<style>
|
|
table {
|
|
border-collapse: collapse;
|
|
width: 100%;
|
|
}
|
|
|
|
th,
|
|
td {
|
|
border: 1px solid #dddddd;
|
|
text-align: left;
|
|
padding: 8px;
|
|
}
|
|
|
|
th {
|
|
background-color: #f2f2f2;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<?php
|
|
include ('includes/config/config.php');
|
|
include ('includes/functions.php');
|
|
include ("pdf_ohc_header.php");
|
|
include ('log_entry.php');
|
|
|
|
$from_date = $_REQUEST['startDate2'];
|
|
$to_date = $_REQUEST['endDate2'];
|
|
|
|
|
|
$start_month = date('m', strtotime($from_date));
|
|
$start_year = date('Y', strtotime($from_date));
|
|
|
|
// Calculate the number of days in the month
|
|
$daysInMonth = cal_days_in_month(CAL_GREGORIAN, $start_month, $start_year);
|
|
|
|
$task_filter = isset($_REQUEST['task_filter']) ? $_REQUEST['task_filter'] : [];
|
|
|
|
$sanitized_filters = [];
|
|
foreach ($task_filter as $filter) {
|
|
$sanitized_filter = filter_var($filter, FILTER_SANITIZE_STRING);
|
|
$sanitized_filters[] = $sanitized_filter;
|
|
}
|
|
|
|
$in_values = "'" . implode("','", $sanitized_filters) . "'";
|
|
|
|
$task_names = [];
|
|
|
|
$sql = "SELECT task_id, task_name FROM task_master WHERE task_header_id IN (SELECT task_id_header FROM task_header_master WHERE task_id_header IN ($in_values)) AND ohc_type ='" . $_SESSION['current_ohcttype'] . "' ";
|
|
|
|
error_log("query " . $sql);
|
|
|
|
$result = mysqli_query($conn, $sql);
|
|
|
|
if ($result) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$task_names[$row['task_id']] = $row['task_name']; // Fill task_names array with task_id as key and task_name as value
|
|
}
|
|
} else {
|
|
// Handle the case where the query fails
|
|
error_log("Error executing query: " . mysqli_error($conn));
|
|
}
|
|
|
|
echo '<table>';
|
|
echo '<tr><th>Task Name</th>'; // Header row for task names
|
|
|
|
// Create header row for dates
|
|
for ($day = 1; $day <= $daysInMonth; $day++) {
|
|
echo '<th>' . $day . '</th>';
|
|
}
|
|
echo '</tr>';
|
|
|
|
// Loop through task names and display data
|
|
foreach ($task_names as $taskId => $taskName) {
|
|
echo '<tr><td>' . $taskName . '</td>'; // Task name cell
|
|
|
|
|
|
// Loop through each day's value for the task
|
|
for ($day = 1; $day <= $daysInMonth; $day++) {
|
|
|
|
$dateToFetch = $start_year . '-' . $start_month . '-' . sprintf("%02d", $day);
|
|
$value = ''; // Default value if no data found for the date
|
|
|
|
// Fetch values for each task from the database
|
|
$values_sql = "SELECT * FROM task_master_status WHERE task_id = $taskId AND task_date = '$dateToFetch'";
|
|
error_log("value query " . $values_sql);
|
|
$values_result = mysqli_query($conn, $values_sql);
|
|
|
|
if ($values_result && $row = mysqli_fetch_assoc($values_result)) {
|
|
$value = $row['status'] == 'on' ? 'C' : 'P';
|
|
}
|
|
echo '<td>' . $value . '</td>';
|
|
}
|
|
|
|
echo '</tr>';
|
|
}
|
|
|
|
echo '</table>';
|
|
echo '<br><div class="note">Note: C = Completed, P = Pending</div>';
|
|
?>
|
|
|
|
</body>
|
|
|
|
</html>
|