<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CurrencyCapture.ascx.cs" Inherits="APC.Forms.UserControls.CurrencyCapture" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<script>
function onCurrencyChange(combo, ratevalue, dteRate, urlRate, numUSD)
{
    // routine to manage when the user changes the currency information
    if(combo.valueModels.length > 0) 
    {
        // set the icon flag
        combo.setIconCls(combo.valueModels[0].get('IconClass'));

        var disabled = (combo.getValue() == 'USD');
        numUSD.setDisabled(disabled);
        ratevalue.setDisabled(disabled);
        dteRate.setDisabled(disabled);
        urlRate.setDisabled(disabled);
        if (disabled) 
        {
            ratevalue.reset();
            dteRate.reset();
            urlRate.reset();
            numUSD.reset();
        }
        else 
        {
            ratevalue.focus();
        }
    }
}
</script>
 <style>
        .icon-combo-item 
        {
            background-repeat   : no-repeat !important;
            background-position : 3px 50% !important;
            padding-left        : 24px !important;
        }
    </style>
          <ext:NumberField ID="numAmount" runat="server" Name="Amount" FieldLabel="Amount" AllowDecimals="true" AllowBlank="false" MsgTarget=Side  DecimalPrecision="2" Step="0.2" TrimTrailedZeros="False"/>
          <ext:ComboBox ID="cmbCurrency" runat="server" Name="Currency" FieldLabel="Currency" Editable="false" DisplayField="Description" ValueField="Code" QueryMode="Local" TriggerAction="All" EmptyText="Please select a Currency...">
          <Store>
          <ext:Store runat="server">
            <Model>
                <ext:Model runat="server">
                <Fields>
                    <ext:ModelField Name="IconClass" />
                    <ext:ModelField Name="Code"/>
                    <ext:ModelField Name="Description"/>
                </Fields>
                </ext:Model>
            </Model>
            </ext:Store>  
            </Store>
            <ListConfig MinWidth="200">
                <ItemTpl ID="ItemTpl1" runat="server">
                <Html>
                    <div class="icon-combo-item {IconClass}">{Description} ({Code})</div>
                </Html>
                </ItemTpl>
            </ListConfig>
             <Listeners>
                <Change Handler="onCurrencyChange(this, #{numRate}, #{dteRate}, #{txtUrlRate}, #{numUSD});" />
            </Listeners>  
          </ext:ComboBox>
          <ext:FieldSet runat="server" Title="Rate Details" Layout="FitLayout" AutoWidth="True" ForceFit="true">
          <Items>
          <ext:FieldContainer runat="server" ID="containCurrency" CombineErrors="true" MsgTarget="Under" Layout="FormLayout">
          <Items>
                <ext:NumberField ID="numRate" runat="server" Name="Rate" FieldLabel="Rate" AllowDecimals="true" AllowBlank="false" MsgTarget=Side  DecimalPrecision="2" Step="0.2" Disabled="true" TrimTrailedZeros="False" />
                <ext:DateField ID="dteRate" runat="server"   Name="RateDate" FieldLabel="Date"  Format="yyyy-MM-dd" AllowBlank="true" MsgTarget="Side" Disabled="true" />
                <ext:TextField ID="txtUrlRate" runat="server" Name="RateURL" FieldLabel="Source" AllowBlank=false MsgTarget="Side"  Disabled="true"/>
                <ext:NumberField ID="numUSD" runat="server" Name="USD" FieldLabel="USD Amount" AllowDecimals="true" AllowBlank="false" MsgTarget=Side  DecimalPrecision="2" Step="0.2" Disabled="true" TrimTrailedZeros="false"/>
          </Items>
          </ext:FieldContainer>
          </Items>
          </ext:FieldSet>