<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

?>

<?php $profile = \app\models\Profile::findOne(['user_id' => '23']); ?>

<?php if($model->lot && $model->lot->status !=4): ?>

    <div class="publications-item">
        <div class="row no-gutters">
            <div class="col-lg-7">
                <p class="publications-lot subtitle-secondary">Номер лоту: <span class="text-uppercase"><?=$model->lot->num?></span></p>
                <h4 class="publications-item-title">
                    <?= Html::a(Yii::t('app', $model->lot->name), ['/publishing/view','id' => $model->id], ['class' => 'link-primary font-weight-bold'])?>
                </h4>
                <div class="row">
                    <div class="col-sm-6">
                        <p class="publications-org"><?= $model->user->at_org?></p>
                        <div class="publications-org-about mb-2">
                            <a href="#<?=$model->id?>" data-toggle="collapse" aria-expanded="true" aria-controls="collapseInfo" class="link-secondary p-0 collapsed">Про організатора</a>
                            <div class="collapse multi-collapse" id="<?=$model->id?>" role="tabpanel" aria-labeledby="" data-parent="">
                                <div class="card-body">
                                    <p class="font-weight-bold mb-0">Контактна особа:</p>
                                    <p class="org-name"><?= $model->profile->at_org?></p>
                                    <p class="font-weight-bold mb-0">E-mail:</p>
                                    <p class="org-email"><?= $model->user->email?></p>
                                    <p class="font-weight-bold mb-0">Телефон:</p>
                                    <p class="org-telephone"><?= $model->profile->phone?></p>
                                    <p class="font-weight-bold mb-0">ЄДРПОУ:</p>
                                    <p class="org-edrpou"><?= $model->profile->inn?></p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <p>Категорія</p>
                        <div class="publications-type-fa font-weight-light">
                            <p><?=$model->lot->category->name?></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-5">
                <div class="row no-gutters">
                    <div class="col-sm-6">
                        <div class="publications-status mb-4">
                            <p class="subtitle-secondary mb-2">Статус</p>
                            <p class="publications-text-ok font-weight-semibold mb-4"><?= $model->statusName?></p>
                        </div>
                        <div class="publications-left">
                            <p class="subtitle-secondary mb-2">Період прийому заявок</p>
                            <p class="publications-left-time"><?php
                                $diff = strtotime ($model->date_start) - time();
                                if($diff < 0){
                                    echo Yii::t('app', 'Закінчився');
                                }else{
                                    echo intval($diff/86400) . ' дн. ' . intval(($diff%86400)/3600) . ' год. ' . intval((($diff%86400)%3600)/60) . ' хв.';
                                }

                                ?></p>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="publications-starting-price mb-4">
                            <p class="subtitle-secondary mb-2">Початкова ціна</p>
                            <p class="publications-starting-price-value"><?= $model->lot->start_price . ' грн.'?></p>
                        </div>
                        <?= Html::a(Yii::t('app', 'Взяти участь'), ['/lots/view','id' => $model->lot->id],
                            ['class' => 'btn btn-primary mt-3 btn-block'])?>
                        <?= Html::a(Yii::t('app', 'Детальніше'), ['/publishing/view','id' => $model->id],
                            ['class' => 'btn link-secondary btn-block'])?>
                    </div>
                </div>
            </div>
        </div>
    </div>


<?php endif; ?>
