<?php
// Copyright 1999-2026. WebPros International GmbH. All rights reserved.
?>
<?php echo $this->partial('partials/tabs.phtml', array('tabs' => $this->tabs, 'renderTo' => 'main')); ?>

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

            exceedingAttempts.push ({
                componentType: 'Jsw.Hint',
                hint: <?php echo $this->jsLmsg('exceedingAttemptsSectionHint'); ?>
            });
            <?php foreach($this->exceedingAttempts as $name => $value): ?>
            <?php
                $icon = '';
                switch ($name) {
                    case 'mbox': $icon = 'mail'; break;
                    case 'domain': $icon = 'domain'; break;
                    case 'subscription': $icon = 'subs'; break;
                }

                 $link = '<span class="b-indent-icon">'
                    . '<img src="' . $this->skinUrl("/icons/16/plesk/{$icon}.png") .'" alt="{$icon}" title="">'
                    . '</span> '
                    . '<a href="' . $this->baseUrl($value['href']) .'">'
                    . $this->lmsg($value['title'] .'ExceedingAttempts') . '</a>';
            ?>

            exceedingAttempts.push ({
                componentType: 'Jsw.form.DisplayField',
                fieldLabel: <?php echo $this->jsHtml('<div class="b-indent">' . $link . '</div>'); ?>,
                value: <?php echo (0 == $value['numOfSuspects']) ? $this->jsLmsg('noExceedingAttempts')
                    : $this->jsHtml('<span class="status-overused">'
                            . $this->lmsg($name.'NumOfSuspects', array('num' => $this->escape($value['numOfSuspects'])))
                            . '</span>'); ?>
            });
            <?php endforeach ?>


            return exceedingAttempts;
        }());
        var serverWideSettings = (function() {
            var serverWideSettings = [];

            serverWideSettings.push ({
                componentType: 'Jsw.Hint',
                hint: <?php echo $this->jsLmsg('serverWideSettingsSectionHint'); ?>
            });
            <?php foreach($this->serverWideLimits as $name => $value): ?>
            serverWideSettings.push ({
                componentType: 'Jsw.form.DisplayField',
                fieldLabel: <?php echo $this->jsLmsg($name.'Limit'); ?>,
                value:  <?php echo 0 > $value ? $this->jsLmsg('limitValueUnlimited')
                    : $this->jsLmsg('messagesPerHour', array('num' => $this->escape($value))); ?>
            });
            <?php endforeach ?>
            serverWideSettings.push ({
                componentType: 'Jsw.form.DisplayField',
                fieldLabel: <?php echo $this->jsLmsg('reportPeriod'); ?>,
                value: <?php echo $this->jsLmsg('periodValue'.$this->outgoingMailReportPeriod); ?>
            });
            serverWideSettings.push ({
                componentType: 'Jsw.form.DisplayField',
                fieldLabel: <?php echo $this->jsLmsg('notificationPeriod'); ?>,
                value: <?php echo $this->jsLmsg('periodValue'.$this->outgoingMailNotificationPeriod); ?>
            });
            <?php if ($this->canChangeServerMail): ?>
            serverWideSettings.push({
                componentType: 'Jsw.SmallButton',
                id: 'changeServerSettings',
                title: <?php echo $this->jsLmsg('changeServerWideSettings'); ?>,
                description: <?php echo $this->jsLmsg('changeServerWideSettingsDescription'); ?>,
                addCls: 'sb-settings',
                href: '/cp/server/mail/settings'
            });
            <?php endif; ?>

            return serverWideSettings;
        }());

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

                new Jsw.layout.TwoColumns({
                    items: [{
                        componentType: 'Jsw.Panel',
                        'title': <?php echo $this->jsLmsg('exceedingAttemptsSectionTitle') ?>,
                        cls: 'form-box',
                        items: exceedingAttempts
                    }
                    <?php if ($this->isAdmin) : ?>
                        , {
                            componentType: 'Jsw.Panel',
                            'title': <?php echo $this->jsLmsg('serverWideSettingsSectionTitle') ?>,
                            cls: 'form-box',
                            items: serverWideSettings
                        }
                    <?php endif; ?>
                    ]
                }),

                new Jsw.Panel({
                    title: <?php echo $this->jsLmsg('listOfSuspectsSectionTitle'); ?>,
                    cls: 'form-box',
                    items: [
                        new Jsw.Panel({
                            title: '',
                            cls: 'list-box list-groups-box',
                            html: <?php  echo $this->jsHtml($this->partial('outgoing-mail/_list.phtml', array(
                                                         'list' => $this->suspectsList,
                                                         'messagesDates' => $this->messagesDates,
                                                         'listType' => 'general',
                                                         'isAdmin' => $this->isAdmin,
                                                         'listType' => $this->listType,
                                                         'periodValue' => $this->lmsg('periodValue'.$this->outgoingMailReportPeriod),
                                                         'mailServerSettingsLink' => $this->mailServerSettingsLink,
                                                         'hint' => $this->isAdmin ? 'listOfSuspectsSectionHintAdmin' : 'listOfSuspectsSectionHintClient'))) ?>
                        })
                    ]
                })
            ]
        });
    });
    //]]>
</script>
