
<?php $__env->startSection('title', 'Production Summary Report'); ?>

<?php $__env->startPush('plugin-styles'); ?>
    <style>
        .summary-card {
            border-left: 4px solid #007bff;
        }
        .summary-card.success {
            border-left-color: #28a745;
        }
        .summary-card.warning {
            border-left-color: #ffc107;
        }
        .summary-card.danger {
            border-left-color: #dc3545;
        }
    </style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="page-content">
    <div class="row">
        <div class="col-md-12 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center mb-4">
                        <h6 class="card-title">Production Summary Report</h6>
                        <div>
                            <button type="button" class="btn btn-info" id="refresh-summary">
                                <i class="fas fa-sync-alt me-2"></i>Refresh Summary
                            </button>
                        </div>
                    </div>

                    <!-- Date Range Filter -->
                    <div class="row mb-4">
                        <div class="col-md-3">
                            <label for="date-from" class="form-label">Date From</label>
                            <input type="date" class="form-control" id="date-from" value="<?php echo e($dateFrom); ?>">
                        </div>
                        <div class="col-md-3">
                            <label for="date-to" class="form-label">Date To</label>
                            <input type="date" class="form-control" id="date-to" value="<?php echo e($dateTo); ?>">
                        </div>
                        <div class="col-md-3">
                            <label class="form-label">&nbsp;</label>
                            <button type="button" class="btn btn-primary d-block" id="apply-filters">
                                <i class="fas fa-filter me-2"></i>Apply Filters
                            </button>
                        </div>
                    </div>

                    <!-- Summary Statistics -->
                    <div class="row mb-4" id="summary-cards">
                        <div class="col-md-3">
                            <div class="card summary-card">
                                <div class="card-body">
                                    <div class="d-flex justify-content-between">
                                        <div>
                                            <h6 class="card-title">Total Runs</h6>
                                            <h3 class="mb-0" id="total-runs">0</h3>
                                        </div>
                                        <div class="align-self-center">
                                            <i class="fas fa-play-circle fa-2x text-primary"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="card summary-card success">
                                <div class="card-body">
                                    <div class="d-flex justify-content-between">
                                        <div>
                                            <h6 class="card-title">Total Pieces</h6>
                                            <h3 class="mb-0" id="total-pieces">0</h3>
                                        </div>
                                        <div class="align-self-center">
                                            <i class="fas fa-cubes fa-2x text-success"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="card summary-card warning">
                                <div class="card-body">
                                    <div class="d-flex justify-content-between">
                                        <div>
                                            <h6 class="card-title">Total Length</h6>
                                            <h3 class="mb-0" id="total-length">0</h3>
                                        </div>
                                        <div class="align-self-center">
                                            <i class="fas fa-ruler fa-2x text-warning"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="card summary-card danger">
                                <div class="card-body">
                                    <div class="d-flex justify-content-between">
                                        <div>
                                            <h6 class="card-title">B-Grade Pieces</h6>
                                            <h3 class="mb-0" id="b-grade-pieces">0</h3>
                                        </div>
                                        <div class="align-self-center">
                                            <i class="fas fa-tags fa-2x text-danger"></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Piece Status Breakdown -->
                    <div class="row mb-4">
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-body text-center">
                                    <h6 class="card-title">Complete Pieces</h6>
                                    <h2 class="text-success" id="complete-pieces">0</h2>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-body text-center">
                                    <h6 class="card-title">Partial Pieces</h6>
                                    <h2 class="text-warning" id="partial-pieces">0</h2>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-body text-center">
                                    <h6 class="card-title">B-Grade Pieces</h6>
                                    <h2 class="text-danger" id="b-grade-pieces-breakdown">0</h2>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Runs by Status -->
                    <div class="row">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header">
                                    <h6 class="card-title">Runs by Status</h6>
                                </div>
                                <div class="card-body">
                                    <div id="runs-by-status">
                                        <!-- Content will be loaded here -->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('custom-scripts'); ?>
<script>
$(document).ready(function() {
    // Load initial summary
    loadSummary();

    // Apply filters button
    $('#apply-filters').on('click', function() {
        loadSummary();
    });

    // Refresh summary button
    $('#refresh-summary').on('click', function() {
        loadSummary();
    });

    function loadSummary() {
        var dateFrom = $('#date-from').val();
        var dateTo = $('#date-to').val();

        $.ajax({
            url: '<?php echo e(route("reports.production-summary")); ?>',
            type: 'GET',
            data: {
                date_from: dateFrom,
                date_to: dateTo
            },
            success: function(response) {
                if (response.success) {
                    var data = response.data;

                    // Update summary cards
                    $('#total-runs').text(data.total_runs);
                    $('#total-pieces').text(data.total_pieces);
                    $('#total-length').text(data.total_length.toFixed(4));
                    $('#b-grade-pieces').text(data.b_grade_pieces);

                    // Update piece breakdown
                    $('#complete-pieces').text(data.complete_pieces);
                    $('#partial-pieces').text(data.partial_pieces);
                    $('#b-grade-pieces-breakdown').text(data.b_grade_pieces);

                    // Update runs by status
                    var runsByStatusHtml = '';
                    for (var status in data.runs_by_status) {
                        var count = data.runs_by_status[status];
                        var badgeClass = status === 'completed' ? 'badge-success' :
                                        status === 'in_progress' ? 'badge-warning' : 'badge-secondary';
                        runsByStatusHtml += '<span class="badge ' + badgeClass + ' me-2 mb-2">' +
                                          status.charAt(0).toUpperCase() + status.slice(1) + ': ' + count + '</span>';
                    }
                    $('#runs-by-status').html(runsByStatusHtml);
                }
            },
            error: function() {
                console.error('Failed to load summary data');
            }
        });
    }
});
</script>
<?php $__env->stopPush(); ?>

<?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\reports\production-summary.blade.php ENDPATH**/ ?>