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

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

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

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

$this->title = '费用申请';
?>

<!--container-->
<div class="container manage-project fix">
  <?= $this->render('@home/views/site/_left-menu') ?>
    <div class="mainbody fix">
    <!--manage-left -->
    <div class="manage-right">
        <div class="tab-column">
            <div class="tab-right">
                <button type="button" title="新增申请" data-height="300" data-width='600' data-url='<?= Url::to([$this->context->id . '/create']) ?>' data-title='新增申请' class="btn btn-default btn-task open-dialog">
                   <i class="icon-plus"></i>
                </button>
            </div>
            <p class="caption">申请管理</p>
        </div>
        <?= $this->render('_search', ['model' => $model, 'get' => $get]) ?>

        <div class="manage-right-cont fix">

            <div class="mainleft-tree">
                <div class="labellink fix"> 
                    <a href="javascript:;" id="labelLink" class="labelfocus">人员</a>
                </div>
                <div class="lefttree-user">
                    <ul id="tree"  class="ztree" ></ul>
                </div>
            </div>

            <div class="manage-right-iframe" style="margin-left: 166px;">
                <iframe id="iframe_default" name="iframe" src="<?= str_replace('%2Findex', '%2Findex-iframe', Yii::$app->request->getUrl()) ?>" style="max-height: 700px; width: 100%;display:none;" data-id="default" frameborder="0" scrolling="auto">
                </iframe>

            </div>
        </div>
    </div>
    </div>
    <!--manage-right--> 
</div>
<!--container-->

<script>
    var CSRF = "<?= Yii::$app->request->getCsrfToken() ?>";
    var getTreeDataUrl = "<?= Url::to(['/reimbursement/application/get-treedata', '_csrf' => Yii::$app->request->getCsrfToken()]) ?>";
    var index = "<?= Url::to(['index']) ?>";
    var disable = <?= Application::ISVERIFY_DISABLE ?>;

    var href = "<?= Yii::$app->request->getUrl() ?>".replace("%2Findex", "%2Findex-iframe");

    function zTreeOnClick(event, treeId, treeNode) {
        $('#iframe_default')[0].contentWindow.location.href = href + "&ids=" + treeNode.user_ids;
    }
</script>