<?php
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
?>
<div class="form-row">
    <div class="field-name"><?php echo $this->lmsg('attemptsIntervalsTitle'); ?></div>
    <div class="filed-value">
        <select name="outgoingMailPeaksInterval" id="outgoingMailPeaksInterval">
            <?php foreach($this->intervals as $value => $title): ?>
                <option value="<?php echo $value;?>"><?php echo $title;?></option>
            <?php endforeach; ?>
        </select>
    </div>
</div>
<div  id="outgoingMailPeaksResult" ></div>
<script type="text/javascript">
//<![CDATA[
(function () {
    var updateControlsState = function () {
        var interval = document.getElementById('outgoingMailPeaksInterval').value;
        new Ajax.Request(Jsw.prepareUrl('/outgoing-mail/peaks/type/<?php echo $this->type; ?>/id/<?php echo $this->objectId; ?>/interval/' + interval), {
            method: 'get',
            onCreate: function () {
                document.getElementById('outgoingMailPeaksResult').innerHTML = (
                    '<div class="ajax-loading">' +
                        <?php echo $this->jsLmsg('loading'); ?> +
                    '</div>'
                );
            },
            onSuccess: function (transport) {
                document.getElementById('outgoingMailPeaksResult').innerHTML = transport.responseText;
            },
        });
    };

    updateControlsState();
    document.getElementById('outgoingMailPeaksInterval').addEventListener('change', updateControlsState);
})();
//]]>
</script>
