<?php
/**
 * Maho
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2023 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/** @var Mage_Page_Block_Html_CookieNotice $this */
?>
<?php if (Mage::helper('core/cookie')->isUserNotAllowSaveCookie()): ?>
<div class="global-site-notice notice-cookie" id="notice-cookie-block">
    <div class="notice-inner">
        <div class="notice-text"><?= $this->getCookieRestrictionBlockContent() ?></div>
        <div class="actions"><button class="button" onclick="allowSaveCookie()"><?= $this->__('Allow') ?></button></div>
    </div>
</div>
<script type="text/javascript">
    function allowSaveCookie() {
        Mage.Cookies.set('<?= Mage_Core_Helper_Cookie::IS_USER_ALLOWED_SAVE_COOKIE ?>', '<?= Mage::helper('core/cookie')->getAcceptedSaveCookiesWebsiteIds()?>', new Date(new Date().getTime() + <?= Mage::helper('core/cookie')->getCookieRestrictionLifetime() ?> * 1000));
        if (Mage.Cookies.get('<?= Mage_Core_Helper_Cookie::IS_USER_ALLOWED_SAVE_COOKIE ?>')) {
            window.location.reload();
        } else {
            window.location.href = '<?= Mage::getUrl('cms/index/noCookies') ?>';
        }
    }

    document.getElementById('notice-cookie-block').style.display = 'block';
</script>
<?php endif ?>


