<%@ page language="C#" masterpagefile="~/MasterFile/TimeCheck.master" autoeventwireup="true" inherits="Transactions_TA_UI_Transactions_MultipleLeaveApplicationModifyAdmin, App_Web_2c5eojew" title="Leave Modify Admin Users" %>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPH" runat="Server">

    <script type="text/javascript">
     function openPopupMailCc()
   {
        var MailType="CC";
        window.open('GetEmailIdsPopup.aspx?MailType=' + MailType + '','Test','height=610,top=200,left=250,width=600');
        return false;
   }
    function hidedivBorrow()
    {
    document.getElementById('ctl00_BodyContentPH_divBorrowLeave').style.display="none";
    }
    function hidedivLeaveProcess()
    {
    document.getElementById('ctl00_BodyContentPH_divLeaveProcess').style.display="none";
    }
    
    function CheckDatesAndNumberOfDays()
    {
        if(document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value!="")
            {
                var weekDay=document.aspnetForm.ctl00_BodyContentPH_txtFromDate;
                var DateFormat = document.getElementById('Hidden1').value;
                var varLeaveApplicationId="0";        
                if(checkDate(weekDay,DateFormat))
                {
                    if(document.aspnetForm.ctl00_BodyContentPH_txtToDate.value!="")
                        {
                            var weekDay=document.aspnetForm.ctl00_BodyContentPH_txtToDate;
                            var DateFormat = document.getElementById('Hidden1').value;
      
                            if(checkDate(weekDay,DateFormat))
                            {
                              NumberOfdays(varLeaveApplicationId);
                            }
                            else
                            {
                            return false;
                            }
                        } 
                }
                else
                {
                     return false;
                }
            } 
    }
    function LeaveApplicationAddClear(Dateval)
    {
//            document.aspnetForm.ctl00_BodyContentPH_ddl_SessionFrom.selectedIndex=0;
//            document.aspnetForm.ctl00_BodyContentPH_ddl_SessionTo.selectedIndex=0;
            document.aspnetForm.ctl00_BodyContentPH_txt_Numberofdays.value="";
            document.getElementById('ctl00_BodyContentPH_hdnNumberofDaysApplied').value="";
        
    }
     function FormValidation()
    {
//        if(trim(document.aspnetForm.ctl00_BodyContentPH_txtReason.value)=="")
//        {
//              alert("Fill Reason");
//              return false;
//        
//        }
//        else
//       {     
              return confirm('Are you sure to Save?');
//       }   
        
    }
    
    function Validation()
    {
   
       var LTypeIndex=document.aspnetForm.ctl00_BodyContentPH_ddl_LeaveType.selectedIndex;
       
       if(LTypeIndex==-1)
       {
       alert("Select Leave Type");
             return false;
       }
        var LeaveType=document.aspnetForm.ctl00_BodyContentPH_ddl_LeaveType.options[LTypeIndex].value; 
        var TypeIndex=document.aspnetForm.ctl00_BodyContentPH_ddl_Type.selectedIndex;
         if(TypeIndex==-1)
       {
       alert("Select Leave Type");
             return false;
       }
        
        var Type=document.aspnetForm.ctl00_BodyContentPH_ddl_Type.options[TypeIndex].value; 
        if(LeaveType=="-Select-")  
        {
             alert("Select Leave Type");
             return false;
        }
        else if (Type=="-Select-") 
        {
             alert("Select Leave/Restricted Holiday");
             return false;
        }
        else if(document.aspnetForm.ctl00_BodyContentPH_txtFromDate.value=="")
        {
              alert("Fill From Date");
              return false;
        } 
        else if(document.aspnetForm.ctl00_BodyContentPH_txtToDate.value=="")
        {
              alert("Fill To Date");
              return false;
        } 
       
        else if(document.aspnetForm.ctl00_BodyContentPH_ddl_SessionFrom.selectedIndex==0)
        {
              alert("Select From Session");
              return false;  
        
        }
        else if(document.aspnetForm.ctl00_BodyContentPH_ddl_SessionTo.selectedIndex==0)
        {
              alert("Select To Session");
              return false;  
        
        }
        else if(trim(document.aspnetForm.ctl00_BodyContentPH_txtReason.value)=="")
        {
              alert("Fill Reason");
              return false;  
        
        }
         else if(document.aspnetForm.ctl00_BodyContentPH_txt_Numberofdays.value=="")
        {
              alert("Number of Days Applied Should Not Be Empty");
              return false;  
        
        }
           else if(document.aspnetForm.ctl00_BodyContentPH_txt_Numberofdays.value=="0")
        {
              alert("Number of Days Applied Should Not Be Zero");
              return false;  
        
        }
        
        else if(document.aspnetForm.ctl00_BodyContentPH_txtRemainingNoOfLeave.value=="0")
        {
              alert("Remaining number of days should not be Zero");
              return false;  
        
        }
        else if(parseInt(document.aspnetForm.ctl00_BodyContentPH_txt_Numberofdays.value)>365)
        {
              alert('Number of days applied should not exceed 365 days');
              return false;  
        
        }

       else
       {
       
       
       return confirm('Are you sure to Save?');
       }        
        
    //return true;   
   }
    function assignEmployeeId(empid)
   {
        document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value=empid;
 
//        document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex=0;
//	   
//	    document.aspnetForm.ctl00_BodyContentPH_ddl_SessionFrom.selectedIndex=0;
//	    document.aspnetForm.ctl00_BodyContentPH_ddl_SessionTo.selectedIndex=0;

//        document.getElementById('ctl00_BodyContentPH_txtRemainingNoOfLeave').value="";
//        document.getElementById('ctl00_BodyContentPH_hdnNumberofDaysApplied').value="";
//        document.getElementById('ctl00_BodyContentPH_txt_Numberofdays').value="";
//	    document.getElementById('ctl00_BodyContentPH_divLeaveProcess').style.display="none";
//	    
//	    if (document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length != null)
//	    {				
//	        for (var count = document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options.length-1;count >-1; count--)
//		    {
//			    document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[count] = null;
//			}	
//        }
//      
//       var newOptSelect = new Option('-Select-','-Select-',  false, false);
//       document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').options[0]=newOptSelect;
//       document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').selectedIndex=0;
//      
//       if(empid.value!="-Select-" && empid.value!="") 
//       {
//            document.getElementById('ctl00_BodyContentPH_ddl_Type').focus();
//       }
   }
   
   //old code
//   function assignEmployeeId(empid)
//   {
//       document.getElementById('ctl00_BodyContentPH_hdnEmployeeId').value=empid;
//       //document.getElementById('ctl00_BodyContentPH_ddl_Type').selectedIndex=0;
//       //document.getElementById('ctl00_BodyContentPH_ddl_LeaveType').selectedIndex=0;
//       document.aspnetForm.ctl00_BodyContentPH_txtRemainingNoOfLeave.value='';
//       document.aspnetForm.ctl00_BodyContentPH_ddl_SessionFrom.selectedIndex=0;
//       document.aspnetForm.ctl00_BodyContentPH_ddl_SessionTo.selectedIndex=0;
//       document.aspnetForm.ctl00_BodyContentPH_txt_Numberofdays.value='';
//        
//        //document.getElementById('ctl00_BodyContentPH_ddl_Type').focus();
//        //alert(document.getElementById('ctl00_BodyContentPH_ddl_Type').value);
//       
//   }
   
   
   function validateNumberOfDays(NumberOfDays)
   {
        if(parseInt(NumberOfDays.value)>365)
        {
        alert('Number of days applied should not exceed 365 days');
        }   
   }  
      
    </script>

    <table border="0" cellspacing="0" cellpadding="0" align="center" width="600">
        <tr>
            <td valign="top" style="width: 16px">
                <img src="../Images/corner1<%=Session["Direction"] %>.gif" width="15" height="15" /></td>
            <td valign="top" background="../Images/sideline.gif" bgcolor="#EAEAEA">
                <img src="../Images/spacer.gif" width="1" height="1" /></td>
            <td valign="top">
                <img src="../Images/corner2<%=Session["Direction"] %>.gif" width="15" height="15" /></td>
        </tr>
        <tr>
            <td background="../Images/line<%=Session["Direction"] %>.gif" style="width: 16px">
                &nbsp;</td>
            <td valign="top" bgcolor="#EAEAEA">
                <table border="0" align="center" cellpadding="0" cellspacing="1">
                    <tr>
                        <td valign="top" colspan="2" class="ModuleTitle" style="height: 21px; width: 100%">
                            <asp:Label ID="lbl_HeaderLeaveApplication" runat="server">
                            </asp:Label></td>
                    </tr>
                    <tr>
                        <td bgcolor="#ff0000" class="td" colspan="2" style="color: #ff0000; width: 100%">
                            *
                            <asp:Label ID="lblIndicatesMandatoryFields" runat="server">
                            </asp:Label><br />
                            &nbsp;
                            <asp:Label ID="lblError" runat="server" Style="color: #ff0000">
                            </asp:Label>&nbsp;
                            <input id="Hidden1" type="hidden" value='<% Response.Write(Session["IDateFormat"].ToString()); %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div id="divEmployees" runat="server" style="width: 100%">
                                <table border="0" cellpadding="1" cellspacing="1" width="100%">
                                    <tr>
                                        <td class="td" style="width: 208px">
                                            <asp:Label ID="lblEmployeeId" runat="server"></asp:Label></td>
                                        <td class="td" style="width: 300px">
                                            <asp:Label ID="lblEmployeeIdData" runat="server"></asp:Label>
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td class="td" style="width: 208px">
                                            <asp:Label ID="lblEmployeeName" runat="server"></asp:Label></td>
                                        <td class="td" style="width: 300px">
                                            <asp:Label ID="lblEmployeeNameData" runat="server"></asp:Label>
                                            &nbsp;</td>
                                    </tr>
                                </table>
                            </div>
                            <div id="divIntimationType" runat="server" style="width: 100%">
                                <table border="0" cellpadding="1" cellspacing="1" width="100%">
                                    <tr>
                                        <td class="td" style="width: 208px">
                                            <asp:Label ID="Label11" runat="server" Text="Intimation Type"></asp:Label>
                                        </td>
                                        <td class="td" style="width: 300px">
                                            <asp:RadioButton ID="rbtnP" runat="server" GroupName="IntimationType" Text="P" onclick="document.getElementById('ctl00_BodyContentPH_lstInformTo').disabled = true;"/>
                                            <asp:RadioButton ID="rbtnUPWI" runat="server" GroupName="IntimationType" Text="UP-WI" onclick="document.getElementById('ctl00_BodyContentPH_lstInformTo').disabled = false;"/>
                                            <asp:RadioButton ID="rbtnUPWOI" runat="server" GroupName="IntimationType" Text="UP-WOI" onclick="document.getElementById('ctl00_BodyContentPH_lstInformTo').disabled = true;"/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="td" style="width: 40%">
                                            Inform To
                                        </td>
                                        <td class="td" style="width: 50%">
                                            <asp:ListBox ID="lstInformTo" runat="server" SelectionMode="Multiple"></asp:ListBox>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="divPreviousReason" runat="server" style="width: 100%">
                                <table border="0" cellpadding="1" cellspacing="1" width="100%">
                                    <tr>
                                        <td class="td" style="width: 208px">
                                            <asp:Label ID="lbl_Reason" Text="Reason" runat="server"></asp:Label></td>
                                        <td class="td" style="width: 300px">
                                            <asp:Label ID="lblPreviousReason" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="divGrid" runat="server" style="width: 100%">
                                <asp:GridView ID="gvTestGrid" DataKeyNames="SLNo" runat="server" CellSpacing="1"
                                    CellPadding="0" ForeColor="Black" GridLines="None" AutoGenerateColumns="False"
                                    OnRowCreated="gvTestGrid_RowCreated" OnRowDataBound="gvTestGrid_RowDataBound"
                                    Height="1px" AllowSorting="true" OnSorting="gvTestGrid_Sorting" OnRowCommand="gvTestGrid_RowCommand"
                                    OnRowDeleting="gvTestGrid_RowDeleting">
                                    <RowStyle CssClass="td" />
                                    <Columns>
                                        <asp:BoundField DataField="SLNo" HeaderText="SL No.">
                                            <HeaderStyle CssClass="td" Width="50px" Height="25px" />
                                            <ItemStyle HorizontalAlign="Center" CssClass="td" />
                                        </asp:BoundField>
                                        <asp:TemplateField HeaderText="Leave Category">
                                            <HeaderStyle />
                                            <ItemStyle Width="90px" Height="25px" CssClass="mainbox_text" HorizontalAlign="Center" />
                                            <ControlStyle CssClass="GridControlText" />
                                            <ItemTemplate>
                                                <asp:DropDownList CssClass="td" Height="20" OnSelectedIndexChanged="ddlLeaveCategory_SelectedIndexChanged"
                                                    ID="ddlLeaveCategory" runat="server" AutoPostBack="true" Width="90px">
                                                    <asp:ListItem Value="1" Text="Leave"></asp:ListItem>
                                                    <asp:ListItem Value="2" Text="LOP"></asp:ListItem>
                                                    <asp:ListItem Value="3" Text="Comp Off"></asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:HiddenField ID="hdnLeaveCategory" EnableViewState="true" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Leave Types">
                                            <HeaderStyle Width="90px" />
                                            <ItemStyle Width="90px" Height="25px" HorizontalAlign="Center" />
                                            <ControlStyle Width="90px" CssClass="GridControlText" />
                                            <ItemTemplate>
                                                <asp:DropDownList CssClass="td" Height="20" ID="ddlLeaveTypes" runat="server" AutoPostBack="false"
                                                    Width="90px" onfocusin="this.className='GridControlText1'" onfocusout="this.className='GridControlText'"
                                                    Style="border-style: none; background-image: url(Images/gradient.jpg);">
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Leave From">
                                            <HeaderStyle Width="100" />
                                            <ItemStyle Width="100px" Height="25px" HorizontalAlign="Center" />
                                            <ControlStyle CssClass="GridControlText" />
                                            <ItemTemplate>
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="90px">
                                                            <asp:TextBox ID="txtFromDate" runat="server" Text='<%# Bind("LeaveFrom") %>' Width="70"
                                                                onfocusin="this.className='GridControlText1';" onfocusout="this.className='GridControlText'"></asp:TextBox></td>
                                                        <td>
                                                            <div runat="server" id="LeaveFromDivText">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Leave To">
                                            <HeaderStyle Width="100" />
                                            <ItemStyle Width="100px" Height="25px" HorizontalAlign="Center" />
                                            <ControlStyle CssClass="GridControlText" />
                                            <ItemTemplate>
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td width="90px">
                                                            <asp:TextBox ID="txtToDate" runat="server" Text='<%# Bind("LeaveTo") %>' Width="70"
                                                                onfocusin="this.className='GridControlText1';" onfocusout="this.className='GridControlText'"></asp:TextBox></td>
                                                        <td>
                                                            <div runat="server" id="LeaveToDivText">
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Session From">
                                            <HeaderStyle Width="90px" />
                                            <ItemStyle Width="90px" Height="25px" HorizontalAlign="Center" />
                                            <ControlStyle Width="90px" CssClass="GridControlText" />
                                            <ItemTemplate>
                                                <asp:DropDownList CssClass="td" EnableViewState="true" Height="20" ID="ddlSessionsFrom"
                                                    runat="server" AutoPostBack="false" Width="90px" onfocusin="this.className='GridControlText1'"
                                                    onfocusout="this.className='GridControlText'" Style="border-style: none; background-image: url(Images/gradient.jpg);">
                                                    <asp:ListItem Value="1" Text="First Half"></asp:ListItem>
                                                    <asp:ListItem Value="2" Text="Second Half"></asp:ListItem>
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Session To">
                                            <HeaderStyle Width="90px" />
                                            <ItemStyle Width="90px" Height="25px" HorizontalAlign="Center" />
                                            <ControlStyle Width="90px" CssClass="GridControlText" />
                                            <ItemTemplate>
                                                <asp:DropDownList CssClass="td" EnableViewState="true" Height="20" ID="ddlSessionsTo"
                                                    runat="server" AutoPostBack="false" Width="90px" onfocusin="this.className='GridControlText1'"
                                                    onfocusout="this.className='GridControlText'" Style="border-style: none; background-image: url(Images/gradient.jpg);">
                                                    <asp:ListItem Value="1" Text="First Half"></asp:ListItem>
                                                    <asp:ListItem Value="2" Text="Second Half"></asp:ListItem>
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="No Of Leaves" Visible="true">
                                            <HeaderStyle Width="50" />
                                            <ItemStyle Width="50px" Height="25px" HorizontalAlign="Center" />
                                            <ControlStyle Width="50px" CssClass="GridControlText" />
                                            <ItemTemplate>
                                                <asp:Label ID="lblNoOfLeaves" runat="server" EnableViewState="true" CssClass="td"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("SLNo") %>' CommandName="Delete"
                                                    runat="server">
                                                         Delete</asp:LinkButton>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <SelectedRowStyle CssClass="td" />
                                    <HeaderStyle CssClass="td" />
                                    <AlternatingRowStyle CssClass="td" />
                                </asp:GridView>
                            </div>
                            <div id="divNewRow" runat="server" style="width: 100%">
                                <table border="0" cellpadding="1" cellspacing="1" width="100%">
                                    <tr>
                                        <td class="td" style="width: 205px">
                                            <asp:Button ID="btnNewRow" CssClass="but" runat="server" Text="Append" OnClick="btnNewRow_Click" />
                                        </td>
                                        <td class="td" style="width: 300px">
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="divComments" runat="server" style="width: 100%">
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tr>
                                        <td class="td" style="width: 205px">
                                            <div id="divLeaveConversation" runat="server">
                                            </div>
                                        </td>
                                        <td class="td" style="width: 300px">
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="divReason" runat="server" style="width: 100%; display: none;">
                                <table border="0" cellpadding="1" cellspacing="1" width="100%">
                                    <tr>
                                        <td class="td" style="width: 40%">
                                            <asp:Label ID="lblReason" runat="server"></asp:Label>
                                            <asp:Label ID="Label5" runat="server" ForeColor="Red" Text="*">
                                            </asp:Label>
                                        </td>
                                        <td class="td" style="width: 50%">
                                            <asp:TextBox ID="txtReason" runat="server" BorderStyle="None" MaxLength="1000" onkeypress="return chkMaxLen(event,this,1000);"
                                                TabIndex="9" TextMode="MultiLine" Height="50px" Width="400px">
                                            </asp:TextBox>
                                            &nbsp;</td>
                                    </tr>
                                    <tr style="display: none">
                                        <td class="td" style="width: 40%">
                                            <asp:Label ID="lblApprovalCC" runat="server" Text="Cc Mail Ids"></asp:Label></td>
                                        <td class="td" width="50%">
                                            <asp:TextBox ID="txtApprovalCC" runat="server" CssClass="textbox_4" OnKeyPress="return false"
                                                Width="365px" Height="40px" TextMode="MultiLine"></asp:TextBox>
                                            <asp:Button ID="btnApprovalCC" runat="server" CssClass="but" Text="Cc..." Width="28px"
                                                OnClientClick="javascript:return openPopupMailCc();" /></td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" valign="bottom" colspan="2">
                            <table border="0" align="center" cellpadding="1" cellspacing="0">
                                <tr>
                                    <td align="right" valign="middle">
                                        <asp:Button ID="btnAdd" Text="Save" CssClass="but" runat="server" OnClientClick="javascript:return FormValidation();"
                                            TabIndex="10" OnClick="btnAdd_Click" />
                                    </td>
                                    <td align="left" valign="middle">
                                        <asp:Button ID="btnCancel" Text="Back" CssClass="but" runat="server" CausesValidation="False"
                                            TabIndex="11" OnClick="btnCancel_Click" />
                                    </td>
                                    <td align="left" valign="middle">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
            <td background="../Images/line1<%=Session["Direction"] %>.gif">
                &nbsp;</td>
        </tr>
        <tr>
            <td valign="bottom" style="width: 16px">
                <img src="../Images/corner3<%=Session["Direction"] %>.gif" width="15" height="16" /></td>
            <td valign="bottom" background="../Images/sideline1.gif" bgcolor="#EAEAEA">
                <img src="../Images/spacer.gif" width="1" height="1" /></td>
            <td valign="bottom">
                <img src="../Images/corner4<%=Session["Direction"] %>.gif" width="15" height="16" /></td>
        </tr>
    </table>
    <input id="hdnEmployeeId" type="hidden" runat="server" />
</asp:Content>
