<?php
    /**
     * @var yii\web\View $this
     * @var Project      $model
     */
    use common\components\artboximage\ArtboxImageHelper;
    use common\models\Project;
    use common\models\ProjectImage;
    use common\modules\product\models\ProductVariant;
    use yii\helpers\Url;
    
    $this->title = $model->lang->title;
    $this->params[ 'breadcrumbs' ][] = [
        'url'   => [ '/project' ],
        'label' => \Yii::t('app', 'Галерея объектов'),
    ];
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class="section-box box-brand margin_bottom_30">
    <div class="style new_articles-wr">
        <div class="row">
            <div class="col-xs-12 col-sm-12 articles_data-title uppercase">
                <div class="articles-title"><?= $this->title; ?></div>
            </div>
            <div class="articles col-xs-12 col-sm-12 col-md-12">
                <div class="new_article-img">
                    <?php
                        if(!empty( $model->images )) {
                            $images = $model->images;
                            $image = current($images);
                            echo ArtboxImageHelper::getImage($image->getImageUrl(), 'article_list');
                        } else {
                            echo ArtboxImageHelper::getImage('/storage/no-image', 'article_list');
                        }
                    ?>
                </div>
                <div class="brand-list-desc-txt">
                    <?php
                        echo $model->lang->description;
                    ?>
                </div>
            </div>
            <?php
                if(!empty( $model->images ) && count($model->images) > 1) {
                    $images = array_slice($model->images, 1);
                    ?>
                    <div class="galery-obj-img col-xs-12 col-sm-12">
                        <!----размер миниатюр макс ширина 165, макс высота 100--->
                        <ul class="gall-1">
                            <?php
                                foreach($images as $img) {
                                    /**
                                     * @var ProjectImage $img
                                     */
                                    ?>
                                    <li data-src="<?php echo $img->getImageUrl(); ?>">
                                        <a href="">
                                            <img class="img-responsive" src="<?php echo ArtboxImageHelper::getImageSrc($img->getImageUrl(), 'project_list'); ?>">
                                        </a>
                                    </li>
                                    <?php
                                }
                            ?>
                        </ul>
                    </div>
                    <?php
                }
            ?>
        </div>
        <?php
            $variants = $model->variants;
            if(!empty( $variants )) {
                ?>
                <div class="row">
                    <div class="col-xs-12 col-sm-12 articles_data-title marginbottom-15">
                        <div class="articles-title"><?php echo \Yii::t('app', 'Продукты, используемые в данном проекте'); ?></div>
                    </div>
                    <div class="style project-brands_">
                        <ul class="style brands-list">
                            <?php
                                foreach($variants as $variant) {
                                    /**
                                     * @var ProductVariant $variant
                                     */
                                    ?>
                                    <li>
                                        <a href="<?php echo Url::to([
                                            'collection/view',
                                            'collection_id' => $variant->product_id,
                                            'variant_id'    => $variant->product_variant_id,
                                        ]); ?>">
                                            <div>
                                                <?php
                                                    echo ArtboxImageHelper::getImage($variant->getImageUrl(), 'brand_collection_variant');
                                                ?>
                                            </div>
                                            <p>
                                                <?php
                                                    echo $variant->lang->name;
                                                ?>
                                            </p>
                                        </a>
                                    </li>
                                    <?php
                                }
                            ?>
                        </ul>
                    </div>
                </div>
                <?php
            }
        ?>
    </div>
</div>