<?php
use yii\helpers\Url;
use yii\helpers\StringHelper;
use home\modules\task\models\Task;

?>
<div class="p15">

    <table class="table task-table ">
        <tbody>
            <tr>
                <th width="24%">任务名</th>
                <th width="12%">负责人</th>
                <th width="10%">开始日期</th>
                <th width="10%">结束日期</th>
                <th width="10%">任务类别</th>
                <th width="10%">状态</th>
                <th width="26%">操作</th>
            </tr>
            <?php if (!empty($tasks['tasks'])) : ?>
            <?php foreach ($tasks['tasks'] as $model) : ?>
            <tr>
                <td style="text-align:left;padding-left:5px;" title="<?= $model['name'] ?>" ><a href="<?= Url::to(['/task/task/detail', 'id' => $model['task_id'], 'from' => Url::to('')]) ?>"><?= (isset($model['_is_child'])) ? '&nbsp;&nbsp;└─&nbsp;' . StringHelper::truncate($model['name'], 8) : StringHelper::truncate($model['name'], 12)  ?></a></td>
                <td><?= (!empty($model['leader']['realname'])) ? $model['leader']['realname'] : '' ?></td>
                <td><?= (!empty($model['begin_time'])) ? date('Y-m-d', $model['begin_time']) : '' ?></td>
                <td><?= (!empty($model['end_time'])) ? date('Y-m-d', $model['end_time']) : '' ?></td>
                <td><?= $model['category']['name'] ?></td>
                <td><?= $model['status_name'] ?></td>
                <td>
                    <?php if (Task::checkTaskAccess($model, 'task/task/create-blog')) : ?>
                    <a href="javascript:;" class="open-dialog" data-title="<?= $model['name'] ?> - 写日志" data-url="<?= Url::to(['/blog/blog/write-daily', 'link_id' => $model['task_no'], 'link_type' => 'task','link_title'=>$model['name']]) ?>" data-reload="false" data-width="600" data-height="380"  data-reload="true">写日志</a>
                    <?php endif; ?>
                    <?php if (Task::checkTaskAccess($model, 'task/task/create-reimbursement')) : ?>
                    <a href="javascript:;" class="open-dialog" data-url="<?= Url::to(['/reimbursement/reimbursement/create', 'link_id' => $model['task_no'], 'link_type' => 'task']) ?>" data-reload="false" data-title="任务报销" data-width="600" data-height="380">报销</a>
                    <?php endif; ?>
                    <?php if (Task::checkTaskAccess($model, 'task/task/create-child')) : ?>
                    <a data-title="建子任务" data-url="<?=Url::to(['/task/task/create', 'parent_id' => $model['task_id']]) ?>" data-width="800" data-height="570" href="javascript:;" class="open-dialog">建子任务</a>
                    <?php endif; ?>
                </td>

            </tr>
            <?php endforeach; ?>
            <tr><td colspan="7"><a href="<?= Url::to(['/task/task/list', 'type' => 'lead']) ?>" >更多我负责的任务...</a></td></tr>
            <?php else : ?>
            <tr><td colspan="7">暂无数据...</td></tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>
