<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TaskList.ascx.cs" Inherits="APC.Forms.BaseUserControls.TaskList" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<script language="javascript">
    var onInfoTipBeforeShow = function (toolTip, grid) 
    {
        // routine to determine if a tooltip needs to be shown
        var view = grid.getView();
        var record = view.getRecord(toolTip.triggerElement);
        if (record.data.ToolTip == null || record.data.ToolTip == '')
            return false;
        return true;
    }
    var onInfoTipShow = function (toolTip, grid) {
        // routine to show the info tooltip on the row of the trip
        var view = grid.getView();
        var record = view.getRecord(toolTip.triggerElement);
        toolTip.update(record.data.ToolTip);
    };
</script>
 <ext:GridPanel ID="TaskPanel" runat="server" AnchorHorizontal="100%" AnchorVertical="100%">
 <TopBar>
            <ext:Toolbar ID="Toolbar2" runat="server" Dock="Top">
            <Items>
                 <ext:SplitButton ID="SplitButton1" runat="server" Text="Capture New..." Icon="Add">
                                    <Menu>
                                        <ext:Menu ID="Menu1" runat="server">
                                            <Items>
                                                 <ext:MenuItem ID="MenuItem3" runat="server" Text="Finance" Icon="Money">
                                                    <Menu>
                                                        <ext:Menu>
                                                            <Items>                                                 
                                                                <ext:MenuItem ID="MenuItem1" runat="server" Text="External Payment Request" Icon="ApplicationAdd">
                                                                <DirectEvents>
                                                                    <Click OnEvent="OpenWorkflow">
                                                                        <EventMask ShowMask="true"/>
                                                                        <ExtraParams>
                                                                        <ext:Parameter Name="ProcessId" Value="1"></ext:Parameter>
                                                                        <ext:Parameter Name="TaskId" Value="0"></ext:Parameter>
                                                                        <ext:Parameter Name="ClassName" Value="NewExternalPaymentRequest"></ext:Parameter>
                                                                        </ExtraParams>
                                                                    </Click>
                                                                </DirectEvents>
                                                                </ext:MenuItem>
                                                                <ext:MenuItem ID="MenuItem2" runat="server" Text="Payment Request (via Import)" Icon="ApplicationAdd">
                                                                <DirectEvents>
                                                                    <Click OnEvent="OpenWorkflow">
                                                                        <EventMask ShowMask="true"/>
                                                                        <ExtraParams>
                                                                        <ext:Parameter Name="ProcessId" Value="0"></ext:Parameter>
                                                                        <ext:Parameter Name="TaskId" Value="0"></ext:Parameter>
                                                                        <ext:Parameter Name="ClassName" Value="ImportPaymentRequest"></ext:Parameter>
                                                                        </ExtraParams>
                                                                    </Click>
                                                                </DirectEvents>
                                                                </ext:MenuItem>

                                                            </Items>
                                                        </ext:Menu>
                                                    </Menu>
                                                    </ext:MenuItem>
                                            </Items>
                                        </ext:Menu>
                                    </Menu>
                                </ext:SplitButton>
                  <ext:ToolbarFill />
                      
                        <ext:Button ID="btnOutstanding" runat="server" Text="View Outstanding Tasks" Icon="Reload">
                        <DirectEvents>
                        <Click OnEvent="btnOutstanding_Click" Success="#{TaskPanel}.store.reload();">
                         <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{Panel2}" />
                         </Click>
                        </DirectEvents>
                        </ext:Button>
            </Items>
            </ext:Toolbar>

 </TopBar>
 <Store>
<ext:Store ID="Store1" runat="server" OnReadData="TaskList_Refresh" GroupField="Status">
    <Model>
        <ext:Model runat="server" IDProperty="Oid">
     <Fields>
        <ext:ModelField Name="ProcessId"/>
        <ext:ModelField Name="DocumentId"/>
        <ext:ModelField Name="StepNo" />
        <ext:ModelField Name="ProcessDescription"/>
        <ext:ModelField Name="StepDescription"/>
        <ext:ModelField Name="CurrentUser"/>
        <ext:ModelField Name="LastUser"/>
        <ext:ModelField Name="StatusInt"/>
        <ext:ModelField Name="Status"/>
        <ext:ModelField Name="AssignedDate" SortType=AsDate Type=Date/>
        <ext:ModelField Name="LastUpdated" SortType=AsDate Type=Date/>
        <ext:ModelField Name="Information"/>
        <ext:ModelField Name="ClassName" />
        <ext:ModelField Name="ToolTip" />
    </Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
       <ColumnModel>
            <Columns>
                 <ext:RowNumbererColumn runat="server" Width="35" />
                 <ext:DateColumn runat="server" Format="yyyy-MM-dd hh:mmtt" Text="Assigned" DataIndex="AssignedDate" Width="130" Sortable="True" Groupable="false"/>
                 <ext:Column runat="server" Text="Reference" DataIndex="DocumentId" Width="80" Sortable="True" Groupable="false"/>
                 <ext:Column runat="server" Text="Information" DataIndex="Information" Width="150" Sortable="True" Groupable="false" Flex=1/>       
                 <ext:Column ID="Column2" runat="server" Text="Type" DataIndex="ProcessDescription" Width="200" Sortable="True" Groupable="true"/>             
                <ext:Column runat="server" Text="Step" DataIndex="StepDescription" Width="200" Sortable="True" Groupable="true"/>                  
                <ext:Column runat="server" Text="Assigned To" DataIndex="CurrentUser" Width="200" Sortable="True" Groupable="true"/>               
            </Columns>            
        </ColumnModel>       
        <SelectionModel>
            <ext:RowSelectionModel runat="server" Mode="Single"/>
        </SelectionModel>
        <View>
                <ext:GridView ID="grdView" runat="server" TrackOver="true" />
            </View>
            <Features>
            <ext:GridFilters Local="true">
            <Filters>
            <ext:StringFilter DataIndex="ProcessDescription" />
            <ext:StringFilter DataIndex="StepDescription" />
            <ext:StringFilter DataIndex="StatusDescription" />
            <ext:StringFilter DataIndex="CurrentUser" />
            <ext:StringFilter DataIndex="LastUser" />
            <ext:NumericFilter DataIndex="Oid" />
            </Filters>
            </ext:GridFilters>
            <ext:Grouping />
            </Features>
            <DirectEvents>
            <ItemDblClick OnEvent="OpenWorkflow">
                <EventMask ShowMask="true"/>
                <ExtraParams>
                   <ext:Parameter Name="ProcessId" Value="record.get('ProcessId')" Mode="Raw"></ext:Parameter>
                   <ext:Parameter Name="TaskId" Value="record.get('Oid')" Mode="Raw"></ext:Parameter>
                   <ext:Parameter Name="ClassName" Value="record.get('ClassName')" Mode="Raw"></ext:Parameter>
                </ExtraParams>
            </ItemDblClick>
            </DirectEvents>
</ext:GridPanel>
  <ext:ToolTip ID="ToolTip" 
            runat="server" 
            Target="={#{TaskPanel}.getView().el}"
             Delegate="tr.x-grid-row"
            TrackMouse="true">
            <Listeners>
                <BeforeShow Handler="onInfoTipBeforeShow(this,#{TaskPanel});"/>

                <Show Handler="onInfoTipShow(this, #{TaskPanel});" />
            </Listeners>
        </ext:ToolTip>             