<?php

use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;

use common\modules\content\models\CoContent;
use common\modules\bids\models\Bid;

$more = CoContent::find()
    ->where([
        'category_id' => 4,
        'active' => true
    ])
    ->andWhere(['!=', 'id', $model->id])
    ->orderBy('RAND()')
    ->one();
?>

<!-- <section class="short_keys_sect">
    <div class="container"> -->
        <div class="row">
            <div class="col-md-12 col-xs-12 col-sm-12">
                <h2 class="short_keys_title">Посмотрите еще один<br/> короткий кейс</h2>
            </div>
        </div>
        <div class="row">
            <?php if($more) : ?>
                <div class="col-md-6 col-xs-6 col-sm-12">
                    <div class="short_keys_block">
                        <img src="<?=$more->preview?>" height="338" width="455">
                        <a href="<?=Url::to(['/'.$more->url]);?>" style="color:<?if($more->custom==CoContent::CUSTOM_WHITE){?>#fff<?}else{?>#2d3642<?}?>;" class="short_keys_title_link"><?=$more->lang->title?></a>
                        <div class="short_keys_foot">
                            <a href="<?=Url::to(['/'.$more->url]);?>" class="short_keys_btn_more"><span>Подробнее</span></a>
                            <!-- <a href="#" class="short_keys_tags"># Big data</a> -->
                        </div>
                    </div>
                </div>
            <?php endif; ?>

            <?php
            $show = true;
            if (!Yii::$app->user->isGuest && Bid::find()->where(['email' => Yii::$app->user->identity->email])->exists())
                $show = false;

            if ($show===true):
                ?>

            <div class="col-md-6 col-xs-6 col-sm-12">
                <div class="subsc_block">
                    <h2 class="subsc_block_title"><?=\Yii::t('form', 'Subscribe for cases updates')?></h2>
                    <div class="subsc_block_txt"><?=\Yii::t('form', 'When we will prepare new interesting case – we will send you a detailed letter. Subscribe here!')?></div>
                    <?php 
                    $model = new Bid;
                    $model->scenario = Bid::SCENARIO_SUBSCRIBE;
                    $model->form = Bid::FORM_SUBSCRIBE;

                    $form = ActiveForm::begin([
                        'action' => '/bids/bid/add',
                        'enableClientValidation' => false,
                        'options' => [
                            'class' => 'subsc_form bids-form',
                            'data-title' => 'Кейс: ' . $title,
                            'data-form' => 'Подписаться на обновление',
                            'data-tag' => Bid::TAG_INVOLVEMENT
                        ],
                    ]); ?>

                        <div class="message-box send_secce">Теперь вы подписаны на обновления кейсов.</div>

                        <div class="content">

                            <?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?>

                            <?php echo $form->field($model, 'form', ['template' => '{input}'])->hiddenInput(['class' => 'not_clear']); ?>

                            <?php echo $form->field($model, 'email', [
                                'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
                                'errorOptions' => []
                            ])->textInput([
                                'placeholder' => 'E-mail*'
                            ]); ?>

                            <?php echo Html::submitButton(\Yii::t('form', 'Subscribe'), ['class' => 'save-button']); ?>

                        </div>

                    <?php ActiveForm::end(); ?>
                </div>
            </div>
            <?php endif; ?>
        </div>
    <!-- </div>
</section> -->
<style type="text/css">
    .field-bid-email,
    .field-bid-email input {
        margin-bottom: 0;
    }
</style>