<?php
// Copyright 1999-2022. Plesk International GmbH. All rights reserved.
?>
<?php if ($this->overuse): ?>
<?php echo $this->element->getSubForm('overusePolicy')->render($this); ?>
<hr/>
<?php endif; ?>

<div class="two-cols-block clearfix">
    <div class="first-col">
      <div class="column-box">
        <div id="limitGroups-main" class="form-box form-box-50x50">
            <div id="limitGroups-main-content-area">
<?php if ($this->isReseller) : ?>
                <?php echo $this->element->getElement('max_cl')->render($this); ?>

<div class="form-row">
    <div class="field-name"></div>
</div>

<?php endif; ?>
                <?php echo $this->element->getElement('disk_space')->render($this); ?>
<?php if ($this->softLimits): ?>
                <?php echo $this->element->getElement('disk_space_soft')->render($this); ?>
<?php endif; ?>
                <?php echo $this->element->getElement('max_traffic')->render($this); ?>
<?php if ($this->softLimits): ?>
                <?php echo $this->element->getElement('max_traffic_soft')->render($this); ?>
<?php endif; ?>

<div class="form-row">
    <div class="field-name"></div>
</div>


<?php if ($this->element->getElement('max_site_builder')): ?>
    <?php echo $this->element->getElement('max_site_builder')->render($this); ?>
    <?php if (!$this->isReseller && $this->isUpsellAllowed) : ?>
                <?php echo $this->element->getElement('upsell_site_builder')->render($this); ?>
    <?php endif; ?>
<?php endif; ?>
<?php if ($this->isReseller) : ?>
                <?php echo $this->element->getElement('max_dom')->render($this); ?>
<?php else: ?>
                <?php echo $this->element->getElement('max_site')->render($this); ?>
<?php endif; ?>
                <?php echo $this->element->getElement('max_subdom')->render($this); ?>
                <?php echo $this->element->getElement('max_dom_aliases')->render($this); ?>

<div class="form-row">
    <div class="field-name"></div>
</div>

<?php if ($this->element->getElement('max_box')): ?>
    <?php echo $this->element->getElement('max_box')->render($this); ?>
<?php endif; ?>
<?php if ($this->element->getElement('mbox_quota')): ?>
    <?php echo $this->element->getElement('mbox_quota')->render($this); ?>
<?php endif; ?>
<?php if ($this->hgModeWindows && $this->element->getElement('total_mboxes_quota')) : ?>
    <?php echo $this->element->getElement('total_mboxes_quota')->render($this); ?>
<?php endif; ?>
<?php if ($this->element->getElement('max_maillists')): ?>
    <?php echo $this->element->getElement('max_maillists')->render($this); ?>
<?php endif; ?>

<?php if ($this->element->getElement('max_box') || $this->element->getElement('mbox_quota') || $this->element->getElement('max_maillists')): ?>
<div class="form-row">
    <div class="field-name"></div>
</div>
<?php endif; ?>

<?php echo $this->element->getElement('max_subftp_users')->render($this); ?>
<?php echo $this->element->getElement('max_db')->render($this); ?>
<?php if ($this->hgModeWindows): ?>
    <?php echo $this->element->getElement('mysql_dbase_space')->render($this); ?>
    <?php echo $this->element->getElement('max_mssql_db')->render($this); ?>
    <?php echo $this->element->getElement('mssql_dbase_space')->render($this); ?>
    <?php if ($this->element->getElement('mssql_dbase_filesize')): ?>
        <?php echo $this->element->getElement('mssql_dbase_filesize')->render($this); ?>
    <?php endif; ?>
    <?php if ($this->element->getElement('mssql_dbase_log_filesize')): ?>
        <?php echo $this->element->getElement('mssql_dbase_log_filesize')->render($this); ?>
    <?php endif; ?>
<?php endif; ?>

<?php if (!$this->isReseller && $this->element->getElement('expiration')) : ?>
                <?php echo $this->element->getElement('expiration')->render($this); ?>
<?php endif; ?>
<?php foreach ($this->mainLimits as $limit): ?>
    <?php echo $this->element->getElement($limit)->render($this); ?>
<?php endforeach; ?>
            </div>
        </div>
      </div>
    </div>

    <div class="second-col">
      <div class="column-box">
        <div id="limitGroups-additional" class="form-box form-box-50x50 b-collapsible">
            <div id="limitGroups-additional-content-area">
                <?php foreach ($this->additionalLimits as $limit) {
                    echo $this->element->getElement($limit)->render($this);
                } ?>
            </div>
        </div>
      </div>
    </div>
</div>

<script type='text/javascript'>
//<![CDATA[
    new Jsw.Hint({
        renderTo: 'limitGroups-main-content-area',
        renderMode: 'top',
        hint: <?php echo $this->jsEscape($this->mainGroupTitle); ?>
    });
    new Jsw.Panel({
        applyTo: 'limitGroups-main',
        cls: 'form-box form-box-50x50'
    });
    new Jsw.Panel({
        title: <?php echo $this->jsEscape($this->additionalGroupTitle) ?>,
        hideContentTitle: <?php echo $this->jsEscape($this->additionalGroupTitleHidden) ?>,
        applyTo: 'limitGroups-additional',
        collapsed: true
    });
//]]>
</script>

<?php if ($this->overuse): ?>
<script type="text/javascript">
//<![CDATA[
Jsw.onReady(function () {
    var updateControlsState = function () {
        if (document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('overuse')->getId(); ?>-true').checked) {
            document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('notifyOveruseSoftAllowed')->getId(); ?>').disabled = true;
            document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('notifyOveruseAlwaysAllowed')->getId(); ?>').disabled = true;
            document.getElementById('<?php echo $this->element->getElement('disk_space_soft')->getId(); ?>-row').style.display = '';
            document.getElementById('<?php echo $this->element->getElement('max_traffic_soft')->getId(); ?>-row').style.display = '';
        }
        if (document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('overuse')->getId(); ?>-soft').checked) {
            document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('notifyOveruseSoftAllowed')->getId(); ?>').disabled = false;
            document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('notifyOveruseAlwaysAllowed')->getId(); ?>').disabled = true;
            document.getElementById('<?php echo $this->element->getElement('disk_space_soft')->getId(); ?>-row').style.display = '';
            document.getElementById('<?php echo $this->element->getElement('max_traffic_soft')->getId(); ?>-row').style.display = '';
        }
        if (document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('overuse')->getId(); ?>-false').checked) {
            document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('notifyOveruseSoftAllowed')->getId(); ?>').disabled = true;
            document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('notifyOveruseAlwaysAllowed')->getId(); ?>').disabled = false;
            document.getElementById('<?php echo $this->element->getElement('disk_space_soft')->getId(); ?>-row').style.display = 'none';
            document.getElementById('<?php echo $this->element->getElement('max_traffic_soft')->getId(); ?>-row').style.display = 'none';
        }
    };

    document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('overuse')->getId(); ?>-true').addEventListener('click', updateControlsState);
    document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('overuse')->getId(); ?>-soft').addEventListener('click', updateControlsState);
    document.getElementById('<?php echo $this->element->getSubForm('overusePolicy')->getElement('overuse')->getId(); ?>-false').addEventListener('click', updateControlsState);

    updateControlsState();
});
//]]>
</script>
<?php endif; ?>
