<?php

use wap\assets\AppAsset;
use yii\helpers\Html;
use yii\helpers\Url;
use wap\models\Task;

/* @var $this \yii\web\View */
/* @var $task wap\models\Task */

$asset = $this->getAssetManager()->getBundle(AppAsset::className());
?>

<div class="task-infowrap" style="background:#f7f7f7;" >
    <div class="task-info"> 
        <span>任务概述</span><img src="<?= $asset->baseUrl ?>/images/taskinfoimg.png">
        <h4><?= (isset($task['leader'])) ? '【' . $task['leader']['realname'] . '】' : '' ?> <?php if (!empty($task['begin_time']) || !empty($task['end_time'])) : ?><?= !empty($task['begin_time']) ? date('y.m.d',
            $task['begin_time']) : '' ?>/<?= !empty($task['end_time']) ? date('y.m.d', $task['end_time']) : '' ?><?php endif; ?></h4>
        <h4>【<?= $task['name'] ?>】</h4>
        <div class="task-description"><?= $task['description'] ?></div>

        <?php if (!empty($task['link_id']) && Task::checkTaskAccess($task, 'task/task/view-link') && in_array($task['link_type'], ['project'])) : ?>
            <?php
            $link_data = common\models\Common::getLinkData($task['link_type'], $task['link_id']);
            if (!empty($link_data)) :
            ?>
                <h3>
                    <a href="<?php
                       $linkType = $link_data['link_type'];
                       $linkType['wap_view_url']['id'] = (!empty($link_data[$linkType['pk']])) ? $link_data[$linkType['pk']] : 0;
                       echo Url::to($linkType['wap_view_url'])
                       ?>"  class="btn btn-default"><?= (!empty($linkType) && !empty($linkType['name'])) ? yii\helpers\StringHelper::truncate($linkType['name'], 1, '') : '' ?></a>
                </h3>
            <?php endif; ?>
        <?php endif; ?>
    </div>
</div>
