<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="investment.aspx.cs" Inherits="HRMS.Investment.investment" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="main-panel">
       <div class="row">
            <div class="col-md-12">
                <section class="panel">
                    <header class="panel-heading" style="padding-bottom:30px">
                           <span class="label label-primary">Investment</span>
                    
                        <div class="pull-right">
                            <asp:Button CssClass="btn btn-info" ID="btn_save" Text="Save" runat="server" 
                                onclick="btn_save_Click" />
                            <asp:Button CssClass="btn btn-info" ID="btn_cancel" Text="Back" 
                                runat="server" onclick="btn_cancel_Click"/>
                        </div>
                    </header>

                    <div class="panel-body">
                         <div class="span6">
                                <div id="divmessage" runat="server" visible="false" class="alert alert-info alert-dismissable">
                                    <asp:label text="" ID="lbl_msg" CssClass="msg" runat="server"></asp:label>
                                </div>
                            </div>

                            <div class="span6">
                                <div id="diverrmessage" runat="server" visible="false" class="alert alert-info alert-dismissable">
                                    <asp:label text="" id="lbl_err_msg" CssClass="msg" runat="server"></asp:label>
                                    
                                </div>
                            </div>

                            
                            <div class="row">
                            <asp:HiddenField ID="hid_per" runat="server" />
                            <asp:HiddenField ID="hid_inv" runat="server" />
                                <label class="control-label col-md-2" runat="server">Company Name</label>
                                <div class="col-md-3">
                                    <%--<asp:TextBox Visible="false" ID="txt_name" CssClass="form-control" runat="server"></asp:TextBox>--%>
                                    <asp:DropDownList ID="ddl_comp" runat="server" CssClass="form-control select2"></asp:DropDownList>
                                </div>
                                 <label class="control-label col-md-2">Available Balance</label>
                                <div class="col-md-3">
                                    <asp:TextBox CssClass="form-control" ID="txt_opn_bal"  style="text-align:right"   Enabled="false" runat="server"></asp:TextBox>
                                </div>
                            </div>


                            <div class="row" style="padding-top:5px">
                                 <label id="Label1" class="control-label col-md-2" runat="server">Amount</label>
                                <div class="col-md-3">
                                    <asp:TextBox ID="txt_amount" onkeyup = "javascript:this.value=Comma(this.value);" style="text-align:right" CssClass="form-control" runat="server" 
                                        AutoPostBack="True" ontextchanged="txt_amount_TextChanged"></asp:TextBox>
                                </div>

                                 <label id="Label4" class="control-label col-md-2" runat="server">Balance</label>
                                <div class="col-md-3">
                                    <asp:TextBox ID="txt_balance" Enabled="false"  style="text-align:right"  CssClass="form-control" runat="server"></asp:TextBox>
                                </div>

                            </div>

                                <div class="row" style="padding-top:5px">
                                <label id="Label2" class="control-label col-md-2" runat="server">Date From</label>
                                <div class="col-md-3">
                                    <asp:TextBox ID="txt_date_frm" CssClass="form-control datetime" runat="server"></asp:TextBox>
                                </div>

                                  <label id="Label3" class="control-label col-md-2" runat="server">Date To</label>
                                <div class="col-md-3">
                                    <asp:TextBox ID="txt_date_to" CssClass="form-control datetime" runat="server"></asp:TextBox>
                                </div>
                                </div>
                                <br />
                                <hr />
                                    <div class="pull-right" runat="server" visible="false" id="div">
                                        <asp:Button ID="btn_get" runat="server" CssClass="btn btn-info" 
                                            Text="Get Employee" onclick="btn_get_Click" />
                                        <asp:Button CssClass="btn btn-info" runat="server" ID="btn_save_dtl" 
                                            Text="Save Member" onclick="btn_save_dtl_Click"  />
                                    </div>



                                      <asp:GridView ID="GridView1" runat="server" CssClass="display" 
                            CellPadding="0" border="0" AutoGenerateColumns="false" 
                             onrowcommand="GridView1_RowCommand" 
                             onrowdatabound="GridView1_RowDataBound"  >
                                <Columns>
                                    <asp:BoundField DataField="inv_mem_id" HeaderText="ID" />
                                    <asp:boundfield datafield="account_id" headertext="Employee ID" ItemStyle-CssClass="hidden" HeaderStyle-CssClass="hidden" />
                                    <asp:BoundField DataField="name" HeaderText="Name" />
                                    <asp:BoundField DataField="Tot_OPN_PF" HeaderText="Total Amount" />
                                    <asp:BoundField HeaderText="Amount" />
                                    <asp:BoundField HeaderText="Percentage" />
                                    
                                    <%--<asp:BoundField DataField="date_from" HeaderText="Date From" />
                                    <asp:BoundField DataField="date_to" HeaderText="Date To" />--%>
                                    <asp:TemplateField HeaderText="Action">
                                        <ItemTemplate>
                            <asp:HiddenField ID="hid_inv_dtl" runat="server" Value='<%#Eval("inv_mem_id") %>'/>
                                
                                            <asp:LinkButton ID="lnk_edit" runat="server" CommandName="g_edit"><i class="fa fa-pencil" style="font-size:20px !important"></i></asp:LinkButton>
                                            <asp:LinkButton ID="lnk_dlt" runat="server" CommandName="g_delete"  OnClientClick="return confirm('Are you sure to delete?')"><i class="fa fa-trash" style="font-size:20px !important"></i></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                 <FooterStyle CssClass="footerStyle" />
                                 <HeaderStyle CssClass="headerStyle" />
                                 <RowStyle CssClass="rowStyle" />
                            </asp:GridView>
                             <script src="/ThemeScrips/Datatables/media/js/jquery.js" type="text/javascript"></script>
                             <script src="/ThemeScrips/Datatables/media/js/jquery.datatables.min.js" type="text/javascript"></script>
                             <script src="/ThemeScrips/Datatables/media/js/jquery.Datatables.js" type="text/javascript"></script>
                             <script src="/ThemeScrips/Datatables/media/js/GridviewFix.js" type="text/javascript"></script>
                             <script type="text/javascript">
                                 $("#ContentPlaceHolder1_GridView1").GridviewFix().dataTable();
                             </script>

                     <div class="row">
                         <div class="span6">
                                <label id="lbl1" visible="false" runat="server" class="control-label col-md-10 col-md-offset-1 alert alert-danger alert-dismissable" style="text-align:left">Amount should be Less than Balance...!</label>
                           </div>
                     </div>
                         

                    </div>

                </section>
            </div>
       </div>
    </div>

    <script>
        function Comma(Num) { //function to add commas to textboxes
            Num += '';
            Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
            Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
            x = Num.split('.');
            x1 = x[0];
            x2 = x.length > 1 ? '.' + x[1] : '';
            var rgx = /(\d+)(\d{3})/;
            while (rgx.test(x1))
                x1 = x1.replace(rgx, '$1' + ',' + '$2');
            return x1 + x2;
        }


        function CheckPFValue() {
            let amt = document.getElementById('<%=txt_amount.ClientID%>').value;
            let pf_value = document.getElementById('<%=txt_opn_bal.ClientID%>').value;

            // Check is loan amount greater than PF amount or less than PF amount
            if (amt != "") {
                if (parseInt(document.getElementById('<%=txt_amount.ClientID%>').value) > parseInt(document.getElementById('<%=txt_opn_bal.ClientID%>').value)) {
                    document.getElementById('<%= btn_save.ClientID %>').disabled = true;
                    document.getElementById('lbl1').style.display = "block";
                }

                else if (parseInt(document.getElementById('<%=txt_amount.ClientID%>').value) <= parseInt(document.getElementById('<%=txt_opn_bal.ClientID%>').value)) {
                    document.getElementById('<%= btn_save.ClientID %>').disabled = false;
                    document.getElementById('lbl1').style.display = "none";
                }
            }
        }

    </script>



</asp:Content>
