<?php
/**
 * Magento Chatbot Integration
 * Copyright (C) 2018
 *
 * This file is part of Werules/Chatbot.
 *
 * Werules/Chatbot is free software: you can redistribute it and/or modify
 * it under the terms of the MIT License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * MIT License for more details.
 *
 * You should have received a copy of the MIT License
 * along with this program. If not, see <https://opensource.org/licenses/MIT>.
 */

    $startedChatbot = $this->checkStartedChat();
    if ($startedChatbot)
    {
        $enablePromotion = $this->checkEnabledPromotion();
        $enableMessenger = $this->checkEnabledMessenger();
    }
    else
    {
        $enablePromotion = false;
        $enableMessenger = false;
    }
?>
<form class="form" action="<?php /* @escapeNotVerified */ echo $this->getPostActionUrl() ?>" method="post" id="form-validate" enctype="multipart/form-data" autocomplete="off">
    <input type="hidden" name="form_key" value="<?php echo $this->getFormKey();?>" />
    <fieldset class="fieldset">
        <legend class="legend">
            <span><?php echo __("Chatbot Settings") ?></span>
        </legend>
        <br>
        <?php if (!$startedChatbot): ?>
            <div class="message notice">
                <p>
                    <b><?php echo __("You still haven't chat with our Chatbot."); ?></b>
                </p>
            </div>
        <?php endif; ?>
        <div class="field choice"> <!-- style="display: none;"-->
            <input type="checkbox" name="enable_promotion" id="enable_promotion" value="1" title="<?php echo __("Receive Promotional Messages?") ?>" class="checkbox" <?php if (!$startedChatbot) echo 'disabled'; else if ($enablePromotion) echo 'checked'; ?>>
            <label for="enable_promotion" class="label">
                <span><?php echo __("Receive Promotional Messages?") ?></span>
            </label>
        </div>
        <div class="field choice">
            <input type="checkbox" name="enable_messenger" id="enable_messenger" value="1" title="<?php echo __("Enable Messenger?") ?>" class="checkbox" <?php if (!$startedChatbot) echo 'disabled'; else if ($enableMessenger) echo 'checked'; ?>>
            <label for="enable_messenger" class="label">
                <span><?php echo __("Enable Messenger?") ?></span>
            </label>
        </div>
    </fieldset>
    <div class="actions-toolbar">
        <div class="primary">
            <button type="submit" class="action submit primary" title="<?php /* @escapeNotVerified */ echo __("Save") ?>" <?php if (!$startedChatbot) echo 'disabled' ?>>
                <span><?php /* @escapeNotVerified */ echo __("Save") ?></span>
            </button>
        </div>
        <div class="secondary">
            <a class="action back" href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>">
                <span><?php /* @escapeNotVerified */ echo __("Back") ?>
                </span>
            </a>
        </div>
    </div>
</form>