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 (0750) :  /home2/imyrqtmy/public_html/thesmarthands/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/thesmarthands/view-project.php
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
$se = $_SESSION["id"];
if (!isset($_SESSION['id'])) {
    header("Location: login.php");
}
include("inc/config.php");;
 
?>

<!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">
    <div class="col-12 col-sm-12">
    <div class="row mb-4">
    <div class="col-12 col-md-12">
    <div class="card redial-border-light redial-shadow mb-4">
        <div class="card-body">
            <h6 class="header-title pl-3 redial-relative">Data Table</h6>

            <form method="GET" action="">
                <div class="row mb-3">
                    <!-- Start Date -->
                    <div class="col-md-3">
                        <label for="start_date">Start Date:</label>
                        <input type="date" name="start_date" id="start_date" class="form-control"
                               value="<?php echo isset($_GET['start_date']) ? $_GET['start_date'] : ''; ?>">
                    </div>

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

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

            <table id="example" class="table table-bordered" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Project Name</th>
                        <th>Task Completed</th>
                        <th>Task Active</th>
                        <th>Project Start</th>
                        <th>Project End</th>
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    
                    
                    <?php
                    // Get start & end dates from input
                    $start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '';
                    $end_date = isset($_GET['end_date']) ? $_GET['end_date'] : '';

                    // Build query with filters
                    $query = "SELECT * FROM projects WHERE 1";

                    if (!empty($start_date) && !empty($end_date)) {
                        // Apply date range filter
                        $query .= " AND project_start >= '$start_date' AND project_end <= '$end_date'";
                    }

                    $query_run = mysqli_query($conn, $query);

                    if (mysqli_num_rows($query_run) > 0) {
                        foreach ($query_run as $row) {
                            $project_id = $row['id'];

                            // Fetch Task Completed count
                            $task_completed_query = "SELECT COUNT(*) AS completed_count FROM tasks WHERE project_name = '$project_id' AND status = 'Complete'";
                            $task_completed_result = mysqli_query($conn, $task_completed_query);
                            $completed_row = mysqli_fetch_assoc($task_completed_result);
                            $task_completed_count = $completed_row['completed_count'] ?? 0;

                            // Fetch Task Active count
                            $task_active_query = "SELECT COUNT(*) AS active_count FROM tasks WHERE project_name = '$project_id' AND status = 'Active'";
                            $task_active_result = mysqli_query($conn, $task_active_query);
                            $active_row = mysqli_fetch_assoc($task_active_result);
                            $task_active_count = $active_row['active_count'] ?? 0;

                            ?>
                            <tr>
                                <td><?php echo $row['id']; ?></td>
                                <td><a href="view-taskbypro.php?id=<?php echo $row['id']; ?>"><?php echo $row['project_name']; ?></a></td>
                                <td><?php echo $task_completed_count; ?></td>
                                <td><?php echo $task_active_count; ?></td>
                                <td><?php echo $row['project_start']; ?></td>
                                <td><?php echo $row['project_end']; ?></td>
                                <td><?php echo $row['project_status']; ?></td>
                                <td>
                                    <div class='btn-group mb-2'>
                                        <a href="update-project.php?id=<?php echo $row['id']; ?>" class="btn btn-success" data-bs-toggle="tooltip" title="Edit Project">
                                            <i class='fa fa-pencil'></i>
                                        </a>
                                  
                                        
                                        &nbsp;&nbsp;
                                        
                                        <!--<form action="add_project.php" method="post">-->
                                        <!--    <input type="hidden" name="delete_id" value="<?php echo $row['id']; ?>">-->
                                        <!--    <button type="submit" name="delete_project" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this project?');">-->
                                        <!--        <i class='fa fa-trash'></i>-->
                                        <!--    </button>-->
                                        <!--</form>-->
                                        <form action="add_project.php" method="post">
                                            <input type="hidden" name="delete_id" value="<?php echo $row['id']; ?>">
                                            <button type="submit" name="delete_project" class="btn btn-danger" >
                                                <i class='fa fa-trash'></i>
                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        <?php }
                    } else {
                        echo "<tr><td colspan='8' class='text-center'>No projects found for the selected date range.</td></tr>";
                    }
                    ?>
                </tbody>
            </table>
        </div>
    </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-->

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

</html>

MMCT - 2023