<?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: [
                new Jsw.List({
                    id: 'database-list',
                    searchOveral: 'domain',
                    searchFilters: <?php echo Zend_Json::encode($this->subscriptionsList->getSearchFilterConfig()); ?>,
                    data: <?php echo Zend_Json::encode($this->subscriptionsList->fetchData()); ?>,
                    dataUrl: '/database/subscriptions-list-data',
                    columns: [
                        {
                            header: <?php echo $this->jsLmsg('subscription'); ?>,
                            sortable: true,
                            renderer: function (item) {
                                var returnUrl = Jsw.prepareUrl('/database/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;
                            }
                        }
                    ]
                })
            ]
        });
    });
    //]]>
</script>
