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/destinytrafficsolutions/vendor/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?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"; ?> <div class="wrapper"> <?php require "inc/sidebar.php"; ?> <div id="content"> <div class="row"> <div class="col-sm-12"> <div class="row mb-xl-4 mb-0"> <?php // session_start(); include("inc/config.php"); if (!isset($_SESSION['id'])) { header("Location: login.php"); exit(); } $se = $_SESSION['id']; $query = "SELECT * FROM projects WHERE emp_id = ?"; $stmt = $conn->prepare($query); $stmt->bind_param("i", $se); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $category_ids = json_decode($row['category_ids'], true); if (!is_array($category_ids)) { continue; // Skip if decoding fails } // Loop through each category ID foreach ($category_ids as $category_id) { // Fetch category details $catQuery = "SELECT v_name, photo FROM categories WHERE id = ?"; $catStmt = $conn->prepare($catQuery); $catStmt->bind_param("i", $category_id); $catStmt->execute(); $catResult = $catStmt->get_result(); if ($catRow = $catResult->fetch_assoc()) { // Fetch the latest click count and last clicked time for this project-category $clickQuery = "SELECT click_count, clicked_at FROM click_records WHERE project_id = ? AND category_id = ? AND emp_id = ? ORDER BY id DESC LIMIT 1"; $clickStmt = $conn->prepare($clickQuery); $clickStmt->bind_param("iii", $row['id'], $category_id, $row['emp_id']); $clickStmt->execute(); $clickResult = $clickStmt->get_result(); if ($clickRow = $clickResult->fetch_assoc()) { $clickCount = $clickRow['click_count']; $clickedAt = $clickRow['clicked_at']; } else { $clickCount = 0; // Default to 0 if no record exists $clickedAt = "Never clicked"; } ?> <div class="col-4 col-sm-6 col-xl-3 mb-4"> <!-- <div class="col-12 col-sm-6 col-xl-3 mb-4"> --> <div class="card redial-border-primary redial-shadow redial-bg-primary text-white"> <div class="card-body"> <div class="text-center"> <h4 class="v_name"><?php echo htmlspecialchars($catRow['v_name']); ?></h4> <img src="<?php echo "../admin/category/" . htmlspecialchars($catRow['photo']); ?>" alt="Category Image" style="max-width: 70px; height: 37px;"> <p>Project: <?php echo htmlspecialchars($row['project_name']); ?></p> <!-- Click Count Display --> <h2 class="mb-1 redial-font-weight-400 text-white count" id="count-<?php echo $row['id'] . '-' . $category_id; ?>"> <?php echo $clickCount; ?> </h2> <!-- Click Button --> <p> <i class="fa fa-plus add-click" data-project="<?php echo $row['id']; ?>" data-category="<?php echo $category_id; ?>" data-emp="<?php echo $row['emp_id']; ?>" aria-hidden="true" style="cursor: pointer;"> </i> </p> </div> </div> </div> </div> <?php } } } } else { echo "<p>No projects found.</p>"; } ?> </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> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function () { $(".add-click").click(function () { var project_id = $(this).data("project"); var category_id = $(this).data("category"); var emp_id = $(this).data("emp"); var countElement = $("#count-" + project_id + "-" + category_id); var timeElement = $("#time-" + project_id + "-" + category_id); $.ajax({ url: "update_click.php", type: "POST", data: { project_id: project_id, category_id: category_id, emp_id: emp_id }, dataType: "json", success: function (response) { if (response.success) { countElement.text(response.newCount); // Update count in UI timeElement.text(response.lastClicked); // Update last clicked time } else { alert("Error updating count."); } } }); }); }); </script> <!-- model --> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> <script> $(document).ready(function() { <?php if ($showModal) { ?> $('#demoModal').modal('show'); // Show modal only if condition is met <?php } ?> }); // Handle form submission with AJAX $(document).on('submit', '#modalForm', function(event) { event.preventDefault(); let formData = new FormData(document.getElementById('modalForm')); $.ajax({ type: "POST", url: "click_verification.php", data: formData, processData: false, contentType: false, success: function(response) { alert(response); // Show success message from PHP $('#demoModal').modal('hide'); // Close the modal after successful submission }, error: function() { alert("Error submitting form!"); } }); }); </script> <!-- Modal --> <div class="modal fade" id="demoModal" tabindex="-1" role="dialog" aria-labelledby="demoModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false"> <div class="modal-dialog" role="document"> <div class="modal-content redial-border-light"> <div class="modal-header redial-border-light"> <h5 class="modal-title pt-2" id="exampleModalLabel">Verification Form</h5> <!-- Remove Close Button --> </div> <div class="modal-body"> <!-- Form inside the modal --> <form id="modalForm" action="click_verification.php" method="POST"> <div class="form-group"> <label for="locationInput">Location</label> <input type="text" class="form-control" name="location" id="locationInput" placeholder="Enter Location" required> </div> <div class="form-group"> <label for="startTimeInput">Start Time</label> <input type="time" class="form-control" name="start_time" id="startTimeInput" required> </div> <div class="form-group"> <label for="dateInput">Date</label> <input type="date" class="form-control" name="date" id="dateInput" required> </div> <?php if (isset($_SESSION['id'])) { $emp_id = $_SESSION['id']; // Get employee ID from session } else { $emp_id = ""; // Set empty if no session exists } ?> <input type="hidden" name="emp_id" id="empId" value="<?php echo $emp_id; ?>"> <button type="submit" class="btn btn-primary">Submit</button> </form> </div> <div class="modal-footer redial-border-light"> <!-- Remove Close Button --> </div> </div> </div> </div> <script> $(document).ready(function() { $('#demoModal').modal('show'); }); $(document).on('submit', '#modalForm', function(event) { event.preventDefault(); let formData = new FormData(document.getElementById('modalForm')); $.ajax({ type: "POST", url: "click_verification.php", data: formData, processData: false, contentType: false, success: function(response) { alert(response); $('#demoModal').modal('hide'); }, error: function() { alert("Error submitting form!"); } }); }); </script> <!-- model --> <script src="dist/js/plugins.min.js"></script> <script src="dist/js/common.js"></script> </body> </html>