test 2
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
using System.Windows.Forms;
|
||||
using BeWo.Service.Plugins;
|
||||
using BeWo.Service.ServiceImplementations;
|
||||
using BeWo.View.Navigation.Filter;
|
||||
using BeWoPlanerMobil.Models;
|
||||
@@ -21,6 +22,7 @@ using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.Extensions;
|
||||
using BS.Shared.Services;
|
||||
using Newtonsoft.Json;
|
||||
using NHibernate.Criterion;
|
||||
using static BS.Shared.ServiceRecordValidationResult;
|
||||
using FormCollection = System.Web.Mvc.FormCollection;
|
||||
using ServiceRecordDC = BS.Shared.DataContracts.ServiceRecordDC;
|
||||
@@ -98,6 +100,7 @@ namespace BeWoPlanerMobil.Controllers
|
||||
|
||||
Model.ShowExpiredSupportConcepts = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.ShowExpiredSupportConcepts);
|
||||
Model.ShowOnlyOwnSupportConcepts = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.ShowOnlyMySupportConcepts);
|
||||
Model.IsOnlyYearMonthVisible = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.IsOnlyYearMonthVisible);
|
||||
|
||||
InitializeInterval(userSettings);
|
||||
|
||||
@@ -1492,14 +1495,7 @@ namespace BeWoPlanerMobil.Controllers
|
||||
long? cb2ScOid = Convert.ToInt64(formCollection[FormCollectionConstants.CostBearer2SupportConceptOidKey]);
|
||||
Log.Info($"SelectSupportConcept: {cb2ScOid}");
|
||||
|
||||
LoadServiceCategoriesToModel(cb2ScOid);
|
||||
|
||||
LoadRecordsToModel();
|
||||
|
||||
LoadGoalRatings();
|
||||
|
||||
// ToDo: Hier LoadGoals aufrufen!
|
||||
LoadGoals();
|
||||
LoadSupportConceptThings(cb2ScOid);
|
||||
|
||||
return ResetEditingMode();
|
||||
}
|
||||
@@ -3002,6 +2998,160 @@ namespace BeWoPlanerMobil.Controllers
|
||||
return LeerzeichenFuerGetMethoden;
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
public void LoadSupportConceptThings(long? cb2ScOid)
|
||||
{
|
||||
if(Model is null)
|
||||
{
|
||||
Logout();
|
||||
return;
|
||||
}
|
||||
|
||||
LoadServiceCategoriesToModel(cb2ScOid);
|
||||
|
||||
LoadRecordsToModel();
|
||||
|
||||
LoadGoalRatings();
|
||||
|
||||
LoadGoals();
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
public ActionResult PrepareServiceRecordInsert()
|
||||
{
|
||||
if(Model is null)
|
||||
{
|
||||
return Logout();
|
||||
}
|
||||
|
||||
// Nach dem Speichern das SchedulerAppointmentDC-Objekt updaten!
|
||||
if(TempData["AppointmentListItem"] is AppointmentListItem appointmentListItem && Model.Employee.EmployeeOid.HasValue)
|
||||
{
|
||||
var appointment = appointmentListItem.SchedulerAppointment;
|
||||
|
||||
var start = appointment.StartDate;
|
||||
var end = appointment.EndDate;
|
||||
var customerOids = appointment.CustomerList.Select(customer => customer.CustomerOid).ToList();
|
||||
var employeeOids = appointment.EmployeeList.Select(e2a => e2a.Employee.EmployeeOid).ToList();
|
||||
var notice = appointment.Description;
|
||||
|
||||
if(start is null || end is null)
|
||||
{
|
||||
// ToDo: Fehler anzeigen!
|
||||
return View("Main", Model);
|
||||
}
|
||||
|
||||
var customerService = PluginLoader.FindClass<CustomerService>();
|
||||
var supportConcepts = customerService.GetAllActiveSupportConceptCostbearer(false, true, Model.Employee.EmployeeOid.Value);
|
||||
supportConcepts = supportConcepts.Where(sc => customerOids.Contains(sc.Customer.CustomerOid) && sc.StartDate.HasValue && sc.EndDate.HasValue && start.Value.AreInBetweenDates(end.Value, sc.StartDate.Value, sc.EndDate.Value)).ToList();
|
||||
|
||||
var supportConceptList = new List<CompactSupportConceptDC>();
|
||||
|
||||
foreach(var customerOid in customerOids)
|
||||
{
|
||||
var supportConcept = supportConcepts.FirstOrDefault(sc => sc.Customer.CustomerOid.Equals(customerOid));
|
||||
|
||||
if(supportConcept is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
supportConceptList.AddIfNotIn(supportConcept);
|
||||
}
|
||||
|
||||
// ToDo: Hier weitermachen: Update des Termins durchführen. In TempData speichern/belassen und beim Speichern dann Updaten?
|
||||
|
||||
// Ohne Hilfeplan
|
||||
if(supportConceptList.Count == 0)
|
||||
{
|
||||
Model.IsInGroupBookingMode = false;
|
||||
Model.SelectedEmployee = Model.AllEmployees.FirstOrDefault(e => e.EmployeeOid.Equals(Model.Employee.EmployeeOid.Value));
|
||||
|
||||
LoadSupportConceptThings(-2);
|
||||
|
||||
var serviceCategory = Model.ServiceCategories.FirstOrDefault();
|
||||
var serviceDescription = serviceCategory?.ServiceDescriptions.FirstOrDefault();
|
||||
|
||||
if(!(serviceDescription is null))
|
||||
{
|
||||
Model.SelectedServiceCategoryOid = serviceDescription.Category.ServiceCategoryOid;
|
||||
var serviceRecord = CreateServiceRecordFromScratch(start.Value, end.Value, null, Model.SelectedEmployee, notice);
|
||||
serviceRecord.ServiceDescription = serviceDescription;
|
||||
Model.SelectedServiceRecord = serviceRecord;
|
||||
}
|
||||
}
|
||||
// Einzelbuchung
|
||||
|
||||
else if(supportConceptList.Count == 1 && employeeOids.Count == 1)
|
||||
{
|
||||
Model.IsInGroupBookingMode = false;
|
||||
Model.SelectedEmployee = Model.AllEmployees.FirstOrDefault(e => e.EmployeeOid.Equals(Model.Employee.EmployeeOid.Value));
|
||||
|
||||
// ToDo: Beim Wählen des CostBearers den nehmen, der aktiv ist?
|
||||
var compactSupportConcept = supportConceptList.First();
|
||||
var supportConcept = Model.SupportConcepts.FirstOrDefault(f => f.SupportConceptOid.HasValue && f.SupportConceptOid.Value.Equals(compactSupportConcept.SupportConceptOid));
|
||||
|
||||
var serviceRecord = CreateServiceRecordFromScratch(start.Value, end.Value, supportConcept?.Customer, Model.SelectedEmployee, notice);
|
||||
|
||||
var costBearer2SupportConcept = supportConcept.CostBearerRelations.FirstOrDefault();
|
||||
|
||||
|
||||
|
||||
Model.SelectedServiceRecord = serviceRecord;
|
||||
}
|
||||
// Gruppenbuchung
|
||||
else
|
||||
{
|
||||
Model.IsInGroupBookingMode = true;
|
||||
Model.GroupBookingSelectedEmployees = Model.AllEmployees.Where(w => employeeOids.Contains(w.EmployeeOid)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
return View("Main", Model);
|
||||
}
|
||||
|
||||
private ServiceRecordDC CreateServiceRecordFromScratch(DateTime start, DateTime end, CompactCustomerDC customer, CompactEmployeeDC employee, string notice)
|
||||
{
|
||||
var serviceRecord = new ServiceRecordDC
|
||||
{
|
||||
Employee = employee,
|
||||
Customer = customer,
|
||||
Notice = notice,
|
||||
InsertedOn = DateTime.Now,
|
||||
InsUser = employee?.ToString(),
|
||||
IsCreatedInMobileClient = true
|
||||
};
|
||||
|
||||
if(start.Date != end.Date)
|
||||
{
|
||||
serviceRecord.Start = end;
|
||||
serviceRecord.End = end;
|
||||
serviceRecord.RoundedDuration = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceRecord.Start = start;
|
||||
serviceRecord.End = end;
|
||||
serviceRecord.RoundedDuration = (decimal)end.Subtract(start).TotalMinutes;
|
||||
}
|
||||
|
||||
if(Model.IsEndDateVisible)
|
||||
{
|
||||
serviceRecord.ServiceRecordFormat = ServiceRecordFormate.ZeiterfassungMitEndDatum;
|
||||
}
|
||||
else if(Model.IsOnlyYearMonthVisible)
|
||||
{
|
||||
serviceRecord.ServiceRecordFormat = ServiceRecordFormate.ZeiterfassungMitMonatJahr;
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceRecord.ServiceRecordFormat = ServiceRecordFormate.OriginaleZeiterfassung;
|
||||
}
|
||||
|
||||
serviceRecord.DurationInStunden = Model.IsShowingDurationInHours ? ZeiterfassungsDauer.Stunden : ZeiterfassungsDauer.Minuten;
|
||||
|
||||
return serviceRecord;
|
||||
}
|
||||
|
||||
|
||||
#region Mehrfachbuchung
|
||||
|
||||
@@ -1006,5 +1006,50 @@ namespace BeWoPlanerMobil.Controllers
|
||||
|
||||
return LeerzeichenFuerGetMethoden;
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost]
|
||||
public ActionResult TransformAppointmentToServiceRecord(FormCollection formCollection)
|
||||
{
|
||||
if(Model is null)
|
||||
{
|
||||
return Logout();
|
||||
}
|
||||
|
||||
// ToDo Serienausnahme erstellen möglich machen? Wenn ja, dann auch für das Bearbeiten und Löschen.
|
||||
if(Guid.TryParse(formCollection["appointment-id-input"], out var identifier))
|
||||
{
|
||||
var ids = Model.AppointmentListItems.Select(s => s.Identifier).ToList();
|
||||
|
||||
var appointmentListItem = Model.AppointmentListItems.FirstOrDefault(f => f.Identifier.Equals(identifier));
|
||||
|
||||
if(!(appointmentListItem is null))
|
||||
{
|
||||
var appointment = appointmentListItem.SchedulerAppointment;
|
||||
|
||||
var employeeOids = appointment.EmployeeList.Select(e2a => e2a.Employee.EmployeeOid).ToList();
|
||||
if(employeeOids.Count == 0)
|
||||
{
|
||||
employeeOids.Add(appointment.Originator.EmployeeOid);
|
||||
}
|
||||
|
||||
var employeeOids2 = employeeOids.ToArray();
|
||||
|
||||
var customerOids = appointment.CustomerList.Select(c => c.CustomerOid).ToArray();
|
||||
|
||||
var notice = appointment.Description;
|
||||
var start = appointment.StartDate;
|
||||
var end = appointment.EndDate;
|
||||
|
||||
// ToDo: Appointment aktualisieren, bzw. eine Serienausnahme erstellen!
|
||||
|
||||
TempData["AppointmentListItem"] = appointmentListItem;
|
||||
|
||||
return RedirectToActionPermanent("PrepareServiceRecordInsert", "Main");
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToActionPermanent("PrepareServiceRecordInsert", "Main");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,6 +651,8 @@ namespace BeWoPlanerMobil.Models
|
||||
public int SelectedDayCount { get; set; }
|
||||
public NullableDateTimeSpan SelectedZeitraum { get; set; }
|
||||
|
||||
public bool IsOnlyYearMonthVisible { get; set; }
|
||||
|
||||
|
||||
#region Mehrfachbuchung
|
||||
|
||||
|
||||
@@ -19,19 +19,37 @@ namespace BeWoPlanerMobil.Models
|
||||
|
||||
public SchedulerAppointmentDC SelectedAppointment { get; set; }
|
||||
|
||||
public List<SchedulerAppointmentDC> Appointments { get; set; } = new List<SchedulerAppointmentDC>();
|
||||
private List<SchedulerAppointmentDC> _Appointments;
|
||||
|
||||
public List<AppointmentListItem> AppointmentListItems
|
||||
public List<SchedulerAppointmentDC> Appointments
|
||||
{
|
||||
get
|
||||
get => _Appointments ?? (_Appointments = new List<SchedulerAppointmentDC>());
|
||||
|
||||
set
|
||||
{
|
||||
var result = new List<AppointmentListItem>();
|
||||
var oldAppointments = AppointmentListItems.Select(li => li.SchedulerAppointment).ToList();
|
||||
|
||||
Appointments.DoForEach(app => result.AddIfNotIn(new AppointmentListItem(app)));
|
||||
_Appointments = value ?? new List<SchedulerAppointmentDC>();
|
||||
|
||||
return result;
|
||||
if(_Appointments.AreListEqual(oldAppointments))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_AppointmentListItems = new List<AppointmentListItem>();
|
||||
|
||||
foreach(var appointment in _Appointments)
|
||||
{
|
||||
var listItem = new AppointmentListItem(appointment);
|
||||
listItem.GenerateIdentifier(_AppointmentListItems.Select(a => a.Identifier).ToList());
|
||||
|
||||
_AppointmentListItems.Add(listItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<AppointmentListItem> _AppointmentListItems;
|
||||
public List<AppointmentListItem> AppointmentListItems => _AppointmentListItems ?? (_AppointmentListItems = new List<AppointmentListItem>());
|
||||
|
||||
public bool HasRightToEditAppointment(long? appointmentOid)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using BS.Shared.DataContracts;
|
||||
@@ -8,7 +9,7 @@ namespace BeWoPlanerMobil.Util
|
||||
{
|
||||
public class AppointmentListItem
|
||||
{
|
||||
public Guid Identifier { get; }
|
||||
public Guid Identifier { get; private set; }
|
||||
|
||||
public long? Oid { get; }
|
||||
|
||||
@@ -64,10 +65,25 @@ namespace BeWoPlanerMobil.Util
|
||||
|
||||
public bool HasServiceRecord { get; }
|
||||
|
||||
public SchedulerAppointmentDC SchedulerAppointment { get; }
|
||||
|
||||
public void GenerateIdentifier(List<Guid> existingIdentifiers)
|
||||
{
|
||||
var identifier = Guid.NewGuid();
|
||||
while(existingIdentifiers.Contains(identifier))
|
||||
{
|
||||
identifier = Guid.NewGuid();
|
||||
}
|
||||
|
||||
Identifier = identifier;
|
||||
}
|
||||
|
||||
public AppointmentListItem(SchedulerAppointmentDC schedulerAppointment)
|
||||
{
|
||||
Identifier = Guid.NewGuid();
|
||||
|
||||
SchedulerAppointment = schedulerAppointment;
|
||||
|
||||
CanBeEdited = schedulerAppointment.CanBeEdited;
|
||||
|
||||
Oid = schedulerAppointment.SchedulerAppointmentOid;
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
|
||||
function copyToServiceRecord(appointmentOid) {
|
||||
try {
|
||||
|
||||
showSpinner();
|
||||
$("#transformAppToServiceRecForm").submit();
|
||||
} catch(error) {
|
||||
hideSpinner();
|
||||
logError(error);
|
||||
}
|
||||
}
|
||||
@@ -203,12 +205,8 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-primary" onclick="copyToServiceRecord(@appointment.Oid)">
|
||||
<span class="fa-stack ml-2 mr-4" style="display: inline;">
|
||||
<i class="fas fa-sync-alt fa-stack-1x text-secondary"></i>
|
||||
<i class="fas fa-slash fa-stack-1x text-secondary"></i>
|
||||
</span>
|
||||
<span class="fa-stack" style="display: inline;">
|
||||
<button type="button" class="btn btn-bewo-service-records" onclick="copyToServiceRecord(@appointment.Oid)">
|
||||
<span>
|
||||
<i class="fas fa-external-link-alt"></i>
|
||||
<i class="fas fa-clock"></i>
|
||||
</span>
|
||||
@@ -216,6 +214,10 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
using(Html.BeginForm("TransformAppointmentToServiceRecord", "Scheduler", FormMethod.Post, new {id="transformAppToServiceRecForm"}))
|
||||
{
|
||||
<input type="hidden" value="@appointment.Identifier" name="appointment-id-input" />
|
||||
}
|
||||
}
|
||||
<p>@appointment.Description</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user