<?php
if ($block['percent'] < 41) {
    $class = 'bg-danger';
} elseif ($block['percent'] > 40 && $block['percent'] < 61) {
    $class = 'bg-warning';
} elseif ($block['percent'] > 60 && $block['percent'] < 81) {
    $class = 'bg-info';
} elseif ($block['percent'] > 80 && $block['percent'] < 101) {
    $class = 'bg-success';
}
?>
<div class="user-block-completeness">
    <div class="row clearfix">
        <div class="col-md-2 text-center">
            <a title="<?php echo $this->escape($block['user']['name']); ?>"
               href="<?php echo $this->escape($block['profileUrl']); ?>">
                <?php echo $block['avatar']; ?>
            </a>
        </div>
        <div class="col-md-10">
            <p>
                <?php echo _b('Please complete your profile information, to can use all website features'); ?>
                <a title="<?php echo _b('update all'); ?>"
                   href="<?php echo $this->escape($block['accountUrl']); ?>">( <?php echo _b('update all'); ?> )</a>
            </p>
            <div class="progress">
                <div class="progress-bar bg-striped <?php echo $class; ?> active" role="progressbar"
                     aria-valuenow="<?php echo $this->escape($block['percent']); ?>" aria-valuemin="0"
                     aria-valuemax="100" style="width: <?php echo $this->escape($block['percent']); ?>%">
                    <?php echo sprintf(_b('%s%s Complete'), _number($block['percent']), '%'); ?>
                </div>
            </div>
            <ul class="list-inline small">
                <?php foreach ($block['mainFields'] as $mainFields) { ?>
                    <li class="list-inline-item">
                        <?php if ($mainFields['status']) { ?>
                            <div class="text-success">
                                <i class="fas fa-check"></i> <?php echo $this->escape($mainFields['title']); ?>
                            </div>
                        <?php } else { ?>
                            <div class="text-danger">
                                <i class="fas fa-times"></i> <?php echo $this->escape($mainFields['title']); ?>
                                <?php if ($mainFields['name'] == 'avatar') { ?>
                                    <a title="<?php echo _b('update'); ?>"
                                       href="<?php echo $this->escape($block['avatarUrl']); ?>">( <?php echo _b('update'); ?>
                                        )</a>
                                <?php } ?>
                            </div>
                        <?php } ?>
                    </li>
                <?php } ?>
            </ul>
        </div>
    </div>
</div>