<?php 
$this->load->view('layouts/header');
$this->load->helper('layout');
?>

    <!-- App Header -->
    <div class="appHeader">
        <div class="left">
            <a href="<?php echo base_url('dashboard'); ?>" class="headerButton">
                <ion-icon name="chevron-back-outline"></ion-icon>
            </a>
        </div>
        <div class="pageTitle">Transfer</div>
        <div class="right"></div>
    </div>

    <!-- App Capsule -->
    <div id="appCapsule">
        <div class="section mt-2">
            <div class="section-title">Transfer Options</div>
            <ul class="listview image-listview flush">
                <li>
                    <a href="<?php echo base_url('transfers/internal'); ?>" class="item">
                        <div class="icon-box bg-primary">
                            <ion-icon name="swap-horizontal-outline"></ion-icon>
                        </div>
                        <div class="in">
                            <div>
                                <strong><?php echo get_app_name(); ?> Transfer</strong>
                                <p>Transfer to <?php echo get_app_name(); ?> accounts</p>
                            </div>
                        </div>
                    </a>
                </li>
                <li>
                    <a href="<?php echo base_url('transfers/external'); ?>" class="item">
                        <div class="icon-box bg-secondary">
                            <ion-icon name="business-outline"></ion-icon>
                        </div>
                        <div class="in">
                            <div>
                                <strong>Bank Transfer</strong>
                                <p>Transfer to other banks</p>
                            </div>
                        </div>
                    </a>
                </li>
                <li>
                    <a href="<?php echo base_url('transfers/international'); ?>" class="item">
                        <div class="icon-box bg-warning">
                            <ion-icon name="globe-outline"></ion-icon>
                        </div>
                        <div class="in">
                            <div>
                                <strong>International Transfer</strong>
                                <p>Send money abroad</p>
                            </div>
                        </div>
                    </a>
                </li>
            </ul>
        </div>

        <?php if (!empty($beneficiaries)): ?>
        <div class="section mt-3">
            <div class="section-title">Saved Beneficiaries</div>
            <ul class="listview image-listview flush">
                <?php foreach ($beneficiaries as $beneficiary): 
                    $transfer_url = $beneficiary->beneficiary_type === 'internal' ? 'transfers/internal' : ($beneficiary->beneficiary_type === 'international' ? 'transfers/international' : 'transfers/external');
                ?>
                <li>
                    <a href="<?php echo base_url($transfer_url . '?to=' . urlencode($beneficiary->account_number)); ?>" class="item">
                        <img src="<?php echo base_url('assets/img/sample/avatar/avatar1.jpg'); ?>" alt="img" class="image">
                        <div class="in">
                            <div>
                                <strong><?php echo htmlspecialchars($beneficiary->name); ?></strong>
                                <p><?php echo $beneficiary->account_number; ?></p>
                            </div>
                        </div>
                    </a>
                </li>
                <?php endforeach; ?>
            </ul>
        </div>
        <?php endif; ?>
    </div>

    <!-- App Bottom Menu -->
    <?php echo get_bottom_menu('transfers'); ?>

<?php $this->load->view('layouts/footer'); ?>
