<?php include app()->basePath('app/Views/partials/header.php'); ?>
<?php $value = fn (string $key, string $default = ''): string => (string) ($settings[$key] ?? $default); ?>

<section class="panel">
    <p class="eyebrow">Configuracoes</p>
    <h1>Pagamentos manuais</h1>
    <p>Defina os dados que aparecem para o aluno ao finalizar uma compra.</p>

    <form class="form" method="post" action="/admin/settings/payments">
        <?= csrf_field() ?>

        <fieldset class="form-section">
            <legend>Transferencia bancaria</legend>
            <label class="check-row">
                <input type="checkbox" name="payment_bank_enabled" value="1" <?= $value('payment_bank_enabled', '1') === '1' ? 'checked' : '' ?>>
                Activar transferencia bancaria
            </label>
            <div class="grid two">
                <label>Banco <input name="payment_bank_name" value="<?= e($value('payment_bank_name', '')) ?>"></label>
                <label>Conta <input name="payment_bank_account" value="<?= e($value('payment_bank_account', '')) ?>"></label>
                <label>Titular <input name="payment_bank_holder" value="<?= e($value('payment_bank_holder', '')) ?>"></label>
                <label>NIB/IBAN <input name="payment_bank_nib" value="<?= e($value('payment_bank_nib', '')) ?>"></label>
            </div>
        </fieldset>

        <fieldset class="form-section">
            <legend>Carteiras moveis</legend>
            <div class="grid three">
                <div class="sub-panel">
                    <label class="check-row"><input type="checkbox" name="payment_mpesa_enabled" value="1" <?= $value('payment_mpesa_enabled', '1') === '1' ? 'checked' : '' ?>> M-Pesa</label>
                    <label>Numero <input name="payment_mpesa_number" value="<?= e($value('payment_mpesa_number', '')) ?>"></label>
                    <label>Nome <input name="payment_mpesa_holder" value="<?= e($value('payment_mpesa_holder', '')) ?>"></label>
                </div>
                <div class="sub-panel">
                    <label class="check-row"><input type="checkbox" name="payment_emola_enabled" value="1" <?= $value('payment_emola_enabled', '1') === '1' ? 'checked' : '' ?>> e-Mola</label>
                    <label>Numero <input name="payment_emola_number" value="<?= e($value('payment_emola_number', '')) ?>"></label>
                    <label>Nome <input name="payment_emola_holder" value="<?= e($value('payment_emola_holder', '')) ?>"></label>
                </div>
                <div class="sub-panel">
                    <label class="check-row"><input type="checkbox" name="payment_mkesh_enabled" value="1" <?= $value('payment_mkesh_enabled', '0') === '1' ? 'checked' : '' ?>> mKesh</label>
                    <label>Numero <input name="payment_mkesh_number" value="<?= e($value('payment_mkesh_number', '')) ?>"></label>
                    <label>Nome <input name="payment_mkesh_holder" value="<?= e($value('payment_mkesh_holder', '')) ?>"></label>
                </div>
            </div>
        </fieldset>

        <fieldset class="form-section">
            <legend>Instrucao para o aluno</legend>
            <label>
                Texto de instrucao
                <textarea name="payment_manual_instructions" rows="4"><?= e($value('payment_manual_instructions', '')) ?></textarea>
            </label>
        </fieldset>

        <div class="actions">
            <button class="button" type="submit">Guardar configuracoes</button>
        </div>
    </form>
</section>

<section class="panel">
    <h2>Pre-visualizacao</h2>
    <div class="payment-methods">
        <?php foreach ($methods as $method): ?>
            <?php if ($method['enabled']): ?>
                <div>
                    <strong><?= e($method['label']) ?></strong>
                    <span><?= e(implode(' - ', $method['lines'])) ?></span>
                </div>
            <?php endif; ?>
        <?php endforeach; ?>
    </div>
</section>

<?php include app()->basePath('app/Views/partials/footer.php'); ?>
