<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ExtPaymentRequestLineEdit.ascx.cs" Inherits="APC.Forms.Workflow.ExtPaymentRequestLineEdit" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    <ext:FormPanel 
        ID="FormPanel1" 
        runat="server"
        AutoHeight="true"
        AutoWidth="true"
        BodyPadding="0"
        DefaultAnchor="100%" Header="false" BodyBorder="0" Border="true" ForceFit="true">
        <Items>
          <ext:DateField ID="dteInvoice" runat="server" FieldLabel="Sup Doc Date" Name="InvoiceDate" Format="yyyy-MM-dd" AllowBlank="False" MsgTarget="Side"/>
          <ext:TextField ID="txtInvoiceNum" runat="server" FieldLabel="Sup Doc Ref" Name="InvoiceNum" AllowBlank="false" MsgTarget=Side />
          <ext:TextField ID="txtDescription" runat="server" FieldLabel="Description" Name="Description" AllowBlank="false" MsgTarget=Side />
          <ext:ComboBox ID="cmbProgramme" runat="server" Name="Programme" 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="ProgrammeStore" runat="server" OnReadData="ProgrammeRefresh">
                <Model>
                    <ext:Model ID="ProgrammeModel" 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="#{cmbProject}.clearValue(); #{cmbProject}.setDisabled(false); #{cmbActivity}.clearValue(); #{cmbActivity}.setDisabled(true); #{cmbAccount}.clearValue(); #{cmbAccount}.setDisabled(true);#{ProjectStore}.reload();#{cmbProject}.focus(false, 100);" />
          </Listeners>
          </ext:ComboBox>
          <ext:ComboBox ID="cmbProject" runat="server" Name="Project" 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="ProjectStore" runat="server" OnReadData="ProjectRefresh">
                <Model>
                    <ext:Model ID="ProjectModel" 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="#{cmbActivity}.clearValue(); #{cmbActivity}.setDisabled(false); #{cmbAccount}.clearValue(); #{cmbAccount}.setDisabled(true); #{ActivityStore}.reload();#{cmbActivity}.focus(false, 100);" />
          </Listeners>
          </ext:ComboBox>
          <ext:ComboBox ID="cmbActivity" runat="server" Name="Activity" FieldLabel="Activity" EmptyText="Select a Activity" 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="ActivityStore" runat="server" OnReadData="ActivityRefresh">
                <Model>
                    <ext:Model ID="ActivityModel" 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="#{cmbAccount}.clearValue(); #{cmbAccount}.setDisabled(false); #{AccountStore}.reload();#{cmbAccount}.focus(false, 100);" />
          </Listeners>
          </ext:ComboBox>
          <ext:ComboBox ID="cmbAccount" runat="server" Name="SubActivity" FieldLabel="Account" EmptyText="Select a Pastel 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="AccountStore" runat="server" OnReadData="AccountRefresh">
                <Model>
                    <ext:Model ID="AccountModel" 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:UserControlLoader ID="CurrencyControl" Path="~/Forms/UserControls/CurrencyCapture.ascx" runat="server" />
          <ext:TextArea ID="txtNotes" runat="server" FieldLabel="Notes" Height="40" Name="Notes" AutoScroll=true />
        </Items>     
                                <TopBar>
                            <ext:Toolbar ID="toolEdit" runat="server">
                             <Items>
                                         <ext:Button runat="server" Text="Save" Icon="Disk" ID="btnAccept">
                                            <DirectEvents>
                                            <Click OnEvent="SaveRecord" Before="return #{FormPanel1}.isValid();" Success="#{grdItems}.store.reload();">
                                            <ExtraParams>
                                                <ext:Parameter Name="values" Value="#{FormPanel1}.getForm().getValues()" Mode="Raw" Encode="true"/>
                                            </ExtraParams>
                                            </Click>
                                            </DirectEvents>
                                          </ext:Button>     
                                          <ext:Button runat="server" Text="Delete" Icon="Delete" ID="btnDelete">
                                            <DirectEvents>
                                            <Click OnEvent="DeleteRecord" Success="#{grdItems}.store.reload();">
                                            <Confirmation ConfirmRequest="true" Title="Delete Line" Message="Are you sure you wish to Delete this Line Item ?"/>
                                            </Click>
                                            </DirectEvents>
                                          </ext:Button>     

                                <ext:ToolbarFill />
                              </Items>
                              </ext:Toolbar>                        
                            </TopBar>
   
    </ext:FormPanel>