<%@ page language="C#" autoeventwireup="true" inherits="Forms_RoutePlanningGrid, App_Web_f1guidzd" %>

<%@ 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" %>--%>

<!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" />
    <script src="../js/wow.min.js"></script>
</head>
<body onload="loadMap();">
    <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">

                                <asp:UpdatePanel ID="updRoutePlanning" runat="server">
                                    <ContentTemplate>

                                        <table width="100%">
                                            <tr>
                                                <td></td>

                                                <td>
                                                    <div id="divOrganizationMgt" runat="server" class="form-box">
                                                        <h1>
                                                            <span class="icon">
                                                                <img src="../images/icn-route-descripition.gif" /></span>Route Input 
                                                            Details</h1>
                                                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form-tbl">
                                                            <tr id="trManageOrganization" runat="server">
                                                                <td class="split"></td>
                                                                <td class="label">Trip Date
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="lblTripDate" Font-Bold="true" runat="server"></asp:Label>
                                                                </td>
                                                                <td class="split"></td>
                                                                <td>Trip Mode
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="lblTripMode" Font-Bold="true" runat="server"></asp:Label>
                                                                </td>
                                                                <td class="split" colspan="2"></td>
                                                            </tr>
                                                            <tr id="tr1" runat="server">
                                                                <td class="split"></td>
                                                                <td>Shiftin Time
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="lblShiftinTime" Font-Bold="true" runat="server"></asp:Label>
                                                                </td>
                                                                <td class="split"></td>
                                                                <td class="label">Shiftout Time
                                                                </td>
                                                                <td>
                                                                    <asp:Label ID="lblShiftOutTime" Font-Bold="true" runat="server"></asp:Label>
                                                                </td>
                                                                <td class="split"></td>
                                                                <td align="right">
                                                                    <asp:ImageButton ID="lbtnBack" ImageUrl="~/images/btn-back-to-routeplanning.jpg" runat="server" ForeColor="blue" Text="Back" OnClick="lbtnBack_Click" />
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>

                                                </td>

                                            </tr>

                                        </table>

                                        <asp:Panel ID="pnlRouteOptimizationDetails" runat="server" CssClass="form-tbl">

                                            <div id="grid-dsply">
                                                <div class="fleetContent">
                                                    <asp:GridView ID="gvAssignedVehicles" runat="server" AllowPaging="False" AllowSorting="False"
                                                        AutoGenerateColumns="False" BackColor="#CCCCCC" CellPadding="0" CellSpacing="1" onkeydown="return (event.keyCode!=13);"
                                                        GridLines="None" Width="100%" OnRowDataBound="gvAssignedVehicles_RowDataBound" ShowFooter="true">
                                                        <Columns>
                                                            <asp:TemplateField>
                                                                <HeaderTemplate>
                                                                    <table cellpadding="0" cellspacing="0" width="100%">
                                                                        <tr style="font-weight: bold;">
                                                                            <td style="width: 2%;"></td>
                                                                            <td style="width: 13%; text-align: left;">
                                                                                <span class="icon">
                                                                                    <img src="../images/icn-vehicle-name.gif" align="top" alt="" /></span>
                                                                                Vehicle Name
                                                                            </td>
                                                                            <td style="width: 13%; text-align: center;">
                                                                                <span class="icon">
                                                                                    <img src="../images/icn-occupancy.gif" align="top" alt="" /></span>
                                                                                Occupancy(%)
                                                                            </td>
                                                                            <td style="width: 13%; text-align: center;">
                                                                                <span class="icon">
                                                                                    <img src="../images/icn-numberof-employees.gif" align="top" alt="" /></span>
                                                                                Employees / Seats
                                                                            </td>

                                                                            <td style="width: 14%; text-align: center;">
                                                                                <span class="icon">
                                                                                    <img src="../images/icn-total-km.gif" align="top" alt="" /></span>
                                                                                Total KM(Approx.)                                                                           
                                                                            </td>
                                                                            <td style="width: 15%; text-align: center;">
                                                                                <span class="icon">
                                                                                    <img src="../images/icn-trip-cost.gif" align="top" alt="" /></span>Approx. 
                                                                             Trip Cost(Rs)
                                                                            </td>
                                                                            <td style="width: 15%; text-align: center;">
                                                                                <span class="icon">
                                                                                    <img src="../images/icn-travel-time.gif" align="top" alt="" /></span>
                                                                                Travel Time(Approx.)                                                                           
                                                                            </td>

                                                                            <td style="width: 12%; text-align: center;">
                                                                                <span class="icon">
                                                                                    <img src="../images/icn-tripsheets.gif" align="top" alt="" /></span>
                                                                                <asp:LinkButton ID="lbtnGenerateAllTrip" runat="server" ForeColor="blue" Text="All TripSheets" OnClick="lbtnGenerateTripSheet_Click" CommandArgument="All"></asp:LinkButton>
                                                                            </td>

                                                                        </tr>
                                                                    </table>
                                                                </HeaderTemplate>
                                                                <ItemTemplate>
                                                                    <table cellpadding="0" cellspacing="0" width="100%">
                                                                        <tr id="trVehicleDetails" runat="server">
                                                                            <td style="width: 2%;">
                                                                                <img id="imgExpandCollapse" onclick="ExpandOrCollpase(this.id);" src="../images/gvCollapsedButton.png"
                                                                                    runat="server" />
                                                                            </td>
                                                                            <td style="width: 13%; text-align: left;">
                                                                                <asp:LinkButton ID="lbtnVehicleName" OnClick="lbtnVehicleName_Click" runat="server"
                                                                                    Text='<%# Eval("VehicleName") %>' CommandArgument='<%# Eval("VehicleId") %>'></asp:LinkButton>
                                                                            </td>
                                                                            <td style="width: 13%; text-align: center;">
                                                                                <asp:Label ID="lblOccupancy" runat="server" Text='<%# Eval("Occupancy") %>'></asp:Label>
                                                                            </td>
                                                                            <td style="width: 13%; text-align: center;">
                                                                                <asp:Label ID="lblNoOfEmps" runat="server" Text='<%# Eval("NoOfEmps")+ " / " + Eval("Capacity") %>'></asp:Label>
                                                                            </td>

                                                                            <td style="width: 14%; text-align: center;">
                                                                                <asp:Label ID="lblDistance" runat="server" Text='<%# Eval("Distance") %>'></asp:Label>

                                                                            </td>
                                                                            <td style="width: 15%; text-align: center;">
                                                                                <asp:Label ID="lblTripCost" runat="server" Text='<%# Eval("TripCost") %>'></asp:Label>
                                                                            </td>


                                                                            <td style="width: 15%; text-align: center;">
                                                                                <asp:Label ID="lblTripTime" runat="server" Text='<%# Eval("TripTime") %>'></asp:Label>

                                                                            </td>

                                                                            <td style="width: 12%; text-align: center;">

                                                                                <asp:CheckBox ID="chkTrip" runat="server" />

                                                                                <asp:LinkButton ID="lbtnGenerateTripSheet" runat="server" Text="Tripsheet"
                                                                                    CommandArgument='<%# Eval("VehicleID") %>' OnClick="lbtnGenerateTripSheet_Click">
                                                                                <img src="../images/btn-tripsheet.jpg" align="top" alt="" style="padding-top:5px;" />
                                                                                </asp:LinkButton>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                    <table cellpadding="0" cellspacing="0" width="100%">
                                                                        <tr id="trOperationsList1" class="ControlHide" runat="server" style="padding-bottom: 5px">
                                                                            <td></td>
                                                                            <td colspan="7" style="margin: 0px; padding: 0px; width: 100%">
                                                                                <div id="grid-dsply">
                                                                                    <div class="fleetContent">
                                                                                        <asp:GridView ID="gvAssignedEmployees" runat="server" AllowPaging="False" AllowSorting="true"
                                                                                            AutoGenerateColumns="false" CellPadding="0" CellSpacing="1" GridLines="None"
                                                                                            Width="100%" OnRowDataBound="gvAssignedEmployees_RowDataBound">
                                                                                            <Columns>
                                                                                                <asp:TemplateField HeaderStyle-Width="12%" ItemStyle-Width="12%">
                                                                                                    <HeaderTemplate>
                                                                                                        <span class="icon">
                                                                                                            <img src="../images/icn-employee-id.gif" align="top" alt="" /></span>
                                                                                                        Employee ID
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>

                                                                                                        <asp:Label ID="lblEmpID" runat="server" Text='<%# Eval("EmployeeID") %>'></asp:Label>

                                                                                                    </ItemTemplate>
                                                                                                </asp:TemplateField>
                                                                                                <asp:TemplateField HeaderStyle-Width="13%" ItemStyle-Width="13%">
                                                                                                    <HeaderTemplate>
                                                                                                        <span class="icon">
                                                                                                            <img src="../images/icn-employee-name.gif" align="top" alt="" /></span>
                                                                                                        Name
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>

                                                                                                        <asp:Label ID="lblEmpName" runat="server" Text='<%# Eval("DisplayName") %>'></asp:Label>

                                                                                                    </ItemTemplate>
                                                                                                </asp:TemplateField>
                                                                                                <asp:TemplateField HeaderStyle-Width="8%" ItemStyle-Width="8%">
                                                                                                    <HeaderTemplate>
                                                                                                        <span class="icon">
                                                                                                            <img src="../images/icn-gender.gif" align="top" alt="" /></span> Gender
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>

                                                                                                        <asp:Label ID="lblSex" runat="server" Text='<%# Eval("Sex") %>'></asp:Label>

                                                                                                    </ItemTemplate>
                                                                                                </asp:TemplateField>
                                                                                                <asp:TemplateField HeaderStyle-Width="24%" ItemStyle-Width="24%">
                                                                                                    <HeaderTemplate>
                                                                                                        <span class="icon">
                                                                                                            <img src="../images/icn-locality.gif" align="top" alt="" /></span>
                                                                                                        Locality
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>

                                                                                                        <asp:Label ID="lblLocality" runat="server" Text='<%# Eval("LocalityName") %>'></asp:Label>

                                                                                                    </ItemTemplate>
                                                                                                </asp:TemplateField>
                                                                                                <asp:TemplateField HeaderStyle-Width="22%" ItemStyle-Width="22%">
                                                                                                    <HeaderTemplate>
                                                                                                        <span class="icon">
                                                                                                            <img src="../images/icn-address.gif" align="top" alt="" /></span>
                                                                                                        Address
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>

                                                                                                        <asp:Label ID="lblAddress" runat="server" Text='<%# Eval("StreetAddress") %>'></asp:Label>

                                                                                                    </ItemTemplate>
                                                                                                </asp:TemplateField>
                                                                                                <asp:TemplateField HeaderStyle-Width="15%" ItemStyle-Width="15%">
                                                                                                    <HeaderTemplate>
                                                                                                        <span class="icon">
                                                                                                            <img src="../images/icn-contact-number.gif" align="top" alt="" /></span>
                                                                                                        Contact#
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>

                                                                                                        <asp:Label ID="lblMobileNo" runat="server" Text='<%# Eval("MobileNo") %>'></asp:Label>

                                                                                                    </ItemTemplate>
                                                                                                </asp:TemplateField>

                                                                                                <asp:TemplateField HeaderStyle-Width="6%" ItemStyle-Width="6%">
                                                                                                    <HeaderTemplate>
                                                                                                        <span class="icon">
                                                                                                            <img src="../images/icn-move.gif" align="top" alt="" /></span>
                                                                                                        Move
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>

                                                                                                        <asp:CheckBox ID="chkMove" runat="server" />

                                                                                                    </ItemTemplate>
                                                                                                </asp:TemplateField>
                                                                                            </Columns>
                                                                                            <SelectedRowStyle BackColor="Aqua" />
                                                                                            <EmptyDataTemplate>
                                                                                                No Employees found
                                                                                            </EmptyDataTemplate>
                                                                                            <RowStyle CssClass="fleetCon" />
                                                                                            <FooterStyle CssClass="fleetFoot" />
                                                                                            <AlternatingRowStyle CssClass="fleetConalt" />
                                                                                            <SelectedRowStyle CssClass="fleetRowd" />
                                                                                            <PagerStyle CssClass="fleetFoot" HorizontalAlign="Left" />
                                                                                            <HeaderStyle CssClass="fleetHead" />
                                                                                            <EmptyDataRowStyle CssClass="fleetHead" />
                                                                                        </asp:GridView>

                                                                                    </div>

                                                                                </div>
                                                                            </td>
                                                                        </tr>
                                                                    </table>

                                                                </ItemTemplate>
                                                                <FooterTemplate>

                                                                    <table cellpadding="0" cellspacing="0" width="100%">
                                                                        <tr>
                                                                            <td width="9%">
                                                                                <asp:Label ID="lblSummary" runat="server" Text="Summary:" Font-Bold="true" ForeColor="Green"></asp:Label>
                                                                            </td>
                                                                            <td width="12%" align="center">
                                                                                <asp:Label ID="lblTotalVehicles" runat="server" Font-Bold="true" ForeColor="Green"></asp:Label>
                                                                            </td>
                                                                            <td width="13%"></td>
                                                                            <td width="14%" align="center">
                                                                                <asp:Label ID="lblTotalEmployees" runat="server" Font-Bold="true" ForeColor="Green"></asp:Label>
                                                                            </td>

                                                                            <td width="15%" align="center">
                                                                                <asp:Label ID="lblTotalDistance" runat="server" Font-Bold="true" ForeColor="Green"></asp:Label>
                                                                            </td>
                                                                            <td width="14%" align="center">
                                                                                <asp:Label ID="lblTotalCost" runat="server" Font-Bold="true" ForeColor="Green"></asp:Label>
                                                                            </td>
                                                                            <td width="15%" align="center"></td>

                                                                            <td></td>
                                                                        </tr>
                                                                    </table>
                                                                </FooterTemplate>
                                                            </asp:TemplateField>
                                                        </Columns>

                                                        <EmptyDataTemplate>
                                                            No Vehicles found
                                                        </EmptyDataTemplate>
                                                        <RowStyle CssClass="fleetCon" />
                                                        <FooterStyle CssClass="fleetFoot" />
                                                        <AlternatingRowStyle CssClass="fleetConalt" />
                                                        <PagerStyle CssClass="fleetFoot" HorizontalAlign="Left" />
                                                        <HeaderStyle CssClass="fleetHead" />
                                                        <EmptyDataRowStyle CssClass="fleetHead" />
                                                    </asp:GridView>

                                                </div>
                                            </div>
                                        </asp:Panel>
                                        <asp:HiddenField ID="hdnSelectedVehicleIds" runat="server" />

                                        <asp:HiddenField ID="hdnId1" runat="server" />
                                        <asp:HiddenField ID="hdnId2" runat="server" />
                                        <asp:HiddenField ID="hdnSelectedRows" runat="server" />
                                        <asp:HiddenField ID="hdnSelectedControls" runat="server" />
                                        <asp:HiddenField ID="hdnMovedEmps" runat="server" />
                                        <asp:HiddenField ID="hdnMovedDistance" runat="server" />
                                        <asp:HiddenField ID="hdnTripMode" runat="server" />
                                        <div id="map-dsply" style="display: none;">
                                        </div>
                                        <div id="directions" style="display: none;">
                                        </div>
                                        <asp:Button ID="btnPickupTime" runat="server" OnClick="btnPickupTime_Click" Style="display: none;" />

                                    </ContentTemplate>
                                </asp:UpdatePanel>


                            </div>
                        </div>

                        <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>
                        <!-- 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" />

        <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/GridCheckBoxMaintainingCSS.js"></script>

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



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

            function checkTrisheet(CheckId, VehicleId) {
                if (document.getElementById(CheckId).checked) {

                    document.getElementById('hdnSelectedVehicleIds').value = document.getElementById('hdnSelectedVehicleIds').value + VehicleId + ",";
                }
                else {
                    var vehicleIds = document.getElementById('hdnSelectedVehicleIds').value;
                    document.getElementById('hdnSelectedVehicleIds').value = String(vehicleIds).replace(VehicleId + ",", '');
                    vehicleIds = document.getElementById('hdnSelectedVehicleIds').value;
                }
            }
            var map;
            var gdir;
            var geocoder = null;
            var addressMarker;
            function loadMap() {
                map = new GMap2(document.getElementById('map-dsply'));
                gdir = new GDirections(map, document.getElementById("directions"));
                GEvent.addListener(gdir, "load", onGDirectionsLoad);
            }
            var toaddr = 0;
            var fromaddr = 0;
            function setDirections(toAddress, locale) {
                var latarray = new Array();
                map.clearOverlays();
                document.getElementById("directions").innerHTML = '';

                toAddress = toAddress.substring(0, toAddress.length - 1);
                if (toAddress.indexOf('#') > 0) {
                    toaddr = toAddress.split('#');
                }
                if (toAddress.indexOf('#') > 0) {
                    for (var i = 0; i < toaddr.length; i++) {

                        gdir = new GDirections(map, document.getElementById("directions"));
                        GEvent.addListener(gdir, "load", onGDirectionsLoad);

                        latarray.push(toaddr[i]);
                    }
                    gdir.loadFromWaypoints(latarray);
                }
            }
            function onGDirectionsLoad() {
                document.getElementById('hdnMovedEmps').value = '';
                for (var i = 0; i < toaddr.length - 1; i++) {
                    document.getElementById('hdnMovedEmps').value = document.getElementById('hdnMovedEmps').value + toaddr[i] + "@" + Math.round((gdir.getRoute(i).getDistance().meters / 1000) * Math.pow(10, 2)) / Math.pow(10, 2) + "#"
                }
                document.getElementById('hdnMovedDistance').value = '';
                document.getElementById('hdnMovedDistance').value = formatTime(gdir.getDuration().seconds) + "#" + formatLength(gdir.getDistance().meters)
                document.getElementById('btnPickupTime').click();
            }






            function ReceiveServerData(arg, context) {
            }
        </script>
        <asp:HiddenField ID="hdnLogout" runat="server" />
    </form>
</body>
</html>
