<?php
use wap\assets\AppAsset;
use yii\helpers\StringHelper;
use yii\helpers\Url;
use wap\models\Announcement;

$this->title = '消息中心 - 首页';

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

<div class="mainbody">
    <ul class="switchtab">
        <li ><a href="<?= Url::to(['index']) ?>"><i class="icon-tasks"></i>我的任务</a></li>
        <li class="active"><a href="<?= Url::to(['announce']) ?>"><i class="icon-envelope"></i>消息中心<?= (!empty($notReadNum)) ? '<span>' . $notReadNum . '</span>' : '' ?></a></li>
    </ul>

    <div class="common-list task-list message-list">
        <ul>
            <?php if (!empty($announces['announces'])) : ?>
                <?php foreach($announces['announces'] as $announce) : ?>
                <li>
                <a href="<?= Url::to(['/announcement/detail', 'id' => $announce['announcement_id']]) ?>">
                    <img src="<?= $asset->baseUrl ?>/images/message-<?= ($announce['is_read'] == Announcement::NOT_READ) ? 'red' : 'gray' ?>.gif" width="6" height="6">
                    <h4><?php if ($announce['type'] == Announcement::TASK_TYPE) echo '【任务】'; elseif ($announce['type'] == Announcement:: RECEIVABLE_TYPE) echo '【回款】'; elseif ($announce['type'] == Announcement::REIMBURSE_TYPE) echo '【报销】'; ?><?= StringHelper::truncate($announce['title'], 14) ?></h4>
                    <p><?= date('Y-m-d', $announce['create_time']) ?></p>
                </a>
                </li>
                <?php endforeach; ?>
                <?php if ($announces['count'] > 10) : ?>
                    <li style="text-align:center;"><a href="<?= Url::to(['/announcement/index']) ?>">点击查看更多</a></li>
                <?php endif; ?>
            <?php else : ?>
                <li style="text-align:center;">还没有任何数据...</li>
            <?php endif; ?>
        </ul>
    </div>

</div>


