<?php
/* @var $this BattlesController */
/* @var $model BattlesLocations */
$this->pageTitle = 'Пропасть Астерии';
?>   
<?php if (!$dungeons): ?>
    <div class="info">Пещеры ещё пусты</div>
<?php else: ?>
    <?php foreach ($dungeons as $dungeon): ?>
        <?php $history = UserDungeons::model()->findByPk(array('id_user'=>Yii::app()->user->id, 'id_dungeon'=>$dungeon->id_dungeon)); ?>
        <div class="view-dungeons_block">
            <div class="view-dungeons_img">
                <img src="/images/dungeons/<?php echo $dungeon->id_dungeon; ?>.jpg">
            </div>
            <div class="view-dungeons_info">
                <?php if ($dungeon->level > $user->level && $dungeon->id_dungeon < 5): ?>
                    <?php echo CHtml::link($dungeon->name_dungeon, 'index', array('class'=>'grey')); ?><br />
                    <span class="small">доступно с <?php echo $dungeon->level; ?> ур.</span>				
                <?php elseif ($dungeon->id_dungeon > 4): ?>
                    <?php echo CHtml::link($dungeon->name_dungeon, 'index', array('class'=>'grey')); ?><br />
                    <span class="small"> в разработке</span>				
                <?php else: ?>
                    <?php echo CHtml::link($dungeon->name_dungeon, array('/dungeons/view', 'id' => $dungeon->id_dungeon)); ?><br />
                <?php endif; ?>
                <?php if ($history && $history->time_last > time()):?>
                    <span class="small grey">до старта (<?php echo FuncHelper::timeToCount($history->time_last-time()); ?>)</span>
                <?php endif; ?>
            </div>
        </div>
        <hr>
    <?php endforeach; ?>
<?php endif; ?>
