<%@ page language="C#" autoeventwireup="true" inherits="Forms_RoutePlanning1, App_Web_kantv33r" culture="auto" uiculture="auto" enableeventvalidation="false" meta:resourcekey="PageResource1" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/UserControls/New_Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/New_Footer.ascx" TagName="Footer" TagPrefix="uc2" %>

<%--<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.2, Version=8.2.10.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.2, Version=8.2.10.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>--%>

<%@ Register Assembly="DevExpress.Web.v14.2" Namespace="DevExpress.Web" TagPrefix="dxw" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>tSense-IoT Route</title>

    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Page-Enter" content="blendTrans(Duration=0)" />
    <meta http-equiv="Page-Exit" content="blendTrans(Duration=0)" />
    <link id="reset" runat="server" href="../css/reset.css" rel="stylesheet" type="text/css" />
    <link id="stylesheet2" runat="server" href="../css/stylesheet2.css" rel="stylesheet" type="text/css" />
    <link id="dropdown" runat="server" href="../css/dropdown.css" rel="stylesheet" type="text/css" />
    <link rel="SHORTCUT ICON" href="../images/favicon.ico" />
    <%--Custom Theme for DevEx 14.2--%>
    <link id="GridView" type="text/css" href="~/App_Themes/Office2003Blue/GridView/grid.css" rel="stylesheet" />
    <link id="Editors" type="text/css" href="~/App_Themes/Office2003Blue/Editors/styles.css" rel="stylesheet" />
    <script src="../js/wow.min.js"></script>
</head>
<body onload="init();" onunload='GUnload()'>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="6000">
        </asp:ScriptManager>
        <div id="container">
            <!-- Header Starts Here -->
            <uc1:Header ID="ucHeader" runat="server" />
            <!-- Nav Ends Here -->
            <!-- Content Starts Here -->
            <div id="outer">
                <div id="inner">
                    <div id="float-wrap">
                        <!-- Main Content Starts Here -->
                        <div id="content">
                            <div class="content-wrap">
                                <div id="top-content">
                                    <div id="heading">
                                        <img class="icon" src="../images/icn-route.gif" alt="" />
                                        <h1>Route</h1>

                                        <a href="Dashboard.aspx">Home</a><span>&gt;</span><span><a href="RoutePanelCSS.aspx">Route</a></span><span>&gt;</span><span><a
                                            href="RoutePlanningCSS.aspx">Manage</a></span>
                                    </div>
                                    <div id="control-box">
                                        <div id="control-btn">
                                            <table cellpadding="0" cellspacing="0" border="0" align="right">
                                                <tr height="20px">
                                                    <td>&nbsp;
                                                    </td>
                                                    <td>&nbsp; &nbsp;
                                                    </td>
                                                    <td>&nbsp;
                                                    </td>
                                                </tr>
                                                <tr height="20px">
                                                    <td>
                                                        <asp:ImageButton ID="ibtBackToRouteManagement" PostBackUrl="~/Forms/RoutePanelCSS.aspx"
                                                            runat="server" ImageUrl="~/images/btn-back-to-routemanage.jpg" />
                                                    </td>
                                                    <td>&nbsp;
                                                    </td>
                                                    <td>&nbsp;&nbsp;
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                    <div class="clear clearfix">
                                    </div>
                                </div>
                                <div class="clear clearfix">
                                </div>
                                <asp:UpdatePanel ID="updRoutePlanning" runat="server">
                                    <ContentTemplate>
                                        <asp:Panel ID="pnlShiftDetails" runat="server">
                                            <cc1:CalendarExtender ID="ceShiftDate" runat="server" Format="dd/MM/yyyy" CssClass="cal_Theme1"
                                                TargetControlID="txtDate">
                                            </cc1:CalendarExtender>
                                            <div id="Div1" class="form-box" runat="server">
                                                <h1>
                                                    <span class="icon">
                                                        <img src="../images/icn-route.gif" alt="" /></span>Route Planning
                                                </h1>
                                                <table id="Table1" border="0" cellpadding="0" cellspacing="0" class="form-tbl" runat="server"
                                                    width="100%">
                                                    <tr>
                                                        <td class="split">&nbsp;
                                                        </td>
                                                        <td>
                                                            <img src="../images/calendar-rht-icon.gif" width="15" height="16" alt="" />&nbsp;
                                                        <asp:Label ID="lblDate" runat="server" Text="Date"></asp:Label>
                                                            &nbsp;<asp:Label ID="Label10" runat="server" ForeColor="Red">*</asp:Label>
                                                        </td>
                                                        <td colspan="4" style="padding: 0px; margin: 0px">
                                                            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                                                <tr>
                                                                    <td>
                                                                        <asp:TextBox ID="txtDate" runat="server" oncopy="return false" oncut="return false"
                                                                            CssClass="date" onkeypress="return false" onpaste="return false" TabIndex="1"></asp:TextBox>
                                                                    </td>
                                                                    <td>
                                                                        <img src="../images/icn-shiftin-time.gif" align="top" alt="" />
                                                                        <asp:Label ID="lblShiftinTime" runat="server" Text="ShiftIn" CssClass="label"></asp:Label>

                                                                    </td>
                                                                    <td>
                                                                        <asp:DropDownList ID="ddlShiftinTime" runat="server" CssClass="time">
                                                                        </asp:DropDownList>
                                                                        <asp:DropDownList ID="ddlShiftinTimeMinutes" runat="server" CssClass="time">
                                                                            <asp:ListItem>00</asp:ListItem>
                                                                            <asp:ListItem>15</asp:ListItem>
                                                                            <asp:ListItem>30</asp:ListItem>
                                                                            <asp:ListItem>45</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                    <td>
                                                                        <img src="../images/icn-shiftout-time.gif" align="top" alt="" />
                                                                        <asp:Label ID="lblShiftOutTime" runat="server" Text="ShiftOut" CssClass="label"></asp:Label>

                                                                    </td>
                                                                    <td>
                                                                        <asp:DropDownList ID="ddlShiftOutTime" runat="server" CssClass="time" onchange="ValidateTime('ddlShiftinTime','ddlShiftOutTime','ddlShiftinTimeMinutes','ddlShiftOutTimeMinutes');">
                                                                        </asp:DropDownList>
                                                                        <asp:DropDownList ID="ddlShiftOutTimeMinutes" runat="server" CssClass="time" onchange="ValidateTime('ddlShiftinTime','ddlShiftOutTime','ddlShiftinTimeMinutes','ddlShiftOutTimeMinutes');">
                                                                            <asp:ListItem>00</asp:ListItem>
                                                                            <asp:ListItem>15</asp:ListItem>
                                                                            <asp:ListItem>30</asp:ListItem>
                                                                            <asp:ListItem>45</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                    <td>
                                                                        <img src="../images/icn-trip-mode.gif" align="top" alt="" />
                                                                        <asp:Label ID="lblType" runat="server" Text="Trip Mode" CssClass="label"></asp:Label>
                                                                        &nbsp;<asp:Label ID="Label13" runat="server" ForeColor="Red">*</asp:Label>
                                                                    </td>
                                                                    <td width="8%">
                                                                        <asp:DropDownList ID="ddlTripMode" runat="server" Width="100%">
                                                                            <asp:ListItem>- Select -</asp:ListItem>
                                                                            <asp:ListItem>Pickup</asp:ListItem>
                                                                            <asp:ListItem>Drop</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                    <td>
                                                                        <asp:ImageButton ID="btnGenerateEmployeeList" runat="server" ImageUrl="~/images/btn-show-employees.jpg"
                                                                            OnClientClick="return ValidateRoutePlanning();" OnClick="btnGenerateEmployeeList_Click" />
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label ID="lblManitary" runat="server" ForeColor="Red">*</asp:Label>
                                                                        &nbsp;
                                                                    <asp:Label ID="lblIndicates" runat="server">Mandatory fields</asp:Label>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </asp:Panel>

                                        <asp:Panel ID="pnlEmployeeDetails" CssClass="ControlShow" runat="server">
                                            <div id="grid-dsply">
                                                <div class="clear clearfix">
                                                </div>
                                                <div id="top">
                                                    <div class="left-col">
                                                        <h1>
                                                            <span class="icon" style="padding-top: 5px;">
                                                                <img src="../images/usernew-icon.gif" alt="" /></span><span class="txt"> Employee 
                                                        Details</span></h1>
                                                    </div>
                                                    <div class="right-col" align="right">
                                                        <asp:ImageButton ID="btnGetRouteOptimization" runat="server" ImageUrl="~/images/btn-route-planning.jpg"
                                                            OnClick="btnGetRouteOptimization_Click" />


                                                    </div>
                                                </div>
                                                <dxw:ASPxGridView ID="gvEmpDetails" ClientInstanceName="gvEmployeeDetails" KeyFieldName="EmployeeId"
                                                    runat="server" Width="100%" AutoGenerateColumns="False" EnableTheming="true" Theme="Office2003Blue"
                                                    CssFilePath="~/App_Themes/Office2003 Blue/{0}/grid.css" CssPostfix="Office2003_Blue">
                                                    <%--<Images ImageFolder="~/App_Themes/Office2003 Blue/{0}/">
                                                    <CollapsedButton Height="12px" Url="~/App_Themes/Office2  003 Blue/GridView/gvCollapsedButton.png"
                                                        Width="11px" />
                                                    <ExpandedButton Height="12px" Url="~/App_Themes/Office2003 Blue/GridView/gvExpandedButton.png"
                                                        Width="11px" />
                                                    <DetailCollapsedButton Height="12px" Url="~/App_Themes/Office2003 Blue/GridView/gvCollapsedButton.png"
                                                        Width="11px" />
                                                    <DetailExpandedButton Height="12px" Url="~/App_Themes/Office2003 Blue/GridView/gvExpandedButton.png"
                                                        Width="11px" />
                                                </Images>--%>
                                                    <Styles AlternatingRow-Enabled="True" CssFilePath="~/App_Themes/Office2003 Blue/{0}/styles.css"
                                                        CssPostfix="Office2003_Blue">
                                                        <Header ImageSpacing="5px" SortingImageSpacing="5px">
                                                        </Header>
                                                        <LoadingPanel ImageSpacing="10px">
                                                        </LoadingPanel>
                                                        <PagerBottomPanel CssClass="PageFooter">
                                                        </PagerBottomPanel>
                                                        <PagerTopPanel CssClass="PageFooter">
                                                        </PagerTopPanel>
                                                    </Styles>
                                                    <SettingsPager PrevPageButton-Image-Url="../App_Themes/Office2003 Blue/GridView/pPrev.gif"
                                                        PrevPageButton-Image-UrlDisabled="../App_Themes/Office2003 Blue/GridView/pPrevDisabled.gif"
                                                        NextPageButton-Image-UrlDisabled="../App_Themes/Office2003 Blue/GridView/pNextDisabled.gif"
                                                        NextPageButton-Image-Url="../App_Themes/Office2003 Blue/GridView/pNext.gif" AlwaysShowPager="true">
                                                    </SettingsPager>
                                                    <Columns>
                                                        <dxw:GridViewDataColumn Caption="DisplayName" FieldName="DisplayName" Width="15%">
                                                            <HeaderCaptionTemplate>
                                                                <span class="icon">
                                                                    <img src="../images/icn-employee-name.gif" align="top" alt="" /></span>
                                                                <span class="label">Employee Name</span>
                                                            </HeaderCaptionTemplate>
                                                        </dxw:GridViewDataColumn>
                                                        <dxw:GridViewDataColumn Caption="StreetAddress" FieldName="StreetAddress" Width="25%">
                                                            <HeaderCaptionTemplate>
                                                                <span class="icon">
                                                                    <img src="../images/icn-address.gif" align="top" alt="" /></span> <span class="label">Address</span>
                                                            </HeaderCaptionTemplate>
                                                        </dxw:GridViewDataColumn>
                                                        <dxw:GridViewDataColumn Caption="LocalityName" FieldName="LocalityName" Width="15%">
                                                            <HeaderCaptionTemplate>
                                                                <span class="icon">
                                                                    <img src="../images/icn-locality.gif" align="top" alt="" /></span> <span class="label">Locality Name</span>
                                                            </HeaderCaptionTemplate>
                                                        </dxw:GridViewDataColumn>
                                                        <dxw:GridViewDataTextColumn Caption="DepartmentName" FieldName="DepartmentName"
                                                            Width="10%">
                                                            <HeaderCaptionTemplate>
                                                                <span class="icon">
                                                                    <img src="../images/icn-department.gif" align="top" alt="" /></span> <span class="label">Department</span>
                                                            </HeaderCaptionTemplate>
                                                        </dxw:GridViewDataTextColumn>
                                                        <dxw:GridViewDataTextColumn Caption="OrgDivisionName" FieldName="OrgDivisionName"
                                                            Width="10%">
                                                            <HeaderTemplate>
                                                                <span class="icon">
                                                                    <img src="../images/icn-division.gif" align="top" alt="" /></span> <span class="label">Division</span>
                                                            </HeaderTemplate>
                                                        </dxw:GridViewDataTextColumn>
                                                        <dxw:GridViewDataTextColumn Caption="Building" FieldName="Building" Width="7%">
                                                            <HeaderTemplate>
                                                                <span class="icon">
                                                                    <img src="../images/icn-building.gif" align="top" alt="" /></span> <span class="label">Building</span>
                                                            </HeaderTemplate>
                                                        </dxw:GridViewDataTextColumn>
                                                        <dxw:GridViewDataTextColumn Caption="MobileNo" FieldName="MobileNo" Width="10%">
                                                            <HeaderTemplate>
                                                                <span class="icon">
                                                                    <img src="../images/icn-contact-number.gif" align="top" alt="" /></span>
                                                                <span class="label">Contact Number</span>
                                                            </HeaderTemplate>
                                                        </dxw:GridViewDataTextColumn>
                                                    </Columns>
                                                    <Settings ShowStatusBar="Auto" ShowFilterRow="false" ShowGroupPanel="false" />
                                                    <SettingsText EmptyDataRow="No Data Identified" />
                                                    <SettingsBehavior ColumnResizeMode="NextColumn" AllowSort="true" AllowDragDrop="true"
                                                        AllowGroup="true" AllowFocusedRow="false" />
                                                    <SettingsPager PageSize="10" Mode="ShowPager">
                                                    </SettingsPager>
                                                </dxw:ASPxGridView>
                                            </div>
                                        </asp:Panel>

                                        <asp:Button ID="btnDistance" runat="server" OnClick="btnDistance_Click" Style="display: none;" />

                                        <!-- Tsp Process controls start -->
                                        <asp:HiddenField ID="hdnDistance" runat="server" />
                                        <asp:HiddenField ID="hdnInValidVeh" runat="server" />

                                        <table class="round" style="display: none;">
                                            <tr class="roundborder">
                                                <td class="ul"></td>
                                                <td class="u"></td>
                                                <td class="ur"></td>
                                            </tr>
                                            <tr>
                                                <td class="l"></td>
                                                <td class="m">
                                                    <h2>Route Planning</h2>
                                                    <div id="map" class="myMap"></div>
                                                    <br>
                                                    <br>
                                                    <div id="buttonArea">


                                                        <table class="buttonTable" style="display: none;">
                                                            <tr>
                                                                <td>
                                                                    <input id="button1" class="calcButton" type="button" value="Calculate Fastest Roundtrip" onclick="clickedAddList(); directions(0, false, false)"></td>
                                                            </tr>
                                                        </table>
                                                </td>
                                                </div><td class="r"></td>
                                            </tr>

                                            <tr class="roundborder">
                                                <td class="ll"></td>
                                                <td class="lower"></td>
                                                <td class="lr"></td>
                                            </tr>

                                        </table>
                                        <table class="round" style="display: none;">
                                            <tr class="roundborder">
                                                <td class="ul"></td>

                                                <td class="u"></td>
                                                <td class="ur"></td>
                                            </tr>
                                            <tr>
                                                <td class="l"></td>
                                                <td class="m">
                                                    <h2>Computed Data:</h2>
                                                    <!--<div id="message"></div>-->
                                                    <div id="path" class="pathdata"></div>
                                                    <div id="durations" class="pathdata"></div>
                                                    <div id="durationsData"></div>
                                                    <div id="my_textual_div"></div>
                                                    <br>
                                                </td>
                                                <td class="r"></td>

                                            </tr>
                                            <tr class="roundborder">
                                                <td class="ll"></td>
                                                <td class="lower"></td>
                                                <td class="lr"></td>
                                            </tr>
                                        </table>
                                        <div id="exportData_hidden" style="visibility: hidden;"></div>
                                        <div id="durationsData_hidden" style="visibility: hidden;"></div>


                                    </ContentTemplate>
                                </asp:UpdatePanel>


                                <asp:UpdateProgress ID="uprDataLoading" runat="server" DynamicLayout="True" AssociatedUpdatePanelID="updRoutePlanning">
                                    <ProgressTemplate>
                                        <asp:Panel ID="pnlProgress" runat="server" CssClass="processMessage" Style="z-index: 1000;">
                                            <center>
                                                <br />
                                                <img alt="Please Wait ..." src="../images/47.gif" /><br />
                                                <br />
                                                <asp:Label ID="lbl_msg11" Text="Processing... Please Wait..." runat="server" CssClass="specialdisplay"></asp:Label>
                                                <br />
                                                <br />
                                            </center>
                                        </asp:Panel>
                                    </ProgressTemplate>
                                </asp:UpdateProgress>



                                <cc1:ModalPopupExtender ID="mpProgress" TargetControlID="pnlUpdateProgress" runat="server" PopupControlID="pnlUpdateProgress">
                                </cc1:ModalPopupExtender>
                                <asp:Panel ID="pnlUpdateProgress" runat="server" CssClass="processMessage" Style="z-index: 1000; display: none;">
                                    <center>
                                        <br />
                                        <img alt="Please Wait ..." id="imgLoading" src="../images/47.gif" /><br />
                                        <br />
                                        <asp:Label ID="lbl_msg12" Text="Processing... Please Wait..." runat="server" CssClass="specialdisplay"></asp:Label>
                                        <br />
                                        <asp:Label ID="lblProgressStatus" runat="server" ForeColor="Yellow" Font-Bold="true" Text="Loading Employee's is Completed" Style="display: none;"></asp:Label><br />
                                        <asp:Label ID="lblProgressStatus1" runat="server" Text="" Font-Bold="true" ForeColor="Yellow"></asp:Label><br />
                                        <asp:Label ID="lblDistance" runat="server" Style="display: none;" />

                                        <br />
                                    </center>
                                </asp:Panel>


                            </div>
                        </div>
                        <!-- Main Content Ends Here -->
                        <div id="left">
                        </div>
                        <div class="clear clearfix">
                        </div>
                    </div>
                    <div id="right">
                    </div>
                    <div class="clear clearfix">
                    </div>
                </div>
            </div>
        </div>
        <!-- Content Ends Here -->
        <uc2:Footer ID="ucFooter" runat="server" />
        <asp:HiddenField ID="hdndistances" runat="server" />


        <script type="text/javascript" src="../js/BpTspSolver.js"></script>

        <script type="text/javascript" src="../js/directions-export.js"></script>

        <script type="text/javascript" src="../js/tsp.js"></script>

        <script language="JavaScript1.2" type="text/javascript" src="../js/myformvalidations.js"></script>

        <script type="text/javascript" language="javascript" src="../js/FormValidations.js"></script>

        <script type="text/javascript" language="javascript" src="../js/GridCheckBoxMaintaining.js"></script>

        <script type="text/javascript" language="javascript" src="../js/Threading.js"></script>

        <script type="text/javascript" language="javascript">



            function ValidateTime(FromTime, ToTime, FromMinutes, ToMinutes) {
                var ToTimeControl = ToTime;
                if (document.getElementById(FromTime).value == "Hr") {
                    alert("Please select the Shift In time first.");
                    document.getElementById(ToTime).value = "Hr";
                    document.getElementById(FromTime).focus();
                }
                else if (document.getElementById(ToTime).value != "Hr") {
                    FromTime = document.getElementById(FromTime).value;
                    FromMinutes = document.getElementById(FromMinutes).value;
                    ToTime = document.getElementById(ToTime).value;
                    ToMinutes = document.getElementById(ToMinutes).value;
                    FromTime = eval(FromTime) + "." + eval(FromMinutes);
                    ToTime = eval(ToTime) + "." + eval(ToMinutes);
                    if (eval(ToTime) <= eval(FromTime)) {
                        alert("Please select shiftout time greater than shiftin time..!");
                        document.getElementById(ToTimeControl).value = "Hr";
                        document.getElementById(ToTimeControl).focus();
                    }
                }

            }

            //Tsp Process

            function init() {
                loadAtStart(23.805450, 78.486328, 4);

            }

            var _popup;
            function ReceiveServerData(arg, context) {
                this._popup = $find('mpProgress');
                //            this._popup.show();              
                document.getElementById('hdnDistance').value = document.getElementById('lblDistance').innerHTML;
                //document.getElementById('<%=btnDistance.ClientID%>').click();
            __doPostBack('btnDistance', 'OnClick');
            // this._popup.hide();
            // window.location.href('RoutePlanningGrid.aspx');

        }

        //Fixing "Microsoft JScript runtime error: '__pendingCallbacks[...].async' is null or not an object" Error
        //************************************************************************************************************//
        //<![CDATA[
        var GlvDelayedNextPageNo;

        function WebForm_CallbackComplete_SyncFixed() {
            // the var statement ensure the variable is not global
            for (var i = 0; i < __pendingCallbacks.length; i++) {
                callbackObject = __pendingCallbacks[i];
                if (callbackObject && callbackObject.xmlRequest &&
			(callbackObject.xmlRequest.readyState == 4)) {
                    // SyncFixed: line move below // WebForm_ExecuteCallback(callbackObject);
                    if (!__pendingCallbacks[i].async) {
                        __synchronousCallBackIndex = -1;
                    }
                    __pendingCallbacks[i] = null;
                    var callbackFrameID = "__CALLBACKFRAME" + i;
                    var xmlRequestFrame = document.getElementById(callbackFrameID);
                    if (xmlRequestFrame) {
                        xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
                    }
                    // SyncFixed: the following statement has been moved down from above;
                    WebForm_ExecuteCallback(callbackObject);
                }
            }
        }

        var OnloadWithoutSyncFixed = window.onload;

        window.onload = function Onload() {
            if (typeof (WebForm_CallbackComplete) == "function") {
                // Set the fixed version
                WebForm_CallbackComplete = WebForm_CallbackComplete_SyncFixed;
                // CallTheOriginal OnLoad
                if (OnloadWithoutSyncFixed != null) OnloadWithoutSyncFixed();
            }
        }
        //]]>
        //**********************************************************************************************************//
        </script>
        <asp:HiddenField ID="hdnLogout" runat="server" />
    </form>
</body>
</html>
