Ejemplo n.º 1
0
        public IActionResult StatusReport(int statusId)
        {
            if (User.Identity.Name == null)
            {
                return(RedirectToAction("Index", "NotFound"));
            }
            else
            {
                StatusReportViewModel viewModel = new StatusReportViewModel();
                viewModel.Orders = new List <Order>();
                viewModel.Status = new Status();
                if (statusId == 0)
                {
                    viewModel.Orders.AddRange(ordersService.GetOrders());
                    viewModel.Status = new Status();
                    return(View(viewModel));
                }
                else
                {
                    viewModel.Orders.AddRange(ordersService.GetOrders().Where(o => o.StatusId == statusId));
                    if (viewModel.Orders.Count() > 0)
                    {
                        viewModel.Status = viewModel.Orders.FirstOrDefault().Status;
                    }
                    else
                    {
                        viewModel.Status = new Status();
                    }

                    return(View(viewModel));
                }
            }
        }
Ejemplo n.º 2
0
        protected override void Load()
        {
            base.Load();

            ConnectHelper.SyncData();

            if (!HasValidLicense())
            {
                return;
            }

            var settingsRepository = GetInstance <ISettingsRepository <WorkshopSettings> >();
            var workshopSettings   = settingsRepository.GetWorkshopSettings();

            if (workshopSettings.IsStatusReportCheckEnabled)
            {
                var allTechnicians = GetInstance <IRepository <Technician> >().Where(c => c.Deleted == null).ToList();
                var statusReport   = new StatusReportViewModel(allTechnicians);
                if (!statusReport.IsUpToDate())
                {
                    if (ShowWarning(Resources.TXT_INFO_OUT_OF_DATE, Resources.TXT_OUT_OF_DATE_TITLE, MessageBoxButton.YesNo))
                    {
                        statusReport.GenerateStatusReport();
                        workshopSettings.CentreQuarterlyCheckDate = DateTime.Now.Date;
                        settingsRepository.Save(workshopSettings);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static int CalculateScore(StatusReportViewModel statusReport)
        {
            var centreQuarterlyStatus = statusReport.TachoCentreQuarterlyStatus.GetInflatedScore();
            var gv212Status           = statusReport.GV212Status.GetInflatedScore();

            int technicianScore = 0;

            foreach (var technician in statusReport.Technicians)
            {
                technicianScore += technician.HalfYearStatus().GetScore();
                technicianScore += technician.ThreeYearStatus().GetScore();
            }

            var technicianMaxScore = statusReport.Technicians.Count * 4;
            var maxScore           = 10 + technicianMaxScore;
            var actualScore        = centreQuarterlyStatus + gv212Status + technicianMaxScore;
            var scorePercentage    = (100 * maxScore) / actualScore;

            if (statusReport.Technicians.Any(c => c.ThreeYearStatus() == ReportItemStatus.Expired || c.ThreeYearStatus() == ReportItemStatus.Unknown))
            {
                if (scorePercentage > 75)
                {
                    return(75);
                }
            }

            return(scorePercentage);
        }
Ejemplo n.º 4
0
        public static string Create(StatusReportViewModel viewModel)
        {
            var directory = Directory.CreateDirectory(Path.Combine(ImageHelper.GetTemporaryDirectory(), "Status Report " + DateTime.Now.Date.ToString("ddMMyyyy")));

            var resources = new[]
            {
                new { ResourceName = "bootstrap_css", FileName = "bootstrap.min.css" },
                new { ResourceName = "bootstrap_js", FileName = "bootstrap.min.js" },
                new { ResourceName = "chart_js", FileName = "Chart.min.js" },
                new { ResourceName = "gauge_js", FileName = "gauge.min.js" },
                new { ResourceName = "jquery_js", FileName = "jquery.min.js" },
                new { ResourceName = "style_css", FileName = "style.css" },
                new { ResourceName = "print_css", FileName = "print.css" },
            };

            foreach (var resource in resources)
            {
                var data = LocalizationHelper.GetResourceManager().GetObject(resource.ResourceName.Replace("-", "_"), CultureInfo.CurrentUICulture);
                if (data != null)
                {
                    File.WriteAllText(Path.Combine(directory.FullName, resource.FileName), data.ToString());
                }
            }

            var logo = ImageHelper.LoadFromResourcesAsByteArray("webcal");

            File.WriteAllBytes(Path.Combine(directory.FullName, "webcal.png"), logo);

            var path = Path.Combine(directory.FullName, "index.html");

            File.WriteAllText(path, GetMarkup(viewModel));
            return(path);
        }
Ejemplo n.º 5
0
        protected override void Initialize()
        {
            var userSEttingsSErvice   = Container.Resolve <IUserSettingsService>();
            var statusReportView      = new StatusReportView.StatusReportView();
            var statusReportViewModel = new StatusReportViewModel(userSEttingsSErvice);

            statusReportView.ViewModel = statusReportViewModel;

            MasterView = statusReportView;
        }
Ejemplo n.º 6
0
        private static void CreateMonthlyGV212Table(PDFDocument document, StatusReportViewModel statusReport)
        {
            AbsolutePositionText(document, Resources.TXT_STATUS_REPORT_MONTHLY_GV_212, 325, document.Height - 80, 425, 35, document.GetRegularFont(true, true), Element.ALIGN_LEFT);

            AbsolutePositionText(document, Resources.TXT_STATUS_REPORT_GENERATED_AND_PRINTED, 325, document.Height - 100, 425, 35, document.GetRegularFont(true), Element.ALIGN_LEFT);
            AbsolutePositionText(document, Resources.TXT_STATUS_REPORT_STATUS, 450, document.Height - 100, 550, 35, document.GetRegularFont(true), Element.ALIGN_LEFT);

            string statusText;
            var    color = GetStatus(statusReport.GV212Status, out statusText);

            AbsolutePositionText(document, statusReport.GV212LastCheck == null ? string.Empty : statusReport.GV212LastCheck.Value.ToString(Constants.ShortYearDateFormat), 325, document.Height - 120, 500, 35, document.GetRegularFont(false, color), Element.ALIGN_LEFT);
            AbsolutePositionText(document, statusText, 450, document.Height - 120, 625, 35, document.GetRegularFont(false, color), Element.ALIGN_LEFT);
        }
Ejemplo n.º 7
0
        private static string GetColorForScore(StatusReportViewModel statusReport)
        {
            var score = CalculateScore(statusReport);

            if (score <= 50)
            {
                return("#E40213");
            }
            if (score > 50 && score <= 75)
            {
                return("#FF8C00");
            }
            if (score > 75)
            {
                return("#006400");
            }
            return("#E40213");
        }
Ejemplo n.º 8
0
        public static StatusReportViewModel GenerateStatusReport(StatusReportData data, List <StatusReportUserViewModel> users)
        {
            var result = new StatusReportViewModel(data.Technicians, data.WorkshopSettings, users)
            {
                Performance = new List <StatusReportTechnician>()
            };

            GetTechniciansPerformanceData(data, result);

            result.LineChartLabels = data.Last12Months.Select(c => c.ToString("MMM yy")).ToList();

            string tachoCentreQuarterlyStatusText;

            result.TachoCentreQuarterlyStatusTextColor = "#" + GetStatus(result.TachoCentreQuarterlyStatus, out tachoCentreQuarterlyStatusText);
            result.TachoCentreQuarterlyStatusText      = tachoCentreQuarterlyStatusText;

            string gv212StatusText;

            result.GV212StatusTextColor = "#" + GetStatus(result.GV212Status, out gv212StatusText);
            result.GV212StatusText      = gv212StatusText;

            return(result);
        }
Ejemplo n.º 9
0
        private static void GetTechniciansPerformanceData(StatusReportData data, StatusReportViewModel result)
        {
            var technicianViewModels = data.Technicians.Select(c => new TechnicianViewModel(data.Documents, data.Last12Months, c)).ToList();

            for (var index = 0; index < technicianViewModels.Count; index++)
            {
                var technician = technicianViewModels[index];

                string halfYearStatusText;
                var    halfYearColor = GetStatus(technician.HalfYearStatus(), out halfYearStatusText);

                string threeYearStatusText;
                var    threeYearColor = GetStatus(technician.ThreeYearStatus(), out threeYearStatusText);

                string statusTextColor;
                var    statusText = GetStatusText(halfYearStatusText, threeYearStatusText, out statusTextColor);

                result.Performance.Add(new StatusReportTechnician
                {
                    Value              = technician.JobsDoneInLast12Months,
                    Color              = GetColor(index),
                    Label              = technician.Technician.Name.ToTitleCase(),
                    DateOfNextCheck    = technician.DateOfLastCheck == null ? (DateTime?)null : technician.DateOfLastCheck.GetValueOrDefault().AddMonths(6),
                    TrainingDateExpiry = technician.DateOfLast3YearCheck == null ? (DateTime?)null : technician.DateOfLast3YearCheck.GetValueOrDefault().AddYears(3),
                    StatusColor        = "#" + halfYearColor,
                    ThreeYearColor     = "#" + threeYearColor,
                    Status             = statusText
                });
            }

            result.LineChartData = new List <int>();
            foreach (var month in data.Last12Months)
            {
                var count = technicianViewModels.Sum(technicianViewModel => technicianViewModel.JobsMonthByMonth.First(d => d.Key == month).Value);
                result.LineChartData.Add(count);
            }
        }
Ejemplo n.º 10
0
        private void CheckGV212Status()
        {
            if (!HasValidLicense())
            {
                return;
            }

            var settingsRepository = GetInstance <ISettingsRepository <WorkshopSettings> >();
            var workshopSettings   = settingsRepository.GetWorkshopSettings();

            if (workshopSettings.IsGV212CheckEnabled && workshopSettings.MonthlyGV212Date != null)
            {
                var statusReport = new StatusReportViewModel();
                if (statusReport.IsGV212Due() && GV212ReportHelper.HasDataForThisMonth())
                {
                    IsGV212OutOfDate = true;
                }
                else
                {
                    IsGV212OutOfDate = false;
                }
                GV212ButtonVisibility = Visibility.Visible;
            }
        }
Ejemplo n.º 11
0
 public IActionResult StatusesReport(StatusReportViewModel viewModel)
 {
     return(RedirectToAction("StatusReport", "Report", new { statusId = viewModel.Status.StatusId }));
 }
Ejemplo n.º 12
0
        private static string GetMarkup(StatusReportViewModel statusReport)
        {
            var workshopSettings = ContainerBootstrapper.Resolve <ISettingsRepository <WorkshopSettings> >().GetWorkshopSettings();

            string tachoCentreQuarterlyStatusText;
            var    tachoCentreQuarterlyStatusTextColor = GetStatus(statusReport.TachoCentreQuarterlyStatus, out tachoCentreQuarterlyStatusText);

            string gv212StatusText;
            var    gv212StatusTextColor = GetStatus(statusReport.GV212Status, out gv212StatusText);

            var centreLastCheck = statusReport.TachoCentreLastCheck.GetValueOrDefault();

            var tachoRepository = ContainerBootstrapper.Resolve <TachographDocumentRepository>();
            var last12Months    = GetLast12Months();
            var from            = last12Months.First();
            var to        = last12Months.Last().AddMonths(1).AddDays(-1);
            var documents = tachoRepository.Where(c => c.Created >= from && c.Created <= to)
                            .Select(c => new ReportDocumentViewModel
            {
                Technician = c.Technician,
                Created    = c.Created
            })
                            .ToList();

            var technicians = statusReport.Technicians.Select(c => new TechnicianViewModel(documents, last12Months, c)).ToList();

            var stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("<!DOCTYPE html>" +
                                     "<html lang=\"en\">" +
                                     "<head>" +
                                     "    <meta charset=\"UTF-8\">" +
                                     "    <title>Webcal Status Report</title>" +
                                     "    <link href=\"bootstrap.min.css\" rel=\"stylesheet\">" +
                                     "    <link href=\"style.css\" rel=\"stylesheet\" />" +
                                     "    <link href=\"print.css\" media=\"print\" rel=\"stylesheet\" />" +
                                     "</head>" +
                                     "<body>" +
                                     "    <div class=\"container\">" +
                                     "        <div class=\"row\">" +
                                     "            <div class=\"col-xs-12\">" +
                                     "                <img src=\"webcal.png\" alt=\"Skillray Transport Services Ltd\" class=\"logo\" />" +
                                     "            </div>" +
                                     "        </div>" +
                                     "        <div class=\"row\">" +
                                     "            <div class=\"col-xs-6 contact-details section\">" +
                                     "                <address>");

            if (!string.IsNullOrEmpty(workshopSettings.WorkshopName))
            {
                stringBuilder.AppendLine("                    <h2>" + workshopSettings.WorkshopName + "</h2>");
            }
            if (!string.IsNullOrEmpty(workshopSettings.Address1))
            {
                stringBuilder.AppendLine("                    " + workshopSettings.Address1 + ",<br/>");
            }
            if (!string.IsNullOrEmpty(workshopSettings.Address2))
            {
                stringBuilder.AppendLine("                    " + workshopSettings.Address2 + ",<br/>");
            }
            if (!string.IsNullOrEmpty(workshopSettings.Address3))
            {
                stringBuilder.AppendLine("                    " + workshopSettings.Address3 + ",<br/>");
            }
            if (!string.IsNullOrEmpty(workshopSettings.Town))
            {
                stringBuilder.AppendLine("                    " + workshopSettings.Town + ",<br/>");
            }
            if (!string.IsNullOrEmpty(workshopSettings.PostCode))
            {
                stringBuilder.AppendLine("                    " + workshopSettings.PostCode + ",<br/>");
            }

            stringBuilder.AppendLine("                    <br/></br>");

            if (!string.IsNullOrEmpty(workshopSettings.PhoneNumber))
            {
                stringBuilder.AppendLine("                    <strong>Phone: </strong>" + workshopSettings.PhoneNumber);
            }

            var score     = CalculateScore(statusReport);
            var statusMsg = score <= 50 ? "Urgent Attention Needed" : score > 50 && score <= 75 ? "Few Outstanding Documents" : score > 75 ? "OK" : "";

            stringBuilder.AppendLine("                </address>" +
                                     "            </div>" +
                                     "            <div class=\"col-xs-6 gauge section\">" +
                                     "                <h2>Overall Status</h2>");

            //Centre quarterly check
            stringBuilder.AppendLine("                 <div class=\"traffic-light-container\"><div class=\"traffic-light\">" +
                                     "                     <div class=\"light-outer\">" +
                                     "                       <div class=\"first-light-decorate\"></div>" +
                                     "                       <div class=\"light-inner\"> " +
                                     "                         <div class=\"light " + (tachoCentreQuarterlyStatusText == Resources.TXT_STATUS_REPORT_EXPIRED || tachoCentreQuarterlyStatusText == Resources.TXT_STATUS_REPORT_UNKNOWN ? "red": "") + "\"></div>" +
                                     "                       </div>" +
                                     "                       <div class=\"light-left-top-shade\"></div>" +
                                     "                       <div class=\"light-left-bottom-shade\"></div>" +
                                     "                       <div class=\"light-right-top-shade\"></div>" +
                                     "                       <div class=\"light-right-bottom-shade\"></div>" +
                                     "                     </div>" +
                                     "                     <div class=\"light-outer\">" +
                                     "                       <div class=\"light-inner\">  " +
                                     "                         <div class=\"light " + (tachoCentreQuarterlyStatusText == Resources.TXT_STATUS_REPORT_CHECK_DUE ? "yellow" : "") + "\"></div>" +
                                     "                       </div>" +
                                     "                       <div class=\"light-left-top-shade\"></div>" +
                                     "                       <div class=\"light-left-bottom-shade\"></div>" +
                                     "                       <div class=\"light-right-top-shade\"></div>" +
                                     "                       <div class=\"light-right-bottom-shade\"></div>" +
                                     "                     </div>" +
                                     "                     <div class=\"light-outer\">" +
                                     "                       <div class=\"light-inner\"> " +
                                     "                         <div class=\"light " + (tachoCentreQuarterlyStatusText == Resources.TXT_STATUS_REPORT_ok ? "green" : "") + "\"></div>" +
                                     "                       </div>" +
                                     "                       <div class=\"light-left-top-shade\"></div>" +
                                     "                       <div class=\"light-left-bottom-shade\"></div>" +
                                     "                       <div class=\"light-right-top-shade\"></div>" +
                                     "                       <div class=\"light-right-bottom-shade\"></div>" +
                                     "                     </div>" +
                                     "                   </div></div>");

            //Monthly GV212
            stringBuilder.AppendLine("                 <div class=\"traffic-light-container\"><div class=\"traffic-light\">" +
                                     "                     <div class=\"light-outer\">" +
                                     "                       <div class=\"first-light-decorate\"></div>" +
                                     "                       <div class=\"light-inner\"> " +
                                     "                         <div class=\"light " + (gv212StatusText == Resources.TXT_STATUS_REPORT_EXPIRED || gv212StatusText == Resources.TXT_STATUS_REPORT_UNKNOWN ? "red" : "") + "\"></div>" +
                                     "                       </div>" +
                                     "                       <div class=\"light-left-top-shade\"></div>" +
                                     "                       <div class=\"light-left-bottom-shade\"></div>" +
                                     "                       <div class=\"light-right-top-shade\"></div>" +
                                     "                       <div class=\"light-right-bottom-shade\"></div>" +
                                     "                     </div>" +
                                     "                     <div class=\"light-outer\">" +
                                     "                       <div class=\"light-inner\">  " +
                                     "                         <div class=\"light " + (gv212StatusText == Resources.TXT_STATUS_REPORT_CHECK_DUE ? "yellow" : "") + "\"></div>" +
                                     "                       </div>" +
                                     "                       <div class=\"light-left-top-shade\"></div>" +
                                     "                       <div class=\"light-left-bottom-shade\"></div>" +
                                     "                       <div class=\"light-right-top-shade\"></div>" +
                                     "                       <div class=\"light-right-bottom-shade\"></div>" +
                                     "                     </div>" +
                                     "                     <div class=\"light-outer\">" +
                                     "                       <div class=\"light-inner\"> " +
                                     "                         <div class=\"light " + (gv212StatusText == Resources.TXT_STATUS_REPORT_ok ? "green" : "") + "\"></div>" +
                                     "                       </div>" +
                                     "                       <div class=\"light-left-top-shade\"></div>" +
                                     "                       <div class=\"light-left-bottom-shade\"></div>" +
                                     "                       <div class=\"light-right-top-shade\"></div>" +
                                     "                       <div class=\"light-right-bottom-shade\"></div>" +
                                     "                     </div>" +
                                     "                   </div></div>");

            var techExpired = statusReport.Technicians.Any(c => c.ThreeYearStatus() == ReportItemStatus.Expired || c.ThreeYearStatus() == ReportItemStatus.Unknown);
            var techOk      = statusReport.Technicians.All(c => c.ThreeYearStatus() == ReportItemStatus.Ok);
            var techDue     = statusReport.Technicians.All(c => c.ThreeYearStatus() == ReportItemStatus.CheckDue);

            //Technicians QC report
            stringBuilder.AppendLine("                 <div class=\"traffic-light-container\"><div class=\"traffic-light\">" +
                                     "                     <div class=\"light-outer\">" +
                                     "                       <div class=\"first-light-decorate\"></div>" +
                                     "                       <div class=\"light-inner\"> " +
                                     "                         <div class=\"light " + (techExpired ? "red" : "") + "\"></div>" +
                                     "                       </div>" +
                                     "                       <div class=\"light-left-top-shade\"></div>" +
                                     "                       <div class=\"light-left-bottom-shade\"></div>" +
                                     "                       <div class=\"light-right-top-shade\"></div>" +
                                     "                       <div class=\"light-right-bottom-shade\"></div>" +
                                     "                     </div>" +
                                     "                     <div class=\"light-outer\">" +
                                     "                       <div class=\"light-inner\">  " +
                                     "                         <div class=\"light " + (techDue ? "yellow" : "") + "\"></div>" +
                                     "                       </div>" +
                                     "                       <div class=\"light-left-top-shade\"></div>" +
                                     "                       <div class=\"light-left-bottom-shade\"></div>" +
                                     "                       <div class=\"light-right-top-shade\"></div>" +
                                     "                       <div class=\"light-right-bottom-shade\"></div>" +
                                     "                     </div>" +
                                     "                     <div class=\"light-outer\">" +
                                     "                       <div class=\"light-inner\"> " +
                                     "                         <div class=\"light " + (techOk ? "green" : "") + "\"></div>" +
                                     "                       </div>" +
                                     "                       <div class=\"light-left-top-shade\"></div>" +
                                     "                       <div class=\"light-left-bottom-shade\"></div>" +
                                     "                       <div class=\"light-right-top-shade\"></div>" +
                                     "                       <div class=\"light-right-bottom-shade\"></div>" +
                                     "                     </div>" +
                                     "                   </div></div>");
            stringBuilder.AppendLine(
                "<div style=\"padding-bottom: 5px; border-bottom: 1px solid #e2e2e2; margin-bottom: 5px;\">" +
                "<div style=\"width: 100px; display: inline-block; margin-left: 50px;\">QC</div>" +
                "<div style=\"width: 120px; display: inline-block;\">3 month check</div>" +
                "<div style=\"width: 100px; display: inline-block; margin-right: 75px;\">Training date</div>" +
                "</div>"
                );
            stringBuilder.AppendLine("                <p>" + statusMsg + "</p>" +
                                     "            </div>" +
                                     "            <div class=\"col-xs-6 piechart section\">" +
                                     "                <h2>Technician Performance</h2>" +
                                     "                <div>" +
                                     "                    <canvas id=\"piechart\"></canvas>" +
                                     "                    <div id=\"js-legend\" class=\"chart-legend\"></div>" +
                                     "                </div>" +
                                     "            </div>" +
                                     "            <div class=\"col-xs-6 bar section\">" +
                                     "                <h2>Jobs Completed</h2>" +
                                     "                <canvas id=\"barchart\" height=\"230\" width=\"350\"></canvas>" +
                                     "            </div>" +
                                     "        </div>" +
                                     "        <div class=\"row checks\">" +
                                     "            <div class=\"col-xs-6\">" +
                                     "                <h3>Centre Quarterly Check</h3>" +
                                     "                <table class=\"table table-striped table-hover\">" +
                                     "                    <thead>" +
                                     "                        <tr>" +
                                     "                            <th>Date of last check</th>" +
                                     "                            <th>Date of next check</th>" +
                                     "                            <th>Status</th>" +
                                     "                        </tr>" +
                                     "                    </thead>" +
                                     "                    <tbody>" +
                                     "                        <tr>" +
                                     "                            <td><span style=\"color:#" + tachoCentreQuarterlyStatusTextColor + ";\">" + centreLastCheck.ToString(Constants.ShortYearDateFormat) + "</span></td>" +
                                     "                            <td><span style=\"color:#" + tachoCentreQuarterlyStatusTextColor + ";\">" + centreLastCheck.AddMonths(3).Date.ToString(Constants.ShortYearDateFormat) + "</span></td>" +
                                     "                            <td><span style=\"color:#" + tachoCentreQuarterlyStatusTextColor + ";\">" + tachoCentreQuarterlyStatusText + "</span></td>" +
                                     "                        </tr>" +
                                     "                    </tbody>" +
                                     "                </table>" +
                                     "            </div>" +
                                     "            <div class=\"col-xs-6\">" +
                                     "                <h3>Monthly GV212</h3>" +
                                     "                <table class=\"table table-striped table-hover\">" +
                                     "                    <thead>" +
                                     "                        <tr>" +
                                     "                            <th>Generated and printed</th>" +
                                     "                            <th>Status</th>" +
                                     "                        </tr>" +
                                     "                    </thead>" +
                                     "                    <tbody>" +
                                     "                        <tr>" +
                                     "                            <td><span style=\"color:#" + gv212StatusTextColor + ";\">" + statusReport.GV212LastCheck.GetValueOrDefault().ToString(Constants.ShortYearDateFormat) + "</span></td>" +
                                     "                            <td><span style=\"color:#" + gv212StatusTextColor + ";\">" + gv212StatusText + "</span></td>" +
                                     "                        </tr>" +
                                     "                    </tbody>" +
                                     "                </table>" +
                                     "            </div>" +
                                     "        </div>" +
                                     "        <div class=\"row\">" +
                                     "            <div class=\"col-xs-12\">" +
                                     "                <h3>Technicians QC Report</h3>" +
                                     "                <table class=\"table table-striped table-hover\">" +
                                     "                    <thead>" +
                                     "                        <tr>" +
                                     "                            <th>Technician Name</th>" +
                                     "                            <th>Date Of Next Check</th>" +
                                     "                            <th>Training Date Expiry</th>" +
                                     "                            <th>Status</th>" +
                                     "                        </tr>" +
                                     "                    </thead>" +
                                     "                    <tbody>");

            foreach (var technician in statusReport.Technicians)
            {
                string statusText;
                var    color = GetStatus(technician.HalfYearStatus(), out statusText);

                string threeYearStatusText;
                var    threeYearColor = GetStatus(technician.ThreeYearStatus(), out threeYearStatusText);

                string statusTextColor;
                var    blah = GetStatusText(statusText, threeYearStatusText, out statusTextColor);

                stringBuilder.AppendLine("                        <tr>" +
                                         "                            <td><span style=\"color:#" + color + ";\">" + technician.Name + "</span></td>" +
                                         "                            <td><span style=\"color:#" + color + ";\">" + technician.DateOfLastCheck.GetValueOrDefault().AddMonths(6).ToString(Constants.ShortYearDateFormat) + "</span></td>" +
                                         "                            <td><span style=\"color:#" + threeYearColor + ";\">" + technician.DateOfLast3YearCheck.GetValueOrDefault().AddYears(3).ToString(Constants.ShortYearDateFormat) + "</span></td>" +
                                         "                            <td><span style=\"color:#" + statusTextColor + ";\">" + blah + "</span></td>" +
                                         "                        </tr>");
            }

            stringBuilder.AppendLine("                    </tbody>" +
                                     "                </table>" +
                                     "            </div>" +
                                     "        </div>" +
                                     "    </div>" +
                                     "    <script src=\"jquery.min.js\"></script>" +
                                     "    <script src=\"bootstrap.min.js\"></script>" +
                                     "    <script type=\"text/javascript\" src=\"Chart.min.js\"></script>" +
                                     "    <script type=\"text/javascript\" src=\"gauge.min.js\"></script>" +
                                     "    <script>" +
                                     "        $(function () {" +
                                     "            var data = [");

            for (var i = 0; i < technicians.Count; i++)
            {
                var technician = technicians[i];
                stringBuilder.AppendLine("                {" +
                                         "                    value: " + technician.JobsDoneInLast12Months + "," +
                                         "                    color: \"" + GetColor(i) + "\"," +
                                         "                    label: \"" + technician.Technician.Name.ToTitleCase() + "\"" +
                                         "                },");
            }

            stringBuilder.AppendLine("                ];" +
                                     "            var ctx = document.getElementById(\"piechart\").getContext(\"2d\");" +
                                     "            var myChart = new Chart(ctx).Pie(data, {" +
                                     "                legendTemplate: \"<ul class=\\\"<%=name.toLowerCase()%>-legend\\\"><% for (var i=0; i<segments.length; i++){%><li><span style=\\\"background-color:<%=segments[i].fillColor%>\\\"></span><%if(segments[i].label){%><%=segments[i].label%> (<%=segments[i].value%>)<%}%></li><%}%></ul>\"," +
                                     "                title: {" +
                                     "                    text: 'Sales MTD'," +
                                     "                    subtitle: 'test'," +
                                     "                    position: 'top-center'" +
                                     "                }" +
                                     "            });" +
                                     "            document.getElementById('js-legend').innerHTML = myChart.generateLegend();" +
                                     "            var opts = {" +
                                     "                lines: 12," +
                                     "                angle: 0.15," +
                                     "                lineWidth: 0.44," +
                                     "                pointer: {" +
                                     "                    length: 0.9, " +
                                     "                    strokeWidth: 0.035," +
                                     "                    color: '#000000' " +
                                     "                }," +
                                     "                limitMax: 'false', " +
                                     "                colorStart: '" + GetColorForScore(statusReport) + "', " +
                                     "                colorStop: '" + GetColorForScore(statusReport) + "', " +
                                     "                strokeColor: '#E0E0E0', " +
                                     "                generateGradient: true" +
                                     "            };" +
                                     "            var data = {" +
                                     "                labels: [");

            foreach (var month in last12Months)
            {
                stringBuilder.AppendLine("\"" + month.ToString("MMM yy") + "\",");
            }

            stringBuilder.AppendLine("]," +
                                     "                datasets: [" +
                                     "                    {" +
                                     "                        label: \"Jobs Completed\"," +
                                     "                        fillColor: \"#09355C\"," +
                                     "                        strokeColor: \"rgba(220,220,220,0.8)\"," +
                                     "                        highlightFill: \"rgba(220,220,220,0.75)\"," +
                                     "                        highlightStroke: \"rgba(220,220,220,1)\"," +
                                     "                        data: [");

            foreach (var month in last12Months)
            {
                var count = technicians.Sum(technicianViewModel => technicianViewModel.JobsMonthByMonth.First(d => d.Key == month).Value);
                stringBuilder.Append(count + ",");
            }

            stringBuilder.AppendLine("]" +
                                     "                    }" +
                                     "                ]" +
                                     "            };" +
                                     "            var ctx = document.getElementById(\"barchart\").getContext(\"2d\");" +
                                     "            new Chart(ctx).Bar(data, {" +
                                     "                barShowStroke: false" +
                                     "            });" +
                                     "        });" +
                                     "    </script>" +
                                     "</body>" +
                                     "</html>");

            return(stringBuilder.ToString());
        }
Ejemplo n.º 13
0
        private static void CreateTachoCentreQuarterlyCheckTable(PDFDocument document, StatusReportViewModel statusReport)
        {
            AddImageFromResource(document, "skillray_small", 61, 770);
            AddImageFromResource(document, "webcal_print_logo", 325, 770);

            AbsolutePositionText(document, Resources.TXT_STATUS_REPORT_CENTRE_QUARTERLY_CHECK, 61, document.Height - 80, 300, 35, document.GetRegularFont(true, true), Element.ALIGN_LEFT);

            AbsolutePositionText(document, Resources.TXT_STATUS_REPORT_DATE_OF_LAST_CHECK, 61, document.Height - 100, 261, 35, document.GetRegularFont(true), Element.ALIGN_LEFT);
            AbsolutePositionText(document, Resources.TXT_STATUS_REPORT_DATE_OF_NEXT_CHECK, 141, document.Height - 100, 341, 35, document.GetRegularFont(true), Element.ALIGN_LEFT);
            AbsolutePositionText(document, Resources.TXT_STATUS_REPORT_STATUS, 221, document.Height - 100, 421, 35, document.GetRegularFont(true), Element.ALIGN_LEFT);

            string statusText;
            var    color = GetStatus(statusReport.TachoCentreQuarterlyStatus, out statusText);

            if (statusReport.TachoCentreLastCheck != null)
            {
                var lastCheck = statusReport.TachoCentreLastCheck.GetValueOrDefault();
                var nextCheck = lastCheck.AddMonths(3).Date;
                AbsolutePositionText(document, lastCheck.ToString(Constants.ShortYearDateFormat), 61, document.Height - 120, 261, 35, document.GetRegularFont(false, color), Element.ALIGN_LEFT);
                AbsolutePositionText(document, nextCheck.ToString(Constants.ShortYearDateFormat), 141, document.Height - 120, 341, 35, document.GetRegularFont(false, color), Element.ALIGN_LEFT);
            }

            AbsolutePositionText(document, statusText, 661, document.Height - 120, 221, 35, document.GetRegularFont(false, color), Element.ALIGN_LEFT);
        }
Ejemplo n.º 14
0
 public static void Create(PDFDocument document, StatusReportViewModel statusReport)
 {
     CreateTachoCentreQuarterlyCheckTable(document, statusReport);
     CreateMonthlyGV212Table(document, statusReport);
     CreateTechniciansQuarterlyTable(document, statusReport.Technicians);
 }
Ejemplo n.º 15
0
        public static void GenerateStatusReport(this StatusReportViewModel statusReport)
        {
            var path = Web.StatusReport.Create(statusReport);

            Process.Start(path);
        }
Ejemplo n.º 16
0
        private void OnGenerateStatusReport(object obj)
        {
            var statusReport = new StatusReportViewModel(Technicians);

            statusReport.GenerateStatusReport();
        }