<?php
/**
 * Copyright © 2016 Magento. 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"><?php /* @escapeNotVerified */ echo __('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="<?php /* @escapeNotVerified */ echo $_code ?>"<?php if ($_code == $block->getOrder()->getStatus()): ?> selected="selected"<?php endif; ?>><?php /* @escapeNotVerified */ echo $_label ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>

            <div class="admin__field">
                <label for="history_comment" class="admin__field-label">
                    <?php /* @escapeNotVerified */ echo __('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">
                                <?php /* @escapeNotVerified */ echo __('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">
                            <?php /* @escapeNotVerified */ echo __('Visible on Storefront') ?>
                        </label>
                    </div>
                </div>

                <div class="order-history-comments-actions">
                    <?php echo $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"><?php /* @escapeNotVerified */ echo $block->formatDate($_item->getCreatedAt(), \IntlDateFormatter::MEDIUM) ?></span>
            <span class="note-list-time"><?php /* @escapeNotVerified */ echo $block->formatTime($_item->getCreatedAt(), \IntlDateFormatter::MEDIUM) ?></span>
            <span class="note-list-status"><?php /* @escapeNotVerified */ echo $_item->getStatusLabel() ?></span>
            <span class="note-list-customer">
                <?php /* @escapeNotVerified */ echo __('Customer') ?>
                <?php if ($block->isCustomerNotificationNotApplicable($_item)): ?>
                    <span class="note-list-customer-notapplicable"><?php /* @escapeNotVerified */ echo __('Notification Not Applicable') ?></span>
                <?php elseif ($_item->getIsCustomerNotified()): ?>
                    <span class="note-list-customer-notified"><?php /* @escapeNotVerified */ echo __('Notified') ?></span>
                <?php else: ?>
                    <span class="note-list-customer-not-notified"><?php /* @escapeNotVerified */ echo __('Not Notified') ?></span>
                <?php endif; ?>
            </span>
            <?php if ($_item->getComment()): ?>
                <div class="note-list-comment"><?php echo $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('<?php /* @escapeNotVerified */ echo $block->getOrder()->getStatusLabel() ?>');

});
</script>
</div>
