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

// @codingStandardsIgnoreFile

?>
<?php $_option = $block->getOption() ?>
<?php $_optionId = $_option->getId() ?>
<?php $class = ($_option->getIsRequire()) ? ' required' : ''; ?>
<div class="field date<?php /* @escapeNotVerified */ echo $class; ?>"
    data-mage-init='{"priceOptionDate":{"fromSelector":"#product_addtocart_form"}}'>
    <fieldset class="fieldset fieldset-product-options-inner<?php /* @escapeNotVerified */ echo $class; ?>">
        <legend class="legend">
            <span><?php echo  $block->escapeHtml($_option->getTitle()) ?></span>
            <?php /* @escapeNotVerified */ echo $block->getFormatedPrice() ?>
        </legend>
        <div class="control">
            <?php if ($_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME
                || $_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE): ?>

                <?php echo $block->getDateHtml() ?>

            <?php endif; ?>

            <?php if ($_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME
                || $_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME): ?>
                <span class="time-picker"><?php echo $block->getTimeHtml() ?></span>
            <?php endif; ?>

            <?php if ($_option->getIsRequire()): ?>
                <input type="hidden"
                       name="validate_datetime_<?php /* @escapeNotVerified */ echo $_optionId ?>"
                       class="validate-datetime-<?php /* @escapeNotVerified */ echo $_optionId ?>"
                       value=""
                       data-validate="{'validate-required-datetime':<?php /* @escapeNotVerified */ echo $_optionId?>}"/>
            <?php else: ?>
                <input type="hidden"
                       name="validate_datetime_<?php /* @escapeNotVerified */ echo $_optionId ?>"
                       class="validate-datetime-<?php /* @escapeNotVerified */ echo $_optionId ?>"
                       value=""
                       data-validate="{'validate-optional-datetime':<?php /* @escapeNotVerified */ echo $_optionId?>}"/>
            <?php endif; ?>
            <script type="text/x-magento-init">
            {
                "#product_addtocart_form": {
                    "validation": {
                        "ignore": ":hidden:not(input[name^='validate_datetime_'])"
                    }
                }
            }
        </script>
        </div>
    </fieldset>

</div>
