@if(TempData["HasWarningMessage"] != null)
{
diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs
index 69c970405..2ad9413df 100644
--- a/Data/Access/SearchDAO.cs
+++ b/Data/Access/SearchDAO.cs
@@ -3128,6 +3128,14 @@ namespace BeWo.Data.Access
private static AbstractCriterion CreateBetweenDateTimesCriterion(DateTime start, DateTime end, string propertyNameStart, string propertyNameEnd)
{
+ /*
+ * Sql für Spalten namens 'StartDate' und 'EndDate':
+ * WHERE
+ * ((start >= StartDate AND end <= StartDate) OR (start <= StartDate AND end >= EndDate))
+ * OR
+ * ((start <= StartDate AND start >= EndDate) OR (start >= StartDate AND end <= EndDate))
+ */
+
var inBetween1 = Restrictions.And(Restrictions.Ge(propertyNameStart, start), Restrictions.Le(propertyNameStart, end));
var inBetween2 = Restrictions.And(Restrictions.Le(propertyNameStart, start), Restrictions.Ge(propertyNameEnd, end));
var inBetween3 = Restrictions.And(Restrictions.Le(propertyNameStart, start), Restrictions.Ge(propertyNameEnd, start));
@@ -3446,10 +3454,11 @@ namespace BeWo.Data.Access
public List
GetConfirmationReceiptSignaturesByServiceRecord(long serviceRecordOid)
{
- var detachedCriteria = DetachedCriteria.For()
- .Add(Subqueries.PropertyIn(nameof(ServiceRecord.Oid), DetachedCriteria.For().SetProjection(Projections.Property(nameof(ServiceRecord.Oid)))));
+ var criteria = CreateCriteria()
+ .CreateAlias(nameof(ConfirmationReceiptSignature.ServiceRecords), "serviceRecord")
+ .Add(Restrictions.Eq("serviceRecord.Oid", serviceRecordOid));
- return null;
+ return criteria.List().ToList();
}
public IList FindEmployeeServiceRecordsForKilometerauswertung(long employeeOid, DateTimeSpan timeSpan)
@@ -3570,5 +3579,22 @@ namespace BeWo.Data.Access
return result;
}
+
+ public bool HasEmployeeSignatureForCustomerInTimeSpan(long customerOid, DateTimeSpan timeSpan)
+ {
+ var startString = timeSpan.StartDate.ToString("yyyy-MM-dd HH:mm:ss");
+ var endString = timeSpan.EndDate.ToString("yyyy-MM-dd HH:mm:ss");
+
+ var sql = $" this_.Oid IN (SELECT ConfirmationReceiptSignatureOid FROM ConfirmationReceiptSignature2ServiceRecord WHERE ServiceRecordOid IN (SELECT Oid FROM ServiceRecord WHERE CustomerOid = {customerOid} AND ((('{startString}' >= StartDate AND '{endString}' <= StartDate) OR ('{startString}' <= StartDate AND '{endString}' >= EndDate)) OR (('{startString}' <= StartDate AND '{startString}' >= EndDate) OR ('{startString}' >= StartDate AND '{endString}' <= EndDate)))))";
+
+ var c = CreateCriteria().Add(Expression.Sql(sql)).List().Any();
+
+ return c;
+ }
+
+ public bool HasEmployeeSignaturesForServiceRecord(long serviceRecordOid)
+ {
+ return GetConfirmationReceiptSignaturesByServiceRecord(serviceRecordOid).Any();
+ }
}
}
diff --git a/Data/Mappings/ConfirmationReceiptSignature.hbm.xml b/Data/Mappings/ConfirmationReceiptSignature.hbm.xml
index d1c99e430..2c5a6bc45 100644
--- a/Data/Mappings/ConfirmationReceiptSignature.hbm.xml
+++ b/Data/Mappings/ConfirmationReceiptSignature.hbm.xml
@@ -12,11 +12,11 @@
-
+
-
+
diff --git a/Model/Changes_2020_09_18_Quittierungsbelegsunterschriften.txt b/Model/Changes_2020_09_18_Quittierungsbelegsunterschriften.txt
index 68a628383..b34d22c30 100644
--- a/Model/Changes_2020_09_18_Quittierungsbelegsunterschriften.txt
+++ b/Model/Changes_2020_09_18_Quittierungsbelegsunterschriften.txt
@@ -15,11 +15,12 @@ CREATE TABLE `confirmationreceiptsignature` (
CONSTRAINT `FK_CONFIRMATIONRECEIPTSIGNATURE2EMPLOYEE` FOREIGN KEY (`EmployeeOid`) REFERENCES `Employee` (`Oid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-CREATE TABLE `confirmationsignature2servicerecord` (
- `ConfirmationSignatureOid` bigint(19) DEFAULT NULL,
+CREATE TABLE `confirmationreceiptsignature2servicerecord` (
+ `ConfirmationReceiptSignatureOid` bigint(19) DEFAULT NULL,
`ServiceRecordOid` bigint(19) DEFAULT NULL,
- KEY `CONFSIG2SERVREC_CONFSIG_FK` (`ConfirmationSignatureOid`),
- CONSTRAINT `FK_CONFSIG2SERVREC_CONFSIG` FOREIGN KEY (`ConfirmationSignatureOid`) REFERENCES `confirmationreceiptsignature` (`Oid`),
+ KEY `CONFSIG2SERVREC_CONFSIG_FK` (`ConfirmationReceiptSignatureOid`),
+ CONSTRAINT `FK_CONFSIG2SERVREC_CONFSIG` FOREIGN KEY (`ConfirmationReceiptSignatureOid`) REFERENCES `confirmationreceiptsignature` (`Oid`),
KEY `CONFSIG2SERVREC_SERVREC_FK` (`ServiceRecordOid`),
CONSTRAINT `FK_CONFSIG2SERVREC_SERVREC` FOREIGN KEY (`ServiceRecordOid`) REFERENCES `servicerecord` (`Oid`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
\ No newline at end of file
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
\ No newline at end of file
diff --git a/Service/Plugins/ServiceRecordValidator.cs b/Service/Plugins/ServiceRecordValidator.cs
index 74f555eca..ce49364aa 100644
--- a/Service/Plugins/ServiceRecordValidator.cs
+++ b/Service/Plugins/ServiceRecordValidator.cs
@@ -447,8 +447,23 @@ namespace BeWo.Service.Plugins
ServiceRecordValidationResultDC resultdc = CheckAbwesenheiten(newServiceRecord, allCustomerRecords, reldc, rd, isGroupRecord);
if (resultdc != null)
result.Add(resultdc);
-
- }
+
+ // 9. Mitarbeiterunterschrift aus dem Mobilklienten prüfen
+ // Für alle Customers, falls Gruppenbuchung
+ //var customer = reldc.SupportConcept.Customer;
+ //if(customer != null)
+ //{
+ // var s = newServiceRecord.Start.Value.GetFirstOfMonth();
+ // var e = s.AddMonths(1).AddDays(-1).MergeDatesByDate(new DateTime(2020, 1, 1, 23, 59, 59));
+
+ // var hasEmployeeSignature = DAOFactory.SearchDAO.HasEmployeeSignatureForCustomerInTimeSpan(customer.CustomerOid, new DateTimeSpan(s, e));
+
+ // if(hasEmployeeSignature)
+ // {
+ // result.Add(new ServiceRecordValidationResultDC {ResultType = ServiceRecordValidationResult.HasEmployeeSignature});
+ // }
+ //}
+ }
return result;
}
@@ -1002,6 +1017,20 @@ namespace BeWo.Service.Plugins
});
}
+ // 2. Prüfe, ob eine Mitarbeiterunterschrift mit diesem Eintrag verknüpft ist
+ //if(serviceRecord.ServiceRecordOid.HasValue)
+ //{
+ // var hasEmployeeSignature = DAOFactory.SearchDAO.HasEmployeeSignaturesForServiceRecord(serviceRecord.ServiceRecordOid.Value);
+
+ // if(hasEmployeeSignature)
+ // {
+ // result.Add(new ServiceRecordValidationResultDC
+ // {
+ // ResultType = ServiceRecordValidationResult.HasEmployeeSignature
+ // });
+ // }
+ //}
+
return result;
}
}
diff --git a/Service/ServiceImplementations/OperationsServiceImp.cs b/Service/ServiceImplementations/OperationsServiceImp.cs
index 8009b16fa..7a965f31e 100644
--- a/Service/ServiceImplementations/OperationsServiceImp.cs
+++ b/Service/ServiceImplementations/OperationsServiceImp.cs
@@ -319,6 +319,22 @@ namespace BeWo.Service.ServiceImplementations
if (srListToDelete.Count > 0)
{
MakeServiceRecordHistoryEntry(srListToDelete, null, StatementType.Delete);
+
+ // ConfirmationReceiptSignatures mit den zu löschenden ServiceRecords suchen und die ServiceRecords aus der Liste entfernen
+ foreach(var item in lOriginals)
+ {
+ if(item.Oid.HasValue)
+ {
+ var confirmationReceiptSignatures = DAOFactory.SearchDAO.GetConfirmationReceiptSignaturesByServiceRecord(item.Oid.Value);
+
+ foreach(var confirmationReceiptSignature in confirmationReceiptSignatures)
+ {
+ confirmationReceiptSignature.ServiceRecords.Remove(item);
+ DAOFactory.GenericDAO.Update(confirmationReceiptSignature);
+ }
+ }
+ }
+
DAOFactory.GenericDAO.Delete(srListToDelete);
}
}
diff --git a/Shared/BeWoEntityEnums.cs b/Shared/BeWoEntityEnums.cs
index f14c9aa69..1f6a17eb2 100644
--- a/Shared/BeWoEntityEnums.cs
+++ b/Shared/BeWoEntityEnums.cs
@@ -518,7 +518,11 @@ namespace BS.Shared
Person_Full_Delete = 171719,
Employee_Full_Delete = 171720,
Employee_Anonymization = 171721,
- Termine_IntervalDelete = 171722
+ Termine_IntervalDelete = 171722,
+
+ ServiceRecord_AllowCreateAfterEmployeeSignature = 171723,
+ ServiceRecord_AllowEditAfterEmployeeSignature = 171724,
+ ServiceRecord_AllowDeleteAfterEmployeeSignature = 171725
}
public enum PersonType
@@ -789,7 +793,8 @@ namespace BS.Shared
Error = 5,
SettlementInvoiceAlreadyExisting = 6,
FristAbgelaufen = 7,
- Custom = 8
+ Custom = 8,
+ HasEmployeeSignature = 9
}
public enum ViewDestination
diff --git a/Shared/Core/EnumTranslations.cs b/Shared/Core/EnumTranslations.cs
index 0d82a3a61..2e39e0813 100644
--- a/Shared/Core/EnumTranslations.cs
+++ b/Shared/Core/EnumTranslations.cs
@@ -631,8 +631,16 @@ namespace BS.Shared.Core
,
{
UserRightType.Termine_IntervalDelete, Translator.Translate("Termine bis zum angegebenen Zeitpunkt löschen")
+ },
+ {
+ UserRightType.ServiceRecord_AllowCreateAfterEmployeeSignature, Translator.Translate("Zeiterfassung anlegen nach Mitarbeiterunterschrift für Quittierungsbeleg")
+ },
+ {
+ UserRightType.ServiceRecord_AllowEditAfterEmployeeSignature, Translator.Translate("Zeiterfassung bearbeiten nach Mitarbeiterunterschrift für Quittierungsbeleg")
+ },
+ {
+ UserRightType.ServiceRecord_AllowDeleteAfterEmployeeSignature, Translator.Translate("Zeiterfassung löschen nach Mitarbeiterunterschrift für Quittierungsbeleg")
}
-
};
#endregion