// /* Retrieves all the employee objects of employees that work for the specified departement * within the Information Technology division (as per client request), then returns them * as a list. If department is null, it displays all employees in the division */ public virtual ActionResult userManagement(DateTime refDate, string department = null) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { //if it's a redirect from submitRejectTimesheet() if (TempData["emailSentFlag"] != null) { ViewBag.emailSentFlag = true; ViewBag.messageRecipient = TempData["recipient"]; } string division = getUserDivision(); IEnumerable<TARSUser> employees = getDivisionEmployeeObjList(division, department); ViewBag.division = division; ViewBag.departmentList = getDepartmentSelectList(division); ViewBag.refDate = refDate; ViewBag.refSunday = refDate.StartOfWeek(DayOfWeek.Sunday); ViewBag.refPayPeriod = getPayPeriod(refDate); return View(employees); } else { return View("error"); } }
// /* Retrieves all PCA codes for the specified division and sends them to the view as * a list. The division name and a division selection list are also sent to the view. */ public virtual ActionResult searchPCA(string division = null) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { ViewBag.divisionList = getDivisionSelectList(); if ( (division == null)||(division.CompareTo("All") == 0) ) { ViewBag.division = "All"; return View(PcaCodeDB.PcaCodeList.ToList()); } else { ViewBag.division = division; var pcaList = from p in PcaCodeDB.PcaCodeList where (p.division.CompareTo(division) == 0) select p; return View(pcaList.ToList()); } } else { return View("error"); } }
public virtual ActionResult addWorkEffort(WorkEffort workeffort) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { if (ModelState.IsValid) { //make sure there is an end date if (workeffort.endDate == null) { workeffort.endDate = DateTime.MaxValue; } //make sure the start date is before the end date if (workeffort.startDate > workeffort.endDate) { ViewBag.divisionList = getDivisionSelectList(); ViewBag.endBeforeStartFlag = true; return View(workeffort); } //make sure it falls within it's associated PCA code's time boundaries if (verifyWeTimeBounds(workeffort, workeffort.pcaCode) == true) { //update WorkEffort table in database WorkEffortDB.WorkEffortList.Add(workeffort); WorkEffortDB.SaveChanges(); //add the PCA_WE association to PCA_WE table PCA_WE tmpPcaWe = new PCA_WE(); tmpPcaWe.WE = workeffort.ID; tmpPcaWe.PCA = getPcaIdFromCode(workeffort.pcaCode); tmpPcaWe.associationStartDate = DateTime.Now; tmpPcaWe.associationEndDate = DateTime.MaxValue; tmpPcaWe.active = true; PCA_WEDB.PCA_WEList.Add(tmpPcaWe); PCA_WEDB.SaveChanges(); return RedirectToAction("weManagement"); } else { ViewBag.divisionList = getDivisionSelectList(); ViewBag.notWithinTimeBounds = true; return View(workeffort); } } return View("error"); } else { return View("error"); } }
// // Returns manager Index view // Overridden from User/Index, which was virtual. public override ActionResult Index() { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { return View(); } else { return View("error"); } }
// /* Creates an empty Work Effort object and sends it to the view, along with a * selection list of divisions. */ public virtual ActionResult addWorkEffort() { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { ViewBag.divisionList = getDivisionSelectList(); return View(new WorkEffort()); } else { return View("error"); } }
public virtual ActionResult searchWorkEffort() { Authentication auth = new Authentication(); if (auth.isUser(this) || Authentication.DEBUG_bypassAuth) { Authentication auth2 = new Authentication(); if (auth2.isManager(this)) { ViewBag.managerFlag = true; } var workEffortList = WorkEffortDB.WorkEffortList.ToList(); //create a list of lists for pca codes //(each work effort will have a list of PCA codes) ViewBag.pcaListOfLists = new List<List<SelectListItem>>(); foreach (var item in workEffortList) { ViewBag.pcaListOfLists.Add(getWePcaCodesSelectList(item)); } return View(workEffortList); } else { return View("notLoggedOn"); } }
public virtual ActionResult managerEditHours(int hrsID, int tsID) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { Hours hours = HoursDB.HoursList.Find(hrsID); WorkEffort we = WorkEffortDB.WorkEffortList.Find(hours.workEffortID); Timesheet timesheet = TimesheetDB.TimesheetList.Find(tsID); ViewBag.timesheetLockedFlag = timesheet.locked; Authentication newAuth = new Authentication(); bool adminFlag = newAuth.isAdmin(this); ViewBag.adminFlag = adminFlag; ViewBag.workEffort = we; ViewBag.timeCodeList = getTimeCodeList(); return View(hours); } else { return View("error"); } }
public virtual ActionResult managerEditHours(Hours tmpHours) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { if (ModelState.IsValid) { HoursDB.Entry(tmpHours).State = EntityState.Modified; HoursDB.SaveChanges(); } int userKeyID = getUserKeyID(tmpHours.creator); return RedirectToAction("approveTimesheet", new { userKeyID = userKeyID, tsDate = tmpHours.timestamp }); } else { return View("error"); } }
// /* Retrieves Timesheet object with specified ID and changes "submitted" and * "approved" statuses to TRUE. Also sends a notification email to the employee */ public virtual ActionResult submitApproveTimesheet(int id) { if (id >= 0) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { Timesheet ts = new Timesheet(); ts = TimesheetDB.TimesheetList.Find(id); ts.submitted = true; ts.approved = true; TimesheetDB.Entry(ts).State = System.Data.EntityState.Modified; //save changes to the database TimesheetDB.SaveChanges(); //send an email to employee to notify of timesheet approval string body = "Your IDHW timesheet for the pay period of " + ts.periodStart + " - " + ts.periodEnd + " has been approved by a manager."; SendEmail(ts.worker, "Timesheet Approved", body); return RedirectToAction("userManagement", new { refDate = DateTime.Now }); } else { return View("error"); } } else { return View("error"); } }
// /* Retrieves Timesheet object with specified ID and changes "submitted" and * "approved" statuses to FALSE. Also sends a notification email to the employee */ public virtual ActionResult submitRejectTimesheet(int id) { if (id >= 0) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { Timesheet ts = new Timesheet(); ts = TimesheetDB.TimesheetList.Find(id); ts.submitted = false; ts.approved = false; //save changes to the database TimesheetDB.Entry(ts).State = System.Data.EntityState.Modified; TimesheetDB.SaveChanges(); //send an email to employee to notify them string body = "Your IDHW timesheet for the pay period of " + ts.periodStart + " - " + ts.periodEnd + " has been rejected by a manager. " + "Please fix it and re-submit as soon as possible.<br /><br />Thanks!"; SendEmail(ts.worker, "Rejected Timesheet", body); TempData["emailSentFlag"] = true; TempData["recipient"] = ts.worker; TempData["emailError"] = TempData["emailError"]; return RedirectToAction("userManagement", new { refDate=DateTime.Now }); } else { return View("error"); } } else { return View("error"); } }
public ActionResult viewHistory(DateTime start, DateTime end, string division = null, string un = null, string dbtable = null) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { IEnumerable<History> searchHist = from h in HistoryDB.HistoryList where h.timestamp >= start where h.timestamp <= end select h; if ( (division != null)&&(division.CompareTo("All") != 0) ) { IEnumerable<SelectListItem> names = getDivisionEmployeeSelectList(division); List<History> tmpList = new List<History>(); foreach (var item in names) { var name = from h in searchHist where (h.username.CompareTo(item.Value) == 0) select h; foreach (var nameObj in name) { tmpList.Add(nameObj); } } searchHist = (IEnumerable<History>)tmpList; } if ((un != null) && (un.CompareTo("All") != 0)) { searchHist = from h in searchHist where (h.username.CompareTo(un) == 0) select h; } if ( (dbtable != null)&&(dbtable.CompareTo("All") != 0) ) { searchHist = from h in searchHist where (h.dbtable.CompareTo(dbtable) == 0) select h; } ViewBag.start = start.ToShortDateString(); ViewBag.end = end.ToShortDateString(); ViewBag.divisionList = getDivisionSelectList(); ViewBag.employeeList = getDivisionEmployeeSelectList(division); ViewBag.dbtableList = getDbTableSelectList(); return View(searchHist.ToList()); } else { return View("error"); } }
public virtual ActionResult approveTimesheet(int userKeyID, DateTime tsDate) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { TARSUser employee = TARSUserDB.TARSUserList.Find(userKeyID); Timesheet timesheet = getTimesheet(employee.userName, tsDate); if (timesheet == null) { createTimesheet(employee.userName, DateTime.Now); ViewBag.timesheet = getTimesheet(employee.userName, DateTime.Now); } else { ViewBag.timesheet = timesheet; } var hoursList = from m in HoursDB.HoursList where (m.creator.CompareTo(employee.userName) == 0) where m.timestamp >= timesheet.periodStart where m.timestamp <= timesheet.periodEnd select m; TempData["hoursList"] = hoursList; //convert hoursList into a format that the view can use List<TimesheetRow> tsRows = convertHoursForTimesheetView(); ViewBag.workEffortList = getVisibleWorkEffortSelectList(getUserDivision()); ViewBag.refDate = tsDate; ViewBag.userKeyID = userKeyID; return View(tsRows); } else { return View("error"); } }
// /* Retrieves Work Effort object with specified ID, and changes "hidden" to FALSE * so users can log hours to it on their timesheet */ public virtual ActionResult unHideWorkEffort(int id) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { WorkEffort we = WorkEffortDB.WorkEffortList.Find(id); we.hidden = false; WorkEffortDB.Entry(we).State = System.Data.EntityState.Modified; WorkEffortDB.SaveChanges(); return RedirectToAction("WeManagement"); } else { return View("error"); } }
public virtual ActionResult searchPCA_WE() { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { return View(PCA_WEDB.PCA_WEList.ToList()); } else { return View("error"); } }
[HttpPost, ActionName("deleteWorkEffort")] //This action MUST match the above delete function. public virtual ActionResult confirmedDeleteWorkEffort(int id) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { //make sure that there aren't any hours billed to the work effort if (checkWeForBilledHours(id) == true) { TempData["failedDelete"] = true; return RedirectToAction("weManagement"); } else { WorkEffort workeffort = WorkEffortDB.WorkEffortList.Find(id); //change the active status to FALSE for all PCA_WE entries for the work effort deactivateAllPcaWeForWorkEffort(id); //delete the work effort WorkEffortDB.WorkEffortList.Remove(workeffort); WorkEffortDB.SaveChanges(); return RedirectToAction("weManagement"); } } else { return View("error"); } }
public virtual ActionResult viewWorkEffort(int id) { Authentication auth = new Authentication(); if (auth.isUser(this) || Authentication.DEBUG_bypassAuth) { Authentication newAuth = new Authentication(); if (newAuth.isManager(this)) { ViewBag.managerFlag = true; } WorkEffort workeffort = WorkEffortDB.WorkEffortList.Find(id); if (workeffort == null) { return HttpNotFound(); } ViewBag.pcaList = getWePcaCodesSelectList(workeffort); ViewBag.WorkEffortID = workeffort.ID; return View(workeffort); } else { return View("notLoggedOn"); } }
public virtual ActionResult deleteWorkEffort(int id) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { WorkEffort workeffort = WorkEffortDB.WorkEffortList.Find(id); ViewBag.pcaList = getWePcaCodesSelectList(workeffort); return View(workeffort); } else { return View("error"); } }
public virtual ActionResult editWorkEffort(WorkEffort workeffort) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { if (ModelState.IsValid) { //make sure the start date is before the end date if (workeffort.startDate > workeffort.endDate) { ViewBag.endBeforeStartFlag = true; ViewBag.pcaList = getWePcaCodesSelectList(workeffort); Authentication newAuth = new Authentication(); if (newAuth.isAdmin(this)) { ViewBag.adminFlag = true; } return View(workeffort); } //make sure it falls within it's associated PCA code's time boundaries if (verifyWeTimeBounds(workeffort, workeffort.pcaCode) == true) { WorkEffortDB.WorkEffortList.Add(workeffort); WorkEffortDB.Entry(workeffort).State = System.Data.EntityState.Modified; WorkEffortDB.SaveChanges(); return RedirectToAction("weManagement"); } else { ViewBag.notWithinTimeBounds = true; ViewBag.pcaList = getWePcaCodesSelectList(workeffort); Authentication newAuth = new Authentication(); if (newAuth.isAdmin(this)) { ViewBag.adminFlag = true; } return View(workeffort); } } return View(workeffort); } else { return View("error"); } }
public ActionResult viewHistory(DateTime start, DateTime end) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { var searchHist = from h in HistoryDB.HistoryList where h.timestamp >= start where h.timestamp <= end select h; ViewBag.start = start.ToShortDateString(); ViewBag.end = end.ToShortDateString(); ViewBag.divisionList = getDivisionSelectList(); ViewBag.employeeList = getDivisionEmployeeSelectList(); ViewBag.dbtableList = getDbTableSelectList(); return View(searchHist.ToList()); } else { return View("error"); } }
// /* Retrieves list of employees that work for specified division and department, and returns * them as a list. If division is null, it returns a list of all employees */ public virtual List<TARSUser> getDivisionEmployeeObjList(string division = null, string department = null) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { List<TARSUser> divEmployees = new List<TARSUser>(); var searchUsers = from m in TARSUserDB.TARSUserList select m; if ( (division != null)&&(division.CompareTo("All") != 0) ) { if ( (department != null)&&(department.CompareTo("All") != 0) ) { searchUsers = from m in searchUsers where (m.company.CompareTo(division) == 0) where (m.department.CompareTo(department) == 0) select m; } else { searchUsers = from m in searchUsers where (m.company.CompareTo(division) == 0) select m; } } foreach (var item in searchUsers) { divEmployees.Add(item); } return divEmployees; } else { return null; } }
public virtual ActionResult viewPCA_WE(int id) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { PCA_WE pca_we = PCA_WEDB.PCA_WEList.Find(id); return View(pca_we); } else { return View("error"); } }
// /* Retrieves list of employee that work for specified division and department, and returns * the names as a selection list. If division is null, it returns all employee names */ public virtual List<SelectListItem> getDivisionEmployeeSelectList(string division = null) { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { List<SelectListItem> employeeNames = new List<SelectListItem>(); var searchUsers = from m in TARSUserDB.TARSUserList select m; if ((division != null) && (division.CompareTo("All") != 0)) { searchUsers = from m in searchUsers where (m.company.CompareTo(division) == 0) select m; } employeeNames.Add(new SelectListItem { Text = "All", Value = "All" }); foreach (var item in searchUsers) { employeeNames.Add(new SelectListItem { Text = item.userName, Value = item.userName }); } return employeeNames; } else { return null; } }
public virtual ActionResult weManagement() { Authentication auth = new Authentication(); if (auth.isManager(this) || Authentication.DEBUG_bypassAuth) { var workEffortList = WorkEffortDB.WorkEffortList.ToList(); //create a list of lists for pca codes //(each work effort will have a list of PCA codes) ViewBag.pcaListOfLists = new List<List<SelectListItem>>(); foreach (var item in workEffortList) { ViewBag.pcaListOfLists.Add(getWePcaCodesSelectList(item)); } //check if an "unable to hide Work Effort error should be displayed" if (TempData["failedHide"] != null) { ViewBag.failedHide = true; } //check if an "unable to delete Work Effort error should be displayed" if (TempData["failedDelete"] != null) { ViewBag.failedDelete = true; } return View(workEffortList); } else { return View("error"); } }