<?php
    /**
     * @var View       $this
     * @var Category[] $categories
     * @var TaxGroup   $purposes
     * @var Banner[]   $banners
     * @var Slider     $slider
     */
    use common\components\artboximage\ArtboxImageHelper;
    use common\models\Articles;
    use common\models\Banner;
    use common\models\Slider;
    use common\modules\product\models\Category;
    use common\modules\rubrication\models\TaxGroup;
    use common\modules\rubrication\models\TaxOption;
    use yii\bootstrap\Html;
    use yii\helpers\Url;
    use yii\web\View;
    use yii\widgets\Menu;
    
    $this->title = Yii::t('app', 'Главная');
?>
<div class="section-box box-slider-wr margin-top">
  <div class="style box-slider">
    <div class="style slider-img">
        <?php
            $first = true;
            foreach ($slider->sliderImage as $image) {
                ?>
              <a href="<?= Url::to($image->url) ?>" class="<?php echo $first ? 'active-slide' : ''; ?>">
                  <?php
                      echo ArtboxImageHelper::getImage(
                          $image->getImageUrl(),
                          'slider_main',
                          [
                              'width'  => 1140,
                              'height' => 460,
                          ]
                      );
                  ?>
                <div>
                  <p><?= $image->lang->title; ?></p>
                  <span><?= $image->lang->alt; ?></span>
                </div>
              </a>
                <?php
                $first = false;
            }
        ?>
    </div>
    <div class="slider-menu">
        <?php
            $menu_items = [];
            foreach ($categories as $category) {
                $menu_items[] = [
                    'label' => $category->lang->name,
                    'url'   => [
                        'filter/category',
                        'id' => $category->category_id,
                    ],
                ];
            }
            echo Menu::widget(
                [
                    'items' => $menu_items,
                ]
            );
        ?>
    </div>
  </div>
</div>
<?php
    /* Заменить на нормальную мозайку */
?>
<div class="section-box box-mosaic margin-top">
  <div class="row">
      <?php
          $options = $purposes->options;
      ?>
    
    <div class="col-xs-12 col-sm-3 col-md-3">
      <div class="row">
          <?php
              if (!empty($options[ 2 ])) {
                  /**
                   * @var TaxOption $option
                   */
                  $option = $options[ 2 ];
                  ?>
                <div class="col-xs-12 col-sm-12 col-md-12 moz-1 moz-1-1">
                  <a href="<?= Url::to(
                      [
                          'filter/purpose',
                          'id' => $option->tax_option_id,
                      ]
                  ); ?>"><p><?= $option->lang->value; ?></p>
                    <div class="hidden-xs" style="background: url('/images/img/img-new-1.png') 50% 0 no-repeat;"></div>
                    <div class="visible-xs" style="background: url('/images/img/img-new-1-small.png') 50% 0 no-repeat; display: none;"></div>
                  </a>
                </div>
                  <?php
              }
          ?>
      </div>
    </div>
    
    <div class="col-xs-6 col-sm-3 col-md-3">
      <div class="row">
          <?php
              if (!empty($options[ 1 ])) {
                  /**
                   * @var TaxOption $option
                   */
                  $option = $options[ 1 ];
                  ?>
                <div class="col-xs-12 col-sm-12 col-md-12 moz-2 moz-2-1">
                  <a href="<?= Url::to(
                      [
                          'filter/purpose',
                          'id' => $option->tax_option_id,
                      ]
                  ); ?>"><p><?= $option->lang->value; ?></p>
                    <div class="hidden-xs" style="background: url('/images/img/img-new-2.png') 50% 0 no-repeat;"></div>
                    <div class="visible-xs" style="background: url('/images/img/img-new-2-small.png') 50% 0 no-repeat; display: none;"></div>
                  </a>
                </div>
                  <?php
              }
              
              if (!empty($options[ 3 ])) {
                  /**
                   * @var TaxOption $option
                   */
                  $option = $options[ 3 ];
                  ?>
                <div class="col-xs-12 col-sm-12 col-md-12 moz-2 moz-2-1" style="margin-top: 2px">
                  <a href="<?= Url::to(
                      [
                          'filter/purpose',
                          'id' => $option->tax_option_id,
                      ]
                  ); ?>"><p><?= $option->lang->value; ?></p>
                    <div class="hidden-xs" style="background: url('/images/img/img-new-3.png') 50% 0 no-repeat;"></div>
                    <div class="visible-xs" style="background: url('/images/img/img-new-3-small.png') 50% 0 no-repeat; display: none;"></div>
                  </a>
                </div>
                  <?php
              }
          
          ?>
      </div>
    </div>
    
    <div class="col-xs-6 col-sm-3 col-md-3">
      <div class="row">
          <?php
              if (!empty($options[ 4 ])) {
                  /**
                   * @var TaxOption $option
                   */
                  $option = $options[ 4 ];
                  ?>
                <div class="col-xs-12 col-sm-12 col-md-12 moz-2 moz-2-2">
                  <a href="<?= Url::to(
                      [
                          'filter/purpose',
                          'id' => $option->tax_option_id,
                      ]
                  ); ?>"><p><?= $option->lang->value; ?></p>
                    <div class="hidden-xs" style="background: url('/images/img/img-new-4.png') 50% 0 no-repeat;"></div>
                    <div class="visible-xs" style="background: url('/images/img/img-new-4-small.png') 50% 0 no-repeat; display: none;"></div>
                  </a>
                </div>
                  <?php
              }
              //                5
              if (!empty($options[ 5 ])) {
                  /**
                   * @var TaxOption $option
                   */
                  $option = $options[ 5 ];
                  ?>
                <div class="col-xs-12 col-sm-12 col-md-12 moz-2 moz-2-2" style="margin-top: 2px;">
                  <a href="<?= Url::to(
                      [
                          'filter/purpose',
                          'id' => $option->tax_option_id,
                      ]
                  ); ?>"><p><?= $option->lang->value; ?></p>
                    <div class="hidden-xs" style="background: url('/images/img/img-new-5.png') 50% 0 no-repeat;"></div>
                    <div class="visible-xs" style="background: url('/images/img/img-new-5-small.png') 50% 0 no-repeat; display: none;"></div>
                  </a>
                </div>
                  <?php
              }
          ?>
      </div>
    </div>
    <div class="col-xs-12 col-sm-3 col-md-3">
      <div class="row">
          <?php
              
              if (!empty($options[ 0 ])) {
                  /**
                   * @var TaxOption $option
                   */
                  $option = $options[ 0 ];
                  ?>
                <div class="col-xs-12 col-sm-12 col-md-12 moz-1 moz-1-2" style="padding-right: 15px !important;">
                  <a href="<?= Url::to(
                      [
                          'filter/purpose',
                          'id' => $option->tax_option_id,
                      ]
                  ); ?>"><p><?= $option->lang->value; ?></p>
                    <div class="hidden-xs" style="background: url('/images/img/img-new-6.png') 50% 0 no-repeat;"></div>
                    <div class="visible-xs" style="background: url('/images/img/img-new-6-small.png') 50% 0 no-repeat; display: none;"></div>
                  </a>
                </div>
                  <?php
              }
          ?>
      </div>
    </div>
      <?php
          /*
            if(!empty( $options[ 6 ] )) {
                /**
                 * @var TaxOption $option
                 *
                $option = $options[ 6 ];
                ?>
                <div class="col-xs-6 col-sm-3 col-md-3 moz-7">
                    <a href="<?= Url::to([
                        'filter/purpose',
                        'id' => $option->tax_option_id,
                    ]); ?>"><p><?= $option->lang->value; ?></p>
                        <div style="background: url('/images/img/img-6.png') 50% 0 no-repeat;"></div>
                    </a>
                </div>
                <?php
            }
        ?>
    </div>

    <div class="row">
        <?php
        $options = $purposes->options;
        if(!empty( $options[ 0 ] )) {
            /**
             * @var TaxOption $option
             *
            $option = $options[ 0 ];
            ?>
            <div class="col-xs-6 col-sm-3 col-md-3 moz-1">
                <a href="<?= Url::to([
                    'filter/purpose',
                    'id' => $option->tax_option_id,
                ]); ?>"><p><?= $option->lang->value; ?></p>
                    <div style="background: url('/images/img/img-1.png') 50% 0 no-repeat;"></div>
                </a>
            </div>
            <?php
        }
        if(!empty( $options[ 1 ] )) {
            /**
             * @var TaxOption $option
             *
            $option = $options[ 1 ];
            ?>
            <div class="col-xs-6 col-sm-3 col-md-3 moz-2">
                <a href="<?= Url::to([
                    'filter/purpose',
                    'id' => $option->tax_option_id,
                ]); ?>"><p><?= $option->lang->value; ?></p>
                    <div style="background: url('/images/img/img-2.png') 50% 0 no-repeat;"></div>
                </a>
            </div>
            <?php
        }
        if(!empty( $options[ 2 ] )) {
            /**
             * @var TaxOption $option
             *
            $option = $options[ 2 ];
            ?>
            <div class="col-xs-6 col-sm-6 col-md-6 moz-3">
                <a href="<?= Url::to([
                    'filter/purpose',
                    'id' => $option->tax_option_id,
                ]); ?>"><p><?= $option->lang->value; ?></p>
                    <div style="background: url('/images/img/img-3.png') 50% 0 no-repeat;"></div>
                </a>
            </div>
            <?php
        }
        if(!empty( $options[ 3 ] )) {
            /**
             * @var TaxOption $option
             *
            $option = $options[ 3 ];
            ?>
            <div class="col-xs-6 col-sm-6 col-md-6 moz-4">
                <a href="<?= Url::to([
                    'filter/purpose',
                    'id' => $option->tax_option_id,
                ]); ?>"><p><?= $option->lang->value; ?></p>
                    <div style="background: url('/images/img/img-4.png') 50% 0 no-repeat;"></div>
                </a>
            </div>
<?php
        }
        if(!empty( $options[ 4 ] )) {
            /**
             * @var TaxOption $option
             *
            $option = $options[ 4 ];
            ?>
            <div class="col-xs-6 col-sm-3 col-md-3 moz-5">
                <a href="<?= Url::to([
                    'filter/purpose',
                    'id' => $option->tax_option_id,
                ]); ?>"><p><?= $option->lang->value; ?></p>
                    <div style="background: url('/images/img/img-7.png') 50% 0 no-repeat;"></div>
                </a>
            </div>
            <?php
        }
        if(!empty( $options[ 5 ] )) {
            /**
             * @var TaxOption $option
             *
            $option = $options[ 5 ];
            ?>
            <div class="col-xs-6 col-sm-6 col-md-6 moz-6">
                <a href="<?= Url::to([
                    'filter/purpose',
                    'id' => $option->tax_option_id,
                ]); ?>"><p><?= $option->lang->value; ?></p>
                    <div style="background: url('/images/img/img-5.png') 50% 0 no-repeat;"></div>
                </a>
            </div>
            <?php
        }
        if(!empty( $options[ 6 ] )) {
            /**
             * @var TaxOption $option
             *
            $option = $options[ 6 ];
            ?>
            <div class="col-xs-6 col-sm-3 col-md-3 moz-7">
                <a href="<?= Url::to([
                    'filter/purpose',
                    'id' => $option->tax_option_id,
                ]); ?>"><p><?= $option->lang->value; ?></p>
                    <div style="background: url('/images/img/img-6.png') 50% 0 no-repeat;"></div>
                </a>
            </div>
            <?php
        }
        ?>
    </div>
          */ ?>
  </div>
</div>
<?php
    /* Заменить на нормальную мозайку */
?>

<div class="section-box box-banners margin-top visible-md visible-lg">
  <div class="row">
      <?php
          foreach ($banners as $banner) {
              ?>
            <div class="col-md-6">
                <?php
                    echo Html::a(Html::img($banner->lang->imageUrl), $banner->url);
                ?>
            </div>
              <?php
          }
      ?>
    <div class="clearfix"></div>
  </div>
</div>

