<?php
include_once "global.php";

$pageTitle = "Staff Report - ";
include_once 'header.php';
?>

<style>
    @media print {
        body {
            margin: 0 auto !important;
            width: 100% !important;
            background-color: #ffffff !important;
        }

        .sidebar-wrapper,
        header,
        .page-breadcrumb {
            display: none !important;
        }

        .main-wrapper {
            margin: 0 !important;
        }

        .page-footer,
        .hide {
            display: none !important;
        }

        .DataDiv .row h6,
        strong,
        span {
            color: black !important;
        }

        .print-col-full {
            flex: 0 0 100% !important;
            max-width: 100% !important;
        }

        th,
        td,
        .alert-dark {
            background-color: white !important;
            color: black !important;
        }

        .card {
            background: white !important;
            box-shadow: none !important;
        }

        .card-body {
            padding: 0 !important;
        }

        .col-3 {
            padding-right: 0 !important;
        }

        .fullname {
            color: black !important;
        }

        .DataDiv .stat-item {
            font-size: 12px;
        }
    }
</style>
<!--breadcrumb-->
<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
    <div class="breadcrumb-title pe-3">Staff Management</div>
    <div class="ps-3">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb mb-0 p-0">
                <li class="breadcrumb-item"><a href="javascript:;"></a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Staff Report</li>
            </ol>
        </nav>
    </div>
</div>
<!--end breadcrumb-->
<div class="row">
    <div class="col-xl-12">
        <h6 class="mb-0 text-uppercase hide">Staff Report</h6>
        <hr class="hide">
        <div class="card hide">
            <div class="card-body p-4">
                <h5 class="mb-4"></h5>
                <form id="staffReportForm" class="row g-3" method="post">
                    <div class="col-md-6">
                        <label for="fromdate" class="form-label">From <span>*</span></label>
                        <input type="date" class="form-control" id="fromdate" name="fromdate">
                    </div>
                    <div class="col-md-6">
                        <label for="todate" class="form-label">To <span>*</span></label>
                        <input type="date" class="form-control" id="todate" name="todate">
                    </div>
                    <?php if ($webUserType === 1 || $webUserType === 2) { ?>
                        <div class="col-md-6">
                            <label for="userId" class="form-label">User <span>*</span></label>
                            <select id="userId" name="userId" class="form-select" required>
                                <option value="" disabled selected>Select...</option>
                                <option value="All">All Staff</option>
                                <?php
                                $users = $productClass->getStaffArray();
                                foreach ($users as $user) {
                                    $userId = $user["acc_id"];
                                    $name = $user["acc_name"];
                                    echo "<option value='$userId'>$name</option>";
                                }
                                ?>
                            </select>
                        </div>
                    <?php } else { ?>
                        <input type="hidden" name="userId" value="<?php echo $_SESSION["webUser"]["id"]; ?>">
                    <?php } ?>
                    <div class="col-md-12">
                        <button type="submit" class="btn btn-grd-primary px-4">Get Results</button>
                    </div>
                </form>
            </div>
        </div>
        <div class="AllStaffDataDiv" style="display:none;"></div>
        <div class="DataDiv" style="display: none;">
            <div class="row align-items-center">
                <div class="col-6 print-col-full">
                    <h6 class="mb-0"></h6>
                </div>
                <div class="col-6 text-end hide">
                    <a href="javascript:;" onclick="window.print()" class="btn btn-dark"><i
                            class="bi bi-printer-fill me-2"></i>Print</a>
                </div>
            </div>
            <hr>
            <div class="card">
                <div class="card-body">
                    <h5 class="fullname"></h5>
                    <div class="row my-3">
                        <div class="col-3 stat-item d-flex align-items-center">
                            <strong class="me-1">Absents:</strong> <span class="absents"></span>
                        </div>
                        <div class="col-3 stat-item d-flex align-items-center">
                            <strong class="me-1">Lates:</strong> <span class="lates"></span>
                        </div>
                        <div class="col-3 stat-item d-flex align-items-center">
                            <strong class="me-1">Presents:</strong> <span class="presents"></span>
                        </div>
                        <div class="col-3 stat-item d-flex align-items-center">
                            <strong class="me-1">Missing Out Times:</strong> <span class="missingouttimes"></span>
                        </div>

                        <div class="col-3 stat-item d-flex align-items-center">
                            <strong class="me-1">Working Hours:</strong> <span class="workinghours"></span>
                        </div>
                        <div class="col-3 stat-item d-flex align-items-center">
                            <strong class="me-1">Total Working Hours:</strong> <span class="totalWorkingHours"></span>
                        </div>
                        <div class="col-3 stat-item d-flex align-items-center">
                            <strong class="me-1">Total Working Days:</strong> <span class="totalWorkingDays"></span>
                        </div>
                    </div>
                    <table class="table table-bordered mb-0">
                        <thead>
                            <tr>
                                <th scope="col">Date</th>
                                <th scope="col">In Time</th>
                                <th scope="col">Out Time</th>
                                <th scope="col">State</th>
                                <th scope="col">Msg</th>
                            </tr>
                        </thead>
                        <tbody class="tbody-2">

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<?php
include_once 'footer.php';
?>