<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php if ($block->hasMethods()): ?>
<div id="order-billing_method_form">
    <dl class="admin__payment-methods">
    <?php
        $_methods       = $block->getMethods();
        $_methodsCount  = count($_methods);
        $_counter = 0;
    ?>
    <?php foreach ($_methods as $_method): $_code = $_method->getCode(); $_counter++; ?>
        <dt class="admin__field-option">
        <?php if ($_methodsCount > 1): ?>
            <input id="p_method_<?= /* @escapeNotVerified */ $_code ?>" value="<?= /* @escapeNotVerified */ $_code ?>" type="radio" name="payment[method]"
                   title="<?= $block->escapeHtml($_method->getTitle()) ?>"
                   onclick="payment.switchMethod('<?= /* @escapeNotVerified */ $_code ?>')"<?php if ($block->getSelectedMethodCode() == $_code): ?> checked="checked"<?php endif; ?>
                   class="admin__control-radio<?php if ($_counter == $_methodsCount) : ?> validate-one-required-by-name<?php endif; ?>"/>
        <?php else :?>
            <span class="no-display">
                <input id="p_method_<?= /* @escapeNotVerified */ $_code ?>" value="<?= /* @escapeNotVerified */ $_code ?>" type="radio"
                       name="payment[method]" class="admin__control-radio"
                       checked="checked"/>
            </span>
        <?php endif;?>

            <label class="admin__field-label" for="p_method_<?= /* @escapeNotVerified */ $_code ?>"><?= $block->escapeHtml($_method->getTitle()) ?></label>
        </dt>
        <dd class="admin__payment-method-wrapper">
            <?= /* @escapeNotVerified */ $block->getChildHtml('payment.method.' . $_code) ?>
        </dd>
    <?php endforeach; ?>
    </dl>
</div>
    <script>
        require(["Magento_Sales/order/create/form"], function(){
        <?php if ($_methodsCount != 1):?>
            order.setPaymentMethod('<?= /* @escapeNotVerified */ $block->getSelectedMethodCode() ?>');
        <?php endif; ?>
        });
    </script>
<?php else: ?>
    <div class="admin__message-empty"><?= /* @escapeNotVerified */ __('No Payment Methods') ?></div>
<?php endif; ?>
