<?php

use home\assets\MainAsset;
use yii\helpers\Url;
use yii\helpers\Html;
use home\modules\sale\models\Opportunity;
use home\modules\sale\models\Category;
use home\modules\sale\models\Status;
use yii\widgets\ActiveForm;
use common\models\User;
use yii\helpers\StringHelper;
use home\modules\schedule\models\Schedule;
use common\assets\ZTreeAsset;

/* @var $this \yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \home\modules\reimbursement\models\Reimbursement */

MainAsset::register($this);
$this->title = '日程列表';
$assetUrl = $this->getAssetManager()->getBundle(MainAsset::className())->baseUrl;
$this->registerJsFile($assetUrl . '/js/table.designer.js', ['depends' => MainAsset::className()]);
?>

<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
    <head>
        <meta charset="<?= Yii::$app->charset ?>"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">
        <?= Html::csrfMetaTags() ?>
        <title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
        <script>
            var GV = {
                announceAjaxUrl: "<?= Url::to(['/announcement/ajax']) ?>"
            };

            var index = "<?= Url::to(['index']) ?>";

        </script>
    </head>
    <body style="background: white;">
        <?= \home\widgets\Alert::widget(); ?>
<?php $this->beginBody() ?>
        <div id="info" style="display:none;"></div>
        <!--task-table-->
<?php $mainForm = ActiveForm::begin([ 'id' => 'main-form', 'action' => '']); ?>
        <table class="table task-table design_table" data-rowspan="1">
            <tr>
                <!-- <th width="40"><label style="font-weight:lighter" ><input type="checkbox" name="select_all" class="box-select-all" style="position:relative;top:2px;" /> 全选</label></th> -->
                <th width="22%">关联</th>
                <th width="22%">主题</th>
                <th width="15%">客户</th>
                <th width="8%">执行人</th>
                <th width="8%">类型</th>
                <th width="7%">日期</th>
                <th width="40" align="center">操作</th>
            </tr>
            <?php if (empty($models)) : ?>
                <tr><td colspan="7" class="tac red">还没有任何数据...</td></tr>
            <?php else : ?>
    <?php foreach ($models as $model) : ?>
                    <tr>
                        <td class='theleft-min' title="<?= $model['name'] ?>">
                            <?php if (!empty($model['link_id'])): ?>
                                <a href="<?= Url::to(['schedule/skip', 'link_type' => $model['link_type'], 'link_id' => $model['link_id']]) ?>" target="_blank"> 【<?= $model['type_name'] ?>】<?= StringHelper::truncate($model['name'],
                        14) ?> </a>
                            <?php endif; ?>
                        </td>
                        <td class='theleft-min' title="<?= $model['title'] ?>">
                                <?php if (Schedule::checkScheduleAccess('schedule/schedule/detail')) : ?>
                                <a  href="javascript:void(0);"  data-title='<?= $model->title ?>' data-url='<?= Url::to([$this->context->id . '/detail', 'id' => $model->schedule_id]) ?>'  data-height='250' data-width='610' class="open-only-see-dialog">
                                <?= StringHelper::truncate($model['title'], 17) ?>
                                </a>
                            <?php else : ?>
            <?= StringHelper::truncate($model['title'], 17) ?>
                            <?php endif; ?>
                        </td>
                        <td>
                            <?php if (!empty($model->customer)&&!empty($model['link_id'])) : ?>
                                <a href="<?= Url::to(['/customer/customer/detail', 'id' => $model['customer']['customer_id']]) ?>" target="_blank"><?= $model['customer']['simple_name'] ?></a>
        <?php endif; ?>
                        </td>
                        <td title="<?= $model['join_names'] ?>" > <?= StringHelper::truncate($model['join_names'], 12) ?></td>
                        <td> <?= $model['category']['name'] ?></td>
                        <td> <?= date("Y-m-d", $model['schedule_time']) ?></td>
                        <td align="center" >
                            <?php if (Schedule::checkScheduleAccess('schedule/schedule/view')) : ?>
                                <a href="javascript:;" class="open-dialog"  data-url="<?= Url::to(['view', 'id' => $model['schedule_id']]) ?>" data-width="650" data-height="400" data-title="编辑日程" >编辑</a>
                            <?php else : ?>
                                <a href="javascript:;" class="gray" title="当前没有编辑权限">编辑</a>
                            <?php endif; ?>
                            <?php if (Schedule::checkScheduleAccess('schedule/schedule/delete')) : ?>
                                <a href="<?= Url::to(['delete', 'id' => $model['schedule_id']]) ?>" class="link-delete" >删除</a>
                            <?php else : ?>
                                <a href="javascript:;" class="gray" title="当前没有删除权限">删除</a>
                    <?php endif; ?>
                        </td>
                    </tr>
            <?php endforeach; ?>
        <?php endif; ?>
        </table>
            <?php ActiveForm::end(); ?>
        <div class="pages">
            <span class="pagetotal">共<em><?= $pages->totalCount ?></em>条记录<em><?= $pages->page + 1 ?>/<?= $pages->pageCount ?></em>页 </span>
        <?= \yii\widgets\LinkPager::widget(['pagination' => $pages, 'prevPageLabel' => '上一页', 'nextPageLabel' => '下一页', 'firstPageLabel' => '首页', 'lastPageLabel' => '末页']); ?>
        </div>
        <!--分页标签-->
<?php $this->endBody() ?>
    </body>
</html>
<?php $this->endPage() ?>
