<?php
/**
 * @var $this WorkController
 * @var $currentBrand WorkBrand
 * @var $models WorkModel[]
 * @var $contacts Contact[]
 */
?>
<?php $this->renderPartial('//snippets/headerGallery'); ?>

<div class="wrapper content-wrapper">
    <div class="col-wrapper">
        <div class="col2">
            <?php
            $services = $this->getServices();
            if (count($services)):?>
                <p class="section-title"><?php echo Yii::t('site', 'Наши услуги');?></p>
                <ul class="sidebar-nav">
                    <?php foreach ($services as $item): ?>
                    <li><?php echo CHtml::link($item->i18n->name, array('tuning/service', 'link' => $item->link));?></li>
                    <?php endforeach; ?>
                </ul>
                <?php endif;?>
            <p class="section-title"><?php echo Yii::t('site', 'Марки авто');?></p>
            <ul class="sidebar-nav">
                <?php foreach ($this->getBrands() as $brand): ?>
                <?php if ($brand->id == $currentBrand->id): ?>
                    <li class="active">
                        <?php echo CHtml::link($brand->i18n->name, array('work/brand', 'brand' => $brand->link));?>
                        <ul>
                            <?php foreach ($brand->workModels as $model) if (!$model->hidden): ?>
                            <li>
                                <?php
                                echo CHtml::link($model->i18n->name, array(
                                    'work/model',
                                    'brand' => $model->workBrand->link,
                                    'model' => $model->link
                                ));
                                ?>
                            </li>
                            <?php endif; ?>
                        </ul>
                    </li>
                    <?php else: ?>
                    <li><?php echo CHtml::link($brand->i18n->name, array('work/brand', 'brand' => $brand->link));?></li>
                    <?php endif; ?>
                <?php endforeach; ?>
            </ul>
        </div>
        <div class="col8">
            <ul class="crumbs">
                <li><?php echo CHtml::link(Yii::t('site', 'Наши работы'), array('work/index'));?>→</li>
            </ul>

            <h1><?php echo $this->pageName?></h1>

            <?php if (count($models)): ?>
            <h2><?php echo Yii::t('site', 'Выберите модель автомобиля')?></h2>
            <div class="tail-frame">
                <div class="tail"></div>
                <div class="catalog-sublist">
                    <?php foreach ($models as $model): ?>
                    <a href="<?php echo
                    CHtml::encode($this->createUrl('work/model', array(
                        'brand' => $model->workBrand->link,
                        'model' => $model->link
                    )));
                        ?>" class="catalog-sublist-item larger">
                        <span class="catalog-sublist-item-img">
                            <?php echo CHtml::image($model->imageBehavior->getFileUrl('medium'))?>
                        </span>
                        <span class="catalog-sublist-item-name"><?php echo $model->i18n->name?></span>
                    </a>
                    <?php endforeach; ?>
                </div>
            </div>
            <?php endif;?>
            <div class="text-content">
                <?php echo $currentBrand->i18n->content?>
                <div class="col8">
                    <div class="tail-frame">
                        <div class="tail"></div>
                        <div class="form-wrap in-col8">
                            <?php
                            /** @var $form CActiveForm */
                            $form = $this->beginWidget('CActiveForm');
                            echo $form->textField($this->feedbackForm, 'link', array('style' => 'display:none;'));
                            ?>

                            <div class="form-line">
                                <?php
                                echo $form->label($this->feedbackForm, 'body');
                                echo $form->textArea($this->feedbackForm, 'body', array('class' => 'wide'));
                                ?>
                            </div>
                            <div class="form-left">
                                <div class="form-line">
                                    <?php
                                    echo $form->label($this->feedbackForm, 'name');
                                    echo $form->textField($this->feedbackForm, 'name', array('class' => 'middle'));
                                    ?>
                                </div>
                                <div class="form-line">
                                    <?php
                                    echo $form->label($this->feedbackForm, 'phone');
                                    echo $form->textField($this->feedbackForm, 'phone', array('class' => 'middle'));
                                    ?>
                                </div>
                                <div class="form-line">
                                    <?php
                                    echo $form->label($this->feedbackForm, 'email');
                                    echo $form->textField($this->feedbackForm, 'email', array('class' => 'middle'));
                                    ?>
                                </div>
                                <div class="form-line with-submit">
                                    <input type="submit" class="button" value="<?php echo Yii::t('site', 'Отправить сообщение')?>"/>
                                </div>
                            </div>
                            <?php
                            $this->endWidget();
                            if (Yii::app()->user->hasFlash('contact')) {
                                $cs = Yii::app()->clientScript;
                                $src = "\n alert(" . CJavaScript::encode(Yii::app()->user->getFlash('contact')) . ')';
                                $cs->registerScript('feedbackForm', $src);
                            }
                            ?>
                            <div class="form-right">
                                <p class="with-list-image"><?php echo Yii::t('site', 'все введенные вами данные расцениваются как конфендинциальные и не будут разглашены третьим лицам. Контактная информация необходима только для ответа на ваш вопрос.'); ?></p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col2">
                </div>
            </div>
        </div>
        <div class="col2">
            <p class="section-title"><?php echo Yii::t('site','Есть вопросы?');?></p>

            <div class="text-content">
                <?php echo Yii::t('site','Обращайтесь к вашему персональному консультанту (наши работы)!');?>
            </div>
            <?php $this->renderPartial('//snippets/sidebarContacts');?>
        </div>
    </div>
</div>
