382 lines
15 KiB
C#
382 lines
15 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.Core;
|
|
using BeWo.Service.Reporting;
|
|
using BeWo.Service.ServiceUtils;
|
|
using BS.Shared;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Translation;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace AkggMid.Export
|
|
{
|
|
public class CustomExportAndPrintHelper : ExportAndPrintHelper
|
|
{
|
|
// Hier ist der Code, der die StringArrays für den Excel-Export und die Print-Versionen des Exports erstellt
|
|
public override string[] PrepareHeaderArrayForEmployeeExport()
|
|
{
|
|
bool darfVertragSehen = true;
|
|
int arrayCount = 37;
|
|
|
|
string[] lHeaderCaption;
|
|
|
|
if (!Utils.UserHasRight(GetLoggedInUser(), UserRightType.Employee_AllowEditContracts))
|
|
{
|
|
arrayCount = 26;
|
|
darfVertragSehen = false;
|
|
}
|
|
|
|
if (darfVertragSehen)
|
|
{
|
|
lHeaderCaption = new string[38]
|
|
{
|
|
"Nachname", // 0
|
|
"Vorname", // 1
|
|
"Personalnummer", // 2
|
|
"Geburtsdatum", // 3
|
|
"Beruf", // 4
|
|
"Geschlecht", // 5
|
|
"Familienstand", // 6
|
|
"Krankenkasse", // 7
|
|
"Steuernummer", // 8
|
|
|
|
"beschäftigt als", // 9
|
|
"Vertragsbeginn", // 10
|
|
"Probezeit (Tage)", // 11
|
|
"Kündigungsfrist (Tage)", // 12
|
|
"Urlaubstage", // 13
|
|
"FLS/Woche", // 14
|
|
"Gesamtstunden/Woche", // 15
|
|
"Arbeitstage pro Woche", // 16
|
|
"Eintrittsdatum", // 17
|
|
"Enddatum", // 18
|
|
"Versicherungsnummer", // 19
|
|
"Stundensatz", // 20
|
|
|
|
"Telefon", // 21
|
|
"Mobil", // 22
|
|
"Mail", // 23
|
|
"private Mail", // 24
|
|
"Fax", // 25
|
|
"Strasse", // 26
|
|
"PLZ", // 27
|
|
"Ort", // 28
|
|
"Kontonummer", // 29
|
|
"Bankleitzahl", // 30
|
|
"Bank", // 31
|
|
"BIC", // 32
|
|
"IBAN", // 33
|
|
"Bemerkung", // 34
|
|
"Fachkraft", // 35
|
|
"Qualifikation", // 36
|
|
"Arbeitsschwerpunkte", // 37
|
|
|
|
};
|
|
}
|
|
else
|
|
{
|
|
lHeaderCaption = new string[26]
|
|
{
|
|
"Nachname", // 0
|
|
"Vorname", // 1
|
|
"Personalnummer", // 2
|
|
"Geburtsdatum", // 3
|
|
"Beruf", // 4
|
|
"Geschlecht", // 5
|
|
"Familienstand", // 6
|
|
"Krankenkasse", // 7
|
|
"Steuernummer", // 8
|
|
"Vertragsbeginn", // 9
|
|
|
|
"Telefon",
|
|
"Mobil", // 20
|
|
"Mail",
|
|
"private Mail",
|
|
"Fax",
|
|
"Strasse",
|
|
"PLZ", // 25
|
|
"Ort", // 26
|
|
"Kontonummer",
|
|
"Bankleitzahl",
|
|
"Bank",
|
|
"BIC", // 30
|
|
"IBAN",
|
|
|
|
"Fachkraft",
|
|
"Qualifikation",
|
|
"Arbeitsschwerpunkte",
|
|
|
|
};
|
|
}
|
|
|
|
return lHeaderCaption;
|
|
}
|
|
|
|
// Unternehmerischen Vetragsbeginn einbauen in Array[10] (Varfield Nr. 2)
|
|
public override string[][] PrepareContentArrayForEmployeeExport(long[] pSortedOids)
|
|
{
|
|
bool darfVertragSehen = true;
|
|
|
|
string[] lHeaderCaption;
|
|
|
|
if (!Utils.UserHasRight(GetLoggedInUser(), UserRightType.Employee_AllowEditContracts))
|
|
{
|
|
darfVertragSehen = false;
|
|
}
|
|
|
|
var lEmployees = DAOFactory.GenericDAO.LoadByIDs<Employee>(pSortedOids);
|
|
|
|
|
|
|
|
string[][] lContent = new string[lEmployees.Count][];
|
|
|
|
for (int iRowCount = 0; iRowCount < lEmployees.Count; iRowCount++)
|
|
{
|
|
lContent[iRowCount] = new string[PrepareHeaderArrayForEmployeeExport().Count()];
|
|
|
|
lContent[iRowCount][0] = lEmployees[iRowCount].Person.LastName;
|
|
lContent[iRowCount][1] = lEmployees[iRowCount].Person.FirstName;
|
|
lContent[iRowCount][2] = lEmployees[iRowCount].PersonnelNumber;
|
|
|
|
lContent[iRowCount][3] = lEmployees[iRowCount].Person.DateOfBirth.DoIfNotNull(d => d.ToShortDateString());
|
|
|
|
lContent[iRowCount][4] = lEmployees[iRowCount].Person.Profession;
|
|
|
|
lContent[iRowCount][5] = lEmployees[iRowCount].Person.Sex == Sex.Male
|
|
? "männlich"
|
|
: "weiblich";
|
|
|
|
if (lEmployees[iRowCount].Person.FamilyStatus != null)
|
|
{
|
|
switch (lEmployees[iRowCount].Person.FamilyStatus.Value)
|
|
{
|
|
case FamilyStatus.Divorced:
|
|
lContent[iRowCount][6] = "geschieden";
|
|
break;
|
|
case FamilyStatus.Married:
|
|
lContent[iRowCount][6] = "verheiratet";
|
|
break;
|
|
case FamilyStatus.Single:
|
|
lContent[iRowCount][6] = "ledig";
|
|
break;
|
|
case FamilyStatus.Widowed:
|
|
lContent[iRowCount][6] = "verwitwet";
|
|
break;
|
|
case FamilyStatus.Partner:
|
|
lContent[iRowCount][6] = "in Partnerschaft";
|
|
break;
|
|
case FamilyStatus.PartnerDivorced:
|
|
lContent[iRowCount][6] = "getrennt lebend";
|
|
break;
|
|
case FamilyStatus.PartnerDead:
|
|
lContent[iRowCount][5] = "partnerhinterblieben";
|
|
break;
|
|
case FamilyStatus.PartnerMarried:
|
|
lContent[iRowCount][5] = "verpartnert";
|
|
break;
|
|
case FamilyStatus.Entpartnert:
|
|
lContent[iRowCount][5] = "entpartnert";
|
|
break;
|
|
}
|
|
}
|
|
|
|
lContent[iRowCount][7] = lEmployees[iRowCount].HealthInsurance;
|
|
lContent[iRowCount][8] = lEmployees[iRowCount].TaxNumber;
|
|
|
|
if (darfVertragSehen)
|
|
{
|
|
|
|
Contract lastContract = lEmployees[iRowCount].LastContract;
|
|
|
|
if (lastContract != null)
|
|
{
|
|
if (lastContract.EmploymentType != null)
|
|
{
|
|
lContent[iRowCount][9] = lastContract.EmploymentType.Name;
|
|
}
|
|
|
|
if (lEmployees[iRowCount].Person.LastName.StartsWith("Hirschle"))
|
|
{
|
|
int test = 0;
|
|
}
|
|
// Unternehmerischen Vertragsbeginn einbauen
|
|
if (lEmployees[iRowCount].VarFieldValueList != null && lEmployees[iRowCount].VarFieldValueList.Count > 0)
|
|
{
|
|
var vertragsbeginn = lEmployees[iRowCount].VarFieldValueList.FirstOrDefault(v => v.VarFieldDefOid == 1);
|
|
if (vertragsbeginn != null && vertragsbeginn.SerializedValue.IsNotNullOrEmpty())
|
|
{
|
|
var serializer = new XmlSerializer(typeof(string));
|
|
var reader = new StringReader(vertragsbeginn.SerializedValue);
|
|
|
|
lContent[iRowCount][10] = (string)serializer.Deserialize(reader);
|
|
}
|
|
}
|
|
|
|
lContent[iRowCount][11] = lastContract.ProbationPeriod.ToString();
|
|
lContent[iRowCount][12] = lastContract.CancellationPeriod.ToString();
|
|
|
|
decimal? urlaubstage = null;
|
|
if (lastContract.EmploymentType != null && lastContract.EmploymentType.LeaveDays.HasValue)
|
|
{
|
|
urlaubstage = lastContract.EmploymentType.LeaveDays;
|
|
}
|
|
else
|
|
{
|
|
urlaubstage = lastContract.LeaveDays;
|
|
}
|
|
if (urlaubstage.HasValue)
|
|
{
|
|
lContent[iRowCount][13] = urlaubstage.Value.ToStringNullCheck();
|
|
}
|
|
|
|
if (lastContract.WeeklyFLS.HasValue)
|
|
{
|
|
lContent[iRowCount][14] = lastContract.WeeklyFLS.Value.ToStringNullCheck();
|
|
}
|
|
|
|
if (lastContract.WeeklyTotalHours.HasValue)
|
|
{
|
|
lContent[iRowCount][15] = lastContract.WeeklyTotalHours.Value.ToStringNullCheck();
|
|
}
|
|
|
|
var wd = lastContract.WeeklyDays ?? 5;
|
|
|
|
if (wd == 0)
|
|
wd = 5;
|
|
|
|
lContent[iRowCount][16] = String.Format("{0}", wd);
|
|
if (!lastContract.ContractEndDate.HasValue)
|
|
{
|
|
lContent[iRowCount][18] = "unbefristet";
|
|
}
|
|
else
|
|
{
|
|
lContent[iRowCount][18] = lastContract.ContractEndDate.DoIfNotNull(d => d.ToShortDateString());
|
|
}
|
|
|
|
}
|
|
|
|
var firstContract = lEmployees[iRowCount].FirstContract;
|
|
if (firstContract != null)
|
|
{
|
|
lContent[iRowCount][17] = firstContract.EntryDate.DoIfNotNull(d => d.ToShortDateString());
|
|
}
|
|
|
|
lContent[iRowCount][19] = lEmployees[iRowCount].InsuranceNumber;
|
|
|
|
if (lastContract != null)
|
|
{
|
|
if (lastContract.HourlyRate.HasValue)
|
|
{
|
|
lContent[iRowCount][20] = lastContract.HourlyRate.Value.ToStringNullCheck();
|
|
}
|
|
|
|
lContent[iRowCount][34] = lastContract.Notice;
|
|
}
|
|
}
|
|
|
|
int index = 10;
|
|
if (darfVertragSehen)
|
|
{
|
|
index = 21;
|
|
}
|
|
foreach (var iContact in lEmployees[iRowCount].Person.Contacts)
|
|
{
|
|
switch (iContact.Type)
|
|
{
|
|
case ContactType.business_Phone:
|
|
lContent[iRowCount][index] = iContact.Value;
|
|
break;
|
|
case ContactType.business_MobilePhone:
|
|
lContent[iRowCount][index + 1] = iContact.Value;
|
|
break;
|
|
case ContactType.business_Mail:
|
|
lContent[iRowCount][index + 2] = iContact.Value;
|
|
break;
|
|
case ContactType.private_Mail:
|
|
lContent[iRowCount][index + 3] = iContact.Value;
|
|
break;
|
|
case ContactType.business_Fax:
|
|
lContent[iRowCount][index + 4] = iContact.Value;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (lEmployees[iRowCount].Person.Address != null)
|
|
{
|
|
lContent[iRowCount][index + 5] = lEmployees[iRowCount].Person.Address.Street;
|
|
lContent[iRowCount][index + 6] = lEmployees[iRowCount].Person.Address.PostalCode;
|
|
lContent[iRowCount][index + 7] = lEmployees[iRowCount].Person.Address.Town;
|
|
}
|
|
|
|
if (lEmployees[iRowCount].Person.BankAccount != null)
|
|
{
|
|
lContent[iRowCount][index + 8] = lEmployees[iRowCount].Person.BankAccount.AccountNumber;
|
|
lContent[iRowCount][index + 9] = lEmployees[iRowCount].Person.BankAccount.BankCode;
|
|
lContent[iRowCount][index + 10] = lEmployees[iRowCount].Person.BankAccount.BankName;
|
|
lContent[iRowCount][index + 11] = lEmployees[iRowCount].Person.BankAccount.Bic;
|
|
lContent[iRowCount][index + 12] = lEmployees[iRowCount].Person.BankAccount.IBAN;
|
|
}
|
|
|
|
if (darfVertragSehen)
|
|
{
|
|
index += 1;
|
|
}
|
|
if (lEmployees[iRowCount].IsQualified.HasValue)
|
|
{
|
|
lContent[iRowCount][index + 13] = lEmployees[iRowCount].IsQualified.Value ? "Ja" : "Nein";
|
|
}
|
|
|
|
var qualis = lEmployees[iRowCount].ValueList.FindByType(ValueListEntryType.StaffQualificationsType)
|
|
.Select(e2o => e2o.Entry);
|
|
|
|
if (qualis != null && qualis.Count() > 0)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
foreach (var entry in qualis)
|
|
{
|
|
if (sb.Length > 0)
|
|
{
|
|
sb.Append(", ");
|
|
}
|
|
sb.Append(entry.Value);
|
|
}
|
|
|
|
lContent[iRowCount][index + 14] = sb.ToString();
|
|
|
|
}
|
|
|
|
var focuses = lEmployees[iRowCount].ValueList.FindByType(ValueListEntryType.StaffActivityFocusType)
|
|
.Select(e2o => e2o.Entry);
|
|
|
|
if (focuses != null && focuses.Count() > 0)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
foreach (var entry in focuses)
|
|
{
|
|
if (sb.Length > 0)
|
|
{
|
|
sb.Append(", ");
|
|
}
|
|
sb.Append(entry.Value);
|
|
}
|
|
|
|
lContent[iRowCount][index + 15] = sb.ToString();
|
|
|
|
}
|
|
}
|
|
|
|
return lContent;
|
|
}
|
|
|
|
}
|
|
}
|