Exemple #1
0
        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);
        }
Exemple #2
0
 public ActionResult SetServiceActive(int id, bool isActive)
 {
     if (CurrenUser.IsAdmin())
     {
         servicesType.SetActive(id, isActive);
     }
     return(Json("ok", JsonRequestBehavior.AllowGet));
 }
Exemple #3
0
 public ActionResult SetAreaTrading(long id, bool istrading)
 {
     if (CurrenUser.IsAdmin())
     {
         areaService.UpdateTradingArea(id, istrading);
     }
     return(Json("ok", JsonRequestBehavior.AllowGet));
 }
Exemple #4
0
 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));
 }
Exemple #5
0
 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));
 }
Exemple #6
0
 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));
 }
Exemple #7
0
        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);
        }
Exemple #8
0
        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;
        }
Exemple #9
0
        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));
        }
Exemple #10
0
        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);
        }