<?php
// Copyright 1999-2012. Parallels IP Holdings GmbH. All Rights Reserved.
?>
<?php echo $this->partial('customer/client.phtml', null, $this); ?>
<?php echo $this->partial('reseller/general.phtml', array('generalInfo' => $this->generalInfo)); ?>
<script type="text/javascript">
//<![CDATA[
Jsw.onReady(function() {

    new Jsw.Container({
        renderTo: 'main',
        items: [
            new Jsw.Hint({
                hint: <?php echo $this->jsLmsg('pageHint'); ?>
            }),

            new Jsw.SmallTools({
                operations: getResellerToolsItems()
            }),

            new Jsw.layout.TwoColumns({
                renderTo: 'main',
                items: [{
                    componentType: 'Jsw.Panel',
                    title: <?php echo $this->jsLmsg('personalInformationTitle'); ?>,
                    cls: 'form-box',
                    items: AdminPanel.Customer.Overview.Info.getPersonalInformationItems()
                },
                new Jsw.Container({
                    items:[{
                            componentType: 'Jsw.Panel',
                            title: <?php echo $this->jsLmsg('accessTitle'); ?>,
                            cls: 'form-box',
                            items: AdminPanel.Customer.Overview.Info.getAccessInformationItems()
                        }, {
                            componentType: 'Jsw.Panel',
                            title: <?php echo $this->jsLmsg('generalTitle'); ?>,
                            cls: 'form-box',
                            items: AdminPanel.Reseller.Overview.Info.getGeneralInformationItems()
                        }]
                    })
                ]
            })
        ]
    });

    <?php if ($this->subscriptionStatusDescription):?>
    Jsw.Tooltip.init(
        $('subscription-status-description-tooltip'),
        {text: <?php echo $this->jsEscape($this->subscriptionStatusDescription);?>}
    );
    <?php endif?>

    new Jsw.bar.Tabs({
        cls: 'tabs',
        type: 'dynamic',
        renderTo: 'main',
        items: [
            <?php echo $this->partial('partials/resources-overview.phtml', null, $this); ?>,
            <?php echo $this->partial('partials/permissions-overview.phtml', null, $this); ?>
        ]
    });
});

function getResellerToolsItems()
{
    var tools = [{
        componentType: 'Jsw.SmallButton',
        id: 'buttonChangeSubscription',
        cls: 's-btn sb-change-subscription',
        title: <?php echo $this->jsLmsg('buttonChangeSubscription'); ?>,
        description: <?php echo $this->jsLmsg('buttonChangeSubscriptionHint'); ?>,
        href: '/reseller/change-subscription/id/<?php echo $this->id; ?>'
    }, {
        componentType: 'Jsw.bar.Separator'
    }, {
        componentType: 'Jsw.SmallButton',
        id: 'buttonEditSubscriptionParameters',
        title: <?php echo $this->jsLmsg('buttonManuallyEditSubscriptionParameters');?>,
        description: <?php echo $this->jsLmsg('buttonManuallyEditSubscriptionParametersHint'); ?>,
        addCls: 'sb-manually-edit-parameters',
        href: '/reseller/customize-subscription/id/<?php echo $this->id; ?>'
    }, <?php if ($this->changeSubscriptionPermission && $this->generalInfo['subscription'] && ($this->generalInfo['subscription']->isLocked() || !$this->generalInfo['subscription']->isSynchronized())): ?> {
        componentType: 'Jsw.SmallButton',
        id: 'buttonUnlockAndSync',
        attrs: { 'data-method': 'post' },
        title: <?php echo $this->jsLmsg($this->generalInfo['subscription']->isLocked() ? 'buttonUnlockAndSync' : 'buttonSync');?>,
        description: <?php echo $this->jsLmsg($this->generalInfo['subscription']->isLocked() ? 'buttonUnlockAndSyncHint' : 'buttonSyncHint'); ?>,
        addCls: 'sb-unlock-and-sync',
        href: '/reseller/synchronize/id/<?php echo $this->id; ?>'
    }, <?php endif; ?> {
        componentType: 'Jsw.bar.Separator'
    }, {
        componentType: 'Jsw.SmallButton',
        id: 'buttonmanageIpPool',
        addCls: 'sb-ip-pool',
        title: <?php echo $this->jsLmsg('buttonIPAddresses'); ?>,
        description: <?php echo $this->jsLmsg('buttonIPAddressesHint'); ?>,
        href: '/plesk/client@<?php echo $this->id; ?>/ipaddress@/'
    }, {
        componentType: 'Jsw.bar.Separator'
    },
    <?php if($this->iisAppPoolLink): ?>
    {
        componentType: 'Jsw.SmallButton',
        id: 'buttonIisAppPool',
        cls: 's-btn sb-iis-app-pool',
        title: <?php echo $this->jsLmsg('buttonIisAppPool'); ?>,
        description: <?php echo $this->jsLmsg('buttonIisAppPoolHint'); ?>,
        href: '<?php echo $this->iisAppPoolLink; ?>'
    }, {
        componentType: 'Jsw.bar.Separator'
    },
    <?php endif; ?>
    {
        componentType: 'Jsw.SmallButton',
        id: 'buttonEditContactInfo',
        addCls: 'sb-edit-contact',
        title: <?php echo $this->jsLmsg('buttonEditContact'); ?>,
        description: <?php echo $this->jsLmsg('buttonEditContactHint'); ?>,
        href: '/reseller/personal-info/id/<?php echo $this->id; ?>'
    }, {
        componentType: 'Jsw.SmallButton',
        id: 'buttonChangePassword',
        addCls: 'sb-change-password',
        title: <?php echo $this->jsLmsg('buttonChangePassword'); ?>,
        description: <?php echo $this->jsLmsg('buttonChangePasswordHint'); ?>,
        href: '/reseller/login-info/id/<?php echo $this->id; ?>'
    }, {
        componentType: 'Jsw.bar.Separator'
    }, {
        componentType: 'Jsw.SmallButton',
        id: 'buttonToggle',
        addCls: '<?php echo $this->customerStatusActive ? "sb-suspend" : "sb-activate"; ?>' ,
        title: <?php echo $this->customerStatusActive ? $this->jsLmsg('buttonSuspend') : $this->jsLmsg('buttonActivate'); ?>,
        description: <?php echo $this->customerStatusActive ? $this->jsLmsg('buttonSuspendHint') : $this->jsLmsg('buttonActivateHint'); ?>,
        handler: function() {
            Jsw.redirectPost('/reseller/toggle/id/<?php echo $this->id; ?>');
        }
    }, {
        componentType: 'Jsw.bar.Separator'
    }, {
        componentType: 'Jsw.SmallButton',
        id: 'buttonRemove',
        cls: 's-btn sb-remove-selected',
        title: <?php echo $this->jsLmsg('buttonRemove'); ?>,
        description: <?php echo $this->jsLmsg('buttonRemoveHint'); ?>,
        handler: function() {
            Jsw.messageBox.show({
                'type': Jsw.messageBox.TYPE_YESNO,
                'subtype': 'delete',
                'text': <?php echo $this->jsLmsg('buttonRemoveResellerConfirmationTitle') ?>,
                'description': <?php echo $this->jsLmsg('buttonRemoveResellerConfirmationDescription') ?>,
                'onYesClick': function() {
                    Jsw.redirectPost('/reseller/delete-current/id/<?php echo $this->id; ?>');
                },
                'buttonTitles': {
                    'yes': <?php echo $this->jsLmsg('components.buttons.yes') ?>,
                    'no': <?php echo $this->jsLmsg('components.buttons.no') ?>
                }
            });
        }
    }

    ];

    return tools;
}

//]]>
</script>
