public ActionResult LoadContractChangeForm(string form = "survey", int employeeID = 0, string ReturnUrl = "", int contractID = 0) //User can only see this if they are in opt out period. { //displays most recent contract change form to the user (will be most recent contract change form created or using (AuthenticateContext db = new AuthenticateContext()) { int userID = 0; //bool survey = false; bool editing = false; bool optout = form.Contains("optout") ? true : false; if (!form.Contains("editing")) {//User is getting surveyed. userID = ((CustomAuthentication.CustomPrincipal) this.HttpContext.User).ID; } else {//HR worker is coming in to make changes to ContractChangeOrder userID = employeeID; editing = true; } var lastContractChangeForm = db.EmployeeContractChanges.Where(x => x.EmployeeID == userID).OrderByDescending(x => x.DateCreated).FirstOrDefault(); var employee = db.Employees.Where(x => x.ID == userID).FirstOrDefault(); if (lastContractChangeForm != null || employee != null) { var lastCF = lastContractChangeForm; EmployeeContractChangesRepository eCCR = new EmployeeContractChangesRepository(); if (editing == true) { HRDashboardViewModel HRModel = eCCR.HRDashboardViewModelLastCF(employee, form, lastCF.StatusID); var UniqueList = eCCR.GetUniqueEmployeeContractLogs(); var GroupedChangeLogs = UniqueList.ToList(); HRModel.ContractChanges = GroupedChangeLogs.ToList(); HRModel.EmployeeID = employee.ID; HRModel.ID = contractID; HRModel.FormType = form; return(RedirectToAction("ShowContractChangeFormHR", "UserDashboard", HRModel)); } else if (optout == true) { return(RedirectToAction("ShowOptOutForm", "UserDashboard", eCCR.GetEmployee(employee))); } else { return(RedirectToAction("ShowContractChangeFormEmployee", "UserDashboard", eCCR.GetEmployee(employee))); } } } if (Url.IsLocalUrl(ReturnUrl)) { return(Redirect(ReturnUrl)); } return(View()); }
// GET: HR/ChangeHistoryView public ActionResult ChangeHistoryOverview() { //displays change history for HR when selecting a table row. if (TempData["showOptout"] == null) { //Determine if user has refreshed the page and needs to collect values to enable survey. return(RedirectToAction("EnableSurvey", "FormUpdates")); } using (AuthenticateContext db = new AuthenticateContext()) { //pass in stored procedure result here then modify to be ContractChanges format. EmployeeContractChangesRepository eCCR = new EmployeeContractChangesRepository(); var UniqueList = eCCR.GetUniqueEmployeeContractLogs(); var GroupedChangeLogs = UniqueList.ToList(); ViewBag.Title = "Dashboard"; ViewBag.ModalHeader = "Survey"; ViewBag.Name = Session["Firstname"] + " " + Session["Lastname"]; var x = ViewBag.showSurvey; ViewBag.showOptout = (string)TempData["showOptout"] == "hide" ? false : true; ViewBag.showSurvey = (string)TempData["showSurvey"] == "hide" ? false : true; ViewBag.submitSurvey = ViewBag.showSurvey ? false : true; if (GroupedChangeLogs != null) { HRDashboardViewModel model = new HRDashboardViewModel(); model.ContractChanges = GroupedChangeLogs.ToList(); return(View(model)); } return(View()); } }
public ActionResult ShowContractChangeFormHR([Bind(Include = "ID,NewLastName, NewEmail, NewAddress, NewCity," + "NewState,NewZipcode,NewCountry,NewHomePhone,FormType,EmployeeID")] HRDashboardViewModel contract) //Will determine if user account needs to have survey created and sent and opt out button enabled. { //returns back data that is used to populate the Survey or Contract Change Form. contract.ContractChanges = new List <ContractChanges>(); IEnumerable <FormStatus> Statuses = new List <FormStatus>(); using (AuthenticateContext db = new AuthenticateContext()) { Statuses = db.FormStatuses.AsEnumerable().ToList(); } ViewBag.FormStatuses = new SelectList(Statuses, "ID", "StatusName"); return(PartialView("~/Views/HR/SetupContractChangeForm.cshtml", contract)); }
public ActionResult SetupContractChangeForm([Bind(Include = "ID ,NewLastName, NewEmail, NewAddress, NewCity," + "NewState,NewZipcode,NewCountry,NewHomePhone, FormType, StatusID, EmployeeID, File")] EmployeeContractChanges contract, string FormType, HttpPostedFileBase File) {//called to either initiate a contract change request (during surveys) or HR editing a contract change form. EmployeeContractChangesRepository eCCR = new EmployeeContractChangesRepository(); string form = FormType; bool editing = form.Contains("editing"); bool survey = form.Contains("survey"); bool optout = form.Contains("optout"); bool notEditingCurrentCF = false; int UserID = -1; if (form == "editing") { UserID = contract.EmployeeID; } else { UserID = ((CustomAuthentication.CustomPrincipal) this.HttpContext.User).ID; } EmployeeContractChanges LastCF = eCCR.GetLCF(UserID); if (editing) { if (LastCF != null) { notEditingCurrentCF = (contract.ID != eCCR.GetLCF(UserID).ID) ? true : false; } if (notEditingCurrentCF) { ModelState.AddModelError("", "Recent changes have been made to this Contract, please review these changes."); HRDashboardViewModel passBackContract = eCCR.HRDashboardViewModel(contract, form); passBackContract.ContractChanges = new List <ContractChanges>(); IEnumerable <FormStatus> Statuses = new List <FormStatus>(); using (AuthenticateContext db = new AuthenticateContext()) { Statuses = db.FormStatuses.AsEnumerable().ToList(); } ViewBag.FormStatuses = new SelectList(Statuses, "ID", "StatusName"); ViewBag.Error = "Recent changes have been made to this Contract, please review these changes"; //return PartialView("~/Views/HR/SetupContractChangeForm.cshtml", passBackContract); var errors = new Hashtable(); foreach (var pair in ModelState) { if (pair.Value.Errors.Count > 0) { errors[pair.Key] = pair.Value.Errors.Select(error => error.ErrorMessage).ToList(); } } return(Json(new { success = true, errors })); } } if (survey || editing) { eCCR.InsertEmployeeContractChanges(contract, UserID, editing, survey); if (editing) { eCCR.CheckApproved(contract, UserID); return(Json(new { redirectTo = Url.Action("EnableSurvey", "FormUpdates") })); } } else if (optout) { eCCR.ResetContractChange(UserID, contract); //return Json(new { redirectTo = Url.Action("EnableSurvey", "FormUpdates") }); return(RedirectToAction("EnableSurvey", "FormUpdates")); } //Need to send to Form updater method that goes through to determine if user needs to get Surveyed. return(RedirectToAction("EnableSurvey", "FormUpdates")); }
public IActionResult DashboardHR() { HRDashboardViewModel HRDVM = new HRDashboardViewModel(); List <LatestEmployeeVM> lastestEmployeeVM = new List <LatestEmployeeVM>(); List <LeaveDashVM> leaveDashVM = new List <LeaveDashVM>(); List <RecentApplication> recentAppVM = new List <RecentApplication>(); LatestEmployeeVM latestEmployee; LeaveDashVM leaveDash; RecentApplication recentApp; var orgId = getOrg(); var empList = _context.Users.Where(x => x.OrganisationId == orgId).ToList(); var empDetails = _context.EmployeeDetails.Where(x => x.OrganisationId == orgId).ToList(); var jobs = _context.Jobs.Where(x => x.OrganisationId == orgId).ToList(); foreach (var item in empList) { var empdet = empDetails.Where(x => x.UserId == Guid.Parse(item.Id)).FirstOrDefault(); if (empdet != null) { //try //{ latestEmployee = new LatestEmployeeVM() { Id = empdet.Id, EmployeeName = empdet.FirstName + " " + empdet.LastName, //Department = jobs.Where(x => x.EmployeeDetailId == empdet.Id).FirstOrDefault().Department.DepartmentName, //JobTitle = jobs.Where(x => x.EmployeeDetailId == empdet.Id).FirstOrDefault().JobTitle.JobTitleName, //IsActive = item.Status }; lastestEmployeeVM.Add(latestEmployee); //} //catch //{ //} } } List <HeadCount> headCounts = new List <HeadCount>(); var department = _context.Departments.Where(x => x.OrganisationId == orgId).ToList(); var allJobs = _context.Jobs.Where(x => x.OrganisationId == orgId); HeadCount hC; foreach (var item in department) { hC = new HeadCount(); hC.Department = item.DepartmentName; hC.Female = allJobs.Where(x => x.DepartmentId == item.Id).Where(x => x.EmployeeDetail.Gender == "Female").ToList().Count(); hC.Male = allJobs.Where(x => x.DepartmentId == item.Id).Where(x => x.EmployeeDetail.Gender == "Male").ToList().Count(); headCounts.Add(hC); } var leaves = _context.Leaves.Where(x => x.OrganisationId == orgId); HRDVM.ActiveLeaves = leaves.Where(c => c.Status == "Pending").ToList(); HRDVM.PendingLeave = leaves.Where(c => c.Status == "Approved").Where(x => x.StartDate <DateTime.Now && x.EndDate> DateTime.Now).ToList().Count(); HRDVM.LatestEmployeeVMs = lastestEmployeeVM; HRDVM.TotalEmployee = empDetails.Count(); HRDVM.HeadCounts = headCounts; return(View(HRDVM)); }