<?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_<?php /* @escapeNotVerified */ echo $_code ?>" value="<?php /* @escapeNotVerified */ echo $_code ?>" type="radio" name="payment[method]"
                   title="<?php echo $block->escapeHtml($_method->getTitle()) ?>"
                   onclick="payment.switchMethod('<?php /* @escapeNotVerified */ echo $_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_<?php /* @escapeNotVerified */ echo $_code ?>" value="<?php /* @escapeNotVerified */ echo $_code ?>" type="radio"
                       name="payment[method]" class="admin__control-radio"
                       checked="checked"/>
            </span>
        <?php endif;?>

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