<?php
use home\assets\MainAsset;
use home\assets\MenuAsset;
use yii\helpers\Url;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use home\modules\reimbursement\models\reimbursement;
use yii\widgets\ActiveForm;
use yii\helpers\StringHelper;
use common\assets\ZTreeAsset;
use common\assets\My97DatePickerAsset;

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

My97DatePickerAsset::register($this);
MenuAsset::register($this);
ZTreeAsset::register($this);

$assetUrl = $this->getAssetManager()->getBundle(MenuAsset::className())->baseUrl;
$this->registerJsFile($assetUrl . '/js/reim.list.tree.js', ['depends' => ZTreeAsset::className()]);

$this->title = '报销统计';
?>

<!--container-->
<div class="container manage-project fix">
    <!--mainbody-->
    <div class="mainbody fix">
        <?= $this->render('@home/views/site/_left-menu') ?>
        <div class="manage-right">
            <div class="tab-column">
                <div class="tab-right">
                    <button type="button" data-url='<?= Url::to([$this->context->id . '/create']) ?>' data-title="我要报销" data-width="600" data-height="380" class="btn btn-default btn-task open-dialog">
                        <a href="javascript:;" >我要报销</a>
                    </button>
                </div>
                <p class="caption">报销统计</p>
            </div>

            <?php
                $action = isset($action) ? $action : $this->context->id . '/statistics';
                $searchForm = ActiveForm::begin([ 'id' => 'search-form', 'action' => [$action, 'id' => $id], 'method' => 'get']);
            ?>
            <div class="task-title-date">
                <p class="lefttitle" style="margin-right: 25px;">
                    视图：<a class="month" href="<?= Url::to([$this->context->id . '/statistics-iframe', 'map' => 'month']) ?>" target="iframe">本月</a>
                    <a class="week" href="<?= Url::to([$this->context->id . '/statistics-iframe', 'map' => 'week']) ?>" target="iframe">本周</a>
                    <a class="reim" href="<?= Url::to([$this->context->id . '/statistics-iframe', 'type' => 'reim']) ?>" target="iframe">我的报销</a>
                    <a class="verify" href="<?= Url::to([$this->context->id . '/statistics-iframe', 'type' => 'verify']) ?>" target="iframe">我的审核</a>

                    <p class="searchfl">
                        <span class="fl">&nbsp;从</span>
                        <input type="text" id="reimbursement-begin_time" value="<?= isset($get['begin_time'])?$get['begin_time']:'' ?>" class="form-control fl date-form-control search-form" style="width: 10%" name="begin_time" 
                            onfocus="WdatePicker({&quot;maxDate&quot;:&quot;#F{$dp.$D(\'reimbursement-end_time\')}&quot;,&quot;readOnly&quot;:true,&quot;dateFmt&quot;:&quot;yyyy-MM-dd&quot;})">

                        <span class="fl">&nbsp;至</span>
                        <input type="text" id="reimbursement-end_time" value="<?= isset($get['end_time'])?$get['end_time']:'' ?>" class="form-control fl date-form-control search-form" style="width: 10%" name="end_time" 
                            onfocus="WdatePicker({&quot;minDate&quot;:&quot;#F{$dp.$D(\'reimbursement-begin_time\')}&quot;,&quot;readOnly&quot;:true,&quot;dateFmt&quot;:&quot;yyyy-MM-dd&quot;})">

                        <button type="submit" class="btn btn-primary fl btn-serch task-sou">
                         <i class="icon-search"></i>
                        </button>
                        <button type="button" class="btn btn-default fl btn-reset reset_search">
                         <i class="icon-undo"></i>
                        </button>
                    </p>
                </p>
            </div>
            <?php ActiveForm::end(); ?>
    
            <?= \home\widgets\Alert::widget(); ?>
            <div class="mainleft">
                <div class="labellink fix"> 
                    <a href="javascript:;" id="labelLink">人员</a>
                    <!-- <a href="javascript:;" id="labelLink">任务</a>  -->
                    <a href="javascript:;" id="labelLink" class="labelfocus">类别</a> 
                </div>
                <div class="lefttree-user"  style="display: none;">
                    <ul id="tree"  class="ztree"></ul>
                </div>
                <div class="lefttree-task" style="display: none;">
                    <ul id="task-tree" class="ztree" data-tree-list-url="<? Url::to(['/task/task/ajax-get-tree-data']) ?>" ></ul>
                </div>
                <div class="lefttree-category">
                    <ul id="category-tree"  class="ztree"  ></ul>
                </div>
            </div>
            <div class="mainright" style="margin-left: 224px;">
                <iframe id="iframe_default" name="iframe" src="<?= str_replace('statistics','statistics-iframe',Yii::$app->request->getUrl()) ?>" style="max-height: 700px; width: 100%;" data-id="default" frameborder="0" scrolling="auto">
                            </iframe>
            </div>
        </div>
    </div>
    <!--mainbody-->
</div>
<script>
    var default_date = "<?= date('Y-m-d') ?>";
    var CSRF = "<?= Yii::$app->request->getCsrfToken() ?>";
    var getTreeDataUrl = "<?= Url::to(['/blog/blog/get-treedata', '_csrf' => Yii::$app->request->getCsrfToken()]) ?>";
    var index = "<?= Url::to(['index']) ?>";
    var getCategory = "<?= Url::to(['get-category']) ?>";

    var monthUrl = "<?= Url::to([$this->context->id . '/statistics-iframe', 'map' => 'month']) ?>";
    var weekUrl = "<?= Url::to([$this->context->id . '/statistics-iframe', 'map' => 'week']) ?>";
    var reimUrl = "<?= Url::to([$this->context->id . '/statistics-iframe', 'type' => 'reim']) ?>";
    var verifyUrl = "<?= Url::to([$this->context->id . '/statistics-iframe', 'type' => 'verify']) ?>";

    function zTreeOnClick(event, treeId, treeNode) {
        window.location.href="<?= Url::to([$this->context->id.'/index']) ?>"+"&ids="+treeNode.user_ids;
    }

    function categoryOnClick(event, treeId, treeNode) {
        $('#iframe_default')[0].contentWindow.location.href="<?= Url::to([$this->context->id.'/statistics-iframe']) ?>"+"&id="+treeNode.cat_id;
    }
</script>
