One Hat Cyber Team
Your IP :
18.222.24.23
Server IP :
50.28.103.30
Server :
Linux host.jcukjv-lwsites.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
Server Software :
nginx/1.24.0
PHP Version :
8.3.12
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
sd.electronharmony.com
/
works
/
Edit File:
ws.php
<?php session_start(); if (!isset($_SESSION['user_email'])) { header("Location: ../login.php"); exit(); } ?> <!DOCTYPE html> <html lang="zxx"> <head> <meta charset="utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="description" content="Fully Responsive Admin & Dashboard Template" /> <meta name="keyword" content="" /> <meta name="author" content="WRAPCODERS" /> <!--! The above 6 meta tags *must* come first in the head; any other head content must come *after* these tags !--> <!--! BEGIN: Google Fonts !--><link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&family=Public+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet"/> <!--! END: Google Fonts !--> <!--! BEGIN: Favicon !--> <link rel="shortcut icon" type="image/x-icon" href="./../assets/images/favicon.ico" /> <!--! END: Favicon !--> <!--! BEGIN: Apps Title !--> <title>works</title> <!--! END: Apps Title !--> <!--! BEGIN: Page Vendors -!--> <link rel="stylesheet" href="./../assets/vendors/bootstrap-table/bootstrap-table.min.css" /> <link rel="stylesheet" href="./../assets/vendors/bootstrap-icons/font/bootstrap-icons.min.css" /> <!--! END: Page Vendors -!--> <!--! BEGIN: MatisMenu CSS -!--> <link rel="stylesheet" href="./../assets/vendors/metismenu/metisMenu.min.css"> <!--! END: MatisMenu CSS -!--> <!--! BEGIN: Flaticon CSS -!--> <link rel="stylesheet" href="./../assets/vendors/@flaticon/flaticon-uicons/css/all/all.css"> <!--! END: Flaticon CSS -!--> <!--! BEGIN: Theme CSS -!--> <link rel="stylesheet" type="text/css" href="./../assets/css/theme.min.css"> <!--! END: Theme CSS -!--> <!--! Start:: Color Modes JS -!--> <script src="./../assets/js/color-modes.min.js"></script> <!--! End:: Color Modes JS -!--> <!--! HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries !--> <!--! WARNING: Respond.js doesn"t work if you view the page via file: !--> <!--[if lt IE 9]> <script src="https:oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https:oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> <style> /* 默认隐藏模态框 */ #addBoardModal { display: none; } </style> </head> <body> <!--! ================================================================ !--> <!--! Start:: Main Wrapper !--> <!--! ================================================================ !--> <div class="main-wrapper"> <!--! ================================================================ !--> <!--! Start:: Main Menu !--> <!--! ================================================================ !--> <aside class="edash-menu position-fixed z-1030 start-0 top-0 end-0 bottom-0 bg-body-tertiary border-end" id="edash-menu"> <!-- Start:: Logo --> <div class="edash-menu-header ht-80 d-flex align-items-center px-5 py-4 position-relative"> <a href="../index.php" class="edash-logo"> <img src="../assets/images/logo/logo_main.png" alt="logo" class="img-fluid edash-logo-main" /> <img src="../assets/images/logo-abbr.png" alt="logo" class="img-fluid edash-logo-abbr" /> </a> </div> <!-- End:: Logo --> <!-- Start:: Sidebar Nav --> <nav class="edash-sidebar-nav position-relative z-2" id="edash-sidebar-nav" style="height: calc(100vh - 5rem)"> <ul class="edash-metismenu" id="edash-metismenu"> <li class="nav-label mb-2 mt-4 px-5 fs-11 fw-semibold text-muted text-uppercase" style="letter-spacing: 1px"> My tables </li> <li> <a href="../index.php" aria-expanded="false"> <i class="fi fi-rr-file-home"></i> <span class="mm-text">首页</span> </a> </li> <li> <a href="ws.php" aria-expanded="false"> <i class="fi fi-rr-file-home"></i> <span class="mm-text">排班表</span> </a> </li> <li> <a href="../pot.php" aria-expanded="false"> <i class="fi fi-rr-file-home"></i> <span class="mm-text">POT</span> </a> </li> <li> <a href="../jobresponsibilities.php" aria-expanded="false"> <i class="fi fi-rr-file-home"></i> <span class="mm-text">DWD</span> </a> </li> <li> <a href="../clipboard.php" aria-expanded="false"> <i class="fi fi-rr-file-home"></i> <span class="mm-text">叫货</span> </a> </li> <!-- <li> <a href="pot.php" aria-expanded="false"> <i class="fi fi-rr-file-invoice"></i> <span class="mm-text">Simmer pot</span> </a> </li>--> <!-- Additional menu items here --> </ul> <div class="card text-center mx-3 mt-6 mb-4 bg-primary-subtle"> <div class="card-body vstack gap-4"> <i class="fi fi-rr-rocket-lunch fs-1 text-primary" style="transform: rotate(320deg)"></i> <div> <h5 class="mb-2 text-primary">Help Center</h5> <p class="fs-13 fw-light mb-0 text-primary"> Expodash is a production ready multi dashboard to get started up and running easily. </p> </div> <a href="" class="btn btn-primary text-white w-100">Get Support</a> </div> </div> </nav> <!-- End:: Sidebar Nav --> </aside> <!--! ================================================================ !--> <!--! End:: Main Menu !--> <!--! ================================================================ !--> <!--! ================================================================ !--> <!--! Start:: Main Content !--> <!--! ================================================================ !--> <main id="edash-main"> <!--! ================================================================ !--> <!--! Start:: Header !--> <!--! ================================================================ !--> <header class="edash-header sticky-top d-flex align-items-end ht-80" id="edash-header-sticky" > <div class="edash-header-container container-xxl w-100 ht-70 px-4 bg-body-tertiary border rounded-3 d-flex align-items-center justify-content-between position-relative" id="edash-header-container" > <!--! Start:: edash-header-left !--> <div class="edash-header-left d-flex align-items-center gap-2"> <!--! Start:: edash-minimenu-toggle !--> <div class="edash-minimenu-toggle d-none d-xl-flex"> <div id="edash-menu-mini"> <a href="javascript:void(0);" class="edash-drop-item d-flex align-items-center justify-content-center rounded-pill ht-40" > <i class="fi fi-sr-arrow-left"></i> </a> </div> <div id="edash-menu-expand" style="display: none"> <a href="javascript:void(0);" class="edash-drop-item d-flex align-items-center justify-content-center rounded-pill ht-40" > <i class="fi fi-rr-arrow-right"></i> </a> </div> </div> <!--! End:: edash-minimenu-toggle !--> <!--! Start:: edash-menu-toggle !--> <div class="edash-menu-toggle d-xl-none"> <a href="javascript:void(0);" class="edash-drop-item d-flex align-items-center justify-content-center rounded-pill ht-40" id="edash-menu-show" > <i class="fi fi-sr-arrow-left"></i> </a> </div> <!--! End:: edash-menu-toggle !--> <!--! Start:: edash-search-wrapper !--> <div class="edash-search-wrapper"> <a href="javascript:void(0);" class="edash-drop-item d-flex align-items-center justify-content-center rounded-pill wd-40 ht-40 ms-1" id="edash-search-show" > <i class="fi fi-rr-search"></i> </a> <form action="#" class="edash-search position-absolute start-0 top-0 end-0 bottom-0 w-100 z-1090" > <div class="input-group ps-3 ps-md-4 pe-md-2 bg-body-tertiary rounded-3" style="height: calc(5rem - 0.75rem)" > <span class="input-group-text border-0"> <i class="fi fi-rr-search"></i> </span> <input type="text" class="form-control border-0 fw-medium text-muted" placeholder="Search...." /> <span class="input-group-text border-0" id="edash-search-hide"> <button type="button" class="btn-close"></button> </span> </div> </form> </div> <!--! End:: edash-search-wrapper !--> </div> <!--! End:: edash-header-left !--> <!--! Start:: edash-header-right !--> <div class="edash-header-right d-flex align-items-center gap-1 gap-sm-2"> <!--! Start:: edash-language !--> <!--! End:: edash-language !--> <!--! Start:: theme-switcher !--> <div class="dropdown"> <svg xmlns="http://www.w3.org/2000/svg" class="d-none"> <symbol id="sun-fill" viewBox="0 0 24 24"> <path d="M12,17c-2.76,0-5-2.24-5-5s2.24-5,5-5,5,2.24,5,5-2.24,5-5,5Zm0-8c-1.65,0-3,1.35-3,3s1.35,3,3,3,3-1.35,3-3-1.35-3-3-3Zm1-5V1c0-.55-.45-1-1-1s-1,.45-1,1v3c0,.55,.45,1,1,1s1-.45,1-1Zm0,19v-3c0-.55-.45-1-1-1s-1,.45-1,1v3c0,.55,.45,1,1,1s1-.45,1-1ZM5,12c0-.55-.45-1-1-1H1c-.55,0-1,.45-1,1s.45,1,1,1h3c.55,0,1-.45,1-1Zm19,0c0-.55-.45-1-1-1h-3c-.55,0-1,.45-1,1s.45,1,1,1h3c.55,0,1-.45,1-1ZM6.71,6.71c.39-.39,.39-1.02,0-1.41l-2-2c-.39-.39-1.02-.39-1.41,0s-.39,1.02,0,1.41l2,2c.2,.2,.45,.29,.71,.29s.51-.1,.71-.29Zm14,14c.39-.39,.39-1.02,0-1.41l-2-2c-.39-.39-1.02-.39-1.41,0s-.39,1.02,0,1.41l2,2c.2,.2,.45,.29,.71,.29s.51-.1,.71-.29Zm-16,0l2-2c.39-.39,.39-1.02,0-1.41s-1.02-.39-1.41,0l-2,2c-.39,.39-.39,1.02,0,1.41,.2,.2,.45,.29,.71,.29s.51-.1,.71-.29ZM18.71,6.71l2-2c.39-.39,.39-1.02,0-1.41s-1.02-.39-1.41,0l-2,2c-.39,.39-.39,1.02,0,1.41,.2,.2,.45,.29,.71,.29s.51-.1,.71-.29Z" ></path> </symbol> <symbol id="moon-stars-fill" viewBox="0 0 24 24"> <path d="M15,24a12.021,12.021,0,0,1-8.914-3.966,11.9,11.9,0,0,1-3.02-9.309A12.122,12.122,0,0,1,13.085.152a13.061,13.061,0,0,1,5.031.205,2.5,2.5,0,0,1,1.108,4.226c-4.56,4.166-4.164,10.644.807,14.41a2.5,2.5,0,0,1-.7,4.32A13.894,13.894,0,0,1,15,24Zm.076-22a10.793,10.793,0,0,0-1.677.127,10.093,10.093,0,0,0-8.344,8.8A9.927,9.927,0,0,0,7.572,18.7,10.476,10.476,0,0,0,18.664,21.43a.5.5,0,0,0,.139-.857c-5.929-4.478-6.4-12.486-.948-17.449a.459.459,0,0,0,.128-.466.49.49,0,0,0-.356-.361A10.657,10.657,0,0,0,15.076,2Z" ></path> </symbol> <symbol id="circle-half" viewBox="0 0 24 24"> <path d="M12,0C5.38,0,0,5.38,0,12s5.38,12,12,12,12-5.38,12-12S18.62,0,12,0Zm0,22V2c5.51,0,10,4.49,10,10s-4.49,10-10,10Z" ></path> </symbol> </svg> <a href="javascript:void(0);" class="edash-drop-item d-flex align-items-center justify-content-center rounded-pill wd-40 ht-40" id="bd-theme" aria-expanded="false" data-bs-toggle="dropdown" aria-label="Toggle theme (dark)" data-bs-auto-close="outside" data-bs-offset="0, 19" > <svg class="theme-icon-active wd-20 ht-20" fill="currentColor"> <use href="#moon-stars-fill"></use> </svg> </a> <ul class="dropdown-menu dropdown-menu-end min-wd-200"> <li> <a href="javascript:void(0);" class="dropdown-item" data-bs-theme-value="light" > <svg class="theme-icon" fill="currentColor" width="16" height="16" > <use href="#sun-fill"></use> </svg> <span class="ms-3">Light</span> </a> </li> <li> <a href="javascript:void(0);" class="dropdown-item" data-bs-theme-value="dark" > <svg class="theme-icon" fill="currentColor" width="16" height="16" > <use href="#moon-stars-fill"></use> </svg> <span class="ms-3">Dark</span> </a> </li> <li> <a href="javascript:void(0);" class="dropdown-item" data-bs-theme-value="auto" > <svg class="theme-icon" fill="currentColor" width="16" height="16" > <use href="#circle-half"></use> </svg> <span class="ms-3">Auto</span> </a> </li> </ul> </div> <!--! End:: theme-switcher !--> <!--! Start:: edash-profile !--> <div class="dropdown"> <a href="javascript:void(0);" class="edash-drop-item d-flex align-items-center justify-content-center rounded-pill wd-40 ht-40" data-bs-toggle="dropdown" data-bs-auto-close="outside" data-bs-offset="0, 19" > <div class="avatar avatar-md rounded-circle"> <img src="../assets/images/logo/logo.png" alt="Avatar" class="img-fluid rounded-circle" /> <div class="avatar-indicator active"></div> </div> </a> <div class="dropdown-menu dropdown-menu-end dropdown-md p-0"> <div class="px-4 py-3 d-flex border-bottom"> <div class="avatar avatar-md flex-shrink-0"> <img src="../assets/images/logo/logo.png" alt="Avatar" class="img-fluid rounded" /> </div> <div class="flex-grow-1 ms-3"> <?php if(isset($_SESSION['user_email'])){ $user_email = $_SESSION['user_email']; date_default_timezone_set('America/Los_angeles'); //echo '<a class="dropdown-item">你好,"echo .$username;"</a>'; // echo "欢迎回来,".$usernames; echo '<h6 class="text-dark mb-1">' .$user_email . '</h6>'; echo '<span class="fs-13 text-muted">' . date('Y-m-d H:i:s') . '</span>'; }else{ echo '<h6 class="text-dark mb-1">未登录</h6>'; date_default_timezone_set('America/Los_angeles'); echo '<span class="fs-13 text-muted">' . date('Y-m-d H:i:s') . '</span>'; } ?> </div> </div> <div class="px-2 py-3"> <?php session_start(); echo '<a href="../index.php" class="dropdown-item"> <i class="fi fi-rs-"></i> <span class="ms-3">首页</span> </a>'; echo '<a href="pot.php" class="dropdown-item"> <i class="fi fi-rs-"></i> <span class="ms-3">pot</span> </a>'; echo '<a href="../works/ws.php" class="dropdown-item"> <i class="fi fi-rs-"></i> <span class="ms-3">排班表</span> </a>'; echo '<a href="jobresponsibilities.php" class="dropdown-item"> <i class="fi fi-rs-"></i> <span class="ms-3">DWD</span> </a>'; echo '<a href="../clipboard.php" class="dropdown-item"> <i class="fi fi-rs-"></i> <span class="ms-3">叫货</span> </a>'; echo '<a href="index.php" class="dropdown-item"> <i class="fi fi-rs-"></i> <span class="ms-3">Schedule</span> </a>'; echo '<a href="employee.php" class="dropdown-item"> <i class="fi fi-rs-"></i> <span class="ms-3">employee</span> </a>'; echo '<div class="dropdown-divider"></div>'; echo '<div class="dropdown-divider"></div>'; echo '<a href="../logout.php" class="dropdown-item text-danger" name="logout"> <i class="fi fi-rr-exit"></i> <span class="ms-3">Logout</span> </a>'; ?> </div> </div> </div> <!--! End:: edash-profile !--> </div> <!--! End:: edash-header-right !--> </div> </header> <!--! ================================================================ !--> <!--! End:: Header !--> <!--! ================================================================ !--> <!--! ================================================================ !--> <!--! Start:: Page Content !--> <!--! ================================================================ !--> <div class="edash-page-container container-xxl" id="edash-page-container" > <!--! Start:: Breadcumb !--> <div class="edash-content-breadcumb row mb-4 mb-md-6 pt-md-2"> <div class="col-12"> <div class="d-flex align-items-center justify-content-between"> <div> <nav aria-label="breadcrumb"> <ol class="breadcrumb mb-0"> <li class="breadcrumb-item"> <a href="addplan.php" class="btn btn-md btn-primary">add plan</a> </li> </ol> </nav> </div> <div class="d-flex align-items-center gap-2"> <a href="javascript:void(0);" class="btn btn-md btn-primary" id="addKanbanBoard" data-bs-toggle="modal" data-bs-target="#addBoardModal"> add people </a> </div> </div> </div> </div> <!--! End:: Breadcumb !--> <!--! Start:: Content Section !--> <div class="edash-content-section row g-3 g-md-4"> <!-- Start:: tableGapHover --> <div class="col-12"> <div class="card"> <div class="card-header"> <h4 class="card-title">Schedule</h4> </div> <div class="card-body p-0"> <div class="table-responsive"> <table class="table-gap-hover table table-hover overflow-hidden mb-0 px-4" style=" border-spacing: 0 0.75rem; border-collapse: separate; " > <thead> <tr> <th scope="col" class="border-top border-start">Monday</th> <th scope="col" class="border-top">Tuesday</th> <th scope="col" class="border-top">Wednesday</th> <th scope="col" class="border-top">Thursday</th> <th scope="col" class="border-top">Friday</th> <th scope="col" class="border-top">Saturday</th> <th scope="col" class="border-top">Sunday</th> <th scope="col" class="text-end border-top border-end" > Action </th> </tr> </thead> <tbody> <?php // 数据库连接配置 $host = "localhost"; $dbname = "t001"; $username = "t001"; $password = "ZRTsRb6Ycp585AEC"; try { $pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die('数据库连接失败: ' . $e->getMessage()); } // 查询员工班次数据 $stmt = $pdo->prepare("SELECT * FROM employee_schedule"); $stmt->execute(); $schedules = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <?php foreach ($schedules as $schedule): ?> <tr> <!-- Monday --> <td class="border-top border-start"> <a><?php echo htmlspecialchars($schedule['employee_name']); ?></a> <a href="javascript:void(0)" class="badge <?php echo $schedule['monday_status'] === 'AM' ? 'bg-primary-subtle text-primary' : ($schedule['monday_status'] === 'PM' ? 'bg-secondary-subtle text-secondary' : 'bg-danger-subtle text-danger'); ?>" data-bs-toggle="modal" data-bs-target="#editShiftModal" data-employee="<?php echo htmlspecialchars($schedule['employee_name']); ?>" data-day="Monday" data-status="<?php echo htmlspecialchars($schedule['monday_status']); ?>"> <?php echo htmlspecialchars($schedule['monday_status']); ?> </a> </td> <!-- Repeat for Tuesday to Sunday --> <?php $days = ['Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']; foreach ($days as $day): $day_status = strtolower($day) . '_status'; // 动态获取字段名 ?> <td class="border-top"> <a><?php echo htmlspecialchars($schedule['employee_name']); ?></a> <a href="javascript:void(0)" class="badge <?php echo $schedule[$day_status] === 'AM' ? 'bg-primary-subtle text-primary' : ($schedule[$day_status] === 'PM' ? 'bg-secondary-subtle text-secondary' : 'bg-danger-subtle text-danger'); ?>" data-bs-toggle="modal" data-bs-target="#editShiftModal" data-employee="<?php echo htmlspecialchars($schedule['employee_name']); ?>" data-day="<?php echo $day; ?>" data-status="<?php echo htmlspecialchars($schedule[$day_status]); ?>"> <?php echo htmlspecialchars($schedule[$day_status]); ?> </a> </td> <?php endforeach; ?> <td class="text-end border-top border-end"> <a href="delete_schedule.php?id=<?php echo $schedule['id']; ?>" class="btn btn-icon btn-sm btn-light rounded-pill delete-btn" onclick="return confirm('确定要删除该员工的班次吗?');"> <i class="fi fi-bs-delete"></i> </a> </td> </tr> <?php endforeach; ?> <div class="modal fade" id="editShiftModal" tabindex="-1" aria-labelledby="editShiftModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="editShiftModalLabel">Edit Shift</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <form id="editShiftForm"> <input type="hidden" id="employeeName" name="employee_name"> <input type="hidden" id="day" name="day"> <div class="mb-3"> <label for="shiftStatus" class="form-label">Shift Status</label> <select class="form-select" id="shiftStatus" name="shift_status"> <option value="AM">AM</option> <option value="PM">PM</option> <option value="Off">Off</option> </select> </div> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> <button type="button" class="btn btn-primary" onclick="saveShift()">Save</button> </div> </div> </div> </div> <!-- <tr> <td class="border-top border-start"> <a >employee_name</a> <a href="javascript:void(0)" class="badge bg-success-subtle text-success" >am</a > </td> <td class="border-top "> <a >employee_name</a> <a href="javascript:void(0)" class="badge bg-success-subtle text-success" >am</a > </td> <td class="border-top "> <a >employee_name</a> <a href="javascript:void(0)" class="badge bg-success-subtle text-success" >am</a > </td> <td class="border-top "> <a >employee_name</a> <a href="javascript:void(0)" class="badge bg-success-subtle text-success" >am</a > </td> <td class="border-top "> <a >employee_name</a> <a href="javascript:void(0)" class="badge bg-success-subtle text-success" >am</a > </td> <td class="border-top "> <a >employee_name</a> <a href="javascript:void(0)" class="badge bg-success-subtle text-success" >am</a > </td> <td class="border-top "> <a >employee_name</a> <a href="javascript:void(0)" class="badge bg-success-subtle text-success" >am</a > </td> <td class="text-end border-top border-end"><a href="" class="btn btn-icon btn-sm btn-light rounded-pill"><i class="fi fi-bs-menu-dots-vertical"></i></a></td> </tr> --> </tbody> </table> </div> </div> </div> </div> <!-- End:: tableGapHover <div class="col-12"> <div class="card"> <div class="card-header"> <h4 class="card-title">遍历name放在这里</h4> </div> <div class="card-body p-0"> <div class="table-responsive"> <div class="card-body"> <div class="d-flex flex-wrap align-items-center gap-1"> <button type="button" class="btn rounded-circle btn-primary btn-icon"> 23 </button> </div> </div> </div> </div> </div> </div> --> <?php // Database connection details $servername = "localhost"; $username = "t001"; $password = "ZRTsRb6Ycp585AEC"; // Your database password $dbname = "t001"; // Replace with your database name // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Fetch employee names and their daily records $sql = "SELECT e.name, d.id AS day_id, d.day_of_month, d.status FROM employees e JOIN employee_days d ON e.id = d.employee_id ORDER BY e.name, d.day_of_month"; $result = $conn->query($sql); $currentEmployee = null; ?> <?php $monthYear = date("F, Y"); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $name = htmlspecialchars($row['name']); $day = htmlspecialchars($row['day_of_month']); $status = htmlspecialchars($row['status']); $dayId = htmlspecialchars($row['day_id']); // Unique ID for the day // Start a new card for each employee if ($currentEmployee !== $name) { if ($currentEmployee !== null) { // Close previous card } echo ' <div class="col-12"> <div class="card"> <div class="card-header d-flex justify-content-between"> <h4 class="card-title">' . $name . ' - ' . $monthYear . '</h4> <form method="POST" action="delete_employee.php" onsubmit="return confirm(\'Are you sure you want to delete ' . $name . '?\')"> <input type="hidden" name="employee_name" value="' . $name .'"> <button type="submit" class="btn btn-secondary btn-sm">Delete</button> </form> </div> <div class="card-body p-0"> <div class="table-responsive"> <div class="d-flex flex-wrap align-items-center gap-1">'; $currentEmployee = $name; } // Directly map the database status to button classes $statusToClassMap = [ 'v' => 'btn-primary', // Blue for 'v' 'x' => 'btn-light', // White for 'x' 'Off' => 'btn-danger' // Red for 'off' ]; // Get the badge class from the map, default to 'btn-secondary' if status is unknown $badgeClass = $statusToClassMap[$status] ?? 'btn-danfer'; // Display button echo '<button type="button" class="btn rounded-circle ' . $badgeClass . ' btn-icon" data-day-id="' . $dayId . '" data-status="' . $status . '" data-day="' . $day . '" data-bs-toggle="modal" data-bs-target="#editModal">'; echo $day; echo '</button>'; } // Close the last card echo '</div></div></div></div></div>'; } else { echo '<p>No data available.</p>'; } ?> <script> // Handle modal opening document.addEventListener('DOMContentLoaded', function () { const editModal = document.getElementById('editModal'); const editForm = document.getElementById('editForm'); const saveChanges = document.getElementById('saveChanges'); editModal.addEventListener('show.bs.modal', function (event) { const button = event.relatedTarget; const dayId = button.getAttribute('data-day-id'); const status = button.getAttribute('data-status'); // Fill form fields document.getElementById('dayId').value = dayId; document.getElementById('status').value = status; }); saveChanges.addEventListener('click', function () { const formData = new FormData(editForm); fetch('update_status.php', { method: 'POST', body: formData }) .then(response => response.json()) .then(data => { if (data.success) { const dayId = document.getElementById('dayId').value; const newStatus = document.getElementById('status').value; const button = document.querySelector(`[data-day-id="${dayId}"]`); // Status to class mapping const statusToClassMap = { 'v': 'btn-primary', 'x': 'btn-light', 'off': 'btn-danger' }; // Get the badge class, default to 'btn-secondary' const newClass = statusToClassMap[newStatus] || 'btn-danger'; // Update button text and class button.textContent = newStatus; button.className = 'btn rounded-circle btn-icon ' + newClass; // Close modal const bootstrapModal = bootstrap.Modal.getInstance(editModal); bootstrapModal.hide(); } else { alert('Error updating status: ' + data.message); } }) .catch(error => { console.error('Error:', error); alert('An error occurred while updating the status.'); }); }); }); </script> <!-- Modal --> <div class="modal fade" id="editModal" tabindex="-1" aria-labelledby="editModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="editModalLabel">Edit Day Status</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <form id="editForm"> <input type="hidden" id="dayId" name="dayId"> <label for="status" class="form-label">Select Status</label> <select id="status" name="status" class="form-select"> <option value="v">V</option> <option value="x">X</option> <option value="Off">Off</option> </select> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> <button type="button" class="btn btn-primary" id="saveChanges">Save changes</button> </div> </div> </div> </div> </div> <!-- Start:: {Options} --> <!-- End:: {Options} --> </div> <!--! End:: Content Section !--> </div> <!--! ================================================================ !--> <!--! End:: Page Content !--> <div class="modal fade" id="addBoardModal" role="dialog" aria-labelledby="addBoardModalTitle" aria-modal="false"> <div class="modal-dialog modal-dialog-centered modal-sm" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title add-list-title" id="addBoardModalTitleLabel1">Add Name</h5> </div> <div class="modal-body"> <form action="add_ws.php" method="POST"> <div class="list-title d-flex align-items-center"> <input type="text" name="name" class="form-control" placeholder="Add name...." required> </div> <div class="d-grid mt-4"> <button type="submit" class="btn add-list btn-primary w-100">Submit</button> </div> </form> </div> </div> </div> </div> <!--! ================================================================ !--> <!--! ================================================================ !--> <!--! Start:: Footer !--> <!--! ================================================================ !--> <footer class="edash-footer-container container-xxl d-flex align-items-center justify-content-between rounded-3 p-4 mx-auto mb-3 ht-64 bg-body-tertiary" id="edash-footer-container" > <div class="hstack"> <span class="text-muted"> <script> const now = new Date(); // 获取星期名称 const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; const dayName = days[now.getDay()]; // 获取月份名称 const months = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; const monthName = months[now.getMonth()]; // 获取日期和年份 const date = now.getDate(); const year = now.getFullYear(); // 拼接成需要的格式 const formattedDate = `${dayName}, ${monthName} ${date}, ${year}`; // 输出 document.write(formattedDate); </script> © </span> <span class="vr mx-2 bg-body-secondary"></span> </div> </footer> <!--! ================================================================ !--> <!--! End:: Footer !--> <!--! ================================================================ !--> </main> <!--! ================================================================ !--> <!--! End:: Main Content !--> <!--! ================================================================ !--> <div class="edash-menu-backdrop" id="edash-menu-hide"></div> </div> <!--! ================================================================ !--> <!--! End:: Main Wrapper !--> <!--! ================================================================ !--> <script> // 等待 DOM 加载完成 document.addEventListener("DOMContentLoaded", function () { const modal = document.getElementById("addBoardModal"); // 获取模态框 const addButton = document.getElementById("addKanbanBoard"); // 获取按钮 // 点击按钮时显示模态框 addButton.addEventListener("click", function () { modal.style.display = "block"; // 显示模态框 modal.classList.add("show"); // 添加 Bootstrap 的 'show' 类 modal.setAttribute("aria-modal", "true"); // 确保无障碍支持 }); // 点击关闭按钮时隐藏模态框 modal.querySelector(".btn-close").addEventListener("click", function () { modal.style.display = "none"; // 隐藏模态框 modal.classList.remove("show"); // 移除 'show' 类 modal.setAttribute("aria-modal", "false"); // 更新无障碍支持 }); }); document.addEventListener('DOMContentLoaded', () => { const editShiftModal = document.getElementById('editShiftModal'); editShiftModal.addEventListener('show.bs.modal', function (event) { const link = event.relatedTarget; // 获取触发模态框的 <a> 标签 const employeeName = link.getAttribute('data-employee'); const day = link.getAttribute('data-day'); const status = link.getAttribute('data-status'); // 填充模态框表单 document.getElementById('employeeName').value = employeeName; document.getElementById('day').value = day; document.getElementById('shiftStatus').value = status; }); }); function saveShift() { const form = document.getElementById('editShiftForm'); const formData = new FormData(form); fetch('update_shift.php', { method: 'POST', body: formData, }) .then(response => response.json()) .then(data => { if (data.success) { const employeeName = formData.get('employee_name'); const day = formData.get('day'); const newStatus = formData.get('shift_status'); // 更新表格中的 <a> 标签内容 const link = document.querySelector( `a[data-employee="${employeeName}"][data-day="${day}"]` ); link.textContent = newStatus; link.className = 'badge ' + (newStatus === 'AM' ? 'bg-primary-subtle text-primary' : (newStatus === 'PM' ? 'bg-secondary-subtle text-secondary' : 'bg-danger-subtle text-danger')); // 关闭模态框 const modal = bootstrap.Modal.getInstance(document.getElementById('editShiftModal')); modal.hide(); } else { alert('Failed to update shift: ' + data.message); } }) .catch(error => { console.error('Error:', error); alert('An error occurred while updating the shift.'); }); } </script> <!--! ================================================================ !--> <!--! Footer Script !--> <!--! ================================================================ !--> <!--! BEGIN: Common Vendors !--> <script src="./../assets/js/vendors.min.js"></script> <!--! END: Common Vendors !--> <!--! BEGIN: Apps Common Init !--> <script src="./../assets/js/common-init.min.js"></script> <!--! END: Apps Common Init !--> <!--! BEGIN: Page Vendors -!--> <!--! END: Page Vendors -!--> </body> </html>
Simpan