diff --git a/BeWo/Scheduler/Converter/AptToServRecsIconVisibilityConverter.cs b/BeWo/Scheduler/Converter/AptToServRecsIconVisibilityConverter.cs index 6790251df..6b697b730 100644 --- a/BeWo/Scheduler/Converter/AptToServRecsIconVisibilityConverter.cs +++ b/BeWo/Scheduler/Converter/AptToServRecsIconVisibilityConverter.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Linq; using System.Windows; using System.Windows.Data; +using BeWo.Scheduler.ViewModel; using BS.Shared.DataContracts; namespace BeWo.Scheduler.Converter @@ -12,9 +13,9 @@ namespace BeWo.Scheduler.Converter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if(value is List serviceRecordList) + if(value is CustomFieldStorage customFieldStorage) { - return serviceRecordList.Any() ? Visibility.Visible : Visibility.Collapsed; + return customFieldStorage.ServiceRecordList.Any() || customFieldStorage.HasServiceRecordEntry ? Visibility.Visible : Visibility.Collapsed; } return Visibility.Collapsed; diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml b/BeWo/Scheduler/View/NewSchedulerView.xaml index d92d815eb..f871a3633 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml @@ -149,7 +149,7 @@ @@ -279,7 +279,7 @@ @@ -307,7 +307,7 @@ diff --git a/BeWo/View/HomeView.xaml.cs b/BeWo/View/HomeView.xaml.cs index 20581bb5b..1c94644b7 100644 --- a/BeWo/View/HomeView.xaml.cs +++ b/BeWo/View/HomeView.xaml.cs @@ -2376,7 +2376,7 @@ namespace BeWo.View { if(value is SchedulerAppointmentDC appointment) { - return appointment.ServiceRecordList.Any() ? Visibility.Visible : Visibility.Collapsed; + return appointment.HasServiceRecordEntry || appointment.ServiceRecordList.Any() ? Visibility.Visible : Visibility.Collapsed; } return Visibility.Collapsed; diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj b/BeWoPlanerMobil/BeWoPlanerMobil.csproj index 5212d421f..98b1aae69 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj @@ -198,11 +198,13 @@ + + @@ -25467,6 +25469,8 @@ + + diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user b/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user index 2e25948f0..b9aa0bdbd 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user @@ -15,7 +15,7 @@ root/Common/MVC/Controller 600 False - False + True False diff --git a/BeWoPlanerMobil/Controllers/AbstractBaseController.cs b/BeWoPlanerMobil/Controllers/AbstractBaseController.cs index 57cc8f524..c7ce27cea 100644 --- a/BeWoPlanerMobil/Controllers/AbstractBaseController.cs +++ b/BeWoPlanerMobil/Controllers/AbstractBaseController.cs @@ -22,6 +22,7 @@ namespace BeWoPlanerMobil.Controllers protected readonly IUserService UserService = new MobileSessionFacade().UserService; protected readonly IDownloadService DownloadService = new MobileSessionFacade().DownloadService; protected readonly IReportService ReportService = new MobileSessionFacade().ReportService; + protected readonly IQueryService QueryService = new MobileSessionFacade().QueryService; protected const string LeerzeichenFuerGetMethoden = " "; diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index 752a6db5c..a4f19fe38 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -24,7 +24,6 @@ using BS.Shared.Services; using DevExpress.XtraScheduler; using DevExpress.XtraScheduler.Compatibility; using Newtonsoft.Json; -using NHibernate.Criterion; using static BS.Shared.ServiceRecordValidationResult; using FormCollection = System.Web.Mvc.FormCollection; using ServiceRecordDC = BS.Shared.DataContracts.ServiceRecordDC; @@ -2490,6 +2489,12 @@ namespace BeWoPlanerMobil.Controllers return AbstractModel.IsAllowedToSeeBills ? RedirectToActionPermanent("InitReports", "Report") : RedirectToMain(); } + [Authorize] + public ActionResult RedirectToReportViewer() + { + return RedirectToActionPermanent("ReportViewer", "ReportViewer"); + } + public ActionResult RedirectToMain() { return RedirectToActionPermanent("Main", "Main"); diff --git a/BeWoPlanerMobil/Controllers/ReportViewerController.cs b/BeWoPlanerMobil/Controllers/ReportViewerController.cs new file mode 100644 index 000000000..faa7ad753 --- /dev/null +++ b/BeWoPlanerMobil/Controllers/ReportViewerController.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Web.Mvc; +using BeWoPlanerMobil.Models; +using BeWoPlanerMobil.Service; +using BeWoPlanerMobil.Util; +using BS.Shared; + +namespace BeWoPlanerMobil.Controllers +{ + public class ReportViewerController : AbstractBaseController + { + private ReportViewerModel _Model; + + public ReportViewerModel Model + { + get + { + if(!MobileSessionFacade.IsUserLoggedIn()) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + + if(((ReportViewerModel)Session[ModelSessionConstants.ReportViewerModelKey])?.Employee is null) + { + _Model = new ReportViewerModel { Employee = MobileSessionFacade.LoggedInEmployee }; + Session[ModelSessionConstants.ReportViewerModelKey] = _Model; + } + else + { + _Model = (ReportViewerModel)Session[ModelSessionConstants.ReportViewerModelKey]; + } + + return _Model; + } + } + + + public ActionResult ReportViewer() + { + var month = DateTime.Today.Month; + var year = DateTime.Today.Year; + var first = new DateTime(year, month, 1).AddMonths(-1); + + Model.SelectedYear = Model.SelectedYear ?? first.Year; + Model.SelectedMonth = Model.SelectedMonth ?? first.Month; + + Model.AllEmployees = EmployeeService.GetActiveCompactEmployeesForEmployee(MobileSessionFacade.LoggedInCompactEmployee.EmployeeOid); + Model.AllTeams = EmployeeService.GetAllActiveCompactTeamsForEmployee(MobileSessionFacade.LoggedInEmployee.EmployeeOid); + + Model.ReportTypes = new List + { + new SelectListItem + { + Text = "Berichte", + Value = "0" + }, + new SelectListItem + { + Text = "Mitarbeiterstundenkonto", + Value = "1" + } + }; + + Model.SelectedReportType = ReportType.Berichte; + + Model.Queries = QueryService.GetAllQueriesOfType(QueryType.Public); + + + return View(Model); + } + + [Authorize] + public ActionResult DocumentViewerPartial() + { + return PartialView("DocumentWebViewerPartial", Model); + } + + [Authorize] + public ActionResult ExportDocumentViewer() + { + throw new NotImplementedException("Service dafür implementieren!"); + } + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Models/AbstractModel.cs b/BeWoPlanerMobil/Models/AbstractModel.cs index 19a8b6337..8a15994ec 100644 --- a/BeWoPlanerMobil/Models/AbstractModel.cs +++ b/BeWoPlanerMobil/Models/AbstractModel.cs @@ -20,7 +20,7 @@ namespace BeWoPlanerMobil.Models public static bool HasRightForGroupBookings => CheckRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking); - public static bool HasRightToViewCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAlleAnsehen) && CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.ViewAll); + public static bool HasRightToViewCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAlleAnsehen) || CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers) || CheckRight(UserRightType.Customer_ViewMyTeams); public static bool HasRightToViewEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAnsehen) || CheckRight(UserRightType.ViewAll); public static bool HasRightToViewAllResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnsehen) || CheckRight(UserRightType.ViewAll); diff --git a/BeWoPlanerMobil/Models/ReportViewerModel.cs b/BeWoPlanerMobil/Models/ReportViewerModel.cs new file mode 100644 index 000000000..9db004110 --- /dev/null +++ b/BeWoPlanerMobil/Models/ReportViewerModel.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Web.Mvc; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using DevExpress.XtraReports.UI; + +namespace BeWoPlanerMobil.Models +{ + public class ReportViewerModel : AbstractModel + { + public List AllEmployees { get; set; } + public List AllTeams { get; set; } + public List Queries { get; set; } + + + [Display(Name = "Monat")] + public int? SelectedMonth { get; set; } + public List Months + { + get + { + var result = new List(); + + for(var i = 1; i < 13; i++) + { + result.Add(new SelectListItem + { + Value = i.ToString(), + Text = new DateTime(DateTime.Now.Year, i, 1).ToString("MMMM") + }); + } + + return result; + } + } + + + [Display(Name = "Jahr")] + public int? SelectedYear { get; set; } + public List Years + { + get + { + var result = new List(); + + for(var i = DateTime.Today.Year; i > DateTime.Today.Year - 11; i--) + { + result.Add(new SelectListItem + { + Value = i.ToString(), + Text = i.ToString() + }); + } + + return result; + } + } + + + [Display(Name="Bericht")] + public ReportType SelectedReportType { get; set; } + public List ReportTypes { get; set; } + + + [Display(Name = "Bericht")] + public long? SelectedCustomReport { get; set; } + public List CustomReports + { + get + { + var result = new List(); + + if(Queries is null) + { + return result; + } + + foreach(var query in Queries) + { + result.Add(new SelectListItem { Text = query.Title, Value = query.Oid.ToString() }); + } + + return result; + } + } + + + [Display(Name="Mitarbeiter")] + public long? SelectedEmployeeOid { get; set; } + public List Employees + { + get + { + var result = new List(); + + if(AllEmployees is null) + { + return result; + } + + foreach(var employee in AllEmployees) + { + result.Add(new SelectListItem { Text = employee.SimpleDescription, Value = employee.EmployeeOid.ToString() }); + } + + return result; + } + } + + + [Display(Name = "Team")] + public long? SelectedTeamOid { get; set; } + public List Teams + { + get + { + var result = new List(); + + if(AllTeams is null) + { + return result; + } + + foreach(var team in AllTeams) + { + result.Add(new SelectListItem { Text = team.Name, Value = team.TeamOid.ToString() }); + } + + return result; + } + } + + + + + + + public XtraReport Report { get; set; } + } + + public enum ReportType + { + Berichte = 0, + Mitarbeiterstundenkonto = 1 + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Service/MobileSessionFacade.cs b/BeWoPlanerMobil/Service/MobileSessionFacade.cs index b87a7c237..7fafcc657 100644 --- a/BeWoPlanerMobil/Service/MobileSessionFacade.cs +++ b/BeWoPlanerMobil/Service/MobileSessionFacade.cs @@ -29,6 +29,7 @@ namespace BeWoPlanerMobil.Service UserService = new UserServiceImp(); DownloadService = new DownloadServiceImp(); ReportService = new ReportServiceImp(); + QueryService = new QueryServiceImp(); } public ICustomerService CustomerService { get; } @@ -40,6 +41,7 @@ namespace BeWoPlanerMobil.Service public IUserService UserService { get; } public IDownloadService DownloadService { get; } public IReportService ReportService { get; } + public IQueryService QueryService { get; } public static ApplicationUser LoggedInUser { diff --git a/BeWoPlanerMobil/Views/ReportViewer/DocumentWebViewerPartial.cshtml b/BeWoPlanerMobil/Views/ReportViewer/DocumentWebViewerPartial.cshtml new file mode 100644 index 000000000..8caf22bb1 --- /dev/null +++ b/BeWoPlanerMobil/Views/ReportViewer/DocumentWebViewerPartial.cshtml @@ -0,0 +1,12 @@ + +@model BeWoPlanerMobil.Models.ReportViewerModel + +@Html.DevExpress().DocumentViewer(settings =>{ + // The following settings are required for a Document Viewer. + settings.Name = "documentViewer1"; + settings.Report = Model.Report; + // Callback and export route values specify corresponding controllers and their actions. + // These settings are also required. + settings.CallbackRouteValues = new { Controller="ReportViewer", Action="DocumentWebViewerPartial" }; + settings.ExportRouteValues = new { Controller="ReportViewer", Action="ExportDocumentWebViewer" }; +}).GetHtml() \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/ReportViewer/ReportViewer.cshtml b/BeWoPlanerMobil/Views/ReportViewer/ReportViewer.cshtml new file mode 100644 index 000000000..62bf3e619 --- /dev/null +++ b/BeWoPlanerMobil/Views/ReportViewer/ReportViewer.cshtml @@ -0,0 +1,131 @@ +@using BeWoPlanerMobil.Models +@model BeWoPlanerMobil.Models.ReportViewerModel + + + + + +
+
+
+
+
+ @Html.DropDownListFor(model => model.SelectedReportType, Model.ReportTypes, new { @class = "custom-select" }) +
+
+
+
+
+ @if(Model.SelectedReportType == ReportType.Berichte) + { + @Html.DropDownListFor(model => model.SelectedCustomReport, Model.CustomReports, new { @class = "custom-select", id = "customReportSelect" }); + } + + @if(Model.SelectedReportType == ReportType.Mitarbeiterstundenkonto) + { + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+ + + + +
+ } +
+
+
+
+ @if(!(Model.Report is null)) + { + @Html.Partial("DocumentWebViewerPartial", Model); + } +
+
+
\ No newline at end of file diff --git a/BeWoPlanerMobil/Views/Scheduler/CustomerFilterSelectionPartial.cshtml b/BeWoPlanerMobil/Views/Scheduler/CustomerFilterSelectionPartial.cshtml index 18204ccd8..c675019a6 100644 --- a/BeWoPlanerMobil/Views/Scheduler/CustomerFilterSelectionPartial.cshtml +++ b/BeWoPlanerMobil/Views/Scheduler/CustomerFilterSelectionPartial.cshtml @@ -95,7 +95,7 @@ } -@if(AbstractModel.HasRightToViewCustomerAppointments && Model.AllCustomers.Any()) +@if(AbstractModel.HasRightToViewCustomerSelectionInScheduler && Model.AllCustomers.Any()) {