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

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <asp:Panel ID="main_pnl" runat="server">
        <div class="row">
            <div id="myModal_email" class="modal fade" role="dialog">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">
                                &times;</button>
                            <h4 class="modal-title">
                                Enter your Email ID and Password:</h4>
                        </div>
                        <div class="modal-body">
                            <div class="row">
                                <div class="col-md-offset-1">
                                </div>
                                <div class="col-md-3">
                                    <label class="control-label col-md-2">
                                        Email</label>
                                </div>
                                <div class="col-md-8">
                                    <asp:TextBox ID="txt_eml" CssClass="form-control" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="req_eml" ErrorMessage="Email is required" ControlToValidate="txt_eml"
                                        SetFocusOnError="true" ValidationGroup="email" runat="server" />
                                </div>
                                <div class="col-md-3">
                                    <label class="control-label col-md-2">
                                        Password</label>
                                </div>
                                <div class="col-md-8">
                                    <asp:TextBox ID="txt_ps" CssClass="form-control" runat="server" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="Password is required"
                                        ControlToValidate="txt_eml" SetFocusOnError="true" ValidationGroup="email" runat="server" />
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <asp:Button ID="btneml" Text="Save" CssClass="btn btn-info" ValidationGroup="email"
                                OnClick="btneml_Click" runat="server" />
                            <button type="button" class="btn btn-danger" data-dismiss="modal">
                                Close</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <section class="panel">
               <header class="panel-heading">Monthly Payroll Process

               <div class="pull-right">
               <asp:Button ID="btn_run" runat="server" Text="Get Employees" ValidationGroup="Run" CssClass="btn btn-default" onclick="btn_run_Click"></asp:Button>
               <asp:Button ID="btn_run_payroll_process" runat="server" Text="Run Payroll Process" ValidationGroup="Run" CssClass="btn btn-info" Visible= "false"   onclick="btn_run_payroll_process_Click"></asp:Button>

               <asp:Button ID="btn_rollback_all" runat="server" Text="Rollback Payrol Process" OnClientClick="return confirm('Are you sure to Rollback the Payroll Process?')"
                       CssClass="btn btn-danger" onclick="btn_rollback_all_Click" ValidationGroup="Run" Visible= "false" ></asp:Button>

                       <asp:Button ID="btn_tax" runat="server" Text="Calculate Tax" ValidationGroup="Run" Visible= "false" 
                       CssClass="btn btn-primary" onclick="btn_tax_Click"></asp:Button>

                       <asp:Button ID="btn_tr_gl" runat="server" Text="Transfer To GL" Visible= "false" 
                       CssClass="btn btn-primary" onclick="btn_tr_gl_Click"></asp:Button>

                     <a data-toggle="modal" data-target="#myModal_email" visible="false" class="btn btn-info" id="btn_email" ValidationGroup="Run" runat="server">Sent Email</a>
                       
               </div>
               </header>
                <div class="panel-body">
                          <div class="span6">
                                <div id="divMessage" runat="server" visible="false" class="alert alert-info alert-dismissable">
                                    <i class="icon-check-sign"></i>
                                    <asp:Label ID="lblMessage" class="msg" runat="server" Text="" ></asp:Label>
                                </div>
                                <div class="span6">
                                    <div id="diverrorMessage" runat="server" visible="false" class="alert alert-danger alert-dismissable">
                                         <i class="icon-check-sign"></i>
                                        <asp:Label ID="lblerrorMessage" class="msg" runat="server" Text="" ></asp:Label>
                                    </div>
                                </div>
                           </div>

                          <div class ="row">
                                <label class="control-label col-md-2">Payoll Period</label>
                                   <div class="col-md-4">
                                      <asp:HiddenField ID="hid_payroll_id" runat="server"></asp:HiddenField>
                                      <asp:HiddenField ID="hid_period_id" runat="server"></asp:HiddenField>
                                      <asp:HiddenField ID="hid_period_start_date" runat="server"></asp:HiddenField>
                                      <asp:HiddenField ID="hid_period_end_date" runat="server"></asp:HiddenField>
                                      <asp:HiddenField ID="hid_element_type_id" runat="server"></asp:HiddenField>
                                      <asp:HiddenField ID="hid_element_type" runat="server"></asp:HiddenField>
                                      <asp:HiddenField ID="hid_cls" runat="server"></asp:HiddenField>
                                      <asp:HiddenField ID="hid_cmb" runat="server"></asp:HiddenField>
                                      <asp:HiddenField ID="hid_acc_type" runat="server"></asp:HiddenField>
                                       <div class="input-group">
                                         <asp:TextBox ID="txt_period_name" CssClass="form-control" runat="server" ></asp:TextBox>

                                    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator_txt_period_name" ControlToValidate="txt_period_name" ErrorMessage="Period is required. " ValidationGroup="Run" setfocusonerror="true"></asp:RequiredFieldValidator>
                                           
                                           <span class="input-group-btn">
                                              <button id="btn_lov_period" type="button" runat="server" onserverclick="btn_lov_period_Click" class="btn btn-white">
                                               <i class="fa fa-search"></i></button>
                                           </span>
                                        </div>
                                   </div>


                                <label class="col-md-2 control-label">Organization</label>
                                <div class="col-md-3">
                                    <asp:DropDownList ID="ddl_org" runat="server" CssClass="form-control select2"></asp:DropDownList>
                                </div>
                          </div>

                         <div class="row">
                          <label class="col-md-2 control-label">Position</label>
                                <div class="col-md-4">
                                    <asp:DropDownList ID="ddl_position" runat="server" CssClass="form-control select2"></asp:DropDownList>
                                </div>

                            <label class="col-md-2 control-label">Grade</label>
                                <div class="col-md-3">
                                   <asp:DropDownList ID="ddl_grd" runat="server" CssClass="form-control select2"></asp:DropDownList>
                                </div>
                         </div>

                         <br />
                           <div class="row">
                           
                            <label class="col-md-3 control-label">Check For All</label>
                            <div class="col-md-3">
                                <asp:CheckBox ID="chk_to_all" runat="server" CssClass="checkbox" AutoPostBack="true"  oncheckedchanged="chk_to_all_CheckedChanged" />
                            </div>

                            <label class="col-md-3 control-label">Payroll Approved</label>
                            <div class="col-md-3">
                                     <asp:CheckBox ID="chk_pr_apv" runat="server" CssClass="checkbox" AutoPostBack="true"  oncheckedchanged="chk_pr_apv_CheckedChanged" />
                            </div>
                                
                                 
                            
                           </div>

                            <hr style="margin-right:100px !important;margin-left:100px !important;"/>

                          <div class="row">
                            <div class="col-md-11">
                         
                             <asp:GridView ID="GridView1" runat="server" CssClass="table"  AutoGenerateColumns="False" 
                                  CellPadding="4" ForeColor="#333333" GridLines="None" HeaderStyle-BackColor="WhiteSmoke" HeaderStyle-ForeColor="Black" 
                                    onrowdatabound="GridView1_RowDataBound" 
                                    onrowcommand="GridView1_RowCommand">
                             
                             
                                 <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                 <Columns>

                                 


                                     <asp:BoundField DataField="EMPLOYEE_ID" HeaderText="Employee Code" HeaderStyle-Width="160px" />
                                     <asp:BoundField DataField="EMPLOYEE_NAME" HeaderText="Employee Name" />
                                     <asp:BoundField DataField="status" HeaderText="Status" HeaderStyle-Width="120px" />
                                     <%--<asp:BoundField DataField="USR_EMAIL" HeaderText="Email" Visible="false"/>--%>
                                     


                                     <asp:TemplateField HeaderStyle-Width="100px">
                                        <HeaderTemplate>
                                             <asp:CheckBox runat="server" ID="chkAll" />
                                        </HeaderTemplate>

                                        <ItemTemplate>
                                            <asp:CheckBox runat="server" ID="chk_payroll" CssClass="checkbox" HeaderStyle-Width="60px"/>
                                        </ItemTemplate>
                                     </asp:TemplateField>

                                     <asp:TemplateField HeaderText="Quick Links/RollBack"  HeaderStyle-Width="200px">
                                         <ItemTemplate>
                                         <asp:HiddenField ID="hid_person_id" runat="server"  Value='<% # Eval("person_id") %>'></asp:HiddenField>
                                         <asp:HiddenField ID="hid_ASSIGNMENT_ID" runat="server"  Value='<% # Eval("ASSIGNMENT_ID") %>'></asp:HiddenField>
                                          <div id="div_btn_modal" runat ="server">
                                             <a data-toggle="modal" data-target="#<%# Eval ("ROW_ID_ASSIG") %>" id="btn_modal_popup"><span class ="fa fa-envelope" style="font-size:20px"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                             <asp:LinkButton ID="btn_rollback" CommandName="cmd_roll" runat="server"><span class ="fa  fa-undo" style="font-size:20px"></asp:LinkButton>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                           
                                           </div>
                                            <div id="<%# Eval ("ROW_ID_ASSIG") %>" class="modal fade" role="dialog">
                                                      <div class="modal-dialog">

                                                        <!-- Modal content-->
                                                        <div class="modal-content">
                                                          <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                            <h4 class="modal-title"><%# Eval("EMPLOYEE_NAME")%></h4>
                                                          </div>
                                                          <div class="modal-body">
                                                               <div class="pre-scrollable">
                                                                <asp:Repeater ID="rpt_run_result" runat="server" 
                                                                         onitemdatabound="rpt_run_result_ItemDataBound" >
                                                                     <HeaderTemplate>
                                                                     
                                                                     <div class="table-responsive">
                                                                       <table class="table table-hover">
                                                                           <tr>
                                                                            <td style="width:25% !important;">
                                                                              Element Name  
                                                                            </td>
                                                                            <td style="width:25% !important;">
                                                                              Classification
                                                                            </td>
                                                                            <td style="width:25% !important;">
                                                                              Pay Value  
                                                                            </td>
                                                                             <td style="width:25% !important;"
                                                                            </td>
                                                                           
                                                                           </tr>
                                                                        </table> 
                                         
                                                                     </div>
                                     

                                                                     </HeaderTemplate>
                                                                     <ItemTemplate >
                                                                           <asp:HiddenField ID="hid_Element_Type_id" runat="server" Value='<% # Eval("ELEMENT_TYPE_ID") %>'></asp:HiddenField>
                                                                            <asp:HiddenField ID="HID_ASSIGNMENT_ID" runat="server" Value='<% # Eval("ASSIGNMENT_ID") %>'></asp:HiddenField>
                                                                      <div class="table-responsive">          
                                                                       <table  class="table table-hover  table-bordered">
                                                                           <tr>
                                                                            <td style="width:25% !important;">
                                                                              <%# Eval("Element") %>  
                                                                            </td>
                                                                            <td style="width:25% !important;">
                                                                              <%# Eval("Class") %>  
                                                                           </td>
                                                                            <td style="width:25% !important;">
                                                                              <%# Eval("Value") %>
                                                                            </td>
                                                                            <td style="width:25% !important;">
                                                                              <a id="dtl_lnk" data-toggle="collapse" href="#<%# string.Concat(Eval("ROW_ID"), "", Eval("ASSIGNMENT_ID")) %> " >Details</a>
                                                                            </td>
                                                                           </tr>
                                                                        </table>
                                                                      </div>
                                                                            <div class="collapse" id="<%# string.Concat(Eval("ROW_ID"), "", Eval("ASSIGNMENT_ID"))%>">
                                                                                 <div class="row">
                                                                                   <div class="col-md-10 col-md-offset-1">
                                                                                    <asp:GridView ID="grd_run_result_valus" runat="server" AutoGenerateColumns="false" CssClass="table  table-hover" >
                                                                                     <Columns>
                                                                                     <asp:BoundField HeaderText="Name" DataField="INPUT_VALUE"/>
                                                                                     <asp:BoundField HeaderText="VALUE" DataField="VALUE"/>
                                                                                     </Columns>
                                                                                    </asp:GridView>
                                                                                   </div>
                                                                                 </div>
                                                                              </div>
                                       
                                              
                                                                     </ItemTemplate>
                                                                 </asp:Repeater>
                                                               </div>
                                                          </div>
                                                          <div class="modal-footer">
                                                            <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                                                          </div>
                                                        </div>

                                                      </div>
                                                    </div>

                                        
                                         </ItemTemplate>

                                     
                                     </asp:TemplateField>

                                     <asp:TemplateField HeaderStyle-Width="1px">
                                        <ItemTemplate>
                                            <asp:HiddenField ID="usr_email" runat="server"  Value='<% # Eval("USR_EMAIL") %>'></asp:HiddenField>
                                             <asp:HiddenField ID="hid_elemnt_id" runat="server"  Value='<% # Eval("ELEMENT_TYPE_ID") %>'></asp:HiddenField>
                                        </ItemTemplate>
                                     </asp:TemplateField>

                                     <asp:TemplateField HeaderText="Add Elements" HeaderStyle-Width="150px" Visible="false">
                                        <ItemTemplate>
                                           <asp:LinkButton ID="btn_elem" CommandName="cmd_elem" runat="server"><span class ="fa  fa-plus" style="font-size:20px"></asp:LinkButton>   
                                        </ItemTemplate>
                                     </asp:TemplateField>

                                     

                                   <%--  <asp:TemplateField HeaderText="Element">
                                        <ItemTemplate>
                                             <div id="div_modal" runat ="server">
                                             
                                             <a data-toggle="modal"  data-target="#modal_el" id="btn_modal"><span class ="fa fa-envelope" style="font-size:20px"></a>&nbsp;&nbsp;&nbsp;&nbsp;
                                           </div>


                                             <div  id="modal_el" class="modal fade" role="dialog">
                                                      <div class="modal-dialog">

                                                        <!-- Modal content-->
                                                        <div class="modal-content">
                                                          <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                          </div>
                                                          <div class="modal-body">
                                                               <div class="pre-scrollable">
                                                                     <ItemTemplate >
                                                                            <div class="collapse">
                                                                                 <div class="row">
                                                                                   <div class="col-md-10 col-md-offset-1">
                                                                                    <asp:GridView ID="grdview_element" runat="server" AutoGenerateColumns="false" CssClass="table  table-hover">
                                                                                     <Columns>
                                                                                     <asp:BoundField HeaderText="ID" DataField="ID"/>
                                                                                     <asp:BoundField HeaderText="Name" DataField="NAME"/>
                                                                                     </Columns>
                                                                                    </asp:GridView>
                                                                                   </div>
                                                                                 </div>
                                                                              </div>
                                                                     </ItemTemplate>
                                                               </div>
                                                          </div>
                                                          <div class="modal-footer">
                                                            <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                                                          </div>
                                                        </div>

                                                      </div>
                                                    </div>





                                        </ItemTemplate>
                                     </asp:TemplateField>--%>

                                    <%-- <asp:TemplateField HeaderText="Roll Back" HeaderStyle-Width="100px">
                                        <ItemTemplate>
                                            
                                            <asp:LinkButton ID="lnk_add" CommandName="cmd_add_elm" runat="server"><span class ="fa  fa-plus" style="font-size:20px"></asp:LinkButton>
                                            <asp:Button ID="btn_rollback" runat="server" CommandName="cmd_roll"></span></asp:Button>
                                        </ItemTemplate>
                                     </asp:TemplateField>--%>
                                 </Columns>

                                     <RowStyle CssClass="rowStyle"/>
                                       <%-- Mandatory--%>
                                        <HeaderStyle CssClass="headerStyle" />
                                       <%-- optional--%>
                                       <FooterStyle  CssClass="footerStyle"  />

                                 <%--<EditRowStyle BackColor="#999999" />--%>
                                 <%--<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />--%>
                                 <%--<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />--%>
                                 <%--<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />--%>
                                 <%--<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />--%>
                                 <%--<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                 <SortedAscendingCellStyle BackColor="#E9E7E2" />
                                 <SortedAscendingHeaderStyle BackColor="#506C8C" />
                                 <SortedDescendingCellStyle BackColor="#FFFDF8" />
                                 <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                             --%>
                             
                             </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">
                                      //without passing class names.
                                      $("#ContentPlaceHolder1_GridView1").GridviewFix().dataTable();
                                      //Passing class names
                            </script>
                            </div>
                          </div>



                          <div class="modal fade" id="inputvalues" role="dialog">
   <div class="modal-dialog modal-dialog-center">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Input Values:</h4>
      </div>
      <div class="modal-body">
        
          <div class="form-group">
           <asp:Repeater ID="rpt_inputEntries" runat="server">
                         <ItemTemplate>
                         <div class="row">
                           <div class="col-md-10  col-md-offset-1">
                             <asp:Label ID="r_lbl" runat="server" class="col-md-6 control-label" Text='<%# Eval("NAME") %>'></asp:Label>
                             <div class="col-md-6">
                                 <asp:TextBox ID="txt_SCREEN_ENTRY_VALUE" runat="server"  Text='<%# Eval("value") %>' CssClass="form-control"></asp:TextBox>
                                 <asp:HiddenField ID="hid_INPUT_VALUE_ID" runat="server" Value='<%# Eval("INPUT_VALUE_ID") %>' ></asp:HiddenField>
                                 <asp:HiddenField ID="hid_ELEMENT_ENTRY_VALUE_ID" runat="server" Value='<%# Eval("ELEMENT_ENTRY_VALUE_ID") %>' ></asp:HiddenField>

                             </div>
                           </div>
                         </div>
                         </ItemTemplate>
            </asp:Repeater>

          </div>
         
      </div>
      <div class="modal-footer">
        <a data-toggle="modal" data-target="#myModal" id="btn_modal_popup" runat="server" class="btn btn-info">Save</a>
        <asp:Button ID="btn_save_inputvalues" class="btn btn-info" runat="server" Text="Save" ></asp:Button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
   </div>
</div>

                </div>


        
<script type="text/javascript" language="javascript">
    $("#<%=GridView1.ClientID%> input[id*='chkAll']:checkbox").click(function () {
        //Check/uncheck all checkboxes in list according to main checkbox 
        $("#<%=GridView1.ClientID%> input[id*='chk_payroll']:checkbox").attr('checked', $(this).is(':checked'));
    });
</script>



      

            </section>
            </div>
        </div>
    </asp:Panel>
    <script src="../../ThemeScrips/jquery.min.js"></script>
    <link href="../../ThemeScrips/select2.min.css" rel="stylesheet" />
    <script src="../../ThemeScrips/select2.min.js"></script>
    <script>
        $('.select2').select2();
    </script>
</asp:Content>
