Files
BeWoPlaner/Queries/Einträge ohne Monatsunterschrift des Klienten.txt
Christian bc48047b3e - Rechnungsformular Prof. Eggers Stiftung
- Klientennamen im Jahresbericht eingebaut
- Bugfix Reports für fehlende Unterschriften
- Bugfix History
2025-03-19 00:58:48 +01:00

36 lines
4.1 KiB
Plaintext

SELECT
p.LastName as 'Nachname',
p.Firstname as 'Vorname',
c2s.ApprovedStartDate as 'Bewilligt von',
c2s.ApprovedEndDate as 'Bewilligt bis',
scat.Name as 'Kategorie',
Date_Format(sr.StartDate, '%d.%m.%Y') as 'Datum',
IF (Date_Format(sr.StartDate, '%s') <> '00', '', Date_Format(sr.StartDate, '%H:%i')) as 'von',
IF (Date_Format(sr.StartDate, '%s') <> '00', '', Date_Format(Date_Add(sr.StartDate, INTERVAL sr.Roundedduration MINUTE), '%H:%i')) as 'bis',
Round(sr.Roundedduration, 0) as 'Minuten',
(select CONCAT(emp1p.`FirstName`, ' ', emp1p.`LastName`) from employee emp1 join `person` emp1p on emp1p.`Oid` = emp1.`PersonOid` where emp1.`Oid` in (select employeeoid from `employee2customer` e2c1 join `valuelistentry2object` vl2o on e2c1.`Oid` = vl2o.`ObjectOid` join `valuelistentry` vle on vl2o.`ValueListEntryOid` = vle.`Oid` where e2c1.`CustomerOid` = c.`Oid` and vle.`SystemEntryID` = 3) LIMIT 1) as 'Hauptbetreuung',
(select t.`Name` from team t where t.`Oid` in (select teamoid from `team2customer` t2c where t2c.`CustomerOid` = c.`Oid`) LIMIT 1) as 'Team'
FROM servicerecord sr
join costbearer2supportconcept c2s on sr.costbearer2supportconceptoid = c2s.oid
join supportconcept sc on c2s.supportconceptoid = sc.oid
join customer c on sc.customeroid = c.oid
join person p on c.personoid = p.oid
join servicedescription sd on sd.oid = sr.servicedescriptionoid
join servicecategory scat on scat.oid = sd.servicecategoryoid
where sr.oid
not in (select servicerecordoid from confirmationreceiptsignature2servicerecord crs2s
join confirmationreceiptsignature crs on crs2s.confirmationreceiptsignatureoid = crs.oid where crs.employeeoid is null and crs.customeroid is not null) and
scat.billable = true and
sr.startdate >= ':Von' and sr.startdate < ':bis'
order by p.Lastname, sr.startdate
INSERT INTO `query` (`Oid`,`Tid`,`Type`,`Title`,`SQL`,`Notice`,`InsTs`,`InsUser`,`UdpUser`,`Version`,`IsActive`,`SystemEntryID`,`UserGroupOids`,`ReportTypeName`,`FileName`,`ExportTitle`) VALUES (4712,24,0,'Einträge ohne Monatsunterschrift des Klienten','SELECT \np.LastName as \'Nachname\',\np.Firstname as \'Vorname\',\nc2s.ApprovedStartDate as \'Bewilligt von\',\nc2s.ApprovedEndDate as \'Bewilligt bis\',\nscat.Name as \'Kategorie\',\nDate_Format(sr.StartDate, \'%d.%m.%Y\') as \'Datum\',\nIF (Date_Format(sr.StartDate, \'%s\') <> \'00\', \'\', Date_Format(sr.StartDate, \'%H:%i\')) as \'von\',\nIF (Date_Format(sr.StartDate, \'%s\') <> \'00\', \'\', Date_Format(Date_Add(sr.StartDate, INTERVAL sr.Roundedduration MINUTE), \'%H:%i\')) as \'bis\',\nRound(sr.Roundedduration, 0) as \'Minuten\',\n(select CONCAT(emp1p.`FirstName`, \' \', emp1p.`LastName`) from employee emp1 join `person` emp1p on emp1p.`Oid` = emp1.`PersonOid` where emp1.`Oid` in (select employeeoid from `employee2customer` e2c1 join `valuelistentry2object` vl2o on e2c1.`Oid` = vl2o.`ObjectOid` join `valuelistentry` vle on vl2o.`ValueListEntryOid` = vle.`Oid` where e2c1.`CustomerOid` = c.`Oid` and vle.`SystemEntryID` = 3) LIMIT 1) as \'Hauptbetreuung\',\n(select t.`Name` from team t where t.`Oid` in (select teamoid from `team2customer` t2c where t2c.`CustomerOid` = c.`Oid`) LIMIT 1) as \'Team\' \nFROM servicerecord sr\njoin costbearer2supportconcept c2s on sr.costbearer2supportconceptoid = c2s.oid\njoin supportconcept sc on c2s.supportconceptoid = sc.oid\njoin customer c on sc.customeroid = c.oid\njoin person p on c.personoid = p.oid\njoin servicedescription sd on sd.oid = sr.servicedescriptionoid\njoin servicecategory scat on scat.oid = sd.servicecategoryoid\nwhere sr.oid \nnot in (select servicerecordoid from confirmationreceiptsignature2servicerecord crs2s\njoin confirmationreceiptsignature crs on crs2s.confirmationreceiptsignatureoid = crs.oid where crs.employeeoid is null and crs.customeroid is not null) and\nscat.billable = true and\nsr.startdate >= \':Von\' and sr.startdate < \':bis\'\norder by p.Lastname, sr.startdate',NULL,NULL,NULL,NULL,1,1,NULL,'1',NULL,NULL,NULL);
INSERT INTO `parameter` (`QueryOid`,`Tid`,`Name`,`Type`,`DbType`,`InsTs`,`InsUser`,`UdpUser`,`Version`,`IsActive`,`SystemEntryID`,`DefaultValue`) VALUES (4712,25,'Von_bis',5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'aktueller Monat');