public void ArrivalsReport(string startDate, string endDate)
        {
            var startDateTime = Convert.ToDateTime(startDate);
            var endDateTime = Convert.ToDateTime(endDate);
            var reportManager = new DataAccess.ReportManager();
            var officeManager = new DataAccess.OfficeMananer();
            var offices = officeManager.GetOfficeIDs(IsAdmin ? 0 : UserDetail.UserId);
            var arrivalsReportData = reportManager.GetArrivalAudiences(offices, startDateTime, endDateTime);
            var columnDetails = new List<Utilities.ExcelExport.ColumnDetail>();
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Week Ending", Value = "EndDate", Type = "dateformat", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "FSM Name", Value = "FSMDetailName", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Name of Selected Person", Value = "PeopleName", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Continent Office", Value = "OfficeName", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Service Selected", Value = "ServiceName", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Date of arrival", Value = "VisitDate", Type = "dateformat", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Arrived", Value = "ArrivalStatus", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "GBS", Value = "GSBAmount", Type = "currencyamount", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Funds", Value = "Amount", Type = "currencyamount", TitleStyle = "header1" });
            var excelDataXML = Utilities.ExcelExport.ExportExcel("People of Arrivals From", columnDetails, arrivalsReportData.Tables[0]);
            string templatePath = "~/ExportTemplate/Excel/Template.xlsx";
            string downloadFilename = string.Format("People of Arrivals From {0} to {1}", startDateTime.ToString("MMM-dd-yyyy"), endDateTime.ToString("MMM-dd-yyyy"));
            try
            {
                OfficeExports.Excel.UpdateWorkbook(excelDataXML, templatePath, downloadFilename, false);
            }
            catch (Exception ex)
            {

            }
        }
        public void OfficeWeeklyCumulativeState(string startDate, string endDate)
        {
            var startDateTime = Convert.ToDateTime(startDate);
            var endDateTime = Convert.ToDateTime(endDate);
            var reportManager = new DataAccess.ReportManager();
            var officeManager = new DataAccess.OfficeMananer();
            var offices = officeManager.GetOfficeIDs(IsAdmin ? 0 : UserDetail.UserId);
            var arrivalsReportData = reportManager.GetOfficeWeeklyCumulativeState(offices, startDateTime, endDateTime);
            var regions = new Dictionary<string, Utilities.ExcelExport.RegionDetail>();

            #region State Report
            var stateColumnDetails = new List<Utilities.ExcelExport.ColumnDetail>();
            stateColumnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Week Ending", Value = "EndDate", Type = "dateformat", TitleStyle = "header1" });
            stateColumnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Office Name", Value = "OfficeName", Type = "string", TitleStyle = "header1" });
            stateColumnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Funds Rised", Value = "FundRaised", Type = "currencyamount", TitleStyle = "header1" });
            stateColumnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "GBS", Value = "GSBAmount", Type = "currencyamount", TitleStyle = "header1" });
            stateColumnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Reaches", Value = "ReachesCount", Type = "string", TitleStyle = "header1" });
            stateColumnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "In Progress", Value = "InProcessCount", Type = "string", TitleStyle = "header1" });
            stateColumnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Booked", Value = "BookedCount", Type = "string", TitleStyle = "header1" });
            stateColumnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Arrivals", Value = "ArrivalCount", Type = "string", TitleStyle = "header1" });
            regions["CumulativeState"] = new Utilities.ExcelExport.RegionDetail { Title = "Week Cumulative State", TitleStyle = "header1", ColumnDetail = stateColumnDetails };
            #endregion

            #region Individual Report
            var columnDetails = new List<Utilities.ExcelExport.ColumnDetail>();
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Week Ending", Value = "EndDate", Type = "dateformat", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "FSM Name", Value = "FSMDetailName", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Name of Selected Person", Value = "PeopleName", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Continent Office", Value = "OfficeName", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Service Selected", Value = "ServiceName", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Date of arrival", Value = "VisitDate", Type = "dateformat", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Arrived", Value = "ArrivalStatus", Type = "string", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "GBS", Value = "GSBAmount", Type = "currencyamount", TitleStyle = "header1" });
            columnDetails.Add(new Utilities.ExcelExport.ColumnDetail { Name = "Funds", Value = "Amount", Type = "currencyamount", TitleStyle = "header1" });

            regions["Booked"] = new Utilities.ExcelExport.RegionDetail { Title = "Booked", TitleStyle = "header1", ColumnDetail = columnDetails };
            regions["InProcess"] = new Utilities.ExcelExport.RegionDetail { Title = "In Process", TitleStyle = "header1", ColumnDetail = columnDetails };
            regions["Reachies"] = new Utilities.ExcelExport.RegionDetail { Title = "Reachies", TitleStyle = "header1", ColumnDetail = columnDetails };
            regions["Arrivals"] = new Utilities.ExcelExport.RegionDetail { Title = "Arrivals", TitleStyle = "header1", ColumnDetail = columnDetails };
            #endregion

            var excelDataXML = Utilities.ExcelExport.ExportExcel("Office Report", regions, arrivalsReportData);
            string templatePath = "~/ExportTemplate/Excel/Template.xlsx";
            string downloadFilename = string.Format("Office Report From {0} to {1}", startDateTime.ToString("MMM-dd-yyyy"), endDateTime.ToString("MMM-dd-yyyy"));
            try
            {
                OfficeExports.Excel.UpdateWorkbook(excelDataXML, templatePath, downloadFilename, false);
            }
            catch (Exception ex)
            {

            }
        }
 private List<dynamic> GetEvents(DateTime startDate, DateTime endDate)
 {
     var eventManager = new DataAccess.EventManager();
     var officeManager = new DataAccess.OfficeMananer();
     var offices = officeManager.GetOfficeIDs(IsAdmin ? 0 : UserDetail.UserId);
     var events = eventManager.GetEvents(offices.ToList(), startDate, endDate);
     return events.Select(model => new
     {
         type = "EVENT",
         id = model.EventId,
         title = model.Name,
         start = model.StartDate.ToString("yyyy-MM-ddThh:mm:ss"),
         end = model.EndDate.ToString("yyyy-MM-ddThh:mm:ss"),
         imageURL = (model.Office == null ? "Content/Images/Common/avatar.png" : Url.Content(model.Office.FileResource.path))
     }).ToList<dynamic>();
 }
        public JsonResult GetAudiences(string startDate, string endDate)
        {
            var startDateTime = Convert.ToDateTime(startDate);
            var endDateTime = Convert.ToDateTime(endDate);
            var officeManager = new DataAccess.OfficeMananer();
            var offices = officeManager.GetOfficeIDs(IsAdmin ? 0 : UserDetail.UserId);
            var audienceManager = new DataAccess.AudienceManager();
            var audiences = audienceManager.GetAudiences(offices.ToList(), startDateTime, endDateTime);
            if (audiences == null) { return Json(new { data = new { } }); }
            var users = audiences.Select(model => new
            {
                ID = model.AudienceID,
                Name = model.Name,
                Contact = model.Contact,
                EmailAddress = model.EmailAddress,
                VisitDate = model.VisitDate.ToString("MMM dd,yyyy"),
                OfficeName = model.Office.Name,
                VisitType = model.VisitType.VisitTypeName,
                EventName = (model.Event == null ? "-" : model.Event.Name),
                ConventionName = (model.Convention == null ? "-" : model.Convention.Name),
                ServiceName = (model.Service == null ? "-" : model.Service.ServiceName),
                Status = (model.VisitType.VisitTypeId == 1) ? "-" : (model.BookingStatus == 1 ? "In Progress" : (model.BookingStatus == 2 ? "Booked" : "Reach")),
                FSMName = model.FSMDetail == null ? " - " : model.FSMDetail.Name,
                Attended = model.IsAttended,
                GSBAmount = model.GSBAmount,
                DonationAmount = model.Amount
            }).ToList();

            return Json(new
            {
                data = users
            });
        }
 public JsonResult GetEvents(string startDate, string endDate)
 {
     var startDateTime = Convert.ToDateTime(startDate);
     var endDateTime = Convert.ToDateTime(endDate);
     var isUpdateEnable = UserDetail.User.Roles.Any(role => new List<int> { 1, 2 }.Contains(role.RoleId));
     var officesManager = new DataAccess.OfficeMananer();
     var eventManager = new DataAccess.EventManager();
     var offices = officesManager.GetOfficeIDs(IsAdmin ? 0 : UserDetail.UserId);
     var events = eventManager.GetEvents(offices.ToList(), startDateTime, endDateTime)
         .Select(modal => new
         {
             id = modal.EventId,
             name = modal.Name,
             startDate = modal.StartDate.ToString("MMM dd,yyyy HH:mm"),
             endDate = modal.EndDate.ToString("MMM dd,yyyy HH:mm"),
             description = modal.Description,
             city = modal.City,
             IsUpdateEnable = isUpdateEnable
         }).ToList();
     return Json(new { data = events });
 }