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()); }
public ActionResult VisualOverview() { //Need to show Pending, Edited, and Approved forms for each user. EmployeeContractChangesRepository eCCR = new EmployeeContractChangesRepository(); var UniqueContractChangeList = eCCR.GetUniqueEmployeeContractLogs(); ViewBag.pending = 0; ViewBag.approved = 0; ViewBag.editing = 0; ViewBag.optout = 0; if (UniqueContractChangeList != null) { foreach (ContractChanges c in UniqueContractChangeList) { ViewBag.pending = c.StatusName == "Pending" ? (ViewBag.pending + 1) : ViewBag.pending; ViewBag.editing = c.StatusName == "Editing" ? (ViewBag.editing + 1) : ViewBag.editing; ViewBag.approved = c.StatusName == "Approved" ? (ViewBag.approved + 1) : ViewBag.approved; ViewBag.optout = c.StatusName == "Opt-Out" ? (ViewBag.optout + 1) : ViewBag.optout; } return(View(UniqueContractChangeList)); } 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()); } }
// GET: FormUpdates public ActionResult EnableSurvey() { //Determine if user is passed due on survey period. EmployeeContractChangesRepository eCCR = new EmployeeContractChangesRepository(); using (AuthenticateContext db = new AuthenticateContext()) { int userID = ((CustomAuthentication.CustomPrincipal) this.HttpContext.User).ID; var employee = (from e in db.Employees where e.ID == userID select e).First(); var latestContractForm = eCCR.GetLCF(userID); bool showSurvey = true; bool showOptout = true; //case where Employee has past contract changes. if (employee != null) { var latestCF = latestContractForm; var latestCFStatus = latestCF != null?eCCR.StatusIs(latestCF.StatusID) : "DNE"; DateTime today = DateTime.Today; DateTime SurveyPeriod = (employee.LastUpdate).AddMonths(3); DateTime OptOutPeriod = (employee.LastUpdate).AddDays(90.00); bool optOutLastDay = SurveyPeriod == OptOutPeriod; showOptout = (OptOutPeriod <= today) ? false : true; showOptout = latestCFStatus == "Opt-Out" ? false : showOptout; showSurvey = (SurveyPeriod >= today) && !optOutLastDay ? false : true; TempData["showOptout"] = null; TempData["showSurvey"] = null; TempData["showOptout"] = showOptout ? "show" : "hide"; TempData["showSurvey"] = showSurvey ? "show" : "hide"; return(RedirectToAction("ShowDashboard", "Account")); } //case where Employee is new. //Check if userID exists, if it does update display the create form, if it does not then just redirect to login. if (userID >= 0) {//create contract forms. return(RedirectToAction("ShowDashboard", "Account")); } //Will be creating 2 new change log if will increment the ChangeLogID. return(Redirect("/Account/Login")); } }
// GET: HR public ActionResult ChangeHistory(int changeLogID, int employeeID) { EmployeeContractChangesRepository eCCR = new EmployeeContractChangesRepository(); var ContractChangeHistory = eCCR.getChangeHistory(changeLogID, employeeID); if (ContractChangeHistory != null) { return(PartialView("ChangeHistoryTable", ContractChangeHistory.ToList())); } return(View()); }
// GET: Dashboard public ActionResult Index() //Will determine if user account needs to have survey created and sent and opt out button enabled. { if (TempData["showOptout"] == null) { return(RedirectToAction("EnableSurvey", "FormUpdates")); } ViewBag.Title = "Dashboard"; ViewBag.ModalHeader = "Survey"; ViewBag.Name = Session["Firstname"] + " " + Session["Lastname"]; ViewBag.showOptout = (string)TempData["showOptout"] == "hide" ? false : true; ViewBag.showSurvey = (string)TempData["showSurvey"] == "hide" ? false : true; ViewBag.submitSurvey = ViewBag.showSurvey ? false : true; EmployeeContractChangesRepository eCCR = new EmployeeContractChangesRepository(); int UserID = ((CustomAuthentication.CustomPrincipal) this.HttpContext.User).ID; Employee employee = eCCR.GetEmployeeBy(UserID); var UniqueList = eCCR.GetUniqueEmployeeContractLogs(); var GroupedChangeLogs = UniqueList.ToList().Where(x => x.EmployeeID == UserID); DateTime today = DateTime.Today; DateTime OptDate = (employee.LastUpdate).AddDays(90.00); if (employee != null) { ViewBag.OptOutDaysLeft = ViewBag.showOptOut ? (OptDate.Subtract(today)).Days : 0; } if (GroupedChangeLogs != null) { return(View(GroupedChangeLogs)); } return(View()); }
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")); }