<?php
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
?>

<?php
if ($this->tabs) {
    echo $this->partial('partials/tabs.phtml', ['tabs' => $this->tabs, 'renderTo' => 'main']);
}
?>

<script type="text/javascript">
    //<![CDATA[
    Jsw.onReady(function() {
        var generalItems = (function() {

            var status = 'ok';
            var statusIcon = '<?php echo $this->skinUrl('/icons/16/plesk/ok.png') ?>';
            var statusMsg = <?php echo $this->jsLmsg('mailStatusSending');?>;
            var statusDescription = <?php echo $this->jsLmsg('mailStatusSendingDesc');?>;
            <?php if (!$this->mailStatus): ?>
                status = 'att';
                statusIcon = '<?php echo $this->skinUrl('/icons/16/plesk/att.png') ?>';
                statusMsg = <?php echo $this->jsLmsg('mailStatusNotSending');?>;
                statusDescription = <?php echo $this->jsLmsg('mailStatusNotSendingDesc');?>;
            <?php endif;?>

            var currentStatus = (
                '<div class="b-indent">'
                + '<span class="b-indent-icon">'
                + '<span class="tooltipData">' + Jsw.escapeHtml(statusDescription) + '</span>'
                + '<img src="' + statusIcon + '" alt="' + status + '" title="">'
                + '</span> '
                + '<nobr>' + Jsw.escapeHtml(statusMsg) + '</nobr>'
                + '</div>'
            );

            var generalItems = [
                {
                    componentType: 'Jsw.form.DisplayField',
                    fieldLabel: <?php echo $this->jsLmsg('mailStatus'); ?>,
                    value: currentStatus
                },
                {
                    componentType: 'Jsw.form.DisplayField',
                    fieldLabel: <?php echo $this->jsLmsg('currentLimit'); ?>,
                    value: <?php echo $this->jsLmsg('currentLimitValue', ['value' => $this->currentLimitValue]); ?>
                }
            ];
            <?php if ('' != $this->changeLimitUrl): ?>

                generalItems.push ({
                    componentType: 'Jsw.SmallButton',
                    id: 'changeLimit',
                    title: <?php echo $this->jsLmsg('changeLimitTitle'); ?>,
                    description: <?php echo $this->jsLmsg('changeLimitDescription'); ?>,
                    addCls: 'sb-settings',
                    href: <?php echo $this->jsEscape($this->changeLimitUrl); ?>
                });

            <?php endif; ?>
            return generalItems;
        }());

        new Jsw.Container({
            renderTo: 'main',
            items: [
                new Jsw.Hint({
                    hint: <?php echo $this->jsLmsg($this->type . 'PageHint'); ?>
                }),

                new Jsw.layout.TwoColumns({
                    items: [
                        new Jsw.Container({
                            items:[{
                                componentType: 'Jsw.Panel',
                                'title': <?php echo $this->jsLmsg('generalSectionTitle') ?>,
                                cls: 'form-box',
                                items: generalItems
                            }, {
                                componentType: 'Jsw.Panel',
                                'title': <?php echo $this->jsLmsg('attemptsSectionTitle') ?>,
                                cls: 'form-box',
                                items: [
                                    new Jsw.Panel({
                                        title: '',
                                        cls: 'list-box',
                                        id: 'outgoingMailPeaks',
                                        html: <?php  echo $this->jsHtml($this->partial('outgoing-mail/_peaks.phtml', array(
                                                         'type' => $this->type,
                                                         'intervals' => $this->intervals,
                                                         'objectId' => $this->objectId))) ?>
                                    })
                                ]
                            }
                            ]
                        }), {
                            componentType: 'Jsw.Panel',
                            'title': <?php echo $this->jsLmsg('messagesSectionTitle') ?>,
                            cls: 'form-box',
                            items: [
                                new Jsw.Panel({
                                    title: '',
                                    cls: 'list-box',
                                    id: 'outgoingMailMessages',
                                    html: <?php  echo $this->jsHtml($this->partial('outgoing-mail/_messages.phtml', array(
                                                         'type' => $this->type,
                                                         'messagesDates' => $this->messagesDates,
                                                         'objectId' => $this->objectId))) ?>
                                })
                            ]
                        }
                    ]
                })
        ]})
    });
    //]]>
</script>
