<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" EnableEventValidation="true"
    AutoEventWireup="true" CodeBehind="GL_Periods_Set.aspx.cs" Inherits="HRMS.GL_Periods_Set" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="scriptManager" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel runat="server" ID="upMain" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
           
            <div class="main-panel">
                <div class="row">
                    <div class="col-md-12">
                        <section class="panel">
                <header class="panel-heading">
                        Accounting Calender
                        <div class="pull-right">
                            <asp:button ID="btn_save" text="Save" ValidationGroup="save" CssClass="btn btn-info" runat="server" 
                                onclick="btn_save_Click"/>
                                 <asp:button text="Back" CssClass="btn btn-info" runat="server" 
                                ID="btn_cancel" onclick="btn_cancel_Click"/>

                                <%--<input type="button" value="Clear" class="btn btn-info" onclick="clearTextBox()"/>--%>
                        </div>
                </header>

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

                    <div class="span6">
                        <div id="diverrmessage" runat="server" visible="false" class="alert alert-danger alert-dismissable">
                         <asp:Label ID="lbl_err_msg" runat="server" CssClass="msg" Text=""> </asp:Label>
                        </div>
                    </div>
                 <div class="row" style="padding-top:10px">
                    <div class="col-md-4 col-md-offset-2">
                            <div class="col-md-8">
                                <asp:HiddenField ID="hid_period_set_id" runat="server" />
                            </div>
                    </div>                            
                 </div>


                     <div class="row" style="padding-top:10px">
                            <label class="control-label col-md-4">Calender</label>                                
                                    <div class="col-md-3">
                                        <asp:textbox ID="txt_cal" CssClass="form-control" runat="server"></asp:textbox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator_txt_cal" SetFocusOnError="true" ControlToValidate="txt_cal" runat="server" ValidationGroup="save" ErrorMessage="Calender is required."></asp:RequiredFieldValidator>
                                    </div>                         
                     </div>

                     <div class="row" style="padding-top:10px">
                        <label class="control-label col-md-4">Description</label>
                                <div class="col-md-3">
                                    <asp:textbox ID="txt_desc" CssClass="form-control" runat="server"></asp:textbox>
                                    <asp:RequiredFieldValidator SetFocusOnError="true" ValidationGroup="save" runat="server" id="req_desc" controltovalidate="txt_desc" errormessage="Description Required!" />
                                </div>
                     </div>

                     <div class="row" style="padding-top:10px;">
                            <div class="col-md-4 col-md-offset-4">
                                <asp:checkbox ID="chk_enable_sec" text="" runat="server" />
                                    <asp:label ID="Label2" text="Enable Security" CssClass="control-label" runat="server" />
                            </div>
                        </div>



                         <asp:Repeater ID="add_info" runat="server">
                            <HeaderTemplate><header class="panel-heading">Additional Information</header><br /></HeaderTemplate>
                            <ItemTemplate>
                                <div class="row">
                                    <asp:Label ID="r_lbl" CssClass="control-label col-md-2" runat="server" Text='<%#Eval("PROMPT") %>'></asp:Label>
                                    <div class="col-md-3">
                                        <asp:TextBox ID="txt_r_value" runat="server" CssClass="form-control" Text='<%#Eval("value") %>' placeholder='<%#Eval("PROMPT") %>'></asp:TextBox>
                                        <asp:HiddenField ID="hid_field_name" runat="server" Value='<%#Eval("col_name") %>' />
                                    </div>
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>
                        <label id="lbl" class="control-label" style="font-size:medium">Periods</label>
                       <hr />

                                      
                                      <div class="pull-right">
                                        <asp:Button ID="btn_add_detail" CssClass="btn btn-info" runat="server" 
                                              Text="Add New" onclick="btn_add_detail_Click" />
                                      </div>

                                           

                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="display" CellPadding="0" onrowcommand="GridView1_RowCommand">
                                <Columns>
                                    <asp:BoundField DataField="PERIOD_ID" HeaderText="ID"/>
                                    <asp:BoundField DataField="PERIOD_NAME" HeaderText="Name" />
                                    <asp:BoundField DataField="type" HeaderText="Type" />
                                    <asp:BoundField DataField="PERIOD_YEAR" HeaderText="Year" />
                                    <asp:BoundField DataField="QUARTER_NUM" HeaderText="Quater" />
                                    <asp:BoundField DataField="PERIOD_NUM" HeaderText="Number" />
                                    <asp:BoundField DataField="START_DATE" HeaderText="From Date" />
                                    <asp:BoundField DataField="END_DATE" HeaderText="To Date" />
                                    <asp:BoundField DataField="ad" HeaderText="Adjusting" />
                                    <asp:TemplateField HeaderText="Action" ItemStyle-Width="6%">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="linkedit" runat="server" CommandName="gEdit"><i class="fa fa-pencil" style="font-size:20px !important;"></i></asp:LinkButton>
                                            <asp:linkbutton ID="linkdlt" CausesValidation="false" CommandName="gDelete" runat="server" OnClientClick="return confirm('Are you sure to delete?')"><i class="fa fa-trash" style="font-size:20px !important"></i></asp:linkbutton>
                                        </ItemTemplate>
                                            <ItemStyle Width="6%"></ItemStyle>
                                    </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>


                            <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                        CssClass="table table-striped table-bordered table-hover" CellPadding="0" 
                        onrowdatabound="GridView2_RowDataBound" onrowcommand="GridView2_RowCommand">
                                <Columns>
                                <asp:TemplateField HeaderStyle-Width="10px">
                                    <ItemTemplate>
                                        <asp:HiddenField ID="hid_per" runat="server" Value='<%#Bind("PERIOD_ID")%>' />
                                        <asp:HiddenField ID="hid_type" runat="server" Value='<%#Bind("PERIOD_TYPE")%>' />
                                    </ItemTemplate>
                                </asp:TemplateField>    

                                <asp:TemplateField HeaderText="Name">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txt_namee" runat="server" CssClass="form-control" Text='<%#Bind("PERIOD_NAME") %>' Enabled='<%#bool.Parse(Eval("PERIOD_NAME").ToString() != "" ? "False" : "True") %>'></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Type" HeaderStyle-Width="140px">
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddl_type" runat="server" CssClass="form-control"></asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Year">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txt_year" runat="server" CssClass="form-control" Text='<%#Bind("PERIOD_YEAR") %>' Enabled='<%#bool.Parse(Eval("PERIOD_YEAR").ToString() != "" ? "False" : "True") %>'></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Quater">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txt_quat" runat="server" CssClass="form-control" Text='<%#Bind("QUARTER_NUM") %>' Enabled='<%#bool.Parse(Eval("QUARTER_NUM").ToString() != "" ? "False" : "True") %>'></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>


                                <asp:TemplateField HeaderText="Number">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txt_num" runat="server" CssClass="form-control" Text='<%#Bind("PERIOD_NUM") %>' Enabled='<%#bool.Parse(Eval("PERIOD_NUM").ToString() != "" ? "False" : "True") %>'></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>


                                <asp:TemplateField HeaderText="From date">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txt_frm_date" runat="server" CssClass="form-control form_datetime" Text='<%#Bind("START_DATE") %>' Enabled='<%#bool.Parse(Eval("START_DATE").ToString() != "" ? "False" : "True") %>'></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="To date">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txt_to_date" runat="server" CssClass="form-control form_datetime" Enabled='<%#bool.Parse(Eval("END_DATE").ToString() != "" ? "False" : "True") %>' Text='<%#Bind("END_DATE") %>' ></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>



                                <asp:TemplateField HeaderText="Adjusting">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chk" runat="server" Enabled='<%#bool.Parse(Eval("ADJUSTMENT_PERIOD_FLAG").ToString() == "Y" ? "False":"True") %>'  Checked='<%# bool.Parse(Eval("ADJUSTMENT_PERIOD_FLAG").ToString() == "Y" ? "True": "False") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>    
                                
                                    <asp:TemplateField HeaderText="Action" ItemStyle-Width="6%">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="linkedit" runat="server" CommandName="gEdit"><i class="fa fa-pencil" style="font-size:20px !important;"></i></asp:LinkButton>
                                            <asp:linkbutton ID="linkdlt" CausesValidation="false" Visible="false" CommandName="gDelete" runat="server" OnClientClick="return confirm('Are you sure to delete?')"><i class="fa fa-trash" style="font-size:20px !important"></i></asp:linkbutton>
                                        </ItemTemplate>
                                            <ItemStyle Width="6%"></ItemStyle>
                                    </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_GridView2").GridviewFix().dataTable();
                            </script>--%>

                </div>
            </section>
                    </div>
                </div>
            </div>
            <script type="text/javascript">
                function clearTextBox() {
                    var elements = document.getElementsByTagName("input");
                    for (var ii = 0; ii < elements.length; ii++) {
                        if (elements[ii].type == "text") {
                            elements[ii].value = "";
                        }
                    }
                    document.getElementById('<%=hid_period_set_id.ClientID %>').value = "";

                }
            </script>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowCommand"></asp:AsyncPostBackTrigger>
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
