<?php
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.

use PleskExt\PanelMigrator\CommonConstants;

echo $this->popupFetchSource;
$this->includeMigratorCss('server-info-toolbar.css');
?>
<div class="clearfix">
    <div class="server-info-toolbar">
        <div class="server-info-toolbar-info">
            <div class="server-info-toolbar-info-item">
                <img src="<?php echo $this->migratorImage('server-info-toolbar-source-server.png'); ?>" class="server-info-toolbar-icon"> <?php echo $this->lmsg('serverInfoSourceServer'); ?>
            </div>
            <div class="server-info-toolbar-info-item">
                <img src="<?php echo $this->migratorImage('server-info-toolbar-subscriptions.png'); ?>" class="server-info-toolbar-icon"> <?php echo $this->lmsg('serverInfoSubscriptions'); ?> <?php echo $this->subscriptionsCount; ?>,
            </div>
            <div class="server-info-toolbar-info-item">
                <img src="<?php echo $this->migratorImage('server-info-toolbar-service-plans.png'); ?>" class="server-info-toolbar-icon"> <?php echo $this->lmsg('serverInfoServicePlans'); ?> <?php echo $this->servicePlansCount; ?>,
            </div>
            <div class="server-info-toolbar-info-item">
                <img src="<?php echo $this->migratorImage('server-info-toolbar-customers.png'); ?>" class="server-info-toolbar-icon"> <?php echo $this->lmsg('serverInfoCustomers'); ?> <?php echo $this->customersCount; ?>,
            </div>
            <div class="server-info-toolbar-info-item">
                <img src="<?php echo $this->migratorImage('server-info-toolbar-resellers.png'); ?>" class="server-info-toolbar-icon"> <?php echo $this->lmsg('serverInfoResellers'); ?> <?php echo $this->resellersCount; ?>
            </div>
        </div>
        <div class="server-info-toolbar-actions">
            <?php if (
                $this->listOfSubscriptionsMode ==
                CommonConstants::LIST_OF_SUBSCRIPTIONS_MODE_SIMPLE
            ) { ?>
                <a class="s-btn" href="<?php echo $this->urlListOfSubscriptionsAdvanced; ?>">
                    <?php echo $this->lmsg('serverInfoButtonSwitchToAdvanced'); ?>
                </a>
            <?php } else if (
                $this->listOfSubscriptionsMode ==
                CommonConstants::LIST_OF_SUBSCRIPTIONS_MODE_ADVANCED
            ) { ?>
                <a class="s-btn" href="<?php echo $this->urlListOfSubscriptionsSimple; ?>">
                    <?php echo $this->lmsg('serverInfoButtonSwitchToSimple'); ?>
                </a>
            <?php } ?>
            <a class="s-btn" href="<?php echo $this->urlSettings; ?>" id="server-info-toolbar-button-settings"><?php echo $this->lmsg('serverInfoButtonSettings'); ?></a>
            <a class="s-btn" href="javascript:;" id="server-info-toolbar-button-reload-source-data"><?php echo $this->lmsg('serverInfoButtonReload'); ?></a>
            <a class="s-btn" id="server-info-toolbar-button-finish-migration"><?php echo $this->lmsg('serverInfoButtonFinishMigration'); ?></a>
        </div>
    </div>
</div>
<?php
// Include everything required for finish migration dialog
echo $this->finishMigrationDialog;
?>
<?php
// Handler for finish migration button
?>
<script type="text/javascript">
    //<![CDATA[
    Jsw.onReady(function() {
        $('server-info-toolbar-button-finish-migration').observe(
            'click', function () {
                finishMigration(<?php echo $this->sessionId; ?>)
            }
        );

        $('server-info-toolbar-button-reload-source-data').observe(
            'click', function() {
                new Ajax.Request(
                    <?php echo Zend_Json::encode($this->urlReloadSourceData); ?>, {
                        onSuccess: function() {
                            showFetchSourcePopup(
                                <?php echo Zend_Json::encode($this->sessionId); ?>,
                                function() {
                                    location.reload();
                                }
                            );
                        }
                    }
                );
            }
        );
    });
    //]]>
</script>
<?php if ($this->reloadRunning) { ?>
<script type="text/javascript">
    //<![CDATA[
    Jsw.onReady(function() {
        showFetchSourcePopup(
            <?php echo Zend_Json::encode($this->sessionId); ?>,
            function() {
                Jsw.redirect(<?php echo Zend_Json::encode($this->onReloadUrl); ?>);
            }
        );
    });
    //]]>
</script>
<?php } ?>
