<%@ Page Language="C#" MasterPageFile="~/masterpages/eDashboard.master" AutoEventWireup="true" Inherits="site_HITS_DepartmentDetails" Title="Brightstar Device Protection: Create New Organization Unit"
    Culture="auto" UICulture="auto" Theme="eMain" CodeBehind="Add.aspx.cs" %>

<%@ Register Src="~/Controls/ChildHeader.ascx" TagName="ChildHeader" TagPrefix="uc" %>
<%@ Register Src="~/Controls/PhoneNumber.ascx" TagName="PhoneNumber" TagPrefix="uc1" %>
<%@ Register Src="~/Controls/PersistNav.ascx" TagName="PersistNav" TagPrefix="uc" %>
<%@ Register Src="~/Controls/AddressValidationLookup.ascx" TagPrefix="uc" TagName="ucAddressLookupDlg"  %>
<%@ 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, LabelOrganizarionUnitItemsToBeReviewed %>" Width="1186"/>

    <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%" border="0">
        <tr>
            <td>
                <h1>
                    <asp:Label ID="lblPageHeading" runat="server" Text="<%$ Resources : OrganizationManagement,LabelCreateNewOrganizationUnit %>"></asp:Label>
                </h1>
            </td>
            <td valign="top">
                <uc:PersistNav ID="m_pNavMain" runat="server" />
            </td>
        </tr>
    </table>
    <uc:ChildHeader ID="ChildHeader1" runat="server" />

    <h2>
        <asp:Literal ID="m_litGeneralInfoHeader" 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:Label ID="Label1" runat="server" Text="<%$ Resources: OrganizationManagement, LabelOrganizationNameColon %>"></asp:Label>
                    <b><span style="color: #ff0000">*</span></b>
                </td>
                <td nowrap="nowrap">

                    <asp:DropDownList ID="m_ddlOrg" runat="server" AutoPostBack="true">
                        <asp:ListItem Text="<%$ Resources : Default,HeaderListDropDownTextSelect %>"></asp:ListItem>
                    </asp:DropDownList>

                    <asp:CustomValidator ID="m_cvOrgType" runat="server" ControlToValidate="m_ddlOrg"
                        Text="<%$ Resources:Default, ValidatorText %>" OnServerValidate="m_cvOrgType_ServerValidate"
                        ErrorMessage="<%$ Resources: OrganizationManagement, LabelOrganizationNameRequired %>"
                        ToolTip="<%$ Resources: OrganizationManagement, LabelOrganizationNameRequired %>" />
                </td>

                <td align="right" nowrap="nowrap">
                    <asp:Label ID="lblTable1BodyRow3" runat="server"
                        Text="<%$ Resources: OrganizationManagement, LabelOrganizationUnitTypeColon %>"></asp:Label><b><span style="color: #ff0000">*</span></b>
                </td>
                <td nowrap="nowrap">

                    <asp:DropDownList ID="m_ddlOrgUnitType" runat="server"
                        OnSelectedIndexChanged="m_ddlOrgUnitType_SelectedIndexChanged" AutoPostBack="true">
                        <asp:ListItem Text="<%$ Resources : Default,HeaderListDropDownTextSelect %>"></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" nowrap="nowrap">
                </td>
                <td nowrap="nowrap" style="width: 200px">
                </td>

                <td align="right" nowrap="nowrap">
                    <asp:Literal ID="m_litOrganizationUnitBelong" runat="server" Text="<%$ Resources: OrganizationManagement, LabelstoreTypeColon %>" />
                </td>
                <td nowrap="nowrap">
                    <asp:DropDownList 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" nowrap="nowrap">
                    <asp:Label ID="lblTable1BodyRow1" runat="server" Text="<%$ Resources: OrganizationManagement, LabelOrganizationUnitNameColon %>"></asp:Label>
                    <b><span style="color: #ff0000">*</span></b>
                </td>
                <td nowrap="nowrap">
                    <asp:TextBox ID="m_txtOrgUnitName" runat="server" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="m_txtOrgUnitName" EnableClientScript="false"
                        Text="<%$ Resources:Default, ValidatorText %>" ErrorMessage="<%$ Resources: OrganizationManagement, LabelOrganizationUnitNameRequired %>"
                        ToolTip="<%$ Resources: OrganizationManagement, LabelOrganizationUnitNameRequired %>" SetFocusOnError="True"></asp:RequiredFieldValidator></td>
                <td align="right">
                    <asp:Literal ID="m_litAccountNumber" runat="server" Text="<%$ Resources: BillingManagement, LabelAccountNumberColon %>" />
                </td>
                <td>
                    <asp:TextBox ID="m_txtAccountNumber" runat="server" Width="100px"></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>
                    <asp:TextBox ID="m_txtDealerCode" runat="server" Width="100px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblTable1BodyRow7" runat="server"
                        Text="<%$ Resources: AddressResources, Address1 %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="m_txtAddress1" runat="server" Width="200px"></asp:TextBox>
                </td>
                <td align="right">
                    <asp:Label ID="lblTable1BodyRow8" runat="server" Text="<%$ Resources: AddressResources, Address2 %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="m_txtAddress2" runat="server" Width="200px"></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">
                        <asp:ListItem Text="<%$ Resources : ClaimsManagement,Unknown %>"></asp:ListItem>
                    </asp:DropDownList></td>

            </tr>

            <tr>
                <td align="right" style="height: 28px">
                    <asp:Label ID="lblTable1BodyRow9" runat="server"
                        Text="<%$ Resources : AddressResources,City %>"></asp:Label>
                </td>
                <td style="height: 28px">
                    <asp:TextBox ID="m_txtCity" runat="server" Width="120px"></asp:TextBox>
                </td>


                <td align="right" style="height: 28px">
                    <asp:Label ID="lblTable1BodyRow12" runat="server" Text="<%$ Resources : AddressResources,Country %>"></asp:Label>
                    <b><span style="color: #ff0000">*</span></b>
                </td>
                <td style="height: 28px">
                    <asp:DropDownList ID="m_ddlCountry" runat="server" Width="125px"
                        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_ddlOrgUnitType"
                        Text="<%$ Resources:Default, ValidatorText %>" OnServerValidate="m_cvCountry_ServerValidate" />
                </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" 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:Label ID="lblTable1BodyRow11" runat="server" Text="<%$ Resources:AddressResources, Zip  %>"></asp:Label>
                    <b><span style="color: #ff0000">*</span>
                </td>
                <td>
                    <asp:TextBox ID="m_txtZip" runat="server" Width="60px"></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:Label ID="lblTable1BodyRow10" runat="server" Text="<%$ Resources:AddressResources, State  %>"></asp:Label>
                    <b><span style="color: #ff0000">*</span>
                </td>
                <td>
                    <asp:DropDownList ID="m_ddlState" runat="server" Width="66px">
                        <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" nowrap="nowrap">
                    <asp:Literal ID="m_litOrgDistributionCenter" runat="server" Text="<%$ Resources: OrganizationManagement, LabelDistributionCenterColon %>" />
                </td>
                <td nowrap="nowrap">
                    <asp:DropDownList ID="m_ddlOrgDistributionCenter" runat="server">
                        <asp:ListItem Text="<%$ Resources : ClaimsManagement,Unknown %>"></asp:ListItem>
                    </asp:DropDownList></td>

            </tr>
            <tr>
                <td align="right" nowrap="nowrap">
                    <asp:Label ID="lblTable1BodyRow41" runat="server"
                        Text="<%$ Resources : ClaimsManagement, PhoneNumberLabel %>"></asp:Label>
                </td>
                <td nowrap="nowrap">
                    <uc1:PhoneNumber ID="m_ucPhoneNumber" runat="server" Required="false" />
                    <asp:Label ID="m_lblPhoneExample" runat="server" Text="<%$ Resources: UsersManagement, LabelExamplexxxxxxxxxx %>"></asp:Label>
                    &nbsp;<asp:Label ID="lblTable1BodyRowExt" runat="server" Text="Ext.">
                    </asp:Label>
                    <asp:TextBox ID="m_txtPhoneExtension" runat="server" Width="33px"></asp:TextBox>
                </td>
                <td align="right" nowrap>
                    <asp:Label ID="lblTable1BodyRow5" runat="server"
                        Text="<%$ Resources: UsersManagement, LabelFaxNumberColon %>"></asp:Label>
                </td>
                <td nowrap>
                    <asp:TextBox ID="m_txtFaxNumber" runat="server" Width="82px" MaxLength="12"></asp:TextBox>
                </td>



            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblTable1BodyRow13" runat="server"
                        Text="<%$ Resources: OrganizationManagement, LabelContactPersonColon %>"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="m_ddlContactPerson" runat="server" Width="125px">
                        <asp:ListItem Text="<%$ Resources: Default, None %>" Value="0"></asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td align="right">
                    <asp:Label ID="lblTable1BodyRow14" runat="server"
                        Text="<%$ Resources: OrganizationManagement, LabelHoursOfOperationColon %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="m_txtHoursOfOperations" runat="server" Width="200px"></asp:TextBox>
                </td>

            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblTable1BodyRow15" runat="server"
                        Text="<%$ Resources: SubscriberManagement, LabelExchangeEmailColon %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="m_txtExchangeEmails" runat="server" Width="200px"></asp:TextBox>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="m_txtExchangeEmails"
                        Text="<%$ Resources:Default, ValidatorText %>" ErrorMessage="<%$ Resources: SubscriberManagement , ErrorEmailAddressInvalidFormat %>"
                        SetFocusOnError="True" ToolTip="<%$ Resources: SubscriberManagement , ErrorEmailAddressInvalidFormat %>" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td>
                <td align="right">
                    <asp:Label ID="lblTable1BodyRow16" runat="server"
                        Text="<%$ Resources: FulfillmentManagement, LabelLandmarksColon %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="m_txtLandmarks" runat="server" TextMode="MultiLine" CssClass="multilinetb"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right" nowrap>
                    <asp:Literal ID="m_litFulfillmentLocation" runat="server" Text="<%$ Resources: FulfillmentManagement, LabelFulfillmentLocationColon %>" />
                </td>
                <td nowrap>
                    <asp:CheckBox ID="m_chkFulfillmentLocation" runat="server" />
                </td>
                <td align="right" nowrap>
                    <asp:Literal ID="m_litModifiers" runat="server" Text="<%$ Resources: OrganizationManagement, LabelModifiersColon %>" />
                </td>

                <td 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>
                <tr>
                    <td align="right">
                        <asp:Literal ID="PayPalIDLiteral" runat="server" Text="<%$ Resources: OrganizationManagement, LabelPayPalID %>" />
                    </td>
                    <td>
                        <asp:TextBox ID="PayPalIDTextBox" runat="server" Width="150px"></asp:TextBox>
                    </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" runat="server" DataValueField="ReferralCode" DataTextField="ReferralCode" />
                    </td>
                </tr>

            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblTable1BodyRow2" runat="server"
                        Text="<%$ Resources: OrganizationManagement, LabelLocationIDColon %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="m_txtLocationID" runat="server" Width="120px"></asp:TextBox>
                </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"
        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="padding-left: 400px">
        <asp:Button ID="m_btnAddNewOrgUnit" runat="server" Text="<%$ Resources : Default,ButtonCreate %>" CssClass="pagebutton"
            OnClick="m_btnAddNewOrgUnit_Click" />
        <asp:Button ID="m_btnCancelNewOrgUnit" runat="server" Text="<%$ Resources : Default,ButtonCancel %>" CausesValidation="False"
            CssClass="pagebutton" OnClick="m_btnCancelNewOrgUnit_Click" />
    </div>
    <cc1:ExtendedValidationSummary ID="m_extValidationSummaryBottom" runat="server" HeaderText="<%$ Resources: OrganizationManagement, LabelOrganizarionUnitItemsToBeReviewed %>" />
    
    
    <script type="text/javascript">

        $(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>
