<?php
// Copyright 1999-2021. Plesk International GmbH. All rights reserved.
?>
<script type="text/javascript">
//<![CDATA[
(function() {

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

    new Jsw.SmallTools({
        renderTo: 'main',
        operations: <?php echo $this->globalOperations; ?>
    });

    var sectionGeneralFields = (function() {
        var sectionGeneralFields = [];

        <?php if (!$this->powerUserMode): ?>
            sectionGeneralFields.push({
                componentType: 'Jsw.form.DisplayField',
                fieldLabel: <?php echo $this->jsLmsg('fieldGeneralPlanName'); ?>,
                value: <?php echo $this->planName ? $this->jsEscape($this->planName) : "'&mdash;'"; ?>
            });
        <?php endif; ?>

        <?php if (!empty($this->addons)): ?>
            sectionGeneralFields.push({
                componentType: 'Jsw.form.DisplayField',
                fieldLabel: <?php echo $this->jsLmsg('fieldGeneralAddons'); ?>,
                value: <?php echo $this->jsHtml(implode('<br/>', $this->addons)); ?>
            });
        <?php endif; ?>

        sectionGeneralFields.push({
            componentType: 'Jsw.form.DisplayField',
            fieldLabel: <?php echo $this->jsLmsg('fieldGeneralSetupDate'); ?>,
            value: <?php echo $this->jsEscape($this->setupDate); ?>
        });

        sectionGeneralFields.push({
            componentType: 'Jsw.form.DisplayField',
            fieldLabel: <?php echo $this->jsLmsg('fieldGeneralStatus'); ?>,
            value: <?php echo $this->jsHtml($this->statusState($this->isActive, 'subscription')); ?>
        });

        <?php if ($this->expirationDate): ?>
            sectionGeneralFields.push({
                componentType: 'Jsw.form.DisplayField',
                fieldLabel: <?php echo $this->jsLmsg('fieldGeneralExpirationDate'); ?>,
                value: <?php echo $this->jsEscape($this->expirationDate); ?>
            });
        <?php endif; ?>

        return sectionGeneralFields;
    }());

    new Jsw.layout.TwoColumns({
        renderTo: 'main',
        items: [{
            componentType: 'Jsw.Panel',
            cls: 'form-box',
            items: sectionGeneralFields
        }]
    });

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

    new Jsw.bar.Tabs({
        renderTo: 'main',
        type: 'dynamic',
        cls: 'tabs',
        items: [
            <?php echo $this->partial('partials/resources-overview.phtml', array('overusePolicy' => $this->overusePolicy, 'mainResourceLimits' => $this->mainResourceLimits, 'additionalResourceLimits' => $this->additionalResourceLimits)); ?>
            <?php if ($this->hostingSettings): ?>
                , <?php echo $this->partial('partials/hosting-overview.phtml', array('hostingSettings' => $this->hostingSettings)); ?>
            <?php endif; ?>
            <?php if (!$this->powerUserMode && ($this->mainPermissions || $this->additionalPermissions)): ?>
                , <?php echo $this->partial('partials/permissions-overview.phtml', array('mainPermissions' => $this->mainPermissions, 'additionalPermissions' => $this->additionalPermissions)); ?>
            <?php endif; ?>
            <?php if ($this->planItems): ?>
                , <?php echo $this->partial('partials/extras-overview.phtml', array('planItems' => $this->planItems)); ?>
            <?php endif; ?>
        ]
    });

})();
//]]>
</script>
