<div class="row-fluid">
    <div class="span3">
        <div class="well" >
            <ul id="treeDemo" name="treeDemo" class="ztree span12" style="height:938px;overflow-y:scroll;overflow-x:auto;"></ul>

            <ul class="nav nav-list">
                <li class="nav-header"><a href="#" ><i class="icon-retweet"></i></a></li>
            </ul>

        </div>
    </div>

    <div class="span7">
        <legend>角色管理</legend>

        <form id="form_rolemanage_edit" name="form_rolemanage_edit" method="post" action="<?php echo site_url('accessmanage/editrole') ?>">
          <fieldset>
            <label>角色名称</label>
            <input name="iar_name" class="span3" type="text" value="<?php echo $current_role->iar_name; ?>">
            <div class="row-fluid">
                <div class="btn-lg">　</div>
                <label>权限分配</label>
                <legend></legend>
                <?php foreach ($actionnode as $a) { ?>
                    <label class="checkbox span12" style="margin-left:0;margin-right:10px;">
                      <input class="parent_action" id="action_list_<?php echo $a->id; ?>" name="action_list[]" type="checkbox" value="<?php echo $a->iaa_id; ?>" <?php if(in_array($a->iaa_id, $current_action)) echo 'checked'; ?>> <?php echo $a->name; ?>
                    </label>
                    <div class="row-fluid">
                    <?php if(isset($methodnode[$a->id])){ foreach ($methodnode[$a->id] as $m) { ?>
                        <label class="checkbox span2" style="margin-left:0;margin-right:10px;">
                          <input class="action_list_<?php echo $a->id; ?>" name="action_list[]" type="checkbox" value="<?php echo $m->iaa_id; ?>" <?php if(in_array($m->iaa_id, $current_action)) echo 'checked'; ?>> <?php echo $m->name; ?>
                        </label>
                    <?php }} ?>
                    </div><br>
                    <legend></legend>
                <?php } ?>
            </div>
            <input name="iar_id" class="span3" type="hidden" value="<?php echo $current_role->iar_id; ?>">
            <input name="ian_iaa_id" class="span3" type="hidden" value="<?php echo $current_role->ian_iaa_id; ?>">
            <input name="iar_old_name" class="span3" type="hidden" value="<?php echo $current_role->iar_name; ?>">
            <div class="btn-group">
              <button type="button" class="btn" onclick="submitForm('form_rolemanage_edit');">保　存</button>
              <button class="btn dropdown-toggle" data-toggle="dropdown">
                <span class="caret"></span>
              </button>
              <ul class="dropdown-menu">
                <li><a href="javascript:void(0);" onClick="deleteInfo('form_rolemanage_edit')">删　除</a></li>
              </ul>
            </div>
          </fieldset>
        </form>
    </div>
    <div class="span2 well" style="min-height:1000px;">
        <?php echo $right_nav; ?>
    </div>
</div>

<script type="text/javascript">
    zNodes =<?PHP echo json_encode($rolestructure); ?>;
    var current_node = "<?php echo $current_role->iar_is_id; ?>"
    var indexpage= "<?php echo site_url('accessmanage/role/'); ?>"
    var addpage  = "<?php echo site_url('accessmanage/addrole'); ?>"
    var movepage = "<?php echo site_url('accessmanage/tree_move'); ?>"
    var deletepage="<?php echo site_url('accessmanage/delete_role'); ?>"
</script>
<script type="text/javascript" src="/js/init_ztree.js"></script>
<script type="text/javascript">
    $(".checkbox>input").click(function(){
        //如果父节点选中，则同时选择该节点的所有子节点
        if($(this).attr("class")=='parent_action'){
            if ($(this).attr("checked")) {
                var idflag=$(this).attr('id');
                $("."+idflag).attr("checked",'true');
            };
        //如果该节点有未选择的子节点，则取消选择父节点
        }else if($(this).attr("class")!='parent_action'){
            if ($(this).attr("checked")!='checked') {
                var classflag=$(this).attr('class');
                //$("#"+classflag).attr("checked",false);
                $("#"+classflag).removeAttr("checked");
            };
        }
    });
</script>