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

<?php echo $this->lmsg('pageHint'); ?>

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

    new Jsw.Panel({
        cls: 'list-box',
        renderTo: 'main',
        items: [{
            componentType: 'Jsw.List',
            id: 'subscriptions-list',
            data: <?php echo Zend_Json::encode($this->subscriptionsList->fetchData()); ?>,
            dataUrl: '/file-manager/subscriptions-list-data',
            columns: [
                {
                    header: <?php echo $this->subscriptionsList->jsLmsg('primaryDomain');?>,
                    sortable: true,
                    dataIndex: 'domain',
                    renderer: function (item) {
                        var returnUrl = Jsw.prepareUrl('/file-manager/list');
                        var subscriptionName = '<a href="' + Jsw.prepareUrl('/account/switch/id/' + item.id + '?hideNotice=1&returnUrl=' + encodeURIComponent(returnUrl)) + '">'
                            + item.domain + '</a>';

                        return subscriptionName;
                    },
                }, {
                    header: <?php echo $this->subscriptionsList->jsLmsg('addonDomains'); ?>,
                    dataIndex: 'addonDomains',
                    renderer: function(item) {
                        var list = '';

                        $A(item.addonDomains).each(function(name) {
                            list += name + '<br/>';
                        });

                        return list;
                    }
                }, {
                    header: <?php echo $this->subscriptionsList->jsLmsg('systemUser'); ?>,
                    sortable: true,
                    dataIndex: 'systemUser'
                }, {
                    header: '',
                    renderer: function(item) {
                        var returnUrl = Jsw.prepareUrl('/ftp');
                        var ftpAccessLink = '<a href="' + Jsw.prepareUrl('/account/switch/id/' + item.id + '?hideNotice=1&returnUrl=' + encodeURIComponent(returnUrl)) + '" class="s-btn sb-login">'
                            + '<i><i><i><span>' + <?php echo $this->subscriptionsList->jsLmsg('ftpAccess'); ?> + '</span></i></i></i></a>';
                        return ftpAccessLink;
                    },
                }
            ]
        }]
    });

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