<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddVisit.aspx.cs" Inherits="NikaiDSR.Executive.AddVisit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <telerik:RadCodeBlock ID="rb" runat="server">
        <script type="text/javascript">
            var TimeIn = null;
            var TimeOut = null;

            function GetRadWindow() {
                var oWindow = null;

                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog  
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz az well)  

                return oWindow;
            }

            function RefreshParentPage() {
                GetRadWindow().Close();
                GetRadWindow().BrowserWindow.refreshGrid();
            }

                                   function cmbContact_SelectedIndexChanged(sender, eventArgs) {
                                       $find('<%=txtDepartment.ClientID %>').set_value(eventArgs.get_item().get_attributes().getAttribute("Department"));
                                        $find('<%=txtMobile.ClientID %>').set_value(eventArgs.get_item().get_attributes().getAttribute("MobileNo"));
                                    }
                       
            function TimeSelection(sender, eventArgs) {
                //alert($find('<=dtCompleted.ClientID%>').get_selectedDate());
                //alert("in");
                //var TimeIn = document.getElementById("tpTimeIn_dateInput_text").value;
                //var TimeOut = document.getElementById("tpTimeOut_dateInput_text").value;
                //alert("in");
                //alert(TimeIn.split(':')[1].substring(3));
                //if ((TimeIn != null || TimeIn != '') && (TimeOut != null || TimeOut != '')) {
                //    var HrIn = TimeIn.split(':')[0];
                //    var MinIn = TimeIn.split(':')[1].substring(0, 2);

                //    var HrOut = TimeOut.split(':')[0];
                //    var MinOut = TimeOut.split(':')[1].substring(0, 2);

                //    if (TimeIn.split(':')[1].substring(3) == "PM")
                //        HrIn = parseInt(HrIn) + 12;
                //    if (TimeOut.split(':')[1].substring(3) == "PM")
                //        HrOut = parseInt(HrOut) + 12;

                //    alert(HrOut + "--HrOut--" + HrIn + "--Hrin--" + MinOut + "--MinOut--" + MinIn + "--MinIn");

                //    var totalMin = ((parseInt(HrOut) - parseInt(HrIn)) * 60) + parseInt(MinOut) - parseInt(MinIn);

                //    document.getElementById('txtTimeSpent').value = totalMin;

                //}
            }

        </script>
    </telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="ScriptManager" runat="server" />
        <telerik:RadAjaxManager ID="RadAjaxManager2" EnableAJAX="true" runat="server">
        </telerik:RadAjaxManager>
        <div class="content_holder" style="margin-top: 10px">
            <asp:HiddenField ID="hdnDsrHeaderID" runat="server" />

            <div class="bg_shadow" style="width: 90%; margin: auto">
                <telerik:RadAjaxPanel ID="RadAjaxPanel" runat="server">
                    <div class="errMsg" id="errMsg" runat="server" style="display: none;">
                        <div class="errMsgText" id="errMsgText" runat="server"></div>
                        <br />
                    </div>
                    <table border="2" cellspacing="0" cellpadding="0" width="100%">
                        <tr>
                            <td>
                                <asp:Literal ID="Literal15" runat="server" Text="<%$ Resources:Res, Date%>" /><span id="label1" class="mand_style">*</span>
                            </td>
                            <td>:
                                <telerik:RadDatePicker ID="dpDate" runat="server" Enabled="false" />
                            </td>
                        </tr>
                        <tr>
                            <td width="150px">
                                <asp:Literal ID="Literal5" runat="server" Text="<%$ Resources:Res, Customer_Name%>" /><span id="Span1" class="mand_style">*</span>
                            </td>
                            <td>:
                                <telerik:RadComboBox ID="cmbCustomers" runat="server" Width="250" Height="150"
                                    DataTextField="Key" EnableLoadOnDemand="True" OnItemsRequested="cmbCustomers_ItemsRequested"
                                    OnSelectedIndexChanged="cmbCustomers_SelectedIndexChanged" AutoPostBack="true">
                                </telerik:RadComboBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Res, Contact_Person%>" /><span id="Span2" class="mand_style">*</span>
                            </td>
                            <td>:
                                <telerik:RadComboBox ID="cmbContact" runat="server" Width="250" Height="150"
                                    DataTextField="Contact_Name" DataValueField="Contact_Id"
                                    EnableLoadOnDemand="True" OnClientSelectedIndexChanged="cmbContact_SelectedIndexChanged"
                                    OnItemDataBound="cmbContact_ItemDataBound">
                                </telerik:RadComboBox>
                               
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:Res, Dept%>" />
                            </td>
                            <td>:
                            <telerik:RadTextBox ID="txtDepartment" runat="server" MaxLength="25" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:Res, Mobile_No%>" />
                            </td>
                            <td>:
                            <telerik:RadTextBox ID="txtMobile" runat="server" MaxLength="25" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal4" runat="server" Text="<%$ Resources:Res, Objective_of_Visit%>" /><span id="Span3" class="mand_style">*</span>
                            </td>
                            <td>:
                            <telerik:RadComboBox ID="cmbObjective" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal6" runat="server" Text="<%$ Resources:Res, Time_In%>" /><span id="Span4" class="mand_style">*</span>
                            </td>
                            <td>:
                         <telerik:RadTimePicker ID="tpTimeIn" runat="server">
                             <%--<TimeView OnClientTimeSelected="TimeSelection()" />--%>
                             <%--<DateInput ClientEvents-OnBlur="TimeSelection()" />--%>
                         </telerik:RadTimePicker>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal7" runat="server" Text="<%$ Resources:Res, Time_Out%>" /><span id="Span5" class="mand_style">*</span>
                            </td>
                            <td>:
                        <%-- <telerik:RadDateTimePicker ID="dtCompleted" DateInput-DisplayDateFormat="hh:mm tt" DateInput-DateFormat="hh:mm tt" runat="server" 
                        Width="200px" 
                        DateInput-EmptyMessage=""
                        ZIndex="999999999" DatePopupButton-Visible="false" TimeView-OnClientTimeSelected="TimeSelection()" DateInput-OnClientDateChanged="TimeSelection()" DateInput-ClientEvents-OnBlur="TimeSelection()">--%>
                    </telerik:RadDateTimePicker>
                                <telerik:RadTimePicker ID="tpTimeOut" runat="server" >
                                    <%--<TimeView OnClientTimeSelected="TimeSelection()" />--%>
                                    <%--<DateInput ClientEvents-OnBlur="TimeSelection()" />--%>
                                </telerik:RadTimePicker>
                            </td>
                        </tr>
                       <%-- <tr>
                            <td>
                                <asp:Literal ID="Literal16" runat="server" Text="<%$ Resources:Res, Time_Spent%>" />*
                            </td>
                            <td>:
                         <asp:TextBox ID="txtTimeSpent" runat="server" ReadOnly="true" />
                            </td>
                        </tr>--%>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal8" runat="server" Text="<%$ Resources:Res, Time_with_Merchandiser%>" />&nbsp;
                            </td>
                            <td>:
                            <telerik:RadNumericTextBox ID="txtTimeMerchandiser" runat="server" MaxLength="8" NumberFormat-DecimalDigits="0" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal9" runat="server" Text="<%$ Resources:Res, Collection%>" />
                            </td>
                            <td>:
                            <telerik:RadNumericTextBox ID="txtCollection" runat="server" MaxLength="8" NumberFormat-DecimalDigits="0" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal10" runat="server" Text="<%$ Resources:Res, Secondary_Sales%>" />
                            </td>
                            <td>:
                            <telerik:RadNumericTextBox ID="txtSecondarySales" runat="server" MaxLength="8" NumberFormat-DecimalDigits="0" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal11" runat="server" Text="<%$ Resources:Res, LPO_Received%>" />
                            </td>
                            <td>:
                            <telerik:RadNumericTextBox ID="txtLPO" runat="server" MaxLength="8" NumberFormat-DecimalDigits="0" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal12" runat="server" Text="<%$ Resources:Res, Discount%>" />
                            </td>
                            <td>:
                            <telerik:RadNumericTextBox ID="txtDiscount" runat="server" MaxLength="8" NumberFormat-DecimalDigits="0" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal13" runat="server" Text="<%$ Resources:Res, Sales_Returns%>" />
                            </td>
                            <td>:
                            <telerik:RadNumericTextBox ID="txtSalesReturn" runat="server" MaxLength="8" NumberFormat-DecimalDigits="0" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Literal ID="Literal14" runat="server" Text="<%$ Resources:Res, Remarks%>" />
                            </td>
                            <td>:
                            <telerik:RadTextBox ID="txtRemarks" textmode="MultiLine" runat="server" Wrap="true" Rows="4" Columns="35" />
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>:
                            <asp:Button ID="btnSave" runat="server" Text="<%$ Resources:Res, Save%>" OnClick="btnSave_Click" OnClientClick="this.disabled = true; this.value = '<%$ Resources:Res, Submitting%>';" />
                            </td>
                        </tr>
                    </table>
                </telerik:RadAjaxPanel>
            </div>
        </div>
    </form>
</body>
</html>
