<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>QualityFlow - Endline Table</title>
    <link rel="icon" type="image/png" href="<?php echo e(asset('gplogofinal.png')); ?>">
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap" rel="stylesheet">
    
    <style>
        body {
            font-family: 'Roboto', sans-serif;
            background-color: #f5f6f8; /* Light gray background */
        }
        
        /* Summary Card Styling */
        .summary-card {
            background-color: white;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.03); /* Soft shadow */
            border: 1px solid rgba(0,0,0,0.05); /* very subtle border */
            padding: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 100%;
            transition: transform 0.2s, box-shadow 0.2s;
        }

        .summary-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.06);
        }

        .summary-card-left {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .summary-icon-wrapper {
            width: 45px;
            height: 45px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: #f8f9fa; /* minimal gray circle */
            border: 1px solid #e9ecef;
        }

        .summary-icon-wrapper i {
            font-size: 1.25rem;
            color: #adb5bd; /* subtle gray icon color */
        }

        .summary-title {
            font-size: 0.70rem;
            font-weight: 700;
            color: #8c98a4;
            letter-spacing: 0.8px;
            text-transform: uppercase;
            margin: 0;
            white-space: nowrap;
        }

        .summary-value {
            font-size: 2.2rem;
            font-weight: 700;
            margin: 0;
            line-height: 1;
        }
        
        /* Metric Specific Colors for Values */
        .val-checked { color: #1a1e23; } /* Black/Dark Gray */
        .val-passed { color: #0d9656; } /* Green */
        .val-first-pass { color: #00c853; } /* Lighter Green */
        .val-rejection { color: #d32f2f; } /* Red */
        .val-rework-total { color: #2b4cc4; } /* Blue */
        .val-rework-completed { color: #1976d2; } /* Lighter Blue */
        .val-rework-pending { color: #e65100; } /* Orange */
        .val-rework-pending-yesterday { color: #a1640e; } /* Brown/Dark Orange */
        
        /* Table Card Styling */
        .table-card {
            background-color: white;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.03); /* Soft shadow */
            border: 1px solid rgba(0,0,0,0.05); /* very subtle border */
            overflow: hidden; /* round corners for table */
            margin-top: 2rem;
            margin-bottom: 4rem;
        }

        .table-responsive {
            margin: 0;
        }

        .custom-table {
            margin-bottom: 0;
            width: 100%;
        }

        .custom-table th {
            font-size: 0.75rem;
            font-weight: 700;
            color: #8c98a4;
            letter-spacing: 0.8px;
            text-transform: uppercase;
            padding: 1.2rem 1.5rem;
            border-bottom: 1px solid #e2e6f0;
            background-color: transparent;
            text-align: center;
        }

        /* Metric Column Header Align Left */
        .custom-table th:first-child {
            text-align: left;
        }

        .custom-table td {
            font-size: 1.1rem;
            font-weight: 600;
            padding: 1.5rem 1.5rem;
            border-bottom: 1px solid #f0f2f5;
            vertical-align: middle;
            text-align: center;
        }

        /* Metric Column Value Align Left & Styling */
        .custom-table td:first-child {
            text-align: left;
            font-size: 0.8rem;
            font-weight: 600;
            color: #495057; /* Darker gray for row labels */
            text-transform: uppercase;
        }

        .custom-table tr:last-child td {
            border-bottom: none;
        }
        
    </style>
</head>
<body>

    <?php
        $emp_checker = session('endline_checker');
        $emp_id_from_session = $emp_checker ? $emp_checker['employee_id'] : '';
    ?>

    <!-- Injecting the navigation bar blade components -->
    <?php echo $__env->make('Quality.Endline_nav', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <!-- Dashboard Content -->
     <div class="container-fluid px-4 px-lg-5 mt-5">
        
        <!-- Top Metrics Cards Row 1 -->
        <div class="row g-4 mb-4">
            <!-- Checked -->
            <div class="col-12 col-md-6 col-lg-3">
                <div class="summary-card">
                    <div class="summary-card-left">
                        <div class="summary-icon-wrapper">
                            <i class="bi bi-bullseye"></i>
                        </div>
                        <h3 class="summary-title">CHECKED</h3>
                    </div>
                    <p class="summary-value val-checked"><?php echo e($resultdata[0]->checked); ?></p>
                </div>
            </div>
            
            <!-- Passed -->
            <div class="col-12 col-md-6 col-lg-3">
                <div class="summary-card">
                    <div class="summary-card-left">
                        <div class="summary-icon-wrapper">
                            <i class="bi bi-check2"></i>
                        </div>
                        <h3 class="summary-title">PASSED</h3>
                    </div>
                    <p class="summary-value val-passed"><?php echo e($resultdata[0]->passed ?? 0); ?></p>
                </div>
            </div>

            <!-- First Pass -->
            <div class="col-12 col-md-6 col-lg-3">
                <div class="summary-card">
                    <div class="summary-card-left">
                        <div class="summary-icon-wrapper">
                            <i class="bi bi-shield-check"></i>
                        </div>
                        <h3 class="summary-title">FIRST PASS</h3>
                    </div>
                    <p class="summary-value val-first-pass"><?php echo e($resultdata[0]->first_pass ?? 0); ?></p>
                </div>
            </div>

            <!-- Rejection -->
            <div class="col-12 col-md-6 col-lg-3">
                <div class="summary-card">
                    <div class="summary-card-left">
                        <div class="summary-icon-wrapper">
                            <i class="bi bi-exclamation-octagon"></i>
                        </div>
                        <h3 class="summary-title">REJECTION</h3>
                    </div>
                    <p class="summary-value val-rejection"><?php echo e($resultdata[0]->rejection ?? 0); ?></p>
                </div>
            </div>
        </div>

        <!-- Top Metrics Cards Row 2 -->
        <div class="row g-4">
            <!-- Rework Total -->
            <div class="col-12 col-md-6 col-lg-3">
                <div class="summary-card">
                    <div class="summary-card-left">
                        <div class="summary-icon-wrapper">
                            <i class="bi bi-arrow-repeat"></i>
                        </div>
                        <h3 class="summary-title">REWORK TOTAL</h3>
                    </div>
                    <p class="summary-value val-rework-total"><?php echo e($resultdata[0]->rework_total ?? 0); ?></p>
                </div>
            </div>
            
            <!-- Rework Completed -->
            <div class="col-12 col-md-6 col-lg-3">
                <div class="summary-card">
                    <div class="summary-card-left">
                        <div class="summary-icon-wrapper">
                            <i class="bi bi-check-circle"></i>
                        </div>
                        <h3 class="summary-title">REWORK COMPLETED</h3>
                    </div>
                    <p class="summary-value val-rework-completed"><?php echo e($resultdata[0]->rework_completed_today +   $resultdata[0]->rework_passed); ?></p>
                </div>
            </div>

            <!-- Rework Pending -->
            <div class="col-12 col-md-6 col-lg-3">
                <div class="summary-card">
                    <div class="summary-card-left">
                        <div class="summary-icon-wrapper">
                            <i class="bi bi-clock-history"></i>
                        </div>
                        <h3 class="summary-title">REWORK PENDING</h3>
                    </div>
                    <p class="summary-value val-rework-pending"><?php echo e($resultdata[0]->rework_pending); ?></p>
                </div>
            </div>

            <!-- Rework Pending Yesterday -->
            <div class="col-12 col-md-6 col-lg-3">
                <div class="summary-card">
                    <div class="summary-card-left">
                        <div class="summary-icon-wrapper">
                            <i class="bi bi-arrow-counterclockwise"></i>
                        </div>
                        <h3 class="summary-title">REWORK PENDING YESTERDAY</h3>
                    </div>
                    <p class="summary-value val-rework-pending-yesterday"><?php echo e($resultdata[0]->rework_pending_yesterday); ?></p>
                </div>
            </div>
        </div>

        <!-- Hourly Metrics Data Table -->
        <div class="table-card">
            <div class="table-responsive">
                <table class="table custom-table table-borderless">
                    <thead>
                        <tr>
                            <th>METRIC</th>
                            <th>H1</th>
                            <th>H2</th>
                            <th>H3</th>
                            <th>H4</th>
                            <th>H5</th>
                            <th>H6</th>
                            <th>H7</th>
                            <th>H8</th>
                        </tr>
                    </thead>
                    <tbody>
                        <!-- Checked Row -->
                        
                        <!-- Passed Row -->
                        <?php $__currentLoopData = $resultdata_hourly; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $hourly): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($hourly->Metric); ?></td>
                            <td class="val-checked"><?php echo e($hourly->H1); ?></td>
                            <td class="val-checked"><?php echo e($hourly->H2); ?></td>
                            <td class="val-checked"><?php echo e($hourly->H3); ?></td>
                            <td class="val-checked"><?php echo e($hourly->H4); ?></td>
                            <td class="val-checked"><?php echo e($hourly->H5); ?></td>
                            <td class="val-checked"><?php echo e($hourly->H6); ?></td>
                            <td class="val-checked"><?php echo e($hourly->H7); ?></td>
                            <td class="val-checked"><?php echo e($hourly->H8); ?></td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div>

    </div>

    <!-- External Script Dependencies (jQuery & Bootstrap) -->
    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        $(document).ready(function() {
            // Document is ready
            console.log("Endline Table page initialized.");
            $('#garmentIdDiv').addClass('d-none');
            

            // Prefer sessionStorage, but fall back to server session if user bypassed the scan page
            var serverEmpId = "<?php echo e($emp_id_from_session); ?>";
            var JSempId = sessionStorage.getItem('emp_id');
            var empId = JSempId ? JSempId : serverEmpId;
            
            // Sync it back to storage if it was missing
            if (empId && !JSempId) {
                sessionStorage.setItem('emp_id', empId);
            }

            var lineNo = sessionStorage.getItem('endline_line_no');
            var group = sessionStorage.getItem('endline_group');

            $('#navScanNext').click(function() {
                window.location.href = "<?php echo e(route('endline.selection')); ?>";
            });

            console.log("Employee ID: " + empId);
            console.log("Line No: " + lineNo + ", Group: " + group);
            
        });
    </script>
</body>
</html>
<?php /**PATH C:\Apache24\htdocs\Quality_Endline\Endline\resources\views/Quality/Endline_tablepage.blade.php ENDPATH**/ ?>