<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExtPaymentRequest.aspx.cs" Inherits="APC.Forms.Workflow.ExtPaymentRequest" EnableSessionState="True" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<%@ Register TagPrefix="uc1" TagName="attachments" Src="~/Forms/Workflow/PaymentReqAttachList.ascx"%>
<%@ Register TagPrefix="uc2" TagName="addAttach" Src="~/Forms/Workflow/AddPaymentReqAttach.ascx"%>
<%@ Register TagPrefix="uc3" TagName="wireInfo" Src="~/Forms/UserControls/WireInfo.ascx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="../../Scripts/script.js"></script>
<style>
 .x-grid-row-summary .x-grid-cell-inner 
 {
            font-weight      : bold;
            font-size        : 11px;
            background-color : #f1f2f4;
        } 

</style>
</head>
<body>
    <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager" runat="server"  Theme="Gray" />
         <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
         <Items>
                <ext:Panel ID="pnlContainer" runat="server" Layout="BorderLayout" Region="Center" Border="false">
                <Items>
                 <ext:Panel ID="pnlNorth" runat="server" Region="North" Margins="0 0 0 0" BodyPadding="0"  Layout="VBoxLayout" Frame="true" Border="false">
                    <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch"></ext:VBoxLayoutConfig>
                    </LayoutConfig>
                <Items>
                 <ext:UserControlLoader runat="server" ID="WorkflowInfo" Path="~/Forms/BaseUserControls/WorkflowInfo.ascx" />
                                  <ext:TabPanel ID="TabPanel1" runat="server" Region="Center" Border="false" Height="110">
                 <Items>
                  <ext:Panel ID="pnlMainDetails" 
                        runat="server" 
                        Title="General Information" 
                        Border="false" 
                        BodyPadding="6"
                        Icon="Information" Closable="false" AutoScroll="true" Layout="VBoxLayout">
                        <LayoutConfig>
                            <ext:VBoxLayoutConfig Align="Stretch"></ext:VBoxLayoutConfig>
                        </LayoutConfig>
                       <Items>
                           <ext:UserControlLoader runat="server" ID="PayeeDrop" Path="~/Forms/UserControls/ExtPaymentPayeeList.ascx" />
                           <ext:ComboBox ID="cmbBankAccount" runat="server" Name="Account" FieldLabel="Bank Account" EmptyText="Select a Bank Account" AllowBlank="false" ForceSelection="true" MsgTarget="Side" DisplayField="Description" ValueField="Value" TypeAhead="true" ValueNotFoundText="Loading..." QueryMode="Local" Editable="false">
                          <ListConfig MinWidth="400" />
                           <Store>
                                <ext:Store ID="BankAccountStore" runat="server" OnReadData="BankAccountRefresh">
                                <Model>
                                    <ext:Model ID="BankAccountModel" runat="server" IDProperty="Value">
                                    <Fields>
                                        <ext:ModelField Name="Value" Type="String" Mapping="Value" />
                                        <ext:ModelField Name="Description" Type="String" Mapping="Description" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                            </ext:Store>
                            </Store>
                          </ext:ComboBox>

                                     <ext:ComboBox ID="cmbProgrammeHeader" runat="server" Name="ProgrammeHeader" FieldLabel="Programme" EmptyText="Select a Programme" AllowBlank="false" ForceSelection="true" MsgTarget="Side" DisplayField="Description" ValueField="Value" TypeAhead="true" ValueNotFoundText="Loading..." QueryMode="Local" Editable="false">
          <ListConfig MinWidth="400" />
           <Store>
               <ext:Store ID="ProgrammeStore2" runat="server">
                <Model>
                    <ext:Model ID="ProgrammeModel2" runat="server" IDProperty="Value">
                        <Fields>
                            <ext:ModelField Name="Value" Type="String" Mapping="Value" />
                            <ext:ModelField Name="Description" Type="String" Mapping="Description" />
                        </Fields>
                    </ext:Model>
                </Model>
           </ext:Store>
           </Store>
          <Listeners>
                <Select Handler="#{cmbProjectHeader}.clearValue(); #{cmbProjectHeader}.setDisabled(false); #{ProjectStore2}.reload();#{cmbProjectHeader}.focus(false, 100);" />
          </Listeners>
          </ext:ComboBox>
          <ext:ComboBox ID="cmbProjectHeader" runat="server" Name="ProjectHeader" FieldLabel="Project" EmptyText="Select a Project" AllowBlank="false" ForceSelection="true" MsgTarget="Side" DisplayField="Description" ValueField="Value" TypeAhead="true" ValueNotFoundText="Loading..." QueryMode="Local" Editable="false">
          <ListConfig MinWidth="400" />
           <Store>
                <ext:Store ID="ProjectStore2" runat="server" OnReadData="ProjectRefresh">
                <Model>
                    <ext:Model ID="ProjectModel2" runat="server" IDProperty="Value">
                        <Fields>
                            <ext:ModelField Name="Value" Type="String" Mapping="Value" />
                            <ext:ModelField Name="Description" Type="String" Mapping="Description" />
                        </Fields>
                    </ext:Model>
                </Model>
                </ext:Store>
          </Store>
          </ext:ComboBox>
                        </Items>
                    </ext:Panel>
                    <ext:Panel ID="pnlWireDetails" 
                        runat="server" 
                        Title="Wire Information" 
                        Closable="false" 
                        Border="false" 
                        BodyPadding="6" Layout="AnchorLayout" Frame="true" Icon="Money" AutoScroll="true">
                        <Content>
                            <uc3:wireInfo id="WireInfo" runat="server" />
                        </Content>
                    </ext:Panel>
                    </Items>
                    </ext:TabPanel>

                 <ext:Panel runat="server" Border="false" Layout="BorderLayout" Header="false" Visible="false">
                 <Items>
                    </Items>
                    </ext:Panel>
                </Items>
                </ext:Panel>
                 <ext:Panel ID="pnlItems" Region="Center" runat="server" Frame="true" Layout="AnchorLayout">
                 <Items>
                  <ext:GridPanel ID="grdItems" runat="server" AnchorHorizontal="100%" AnchorVertical="100%">
                 <TopBar>
                        <ext:Toolbar ID="toolItems" runat="server" Dock="Top">
                    <Items>
                     <ext:Button ID="btnAddItem" runat="server" Text="Add New..." Icon="Add">
                        <DirectEvents>
                            <Click OnEvent="AddDetail">
                                <EventMask ShowMask="true"/>
                            </Click>
                        </DirectEvents>
                     </ext:Button>
                     <ext:ToolbarFill />                      
                      <ext:Button ID="btnReloadItems" runat="server" Text="Refresh" Icon="Reload">
                      <Listeners>
                      <Click Handler="#{grdItems}.store.reload();"/>
                      </Listeners>
                      </ext:Button>
            </Items>
            </ext:Toolbar>
            </TopBar>
            <Store>
                <ext:Store ID="storeItems" runat="server" OnReadData="ItemList_Refresh">
                <Model>
                    <ext:Model ID="modelItems" runat="server" IDProperty="Oid">
                    <Fields>
                        <ext:ModelField Name="InvoiceNum"/>
                        <ext:ModelField Name="InvoiceDate" SortType="AsDate" Type="Date"/>
                        <ext:ModelField Name="Description" />
                        <ext:ModelField Name="ProgrammeDesc"/>
                        <ext:ModelField Name="ProjectDesc"/>
                        <ext:ModelField Name="ActivityDesc"/>
                        <ext:ModelField Name="AccountDesc"/>
                        <ext:ModelField Name="Currency"/>
                        <ext:ModelField Name="Amount" SortType="AsFloat" Type="Float"/>
                        <ext:ModelField Name="USDAmount" SortType="AsFloat" Type="Float"/>
                    </Fields>
                </ext:Model>
                </Model>
                </ext:Store>
               </Store>
                <ColumnModel>
                <Columns>
                 <ext:RowNumbererColumn ID="rnumItems" runat="server" Width="35" />
                 <ext:Column ID="colDescription" runat="server" Text="Description" DataIndex="Description" Width="300" Flex="1" Sortable="True" MinWidth="200"/>
                 <ext:SummaryColumn ID="colAmount" runat="server" Text="Amount" DataIndex="Amount" Width="150" SummaryType="Sum">
                 <Renderer Fn="Ext.util.Format.numberRenderer('0000.00')" />
                 <SummaryRenderer Fn="Ext.util.Format.numberRenderer('0000.00')" />
                 </ext:SummaryColumn>
                  <ext:SummaryColumn ID="colUSDAmount" runat="server" Text="USD Amount" DataIndex="USDAmount" Width="150" SummaryType="Sum">
                  <SummaryRenderer Fn="Ext.util.Format.usMoney" />
                  <Renderer Format="UsMoney"/>
                  </ext:SummaryColumn>
                  <ext:Column ID="colCurrency" runat="server" Text="Currency" DataIndex="Currency" Width="80" Sortable="False"/>
                  <ext:Column ID="colAccount" runat="server" Text="Account" DataIndex="AccountDesc" Width="150" Sortable="True"/>
                  <ext:Column ID="colInvoice" runat="server" Text="Sup Doc Ref" DataIndex="InvoiceNum" Width="200" Sortable="False"/>
                  <ext:DateColumn ID="colInvoiceDate" runat="server" Text="Sup Doc Date" DataIndex="InvoiceDate" Width="200" Sortable="True" />

            </Columns>            
        </ColumnModel>       
        <Features>               
                <ext:Summary ID="Summary1" runat="server" />                   
            </Features>
        <SelectionModel>
            <ext:RowSelectionModel ID="rsmItems" runat="server" Mode="Single">
            <DirectEvents>
                <Select OnEvent="LoadDetail" Buffer="250">
                    <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{DetailsPanel}" />
                        <ExtraParams>
                            <ext:Parameter Name="LineId" Value="record.getId()" Mode="Raw" />
                        </ExtraParams>
                 </Select>
           </DirectEvents>
           </ext:RowSelectionModel>
        </SelectionModel>
</ext:GridPanel>
                  </Items>
                </ext:Panel>
               <ext:Panel Region="East" Split="true" Width="300" Frame="true" Collapsible="true" runat="server" Title="Line Details" ID="DetailsPanel">
                <Items>
                 <ext:TabPanel ID="tabLineInfo" runat="server" Region="East">
                 <Items>
                  <ext:Panel ID="pnlLineInfo" 
                        runat="server" 
                        Title="Line Information" 
                        Border="false" 
                        BodyPadding="6"
                        Icon="Tab" Closable="false" AutoScroll="true" Layout="AnchorLayout" Height="270">
                        <Items>
                            <ext:UserControlLoader runat="server" ID="EditForm2"/>
                        </Items>
                    </ext:Panel>
                    <ext:Panel ID="pnlLineAttach" 
                        runat="server" 
                        Title="Attachments" 
                        Closable="false" 
                        Border="false" 
                        BodyPadding="6" Layout="AnchorLayout" Frame=true>
                        <Content>
                            <uc1:attachments id="AttachList" runat="server" />
                        </Content>
                    </ext:Panel>
                    </Items>
                    </ext:TabPanel>
                </Items>
        </ext:Panel>
                </Items>
                </ext:Panel>
        </Items>
         </ext:Viewport>
          <uc2:addattach id="AddAttach" runat="server" />
    </form>
</body>
</html>
