<?php
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
?>
<?php echo $this->partial('partials/tabs.phtml', array('tabs' => $this->tabs, 'renderTo' => 'main')); ?>

<script type="text/javascript">
//<![CDATA[
    new Jsw.Hint({
        renderTo: 'main',
        hint: <?php echo $this->jsLmsg('hint'); ?>
    });

    new Jsw.Panel({
        cls: 'list-box',
        renderTo: 'main',
        items: [
            new Jsw.List({
                id: 'reseller-service-plan-list',
                data: <?php echo Zend_Json::encode($this->plansList->fetchData()); ?>,
                dataUrl: '/reseller-service-plan/list-data',
                disabledSelectHint: <?php echo $this->plansList->jsLmsg('disabledSelectHint');?>,
                searchFilters: <?php echo Zend_Json::encode($this->plansList->getSearchFilterConfig()); ?>,
                operations: [
                    {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonAddNewPlan',
                        title: <?php echo $this->plansList->jsLmsg('buttonAddNewPlan');?>,
                        description: <?php echo $this->plansList->jsLmsg('hintAddNewPlan'); ?>,
                        addCls: 'sb-add-new-plan btn-primary',
                        href: '/reseller-service-plan/create'
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonDuplicatePlans',
                        title: <?php echo $this->plansList->jsLmsg('buttonDuplicatePlans');?>,
                        description: <?php echo $this->plansList->jsLmsg('hintDuplicatePlans'); ?>,
                        addCls: 'sb-copy-selected',
                        handler: function(event) {
                            Jsw.getComponent('reseller-service-plan-list').execGroupOperation({
                                url: '/reseller-service-plan/duplicate-plans/?redirect=/reseller-service-plan/list/',
                                skipConfirmation: true
                            });
                        }
                    }, {
                        componentType: 'Jsw.bar.Separator'
                    }, {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonRemovePlan',
                        title: <?php echo $this->plansList->jsLmsg('buttonRemove');?>,
                        description: <?php echo $this->plansList->jsLmsg('hintRemove'); ?>,
                        addCls: 'sb-remove-selected',
                        handler: function(event) {
                            Jsw.getComponent('reseller-service-plan-list').execGroupOperation({
                                url: '/reseller-service-plan/delete/?redirect=/reseller-service-plan/list/',
                                subtype: 'delete',
                                mouseEvent: event,
                                locale: {
                                    confirmOnGroupOperation: <?php echo $this->plansList->jsLmsg('confirmOnDelete'); ?>
                                }
                            });
                        }
                    }
                ],
                columns: [
                    Jsw.list.COLUMN_SELECTION,
                    {
                        header: <?php echo $this->plansList->jsLmsg('planName');?>,
                        sortable: true,
                        dataIndex: 'planName',
                        renderer: function (item, isDisabled) {
                            return (
                                '<a href="' + Jsw.prepareUrl('/reseller-service-plan/edit/id/' + item.id) + '">' +
                                    Jsw.escapeHtml(item.planName) +
                                '</a>'
                            );
                        }
                    }, {
                        header: <?php echo $this->plansList->jsLmsg('planTraffic');?>,
                        sortable: true,
                        dataIndex: 'traffic',
                        renderer: function (item, isDisabled) {
                            return Jsw.escapeHtml(item.trafficString);
                        }
                    }, {
                        header: <?php echo $this->plansList->jsLmsg('planDiskSpace');?>,
                        sortable: true,
                        dataIndex: 'diskSpace',
                        renderer: function (item, isDisabled) {
                            return Jsw.escapeHtml(item.diskSpaceString);
                        }
                    }, {
                        header: <?php echo $this->plansList->jsLmsg('planSubscriptions');?>,
                        sortable: true,
                        dataIndex: 'subscriptions',
                        renderer: function (item, isDisabled) {
                            return (
                                '<a href="' + Jsw.prepareUrl('/reseller/list/?force-show-search=true&searchFilter[subscription][searchText]=' + item.id) + '">' +
                                    Jsw.escapeHtml(item.subscriptions) +
                                '</a>'
                            );
                        }
                    }
                ]
            })
        ]
    });
//]]>
</script>
