

<?php $__env->startSection('title', 'QC Details - ' . $qc->qc_number); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h4 class="card-title">QC Inspection Details - <?php echo e($qc->qc_number); ?></h4>
                    <div class="card-tools">
                        <a href="<?php echo e(route('qcs.index')); ?>" class="btn btn-secondary">
                            <i class="fas fa-arrow-left"></i> Back to QC List
                        </a>
                        <?php if($qc->status === 'pending'): ?>
                        <a href="<?php echo e(route('qcs.create', $qc->grn)); ?>" class="btn btn-primary">
                            <i class="fas fa-edit"></i> Edit QC
                        </a>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="card-body">
                    <!-- QC Information -->
                    <div class="row mb-4">
                        <div class="col-md-6">
                            <h5>QC Information</h5>
                            <table class="table table-sm">
                                <tr>
                                    <td><strong>QC Number:</strong></td>
                                    <td><?php echo e($qc->qc_number); ?></td>
                                </tr>
                                <tr>
                                    <td><strong>Status:</strong></td>
                                    <td>
                                        <span class="badge bg-<?php echo e($qc->status === 'pending' ? 'warning' : ($qc->status === 'completed' ? 'success' : ($qc->status === 'cancelled' ? 'danger' : 'info'))); ?>">
                                            <?php echo e(ucfirst(str_replace('_', ' ', $qc->status))); ?>

                                        </span>
                                    </td>
                                </tr>
                                <tr>
                                    <td><strong>Inspector:</strong></td>
                                    <td><?php echo e($qc->inspector->name ?? 'N/A'); ?></td>
                                </tr>
                                <tr>
                                    <td><strong>Inspected At:</strong></td>
                                    <td><?php echo e($qc->inspected_at ? $qc->inspected_at->format('d/m/Y H:i') : 'N/A'); ?></td>
                                </tr>
                                <tr>
                                    <td><strong>Created:</strong></td>
                                    <td><?php echo e($qc->created_at->format('d/m/Y H:i')); ?></td>
                                </tr>
                                <?php if($qc->status === 'cancelled'): ?>
                                <tr>
                                    <td><strong>Cancelled By:</strong></td>
                                    <td><?php echo e($qc->cancelledBy->name ?? 'N/A'); ?></td>
                                </tr>
                                <tr>
                                    <td><strong>Cancelled At:</strong></td>
                                    <td><?php echo e($qc->cancelled_at ? $qc->cancelled_at->format('d/m/Y H:i') : 'N/A'); ?></td>
                                </tr>
                                <tr>
                                    <td><strong>Reason:</strong></td>
                                    <td><?php echo e($qc->cancelled_reason ?? 'N/A'); ?></td>
                                </tr>
                                <?php endif; ?>
                            </table>
                        </div>
                        <div class="col-md-6">
                            <h5>GRN Information</h5>
                            <table class="table table-sm">
                                <tr>
                                    <td><strong>GRN Number:</strong></td>
                                    <td><?php echo e($qc->grn->grn_number); ?></td>
                                </tr>
                                <tr>
                                    <td><strong>PO Number:</strong></td>
                                    <td><?php echo e($qc->grn->purchaseOrder->po_number); ?></td>
                                </tr>
                                <tr>
                                    <td><strong>Supplier:</strong></td>
                                    <td><?php echo e($qc->grn->purchaseOrder->vendor->name); ?></td>
                                </tr>
                                <tr>
                                    <td><strong>Received Date:</strong></td>
                                    <td><?php echo e($qc->grn->received_date->format('d/m/Y')); ?></td>
                                </tr>
                                <tr>
                                    <td><strong>GRN Status:</strong></td>
                                    <td>
                                        <span class="badge bg-<?php echo e($qc->grn->status === 'accepted' ? 'success' : ($qc->grn->status === 'rejected' ? 'danger' : 'warning')); ?>">
                                            <?php echo e(ucfirst($qc->grn->status)); ?>

                                        </span>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>

                    <!-- QC Summary -->
                    <?php if($qc->status === 'completed'): ?>
                    <div class="row mb-4">
                        <div class="col-md-12">
                            <h5>QC Summary</h5>
                            <div class="row">
                                <div class="col-md-3">
                                    <div class="info-box bg-success">
                                        <div class="info-box-content p-3">
                                            <h6>Total Passed</h6>
                                            <h4><?php echo e($qc->total_passed_qty); ?></h4>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="info-box bg-danger">
                                        <div class="info-box-content p-3">
                                            <h6>Total Failed</h6>
                                            <h4><?php echo e($qc->total_failed_qty); ?></h4>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="info-box bg-info">
                                        <div class="info-box-content p-3">
                                            <h6>Items Inspected</h6>
                                            <h4><?php echo e($qc->qcItems->count()); ?></h4>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <div class="info-box bg-warning">
                                        <div class="info-box-content p-3">
                                            <h6>Pass Rate</h6>
                                            <h4><?php echo e($qc->total_passed_qty + $qc->total_failed_qty > 0 ? round(($qc->total_passed_qty / ($qc->total_passed_qty + $qc->total_failed_qty)) * 100, 1) : 0); ?>%</h4>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>

                    <!-- QC Items -->
                    <div class="row">
                        <div class="col-md-12">
                            <h5>QC Items</h5>
                            <div class="table-responsive">
                                <table class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th>Item</th>
                                            <th>Received Qty</th>
                                            <th>Passed Qty</th>
                                            <th>Failed Qty</th>
                                            <th>Available Bin</th>
                                            <th>Rejected Bin</th>
                                            <th>Lot No</th>
                                            <th>Remarks</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $__currentLoopData = $qc->qcItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $qcItem): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td>
                                                <strong><?php echo e($qcItem->item->name); ?></strong><br>
                                                <small class="text-muted"><?php echo e($qcItem->item->sku); ?></small>
                                            </td>
                                            <td><?php echo e($qcItem->grnItem->received_quantity); ?></td>
                                            <td>
                                                <span class="badge bg-success"><?php echo e($qcItem->qty_passed); ?></span>
                                            </td>
                                            <td>
                                                <span class="badge bg-danger"><?php echo e($qcItem->qty_failed); ?></span>
                                            </td>
                                            <td>
                                                <?php if($qcItem->availableBin): ?>
                                                    <span class="badge bg-primary"><?php echo e($qcItem->availableBin->code); ?></span>
                                                <?php else: ?>
                                                    <span class="text-muted">N/A</span>
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <?php if($qcItem->rejectedBin): ?>
                                                    <span class="badge bg-secondary"><?php echo e($qcItem->rejectedBin->code); ?></span>
                                                <?php else: ?>
                                                    <span class="text-muted">N/A</span>
                                                <?php endif; ?>
                                            </td>
                                            <td><?php echo e($qcItem->lot_no ?? 'N/A'); ?></td>
                                            <td><?php echo e($qcItem->remarks ?? 'N/A'); ?></td>
                                        </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                    <!-- Remarks -->
                    <?php if($qc->remarks): ?>
                    <div class="row mt-4">
                        <div class="col-md-12">
                            <h5>General Remarks</h5>
                            <div class="alert alert-info">
                                <?php echo e($qc->remarks); ?>

                            </div>
                        </div>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\habibcables-ERP\resources\views\qcs copy\show.blade.php ENDPATH**/ ?>