<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">

    <style>
        body {
            font-family: DejaVu Sans;
            background: #f2f2f2;
            margin: 0;
            padding: 0;
        }

        .wrapper {
            width: 700px;
            margin: auto;
            background: #fff;
        }

        .header {
            background: #1c8ec2;
            color: #fff;
            text-align: center;
            padding: 15px;
            font-size: 20px;
            font-weight: bold;
        }

        .section {
            padding: 25px;
        }

        .logo {
            float: left;
        }

        .meta {
            float: right;
            text-align: right;
            font-size: 12px;
        }

        .clear {
            clear: both;
        }

        .title {
            color: #1c8ec2;
            font-weight: bold;
            margin-top: 25px;
            margin-bottom: 10px;
            border-bottom: 2px solid #1c8ec2;
            padding-bottom: 5px;
            font-size: 13px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 12px;
        }

        td {
            padding: 8px 0;
            border-bottom: 1px solid #e5e5e5;
        }

        td.label {
            color: #666;
        }

        td.value {
            text-align: right;
        }

        .footer {
            text-align: center;
            font-size: 11px;
            color: #777;
            margin-top: 80px;
        }
    </style>

</head>

<body>

    <?php
        $logo = 'https://yefranchisees.b-cdn.net/frontend/YoungEngineerLogo.png';
        $type = pathinfo($logo, PATHINFO_EXTENSION);
        $data = file_get_contents($logo);
        $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);

        $submission = $invoice->class_and_customer_details;

        $parent = [];
        $child = [];
        $group = [];
        $class = [];

        $classDetails = $submission['class_details'] ?? [];

        if (is_array($submission)) {

            foreach ($submission as $step) {

                if (!is_array($step)) continue;

                // Accept both legacy label variants ("parent_info") and the current
                // frontend label ("parent_details") so older and newer submissions both work.
                if (isset($step['step_1']) && in_array($step['step_1'], ['parent_info', 'parent_details'], true)) {
                    $parent = $step;
                }

                if (isset($step['step_2']) && in_array($step['step_2'], ['child_info', 'child_details'], true)) {
                    $child = $step;
                }

                if (isset($step['step_2']) && $step['step_2'] == "child_group") {
                    $group = $step;
                }

                if (isset($step['step_4'])) {
                    $class = $step;
                }

                // step_3 carries class/pricing data when there is no step_4
                if (isset($step['step_3']) && empty($class)) {
                    $class = $step;
                }

            }

        }

    ?>


    <div class="wrapper">

        <div class="header">
            PAYMENT RECEIPT
        </div>

        <div class="section">

            <div class="logo">
                <img src="<?php echo e($base64); ?>" width="150">
            </div>

            <div class="meta">

                <div>
                    <strong>Date:</strong>
                    <?php echo e($invoice->created_at->format('F d, Y')); ?>

                </div>

                <div>
                    <strong>Receipt ID:</strong>
                    <?php echo e($invoice->id); ?>

                </div>

            </div>

            <div class="clear"></div>


            <div class="title">
                TRANSACTION DETAILS
            </div>

            <table>

                <tr>
                    <td class="label">Transaction ID</td>
                    <td class="value"><?php echo e($invoice->transaction_id); ?></td>
                </tr>

                <tr>
                    <td class="label">Amount Paid</td>
                    <td class="value">
                        <?php echo e(number_format((float)($invoice->total ?? $invoice->amount ?? 0), 2)); ?>

                        <?php echo e(strtoupper($invoice->currency ?? 'USD')); ?>

                    </td>
                </tr>

                <tr>
                    <td class="label">Date Paid</td>
                    <td class="value">
                        <?php echo e(($invoice->paid_at ?? $invoice->created_at)?->format('F d, Y') ?? ''); ?>

                    </td>
                </tr>

                <tr>
                    <td class="label">Payment Method</td>
                    <td class="value">
                        <?php echo e($invoice->payment_method ?? 'Card'); ?>

                    </td>
                </tr>

            </table>



            <div class="title">
                PROGRAM INFORMATION
            </div>

            <table>

                <tr>
                    <td class="label">Program Name</td>
                    <td class="value"><?php echo e($classDetails['program_name'] ?? $class['program_name'] ?? $group['study_program'] ?? ''); ?></td>
                </tr>

                <tr>
                    <td class="label">Instructor</td>
                    <td class="value"><?php echo e($classDetails['instructor_name'] ?? $class['instructor_name'] ?? ''); ?></td>
                </tr>

                <tr>
                    <td class="label">Start Date</td>
                    <td class="value"><?php echo e($classDetails['start_date'] ?? $class['start_date'] ?? ''); ?></td>
                </tr>

                <tr>
                    <td class="label">Class Time</td>
                    <td class="value">
                        <?php echo e($classDetails['start_time'] ?? $class['start_time'] ?? ''); ?>

                        <?php if(!empty($classDetails['end_time'] ?? $class['end_time'] ?? '')): ?>
                            - <?php echo e($classDetails['end_time'] ?? $class['end_time']); ?>

                        <?php endif; ?>
                    </td>
                </tr>

                <tr>
                    <td class="label">Location</td>
                    <td class="value"><?php echo e($classDetails['location'] ?? $group['location'] ?? ''); ?></td>
                </tr>

            </table>



            <div class="title">
                REGISTRATION DETAILS
            </div>

            <table>

                <tr>
                    <td class="label">Parent/Guardian</td>
                    <td class="value"><?php echo e($parent['name'] ?? ''); ?></td>
                </tr>

                <tr>
                    <td class="label">Parent Email</td>
                    <td class="value"><?php echo e($parent['email'] ?? ''); ?></td>
                </tr>

                <tr>
                    <td class="label">Child Name</td>
                    <td class="value"><?php echo e($child['childs_name'] ?? $child['child_name'] ?? ''); ?></td>
                </tr>

                <tr>
                    <td class="label">Child Age Group</td>
                    <td class="value"><?php echo e($child['age'] ?? ''); ?> years</td>
                </tr>

            </table>



            <div class="footer">
                Thank you for choosing our programs. Please keep this receipt for your records.
            </div>


        </div>

    </div>

</body>

</html>
<?php /**PATH /home/org/public_html/backend.youngengineers.org/resources/views/pdf/receipt.blade.php ENDPATH**/ ?>