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

$this->passVariablesToJavaScript([
    'SHOW_STATUS_ICONS' => $this->showStatusIcons,
    'SHOW_ADD_SUBSCRIPTIONS_LINK' => $this->showAddSubscriptionsLink,
    'PROGRESS_STATUS_UPDATE_INTERVAL' => 3000,
    'SESSION_STATUS' => $this->sessionStatus,
    'URL_GET_SESSION_STATUS' => $this->urlGetSessionStatus,
    'MESSAGE_SUBSCRIPTIONS_IN_QUEUE' => $this->lmsg('progressStatusSubscriptionsInQueue'),
    'MESSAGE_SUBSCRIPTIONS_MIGRATED' => $this->lmsg('progressStatusSubscriptionsMigrated'),
    'MESSAGE_SUBSCRIPTIONS_NOT_MIGRATED' => $this->lmsg('progressStatusSubscriptionsNotMigrated'),
    'MESSAGE_ALL_SUBSCRIPTIONS_MIGRATED' => $this->lmsg('progressStatusAllSubscriptionsMigrated'),
]);
$this->includeMigratorJavaScript('common.js');
$this->includeMigratorJavaScript('progress-status.js');
$this->includeMigratorCss('progress-status.css');
$this->includeMigratorCss('gauge.css');
echo $this->popupCancelAll;
?>
<div id="progress-status" class="progress-status-container">
    <?php // Situation #1: migration was not started yet ?>
    <div id="progress-status-not-started" style="display: none">
        <div class="progress-status-msg-box-not-finished">
            <div class="progress-status-migration-status-row">
                <?php echo $this->lmsg('progressStatusMigrationStatus') ?>
            </div>
            <div>
                <?php echo $this->lmsg('progressStatusNotStarted'); ?>
                <span class="progress-status-add-subscriptions-link">
                    <a href="<?php echo $this->urlAddSubscriptionsToMigrate; ?>">[<?php echo $this->lmsg('progressStatusSelectSubscriptionsToMigrate'); ?>]</a>
                </span>
            </div>
        </div>
    </div>
    <?php // Situation #2: migration is in progress right now: display progress bar ?>
    <div id="progress-status-in-progress" style="display: none;">
        <div class="progress-status-msg-box-not-finished">
            <div class="progress-status-migration-status-row">
                <?php echo $this->lmsg('progressStatusMigrationStatus') ?>
            </div>
            <div class="progress-status-gauge-row">
                <span class="migrator-gauge-block">
                    <span title="" class="migrator-gauge-wrapper not_empty">
                        <span class="migrator-gauge-container">
                            <?php
                            // Progress bar element, will have "width" CSS property set from JavaScript
                            // according to the current progress
                            ?>
                            <span class="migrator-gauge-filled" id="progress-status-progress-bar"></span>
                        </span>
                    </span>
                </span>
            </div>
            <div class="progress-status-bottom-row">
                <div>
                    <span id="progress-status-text-subscriptions-in-queue"></span>
                    <a href="javascript:;" id="progress-status-cancel">[<?php echo $this->lmsg('progressStatusCancel'); ?>]</a>
                </div>
                <div class="progress-status-count-box">
                    <div class="progress-status-count-item progress-status-count-item-success" style="display: none">
                        <a href="">
                            <img src="<?php echo $this->migratorImage('subscription-status-success.png'); ?>" class="progress-status-count-icon">
                            <span class="progress-status-count-value-success">-</span>
                        </a>
                    </div>
                    <div class="progress-status-count-item progress-status-count-item-failed" style="display: none">
                        <a href="">
                            <img src="<?php echo $this->migratorImage('subscription-status-error.png'); ?>" class="progress-status-count-icon">
                            <span class="progress-status-count-value-failed">-</span>
                        </a>
                    </div>
                    <div class="progress-status-count-item progress-status-count-item-warning" style="display: none">
                        <a href="">
                            <img src="<?php echo $this->migratorImage('subscription-status-warning.png'); ?>" class="progress-status-count-icon">
                            <span class="progress-status-count-value-warning">-</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php // Situation #3: migration finished for several (but not all) subscriptions ?>
    <div id="progress-status-queue-finished" style="display: none">
        <div class="progress-status-msg-box-finished">
            <div class="progress-status-top-row">
                <span id="progress-status-text-subscriptions-migrated"></span>
            </div>
            <div class="progress-status-bottom-row">
                <div>
                    <span id="progress-status-text-subscriptions-not-migrated"></span>
                    <span class="progress-status-add-subscriptions-link">
                        <a href="<?php echo $this->urlAddSubscriptionsToMigrate; ?>">[<?php echo $this->lmsg('progressStatusSelectSubscriptionsToMigrate'); ?>]</a>
                    </span>
                </div>
                <div class="progress-status-count-box">
                    <div class="progress-status-count-item progress-status-count-item-success" style="display: none">
                        <a href="">
                            <img src="<?php echo $this->migratorImage('subscription-status-success.png'); ?>" class="progress-status-count-icon">
                            <span class="progress-status-count-value-success">-</span>
                        </a>
                    </div>
                    <div class="progress-status-count-item progress-status-count-item-failed" style="display: none">
                        <a href="">
                            <img src="<?php echo $this->migratorImage('subscription-status-error.png'); ?>" class="progress-status-count-icon">
                            <span class="progress-status-count-value-failed">-</span>
                        </a>
                    </div>
                    <div class="progress-status-count-item progress-status-count-item-warning" style="display: none">
                        <a href="">
                            <img src="<?php echo $this->migratorImage('subscription-status-warning.png'); ?>" class="progress-status-count-icon">
                            <span class="progress-status-count-value-warning">-</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php // Situation #4: migration finished for all subscriptions of the server ?>
    <div id="progress-status-all-migrated" style="display: none">
        <div class="progress-status-msg-box-finished">
            <div class="progress-status-top-row">
                <span id="progress-status-text-all-subscriptions-migrated"></span>
            </div>
            <div class="progress-status-bottom-row">
                <div>
                    <?php echo $this->lmsg('progressStatusFinished'); ?>
                </div>
                <div class="progress-status-count-box">
                    <div class="progress-status-count-item progress-status-count-item-success" style="display: none">
                        <a href="">
                            <img src="<?php echo $this->migratorImage('subscription-status-success.png'); ?>" class="progress-status-count-icon">
                            <span class="progress-status-count-value-success">-</span>
                        </a>
                    </div>
                    <div class="progress-status-count-item progress-status-count-item-failed" style="display: none">
                        <a href="">
                            <img src="<?php echo $this->migratorImage('subscription-status-error.png'); ?>" class="progress-status-count-icon">
                            <span class="progress-status-count-value-failed">-</span>
                        </a>
                    </div>
                    <div class="progress-status-count-item progress-status-count-item-warning" style="display: none">
                        <a href="">
                            <img src="<?php echo $this->migratorImage('subscription-status-warning.png'); ?>" class="progress-status-count-icon">
                            <span class="progress-status-count-value-warning">-</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php // Situation #5: migration failed with overall failure ?>
    <div id="progress-status-overall-failure" style="display: none">
        <div class="progress-status-msg-box-failed">
            <span id="progress-status-text-overall-failure"></span>
        </div>
    </div>
</div>