Exemple #1
0
        public VHR_EmployeeProfile GetDetail(int id)
        {
            //Instantiating the Employee profile view
            VHR_EmployeeProfile vmEmployeeProfile = new VHR_EmployeeProfile();
            //Getting the entry of the specific employee to his details
            VHR_EmployeeProfile employeeObj = VHREmployeeProfileReporsitory.GetSingle(id);

            vmEmployeeProfile.PEmployeeID     = employeeObj.PEmployeeID;
            vmEmployeeProfile.OEmpID          = employeeObj.OEmpID;
            vmEmployeeProfile.EmployeeName    = employeeObj.EmployeeName;
            vmEmployeeProfile.TelephoneNo     = employeeObj.TelephoneNo;
            vmEmployeeProfile.OfficialEmailID = employeeObj.OfficialEmailID;
            vmEmployeeProfile.CrewName        = employeeObj.CrewName;
            vmEmployeeProfile.LineManagerID   = employeeObj.LineManagerID;
            vmEmployeeProfile.FatherName      = employeeObj.CardNo;
            vmEmployeeProfile.DOJ             = employeeObj.ValidDate;
            vmEmployeeProfile.DateOfBirth     = employeeObj.DateOfBirth;
            vmEmployeeProfile.Gender          = employeeObj.Gender;
            vmEmployeeProfile.GradeName       = employeeObj.GradeName;
            vmEmployeeProfile.CNIC            = employeeObj.CNIC;
            vmEmployeeProfile.Address         = employeeObj.Address;
            vmEmployeeProfile.LocationName    = employeeObj.LocationName;
            vmEmployeeProfile.DesignationName = employeeObj.DesignationName;
            vmEmployeeProfile.EmailID         = employeeObj.EmailID;
            return(vmEmployeeProfile);
        }
        public VMOvertimeEncashable GetCreate3(VMOvertimeEncashableSelection es, int?[] SelectedEmployeeIds, VMOvertimeEncashable vmOvertimeApproval)
        {
            List <VMOvertimeEncashableChild> vmOvertimeApprovalChildList = new List <VMOvertimeEncashableChild>();
            List <VHR_EmployeeProfile>       employees = DDService.GetEmployeeInfo();                                          // Get All Employees from database
            PayrollPeriod payrollPeriod = DDService.GetPayrollPeriod().First(aa => aa.PPayrollPeriodID == es.PayrollPeriodID); // Get selected Payroll Period

            foreach (int empid in SelectedEmployeeIds)
            {
                VMOvertimeEncashableChild vmOvertimeApprovalChild = new VMOvertimeEncashableChild();
                VHR_EmployeeProfile       employee = employees.First(aa => aa.PEmployeeID == empid);// Get Specific Employee

                vmOvertimeApprovalChild.EmpID              = employee.PEmployeeID;
                vmOvertimeApprovalChild.EmpNo              = employee.OEmpID;
                vmOvertimeApprovalChild.EmployeeName       = employee.EmployeeName;
                vmOvertimeApprovalChild.OvertimePolicyID   = employee.OTPolicyID;
                vmOvertimeApprovalChild.OvertimePolicyName = employee.OTPolicyName;
                vmOvertimeApprovalChild.ApprovedOT         = 80;
                vmOvertimeApprovalChild.EncashableOT       = 56;
                vmOvertimeApprovalChild.CPLConvertedOT     = 24;
                vmOvertimeApprovalChild.PayrollPeriodID    = payrollPeriod.PPayrollPeriodID;
                vmOvertimeApprovalChild.PayrollPeriodName  = payrollPeriod.PRName;
                vmOvertimeApprovalChildList.Add(vmOvertimeApprovalChild);
            }
            vmOvertimeApproval.PayrollPeriodID         = payrollPeriod.PPayrollPeriodID;
            vmOvertimeApproval.PayrollPeriodName       = payrollPeriod.PRName;
            vmOvertimeApproval.OvertimeEncashableChild = vmOvertimeApprovalChildList;
            return(vmOvertimeApproval);
        }
        public VMOvertimeApproval GetCreate3(VMOvertimeApprovalSelection es, int?[] SelectedEmployeeIds, VMOvertimeApproval vmOvertimeApproval)
        {
            List <MonthData> monthDatas   = new List <MonthData>();
            List <OTPolicy>  dbOTPolicies = DDService.GetOTPolicy();
            List <VMOvertimeApprovalChild> vmOvertimeApprovalChildList = new List <VMOvertimeApprovalChild>();
            List <VHR_EmployeeProfile>     employees = DDService.GetEmployeeInfo();
            PayrollPeriod payrollPeriod = DDService.GetPayrollPeriod().First(aa => aa.PPayrollPeriodID == es.PayrollPeriodID); // Get selected Payroll Period
            Expression <Func <MonthData, bool> > SpecificEntries = c => c.PayrollPeriodID == payrollPeriod.PPayrollPeriodID && (c.EncashbaleSingleOT > 0 || c.EncashbaleDoubleOT > 0 || c.CPLConversionOT > 0);

            monthDatas = MonthDataReporsitory.FindBy(SpecificEntries);
            foreach (int empid in SelectedEmployeeIds)
            {
                if (monthDatas.Where(aa => aa.EmployeeID == empid).Count() > 0)
                {
                    MonthData monthData = new MonthData();
                    monthData = monthDatas.First(aa => aa.EmployeeID == empid);
                    VMOvertimeApprovalChild vmOvertimeApprovalChild = new VMOvertimeApprovalChild();
                    VHR_EmployeeProfile     employee = employees.First(aa => aa.PEmployeeID == empid);// Get Specific Employee
                    vmOvertimeApprovalChild = GetConveretedOTList(vmOvertimeApprovalChild, employee, monthData, payrollPeriod);
                    vmOvertimeApprovalChildList.Add(vmOvertimeApprovalChild);
                }
            }
            vmOvertimeApproval.PayrollPeriodID       = payrollPeriod.PPayrollPeriodID;
            vmOvertimeApproval.PayrollPeriodName     = payrollPeriod.PRName;
            vmOvertimeApproval.OvertimeApprovalChild = vmOvertimeApprovalChildList;
            return(vmOvertimeApproval);
        }
Exemple #4
0
        /// <summary>
        /// Shows the list of all Leave Carry Forward of selected employees.
        /// </summary>
        /// <param name="es"></param>
        /// <param name="SelectedEmployeeIds">Parameter of Selected Employee ids</param>
        /// <param name="vmLeaveCF"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public VMLeaveCF GetCreate3(VMLeaveCFSelection es, int?[] SelectedEmployeeIds, VMLeaveCF vmLeaveCF)
        {
            List <VMLeaveCFChild>      vmLeaveCFChildList = new List <VMLeaveCFChild>();
            List <VHR_EmployeeProfile> employees          = DDService.GetEmployeeInfo();                                       // Get All Employees from database
            FinancialYear financialYear = DDService.GetFinancialYear().First(aa => aa.PFinancialYearID == es.FinancialYearID); // Get selected financial year

            foreach (int empid in SelectedEmployeeIds)
            {
                VMLeaveCFChild      vmLeaveCFChild = new VMLeaveCFChild();
                VHR_EmployeeProfile employee       = employees.First(aa => aa.PEmployeeID == empid);// Get Specific Employee

                vmLeaveCFChild.EmpID             = employee.PEmployeeID;
                vmLeaveCFChild.EmpNo             = employee.OEmpID;
                vmLeaveCFChild.EmployeeName      = employee.EmployeeName;
                vmLeaveCFChild.FinancialYearID   = financialYear.PFinancialYearID;
                vmLeaveCFChild.FinancialYearName = financialYear.FYName;
                vmLeaveCFChild.TotalLeave        = 20;
                vmLeaveCFChild.LeaveTypeName     = "AL";
                vmLeaveCFChild.CarryForward      = 15;
                vmLeaveCFChild.CollapseLeave     = 5;
                vmLeaveCFChildList.Add(vmLeaveCFChild);
            }
            vmLeaveCF.FinancialYearID   = financialYear.PFinancialYearID;
            vmLeaveCF.FinancialYearName = financialYear.FYName;
            vmLeaveCF.LeaveCFChild      = vmLeaveCFChildList;
            return(vmLeaveCF);
        }
        public ActionResult Detail(int?id)
        {
            VMLoggedUser        vmf = Session["LoggedInUser"] as VMLoggedUser;
            VHR_EmployeeProfile vhremployeeprofile = new VHR_EmployeeProfile();
            Expression <Func <VHR_EmployeeProfile, bool> > SpecificEntries = c => c.Status == "Active" && c.PEmployeeID == id;

            return(View(DDService.GetSpecificEmployee(SpecificEntries).First()));
        }
        public string ApproveLeaveApplication(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, string Message)
        {
            //gets the First entry and comment box for the approval of the leave application
            LeaveApplication lvapplication = LeaveApplicationRepository.GetSingle((int)vmESSPCommon.PID);
            //if (DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
            //{
            //Gets Employee Information about the access of the location and company of the employee.
            List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).ToList();
            VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).First();
            //Gets Employee Leave policy on the Type of leave applied
            LeavePolicy lvPolicy = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());

            Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
            List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();

            if (dbPayrollPeriods.Count() > 0)
            {
                Message = "Cannot Approve leaves of Closed Payroll Period";
            }
            if (Message == "")
            {
                //Check the Leave balance if there are some leaves remaining of the employee whose leave is being approved.
                if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
                {
                    //Changes Leave Stage ID to "A" (Approved).
                    lvapplication.LeaveStageID = "A";
                    //Gets the leave Type through generic service.
                    LeaveType lvType = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
                    LeaveApplicationService.BalanceLeaves(lvapplication, lvType, AssistantLeave.GetPayRollPeriodID(DDService.GetPayrollPeriod().ToList(), lvapplication.FromDate));
                    LeaveApplicationRepository.Edit(lvapplication);
                    LeaveApplicationRepository.Save();
                    UnitOfWork.Commit();
                    //Adds leave to leave data frim where its impact is generated on the reports.
                    LeaveApplicationService.AddLeaveToLeaveData(lvapplication, lvType, lvPolicy);
                    //Add Leaves to Att Data where Daily and Monthy Reporcessing of attendance occurs on the day
                    LeaveApplicationService.AddLeaveToAttData(lvapplication, lvType);
                    VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                    VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                    // Add notification to the Employee that leave has been approved.
                    DDService.SaveNotification((int)EmpUser.PUserID, "/ESSP/ESSPLeaveApp/Index",
                                               Convert.ToInt32(NTLeaveEnum.LeaveApproved), true, lvapplication.LineManagerID, lvapplication.PLeaveAppID);
                    //Add entry in the flow table
                    SaveLeaveApplicationFlow((int)EmpUser.PUserID, lvapplication.LineManagerID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, "", vmESSPCommon.Comment);

                    //Save Email in the Notification Email table from where through services email is generated to employee about the approval of the leave Application.
                    Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries3 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                    VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries3).First();
                    DDService.GenerateEmail(EmpUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                            ESSPText.GetApprovedLeaveText(vlvApplication, EmpUser.UserEmployeeName, LMUser.UserEmployeeName, LMUser.DesignationName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeaveApproved));

                    // Disable Notification of the pending Leave.
                    int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                    Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                    DDService.DeleteNotification(SpecificEntries);
                }
            }
            return(Message);
        }
        private float GetTotalDays(List <LeavePolicy> leavePolicies, VHR_EmployeeProfile employee, FinancialYear financialYear)
        {
            if (leavePolicies.Count == 0)
            {
                return(0);
            }
            else
            {
                LeavePolicy leavePolicy = leavePolicies.First();
                if (leavePolicy.ProRata == true)
                {
                    // get months between
                    if (employee.DOJ.Value > financialYear.FYStartDate)
                    {
                        float months = 0;
                        float leaves = 0;

                        // Get month of first Salary
                        if (employee.DOJ.Value.Month == financialYear.FYStartDate.Value.Month)
                        {
                            months = 12;
                        }
                        else
                        {
                            int FirstSalaryMonth = employee.DOJ.Value.Month;
                            if (employee.DOJ.Value.Year == financialYear.FYStartDate.Value.Year)
                            {
                                months = 13 - FirstSalaryMonth + 6;
                            }
                            else
                            {
                                months = 7 - FirstSalaryMonth;
                            }
                        }
                        leaves = (months * leavePolicy.TotalDays.Value) / 12;
                        return((int)(leaves));
                    }
                    else
                    {
                        return((leavePolicy.TotalDays == null) ? 0 : (float)leavePolicy.TotalDays);
                    }
                }
                else
                {
                    return((leavePolicy.TotalDays == null) ? 0 : (float)leavePolicy.TotalDays);
                }
            }
        }
Exemple #8
0
        public void PostCreate3(VMJobCardCreate es, int?[] employeeIds, VMLoggedUser LoggedInUser)
        {
            string Message = "";

            foreach (var empid in employeeIds)
            {
                VHR_EmployeeProfile employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == empid).First();
                Expression <Func <Shift, bool> > SpecificEntries97 = c => c.PShiftID == employee.ShiftID;
                Shift shifts = ShiftService.GetIndexSpecific(SpecificEntries97).First();
                if (shifts.GZDays == true)
                {
                    List <Holiday> holiday = DDService.GetHolidays().Where(aa => aa.HolidayDate == es.JobDateFrom).ToList();
                    if (holiday.Count > 0)
                    {
                        Message = "Cannot apply job card of the Gazetted Holiday";
                    }
                }
                Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => es.JobDateFrom >= c.PRStartDate && es.JobDateFrom <= c.PREndDate && c.PeriodStageID == "C";
                List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();
                if (dbPayrollPeriods.Count() > 0)
                {
                    Message = "Cannot enter Job card in Closed Payroll Period";
                }
                if (Message == "")
                {
                    JobCardApp jcApp = new JobCardApp();
                    jcApp.DateCreated   = DateTime.Now;
                    jcApp.DateEnded     = es.JobDateTo;
                    jcApp.DateStarted   = es.JobDateFrom;
                    jcApp.EmployeeID    = empid;
                    jcApp.Minutes       = es.TotalMinutes;
                    jcApp.Remarks       = es.Remarks;
                    jcApp.JobCardTypeID = es.JobCardTypeID;
                    jcApp.UserID        = LoggedInUser.PUserID;
                    JobCardAppRepository.Add(jcApp);
                    JobCardAppRepository.Save();
                    DDService.ProcessDailyAttendance(jcApp.DateStarted, jcApp.DateEnded, (int)jcApp.EmployeeID, jcApp.EmployeeID.ToString());
                    DDService.ProcessMonthlyAttendance(jcApp.DateStarted, (int)jcApp.EmployeeID, jcApp.EmployeeID.ToString());
                }
                else
                {
                }
            }
        }
        public VMLeaveQuota GetCreate3(VMLeaveQuotaSelection es, int?[] SelectedEmployeeIds, VMLeaveQuota vmLeaveQuota)
        {
            List <VMLeaveQuotaChild>   vmLeaveQuotaChildList = new List <VMLeaveQuotaChild>();
            List <VHR_EmployeeProfile> employees             = DDService.GetEmployeeInfo();                                                         // Get All Employees from database
            List <LeavePolicy>         leavePolicyList       = DDService.GetLeavePolicy();                                                          // Get all leave policies
            FinancialYear         financialYear              = DDService.GetFinancialYear().First(aa => aa.PFinancialYearID == es.FinancialYearID); // Get selected financial year
            List <FinancialYear>  financialYearCloseList     = DDService.GetFinancialYear().Where(aa => aa.FYStatus == false).OrderByDescending(aa => aa.FYEndDate).ToList();
            List <LeaveQuotaYear> leaveQuotaPreviousYearList = new List <LeaveQuotaYear>();

            // Get Old Financial Year
            if (financialYearCloseList.Count > 0)
            {
                int LastFinYearID = financialYearCloseList.FirstOrDefault().PFinancialYearID;
                Expression <Func <LeaveQuotaYear, bool> > SpecificEntries = c => c.FinancialYearID == LastFinYearID && c.LeaveTypeID == 1;
                leaveQuotaPreviousYearList = LeaveQuotaYearReporsitory.FindBy(SpecificEntries);// Get all Leave quota Balances for specific financial year
            }
            Expression <Func <LeaveQuotaYear, bool> > SpecificEntries2 = c => c.FinancialYearID == es.FinancialYearID;
            List <LeaveQuotaYear> leaveQuotaYearList = LeaveQuotaYearReporsitory.FindBy(SpecificEntries2);// Get all Leave quota Balances for specific financial year

            foreach (int empid in SelectedEmployeeIds)
            {
                if (leaveQuotaYearList.Where(aa => aa.EmployeeID == empid).Count() == 0)
                {
                    VMLeaveQuotaChild   vmLeaveQuotaChild = new VMLeaveQuotaChild();
                    VHR_EmployeeProfile employee          = employees.First(aa => aa.PEmployeeID == empid);// Get Specific Employee
                    float ALDays   = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.ALPolicyID).ToList(), employee, financialYear);
                    float CLDays   = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.CLPolicyID).ToList(), employee, financialYear);
                    float SLDays   = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.SLPolicyID).ToList(), employee, financialYear);
                    float STDLDays = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.STDLPolicyID).ToList(), employee, financialYear);
                    vmLeaveQuotaChild.EmpID             = employee.PEmployeeID;
                    vmLeaveQuotaChild.EmpNo             = employee.OEmpID;
                    vmLeaveQuotaChild.EmployeeName      = employee.EmployeeName;
                    vmLeaveQuotaChild.JobTitleName      = employee.JobTitleName;
                    vmLeaveQuotaChild.FinancialYearID   = financialYear.PFinancialYearID;
                    vmLeaveQuotaChild.FinancialYearName = financialYear.FYName;
                    if (employee.DOJ != null)
                    {
                        vmLeaveQuotaChild.DOJ = employee.DOJ.Value.ToString("dd-MMM-yyyy");
                    }
                    vmLeaveQuotaChild.AL   = ALDays;
                    vmLeaveQuotaChild.CL   = CLDays;
                    vmLeaveQuotaChild.SL   = SLDays;
                    vmLeaveQuotaChild.STDL = STDLDays;
                    // Get LeaveBalance for Previous Year
                    if (leaveQuotaPreviousYearList.Where(aa => aa.EmployeeID == employee.PEmployeeID).Count() > 0)
                    {
                        vmLeaveQuotaChild.CollapseLeave = 0;
                        vmLeaveQuotaChild.ALBalance     = GetALLeaveBalance(leaveQuotaPreviousYearList.Where(aa => aa.EmployeeID == employee.PEmployeeID).ToList());
                        vmLeaveQuotaChild.CarryForward  = vmLeaveQuotaChild.ALBalance - vmLeaveQuotaChild.CollapseLeave;
                    }
                    else
                    {
                        vmLeaveQuotaChild.CarryForward  = 0;
                        vmLeaveQuotaChild.CollapseLeave = 0;
                        vmLeaveQuotaChild.ALBalance     = 0;
                    }
                    vmLeaveQuotaChildList.Add(vmLeaveQuotaChild);
                }
            }
            vmLeaveQuota.FinancialYearID   = financialYear.PFinancialYearID;
            vmLeaveQuota.FinancialYearName = financialYear.FYName;
            vmLeaveQuota.LeaveQuotaChild   = vmLeaveQuotaChildList;
            return(vmLeaveQuota);
        }
Exemple #10
0
 public ActionResult SingleDay(JobCardApp obj)
 {
     {
         VMLoggedUser LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;
         string       _EmpNo       = Request.Form["EmpNo"].ToString();
         Expression <Func <Employee, bool> > SpecificEntries = c => c.OEmpID == _EmpNo;
         List <VHR_EmployeeProfile>          _emp            = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).ToList();
         VHR_EmployeeProfile employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).First();
         if (_emp.Count == 0)
         {
             ModelState.AddModelError("StartDate", "Emp No not exist");
         }
         else
         {
             obj.EmployeeID = _emp.First().PEmployeeID;
         }
         if (obj.DateStarted == null)
         {
             ModelState.AddModelError("DateStarted", "Date start cannot be empty");
         }
         if (obj.TimeStart == null || obj.TimeEnd == null)
         {
             ModelState.AddModelError("TimeStart", "Time Start and Time End cannot be empty");
         }
         if (obj.Remarks == null || obj.Remarks == "")
         {
             ModelState.AddModelError("Remarks", "Reason is Mandatory !");
         }
         if (obj.TimeEnd <= obj.TimeStart)
         {
             ModelState.AddModelError("TimeEnd", "Time end cannot be less than or equal to start time .");
         }
         Expression <Func <VEP_JobCardApplication, bool> > SpecificEntries2 = aa => obj.DateStarted == aa.DateStarted && obj.TimeStart <= aa.TimeEnd && aa.TimeStart <= obj.TimeEnd && aa.EmployeeID == obj.EmployeeID && aa.JobCardStageID != "R";
         if (VEPJobCardApplicationService.GetIndexSpecific(SpecificEntries2).Count() > 0)
         {
             ModelState.AddModelError("TimeStart", "Already exists between the time span");
         }
         Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries4 = aa => aa.EmpID == obj.EmployeeID && obj.DateStarted <= aa.ToDate && aa.FromDate <= obj.DateEnded && aa.IsHalf != true;
         if (VATLeaveApplicationService.GetIndexSpecific(SpecificEntries4).Count() > 0)
         {
             ModelState.AddModelError("DateStarted", "Leave already applied for one or more days");
         }
         Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => obj.DateStarted >= c.PRStartDate && obj.DateStarted <= c.PREndDate && c.PeriodStageID == "C";
         List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();
         if (dbPayrollPeriods.Count() > 0)
         {
             ModelState.AddModelError("DateStarted", "Cannot enter Job card in Closed Payroll Period");
         }
         Expression <Func <Shift, bool> > SpecificEntries97 = c => c.PShiftID == employee.ShiftID;
         Shift shifts = ShiftService.GetIndexSpecific(SpecificEntries97).First();
         if (shifts.GZDays == true)
         {
             List <Holiday> holiday = DDService.GetHolidays().Where(aa => aa.HolidayDate == obj.DateStarted).ToList();
             if (holiday.Count > 0)
             {
                 ModelState.AddModelError("DateStarted", "Cannot apply job card of the Gazetted Holiday");
             }
         }
         if (ModelState.IsValid)
         {
             JobCardESSPService.SingleDayPostCreate(obj, LoggedInUser);
             ToasterMessages.Add("Job card applied successfully !");
             Session["ToasterMessages"] = ToasterMessages;
             return(Json("OK", JsonRequestBehavior.AllowGet));
         }
         SingleDayJobCardHelper(obj);
         return(PartialView("SingleDay", obj));
     }
 }
        public string RecommendLeaveApplication(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, string Message)
        {
            //gets the First entry and comment box for the approval of the leave application
            LeaveApplication lvapplication = LeaveApplicationRepository.GetSingle((int)vmESSPCommon.PID);
            //if (DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
            //{
            //Gets Employee Information about the access of the location and company of the employee.
            List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).ToList();
            VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).First();
            //Gets Employee Leave policy on the Type of leave applied
            LeavePolicy lvPolicy = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());

            Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
            List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();

            if (dbPayrollPeriods.Count() > 0)
            {
                Message = "Cannot Approve leaves of Closed Payroll Period";
            }
            if (Message == "")
            {
                if (employee.HasOneStep == false)
                {
                    if (LoggedInUser.LineManagerID == null && (lvapplication.LeaveStageID == "P" || lvapplication.LeaveStageID == "D"))
                    {
                        ApprovalCode(vmESSPCommon, LoggedInUser, lvapplication, lvPolicy);
                    }
                    else if (LoggedInUser.LineManagerID != null && (lvapplication.LeaveStageID == "P"))
                    {
                        //gets the information of leave and saving entries from logged in user to leaveApplication.

                        int _userID = (int)LoggedInUser.PUserID;
                        lvapplication.LineManagerID     = (int)LoggedInUser.LineManagerID;
                        lvapplication.SubmittedByUserID = LoggedInUser.PUserID;
                        lvapplication.LeaveStageID      = "D";
                        LeaveApplicationRepository.Edit(lvapplication);
                        LeaveApplicationRepository.Save();
                        // Add notification to Line manager's end that he has a pending leave Request.
                        DDService.SaveNotification(lvapplication.LineManagerID, "/ESSP/ESSPLeaveApp/PendingLeaveApplicationIndex",
                                                   Convert.ToInt32(NTLeaveEnum.LeaveRecommend), true, lvapplication.EmpID, lvapplication.PLeaveAppID);
                        SaveLeaveApplicationFlow(lvapplication.LineManagerID, _userID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, lvapplication.LeaveReason, "");
                        // Save entry in Notification Email table for where the email is generated through service.
                        VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                        VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                        Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries2 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                        VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries2).First();
                        DDService.GenerateEmail(LMUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                                ESSPText.GetPendingLeaveText(vlvApplication, LMUser.UserEmployeeName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeavePending));

                        // Disable Notification of the pending Leave.
                        int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                        Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                        DDService.DeleteNotification(SpecificEntries);
                    }
                    else if (LoggedInUser.LineManagerID != null && (lvapplication.LeaveStageID == "D"))
                    {
                        ApprovalCode(vmESSPCommon, LoggedInUser, lvapplication, lvPolicy);
                    }
                }
                else
                {
                    if (lvapplication.LeaveStageID == "P")
                    {
                        ApprovalCode(vmESSPCommon, LoggedInUser, lvapplication, lvPolicy);
                    }
                }
            }
            return(Message);
        }
        public ActionResult Create(LeaveApplication lvapplication)
        {
            VMLoggedUser LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;

            if (lvapplication.FromDate.Date > lvapplication.ToDate.Date)
            {
                ModelState.AddModelError("FromDate", "From Date should be smaller than To Date");
            }


            FinancialYear dbFinancialYear = DDService.GetFinancialYear().Where(aa => aa.PFinancialYearID == lvapplication.FinancialYearID).First();

            if (lvapplication.ToDate > dbFinancialYear.FYEndDate || lvapplication.ToDate < dbFinancialYear.FYStartDate)
            {
                ModelState.AddModelError("FromDate", "To Date must lie in selected financial year");
            }
            Expression <Func <PayrollPeriod, bool> > SpecificEntries3 = c => c.PeriodStageID == "O";
            PayrollPeriod dbpayrollperiod = PayrollPeriodService.GetIndexSpecific(SpecificEntries3).First();

            if (lvapplication.FromDate < dbpayrollperiod.PRStartDate)
            {
                ModelState.AddModelError("FromDate", "Cannot Create leaves in the Closed Payroll Period");
            }

            string _EmpNo = Request.Form["EmpNo"].ToString();
            List <VHR_EmployeeProfile> _emp = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).ToList();
            Expression <Func <VHR_EmployeeProfile, bool> > SpecificEntries121 = c => c.OEmpID == _EmpNo;
            VHR_EmployeeProfile employee = VHR_EmployeeProfile.GetIndexSpecific(SpecificEntries121).First();

            lvapplication.EmpID = employee.PEmployeeID;


            var RBValue = Request.Form["HalfLvHA"];

            if (RBValue == "false")
            {
                lvapplication.IsHalf = false;
            }
            else
            {
                lvapplication.IsHalf = true;
            }
            LeavePolicy lvPolicy = new LeavePolicy();
            LeaveType   lvType   = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);

            if (_emp.Count == 0)
            {
                ModelState.AddModelError("EmpID", "Invalid Department Access or Employee Resigned.");
            }

            else
            {
                if (_emp.First().Status == "Resigned")
                {
                    if (_emp.First().ResignDate <= lvapplication.ToDate)
                    {
                        ModelState.AddModelError("ToDate", "Cannot Apply leaves of Resigned Employee.");
                    }
                }
                lvapplication.EmpID = employee.PEmployeeID;
                lvPolicy            = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());
                //lvType = db.Att_LeaveType.First(aa => aa.LvTypeID == lvapplication.LeaveTypeID);
                Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries = aa => aa.EmpID == lvapplication.EmpID && lvapplication.FromDate >= aa.FromDate && lvapplication.FromDate <= aa.ToDate && lvapplication.ToDate > aa.FromDate;
                if (VATLeaveApplicationService.GetIndexSpecific(SpecificEntries).Count() > 0)
                {
                    ModelState.AddModelError("FromDate", "Duplicate leave applied for one or more days");
                }
            }

            if (lvapplication.IsHalf == false && lvapplication.IsDeducted == false)
            {
                List <DailyAttendance> att = new List <DailyAttendance>();
                Expression <Func <DailyAttendance, bool> > SpecificEntries2 = aa => aa.EmpID == lvapplication.EmpID && aa.AttDate >= lvapplication.FromDate && aa.AttDate <= lvapplication.ToDate;
                att = DailyAttendanceService.GetIndexSpecific(SpecificEntries2);
                if (att.Count > 0)
                {
                    foreach (var at in att)
                    {
                        if (at.TimeIn != null || at.TimeOut != null)
                        {
                            ModelState.AddModelError("LeaveTypeID", "This employee has attendance for Specific day, Please clear his attendance first to proceed further");
                        }
                    }
                }
            }
            // CL cannot be taken after next to AL consective day
            if (lvapplication.LeaveTypeID == 2)
            {
                if (LeaveApplicationService.CheckForALConsectiveDay(lvapplication))
                {
                    ModelState.AddModelError("FromDate", "You have applied AL leave for previous date");
                }
            }

            float noofDays = LeaveApplicationService.CalculateNoOfDays(lvapplication, lvType, lvPolicy);

            if (lvapplication.LeaveTypeID == 11)
            {
                if (noofDays < lvPolicy.MinimumDays)
                {
                    ModelState.AddModelError("LeaveTypeID", "Cannot Apply Academic for Less than" + lvPolicy.MinimumDays.ToString() + " days");
                }
            }
            {
                if (noofDays < lvPolicy.MinimumDays)
                {
                    ModelState.AddModelError("LeaveTypeID", "Cannot Apply CME/Workshop for Less than" + lvPolicy.MinimumDays.ToString() + " days");
                }
            }
            if (lvapplication.IsHalf != true)
            {
                Expression <Func <VAT_JobCardApplication, bool> > SpecificEntries1 = aa => aa.OEmpID == _EmpNo && aa.DateStarted == lvapplication.FromDate && aa.DateStarted <= lvapplication.ToDate && aa.DateEnded > lvapplication.FromDate;
                if (JobcardAppService.GetIndexSpecific(SpecificEntries1).Count() > 0)
                {
                    ModelState.AddModelError("FromDate", "Job card exist for same date");
                }
            }
            Expression <Func <Shift, bool> > SpecificEntries97 = c => c.PShiftID == employee.ShiftID;
            Shift shifts = ShiftService.GetIndexSpecific(SpecificEntries97).First();

            if (shifts.GZDays == true)
            {
                List <Holiday> holiday = DDService.GetHolidays().Where(aa => aa.HolidayDate == lvapplication.FromDate).ToList();
                if (holiday.Count > 0)
                {
                    ModelState.AddModelError("FromDate", "Cannot apply leave of the Gazetted Holiday");
                }
            }
            Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
            List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();

            if (dbPayrollPeriods.Count() > 0)
            {
                ModelState.AddModelError("FromDate", "Cannot enter leaves in Closed Payroll Period");
            }
            //if (!DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
            //    ModelState.AddModelError("FromDate", "Payroll Period is Closed for this date");
            if (ModelState.IsValid)
            {
                if (LeaveApplicationService.CheckDuplicateLeave(lvapplication))
                {
                    // max days

                    float CalenderDays = LeaveApplicationService.CalculateCalenderDays(lvapplication, lvType, lvPolicy);
                    lvapplication.ReturnDate   = LeaveApplicationService.GetReturnDate(lvapplication, lvType, lvPolicy);
                    lvapplication.NoOfDays     = noofDays;
                    lvapplication.CalenderDays = CalenderDays;
                    int _UserID = LoggedInUser.PUserID;
                    lvapplication.CreatedBy = _UserID;
                    if (lvPolicy.PLeavePolicyID == 0)
                    {
                        LeaveApplicationService.CreateLeave(lvapplication, lvType, LoggedInUser, lvPolicy);
                        return(Json("OK", JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        //check for employee eligible for leave
                        if (AssistantLeave.EmployeeEligbleForLeave(lvPolicy, _emp))
                        {
                            if (lvPolicy.UpdateBalance == true)
                            {
                                if (LeaveApplicationService.HasLeaveQuota(lvapplication.EmpID, lvPolicy, (int)lvapplication.FinancialYearID))
                                {
                                    if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
                                    {
                                        //if (LeaveApplicationService.CheckForMaxMonthDays(lvapplication, lvPolicy, LvProcessController.GetFinancialYearID(db.PR_FinancialYear.ToList(), lvapplication.FromDate)))
                                        {
                                            LeaveApplicationService.CreateLeave(lvapplication, lvType, LoggedInUser, lvPolicy);
                                            return(Json("OK", JsonRequestBehavior.AllowGet));
                                        }
                                        //else
                                        //    ModelState.AddModelError("FromDate", "Leave Monthly Quota Exceeds");
                                    }
                                    else
                                    {
                                        ModelState.AddModelError("LeaveTypeID", "Leave Balance Exceeds!!!");
                                    }
                                }
                                else
                                {
                                    ModelState.AddModelError("LeaveTypeID", "Leave Quota does not exist");
                                }
                            }
                            else
                            {
                                LeaveApplicationService.CreateLeave(lvapplication, lvType, LoggedInUser, lvPolicy);
                                return(Json("OK", JsonRequestBehavior.AllowGet));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("LeaveTypeID", "Employee is not eligible for leave");
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("FromDate", "This Employee already has leave in this range of dates");
                }
            }
            HelperMethod(lvapplication);
            return(PartialView("Create", lvapplication));
        }
Exemple #13
0
        public ActionResult Create(LeaveApplication lvapplication)
        {
            VMLoggedUser LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;

            if (lvapplication.LeaveAddress == "" || lvapplication.LeaveAddress == null)
            {
                ModelState.AddModelError("LeaveAddress", "Contact number is mandatory !");
            }
            if (lvapplication.LeaveAddress != null)
            {
                Match match = Regex.Match(lvapplication.LeaveAddress, @"^-*[0-9,\-]+$");
                if (!match.Success)
                {
                    ModelState.AddModelError("LeaveAddress", "Enter a valid Contact No");
                }
            }

            if (lvapplication.FromDate.Date > lvapplication.ToDate.Date)
            {
                ModelState.AddModelError("FromDate", "From Date should be smaller than To Date");
            }
            FinancialYear dbFinancialYear = DDService.GetFinancialYear().Where(aa => aa.PFinancialYearID == lvapplication.FinancialYearID).First();

            if (lvapplication.ToDate >= dbFinancialYear.FYEndDate || lvapplication.ToDate <= dbFinancialYear.FYStartDate)
            {
                ModelState.AddModelError("FromDate", "To Date must lie in selected financial year");
            }
            if (lvapplication.ToDate > AppAssistant.MaxDate)
            {
                ModelState.AddModelError("ToDate", "Date cannot be greater than " + AppAssistant.MaxDate.ToString("dd-MM-yyyy"));
            }
            if (lvapplication.FromDate < AppAssistant.MinDate)
            {
                ModelState.AddModelError("FromDate", "Date cannot be less than " + AppAssistant.MinDate.ToString("dd-MM-yyyy"));
            }

            string _EmpNo = Request.Form["EmpNo"].ToString();
            List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).ToList();
            VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).First();
            var RBValue = Request.Form["HalfLvHA"];

            if (_emp.First().LineManagerID == null)
            {
                ModelState.AddModelError("EmpID", "There is no Line Manager associated with your profile. Please contact HR");
            }
            {
                LeavePolicy lvPolicy = new LeavePolicy();
                LeaveType   lvType   = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
                if (_emp.Count == 0)
                {
                    ModelState.AddModelError("FromDate", "Emp No not exist");
                }
                else
                {
                    lvapplication.EmpID = _emp.FirstOrDefault().PEmployeeID;
                    lvPolicy            = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());
                    //lvType = db.Att_LeaveType.First(aa => aa.LvTypeID == lvapplication.LeaveTypeID);
                }
                if (lvapplication.IsHalf == false && lvapplication.IsDeducted == false)
                {
                    List <DailyAttendance> att = new List <DailyAttendance>();
                    Expression <Func <DailyAttendance, bool> > SpecificEntries = aa => aa.EmpID == lvapplication.EmpID && aa.AttDate >= lvapplication.FromDate && aa.AttDate <= lvapplication.ToDate;
                    att = DailyAttendanceService.GetIndexSpecific(SpecificEntries);
                    if (att.Count > 0)
                    {
                        foreach (var at in att)
                        {
                            if (at.TimeIn != null || at.TimeOut != null)
                            {
                                ModelState.AddModelError("LeaveTypeID", "This employee has attendance for Specific day, Please clear his attendance first to proceed further");
                            }
                        }
                    }
                }
                // CL cannot be taken after next to AL consective day
                float noofDays = LeaveApplicationService.CalculateNoOfDays(lvapplication, lvType, lvPolicy);
                if (lvapplication.LeaveTypeID == 2)
                {
                    if (LeaveApplicationService.CheckForALConsectiveDay(lvapplication))
                    {
                        ModelState.AddModelError("FromDate", "You have applied AL leave for previous date");
                    }
                }
                // Check for Minimum Days of Attachment of Sick Leave
                if (lvapplication.LeaveTypeID == 3)
                {
                    if (noofDays < lvPolicy.MinimumDays)
                    {
                        ModelState.AddModelError("LeaveTypeID", "Cannot Apply SL for Less than" + lvPolicy.MinimumDays.ToString() + " days");
                    }
                }
                //if (LeaveForHoliday(lvapplication))
                //{
                //    ModelState.AddModelError("LeaveTypeID", "This employee has Rest Or GZ for specific Day");
                //}
                //if (!CheckForLvTypeHasLvPolicyForEmp(_emp, lvType))
                //{
                //    ModelState.AddModelError("LeaveTypeID", "This employee does not have Leave Policy, Please add Leave Policy first");
                //}
                //if (!DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
                //    ModelState.AddModelError("FromDate", "Payroll Period is Closed for this date");
                Expression <Func <Shift, bool> > SpecificEntries97 = c => c.PShiftID == employee.ShiftID;
                Shift shifts = ShiftService.GetIndexSpecific(SpecificEntries97).First();
                if (shifts.GZDays == true)
                {
                    List <Holiday> holiday = DDService.GetHolidays().Where(aa => aa.HolidayDate == lvapplication.FromDate).ToList();
                    if (holiday.Count > 0)
                    {
                        ModelState.AddModelError("FromDate", "Cannot apply leave of the Gazetted Holiday");
                    }
                }
                Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
                List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();
                if (dbPayrollPeriods.Count() > 0)
                {
                    ModelState.AddModelError("FromDate", "Cannot enter leaves in Closed Payroll Period");
                }
                if (ModelState.IsValid)
                {
                    if (LeaveApplicationService.CheckDuplicateLeave(lvapplication))
                    {
                        // max days

                        float CalenderDays = LeaveApplicationService.CalculateCalenderDays(lvapplication, lvType, lvPolicy);
                        lvapplication.ReturnDate   = LeaveApplicationService.GetReturnDate(lvapplication, lvType, lvPolicy);
                        lvapplication.IsDeducted   = false;
                        lvapplication.NoOfDays     = noofDays;
                        lvapplication.CalenderDays = CalenderDays;
                        int _UserID = LoggedInUser.PUserID;
                        lvapplication.CreatedBy = _UserID;
                        if (lvPolicy.PLeavePolicyID == 0)
                        {
                            ESSPLeaveService.CreateLeave(lvapplication, lvType, LoggedInUser);
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            //check for employee eligible for leave
                            if (AssistantLeave.EmployeeEligbleForLeave(lvPolicy, _emp))
                            {
                                if (lvPolicy.UpdateBalance == true)
                                {
                                    if (LeaveApplicationService.HasLeaveQuota(lvapplication.EmpID, lvPolicy, (int)lvapplication.FinancialYearID))
                                    {
                                        if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
                                        {
                                            //if (LeaveApplicationService.CheckForMaxMonthDays(lvapplication, lvPolicy, LvProcessController.GetFinancialYearID(db.PR_FinancialYear.ToList(), lvapplication.FromDate)))
                                            {
                                                lvapplication.LineManagerID = (int)_emp.First().LineManagerID;
                                                ESSPLeaveService.CreateLeave(lvapplication, lvType, LoggedInUser);
                                                ToasterMessages.Add("Leave applied successfully.");
                                                Session["ToasterMessages"] = ToasterMessages;
                                                return(Json(lvapplication.PLeaveAppID, JsonRequestBehavior.AllowGet));
                                            }
                                            //else
                                            //    ModelState.AddModelError("FromDate", "Leave Monthly Quota Exceeds");
                                        }
                                        else
                                        {
                                            ModelState.AddModelError("LeaveTypeID", "Leave Balance Exceeds, Please check the balance");
                                        }
                                    }
                                    else
                                    {
                                        ModelState.AddModelError("LeaveTypeID", "Leave Quota does not exist");
                                    }
                                }
                                else
                                {
                                }
                            }
                            else
                            {
                                ModelState.AddModelError("LeaveTypeID", "Employee is not eligible for leave");
                            }
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("FromDate", "This Employee already has leave in this range of dates");
                    }
                }
                HelperMethod(lvapplication);
                return(PartialView("Create", lvapplication));
            }
        }
 public VMOvertimeApprovalChild GetConveretedOTList(VMOvertimeApprovalChild vmOvertimeApprovalChild, VHR_EmployeeProfile employee, MonthData monthData, PayrollPeriod payrollPeriod)
 {
     vmOvertimeApprovalChild.EmpID              = employee.PEmployeeID;
     vmOvertimeApprovalChild.EmpNo              = employee.OEmpID;
     vmOvertimeApprovalChild.EmployeeName       = employee.EmployeeName;
     vmOvertimeApprovalChild.OvertimePolicyID   = employee.OTPolicyID;
     vmOvertimeApprovalChild.OvertimePolicyName = employee.OTPolicyName;
     vmOvertimeApprovalChild.EncashableSingleOT = ATAssistant.GetTimeHours(monthData.EncashbaleSingleOT);
     vmOvertimeApprovalChild.EncashableDoubleOT = ATAssistant.GetTimeHours(monthData.EncashbaleDoubleOT);
     vmOvertimeApprovalChild.CPLConvertedOT     = ATAssistant.GetTimeHours(monthData.CPLConversionOT);
     vmOvertimeApprovalChild.NormalOT           = ATAssistant.GetTimeHours(monthData.TNOT);
     vmOvertimeApprovalChild.RestOT             = ATAssistant.GetTimeHours(monthData.TROT);
     vmOvertimeApprovalChild.GZOT = ATAssistant.GetTimeHours(monthData.TGZOT);
     vmOvertimeApprovalChild.CPLConvertedOTDays = monthData.CPLConvertedDays;
     vmOvertimeApprovalChild.PayrollPeriodID    = payrollPeriod.PPayrollPeriodID;
     vmOvertimeApprovalChild.PayrollPeriodName  = payrollPeriod.PRName;
     vmOvertimeApprovalChild.StatusID           = monthData.MonthDataStageID;
     return(vmOvertimeApprovalChild);
 }
        public ActionResult MultipleDay(JobCardApp obj)
        {
            {
                try
                {
                    VMLoggedUser LoggedInUser           = Session["LoggedInUser"] as VMLoggedUser;
                    string       _EmpNo                 = Request.Form["EmpNo"].ToString();
                    List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).ToList();
                    VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).First();
                    if (_emp.Count == 0)
                    {
                        ModelState.AddModelError("EmployeeID", "Invalid Employee Location");
                    }
                    else
                    {
                        obj.EmployeeID = _emp.First().PEmployeeID;
                    }

                    if (obj.DateStarted != null && obj.DateEnded != null)
                    {
                        if (obj.DateEnded < obj.DateStarted)
                        {
                            ModelState.AddModelError("DateStarted", "Start date can never be greater than end date.");
                        }
                    }
                    Expression <Func <Shift, bool> > SpecificEntries97 = c => c.PShiftID == employee.ShiftID;
                    Shift shifts = ShiftService.GetIndexSpecific(SpecificEntries97).First();
                    if (shifts.GZDays == true)
                    {
                        List <Holiday> holiday = DDService.GetHolidays().Where(aa => aa.HolidayDate == obj.DateStarted).ToList();
                        if (holiday.Count > 0)
                        {
                            ModelState.AddModelError("DateStarted", "Cannot apply job card of the Gazetted Holiday");
                        }
                    }
                    Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => obj.DateStarted >= c.PRStartDate && obj.DateStarted <= c.PREndDate && c.PeriodStageID == "C";
                    List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();
                    if (dbPayrollPeriods.Count() > 0)
                    {
                        ModelState.AddModelError("DateStarted", "Cannot enter Job card in Closed Payroll Period");
                    }
                    Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries4 = aa => aa.EmpID == obj.EmployeeID && obj.DateStarted <= aa.ToDate && aa.FromDate <= obj.DateEnded && aa.IsHalf != true;
                    if (VATLeaveApplicationService.GetIndexSpecific(SpecificEntries4).Count() > 0)
                    {
                        ModelState.AddModelError("DateStarted", "Leave already applied for one or more days");
                    }
                    Expression <Func <JobCardApp, bool> > SpecificEntries2 = aa => obj.DateStarted <= aa.DateEnded && aa.DateStarted <= obj.DateEnded && aa.EmployeeID == obj.EmployeeID;
                    if (JobCardAppService.GetIndexSpecific(SpecificEntries2).Count() > 0)
                    {
                        ModelState.AddModelError("DateStarted", "Already exists in same date");
                    }

                    if (ModelState.IsValid)
                    {
                        obj.UserID = LoggedInUser.PUserID;
                        JobCardService.PostMultipleDay(obj);
                        DDService.ProcessDailyAttendance(obj.DateStarted, obj.DateEnded, (int)obj.EmployeeID, obj.EmployeeID.ToString());
                        DDService.ProcessMonthlyAttendance(obj.DateStarted, (int)obj.EmployeeID, obj.EmployeeID.ToString());
                        return(Json("OK", JsonRequestBehavior.AllowGet));
                    }
                    CreateHelper(obj);
                    return(PartialView("MultipleDay", obj));
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        public ActionResult SingleDay(JobCardApp obj)
        {
            try
            {
                string       _EmpNo                 = Request.Form["EmpNo"].ToString();
                VMLoggedUser LoggedInUser           = Session["LoggedInUser"] as VMLoggedUser;
                List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).ToList();
                VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).First();
                if (_emp.Count == 0)
                {
                    ModelState.AddModelError("EmployeeID", "Emp No not exist");
                }
                else
                {
                    obj.EmployeeID = _emp.First().PEmployeeID;
                }

                if (obj.TimeStart == null || obj.TimeEnd == null)
                {
                    ModelState.AddModelError("TimeStart", "Time Start and Time End cannot be empty");
                }
                if (obj.TimeEnd <= obj.TimeStart)
                {
                    ModelState.AddModelError("TimeEnd", "Time end cannot be less than or equal to start time .");
                }
                Expression <Func <JobCardApp, bool> > SpecificEntries2 = aa => obj.DateStarted == aa.DateStarted && obj.TimeStart <= aa.TimeEnd && aa.TimeStart <= obj.TimeEnd && aa.EmployeeID == obj.EmployeeID && aa.JobCardStageID != "R";
                if (JobCardAppService.GetIndexSpecific(SpecificEntries2).Count() > 0)
                {
                    ModelState.AddModelError("TimeStart", "Already exists between the time span");
                }
                Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => obj.DateStarted >= c.PRStartDate && obj.DateStarted <= c.PREndDate && c.PeriodStageID == "C";
                List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();
                if (dbPayrollPeriods.Count() > 0)
                {
                    ModelState.AddModelError("DateStarted", "Cannot enter Job card in Closed Payroll Period");
                }
                Expression <Func <Shift, bool> > SpecificEntries97 = c => c.PShiftID == employee.ShiftID;
                Shift shifts = ShiftService.GetIndexSpecific(SpecificEntries97).First();
                if (shifts.GZDays == true)
                {
                    List <Holiday> holiday = DDService.GetHolidays().Where(aa => aa.HolidayDate == obj.DateStarted).ToList();
                    if (holiday.Count > 0)
                    {
                        ModelState.AddModelError("DateStarted", "Cannot apply job card of the Gazetted Holiday");
                    }
                }
                if (ModelState.IsValid)
                {
                    obj.UserID = LoggedInUser.PUserID;
                    JobCardService.PostSingleDay(obj);
                    DDService.ProcessDailyAttendance(obj.DateStarted, obj.DateEnded, (int)obj.EmployeeID, obj.EmployeeID.ToString());
                    DDService.ProcessMonthlyAttendance(obj.DateStarted, (int)obj.EmployeeID, obj.EmployeeID.ToString());
                    return(Json("OK", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
            }
            CreateHelper(obj);
            return(PartialView("SingleDay", obj));
        }