internal static DMPieChartParentModel ApplyGraphForItems(DMPieChartParentModel vm, UserGraphType userGraphType, VMAttendanceDashboard vmAttendanceDashboard) { switch (userGraphType) { case UserGraphType.HasMultipleCommonOU: vm.HeaderRight = "Common Organizational Units"; vm.TBLHeaderID = "OUCommonID"; vm.TBLHeaderName = "Common Organization Units"; if (vm.TBLHeaderCount == null) { vm.TBLHeaderCount = "No. Of Employees"; } if (vmAttendanceDashboard.ID == 0) { vm = GetDataForPieChartCommonOU(vm.AttData, vm); } else { vm = GetDataForPieChartCommonOU(vm.AttData.Where(aa => aa.OUCommonID == vmAttendanceDashboard.ID).ToList(), vm); } break; case UserGraphType.HasMultipleOU: vm.HeaderRight = "Organizational Units"; vm.TBLHeaderID = "OUID"; vm.TBLHeaderName = "Organization Units"; if (vm.TBLHeaderCount == null) { vm.TBLHeaderCount = "No. Of Employees"; } if (vmAttendanceDashboard.ID == 0) { vm = GetDataForPieChartOU(vm.AttData, vm); } else { vm = GetDataForPieChartOU(vm.AttData.Where(aa => aa.OUCommonID == vmAttendanceDashboard.ID).ToList(), vm); } break; case UserGraphType.SimpleLM: vm.HeaderRight = "Employee"; vm.TBLHeaderID = "EmpID"; vm.TBLHeaderName = "Employee Name"; vm.TBLHeaderCount = "No. Of Days"; if (vmAttendanceDashboard.ID == 0) { vm = GetDataForPieChartEmployee(vm.AttData, vm); } else { vm = GetDataForPieChartEmployee(vm.AttData.Where(aa => aa.OUID == vmAttendanceDashboard.ID).ToList(), vm); } break; } return(vm); }
// Gnereate Bar Chart based upon values stored in session public ActionResult LoadPieChart() { VMAttendanceDashboard vmDashboard = Session["VMATDashboard"] as VMAttendanceDashboard; dateS = vmDashboard.StartDate; dateE = vmDashboard.EndDate; DMPieChartParentModel vm = new DMPieChartParentModel(); VMLoggedUser LoggedInUser = Session["LoggedInUser"] as VMLoggedUser; List <VAT_DailyAttendance> AttList = new List <VAT_DailyAttendance>(); // Apply User Access Role if (LoggedInUser.UserAccessTypeID == 1) // Normal { List <VHR_EmployeeProfile> emps = EmployeeLM.GetReportingEmployees(VHREmployeeProfileService.GetIndex(), LoggedInUser); string query = QueryBuilder.GetReportQueryForLoggedUser(LoggedInUser, emps); if (query != "") { query = " and " + query; } DataTable dataTable = QueryBuilder.GetValuesfromDB("select * from VAT_DailyAttendance where (AttDate >= " + "'" + vmDashboard.StartDate.ToString("yyyy-MM-dd") + "'" + " and AttDate <= " + "'" + vmDashboard.EndDate.ToString("yyyy-MM-dd") + "'" + " ) " + query); AttList = dataTable.ToList <VAT_DailyAttendance>(); } else if (LoggedInUser.UserAccessTypeID == 2) // Location Access { foreach (var item in LoggedInUser.UserLoctions) { Expression <Func <VAT_DailyAttendance, bool> > SpecificEntries = c => c.AttDate >= dateS && c.AttDate <= dateE && c.LocationID == item.LocationID; AttList.AddRange(VATDailyAttendanceService.GetIndexSpecific(SpecificEntries)); } } else if (LoggedInUser.UserAccessTypeID == 3) // All { Expression <Func <VAT_DailyAttendance, bool> > SpecificEntries = c => c.AttDate >= dateS && c.AttDate <= dateE; AttList = VATDailyAttendanceService.GetIndexSpecific(SpecificEntries); } else if (LoggedInUser.UserAccessTypeID == 4) // Department { foreach (var item in LoggedInUser.UserDepartments) { Expression <Func <VAT_DailyAttendance, bool> > SpecificEntries = c => c.AttDate >= dateS && c.AttDate <= dateE && c.OUCommonID == item.DepartmentID; AttList.AddRange(VATDailyAttendanceService.GetIndexSpecific(SpecificEntries)); } } //Filter based on Graph Type vm = DashboardManager.ApplyGraphTypeItems(vm, AttList, vmDashboard.GraphType); // Filter based on Graph For vm = DashboardManager.ApplyGraphForItems(vm, vmDashboard.UserGraphType, vmDashboard); if (vm.ChildList != null && vm.ChildList.Count() > 0) { return(PartialView("RenderPieChart", vm)); } else { return(Json("OK", JsonRequestBehavior.AllowGet)); } }
internal static DMPieChartParentModel ApplyGraphTypeItems(DMPieChartParentModel vm, List <VAT_DailyAttendance> AttList, string graphType) { switch (graphType) { case "LateIn": vm.HeaderLeft = "Late In Percentage"; vm.TBLHeaderCount = "Late Arrivals"; AttList = AttList.Where(aa => aa.LateIn > 0).ToList(); break; case "LateOut": vm.HeaderLeft = "Late Out Percentage"; vm.TBLHeaderCount = "Late Departures"; AttList = AttList.Where(aa => aa.LateOut > 0).ToList(); break; case "EarlyIn": vm.HeaderLeft = "Early In Detail Percentage"; vm.TBLHeaderCount = "Early Arrivals"; AttList = AttList.Where(aa => aa.EarlyIn > 0).ToList(); break; case "EarlyOut": vm.HeaderLeft = "Early Out Detail Percentage"; vm.TBLHeaderCount = "Early Departures"; AttList = AttList.Where(aa => aa.EarlyOut > 0).ToList(); break; case "Absent": vm.HeaderLeft = "Absent Detail Percentage"; vm.TBLHeaderCount = "Total Days"; AttList = AttList.Where(aa => aa.AbDays > 0).ToList(); break; case "Leave": vm.HeaderLeft = "Leaves Detail Percentage"; vm.TBLHeaderCount = "Total Days"; AttList = AttList.Where(aa => aa.LeaveDays > 0).ToList(); break; case "OfficialDuty": vm.HeaderLeft = "Official Duty Detail Percentage"; vm.TBLHeaderCount = "Total Days"; AttList = AttList.Where(aa => aa.TimeIn == null && aa.TimeOut == null && aa.Remarks != null && aa.Remarks.Contains("JC:")).ToList(); break; } vm.AttData = AttList; return(vm); }
internal static DMPieChartParentModel GetDataForPieChartEmployee(List <VAT_DailyAttendance> AttList, DMPieChartParentModel vm) { if (AttList.Count > 0) { vm.HeaderRight = "Employees for " + AttList.FirstOrDefault().OUName; vm.HeaderDescription = "Click on below employee to view its details"; List <DMParentModel> dmList = new List <DMParentModel>(); foreach (var id in AttList.Select(aa => aa.EmpID).Distinct().ToList()) { if (AttList.Where(aa => aa.EmpID == id).Count() > 0) { DMParentModel dmObj = new DMParentModel(); dmObj.ID = (int)id; dmObj.NameWithDetail = AttList.Where(aa => aa.EmpID == id).First().EmployeeName + " (" + AttList.Where(aa => aa.EmpID == id).First().JobTitleName + ")"; dmObj.Name = AttList.Where(aa => aa.EmpID == id).First().EmployeeName; dmObj.Count = AttList.Where(aa => aa.EmpID == id).Count(); dmList.Add(dmObj); } } vm.ChildList = dmList.OrderByDescending(aa => aa.Count).ToList(); } return(vm); }
internal static DMPieChartParentModel GetDataForPieChartCommonOU(List <VAT_DailyAttendance> AttList, DMPieChartParentModel vm) { if (AttList.Count > 0) { vm.HeaderRight = "Common Organizational Units"; vm.HeaderDescription = "Click on below common organizational unit to view its details"; List <DMParentModel> dmList = new List <DMParentModel>(); foreach (var id in AttList.Select(aa => aa.OUCommonID).Distinct().ToList()) { if (AttList.Where(aa => aa.OUCommonID == id).Count() > 0 && id != null) { DMParentModel dmObj = new DMParentModel(); dmObj.ID = (int)id; dmObj.Name = AttList.Where(aa => aa.OUCommonID == id).First().OUCommonName; dmObj.NameWithDetail = AttList.Where(aa => aa.OUCommonID == id).First().OUCommonName; dmObj.Count = AttList.Where(aa => aa.OUCommonID == id).Count(); dmList.Add(dmObj); } } vm.ChildList = dmList.OrderByDescending(aa => aa.Count).ToList(); } return(vm); }