<%@ Page Language="C#" MasterPageFile="~/masterpages/eDashboard.master" AutoEventWireup="true"
    Inherits="site_HITS_OrganizationUnit_Details" Title="Brightstar Device Protection: Organization Unit Details"
    Culture="auto" UICulture="auto" Theme="eMain"
    CodeBehind="Details.aspx.cs" %>
<%@ Register Src="~/Controls/AddressValidationLookup.ascx" TagPrefix="uc" TagName="ucAddressLookupDlg"  %>
<%@ Register Src="~/Controls/PhoneNumber.ascx" TagName="PhoneNumber" TagPrefix="uc1" %>
<%@ Register Src="~/Controls/ChildHeader.ascx" TagName="ChildHeader" TagPrefix="uc" %>
<%@ Register Src="~/Controls/ScriptingHelper.ascx" TagName="ScriptingHelper" TagPrefix="uc" %>
<%@ Register Src="~/Controls/PersistNav.ascx" TagName="PersistNav" TagPrefix="uc" %>
<%@ Register TagPrefix="eSecuritelHITSControls" Namespace="WebSite.Controls" Assembly="WebSite" %>
<%@ Register Assembly="eSecuritel.HITS.UI.Components" Namespace="eSecuritel.HITS.UI.Components"
    TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="eContent" runat="Server">
    <cc1:ExtendedValidationSummary ID="m_extValidationSummaryTop" runat="server" HeaderText="<%$ Resources: OrganizationManagement, LabelThefollowingitemsneedtobereviewedbeforeupdatingthisorganizationunit %>" />
    <script src="../../../script/eSetFormControls.js" type="text/javascript"></script>
    <script src="../../../script/multiple-select.js" type="text/javascript"></script>
    <link href="../../../style/multiple-select.css" rel="stylesheet" />
    <table width="100%">
        <tr>
            <td valign="top">
                <h1>
                    <asp:Literal ID="lblPageHead" runat="server" Text="<%$ Resources: OrganizationManagement, LabelOrganizationUnitDetails %>"></asp:Literal>
                    -
                    <asp:Label ID="m_lblOrgUnitName" runat="server"></asp:Label>
                </h1>
            </td>
            <td valign="top">
                <uc:PersistNav ID="PersistNav1" runat="server" />
            </td>
        </tr>
    </table>
    <uc:ChildHeader ID="ChildHeader1" runat="server" OnSendEmailClicked="SendEmail_Clicked" />
    <h2>
        <asp:Literal ID="m_litGeneralInfo" runat="server" Text="<%$ Resources: UsersManagement, LabelGeneralInformation %>" />
        <asp:Label ID="m_lblSuccess" runat="server" Text="<%$ Resources: Default, LabelLabel %>"></asp:Label>
    </h2>
    <div class="greyblock">
        <b><span style="color: #ff0000">* </span></b>
        <asp:Label ID="lblRequired" runat="server" Text="<%$ Resources: Default, LabelIndicatesRequiredFields %>"></asp:Label>
        <table border="0" cellpadding="0" cellspacing="0" class="gvTable">
            <tr>
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litOrganizationUnitName" runat="server" Text="<%$ Resources: OrganizationManagement, LabelOrganizationUnitNameColon %>" /><span
                        style="color: #ff0000">*</span>
                </td>
                <td nowrap="nowrap">
                    <asp:TextBox ID="m_txtOrgUnitName" runat="server" Width="230px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ToolTip="<%$ Resources: OrganizationManagement, LabelOrganizationUnitNameRequired %>"
                        ErrorMessage="<%$ Resources: OrganizationManagement, LabelOrganizationUnitNameRequired %>"
                        Text="<%$ Resources: Default, ValidatorText %> " ControlToValidate="m_txtOrgUnitName"
                        EnableClientScript="false"></asp:RequiredFieldValidator>
                </td>
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litOrganizationUnitType" runat="server" Text="<%$ Resources: OrganizationManagement, LabelOrganizationUnitTypeColon %>" />
                    <b><span style="color: #ff0000">*</span></b>
                </td>
                <td nowrap="nowrap">
                    <asp:DropDownList ID="m_ddlOrgUnitType" Width="242px" runat="server" OnSelectedIndexChanged="m_ddlOrgUnitType_SelectedIndexChanged" AutoPostBack="true">
                        <asp:ListItem Text="<%$ Resources: Default, SelectLabel %>"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:CustomValidator ID="m_cvOrgUnitType" runat="server" ControlToValidate="m_ddlOrgUnitType"
                        Text="<%$ Resources: Default, ValidatorText %>" OnServerValidate="m_cvOrgUnitType_ServerValidate"
                        ErrorMessage="<%$ Resources: OrganizationManagement, LabelOrganizationUnitTypeRequired %>"
                        ToolTip="<%$ Resources: OrganizationManagement, LabelOrganizationUnitTypeRequired %>" />
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Literal ID="m_litLocationId" runat="server" Text="<%$ Resources: OrganizationManagement, LabelLocationIDColon %>" />
                </td>
                <td>
                    <asp:TextBox ID="m_txtLocationID" runat="server" Width="230px"></asp:TextBox>
                </td>
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litOrganizationUnitBelong" runat="server" Text="<%$ Resources: OrganizationManagement, LabelstoreTypeColon %>" />
                </td>
                <td nowrap="nowrap">
                    <asp:DropDownList Width="242px" ID="m_ddlOrgUnitBelong" runat="server" OnSelectedIndexChanged="m_ddlOrgUnitBelong_SelectedIndexChanged" AutoPostBack="true">
                        <asp:ListItem Text="<%$ Resources: ClaimsManagement, Unknown %>"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
               <td align="right">
                    <asp:Literal ID="m_litAccountNumber" runat="server" Text="<%$ Resources: BillingManagement, LabelAccountNumberColon %>"></asp:Literal>
                </td>
                <td>
                    <asp:TextBox ID="m_txtAccountNumber" runat="server" Width="230px"></asp:TextBox>
                </td>
                <td align="right">
                    <asp:Literal ID="m_litDealerCode" runat="server" Text="<%$ Resources: OrganizationManagement, LabelDealerCodeColon %>" />
                    <asp:Label ID="m_litAsterik" runat="server" ForeColor="red" Text="*" />
                    <%--<b><span style="color: #ff0000">*</span></b>--%>
                </td>
                <td valign="bottom">
                    <asp:TextBox ID="m_txtDealerCode" runat="server" Width="230px" Rows="1"></asp:TextBox>
                    <asp:CustomValidator ID="m_cvDealerCode" runat="server" ControlToValidate="m_txtDealerCode"
                        OnServerValidate="m_cvDealerCode_ServerValidate" />
                </td>                        
            </tr>
            <tr>
                <td align="right">
                    <asp:Literal ID="m_litAddress1" runat="server" Text="<%$ Resources: AddressResources, Address1 %>"></asp:Literal>
                </td>
                <td>
                    <asp:TextBox ID="m_txtAddress1" runat="server" Width="230px"></asp:TextBox>
                </td>
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litOrganizationDealer" runat="server" Text="<%$ Resources: OrganizationManagement, LabelStoreOwnedByColon %>" />
                </td>
                <td nowrap="nowrap">
                    <asp:DropDownList ID="m_ddlOrgDealerBelong" runat="server" Width="242px">
                        <asp:ListItem Text="<%$ Resources: ClaimsManagement, Unknown %>"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Literal ID="m_litAddress2" runat="server" Text="<%$ Resources: AddressResources, Address2 %>" />
                </td>
                <td>
                    <asp:TextBox ID="m_txtAddress2" runat="server" Width="230px"></asp:TextBox>
                </td>
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litOrganizationRepLoc" runat="server" Text="<%$ Resources: OrganizationManagement, LabelReplenishmentLocationColon %>" />
                </td>
                <td nowrap="nowrap">
                    <asp:DropDownList ID="m_ddlOrganizationRepLoc" Width="242px" runat="server" OnSelectedIndexChanged="m_ddlOrganizationRepLoc_SelectedIndexChanged"
                        AutoPostBack="true">
                        <asp:ListItem Text="<%$ Resources: ClaimsManagement, Unknown %>"></asp:ListItem>
                    </asp:DropDownList>
                </td>                          
            </tr>
            <tr>
                 <td align="right">
                    <asp:Literal ID="m_litCity" runat="server" Text="<%$ Resources: AddressResources, City %>" />
                </td>
                <td>
                    <asp:TextBox ID="m_txtCity" runat="server" Width="230px"></asp:TextBox>
                </td>
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litOrgDistributionCenter" runat="server" Text="<%$ Resources: OrganizationManagement, LabelDistributionCenterColon %>" />
                </td>
                <td nowrap="nowrap">
                    <asp:DropDownList ID="m_ddlOrgDistributionCenter" Width="242px" runat="server">
                        <asp:ListItem Text="<%$ Resources: ClaimsManagement, Unknown %>"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                 <td align="right">
                    <asp:Literal ID="m_litCountry" runat="server" Text="<%$ Resources: AddressResources, Country %>"> </asp:Literal>
                    <b><span style="color: #ff0000">*</span></b>
                </td>
                <td>
                    <asp:DropDownList ID="m_ddlCountry" Width="242px" runat="server" OnSelectedIndexChanged="m_ddlCountry_SelectedIndexChanged" AutoPostBack="true">
                        <asp:ListItem Text="<%$ Resources: Default, HeaderListDropDownTextSelect %>"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:CustomValidator ID="m_cvCountry" runat="server" ControlToValidate="m_ddlCountry"
                        OnServerValidate="m_cvCountry_ServerValidate" />
                </td>
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources: OrganizationManagement, LabelChannelCodeColon %>" />
                </td>
                <td nowrap="nowrap">
                    <asp:DropDownList ID="m_ddlChannelCodes" Width="242px" runat="server" DataValueField="ReferralCode"
                        DataTextField="ReferralCode" />
                </td>            
            </tr>
            <tr>
                <td align="right">
                    <asp:Literal ID="m_litZip" runat="server" Text="<%$ Resources: AddressResources, Zip  %>"></asp:Literal>
                    <b><span style="color: #ff0000">*</span></b>
                    <%-- <asp:Literal ID="m_litZip" runat="server" Text="<%$ Resources:AddressResources, Zip  %>"></asp:Literal>
                    <b><span style="color: #ff0000">*</span></b>--%>
                </td>
                <td>
                    <asp:TextBox ID="m_txtZip" runat="server" Width="230px"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="m_txtZip"
                        ValidationExpression="<%$ Resources: AddressResources, ZipValidation %>" Text="<%$ Resources: Default, ValidatorText %>"
                        Display="Dynamic" ErrorMessage="<%$ Resources: AddressResources, ErrorMessageZipCodeisInAnInvalidFormat %>"
                        ToolTip="<%$ Resources: AddressResources, ErrorMessageZipCodeisInAnInvalidFormat %>" />
                </td>
                <td align="right">
                    <asp:Literal ID="PayPalIDLiteral" runat="server" Text="<%$ Resources: OrganizationManagement, LabelPayPalID %>" />
                </td>
                <td>
                    <asp:TextBox ID="PayPalIDTextBox" runat="server" Width="230px"></asp:TextBox>
                </td>             
            </tr>
            <tr>
                <td align="right">
                    <asp:Literal ID="m_litState" runat="server" Text="<%$ Resources: AddressResources, State  %>"></asp:Literal>
                    <b><span style="color: #ff0000">*</span></b>
                </td>
                <td>
                    <asp:DropDownList ID="m_ddlState" Width="242px" runat="server">
                        <asp:ListItem Text="<%$ Resources: Default, HeaderListDropDownTextSelect %>"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:CustomValidator ID="m_cvState" runat="server" ControlToValidate="m_ddlState"
                        Text="<%$ Resources: Default, ValidatorText %>" OnServerValidate="m_cvState_ServerValidate" />
                </td>
                <td align="right">
                    <asp:Literal ID="m_litArea" runat="server" Text="Area:"></asp:Literal>
                </td>
                <td>
                    <asp:DropDownList ID="ddlArea" Width="242px" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlArea_SelectedIndexChanged">
                        <asp:ListItem Text="Select"></asp:ListItem>
                    </asp:DropDownList>
                </td> 
            </tr>
            <tr>
                 <td align="right">
                    <asp:Literal ID="m_litPhoneNumber" runat="server" Text="<%$ Resources: UsersManagement, LabelUserPhoneNumber %>" />
                </td>
                <td>
                    <uc1:PhoneNumber ID="m_ucPhoneNumber" PhoneNumberTextBox-Width="154px" runat="server" Required="false" />
                      <asp:Label ID="m_lblTable1BodyRowExt" runat="server" Text="<%$ Resources: UsersManagement, LabelUserExtColon %>"></asp:Label>
                    <asp:TextBox ID="m_txtPhoneExtension" runat="server" Width="33px"></asp:TextBox>
                </td>
               <td align="right">
                   <asp:Literal ID="m_litMarket" runat="server" Text="Market:"></asp:Literal>
                </td>
                <td>
                    <asp:UpdatePanel runat="server" ID="MarketUpdatePanel" UpdateMode="Conditional">
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="ddlArea" EventName="SelectedIndexChanged" />
                        </Triggers>
                        <ContentTemplate>
                            <asp:DropDownList ID="ddlMarket" Width="242px" runat="server">
                                <asp:ListItem Text="Select">
                                </asp:ListItem>
                            </asp:DropDownList>
                            <asp:HyperLink runat="server" ID="lnkAddMarket" NavigateUrl="AddMarket.aspx">Add Market</asp:HyperLink>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Literal ID="m_litFaxNumber" runat="server" Text="<%$ Resources: UsersManagement, LabelFaxNumberColon %>" />
                </td>
                <td>
                    <asp:TextBox ID="m_txtFaxNumber" runat="server" Width="230px"></asp:TextBox>
                </td>
                <td align="right">
                    <asp:Literal ID="m_litContactPerson" runat="server" Text="<%$ Resources: OrganizationManagement, LabelContactPersonColon %>" />
                </td>
                <td>
                    <asp:DropDownList ID="m_ddlContactPerson" Width="242px" runat="server">
                        <asp:ListItem Text="Select"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Literal ID="m_litHoursOfOperation" runat="server" Text="<%$ Resources: OrganizationManagement, LabelHoursOfOperationColon %>" />
                </td>
                <td>
                    <asp:TextBox ID="m_txtHoursOfOperation" runat="server" Width="230px"></asp:TextBox>
                </td>
                <td align="right">
                    <asp:Literal ID="m_lblExchMail" runat="server" Text="<%$ Resources: SubscriberManagement, LabelExchangeEmailColon %>"></asp:Literal>
                </td>
                <td>
                    <asp:TextBox ID="m_txtExchMail" runat="server" Width="230px"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="m_revExchMail" runat="server" ControlToValidate="m_txtExchMail"
                        Text="<%$ Resources: Default, ValidatorText %>" ErrorMessage="<%$ Resources: SubscriberManagement, ErrorMessageEmailAddressisinaninvalidformat %>"
                        SetFocusOnError="True" ToolTip="<%$ Resources: SubscriberManagement, ToolTipEmailAddressisinaninvalidformat %>"
                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Literal ID="m_litLandmarks" runat="server" Text="<%$ Resources: FulfillmentManagement, LabelLandmarksColon %>"></asp:Literal>
                </td>
                <td>
                    <asp:TextBox ID="m_txtLandmarks" runat="server" CssClass="multilinetb" Width="236px" TextMode="MultiLine"></asp:TextBox>
                </td>
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litFulfillmentLocation" runat="server" Text="<%$ Resources: FulfillmentManagement, LabelFulfillmentLocationColon %>"></asp:Literal>
                </td>
                <td nowrap="nowrap">
                    <asp:CheckBox ID="m_chkFulfillmentLocation" runat="server" />
                </td>
            </tr>
            <tr> 
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litModifiers" runat="server" Text="<%$ Resources: OrganizationManagement, LabelModifiersColon %>"></asp:Literal>
                </td>
                <td nowrap="nowrap">
                    <asp:CheckBox ID="m_chkDamaged" runat="server" Text="<%$ Resources: ClaimsManagement, DefaultDamagedLegendText %>" />
                    <asp:CheckBox ID="m_chkLostStolen" runat="server" Text="<%$ Resources: ClaimsManagement, ListItemLostStolen %>" />
                    <asp:CheckBox ID="m_chkWarranty" runat="server" Text="<%$ Resources: ClaimsManagement, DefaultWarrantyLegendText %>" />
                    <asp:CheckBox ID="m_chkDefective" runat="server" Text="<%$ Resources: ClaimsManagement, DefaultDefectiveLegendText %>" />
                </td>
                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litCompaniesAssignedToOrgUnit" runat="server" Text="<%$ Resources: OrganizationManagement, LabelCompaniesAssignedToOrgUnit %>" />
                </td>
                <td nowrap="nowrap">
                    <asp:DropDownList ID="m_ddlCompaniesAssignedToOrgUnit" runat="server" AutoPostBack="False" DataValueField="OrganizationId" DataTextField="OrganizationName" Width="200px" />
                    <asp:HiddenField runat="server" ID="m_hfSelectedCompaniesForAssignment" />
                </td>
            </tr>
        </table>
    </div>


      <!-- Code to support the Address Lookup Popup -->
    <asp:Panel runat="server" ID="pnlAddressLookupDialogPopup" CssClass=""
        Style="display: none; width: 800px; height: 400px;">
        <asp:Panel ID="pnlMatchingAddressHeader" runat="server" EnableViewState="false" CssClass="modalHeader">
            <asp:Label ID="Label2" runat="server" EnableViewState="false" Text="<%$ Resources: AddressResources, SelectAppropriateSubscriberAddress %>" />
        </asp:Panel>
        <asp:Panel ID="pnlMatchingAddressBody" runat="server" CssClass="modalContent" Style="text-align: left;">
            <uc:ucAddressLookupDlg ID="aldMatch" runat="server" />
        </asp:Panel>
    </asp:Panel>
    <eSecuritelHITSControls:hitsmodalpopupextender id="mdlAddressValidationLookupPopup" runat="server" targetcontrolid="btnOnlyHereToSatisfyTargetControlIDForPopup"
        popupcontrolid="pnlAddressLookupDialogPopup" backgroundcssclass="modalBackground"
        cancelcontrolid="btnOnlyHereToSatisfyTargetControlIDForPopup2" behaviorid="mdlAddressValidationLookupPopup">
    </eSecuritelHITSControls:hitsmodalpopupextender>
    <span style="display: none">
        <asp:Button runat="server" ID="btnOnlyHereToSatisfyTargetControlIDForPopup2" Text="If you see me, there is an error." /><br />
        <asp:Button runat="server" ID="btnOnlyHereToSatisfyTargetControlIDForPopup" Text="If you see me, there is an error." /><br />
    </span>
    <!-- End of the road for the address Lookup Popup. -->


    <div style="text-align: center">
        <asp:Button ID="m_btnUpdate" runat="server" CssClass="pagebutton" Text="<%$ Resources : Default,ButtonUpdate %>"
            OnClick="m_btnUpdate_Click" />
        <asp:Button ID="m_btnCancel" runat="server" CssClass="pagebutton" Text="<%$ Resources : Default,ButtonCancel %>"
            OnClick="m_btnCancel_Click" CausesValidation="False" />
    </div>
    <cc1:ExtendedValidationSummary ID="m_extValidationSummaryBottom" runat="server" HeaderText="<%$ Resources: OrganizationManagement, LabelThefollowingitemsneedtobereviewedbeforeupdatingthisorganizationunit %>" />
        <script type="text/javascript">
            Sys.Application.add_load(setStyle);
            function setStyle() {
                if (navigator.appName == 'Microsoft Internet Explorer') {
                    var ua = navigator.userAgent;
                    var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
                    if (re.exec(ua) != null)
                        var rv = parseFloat(RegExp.$1);
                    if (rv == 7.0)
                        $('[id$=_m_ucPhoneNumber_m_txtPhoneNumber]').attr('style', 'width: 150px');
                }
            }


            $(document).ready(function() {
            
                var previousSelectedValues = $('#<%= m_hfSelectedCompaniesForAssignment.ClientID %>').val().split(",");

                $('#<%= m_ddlCompaniesAssignedToOrgUnit.ClientID %>').multipleSelect({
                    filter: true,
                    onClose: populateDropdownValuesToField
                });

                $('#<%= m_ddlCompaniesAssignedToOrgUnit.ClientID %>').multipleSelect("setSelects", previousSelectedValues);
            
            });

                function populateDropdownValuesToField() {
                    var dropdown = $('#<%= m_ddlCompaniesAssignedToOrgUnit.ClientID %>');
                $('#<%= m_hfSelectedCompaniesForAssignment.ClientID %>').val(dropdown.multipleSelect('getSelects'));
            }
    
    </script>
</asp:Content>
