﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:include href="GenericTemplates/Item.xslt" />
    <xsl:template match="/">
        <xsl:variable name ="TemplatePathURL" select ="ActionReport/TemplateURL"></xsl:variable>

        <xsl:if test ="ActionReport/Mode = 'DashBoard' or 
                (ActionReport/Params/Mode = 'MyItems' and  normalize-space(ActionReport/Action) = 'DisplayMyTaskReport')">
            <div id="divActionReportControl_Container" style="border: 2px solid #385D8A;">
                <table>
                    <tr>
                        <td width="100%">
                            <div id="divActionReport_Title"
                                 style="float:left; 
                                overflow:hidden;
                                background-color:
                                white;border: 2px solid #385D8A;
                                margin-top:-10px; 
                                margin-left:-10px;
                                width:150px;
                                height:25px;
                                position:relative; text-align:center;"
                                onClick='return GetItemReport("divDashBoard_Content","{ActionReport/Params/ItemID}")'
                                class="link">
                                <span class="labelHeader">Do It</span>
                            </div>
                        </td>
                    </tr>
                    <xsl:if test="ActionReport/Mode = 'DashBoard'">
                        <tr>
                            <td>
                                <div id="divActionReport" style="margin-left:20px; margin-top:10px;" class="label">
                                    <div>
                                        <img id="TaskReport_Img_ItemSummary1" style="display:inline"
                                                 src="{$TemplatePathURL}Web/Icons/Action Not Started/32 Bit Alpha png/Action Not Started 16 n p.png" title="Not Started" />
                                        <span style="margin-left:5px;margin-right:5px;">
                                            <b>
                                                <xsl:value-of select="ActionReport/MyItemsSummary/Current"></xsl:value-of> Current
                                            </b>
                                        </span>
                                        <img id="TaskReport_Img_ItemSummary3" style="display:inline"
                                             src="{$TemplatePathURL}Web/Icons/Action In Progress/32 Bit Alpha png/Action In Progress 16 n p.png" title="In Progress" />
                                        <span style="margin-left:5px;margin-right:5px;">
                                            <b>
                                                <xsl:value-of select="ActionReport/MyItemsSummary/InProgress"></xsl:value-of> In Progress
                                            </b>
                                        </span>
                                        <img id="TaskReport_Img_ItemSummary2" style="display:inline"
                                                 src="{$TemplatePathURL}Web/Icons/Action Past Due/32 Bit Alpha png/Action Past Due 16 n p.png" title="Past Due" />
                                        <span style="margin-left:5px;margin-right:5px;">
                                            <b>
                                                <xsl:value-of select="ActionReport/MyItemsSummary/PastDue"></xsl:value-of> Past Due
                                            </b>
                                        </span>
                                    </div>
                                    <div onClick='return GetItemReport("divDashBoard_Content","{ActionReport/ItemID}")'>
                                        <span style="margin-left:30px;margin-top:10px;" class="link">
                                            <font color="Gray">View All...</font>
                                        </span>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </xsl:if>
                    <xsl:if test="ActionReport/Params/Mode = 'MyItems'">
                        <tr>
                            <td>
                                <xsl:variable name ="GoalID" select ="ActionReport/GoalID"></xsl:variable>
                                <xsl:if test ="normalize-space(ActionReport/Action) = 'DisplayMyTaskReport'">
                                    <div id="divActionReportControl" class="body" style="margin:15px;">
                                        <div id="divActionReport_Filters" style="margin-bottom:25px;">
                                            <input id="rbOrderTaskReportByGoal" type="radio" name="orderByTaskReport" checked="true" onclick='myTaskReport_Grouping("divActionReport");'>
                                                <span class="taskFilter spaceRt">By Goal</span>
                                            </input>
                                            <input id="rbOrderTaskReportByDate" type="radio" name="orderByTaskReport" onclick='myTaskReport_Grouping("divActionReport");'>
                                                <span class="taskFilter spaceRt">By Date</span>
                                            </input>
                                            <input id="chkCurrent" type="checkbox" checked="true" onclick='myTaskReport_Filter_Current("{normalize-space($GoalID)}","divActionReport");'>
                                                <span class="taskFilter spaceRt">Current</span>
                                            </input>
                                            <input id="chkFuture" type="checkbox" onclick='myTaskReport_Filter_Future("{normalize-space($GoalID)}","divActionReport");'>
                                                <span class="taskFilter spaceRt">Future</span>
                                            </input>
                                            <input id="chkCompleted" type="checkbox" style="display:none" onclick='myTaskReport_Filter_Completed("{normalize-space($GoalID)}","divActionReport");'>
                                                <span style="display:none" class="taskFilter spaceRt">Completed</span>
                                            </input>
                                            <input id="chkInProgress" type="checkbox" checked="true" onclick='myTaskReport_Filter_InProgress("{normalize-space($GoalID)}","divActionReport");'>
                                                <span class="taskFilter spaceRt">In Progress</span>
                                            </input>
                                            <input id="chkMyItem" type="checkbox" checked="true" onclick='myTaskReport_Filter_CheckMyItems("{normalize-space($GoalID)}","divActionReport");'>
                                                <span class="taskFilter spaceRt">My Items</span>
                                            </input>
                                            <input id="chkOtherItem" type="checkbox" style="display:none;" onclick='myTaskReport_Filter_CheckOtherUsers("{normalize-space($GoalID)}","divActionReport");'>
                                                <span class="taskFilter spaceRt" style="display:none;">Other's Items</span>
                                            </input>
                                            <input id="chkItemUsers" type="checkbox" onclick='myTaskReport_Filter_CheckSelectedUser("{normalize-space($GoalID)}","divActionReport");'>
                                            </input>
                                            <select id="opt_Item_Report_Users" name="responsible" class="dropdown" onchange='myTaskReport_Filter_SelectedUserChanged("{normalize-space($GoalID)}","divActionReport");'>
                                                <xsl:for-each select="ActionReport/UsersList/Users/User">
                                                    <option value="{ID/.}">
                                                        <xsl:value-of select="normalize-space(FirstName/.)"/>&#xa0;
                                                        <xsl:value-of select="normalize-space(LastName/.)"/>
                                                    </option>
                                                </xsl:for-each>
                                            </select>
                                        </div>
                                        <div id="divActionReport">
                                            <xsl:for-each select="ActionReport/MyReport/Item">
                                                <div id="div_ActionReport_Item_{normalize-space(ID)}_Report" style="margin-top:10px">
                                                    <xsl:call-template name="groupByVariables"></xsl:call-template>
                                                    <xsl:call-template name="displayAction"></xsl:call-template>
                                                    <div id ="div_ActionReport_Item_{normalize-space(ID)}_Seprator" style="margin-top:10px;">
                                                        <img  id="div_ActionReport_{normalize-space(ID)}_seperator_image" src="{normalize-space($TemplatePathURL)}Web/Images/seperator.jpg" ></img>
                                                    </div>
                                                </div>
                                            </xsl:for-each>
                                        </div>
                                    </div>
                                </xsl:if>
                            </td>
                        </tr>
                    </xsl:if>
                </table>
            </div>
        </xsl:if>
        <xsl:if test ="ActionReport/Params/Mode = 'MyItems' and normalize-space(ActionReport/Action) != 'DisplayMyTaskReport'">
            <xsl:for-each select="ActionReport/MyReport/Item">
                <div id="div_ActionReport_Item_{normalize-space(ID)}_Report" style="margin-top:10px;">
                    <xsl:call-template name="groupByVariables"></xsl:call-template>
                    <xsl:call-template name="displayAction"></xsl:call-template>
                    <div id ="div_ActionReport_Item_{normalize-space(ID)}_Seprator" style="margin-top:10px;">
                        <img  id="div_ActionReport_{normalize-space(ID)}_seperator_image" src="{normalize-space($TemplatePathURL)}Web/Images/seperator.jpg" ></img>
                    </div>
                </div>
            </xsl:for-each>
        </xsl:if>

    </xsl:template>

    <xsl:template name ="displayAction">

        <xsl:variable name="ItemDivPrefix">
            <xsl:text>div_ActionReport_Item_</xsl:text>
            <xsl:value-of select ="normalize-space(ID)"></xsl:value-of>
        </xsl:variable>

        <div id="{normalize-space($ItemDivPrefix)}" style="margin-left:15px; margin-right: 5px; margin-bottom: 10px;">
            <xsl:call-template name="Item">
                <xsl:with-param name="TemplatePathURL" select="../../TemplateURL"></xsl:with-param>
                <xsl:with-param name="ItemID" select="normalize-space(ID)"></xsl:with-param>
                <xsl:with-param name="GoalID" select="normalize-space(PrimaryID)"></xsl:with-param>
                <xsl:with-param name="Status" select="normalize-space(Status)"></xsl:with-param>
                <xsl:with-param name="Level" select="normalize-space(Level)"></xsl:with-param>
                <xsl:with-param name="ParentParentID" select="normalize-space(ParentParentID)"></xsl:with-param>
                <xsl:with-param name="ParentID" select="normalize-space(ParentID)"></xsl:with-param>
                <xsl:with-param name="UpperSiblingID" select="normalize-space(UpperSiblingID)"></xsl:with-param>
                <xsl:with-param name="LowerSiblingID" select="normalize-space(LowerSiblingID)"></xsl:with-param>
                <xsl:with-param name="Mode" select="'TaskReport'"></xsl:with-param>

                <xsl:with-param name="PermissionID" select="normalize-space(PermissionID)"></xsl:with-param>
                <xsl:with-param name="LeftDays" select="normalize-space(LeftDays)"></xsl:with-param>
                <xsl:with-param name="DueDate" select="normalize-space(DueDate)"></xsl:with-param>
                <xsl:with-param name="Responsible" select="normalize-space(Responsible)"></xsl:with-param>

                <xsl:with-param name="TotalCount" select="normalize-space(TotalCount)"></xsl:with-param>
                <xsl:with-param name="Completed" select="normalize-space(Completed)"></xsl:with-param>
                <xsl:with-param name="PastDueCount" select="normalize-space(PastDueCount)"></xsl:with-param>
                <xsl:with-param name="Name" select="normalize-space(ItemName)"></xsl:with-param>
                <xsl:with-param name="TypeID" select="normalize-space(TypeID)"></xsl:with-param>
                <xsl:with-param name="TotalChildCount" select="normalize-space(TotalChildCount)"></xsl:with-param>

                <xsl:with-param name="ItemDivPrefix" select ="normalize-space($ItemDivPrefix)"></xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name ="groupByVariables">
        <input type="hidden" id="div_ActionReport_Item_{normalize-space(ID)}_Report_Actor_ID" value="{normalize-space(ResponsibleID)}"></input>
        <input type="hidden" id="div_ActionReport_Item_{normalize-space(ID)}_Report_Left_Days" value="{normalize-space(LeftDays)}"></input>
        <input type="hidden" id="div_ActionReport_Item_{normalize-space(ID)}_Report_Mine_ID" value="{normalize-space(MineID)}"></input>
        <input type="hidden" id="div_ActionReport_Item_{normalize-space(ID)}_Report_Status_ID" value="{normalize-space(StatusID)}"></input>
        <input type="hidden" id="div_ActionReport_Item_{normalize-space(ID)}_Report_HiddenGoal_ID" value="{normalize-space(PrimaryID)}"></input>
        <input type="hidden" id="div_ActionReport_Item_{normalize-space(ID)}_Report_HiddenGoal_Name" value="{normalize-space(PrimaryName)}"></input>
    </xsl:template>

</xsl:stylesheet>