public ModelSOTEmpList GetEmpPending(ViewUserEmp LoggedInUser, int?PayrollPeriodID, int DeptID) { // Varibale Initilization ModelSOTEmpList vm = new ModelSOTEmpList(); List <short?> deptIds = new List <short?>(); List <short?> divIds = new List <short?>(); List <int?> empIds = new List <int?>(); List <EmpView> totalEmps = new List <EmpView>(); List <EmpView> emps = new List <EmpView>(); List <PR_PayrollPeriod> activePeriods = new List <PR_PayrollPeriod>(); List <int?> activePeriodIds = new List <int?>(); PR_PayrollPeriod prp = new PR_PayrollPeriod(); int SelectedPeriodID = 0; List <ViewDailyOTEntry> otList = new List <ViewDailyOTEntry>(); deptIds.Add((short)DeptID); divIds = OTHelperManager.GetDivisionIDs(deptIds, db.HR_Section.ToList()); totalEmps = db.EmpViews.Where(aa => aa.Status == "Active").ToList(); // Get Payroll Period SelectedPeriodID = Convert.ToInt32(Session["PRID"].ToString()); if (PayrollPeriodID == null) { PayrollPeriodID = SelectedPeriodID; } else { Session["PRID"] = PayrollPeriodID.ToString(); } activePeriodIds = db.ViewDailyOTEntries.Where(aa => (aa.SupervisorID == LoggedInUser.EmployeeID && aa.StatusID == "P") || (aa.StatusID == "F" && aa.ForwardToID == LoggedInUser.EmployeeID)).Select(aa => aa.PeriodID).Distinct().ToList(); activePeriods = OTHelperManager.GetActivePeriods(db.PR_PayrollPeriod.ToList(), activePeriodIds); prp = OTHelperManager.GetPayrollPeriod(activePeriods, (int)PayrollPeriodID); empIds = db.ViewDailyOTEntries.Where(aa => aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate && aa.SecID == DeptID && ((aa.SupervisorID == LoggedInUser.EmployeeID && aa.StatusID == "P") || (aa.StatusID == "F" && aa.ForwardToID == LoggedInUser.EmployeeID))).Select(aa => aa.EmployeeID).Distinct().ToList(); emps = OTHelperManager.GetEmployeeConvertedFromIds(empIds, totalEmps); otList = db.ViewDailyOTEntries.Where(aa => aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate && aa.SecID == DeptID && ((aa.SupervisorID == LoggedInUser.EmployeeID && aa.StatusID == "P") || (aa.StatusID == "F" && aa.ForwardToID == LoggedInUser.EmployeeID))).ToList(); vm.DeptID = (int)DeptID; if (prp.FinYearID != null) { vm.DivRemainingBudget = OTHelperManager.GetDivRemainingBudget(divIds, db.BG_OTDivision.ToList(), (int)prp.FinYearID); } vm.List = OTHelperRecommended.GetConvertedOTListEmp(otList, emps); //if (DateTime.Today > prp.SupervisorCutOffDate) // vm.IsLate = true; //else vm.IsLate = false; if (vm.List.Count() > 1) { vm.TotalOTAmount = vm.List.Sum(aa => aa.OTAmount); vm.SystemOT = OTHelperManager.ConverMinIntoHours(vm.List.Sum(aa => aa.SystemOTMins)); vm.ClaimedOT = OTHelperManager.ConverMinIntoHours(vm.List.Sum(aa => aa.ClaimedOTMins)); vm.TotalEmps = vm.List.Count().ToString(); } vm.Count = vm.List.Count; ViewBag.DecisionID = new SelectList(OTHelperManager.GetOTStatusForApprover(db.Att_OTStatus.ToList()), "PSID", "StatusName", "F"); ViewBag.RecommendID = new SelectList(OTHelperManager.GetUsersForRecommender(db.ViewUserEmps.Where(aa => aa.EmpStatus == "Active").ToList()), "UserID", "FullName"); ViewBag.PayrollPeriodID = new SelectList(activePeriods, "PID", "PName", PayrollPeriodID); return(vm); }
private List <string> IsValidateEmpList(ModelSOTEmpList model, string[] checkedEmpDates) { List <string> messages = new List <string>(); if (model.IsLate == true) { if (model.Justification == null || model.Justification == "") { messages.Add("Please provide justification for late subission of overtime"); } } if (model.Certified == false) { messages.Add("Please verify this employee does not claim daily overtime allowance on these dates"); } if (checkedEmpDates != null) { } else { messages.Add("Select Atleast One Entry"); } return(messages); }
public ActionResult AOTEmpList(int?DeptID, int?PayrollPeriodID) { ModelSOTEmpList vm = new ModelSOTEmpList(); ViewUserEmp LoggedInUser = Session["LoggedUser"] as ViewUserEmp; vm = GetEmpPending(LoggedInUser, (int)PayrollPeriodID, (int)DeptID); vm.Message = new List <string>(); return(View(vm)); }
public ModelSOTEmpList GetEmpPendingHR(ViewUserEmp LoggedInUser, int PayrollPeriodID, int DeptID) { ModelSOTEmpList vm = new ModelSOTEmpList(); int CurrentPID = Convert.ToInt32(Session["PRID"].ToString()); if (PayrollPeriodID == null) { PayrollPeriodID = CurrentPID; } else { Session["PRID"] = PayrollPeriodID.ToString(); } List <EmpView> emps = db.EmpViews.Where(aa => aa.Status == "Active" && aa.SecID == DeptID).ToList(); PR_PayrollPeriod prp = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), (int)PayrollPeriodID); vm.DeptID = (int)DeptID; emps = emps.Where(aa => aa.SecID == DeptID).ToList(); List <ViewDailyOTEntry> otList = new List <ViewDailyOTEntry>(); vm.DivRemainingBudget = OTHelperManager.GetDivRemainingBudget(OTHelperManager.ConvertDeptIDList(DeptID), db.BG_OTDivision.ToList(), (int)prp.FinYearID); otList = db.ViewDailyOTEntries.Where(aa => aa.OTProcessingPeriodID == PayrollPeriodID).ToList(); if (LoggedInUser.UserType == "H" || LoggedInUser.UserType == "A") { ViewBag.DecisionID = new SelectList(OTHelperManager.GetOTStatusForSupervisor(db.Att_OTStatus.ToList()), "PSID", "StatusName", "F"); ViewBag.RecommendID = new SelectList(OTHelperManager.GetUsersForSupervisor(db.ViewUserEmps.Where(aa => aa.EmpStatus == "Active").ToList()), "UserID", "FullName"); } else { ViewBag.DecisionID = new SelectList(OTHelperManager.GetOTStatusForSupervisor(db.Att_OTStatus.ToList()), "PSID", "StatusName", "F"); ViewBag.RecommendID = new SelectList(OTHelperManager.GetUsersForSupervisor(db.ViewUserEmps.Where(aa => aa.EmpStatus == "Active").ToList()), "UserID", "FullName"); List <int?> empIds = db.ViewDailyOTEntries.Where(aa => aa.OTProcessingPeriodID == PayrollPeriodID).Select(aa => aa.EmployeeID).Distinct().ToList(); emps = OTHelperManager.GetEmployees(emps, LoggedInUser); emps = OTHelperManager.GetEmployeeConvertedFromIds(empIds, emps); } vm.List = OTHelperRecommended.GetConvertedOTListEmpHR(otList, emps); if (vm.List.Count() > 0) { vm.TotalOTAmount = OTHelperManager.GetTotalOTAmount(vm.List); } vm.Count = vm.List.Count; vm.PayrollPeriodID = (int)PayrollPeriodID; if (vm.List.Count() > 0) { vm.RecommendID = (int)LoggedInUser.ReportingToID; vm.RecommenderName = db.EmpViews.First(aa => aa.EmployeeID == LoggedInUser.ReportingToID).FullName; } ViewBag.PayrollPeriodID = new SelectList(db.PR_PayrollPeriod.ToList(), "PID", "PName", PayrollPeriodID); return(vm); }
public ActionResult AOTEmpList(ModelSOTEmpList model) { ViewUserEmp LoggedInUser = Session["LoggedUser"] as ViewUserEmp; var empsChecked = Request.Form.GetValues("cbEmployee"); List <EmpView> emps = db.EmpViews.Where(aa => aa.Status == "Active").ToList(); List <EmpView> tempEmps = new List <EmpView>(); PR_PayrollPeriod prp = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), (int)model.PayrollPeriodID); List <ViewDailyOTEntry> otList = new List <ViewDailyOTEntry>(); List <string> messages = new List <string>(); model.Certified = true; messages = IsValidateEmpList(model, empsChecked); if (messages.Count == 0) { foreach (var id in empsChecked) { int chNo = Convert.ToInt32(id); tempEmps.Add(emps.First(aa => aa.EmployeeID == chNo)); } otList = db.ViewDailyOTEntries.Where(aa => aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate && aa.StatusID != "C").ToList(); List <ViewDailyOTEntry> vdat = OTHelperManager.GetOTListEmp(otList, tempEmps); foreach (var emp in tempEmps) { //DeptID = (int)emp.SecID; if (emp.DaysInMonth > 0) { // check for Monthly Limit if (vdat.Where(aa => aa.EmpID == emp.EmployeeID).Count() > emp.DaysInMonth) { messages.Add("Your Monthly overtime claim limit exceeds for:" + emp.FullName); } else { // check for weekly limit if (emp.DaysInWeek > 0) { if (OTHelperManager.IsValidWeekPolicy(vdat.Where(aa => aa.EmpID == emp.EmployeeID).OrderByDescending(aa => aa.OTDate).ToList(), prp, emp.DaysInWeek)) { messages.Add("Your weekly overtime claim limit exceeds for:" + emp.FullName); } } } } // check for daily ot limit { if (OTHelperManager.IsValidDailyOT(vdat.Where(aa => aa.EmpID == emp.EmployeeID), emp)) { messages.Add("Your daily overtime claim limit exceeds for:" + emp.FullName); } } } } if (messages.Count == 0) { int CurrentPeriodID = db.PR_PayrollPeriod.OrderByDescending(aa => aa.PID).First().PID; List <Att_OTDailyEntry> attOts = db.Att_OTDailyEntry.Where(aa => aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate && (aa.StatusID == "F" || aa.StatusID == "P")).ToList(); foreach (var emp in tempEmps) { foreach (var atot in attOts.Where(aa => aa.EmpID == emp.EmployeeID).ToList()) { // Save Log db.Att_OTDForward.Add(OTHelperManager.CreateOTLog(atot, LoggedInUser, model.RecommendID, model.Justification, model.DecisionID, "Recommend", CurrentPeriodID)); string oldStatus = "P"; oldStatus = atot.StatusID; atot.StatusID = model.DecisionID; if (atot.StatusID == "R") { atot.FtoARDateTime = DateTime.Now; atot.FtoARUserID = LoggedInUser.UserID; atot.CancelByID = LoggedInUser.UserID; atot.OTProcessingPeriodID = CurrentPeriodID; } else { if (model.IsLate == true) { atot.Remarks = model.Justification; } atot.ApprovedByID = LoggedInUser.UserID; atot.OTProcessingPeriodID = CurrentPeriodID; atot.FtoARDateTime = DateTime.Now; atot.FtoARUserID = LoggedInUser.UserID; } } db.SaveChanges(); // Cancel All others foreach (var item in attOts.Where(aa => aa.EmpID == emp.EmployeeID && aa.StatusID == "F").ToList()) { item.StatusID = "C"; item.FtoFCDateTime = DateTime.Now; item.FtoFCUserID = LoggedInUser.UserID; item.CancelByID = LoggedInUser.UserID; item.OTProcessingPeriodID = CurrentPeriodID; } db.SaveChanges(); } return(Json("OK")); } else { } return(Json(messages)); }
public ActionResult HROTEmpList(int?PayrollPeriodID) { ViewUserEmp LoggedInUser = Session["LoggedUser"] as ViewUserEmp; var empsChecked = Request.Form.GetValues("cbEmployee"); List <EmpView> emps = db.EmpViews.Where(aa => aa.Status == "Active").ToList(); List <EmpView> tempEmps = new List <EmpView>(); PR_PayrollPeriod prp = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), (int)PayrollPeriodID); List <ViewDailyOTEntry> otList = new List <ViewDailyOTEntry>(); List <string> messages = new List <string>(); string val = Request.Form["Certified"].ToString(); int DeptID = Convert.ToInt32(Request.Form["DeptID"].ToString()); if (val == "true,false") { foreach (var id in empsChecked) { int chNo = Convert.ToInt32(id); tempEmps.Add(emps.First(aa => aa.EmployeeID == chNo)); } otList = db.ViewDailyOTEntries.Where(aa => aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate && (aa.StatusID == "P")).ToList(); if (LoggedInUser.UserType == "N" || LoggedInUser.UserType == "R") { List <ViewDailyOTEntry> vdat = OTHelperManager.GetOTListEmp(otList, tempEmps); foreach (var emp in tempEmps) { //DeptID = (int)emp.SecID; if (emp.DaysInMonth > 0) { // check for Monthly Limit if (vdat.Where(aa => aa.EmpID == emp.EmployeeID).Count() > emp.DaysInMonth) { messages.Add("Your Monthly overtime claim limit exceeds."); } else { // check for weekly limit if (emp.DaysInWeek > 0) { if (OTHelperManager.IsValidWeekPolicy(vdat.Where(aa => aa.EmpID == emp.EmployeeID).OrderByDescending(aa => aa.OTDate).ToList(), prp, emp.DaysInWeek)) { messages.Add("Your weekly overtime claim limit exceeds."); } } } } // check for daily ot limit { if (OTHelperManager.IsValidDailyOT(vdat.Where(aa => aa.EmpID == emp.EmployeeID), emp)) { messages.Add("Your daily overtime claim limit exceeds."); } } } if (messages.Count == 0) { List <Att_OTDailyEntry> attOts = db.Att_OTDailyEntry.Where(aa => aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate).ToList(); foreach (var emp in tempEmps) { foreach (var atot in attOts.Where(aa => aa.EmpID == emp.EmployeeID).ToList()) { atot.StatusID = Request.Form["DecisionID"].ToString(); if (atot.StatusID == "C") { //atot.NtoPDateTime = DateTime.Now; atot.CancelByID = LoggedInUser.UserID; } else { atot.ForwardToID = Convert.ToInt32(Request.Form["RecommendID"]); //atot.NtoPDateTime = DateTime.Now; //atot.NtoPUserID = LoggedInUser.UserID; //atot.OTProcessingPeriod = PayrollPeriodID; } } db.SaveChanges(); } } else { } } } else { messages.Add("Please verify, this employee does not claim daily allowance on these dates"); } // ModelSOTEmpList vm = new ModelSOTEmpList(); //vm = GetEmpPending(LoggedInUser, (int)PayrollPeriodID, (int)DeptID); vm.Message = messages; return(View(vm)); }