<?php
// Copyright 1999-2018. Plesk International GmbH. All rights reserved.
$id = $this->element->getId();
?>
<div class="form-row">
    <div class="single-row">
        <div id="<?= $id ?>-info"></div>
        <div class="indent-box" id="<?= $id ?>-checkbox-block" style="display: none;">
            <input type="checkbox" id="<?= $id ?>-checkbox" class="checkbox">
            <div class="indent-box-content">
                <label for="<?= $id ?>-checkbox">
                    <?= $this->lmsg('admin.components.forms.admin.announcement-settings.sendAnnouncePersonalizedConsent', [
                        'privacyPolicy' => '<a href="' . Plesk_Config::get()->product->privacyPolicyUrl . '" target="_blank">'
                            . $this->lmsg('admin.components.forms.admin.announcement-settings.privacyPolicy')
                            . '</a>',
                    ]) ?>
                </label>
            </div>
        </div>
        <div class="indent-box" id="<?= $id ?>-radio-block" style="display: none;">
            <input type="radio" id="<?= $id ?>-personalized" class="radio" value="<?= \Plesk\PartnerCentral\Consent::TYPE_SEND_PERSONALIZED_ANNOUNCE ?>" name="<?= $id ?>-type">
            <div class="indent-box-content">
                <b><label for="<?= $id ?>-personalized">
                    <?= $this->lmsg('admin.components.forms.admin.announcement-settings.sendAnnouncePersonalizedConsent', [
                        'privacyPolicy' => '<a href="' . Plesk_Config::get()->product->privacyPolicyUrl . '" target="_blank">'
                            . $this->lmsg('admin.components.forms.admin.announcement-settings.privacyPolicy')
                            . '</a>',
                    ]) ?>
                </label></b>
            </div>
            <input type="radio" id="<?= $id ?>-general" class="radio" value="<?= \Plesk\PartnerCentral\Consent::TYPE_SEND_ANNOUNCE ?>" name="<?= $id ?>-type" checked>
            <div class="indent-box-content">
                <label for="<?= $id ?>-general">
                    <?= $this->lmsg('admin.components.forms.admin.announcement-settings.sendAnnounceConsent') ?>
                </label>
            </div>
            <input type="radio" id="<?= $id ?>-none" class="radio" value="<?= \Plesk\PartnerCentral\Consent::TYPE_NONE ?>" name="<?= $id ?>-type">
            <div class="indent-box-content">
                <label for="<?= $id ?>-none">
                    <?= $this->lmsg('admin.components.forms.admin.announcement-settings.noConsent') ?>
                </label>
            </div>
        </div>
        <span class="ajax-loading" id="<?= $id ?>-loader">
            <?= $this->lmsg('admin.components.forms.admin.announcement-settings.getConsentLoading') ?>
        </span>
        <div class="alert alert-warning" id="<?= $id ?>-warning" style="display: none;">
            <div class="b-indent">
                <span class="b-indent-icon"><i class="icon-attention"></i></span>
                <?= $this->lmsg('admin.components.forms.admin.announcement-settings.getConsentWarning') ?>
                <a id="<?= $id ?>-retry" href="">
                    <?= $this->lmsg('admin.components.forms.admin.announcement-settings.retry') ?>
                </a>
            </div>
        </div>
    </div>
</div>

<?= $this->requireJs('app/profile/announcement-settings', [
    'id' => $id,
    'getConsentUrl' => $this->baseUrl('/my-profile/get-consent'),
    'closeConsentInfoUrl' => $this->baseUrl('/my-profile/close-consent-info'),
    'email' => $this->email,
    'infoClosed' => get_param('consent_info_message_closed'),
    'dialogShown' => NewsletterSubscription::wasDialogShown(),
    'locale' => [
        'consentGivenInfo' => $this->lmsg('admin.components.forms.admin.announcement-settings.consentGivenInfo'),
        'consentNotGivenInfo' => $this->lmsg('admin.components.forms.admin.announcement-settings.consentNotGivenInfo'),
    ],
]) ?>
