MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/dts/vendor/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/dts/vendor/taskbyemployeelist.php
<?php
session_start();
$se = $_SESSION["id"];
if (!isset($_SESSION['id'])) {
    header("Location: login.php");
}
include("inc/config.php");

$emp_name = isset($_GET['emp_name']) ? mysqli_real_escape_string($conn, $_GET['emp_name']) : '';

 
?>

<!DOCTYPE html>
<html lang="en">
    
<?php require "inc/head.php"; ?>
    <body>
        <!-- header-->
        <?php require "inc/header.php"; ?>
        <!-- End Main-content Top bar-->

        <!-- main-content-->
        <div class="wrapper">
        <?php require "inc/sidebar.php"; ?>
        <div id="content">
        <div class="row">
    <?php
    // Get start and end dates from input (use correct variable names)
    $start_date = isset($_GET['start_datetime']) ? mysqli_real_escape_string($conn, $_GET['start_datetime']) : '';
    $end_date = isset($_GET['end_datetime']) ? mysqli_real_escape_string($conn, $_GET['end_datetime']) : '';

    // Get employee name from GET request
    $emp_name = isset($_GET['emp_name']) ? mysqli_real_escape_string($conn, $_GET['emp_name']) : '';

    // Base Query to Fetch Tasks for Employee with Date Filter
    $task_query = "SELECT * FROM tasks WHERE 1";

    // Apply Employee Filter (If Employee Name is provided)
    if (!empty($emp_name)) {
        $task_query .= " AND emp_name = '$emp_name'";
    }

    // Apply Date Range Filter (Only if both dates are selected)
    if (!empty($start_date) && !empty($end_date)) {
        $task_query .= " AND (start_datetime BETWEEN '$start_date' AND '$end_date' OR end_datetime BETWEEN '$start_date' AND '$end_date')";
    }

    // Execute the query
    $task_result = mysqli_query($conn, $task_query);
    ?>

    <div class="col-12 col-sm-12">
        <div class="row">
            <div class="col-12 col-md-12">
                <div class="card redial-border-light redial-shadow">
                    <div class="card-body">
                        <h6 class="header-title pl-3 redial-relative">Tasks of <?php echo htmlspecialchars($emp_name); ?></h6>

                        <!-- Filter Form -->
                        <form method="GET" action="">
                            <div class="row mb-3">
                                <!-- Employee Name (Hidden field) -->
                                <input type="hidden" name="emp_name" value="<?php echo htmlspecialchars($emp_name); ?>">

                                <!-- Start Date -->
                                <div class="col-md-3">
                                    <label for="start_datetime">Start Date:</label>
                                    <input type="date" name="start_datetime" id="start_datetime" class="form-control"
                                        value="<?php echo htmlspecialchars($start_date); ?>">
                                </div>

                                <!-- End Date -->
                                <div class="col-md-3">
                                    <label for="end_datetime">End Date:</label>
                                    <input type="date" name="end_datetime" id="end_datetime" class="form-control"
                                        value="<?php echo htmlspecialchars($end_date); ?>">
                                </div>

                                <!-- Filter Button -->
                                <div class="col-md-3">
                                    <button type="submit" class="btn btn-primary mt-4">Filter</button>
                                </div>
                            </div>
                        </form>

                        <!-- Task Table -->
                        <table class="table table-striped table-hover mb-0">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Task Name</th>
                                    <th>Start Date</th>
                                    <th>End Date</th>
                                    <th>Grand Total</th>
                                    <th>Task Report</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                if (mysqli_num_rows($task_result) > 0) {
                                    while ($task = mysqli_fetch_assoc($task_result)) {
                                        ?>
                                        <tr>
                                            <td><?php echo $task['id']; ?></td>
                                            <td><?php echo $task['task_name']; ?></td>
                                            <td><?php echo date('Y-m-d', strtotime($task['start_datetime'])); ?></td>
                                            <td><?php echo date('Y-m-d', strtotime($task['end_datetime'])); ?></td>
                                            <td><?php echo $task['grand_total']; ?></td>
                                            <td>
                                                <span class="badge bg-danger">
                                                    <a href="task-report.php?id=<?php echo $task['id']; ?>" class="text-white">Report</a>
                                                </span>
                                            </td>
                                        </tr>
                                        <?php
                                    }
                                } else {
                                    echo "<tr><td colspan='6' class='text-center'>No tasks found for this employee.</td></tr>";
                                }
                                ?>
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

        </div>
        <!-- End main-content-->

        <!-- Top To Bottom-->
        <a href="#" class="scrollup text-center redial-bg-primary redial-rounded-circle-50"> 
            <h4 class="text-white mb-0"><i class="icofont icofont-long-arrow-up"></i></h4>
        </a>
        <!-- End Top To Bottom-->

        <!-- Chat-->
     
        <!-- End Chat-->
        
        <!-- jQuery -->
        <script src="dist/js/plugins.min.js"></script>        
        <script src="dist/js/common.js"></script>
    </body>
</html>

MMCT - 2023