<%@ page language="C#" masterpagefile="~/MasterFile/TimeCheck.master" enableeventvalidation="false" autoeventwireup="true" inherits="Masters_Landmarks, App_Web_ioskhdy0" %>

<%@ Register TagPrefix="dxGridview" Namespace="DevExpress.Web" Assembly="DevExpress.Web.v14.2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPH" runat="Server">

    <script src="../js/Map_GoogleV3.js"></script>
    <script type="text/javascript">
        var MaxLength = "Maximum length is ";
        function MaxLengthh(maxLength) {
            MaxLength = maxLength;
        }
    </script>
    <div class="content-header">
        <h1 style="background-image: url('../dist/img/city.png'); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbllandMarkHeader" Text="Landmark Details" runat="server"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>
    <div class="content">
        <div class="inr-ftr">
            <div class="row">
                <div class="col-sm-12">
                    <div class="pull-right">
                        <h6>
                            <span style="color: Red">|</span><span style="padding-left: 10px; padding-right: 10px"><asp:Label
                                ID="lbl_IndicatesMandatoryFields" runat="server"></asp:Label>
                                (2 No.)</span>
                        </h6>
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
        <div class="emp-filter">
            <div class="form-horizontal">
                <div class="row form-group">
                    <div class="col-md-12">
                        <div id="map-dsply" style="height: 400px; direction: ltr; width: 100%;">
                        </div>
                        <style type="text/css">
                            .nm_buttonPair {
                                right: 96%;
                            }

                            @media screen and (-webkit-min-device-pixel-ratio:0) {
                                .nm_zoomWrap {
                                    margin-right: 96%;
                                }
                            }
                        </style>
                    </div>
                </div>
                <div class="row form-group">
                    <div class="col-md-12">
                        <asp:UpdatePanel ID="updPanel" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <div id="search-tbl" style="vertical-align: top;">
                                    <div class="row form-group">
                                        <div class="col-md-3">
                                            <asp:Label runat="server" ID="lblfenchType" Text="Type of Fencing"></asp:Label>
                                        </div>
                                        <div class="col-md-8">
                                            <div id="tdStreetAddr" runat="server" class="LandmarkPaddingStyle">
                                                <asp:DropDownList ID="ddlType" runat="server" CssClass="form-control select2" onchange="showControls(this.selectedIndex);">
                                                </asp:DropDownList>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <div class="col-md-3">
                                            <asp:Label ID="lblLocat" runat="server" Text="Location Name & Radius"></asp:Label>
                                        </div>
                                        <div class="col-md-3">
                                            <asp:TextBox ID="txtLocationName" Width="100px" CssClass="form-control mandatory" runat="server" MaxLength="100" onpaste="return false"
                                                onkeypress="return acceptChars_MaxLength(event,this,100,MaxLength);" ondrop="return false"></asp:TextBox>

                                        </div>
                                        <div class="col-md-3 nullpadding" style="margin-left: -24px;">
                                            <asp:TextBox ID="txtRadius" Width="100px" runat="server" CssClass="form-control" onpaste="return true" ondrop="return false"
                                                MaxLength="4" onkeypress="return number_only(event,this);"></asp:TextBox>
                                        </div>

                                        <div class="col-xs-2">
                                            <asp:Label ID="lblinmetres" runat="server" Text="in metres"></asp:Label>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <div class="col-md-3">
                                            <asp:Label ID="lblDescript" runat="server" Text="Description"></asp:Label>
                                        </div>
                                        <div class="col-md-8">
                                            <asp:TextBox ID="txtLocationDesc" runat="server" CssClass="form-control" Height="50px" MaxLength="250"
                                                onkeypress="return acceptChars_MaxLength(event,this,250,MaxLength);"  TextMode="MultiLine" Style="resize: none"></asp:TextBox>

                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <div id="spAddr" name="spAddr" runat="server">
                                            <div class="col-md-3">
                                                <asp:Label ID="lblAddress" runat="server" valign="top" Text="Address"></asp:Label>
                                            </div>
                                            <div class="col-md-3">
                                                <asp:TextBox ID="txtstreet" CssClass="form-control mandatory" runat="server"
                                                    Style="resize: none" TextMode="MultiLine" MaxLength="250" onkeypress="return acceptChars_MaxLength(event,this,250,MaxLength);" ></asp:TextBox>

                                            </div>
                                            <div class="col-md-5 nullpadding">
                                                <asp:TextBox ID="txtcity" runat="server" CssClass="form-control" onpaste="return false" ondrop="return false"
                                                    onkeypress="return acceptChars_MaxLength(event,this,50,MaxLength);"  MaxLength="50"></asp:TextBox>

                                                <asp:TextBox ID="txtstate" runat="server" CssClass="form-control" onpaste="return false" ondrop="return false"
                                                    onkeypress="return acceptChars_MaxLength(event,this,50,MaxLength);"  MaxLength="50"></asp:TextBox>

                                                <asp:TextBox ID="txtCountry" onpaste="return false" CssClass="form-control" ondrop="return false" runat="server"
                                                    onkeypress="return acceptChars_MaxLength(event,this,50,MaxLength);"  MaxLength="50"></asp:TextBox>

                                            </div>
                                        </div>
                                    </div>
                                    <div class="row form-group" id="spLatlng" name="spLatlng" runat="server" style="display: none;">
                                        <div class="col-md-3">
                                            <asp:Label ID="lbllatelng" runat="server"></asp:Label>
                                        </div>
                                        <div class="col-md-4 col-Landmark nullpadding">
                                            <asp:TextBox ID="txtlat" CssClass="form-control" runat="server" MaxLength="17"></asp:TextBox>

                                        </div>
                                        <div class="col-md-4 nullpadding">
                                            <asp:TextBox ID="txtlong" CssClass="form-control" runat="server" MaxLength="17"></asp:TextBox>

                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <div class="col-md-3">
                                        </div>
                                        <div class="col-md-8">
                                            <div class="pull-right-button">
                                                <asp:LinkButton ID="btnAddress" runat="server" CssClass="btn save-btn fa-floppy-oo"
                                                    OnClick="btnAddress_Click" Text="&nbsp;Locate Me">
                                                </asp:LinkButton>
                                                <asp:LinkButton ID="lnkbtnSave" runat="server" CssClass="btn save-btn fa-floppy-o" OnClientClick="return ValidateControls();"
                                                    OnClick="lnkbtnSave_Click" Text="&nbsp;Save">
                                                </asp:LinkButton>
                                                <asp:LinkButton ID="btnCancel" runat="server" CssClass="btn save-btn fa-floppy-oo" OnClientClick="showControls(0);" Text="&nbsp;&nbsp;Cancel"
                                                    OnClick="btnCancel_Click">
                                                </asp:LinkButton>
                                                <asp:LinkButton ID="lnkbtnDelete" runat="server" CssClass="btn del-btn fa-trash-o" Text="&nbsp;&nbsp;Delete"
                                                    OnClick="lnkbtnDelete_Click" OnClientClick="return confirmdelete(this.form);">
                                                </asp:LinkButton>
                                                <asp:HiddenField ID="hdnSelectRow" runat="server" />
                                                <asp:HiddenField ID="hdnGetAllid" runat="server" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                            <ContentTemplate>
                                                <dxGridview:ASPxGridView ID="grvLandmarks" EnableCallBacks="false" runat="server"
                                                    ClientInstanceName="grvLandmarks" KeyFieldName="id"
                                                    AutoGenerateColumns="false" Width="100%" OnHtmlRowCreated="grvLandmarks_HtmlRowCreated">
                                                    <Columns>
                                                        <dxGridview:GridViewDataColumn VisibleIndex="0" HeaderStyle-VerticalAlign="Middle"
                                                            Width="30px" HeaderStyle-HorizontalAlign="Center" CellStyle-VerticalAlign="Middle"
                                                            CellStyle-HorizontalAlign="Center">
                                                            <Settings AllowAutoFilter="false" />
                                                            <HeaderTemplate>
                                                                <input id="chkSelectAll" runat="server" type="checkbox" onclick="SelectAllOnThisPage(this)" />
                                                            </HeaderTemplate>
                                                            <DataItemTemplate>
                                                                <input id="chkSelect" runat="server" type="checkbox" onclick="SelectOnRow(this)"
                                                                    accesskey='<%# Eval("id") %>' />
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                        </dxGridview:GridViewDataColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="Options" VisibleIndex="1" Width="150px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lblOptions" Text='<%# Eval("Options") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="LocationName" VisibleIndex="2" Width="200px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lblLocationName" Text='<%# Eval("LocationName") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="Radius" VisibleIndex="3" Width="100px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lblRadius" Text='<%# Eval("Radius") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="Description" VisibleIndex="3" Width="150px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lblDescription" Text='<%# Eval("Description") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="Address" VisibleIndex="4" Width="150px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lblAddress" Text='<%# Eval("Address") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="City" VisibleIndex="5" Width="150px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lblCity" Text='<%# Eval("City") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="State" VisibleIndex="6" Width="150px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lblState" Text='<%# Eval("State") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="Country" VisibleIndex="7" Width="150px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lblCountry" Text='<%# Eval("Country") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="Country" VisibleIndex="7" Width="150px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lblCountry" Text='<%# Eval("Country") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="latitude" VisibleIndex="8" Width="150px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lbllatitude" Text='<%# Eval("latitude") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn FieldName="longitude" VisibleIndex="9" Width="150px">
                                                            <DataItemTemplate>
                                                                <asp:Label ID="lbllongitude" Text='<%# Eval("longitude") %>' runat="server" Style="overflow-y: auto; overflow-x: auto; word-break: break-all; word-wrap: break-word; display: inline-block;"></asp:Label>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                            <Settings ShowInFilterControl="False" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn CellStyle-HorizontalAlign="Center" VisibleIndex="10"
                                                            Name="Edit">
                                                            <DataItemTemplate>
                                                                <asp:LinkButton ID="btnEdit" runat="server" CommandArgument='<%# Eval("id") %>' data-toggle="tooltip"
                                                                    data-placement="top" CssClass="btn btn-defalut edit-icons" Style="color: #3C8DBC; text-decoration: none;"
                                                                    OnClick="ibEdit_Click" CommandName="Edit"></asp:LinkButton>
                                                            </DataItemTemplate>
                                                        </dxGridview:GridViewDataTextColumn>
                                                        <dxGridview:GridViewDataTextColumn CellStyle-HorizontalAlign="Center" VisibleIndex="11"
                                                            Name="Delete">
                                                            <Settings AllowAutoFilter="false" />
                                                            <DataItemTemplate>
                                                                <asp:LinkButton ID="ibDelete" runat="server" CommandArgument='<%# Eval("id") %>' data-toggle="tooltip"
                                                                    data-placement="top" CssClass="btn btn-defalut del-icons" Style="color: Red"
                                                                    CommandName='Delete' OnClick="ibDelete_Click"></asp:LinkButton>
                                                            </DataItemTemplate>
                                                            <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                                        </dxGridview:GridViewDataTextColumn>
                                                    </Columns>
                                                    <SettingsPager PageSize="15">
                                                        <PageSizeItemSettings Visible="true" ShowAllItem="true" Items="10,20,50,100,200,500" />
                                                    </SettingsPager>
                                                    <Settings ShowFilterRow="true" ShowFilterRowMenu="true" HorizontalScrollBarMode="Auto" VerticalScrollBarMode="Hidden" VerticalScrollableHeight="400" />
                                                    <SettingsText EmptyDataRow="No Records Found" />
                                                    <SettingsBehavior AutoExpandAllGroups="True" ColumnResizeMode="Control" />
                                                    <SettingsBehavior AllowDragDrop="true" />
                                                </dxGridview:ASPxGridView>
                                                <dxGridview:ASPxGridViewExporter ID="ASPxGridViewExporter1" runat="server" GridViewID="grvLandmarks">
                                                    <PageFooter Right="[Page # of Pages #]">
                                                    </PageFooter>
                                                </dxGridview:ASPxGridViewExporter>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                    </div>
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function ValidateControls() {
            var ddlType = document.getElementById('ctl00_BodyContentPH_ddlType').value;

            if (document.getElementById('ctl00_BodyContentPH_txtLocationName').value == '') {
                alert("Enter Location Name");
                document.getElementById('ctl00_BodyContentPH_txtLocationName').focus();
                return false;
            }
            if (ddlType == 'addr') {
                if (document.getElementById('ctl00_BodyContentPH_txtstreet').value == '') {
                    alert("Enter Address Name");
                    document.getElementById('ctl00_BodyContentPH_txtstreet').focus();
                    return false;
                }
            }
            if (document.getElementById('ctl00_BodyContentPH_txtlat').value == '') {
                alert("Enter Latitude / click Locate Me");
                document.getElementById('ctl00_BodyContentPH_txtlat').focus();
                return false;
            }
            if (document.getElementById('ctl00_BodyContentPH_txtlong').value == '') {
                alert("Enter Longitude / click Locate Me");
                document.getElementById('ctl00_BodyContentPH_txtlong').focus();
                return false;
            }
            return confirm('Are you sure to save location');
        }
        function showControls(ddlvalue) {
            //alert(ddlvalue);
            if (ddlvalue == 1) {
                document.getElementById('ctl00_BodyContentPH_spLatlng').style.display = "block";
                document.getElementById('ctl00_BodyContentPH_spAddr').style.display = "none";
            }
            else if (ddlvalue == 0) {
                document.getElementById('ctl00_BodyContentPH_spLatlng').style.display = "none";
                document.getElementById('ctl00_BodyContentPH_spAddr').style.display = "block";
            }
            return true;
        }
        function SelectAllOnThisPage(chkSelectAll) {
            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var hdnSelectAll = document.getElementById('<%= hdnGetAllid.ClientID %>');
            if (chkSelectAll.checked == true) {
                for (var i = 0; i < grvLandmarks.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_grvLandmarks_cell' + (i + grvLandmarks.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                        document.getElementById('ctl00_BodyContentPH_grvLandmarks_cell' + (i + grvLandmarks.visibleStartIndex) + '_0_chkSelect').checked = true;
                        var hdnUserId = document.getElementById('ctl00_BodyContentPH_grvLandmarks_cell' + (i + grvLandmarks.visibleStartIndex) + '_0_chkSelect').accessKey;
                        var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
                        var removeId = hdnSelectRow.value.split(",");
                        if (hdnUserId != "" && !Array.contains(removeId, hdnUserId)) {
                            if (hdnSelectRow.value != "")
                                hdnSelectRow.value += ",";
                            hdnSelectRow.value += hdnUserId;
                        }
                    }
                }
            }
            else {
                for (var i = 0; i < grvLandmarks.pageRowCount; i++) {
                    document.getElementById('ctl00_BodyContentPH_grvLandmarks_cell' + (i + grvLandmarks.visibleStartIndex) + '_0_chkSelect').checked = false;
                }
                hdnSelectRow.value = '';
            }
        }
        function SelectOnRow(chkOnSelect) {
            var hdnUserId = chkOnSelect.accessKey;
            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
                var removeId = hdnSelectRow.value.split(",");
                if (chkOnSelect.checked) {
                    if (hdnUserId != "" && !Array.contains(removeId, hdnUserId)) {
                        if (hdnSelectRow.value != "")
                            hdnSelectRow.value += ",";
                        hdnSelectRow.value += hdnUserId;
                    }
                    var varTotalCheckedCount = 0;
                    var varTotalEnabled = 0;
                    for (var i = 0; i < grvLandmarks.pageRowCount; i++) {
                        if (document.getElementById('ctl00_BodyContentPH_grvLandmarks_cell' + (i + grvLandmarks.visibleStartIndex) + '_0_chkSelect').disabled == false) {
                            varTotalEnabled = varTotalEnabled + 1;
                        }
                        if (document.getElementById('ctl00_BodyContentPH_grvLandmarks_cell' + (i + grvLandmarks.visibleStartIndex) + '_0_chkSelect').checked)
                            varTotalCheckedCount = varTotalCheckedCount + 1;
                    }
                    if (varTotalCheckedCount == varTotalEnabled)
                        document.getElementById('ctl00_BodyContentPH_grvLandmarks_header0_chkSelectAll').checked = true;
                    else
                        document.getElementById('ctl00_BodyContentPH_grvLandmarks_header0_chkSelectAll').checked = false;
                }
                else {
                    if (Array.contains(removeId, hdnUserId)) {
                        Array.remove(removeId, hdnUserId);
                    }
                    hdnSelectRow.value = removeId;
                    document.getElementById('ctl00_BodyContentPH_grvLandmarks_header0_chkSelectAll').checked = false;
                }
            }
    </script>
</asp:Content>
