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

// @codingStandardsIgnoreFile

?>
<div id="order_history_block" class="edit-order-comments">
    <?php if ($block->canAddComment()):?>
        <div class="order-history-block" id="history_form">

            <div class="admin__field">
                <label for="history_status" class="admin__field-label"><?= /* @escapeNotVerified */ __('Status') ?></label>
                <div class="admin__field-control">
                    <select name="history[status]" id="history_status" class="admin__control-select">
                        <?php foreach ($block->getStatuses() as $_code => $_label): ?>
                            <option value="<?= /* @escapeNotVerified */ $_code ?>"<?php if ($_code == $block->getOrder()->getStatus()): ?> selected="selected"<?php endif; ?>><?= /* @escapeNotVerified */ $_label ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>

            <div class="admin__field">
                <label for="history_comment" class="admin__field-label">
                    <?= /* @escapeNotVerified */ __('Comment') ?>
                </label>
                <div class="admin__field-control">
                    <textarea name="history[comment]"
                              rows="3"
                              cols="5"
                              id="history_comment"
                              class="admin__control-textarea"></textarea>
                </div>
            </div>

            <div class="admin__field">
                <div class="order-history-comments-options">
                    <div class="admin__field admin__field-option">
                        <?php if ($block->canSendCommentEmail()): ?>
                            <input name="history[is_customer_notified]"
                                   type="checkbox"
                                   id="history_notify"
                                   class="admin__control-checkbox"
                                   value="1" />
                            <label class="admin__field-label" for="history_notify">
                                <?= /* @escapeNotVerified */ __('Notify Customer by Email') ?>
                            </label>
                        <?php endif; ?>
                    </div>

                    <div class="admin__field admin__field-option">
                        <input name="history[is_visible_on_front]"
                               type="checkbox"
                               id="history_visible"
                               class="admin__control-checkbox"
                               value="1" />
                        <label class="admin__field-label" for="history_visible">
                            <?= /* @escapeNotVerified */ __('Visible on Storefront') ?>
                        </label>
                    </div>
                </div>

                <div class="order-history-comments-actions">
                    <?= $block->getChildHtml('submit_button') ?>
                </div>
            </div>
        </div>
    <?php endif;?>

    <ul class="note-list">
    <?php foreach ($block->getOrder()->getStatusHistoryCollection(true) as $_item): ?>
        <li class="note-list-item">
            <span class="note-list-date"><?= /* @noEscape */ $block->formatDate($_item->getCreatedAt(), \IntlDateFormatter::MEDIUM) ?></span>
            <span class="note-list-time"><?= /* @noEscape */ $block->formatTime($_item->getCreatedAt(), \IntlDateFormatter::MEDIUM) ?></span>
            <span class="note-list-status"><?= /* @escapeNotVerified */ $_item->getStatusLabel() ?></span>
            <span class="note-list-customer">
                <?= /* @escapeNotVerified */ __('Customer') ?>
                <?php if ($block->isCustomerNotificationNotApplicable($_item)): ?>
                    <span class="note-list-customer-notapplicable"><?= /* @escapeNotVerified */ __('Notification Not Applicable') ?></span>
                <?php elseif ($_item->getIsCustomerNotified()): ?>
                    <span class="note-list-customer-notified"><?= /* @escapeNotVerified */ __('Notified') ?></span>
                <?php else: ?>
                    <span class="note-list-customer-not-notified"><?= /* @escapeNotVerified */ __('Not Notified') ?></span>
                <?php endif; ?>
            </span>
            <?php if ($_item->getComment()): ?>
                <div class="note-list-comment"><?= $block->escapeHtml($_item->getComment(), ['b', 'br', 'strong', 'i', 'u', 'a']) ?></div>
            <?php endif; ?>
        </li>
    <?php endforeach; ?>
    </ul>
    <script>
require(['prototype'], function(){

        if($('order_status'))$('order_status').update('<?= /* @escapeNotVerified */ $block->getOrder()->getStatusLabel() ?>');

});
</script>
</div>
