private void UpdateGridCarrierData() { var totalRow = 0; ViewData["CarrierTypes"] = CarrierTypes; var page = carriedGrid.Pager; var sort = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "CarrierAirLineName" : page.Sidx, page.Sord == "asc"); //IEnumerable<ca> customers = customerServices.GetAll(_customerGrid.SearchCriteria, sort, out totalRow, page.CurrentPage, page.PageSize); var qr = carrierService.GetAll(carriedGrid.SearchCriteria); if (!CurrenUser.IsAdmin()) { qr = qr.Where(x => x.IsHideUser == false); } qr = qr.OrderBy(sort); totalRow = qr.Count(); carriedGrid.Pager.Init(totalRow); if (totalRow == 0) { carriedGrid.Data = new List <CarrierAirLine>(); return; } carriedGrid.Data = carrierService.GetListPager(qr, page.CurrentPage, page.PageSize); }
public ActionResult Index() { long depId = CurrenUser.DeptId ?? 4; if (CurrenUser.IsAdminAndAcct()) { depId = 4; } var currentYear = DateTime.Now.Year; var filter = new PlanFilter() { Id = depId, Year = currentYear }; ViewBag.AllPrograms = programService.GetModelAll(); ViewBag.AllSalse = usersServices.GetAll(x => x.DeptId == depId && x.IsActive == true); var listUserShow = planSaleService.GetAllByUser(CurrenUser, currentYear, depId); var listDeptShow = planSaleService.GetAllDeptList(currentYear, depId); var depList = usersServices.GetSalesDept(); ViewBag.AlldeptSalseList = new SelectList(depList, "Id", "DeptName"); ViewBag.PlanOfDep = listDeptShow; ViewBag.PlanFilter = filter; return(View(listUserShow)); }
public ActionResult SetServiceActive(int id, bool isActive) { if (CurrenUser.IsAdmin()) { servicesType.SetActive(id, isActive); } return(Json("ok", JsonRequestBehavior.AllowGet)); }
public ActionResult SetAreaTrading(long id, bool istrading) { if (CurrenUser.IsAdmin()) { areaService.UpdateTradingArea(id, istrading); } return(Json("ok", JsonRequestBehavior.AllowGet)); }
public ActionResult SetAreaIsSee(long id, bool isChecked) { if (CurrenUser.IsAdmin()) { var cus = areaService.GetById(id); cus.IsSee = isChecked; areaService.Commited(); } return(Json("ok", JsonRequestBehavior.AllowGet)); }
public ActionResult SeteAgentIsHideUser(long id, bool isChecked) { if (CurrenUser.IsAdmin()) { var cus = agentService.GetById(id); cus.IsHideUser = isChecked; agentService.Commited(); } return(Json("ok", JsonRequestBehavior.AllowGet)); }
public ActionResult SetMoveToCrmCustomer(long id, bool isChecked) { if (CurrenUser.IsAdmin()) { var cus = customerServices.GetById(id); cus.IsMove = isChecked; cus.MovedBy = CurrenUser.Id; countryService.Commited(); } return(Json("ok", JsonRequestBehavior.AllowGet)); }
public ActionResult SetLookUser(long id, bool isLook) { var db = followEventService.FindEntity(x => x.Id == id); if (db.IsLook && db.LockById != CurrenUser.DeptId && CurrenUser.IsDepManager() && !CurrenUser.IsAdmin()) { var value = new { Views = "This locked by director. Please contact him for unlock", Title = "Error!", ColumnClass = "col-md-6 col-md-offset-3" }; return(JsonResult(value, true)); } followEventService.Look(id, isLook, CurrenUser); db = followEventService.FindEntity(x => x.Id == id); var view = this.RenderPartialView("_UserFollowItem", db); return(Json(view, JsonRequestBehavior.AllowGet)); }
public ActionResult CalendarView() { ViewData["UserSalesList"] = usersServices.GetAllSales(CurrenUser, false); var current = DateTime.Now; var filter = new EventFilter() { Year = current.Year, Month = current.Month, Sales = 0, OfEvent = null }; ViewBag.filter = filter; var qrEvents = eventService.GetQuery(x => x.DateBegin.Month == current.Month && x.DateBegin.Year == current.Year); if (!CurrenUser.IsDirecter()) { if (CurrenUser.IsDepManager()) { qrEvents = qrEvents.Where(x => x.User.DeptId == CurrenUser.DeptId || (x.CRMCustomer.CRMFollowCusUsers != null && x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == CurrenUser.Id)) || (x.CRMCustomer.CreatedById == CurrenUser.Id) || (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == CurrenUser.Id))); } else { qrEvents = qrEvents.Where(x => x.CreatedById == CurrenUser.Id || (x.CRMCustomer.CRMFollowCusUsers != null && x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == CurrenUser.Id)) || (x.CRMCustomer.CreatedById == CurrenUser.Id) || (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == CurrenUser.Id))); } } var list = qrEvents.ToList(); Session[CALENDAR_SEARCH_MODEL] = filter; return(View(list)); }
private void UpdateGridAgentData() { ViewData["CountryListAgent"] = new SelectList(Countries, "CountryName", "CountryName"); var totalRow = 0; var page = agentGrid.Pager; var sort = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "AgentName" : page.Sidx, page.Sord == "asc"); var qr = agentService.GetAll(agentGrid.SearchCriteria); if (!CurrenUser.IsAdmin()) { qr = qr.Where(x => x.IsHideUser == false); } qr = qr.OrderBy(sort); totalRow = qr.Count(); agentGrid.Pager.Init(totalRow); if (totalRow == 0) { agentGrid.Data = new List <Agent>(); return; } agentGrid.Data = agentService.GetListPager(qr, page.CurrentPage, page.PageSize); }
public ActionResult DeleleUserFollow(long id) { var db = followEventService.FindEntity(x => x.Id == id); if (db != null && !db.IsLook) { followEventService.DeleteToDb(id); if (CurrenUser.Id == db.UserId && CurrenUser.IsStaff()) { var value2 = new { Views = "You have ve leave out this event", Title = "Success!", FormClose = true, }; return(JsonResult(value2, true)); } else { var value = new { Views = "Bạn đã xoá thành công", Title = "Success!", IsRemve = true, TdId = "del_" + id }; return(JsonResult(value, true)); } } else { var result = new CommandResult(false) { ErrorResults = new[] { "Sale is look by owner, you can not leave!" } }; return(JsonResult(result, null, true)); } }
private void UpdateGridAreaData() { var totalRow = 0; var page = areaGrid.Pager; var sort = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "AreaAddress" : page.Sidx, page.Sord == "asc"); var area = new Area(); if (areaGrid.SearchCriteria != null) { area = new Area { AreaAddress = areaGrid.SearchCriteria.AreaAddress, CountryId = areaGrid.SearchCriteria.CountryId, trading_yn = areaGrid.SearchCriteria.IsTrading, }; } var qr = areaService.GetAll(area); if (!CurrenUser.IsAdmin()) { qr = qr.Where(x => x.IsHideUser == false); } qr = qr.OrderBy(sort); totalRow = qr.Count(); areaGrid.Pager.Init(totalRow); List <AreaModel> list = new List <AreaModel>(); if (totalRow == 0) { areaGrid.Data = list; return; } var data = areaService.GetListPager(qr, page.CurrentPage, page.PageSize); list.AddRange(data.Select(db => Mapper.Map <AreaModel>(db))); areaGrid.Data = list; }
private void UpdateGrid(ListEventFilter filter = null) { filter = filter ?? new ListEventFilter(); filter.Sales = filter.Sales ?? 0; bool isEventAction = filter.OfEvent == TypeOfEvent.Events; ViewBag.IsEventAction = isEventAction; var page = _grid.Pager; var sort = new SSM.Services.SortField(string.IsNullOrEmpty(page.Sidx) ? "DateEvent" : page.Sidx, page.Sord == "asc"); var totalRow = 0; var qr = eventService.GetQuery(x => (filter.Sales == 0 || filter.Sales == x.CreatedById || (x.CRMCustomer.CRMFollowCusUsers != null && x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == filter.Sales)) || (x.CRMCustomer.CreatedById == CurrenUser.Id) || (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == filter.Sales)) ) && (filter.Status == CRMEventStatus.All || x.Status == (byte)filter.Status) && (string.IsNullOrEmpty(filter.CustomerName) || x.CRMCustomer.CompanyShortName.Contains(filter.CustomerName) || x.CRMCustomer.CompanyName.Contains(filter.CustomerName))); if (filter.OfEvent.HasValue) { qr = filter.OfEvent == TypeOfEvent.Events ? qr.Where(x => x.IsEventAction == true) : qr.Where(x => x.IsEventAction == false); } if (filter.BeginDate.HasValue) { qr = qr.Where(x => x.DateEvent >= filter.BeginDate); } if (filter.EndDate.HasValue) { qr = qr.Where(x => x.DateEvent.Date <= filter.EndDate); } if (!CurrenUser.IsDirecter() && filter.Sales == 0) { if (CurrenUser.IsDepManager()) { qr = qr.Where(x => x.User.DeptId == CurrenUser.DeptId || (x.CRMCustomer.CRMFollowCusUsers != null && x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == CurrenUser.Id)) || (x.CRMCustomer.CreatedById == CurrenUser.Id) || (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == CurrenUser.Id))); } else { qr = qr.Where(x => x.CreatedById == CurrenUser.Id || (x.CRMCustomer.CRMFollowCusUsers != null && x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == CurrenUser.Id)) || (x.CRMCustomer.CreatedById == CurrenUser.Id) || (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == CurrenUser.Id))); } } qr = qr.OrderByDescending(x => x.DateEvent).ThenBy(sort); totalRow = qr.Count(); var list = eventService.GetListPager(qr, page.CurrentPage, page.PageSize); var listView = list.Select(x => eventService.ToModel(x)).ToList(); _grid.Pager.Init(totalRow); if (totalRow == 0) { _grid.Data = new List <CRMEventModel>(); ViewBag.TotalDisplay = string.Empty; return; } var typeOfEvent = filter.OfEvent == TypeOfEvent.Visited ? "viếng thăm" : "sự kiện"; var finished = list.Count(x => x.Status == (byte)CRMEventStatus.Finished); var follow = list.Count(x => x.Status == (byte)CRMEventStatus.Follow); string display = string.Format(Resources.Resource.CRM_EVENT_LIST_TOTAL, totalRow, typeOfEvent, finished, follow); ViewBag.TotalDisplay = display; _grid.Data = listView; }
public ActionResult CalendarView(string type, EventFilter filter) { ViewData["UserSalesList"] = usersServices.GetAllSales(CurrenUser, false); var currentFilter = (EventFilter)Session[CALENDAR_SEARCH_MODEL]; if (filter.Month == 0) { filter = currentFilter; } var dateOfMonth = new DateTime(filter.Year, filter.Month, 1); if (!filter.Sales.HasValue) { filter.Sales = 0; } switch (type) { case "prev": dateOfMonth = dateOfMonth.AddMonths(-1); break; case "current": dateOfMonth = DateTime.Now; break; case "next": dateOfMonth = dateOfMonth.AddMonths(1); break; } filter.Month = dateOfMonth.Month; filter.Year = dateOfMonth.Year; var qrEvents = eventService.GetQuery(x => (x.DateBegin.Month == filter.Month && x.DateBegin.Year == filter.Year) && (filter.Sales == 0 || (filter.Sales == x.CreatedById || (x.CRMCustomer.CreatedById == filter.Sales) || (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == filter.Sales)))) && (filter.Status == CRMEventStatus.All || x.Status == (byte)filter.Status) && (string.IsNullOrEmpty(filter.CustomerName) || x.CRMCustomer.CompanyShortName.Contains(filter.CustomerName) || x.CRMCustomer.CompanyName.Contains(filter.CustomerName)) ); if (filter.OfEvent.HasValue) { qrEvents = filter.OfEvent == TypeOfEvent.Events ? qrEvents.Where(x => x.IsEventAction == true) : qrEvents.Where(x => x.IsEventAction == false); } if (!CurrenUser.IsDirecter() && filter.Sales == 0) { if (CurrenUser.IsDepManager()) { qrEvents = qrEvents.Where(x => x.User.DeptId == CurrenUser.DeptId || (x.CRMCustomer.CRMFollowCusUsers != null && x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == CurrenUser.Id)) || (x.CRMCustomer.CreatedById == CurrenUser.Id) || (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == CurrenUser.Id))); } else { qrEvents = qrEvents.Where(x => x.CreatedById == CurrenUser.Id || (x.CRMCustomer.CRMFollowCusUsers != null && x.CRMCustomer.CRMFollowCusUsers.Any(f => f.UserId == CurrenUser.Id)) || (x.CRMCustomer.CreatedById == CurrenUser.Id) || (x.CRMFollowEventUsers != null && x.CRMFollowEventUsers.Any(ef => ef.UserId == CurrenUser.Id))); } } var list = qrEvents.ToList(); Session[CALENDAR_SEARCH_MODEL] = filter; ViewBag.filter = filter; return(PartialView("_CalendarModelView", list)); }
private List <PersonalReport> ProcessPersonalMonthlyReports(PlanFilter filter) { ViewBag.PlanFilter = filter; var plans = planMonthService.GetQuery(x => (filter.Month == 0 || x.PlanMonth == filter.Month) && x.PlanYear == filter.Year); switch (filter.SummaryByType) { case SummaryByType.ByUser: plans = plans.Where(x => x.CRMPlanProgMonth.CRMPLanSale.SalesId == filter.Id); var usersList = usersServices.GetAllSales(CurrenUser, false).ToList(); if (CurrenUser.IsAdmin()) { usersList.Add(CurrenUser); } ViewBag.AlldeptSalseList = new SelectList(usersList.OrderBy(x => x.FullName), "Id", "FullName"); break; case SummaryByType.ByDeparment: plans = plans.Where(x => x.CRMPlanProgMonth.CRMPLanSale.Sales.DeptId == filter.Id); ViewBag.AlldeptSalseList = new SelectList(usersServices.GetAllDepartmentActive(CurrenUser), "Id", "DeptName"); break; case SummaryByType.ByOffice: plans = plans.Where(x => x.CRMPlanProgMonth.CRMPLanSale.Sales.ComId == filter.Id); ViewBag.AlldeptSalseList = new SelectList(usersServices.GetCompanies(CurrenUser), "Id", "CompanyName"); break; } var reports = new List <PersonalReport>(); var summary = crmCustomerService.SummarysList(CurrenUser, filter); var totalShipmentExc = summary.Sum(x => x.TotalShippments); //So lo thanh cong var totalSuccessExc = summary.Sum(x => x.SuccessFully); // khach hang moi thanh cong var totalVistedExc = summary.Sum(x => x.TotalVisitedSuccess); //Vieng tham var totaldocdExc = summary.Sum(x => x.TotalDocument); //Bai viet var totalEmailExc = summary.Sum(x => x.TotalFirstSendEmail); //Guid bao gia var hatMonthShipmentExc = 0; //So lo thanh cong var hatMonthSuccessExc = 0; // khach hang moi thanh cong var hatMonthVistedExc = 0; //Vieng tham var hatMonthdocdExc = 0; //Bai viet var hatMonthEmailExc = 0; //Guid bao gia // report for personal monthly if (filter.ReportType == ReportType.Monthly && filter.Month > 0) { var nextTime = new DateTime(filter.Year, filter.Month, 1).AddMonths(1); filter.NextMonth = nextTime.Month; filter.NextYear = nextTime.Year; var cusHatMonth = summary.Where(x => x.CreatedDate <= new DateTime(filter.Year, filter.Month, 15, 23, 59, 59)).ToList(); hatMonthShipmentExc = cusHatMonth.Sum(x => x.TotalShippments); //So lo thanh cong hatMonthSuccessExc = cusHatMonth.Sum(x => x.SuccessFully); // khach hang moi thanh cong hatMonthVistedExc = cusHatMonth.Sum(x => x.TotalVisitedSuccess); //Vieng tham hatMonthdocdExc = cusHatMonth.Sum(x => x.TotalDocument); //Bai viet hatMonthEmailExc = cusHatMonth.Sum(x => x.TotalFirstSendEmail); //Guid bao gia } var planMonths = plans.Where(x => (filter.Month == 0 || x.PlanMonth == filter.Month) && x.PlanYear == filter.Year).ToList(); foreach (var p in planMonths) { var report = new PersonalReport { PlanName = p.CRMPlanProgMonth.CRMPlanProgram.Name, PlanValue = p.PlanValue, Month = p.PlanMonth, Year = p.PlanYear }; if (filter.ReportType == ReportType.Monthly && filter.Month > 0) { var next = planMonthService.FindEntity(x => x.ProgramMonthId == p.Id && x.PlanMonth == filter.NextMonth && filter.NextYear == x.PlanYear); var nextPlan = next != null ? next.PlanValue : 0; report.PlanValueNextMonth = nextPlan; } switch (p.CRMPlanProgMonth.ProgramId) { case 1: report.TotalExc = totalSuccessExc; report.FistExc = hatMonthSuccessExc; report.LastExc = totalSuccessExc - hatMonthSuccessExc; break; case 2: report.TotalExc = totalEmailExc; report.FistExc = hatMonthEmailExc; report.LastExc = totalEmailExc - hatMonthEmailExc; break; case 3: report.TotalExc = totalVistedExc; report.FistExc = hatMonthVistedExc; report.LastExc = totalVistedExc - hatMonthVistedExc; break; case 4: report.TotalExc = totalShipmentExc; report.FistExc = hatMonthShipmentExc; report.LastExc = totalShipmentExc - hatMonthShipmentExc; break; case 5: report.TotalExc = totaldocdExc; report.FistExc = hatMonthdocdExc; report.LastExc = totaldocdExc - hatMonthdocdExc; break; } report.Odds = report.TotalExc - report.PlanValue; reports.Add(report); } ViewBag.PlanMount = plans.ToList(); return(reports); }