<?php
// Copyright 1999-2024. Plesk International GmbH. All rights reserved.
?>
<script type="text/javascript">
//<![CDATA[
    Jsw.onReady(function () {
        new Jsw.Panel({
            renderTo: '<?php echo $this->form->getId() ?>',
            renderMode: 'top',
            cls: 'tools-list-box',
            items: [{
                componentType: 'Jsw.ListContainer',
                cls: 'tools-list',
                itemClass: 'tools-item',
                items: [{
                    id: '<?php echo $this->anonFtpEnabled ? 'turnOff' : 'turnOn'; ?>',
                    componentType: 'Smb.ToolButton',
                    icon: '<?php echo $this->skinUrl('/icons/32/plesk/' . ($this->anonFtpEnabled ? 'disable' : 'enable') . '.png') ?>',
                    title: '<?php echo $this->lmsg($this->anonFtpEnabled ? 'turnOff' : 'turnOn') ?>',
                    comment: '<?php echo $this->lmsg($this->anonFtpEnabled ? 'turnOffHint' : 'turnOnHint') ?>',
                    handler: function () {
                        var statusElement = document.getElementById('<?php echo $this->form->getElement('status')->getId() ?>');
                        statusElement.value = '<?php echo $this->anonFtpEnabled ? 'false' : 'true' ?>';
                        Jsw.submit(statusElement);
                    },
                }],
            }],
        });
    });
//]]>
</script>

<?php echo $this->partial('partials/tabs.phtml', array('tabs' => $this->tabs, 'renderTo' => 'main', 'renderMode' => 'top')); ?>

<?php if (isset($this->notAllowedWarning)): ?>
<script type="text/javascript">
//<![CDATA[
    Jsw.onReady(function () {
        Jsw.addStatusMessage('warning', <?php echo $this->jsEscape($this->notAllowedWarning) ?>, { renderTo: 'main' });
    });
//]]>
</script>
<?php endif ?>

<?php echo $this->masterCheckbox($this->form->getElement('displayLogin'), [$this->form->getElement('loginText')], true, false) ?>

<?php echo $this->form ?>

<?php if ($this->form->getSubForm('quota')): ?>
<script type="text/javascript">
//<![CDATA[
    Jsw.onReady(function () {
        var updateState = function () {
            var noLimitElement = document.getElementById('<?php echo $this->form->getSubForm('quota')->getElement('noLimit')->getId() ?>');
            var quotaElement = document.getElementById('<?php echo $this->form->getSubForm('quota')->getElement('quota')->getId() ?>');
            if (document.getElementById('<?php echo $this->form->getElement('incomingDir')->getId() ?>').checked) {
                noLimitElement.disabled = false;
                if (noLimitElement.checked) {
                    quotaElement.disabled = true;
                } else {
                    quotaElement.disabled = false;
                }
            } else {
                noLimitElement.disabled = true;
                quotaElement.disabled = true;
            }
        };

        updateState();
        document.getElementById('<?php echo $this->form->getElement('incomingDir')->getId() ?>').addEventListener('click', updateState);
    });
//]]>
</script>
<?php endif ?>
