<%@ taglib uri="webwork" prefix="webwork" %>
<%@ taglib uri="webwork" prefix="ui" %>
<%-- Large 'todo' in this file.  Fix up the duplication with the way the histograms / stats are presented --%>
<webwork:bean id="fieldVisibility" name="'com.atlassian.jira.web.bean.FieldVisibilityBean'" />

<webwork:property value="/statAccessor" id="StatAccessor" />
<webwork:property value="/allStatAccessor" id="AllStatAccessor" />

<br><h3 class="formtitle"><webwork:text name="'common.concepts.projectsummary'" /></h3>
<table cellpadding="2" cellspacing="0" border="0" width="90%" align="center">
<webwork:property value="@AllStatAccessor/allFilterBy('statuses')">
<webwork:iterator value="./keySet">
    <webwork:if test="../(.) != 0 ">
    <tr>
        <td valign="top" width="1%">
            <a href="<%= request.getContextPath() %>/secure/IssueNavigator.jspa?reset=true&pid=<webwork:property value="../long('id')"/>&status=<webwork:property value="./string('id')" />">
            <webwork:component name="''" template="constanticon.jsp">
                <webwork:param name="'contextPath'"><%= request.getContextPath() %></webwork:param>
                <webwork:param name="'iconurl'" value="./string('iconurl')" />
                <webwork:param name="'title'"><webwork:property value="/nameTranslation(.)" /></webwork:param>
                <webwork:param name="'alt'"><webwork:property value="/nameTranslation(.)" /></webwork:param>
            </webwork:component>
            </a>
        </td>
        <td nowrap>
            <a href="<%= request.getContextPath() %>/secure/IssueNavigator.jspa?reset=true&pid=<webwork:property value="../long('id')"/>&status=<webwork:property value="./string('id')" />"><webwork:property value="/nameTranslation(.)" /></a>
        </td>
        <td align="right">
            <webwork:property value="../(.)"/>
        </td>
        <td width="60%">
            <ui:component name="''" template="histogram.jsp">
                <ui:param name="'percentage'" value="../percentage(.)" />
                <ui:param name="'title'" value="./string('name')" />
            </ui:component>
        </td>
    </tr>
    </webwork:if>
</webwork:iterator>
</webwork:property>

</table>

<webwork:property value="/project/long('id')">

    <%-- Do not show the title if either priority and assignee fields are hidden for all issues --%>
    <webwork:if test="@fieldVisibility/fieldHiddenInAllSchemes(., 'priority') == false || @fieldVisibility/fieldHiddenInAllSchemes(., 'assignee') == false ">
    <br><h3 class="formtitle"><webwork:text name="'common.concepts.openissues'" /></h3>
    </webwork:if>

    <%-- Do not show the "open by priority" stats if the priority field is hidden for all issues --%>
    <webwork:if test="@fieldVisibility/fieldHiddenInAllSchemes(., 'priority') == false">
        <b><webwork:text name="'common.concepts.bypriority'" /></b><br>

        <table cellpadding="2" cellspacing="0" border="0" width="90%" align="center">
         <webwork:property value="@StatAccessor/allFilterBy('priorities')">
         <webwork:iterator value="./keySet">
             <webwork:if test=". != null && . != '' && ../(.) != 0 ">
             <tr>
                 <td valign="top" width="1%">
                     <a href="<%= request.getContextPath() %>/secure/IssueNavigator.jspa?reset=true&pid=<webwork:property value="../.." />&priority=<webwork:url value="./string('id')" />&resolution=-1">
                     <webwork:component name="'priority'" template="constanticon.jsp">
                         <webwork:param name="'contextPath'"><%= request.getContextPath() %></webwork:param>
                         <webwork:param name="'iconurl'" value="./string('iconurl')" />
                         <webwork:param name="'title'"><webwork:property value="/nameTranslation(.)" /></webwork:param>
                         <webwork:param name="'alt'"><webwork:property value="/nameTranslation(.)" /></webwork:param>
                     </webwork:component>
                     </a>
                 </td>
                 <td valign="top">
                     <a href="<%= request.getContextPath() %>/secure/IssueNavigator.jspa?reset=true&pid=<webwork:property value="../.." />&priority=<webwork:url value="./string('id')" />&resolution=-1"><webwork:property value="/nameTranslation(.)" /></a>
                 </td>
                 <td align="right">
                     <webwork:property value="../(.)"/>
                 </td>
                 <td width="60%">
                     <ui:component name="''" template="histogram.jsp">
                         <ui:param name="'percentage'" value="percentage(.)" />
                         <ui:param name="'title'" value="./string('name')" />
                     </ui:component>
                 </td>
             </tr>
             </webwork:if>
             <!-- Display issues that do not have a priority -->
             <webwork:elseIf test="nullKeyValue() != 0">
                <tr>
                    <td valign="top" width="1%"></td>
                    <td valign="top">
                        <a href="<%= request.getContextPath() %>/secure/IssueNavigator.jspa?reset=true&pid=<webwork:property value="../../string('id')" />&priority=-1&resolution=-1"><webwork:text name="'common.words.none'" /></a>
                    </td>
                    <td align="right"><webwork:property value="nullKeyValue()" /></td>
                    <td width="60%">
                     <ui:component name="''" template="histogram.jsp">
                         <ui:param name="'percentage'" value="percentage(.)" />
                         <ui:param name="'title'" value="./string('name')" />
                     </ui:component>
                 </td>
                </tr>
             </webwork:elseIf>
         </webwork:iterator>
         </webwork:property>

        </table>
    </webwork:if>

    <%-- Do not show the "open by assignee" stats if the assignee field is hidden in all issues--%>
    <webwork:if test="@fieldVisibility/fieldHiddenInAllSchemes(., 'assignee') == false">
    <p>
        <b><webwork:text name="'common.concepts.byassignee'" /></b><br>
        <table cellpadding="2" cellspacing="0" border="0" width="90%" align="center">
         <webwork:property value="@StatAccessor/allFilterBy('assignees')">
         <webwork:if test=". != null">
         <webwork:iterator value="./entrySet">
             <tr>
             <webwork:if test="key == null">
                 <td valign="top" ><a href="<webwork:url page="/secure/IssueNavigator.jspa"><webwork:param name="'reset'" value="'true'"/><webwork:param name="'mode'" value="'hide'"/><webwork:param name="'sorter/order'" value="'DESC'"/><webwork:param name="'sorter/field'" value="'priority'"/><webwork:param name="'pid'" value="../.."/><webwork:param name="'assigneeSelect'" value="'unassigned'"/><webwork:param name="'resolution'" value="'-1'"/></webwork:url>"><webwork:text name="'common.concepts.unassigned'"/></a></td>
                 <td valign="top" align="right"><webwork:property value="value" /></td>
                 <td width="60%">
                     <ui:component name="''" template="histogram.jsp">
                         <ui:param name="'percentage'" value="percentage(key)" />
                         <ui:param name="'title'" value="Unassigned" />
                     </ui:component>
                 </td>
             </webwork:if>
             <webwork:elseIf test="value != 0 ">
                 <td valign="top" nowrap>
                     <a href="<webwork:url page="/secure/IssueNavigator.jspa"><webwork:param name="'reset'" value="'true'"/><webwork:param name="'mode'" value="'hide'"/><webwork:param name="'sorter/order'" value="'DESC'"/><webwork:param name="'sorter/field'" value="'priority'"/><webwork:param name="'pid'" value="../.."/><webwork:param name="'assigneeSelect'" value="'specificuser'"/><webwork:param name="'assignee'" value="key/name" /><webwork:param name="'resolution'" value="'-1'"/></webwork:url>"><webwork:property value="key/fullName" /></a>
                 </td>
                 <td valign="top" align="right"><webwork:property value="value" /></td>
                 <td width="60%">
                     <ui:component name="''" template="histogram.jsp">
                         <ui:param name="'percentage'" value="../percentage(key)" />
                         <ui:param name="'title'" value="./string('name')" />
                     </ui:component>
                 </td>
             </webwork:elseIf>
             </tr>
         </webwork:iterator>
         </webwork:if>
         </webwork:property>

        </table>
    </p>
    </webwork:if>

</webwork:property>
