<?php
    use common\models\User;
    use yii\helpers\Html;

    /**
     * @var \common\modules\comment\models\Comment $model  Current comment model
     * @var integer                                $key    ID of current comment
     * @var integer                                $index  index of current element according to
     *      current page, starting from 0
     * @var \yii\widgets\ListView                  $widget current ListView instance
     * @var User                                   $user
     */
    $user = NULL;
    if(!empty( $model->user_id )) {
        $user = User::find()
                    ->where([ 'id' => $model->user_id ])
                    ->with('userInfo')
                    ->one();
    }
?>
<div class="new-portf-comm-read artbox_comment_container" data-comment_id="<?= $model->comment_id ?>" data-form_name="<?= $model->formName() ?>">
    <div class="style">
        <div class="header-cabinet-foto">
            <?php
                if(!empty( $user ) && !empty( $user->userInfo->image )) {
                    echo "<img src='{$user->userInfo->image}' alt=''>";
                } else {
                    echo "<img src='/images/ded-ico.png' alt=''>";
                }
            ?>
        </div>
        <div class="new-prof-wrapper-read">
            <div class="new-portf-comm-read-title">
                <?php
                    if(!empty( $user )) {
                        echo Html::a('<span class="artbox_comment_author">' . $user->firstname . ' ' . $user->lastname . '</span>', [
                            'performer/common',
                            'performer_id' => $user->id,
                        ]);
                    } else {
                        echo '<span class="artbox_comment_author">' . $model->user_name . '</span>' . '(Гость)';
                    }
                ?>
            </div>
            <div class="new-portf-comm-read-rating">
                <?php
                    if($rating = $model->hasRating()) {
                        ?>
                        <div class="rating">
                            <!--оценка-->
                            <input type="hidden" class="val" value="<?= $rating->value ?>"/>
                            <!--количество голосов-->
                            <input type="hidden" class="votes" value="1"/>
                        </div>
                        <?php
                    }
                ?>
            </div>
            <div class="blog-post-date">
                <span></span>
                <p><?= date('d.m.Y', strtotime($model->date_add)) ?></p>
            </div>
        </div>

        <div class="new-portf-answer artbox_comment_text">
            <?= Html::encode($model->text) ?>
        </div>
        <div style="clear:both"></div>
        <?php
            /*
            ?>
            <div class="action_panel">
                <ul>
                    <li style="display:inline-block" class="artbox_comment_reply">Ответить</li>
                    <li style="display:inline-block" class="artbox_comment_update">Редактировать</li>
                    <li style="display:inline-block" class="artbox_comment_delete">Удалить</li>
                </ul>
            </div>
            <?php
            */
        ?>
    </div>
    <div class="style"></div>
</div>