<?php
/**
 * Maho
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2022-2023 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/** @var Mage_Checkout_Block_Onepage $this */
?>
<div class="page-title">
    <h1><?= $this->__('Checkout') ?></h1>
</div>
<ol class="opc opc-firststep-<?= $this->getActiveStep() ?>" id="checkoutSteps">
<?php $i=0; foreach($this->getSteps() as $_stepId => $_stepInfo): ?>
<?php if (!$this->getChild($_stepId) || !$this->getChild($_stepId)->isShow()): continue; endif; $i++ ?>
    <li id="opc-<?= $_stepId ?>" class="section<?= !empty($_stepInfo['allow'])?' allow':'' ?><?= !empty($_stepInfo['complete'])?' saved':'' ?>">
        <div class="step-title">
            <span class="number"><?= $i ?></span>
            <h2><?= $_stepInfo['label'] ?></h2>
            <a href="#"><?= $this->__('Edit') ?></a>
        </div>
        <div id="checkout-step-<?= $_stepId ?>" class="step a-item" style="display:none;">
            <?= $this->getChildHtml($_stepId) ?>
        </div>
    </li>
<?php endforeach ?>
</ol>
<script type="text/javascript">
    const accordion = new Accordion('checkoutSteps', '.step-title', true);
    <?php if($this->getActiveStep()): ?>
    accordion.openSection('opc-<?= $this->getActiveStep() ?>');
    <?php endif ?>

    const checkout = new Checkout(accordion, {
        progress: '<?= $this->getUrl('checkout/onepage/progress') ?>',
        review: '<?= $this->getUrl('checkout/onepage/review') ?>',
        saveMethod: '<?= $this->getUrl('checkout/onepage/saveMethod') ?>',
        failure: '<?= $this->getUrl('checkout/cart') ?>'
    });
</script>
