<!DOCTYPE html>
<html class="" lang="en">
<head  >

    {% include 'twig/common/header/include.twig' %}


    <script src="/dev/lib/notify/bootstrap-notify/dist/bootstrap-notify.min.js"></script>
    <script src="/dev/lib/chart.js/Chart.bundle.js"></script>
    <script src="/dev/lib/chart.js/samples/utils.js"></script>

    <link href="/dev/lib/bootstrap-3.3.7/css/bootstrap.css" rel="stylesheet" type="text/css"/>
    <link href="/dev/css/dashboard.css?v=<?=_version?>" rel="stylesheet">
    <link href="/dev/css/statistics.css?v=<?=_version?>" rel="stylesheet">
</head>
<body class="" data-group="" data-page="projects:issues:index" data-project="xphp">
{% include 'twig/common/body/script.twig' %}

<div class="has-sidebar page-layout max-sidebar">
    {% include 'twig/common/body/page-left.twig' %}
    <div class="page-layout page-content-body">
{% include 'twig/common/body/header-content.twig' %}

<script>
    var findFileURL = "";
</script>
<div class="page-with-sidebar">
    {% include 'twig/project/common-page-nav-project.twig' %}
    {% include 'twig/project/common-stat-sub-nav.twig' %}

    <div class="content-wrapper page-with-layout-nav page-with-sub-nav">
        <div class="alert-wrapper">
            <div class="flash-container flash-container-page">
            </div>
        </div>
        <div class="content" id="content-body">
            <div class="container-fluid padding-0">
                <div class="content-block padding-lg margin-b-lg content-block-header">
                    <h3 class="header-title">迭代统计</h3>
                    <div class="row header-body">
                        <div class="col-sm-3 col-xs-12 column header-body-item">
                            <span id="issues_count" class="item-num">-</span>
                            <span class="item-text">事项数</span>
                        </div>
                        <div class="col-sm-3 col-xs-12 column header-body-item">
                            <span id="no_done_count" class="item-num">-</span>
                            <span class="item-text">未解决</span>
                        </div>
                        <div class="col-sm-3 col-xs-12 column header-body-item">
                            <span id="closed_count" class="item-num">-</span>
                            <span class="item-text">关闭</span>
                        </div>
                    </div>
                </div>
                <div id="multi" class="row">

                    <div class="col-md-6 group_panel">
                        <div class="panel panel-info">
                            <!-- Default panel contents -->
                            <div class="panel-heading tile__name " data-force="25" draggable="false">
                                <h3 class="panel-heading-title">按优先级</h3>
                                <div class="panel-heading-extra">
                                    <div class="panel-action">
                                        <i class="fa fa-angle-down"></i>
                                        <ul id="stat-priority" data-current-key="priority_stat_undone" style="width:120px;">
                                            <li data-key="priority_stat_undone">未解决事项</li>
                                            <li data-key="priority_stat_done">已解决事项</li>
                                            <li data-key="priority_stat_all">全部事项</li>
                                        </ul>
                                    </div>
                                </div>
                            </div>

                            <!-- Table -->
                            <div class="panel-body">
                                <table class="table">
                                    <thead>
                                    <tr>
                                        <th>优先级</th>
                                        <th>事项</th>
                                        <th>百分比</th>
                                    </tr>
                                    </thead>
                                    {% verbatim %}<script id="priority_stat_tpl" type="text/html" >
                                        {{#list}}
                                        <tr>
                                            <td>{{priority_html id }}</td>
                                            <td>{{count}}</td>
                                            <td>
                                                <div class="progress">
                                                    <div class="progress-outer">
                                                        <div class="progress-bar"
                                                             role="progressbar"
                                                             aria-valuenow="{{percent}}"
                                                             aria-valuemin="0"
                                                             aria-valuemax="100"
                                                             style="min-width: 2em;width:{{percent}}%;
                                                             {{#lessThan percent 30}}
                                                                background-color: #f5222d;
                                                             {{/lessThan}}
                                                             {{#greaterThan percent 90}}
                                                                background-color: #168f48;
                                                             {{/greaterThan}}
                                                            ">
                                                        </div>
                                                    </div>
                                                    <span class="progress-text">{{percent}}%</span>
                                                </div>
                                            </td>
                                        </tr>
                                        {{/list}}
                                    </script>{% endverbatim %}
                                    <tbody id="priority_stat">

                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <div class="panel panel-info">
                            <!-- Default panel contents -->
                            <div class="panel-heading tile__name " data-force="25" draggable="false">
                                <h3 class="panel-heading-title">按开发人员</h3>
                                <div class="panel-heading-extra">
                                    <div class="panel-action">
                                        <i class="fa fa-angle-down"></i>
                                        <ul id="stat-assignee" data-current-key="assignee_stat_undone" style="width:120px;">
                                            <li data-key="assignee_stat_undone">未解决事项</li>
                                            <li data-key="assignee_stat_done">已解决事项</li>
                                            <li data-key="assignee_stat_all">全部事项</li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="panel-body">
                                <!-- Table -->
                                <table class="table">
                                    <thead>
                                    <tr>
                                        <th>开发者</th>
                                        <th>事项</th>
                                        <th>百分比</th>
                                    </tr>
                                    </thead>
                                    {% verbatim %}<script id="assignee_stat_tpl" type="text/html" >
                                        {{#list}}
                                        <tr>
                                            <td>
                                                {{user_html user_id }}
                                            </td>
                                            <td  >{{count}}</td>
                                            <td>
                                                <div class="progress">
                                                    <div class="progress-outer">
                                                        <div class="progress-bar"
                                                             role="progressbar"
                                                             aria-valuenow="{{percent}}"
                                                             aria-valuemin="0"
                                                             aria-valuemax="100"
                                                             style="min-width: 2em;width:{{percent}}%;
                                                             {{#lessThan percent 30}}
                                                                background-color: #f5222d;
                                                             {{/lessThan}}
                                                             {{#greaterThan percent 90}}
                                                                background-color: #168f48;
                                                             {{/greaterThan}}
                                                            ">
                                                        </div>
                                                    </div>
                                                    <span class="progress-text">{{percent}}%</span>
                                                </div>
                                            </td>
                                        </tr>
                                        {{/list}}
                                    </script>{% endverbatim %}

                                    <tbody id="assignee_stat">
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6 group_panel">
                        <div class="panel panel-info">
                            <!-- Default panel contents -->
                            <div class="panel-heading tile__name " data-force="25" draggable="false" >
                                <h3 class="panel-heading-title">按状态</h3>
                            </div>
                            <div class="panel-body">
                                <table class="table">
                                    <thead>
                                    <tr>
                                        <th>状态</th>
                                        <th>事项</th>
                                        <th>百分比</th>
                                    </tr>
                                    </thead>
                                    {% verbatim %}<script id="status_stat_tpl" type="text/html" >
                                        {{#status_stat}}
                                        <tr>
                                            <td>
                                                {{status_html id}}
                                            </td>
                                            <td  >{{count}}</td>
                                            <td>
                                                <div class="progress">
                                                    <div class="progress-outer">
                                                        <div class="progress-bar"
                                                             role="progressbar"
                                                             aria-valuenow="{{percent}}"
                                                             aria-valuemin="0"
                                                             aria-valuemax="100"
                                                             style="min-width: 2em;width:{{percent}}%;
                                                             {{#lessThan percent 30}}
                                                                background-color: #f5222d;
                                                             {{/lessThan}}
                                                             {{#greaterThan percent 90}}
                                                                background-color: #168f48;
                                                             {{/greaterThan}}
                                                            ">
                                                        </div>
                                                    </div>
                                                    <span class="progress-text">{{percent}}%</span>
                                                </div>
                                            </td>
                                        </tr>
                                        {{/status_stat}}
                                    </script>{% endverbatim %}

                                    <tbody id="status_stat">

                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="panel panel-info">
                            <!-- Default panel contents -->
                            <div class="panel-heading tile__name " data-force="25" draggable="false" >
                                <h3 class="panel-heading-title">按事项类型</h3>
                            </div>
                            <div class="panel-body">
                                <!-- Table -->
                                <table class="table">
                                    <thead>
                                    <tr>
                                        <th>类型</th>
                                        <th>事项</th>
                                        <th>百分比</th>
                                    </tr>
                                    </thead>
                                    {% verbatim %}<script id="type_stat_tpl" type="text/html" >
                                        {{#type_stat}}
                                        <tr>
                                            <td>
                                                {{issue_type_html id }}
                                            </td>
                                            <td  >{{count}}</td>
                                            <td>
                                                <div class="progress">
                                                    <div class="progress-outer">
                                                        <div class="progress-bar"
                                                             role="progressbar"
                                                             aria-valuenow="{{percent}}"
                                                             aria-valuemin="0"
                                                             aria-valuemax="100"
                                                             style="min-width: 2em;width:{{percent}}%;
                                                             {{#lessThan percent 30}}
                                                                background-color: #f5222d;
                                                             {{/lessThan}}
                                                             {{#greaterThan percent 90}}
                                                                background-color: #168f48;
                                                             {{/greaterThan}}
                                                            ">
                                                        </div>
                                                    </div>
                                                    <span class="progress-text">{{percent}}%</span>
                                                </div>
                                            </td>
                                        </tr>
                                        {{/type_stat}}
                                    </script>{% endverbatim %}

                                    <tbody id="type_stat">

                                    </tbody>
                                </table>
                            </div>
                        </div>
						
						<div class="panel panel-info">
                            <!-- Default panel contents -->
                            <div class="panel-heading tile__name " data-force="25" draggable="false" >
                                <h3 class="panel-heading-title">用户权重值</h3>
                            </div>
                            <div class="panel-body">
                                <!-- Table -->
                                <table class="table">
                                    <thead>
                                    <tr>
                                        <th>用户</th>
                                        <th>权重累计</th>
                                        <th>百分比</th>
                                    </tr>
                                    </thead>
                                    {% verbatim %}<script id="weight_stat_tpl" type="text/html" >
                                        {{#weight_stat}}
                                        <tr>
                                            <td>
                                                {{user_html user_id }}
                                            </td>
                                            <td  >{{count}}</td>
                                            <td>
                                                <div class="progress">
                                                    <div class="progress-outer">
                                                        <div class="progress-bar"
                                                             role="progressbar"
                                                             aria-valuenow="{{percent}}"
                                                             aria-valuemin="0"
                                                             aria-valuemax="100"
                                                             style="min-width: 2em;width:{{percent}}%;
                                                             {{#lessThan percent 30}}
                                                                background-color: #f5222d;
                                                             {{/lessThan}}
                                                             {{#greaterThan percent 90}}
                                                                background-color: #168f48;
                                                             {{/greaterThan}}
                                                            ">
                                                        </div>
                                                    </div>
                                                    <span class="progress-text">{{percent}}%</span>
                                                </div>
                                            </td>
                                        </tr>
                                        {{/weight_stat}}
                                    </script>{% endverbatim %}

                                    <tbody id="weight_stat">

                                    </tbody>
                                </table>
                            </div>
                        </div>
						
						
                    </div>

                </div>
            </div>
        </div>
    </div>
    </div>
</div>
 </div>
</section>

<script src="/dev/lib/handlebars-v4.0.10.js" type="text/javascript" charset="utf-8"></script>
<script src="/dev/js/handlebars.helper.js?v=<?=_version?>" type="text/javascript" charset="utf-8"></script>
<script src="/dev/js/panel.js" type="text/javascript" charset="utf-8"></script>
<script src="/dev/lib/sortable/Sortable.js"></script>

<script type="text/javascript">

    var _cur_project_id = '<?=project_id?>';
    var _active_sprint_id = '<?=active_sprint_id?>';

    var _issueConfig = {
        "priority":<?=priority|json_encode()|raw?>,
        "issue_types":<?=issue_types|json_encode()|raw?>,
        "issue_status":<?=issue_status|json_encode()|raw?>,
        "issue_resolve":<?=issue_resolve|json_encode()|raw?>,
        "issue_module":<?=project_modules|json_encode()|raw?>,
        "issue_version":<?=project_versions|json_encode()|raw?>,
        "issue_labels":<?=project_labels|json_encode()|raw?>,
        "users":<?=users|json_encode()|raw?>,
        "project_users":<?=project_users|json_encode()|raw?>,
        "projects":<?=projects|json_encode()|raw?>
    };

    var $panel = null;
    var _cur_page = 1;

    $(function() {
        var options = {
        }
        window.$panel = new Panel( options );
        //window.$panel.fetchSprintStat(_active_sprint_id);
        window.$panel.fetchSprintStat(_active_sprint_id).then(res => {
            $("#stat-assignee").on("click", "li", function(e){
                var key = $(this).data("key")
                var data = {
                    list: res[key]
                }
                $("#stat-assignee").attr("data-current-key", key)
                var source = $('#assignee_stat_tpl').html();
                var template = Handlebars.compile(source);
                var result = template(data);
                $('#assignee_stat').html(result);
                console.log(data)
            })

            $("#stat-priority").on("click", "li", function(e){
                var key = $(this).data("key")
                if(!res[key]) return
                var data = {
                    list: res[key]
                }
                $("#stat-priority").attr("data-current-key", key)
                var source = $('#priority_stat_tpl').html();
                var template = Handlebars.compile(source);
                var result = template(data);
                $('#priority_stat').html(result);
            })
        })

        $(document).on("click", ".panel-action i", function (e) {
            e.preventDefault();
            e.stopPropagation();
            $(this).siblings("ul").slideDown(100);
        });

        $(document).on("click", function () {
            $(".panel-action ul").slideUp(100);
        });


    });

</script>
</body>
</html>

