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

<%@ Register Src="~/UserControls/TA_uc_OrganizationLevels.ascx" TagName="OrganizationLevel"
    TagPrefix="UC" %>
<%@ Register TagPrefix="UC1" TagName="orglevel" Src="~/UserControls/TA_uc_OrgLevel_Filter_Modify.ascx" %>

<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>
    <link href="../dist/css/bootstrap-responsive-tabs.css" rel="stylesheet" type="text/css">
    <script src="../dist/js/jquery.bootstrap-responsive-tabs.min.js"></script>
    <script src="../js/DateTimeValidation.js" type="text/javascript"></script>
    <script>

        function ValidateText(id) {
            var btnID = id;
            var txtAdd_TaskName = btnID.replace("lbtnAdd", "txtAdd_TaskName")
            var txtAdd_Hours = btnID.replace("lbtnAdd", "txtAdd_Hours")
            if (document.getElementById(txtAdd_TaskName).value == "") {
                alert("Enter the Task Name");
                document.getElementById(txtAdd_TaskName).focus();
                return false;
            }
            if (document.getElementById(txtAdd_Hours).value == "") {
                document.getElementById(txtAdd_Hours).focus();
                alert("Enter the Task Hours");
                return false;
            }
        }
        function ValidateEdit(id) {
            var btnID = id;
            var txtAdd_TaskName = btnID.replace("imgbtnUpdate", "txtedit_TaskName")
            var txtAdd_Hours = btnID.replace("imgbtnUpdate", "txtedit_Hours")
            if (document.getElementById(txtAdd_TaskName).value == "") {
                alert("Enter the Task Name");
                document.getElementById(txtAdd_TaskName).focus();
                return false;
            }
            if (document.getElementById(txtAdd_Hours).value == "") {
                document.getElementById(txtAdd_Hours).focus();
                alert("Enter the Task Hours");
                return false;
            }
        }

        $(function () {
            $('#ctl00_BodyContentPH_txtProjectEndDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
            );
        });
        $(function () {
            $('#ctl00_BodyContentPH_txtProjectStartDate').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden1').value }
            );

        });
    </script>
    <script type="text/javascript">
        function number_dot(e, ctrl) {
            dec_limit = arguments[1];
            var keycode;
            if (window.event) keycode = window.event.keyCode;
            else if (e) keycode = e.which;
            else return true;
            if ((keycode == 8) || (keycode == 0)) {
                return true;
            }
            val = ctrl.value;
            dot_index = val.indexOf('.');
            if (dot_index != -1) {
                dec_pts = (val.length - dot_index);
                if (!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
            }
            if (document.selection) {
                var selection = document.selection.createRange();
                var selected_text = selection.text;
            }
            else if (document.getSelection) {
                var start = ctrl.selectionStart;
                var end = ctrl.selectionEnd;
                var selected_text = ctrl.value.substring(start, end);
            }
            if ((val.length == 0 || selected_text != "") && (keycode == 46))	// || keycode==48
            {
                return false;
            }
            else if (dot_index != -1 && keycode == 46) {
                return false;
            }
            else if (!(keycode >= 48 && keycode <= 58) && (keycode != 13) && (keycode != 46) && (keycode = 36) && (keycode != 8) && (keycode != 0) && (keycode = 45) && (keycode = 47)) {
                return false;
            }
            else return true;
        }
        function numbers_dot(e, ctrl) {
            dec_limit = arguments[1];
            var keycode;
            if (window.event) keycode = window.event.keyCode;
            else if (e) keycode = e.which;
            else return true;
            if ((keycode == 8) || (keycode == 0)) {
                return true;
            }
            val = ctrl.value;
            dot_index = val.indexOf('.');
            if (dot_index != -1) {
                dec_pts = (val.length - dot_index);
                if (!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
            }
            if (document.selection) {
                var selection = document.selection.createRange();
                var selected_text = selection.text;
            }
            else if (document.getSelection) {
                var start = ctrl.selectionStart;
                var end = ctrl.selectionEnd;
                var selected_text = ctrl.value.substring(start, end);
            }
            if ((val.length == 0 || selected_text != "") && (keycode == 46))	// || keycode==48
            {
                return false;
            }
            else if (dot_index != -1 && keycode == 46) {
                return false;
            }
            else if (!(keycode >= 48 && keycode <= 57) && (keycode != 13) && (keycode != 46) && (keycode = 36) && (keycode != 8) && (keycode != 0)) {
                return false;
            }
            else return true;
        }
    </script>

    <script type="text/javascript" language="javascript">
        var MaxLength = "Maximum length is ";
        function MaxLengthh(maxLength) {
            MaxLength = maxLength;
        }
    </script>
    <div>
        <asp:HiddenField ID="Hidden1" runat="server" />
        <asp:HiddenField ID="Hidden2" runat="server" />
        <div class="content-header">
            <h1 style="background-image: url('../dist/img/Terminal.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 class="content">
            <div class="inr-ftr">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="pull-right">
                            <h6>
                                <span><span style="color: Red">|</span><span style="padding-left: 10px; padding-right: 10px"><asp:Label
                                    ID="lbl_IndicatesMandatoryFields" runat="server"></asp:Label>
                                    (5 No.)</span>
                            </h6>
                        </div>
                    </div>
                    <div class="clearfix">
                    </div>
                </div>
            </div>
            <div class="emp-filter">
                <div class="form-horizontal">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="row form-group">
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_ProjectId" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox onpaste="return true" ID="txtProjectId" runat="server" CssClass="form-control man-dat"
                                        MaxLength="15" onkeyup="return chkMaxLen(event,this,15,MaxLength);" ValidationGroup="Project"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtProjectId" ValidationGroup="Project"
                                        ErrorMessage="Please Enter Project Code" SetFocusOnError="true" Display="None">*</asp:RequiredFieldValidator>
                                </div>
                                <div class="col-md-1">
                                </div>
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_ProjectName" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox onpaste="return true" ID="txtProjectName" runat="server" CssClass="form-control man-dat"
                                        MaxLength="50" onkeyup="return chkMaxLen(event,this,50,MaxLength);" ValidationGroup="Project"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtProjectName"
                                        ErrorMessage="Please Enter Project Name" SetFocusOnError="true" Display="None" ValidationGroup="Project">*</asp:RequiredFieldValidator>
                                </div>
                            </div>
                            <div class="row form-group">
                            </div>
                            <div class="row form-group">
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_ProjectStartdate" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox onpaste="return true" ID="txtProjectStartDate" runat="server" CssClass="form-control"
                                        MaxLength="11" oncut="return false;" ValidationGroup="Project"></asp:TextBox>
                                </div>
                                <div class="col-md-1"></div>
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_ProjectEndDate" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox onpaste="return true" ID="txtProjectEndDate" runat="server" CssClass="form-control"
                                        MaxLength="11" oncut="return false;" ValidationGroup="Project"></asp:TextBox>
                                </div>
                            </div>

                            <div class="row form-group">
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_ClientName" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox onpaste="return true" ID="txtClientName" runat="server" CssClass="form-control"
                                        MaxLength="100" oncut="return false;" onkeyup="return chkMaxLen(event,this,100,MaxLength);"></asp:TextBox>
                                </div>
                                <div class="col-md-1">
                                </div>
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_ProjectDescription" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox ID="txtProjectDescription" CssClass="form-control"
                                        TextMode="MultiLine" Style="resize: none;" runat="server" onkeypress="return chkMaxLen(event,this,500,MaxLength);"
                                        MaxLength="500"></asp:TextBox>
                                </div>
                            </div>
                            <div class="row form-group">
                                <div class="col-md-2">
                                    <asp:Label ID="lblManDays" runat="server" Text="Man Days"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox onpaste="return true" ID="txtMandays" runat="server" CssClass="form-control"
                                        MaxLength="10" oncut="return false;" onkeypress="return number_only(event,this)" ValidationGroup="Project"></asp:TextBox>
                                </div>
                                <div class="col-md-1">
                                </div>
                                <div class="col-md-2">
                                    <asp:Label ID="lblManHours" runat="server" Text="Man Hours"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:TextBox ID="txtManHours" CssClass="form-control" runat="server" onkeypress="return number_only(event,this)"
                                        MaxLength="10" ValidationGroup="Project"></asp:TextBox>
                                </div>
                            </div>
                            <div class="row form-group">
                                <div class="col-md-2">
                                    <asp:Label ID="lbl_Status" runat="server"></asp:Label>
                                </div>
                                <div class="col-md-3">
                                    <asp:DropDownList ID="ddlProjectStatus" runat="server" AppendDataBoundItems="true"
                                        CssClass="form-control select2">
                                        <asp:ListItem Selected="True" Text="Yet to Start" Value="Yet to Start"></asp:ListItem>
                                        <asp:ListItem Text="In Progress" Value="In Progress"></asp:ListItem>
                                        <asp:ListItem Text="Completed" Value="Completed"></asp:ListItem>
                                        <asp:ListItem Text="Rejected" Value="Rejected"></asp:ListItem>
                                    </asp:DropDownList>
                                </div>
                            </div>
                            <div class="row form-group" runat="server" id="divAddOrganization">
                                <div class="col-md-12">
                                    <asp:UpdatePanel ID="upOrgLevel" runat="server" UpdateMode="Conditional">
                                        <ContentTemplate>
                                            <asp:PlaceHolder ID="PlaceHolderManualEntry" runat="server">
                                                <UC:OrganizationLevel ID="ucOrganizationLevel" runat="server" />
                                            </asp:PlaceHolder>
                                        </ContentTemplate>
                                    </asp:UpdatePanel>
                                </div>
                            </div>
                            <div class="row form-group" runat="server" id="divModifyOrganization" style="display: none;">
                                <div class="col-md-12">
                                    <UC1:orglevel ID="uc_orglevel" runat="server" />
                                </div>
                            </div>
                            <div class="row form-group">
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                    <ContentTemplate>
                                        <asp:HiddenField ID="hiddenTime" runat="server" Value="%I:%M:%S %p" />
                                        <div class="col-md-12" id="dvScroll" style="overflow: auto; padding-bottom: 20px" onscroll="SetPosition();">
                                            <asp:GridView ID="gvTask" runat="server" Width="96%" AutoGenerateColumns="false" HeaderStyle-Font-Size="14px" RowStyle-Font-Size="14px"
                                                HeaderStyle-Height="50" FooterStyle-Height="50" CssClass="table das-table1"
                                                ShowFooter="true" OnRowCommand="gvTask_RowCommand" OnRowDeleting="gvTask_RowDeleting"
                                                OnRowDataBound="gvTask_RowDataBound" OnRowUpdating="gvTask_RowUpdating" DataKeyNames="TaskID"
                                                OnRowCancelingEdit="gvTask_RowCancelingEdit" OnRowEditing="gvTask_RowEditing">
                                                <Columns>
                                                    <asp:TemplateField Visible="false">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblTaskId" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "TaskID") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>

                                                    <asp:TemplateField HeaderText="Task Name" HeaderStyle-BackColor="#d9f0fb" HeaderStyle-ForeColor="black">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblTaskName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "TaskName") %>' Style="padding: 0px 5px;"></asp:Label>
                                                        </ItemTemplate>
                                                        <EditItemTemplate>
                                                            <asp:TextBox MaxLength="250" onCut="return false" onDrop="return false" ID="txtedit_TaskName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "TaskName") %>' CssClass="form-control"></asp:TextBox>
                                                        </EditItemTemplate>
                                                        <FooterTemplate>
                                                            <asp:TextBox MaxLength="250" onCut="return false" onDrop="return false" ID="txtAdd_TaskName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "TaskName") %>' CssClass="form-control"></asp:TextBox>
                                                        </FooterTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Hours" HeaderStyle-BackColor="#d9f0fb" HeaderStyle-ForeColor="black">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblHours" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Hours") %>' Style="padding: 0px 5px;"></asp:Label>
                                                        </ItemTemplate>
                                                        <EditItemTemplate>
                                                            <asp:TextBox MaxLength="10" onCut="return false" onDrop="return false" ID="txtedit_Hours" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Hours") %>' CssClass="form-control"></asp:TextBox>
                                                        </EditItemTemplate>
                                                        <FooterTemplate>
                                                            <asp:TextBox MaxLength="10" onCut="return false" onDrop="return false" ID="txtAdd_Hours" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Hours") %>' CssClass="form-control"></asp:TextBox>
                                                        </FooterTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Action" HeaderStyle-BackColor="#d9f0fb" HeaderStyle-ForeColor="black" ItemStyle-Width="200px">
                                                        <ItemTemplate>
                                                            &nbsp;&nbsp;<asp:LinkButton ID="imgbtnEdit" runat="server" Font-Size="16px" CommandName="Edit" Text="Edit"></asp:LinkButton>
                                                            &nbsp;&nbsp;<asp:Label ID="lblbackslash" runat="server" Text="/"></asp:Label>
                                                            &nbsp;&nbsp;<asp:LinkButton ID="imgbtnDelete" runat="server" Font-Size="16px" CommandName="Delete" Text="Delete"></asp:LinkButton>
                                                        </ItemTemplate>
                                                        <EditItemTemplate>
                                                            &nbsp;&nbsp;<asp:LinkButton ID="imgbtnUpdate" runat="server" Font-Size="16px" CommandName="Update" Text="&nbsp;&nbsp;Update"></asp:LinkButton>
                                                            <asp:Label ID="lblbackslash1" runat="server" Text="/"></asp:Label>
                                                            <asp:LinkButton ID="imgbtnCancel" runat="server" Font-Size="16px" CommandName="Cancel" Text="&nbsp;&nbsp;Cancel"></asp:LinkButton>
                                                        </EditItemTemplate>
                                                        <FooterTemplate>
                                                            &nbsp;&nbsp;<asp:LinkButton ID="lbtnAdd" runat="server" Font-Size="16px" CommandName="ADD" OnClientClick="return ValidateText(this.id);" Text="&nbsp;&nbsp;Add" Width="200px"></asp:LinkButton>
                                                        </FooterTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                            </asp:GridView>
                                        </div>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6"></div>
                        <div class="col-md-5">
                            <div class="pull-right-button">
                                <asp:ValidationSummary ID="ValidationSummary1" EnableClientScript="true" ShowMessageBox="true"
                                    ShowSummary="false" runat="server" ValidationGroup="Project" />
                                <asp:LinkButton ID="btn_save" CssClass="btn save-btn fa-floppy-o" runat="server" ValidationGroup="Project"
                                    OnClick="btn_save_Click" OnClientClick="if(Page_ClientValidate()) return ProjectValidation();return false;" />
                                <asp:LinkButton ID="btn_cancel" CssClass="btn save-btn fa-angle-left" runat="server"
                                    OnClick="btn_cancel_Click" CausesValidation="False" />
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</asp:Content>
