<?php
/** @var \Mirasvit\Rma\Block\Rma\NewRma\Step1 $block */
?>
<?php
$orders = $block->getAllowedOrderList();
$offlineOrderPlaceholder = \Mirasvit\Rma\Api\Config\OfflineOrderConfigInterface::OFFLINE_ORDER_PLACEHOLDER;
?>
<?php if (count($orders) || $block->getIsAllowedOfflineOrder()): ?>
    <form action="<?= $block->getStep1PostUrl() ?>" method="GET"
          data-hasrequired="<?= __('* Required Fields') ?>" data-mage-init='{"validation":{}}' class="rma-customer-new">
        <div class="block">
            <div class="title">
                <strong><?= __('Please, select an order') ?></strong>
            </div>

            <div class="block-content">
                <fieldset class="fieldset">
                    <div class="field required">
                        <label class="label"><span><?= __('Order') ?></span></label>

                        <div class="control">
                            <select name="order_id" id="order_id" class="required-entry">
                                <option value=""><?= __('-- Select an Order --') ?></option>
                                <?php if ($block->getIsAllowedOfflineOrder()): ?>
                                    <option value="<?= $offlineOrderPlaceholder; ?>">
                                        <?= __('-- Create Offline Order --') ?>
                                    </option>
                                <?php endif; ?>
                                <?php foreach ($orders as $order): ?>
                                    <option value="<?= $order->getId() ?>">
                                        <?= $block->getOrderLabel($order) ?>
                                    </option>
                                <?php endforeach ?>
                            </select>
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="actions-toolbar">
            <div class="primary">
                <button type="submit" class="action primary">
                    <span><?= __('Next') ?></span>
                </button>
            </div>
        </div>
    </form>
<?php else: ?>
    <div class="message info empty">
        <span><?= __('You have no completed orders to request RMA or your orders were placed more than %1 days ago. Please, contact customer service.', $block->getReturnPeriod()) ?></span>
    </div>
<?php endif ?>