<%@ page language="C#" autoeventwireup="true" masterpagefile="~/MasterFile/TimeCheck.master" inherits="Masters_TA_UI_Master_ProjectList, App_Web_3fkcmghr" %>

<%@ Register TagPrefix="dxGridview" Assembly="DevExpress.Web.v14.2" Namespace="DevExpress.Web" %>
<%@ Register Assembly="DevExpress.Web.v14.2" Namespace="DevExpress.Web"
    TagPrefix="devEditors" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ContentPlaceHolderID="BodyContentPH" ID="conProject" runat="server">
    <script src="../plugins/datepicker/jquery-1.11.1.min.js"></script>
    <script language="javascript" src="../js/jquery.autocomplete.js" type="text/javascript"></script>
    <script src="../plugins/datepicker/bootstrap-datepicker.js"></script>
     <script type="text/javascript">
        function navi(loc) {
            document.getElementById('ctl00_BodyContentPH_iframePopup').src = loc;
            return false;
        }
        function Delete_Conf() {
            //Alert_AreyousuretoDelete
            //return confirm('Are you sure, to delete?');
            var ControlID = id;
            if (document.getElementById(ControlID).Disabled == false) {
                return confirm('Are you sure to Delete ?');
            }
        }

    </script>
    <script type="text/javascript">
        function checkAll(objRef) {
            var GridView = objRef.parentNode.parentNode.parentNode;
            var inputList = GridView.getElementsByTagName("input");
            for (var i = 0; i < inputList.length; i++) {
                var row = inputList[i].parentNode.parentNode;
                if (inputList[i].type == "checkbox" && objRef != inputList[i]) {
                    if (objRef.checked) {
                        inputList[i].checked = true;
                    }
                    else {
                        inputList[i].checked = false;
                    }
                }
            }
        }
        function ShowPopup() {
            $(document).ready(function () {
                $("#MyShowGrid").modal('show');
            });
        }
    </script>
    <div class="content-header">
        <h1 style="background-image: url(../dist/img/swipe-icon.png); background-repeat: no-repeat; padding-left: 35px">
            <asp:Label ID="lbl_ProjectMaster" runat="server"></asp:Label>
        </h1>
        <asp:SiteMapPath ID="site" runat="server" CssClass="breadcrumb">
            <NodeStyle CssClass="active" />
        </asp:SiteMapPath>
    </div>
    <div id="myModal" class="modal modal-default fade" role="dialog">
        <div class="modal-dialog" style="min-width: 85%;">
            <!-- Modal content-->
            <div class="modal-content" style="margin-top: 100px">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" style="border-radius: 50px;">
                        &times;</button>
                    <h4 class="modal-title">
                        <asp:Label ID="lblDataView" runat="server" Text="Data View"></asp:Label>
                    </h4>
                </div>
                <div class="modal-body">
                    <iframe id="iframePopup" runat="server" scrolling="auto" width="100%" height="590px"
                        style="border-style: none"></iframe>
                </div>
                <div class="modal-footer" style="display: none">
                    <button type="button" class="btn btn-primary pull-right" data-dismiss="modal">
                        Close</button>
                </div>
            </div>
        </div>
    </div>
    <div class="content">
        <div class="form-horizontal">
           <div id="MyShowGrid" class="modal modal-default fade" role="dialog">
                <div class="modal-dialog" style="min-width: 50%; max-width: 60%">
                    <!-- Modal content-->
                    <div class="modal-content" style="margin-top: 100px">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" style="border-radius: 50px;">
                                &times;</button>
                            <h4 class="modal-title">
                                <asp:Label ID="lblProjectList" runat="server" ></asp:Label>
                            </h4>
                        </div>
                        <div class="modal-body">                          
                            <asp:GridView ID="gvProjectList" runat="server" AutoGenerateColumns="False" Width="100%"
                                PageSize="10" AllowPaging="True" CssClass="table das-table1" OnPageIndexChanging="gvProjectList_PageIndexChanging">
                                <Columns>
                                    <asp:TemplateField>
                                        <HeaderTemplate>
                                            <asp:CheckBox ID="checkall" runat="server" onclick="checkAll(this);" />
                                            <asp:Label ID="lblall" runat="server"></asp:Label>
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkSelected" runat="server"></asp:CheckBox>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" Width="6%" />
                                        <HeaderStyle HorizontalAlign="center" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Project ID / Code">
                                        <ItemTemplate>
                                            <asp:Label ID="lblProjectCode" runat="server" Text='<% # Bind("Project_Code") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Project Name">
                                        <ItemTemplate>
                                            <asp:Label ID="lblProjectName" runat="server" Text='<% # Bind("Project_Name") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Start Date" Visible="false">
                                        <ItemTemplate>
                                            <asp:Label ID="lblProjectStartTime" runat="server" Text='<% # Bind("Project_StartTime") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                       <asp:TemplateField HeaderText="End Date" Visible="false">
                                        <ItemTemplate>
                                            <asp:Label ID="lblProjectEndTime" runat="server" Text='<% # Bind("Project_EndTime") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                       <asp:TemplateField HeaderText="Status" Visible="false">
                                        <ItemTemplate>
                                            <asp:Label ID="lblProjectStatus" runat="server" Text='<% # Bind("Project_Status") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <RowStyle Height="30px" CssClass="table-bg" BorderColor="#C5DFFC" />
                                <PagerStyle Font-Overline="False" HorizontalAlign="Right" CssClass="GridPager" />
                                <PagerSettings FirstPageText="<<" LastPageText=">>" Mode="NumericFirstLast" NextPageText=">"
                                    PreviousPageText="<" />
                                <HeaderStyle CssClass="empheader" />
                                <AlternatingRowStyle BackColor="white" />
                            </asp:GridView>
                        </div>
                        <div class="modal-footer">
                         <%--   <asp:LinkButton ID="btnSave" runat="server" Text="&nbsp;&nbsp;Save" CssClass="btn save-btn fa-floppy-o"
                               OnClick="GetSelectedRecords" />--%>
                        </div>
                    </div>
                </div>
            </div>
            <div class="border-table new-space" style="margin-top: 0px">
                <div class="row form-group">
                    <div class="col-md-12" style="overflow: auto; overflow-y: hidden; padding-bottom: 10px">
                        <asp:HiddenField ID="hdnSelectRow" runat="server" />
                        <asp:HiddenField ID="hdnGetAllid" runat="server" />
                        <dxGridview:ASPxGridView ID="gv_Project" runat="server" AutoGenerateColumns="false"
                            EnableCallBacks="false" KeyFieldName="Project_Id" ClientInstanceName="gv_Project"
                            OnHtmlRowCreated="gv_Project_HtmlRowCreated">
                            <Columns>
                                <dxGridview:GridViewDataTextColumn Caption="Project ID" FieldName="Project_Id"
                                    VisibleIndex="0" Visible="false">
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataColumn VisibleIndex="1" Width="30px" HeaderStyle-VerticalAlign="Middle"
                                    HeaderStyle-HorizontalAlign="Center" CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center">
                                    <HeaderTemplate>
                                        <input id="chkSelectAll" runat="server" type="checkbox" onclick="SelectAllOnThisPage(this)" />
                                    </HeaderTemplate>
                                    <DataItemTemplate>
                                        <input id="chkSelect" runat="server" type="checkbox" onclick="SelectOnRow(this)"
                                            accesskey='<%# Eval("Project_Id") %>' />
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataTextColumn Caption="Project ID / Code" FieldName="Project_Code"
                                    Width="100px" VisibleIndex="2">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblProjectCode" Text='<%# Eval("Project_Code") %>' runat="server"
                                            CssClass="dxlabel"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn Caption="Project Name" FieldName="Project_Name"
                                    Width="150px" VisibleIndex="3">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblProjectName" Text='<%# Eval("Project_Name") %>' runat="server"
                                            CssClass="dxlabel"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn Caption="Start Date" FieldName="Project_StartTime"
                                    Width="120px" VisibleIndex="4">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblProjectStartTime" Text='<%# Eval("Project_StartTime") %>'
                                            runat="server" CssClass="dxlabel"></asp:Label>
                                    </DataItemTemplate>
                                    
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataTextColumn Caption="End Date" FieldName="Project_EndTime"
                                    Width="120px" VisibleIndex="5">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblProjectEndTime" Text='<%# Eval("Project_EndTime") %>' runat="server"
                                            CssClass="dxlabel"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                  <dxGridview:GridViewDataTextColumn Caption="Status" FieldName="Project_Status"
                                    Width="120px" VisibleIndex="6">
                                    <DataItemTemplate>
                                        <asp:Label ID="lblProjectStatus" Text='<%# Eval("Project_Status") %>' runat="server"
                                            CssClass="dxlabel"></asp:Label>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataTextColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="30px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <a data-toggle="modal" title='<%# Session["View"] %>' data-placement="top" data-target="#myModal" onclick="return navi('TA_UI_Master_ProjectView.aspx?Project_Id=<%# Eval("Project_Id") %>')"
                                            href="#"><span class="btn btn-defalut view-icons"></span></a>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="30px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <asp:LinkButton ID="btnEdit" runat="server" ToolTip='<%# Session["Edit"] %>' data-toggle="tooltip"
                                            OnClick="EditLinkButton_Click" CommandName='<%# Eval("Project_Id") %>' data-placement="top"
                                            CssClass="btn btn-defalut edit-icons" Style="color: #3C8DBC"></asp:LinkButton>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                                <dxGridview:GridViewDataColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"
                                    CellStyle-VerticalAlign="Middle" CellStyle-HorizontalAlign="Center" Width="30px">
                                    <Settings AllowAutoFilter="false" />
                                    <DataItemTemplate>
                                        <asp:LinkButton ID="btnDelete" runat="server" ToolTip='<%# Session["Delete"] %>' data-toggle="tooltip"
                                            OnClick="btn_delete_Click_1" CommandName='<%# Eval("Project_Id") %>' data-placement="top"
                                            CssClass="btn btn-defalut del-icons" Style="color: Red" OnClientClick="return Delete_Conf(this.id);"></asp:LinkButton>
                                    </DataItemTemplate>
                                    <HeaderStyle HorizontalAlign="center" Wrap="true" />
                                </dxGridview:GridViewDataColumn>
                            </Columns>
                            <SettingsText EmptyDataRow="No Records Found" />
                            <Settings ShowFilterRow="true" />
                            <SettingsBehavior AllowSort="true" />
                            <SettingsPager PageSize="10">
                            </SettingsPager>
                            <Styles AlternatingRow-CssClass="table-bg">
                            </Styles>
                        </dxGridview:ASPxGridView>
                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" >
                            <SelectParameters>
                                <asp:SessionParameter Name="strUserGroupName" SessionField="UserGroupName" Type="String" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="pull-right-button">
                            <asp:Button ID="btnPopup" runat="server" Style="display: none" />
                            <asp:LinkButton ID="btn_add" CssClass="btn add-btn fa-plus" runat="server" OnClick="btn_add_Click" /> 
                              <asp:HiddenField ID="hdnDeletedData" runat="server" />
                            <asp:LinkButton ID="btn_PermanentDelete" CssClass="btn del-btn fa-trash-o" runat="server"
                                OnClick="btn_PermanentDelete_Click" OnClientClick="return Permanentconfirmdelete(this.form);"></asp:LinkButton>              
                            <asp:LinkButton ID="btn_Cancel" CssClass="btn btn-primary fa fa-hand-o-left" runat="server"
                                OnClick="btn_Cancel_Click" Visible="false" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" language="javascript">
        function SelectAllOnThisPage(chkSelectAll) {
            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var hdnSelectAll = document.getElementById('<%= hdnGetAllid.ClientID %>');
            if (chkSelectAll.checked == true) {
                for (var i = 0; i < gv_Project.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_gv_Project_cell' + (i + gv_Project.visibleStartIndex) + '_1_chkSelect').disabled == false) {
                        document.getElementById('ctl00_BodyContentPH_gv_Project_cell' + (i + gv_Project.visibleStartIndex) + '_1_chkSelect').checked = true;
                        var hdnUserId = document.getElementById('ctl00_BodyContentPH_gv_Project_cell' + (i + gv_Project.visibleStartIndex) + '_1_chkSelect').accessKey;
                        var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
                        var removeId = hdnSelectRow.value.split(",");
                        if (hdnUserId != "" && !Array.contains(removeId, hdnUserId)) {
                            if (hdnSelectRow.value != "")
                                hdnSelectRow.value += ",";
                            hdnSelectRow.value += hdnUserId;
                        }
                    }
                }
            }
            else {
                for (var i = 0; i < gv_Project.pageRowCount; i++) {
                    document.getElementById('ctl00_BodyContentPH_gv_Project_cell' + (i + gv_Project.visibleStartIndex) + '_1_chkSelect').checked = false;
                }
                hdnSelectRow.value = '';
            }
        }
        function SelectOnRow(chkOnSelect) {
            var hdnUserId = chkOnSelect.accessKey;
            var hdnSelectRow = document.getElementById('<%= hdnSelectRow.ClientID %>');
            var removeId = hdnSelectRow.value.split(",");
            if (chkOnSelect.checked) {
                if (hdnUserId != "" && !Array.contains(removeId, hdnUserId)) {
                    if (hdnSelectRow.value != "")
                        hdnSelectRow.value += ",";
                    hdnSelectRow.value += hdnUserId;
                }
                var varTotalCheckedCount = 0; var varTotalEnabled = 0;
                for (var i = 0; i < gv_Project.pageRowCount; i++) {
                    if (document.getElementById('ctl00_BodyContentPH_gv_Project_cell' + (i + gv_Project.visibleStartIndex) + '_1_chkSelect').disabled == false) {
                        varTotalEnabled = varTotalEnabled + 1;
                    }
                    if (document.getElementById('ctl00_BodyContentPH_gv_Project_cell' + (i + gv_Project.visibleStartIndex) + '_1_chkSelect').checked)
                        varTotalCheckedCount = varTotalCheckedCount + 1;
                }
                if (varTotalCheckedCount == varTotalEnabled)
                    document.getElementById('ctl00_BodyContentPH_gv_Project_header1_chkSelectAll').checked = true;
                else
                    document.getElementById('ctl00_BodyContentPH_gv_Project_header1_chkSelectAll').checked = false;
            }
            else {
                if (Array.contains(removeId, hdnUserId)) {
                    Array.remove(removeId, hdnUserId);
                }
                hdnSelectRow.value = removeId;
                document.getElementById('ctl00_BodyContentPH_gv_Project_header1_chkSelectAll').checked = false;
            }
        }
        
        
    </script>
</asp:Content>
