Fixed Show Workingtimes
This commit is contained in:
@@ -34,7 +34,7 @@ const selectedEndDay = ref("")
|
||||
|
||||
const setupPage = async () => {
|
||||
if(route.params.id) itemInfo.value = profileStore.getProfileById(route.params.id)
|
||||
if(itemInfo.value.id) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
|
||||
//if(itemInfo.value.id) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
|
||||
workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",itemInfo.value.id).order("startDate",{ascending:false})).data
|
||||
absencerequests.value = (await supabase.from("absencerequests").select().eq("profile",itemInfo.value.id).order("startDate",{ascending: false})).data
|
||||
|
||||
@@ -91,106 +91,6 @@ const changeRange = () => {
|
||||
loadWorkingTimeInfo()
|
||||
}
|
||||
|
||||
/*const workingTimeInfo = computed(() => {
|
||||
|
||||
let times = workingtimes.value
|
||||
|
||||
//times = times.filter(i => dayjs(i.date).isBetween(dayjs(selectedStartDay.value).subtract(1,"days"),selectedEndDay.value,'day') && i.end)
|
||||
times = times.filter(i => dayjs(i.startDate).isSameOrAfter(selectedStartDay.value) && dayjs(i.endDate).subtract(1,"day").isSameOrBefore(selectedEndDay.value))
|
||||
|
||||
|
||||
let weekFactor = 4.33
|
||||
let monthlyWorkingMinutes = itemInfo.value.weeklyWorkingHours * weekFactor * 60
|
||||
|
||||
let workingMinutesTarget = Math.ceil(Number((Number(dayjs(selectedEndDay.value).add(1,"days").diff(dayjs(selectedStartDay.value),'month',true).toFixed(2)) * 4.33 * itemInfo.value.weeklyWorkingHours * 60).toFixed(2)))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Eingreicht
|
||||
let sumWorkingMinutesEingereicht = 0
|
||||
times.forEach(time => {
|
||||
const minutes = dayjs(time.endDate).diff(dayjs(time.startDate),'minutes')
|
||||
sumWorkingMinutesEingereicht = sumWorkingMinutesEingereicht + minutes
|
||||
})
|
||||
|
||||
//Bestätigt
|
||||
let sumWorkingMinutesApproved = 0
|
||||
times.filter(i => i.approved).forEach(time => {
|
||||
const minutes = dayjs(time.endDate).diff(dayjs(time.startDate),'minutes')
|
||||
sumWorkingMinutesApproved = sumWorkingMinutesApproved + minutes
|
||||
})
|
||||
//console.log(times.filter(i => i.approved).length)
|
||||
//console.log(sumWorkingMinutesApproved)
|
||||
|
||||
let recreationDays = ["2025-01-01","2025-04-18","2025-04-21","2025-05-01","2025-05-29","2025-06-09","2024-10-03","2024-10-31","2024-12-25","2024-12-26"]
|
||||
|
||||
//Feiertagsausgleich
|
||||
let sumWorkingMinutesRecreationDays = 0
|
||||
let sumRecreationDays = 0
|
||||
recreationDays.filter(i => dayjs(i).isSameOrAfter(selectedStartDay.value) && dayjs(i).isSameOrBefore(selectedEndDay.value)).forEach(day => {
|
||||
let compensationTime = itemInfo.value.weeklyRegularWorkingHours[dayjs(day).day()] || 0
|
||||
sumWorkingMinutesRecreationDays += compensationTime * 60
|
||||
sumRecreationDays++
|
||||
})
|
||||
|
||||
//Urlaubsausgleich
|
||||
let sumWorkingMinutesVacationDays = 0
|
||||
let sumVacationDays = 0
|
||||
let dailyMinutes = (itemInfo.value.weeklyWorkingHours / 6 * 60).toFixed(2)
|
||||
|
||||
let isBetween = (date,start,end) => {
|
||||
return dayjs(date).isSameOrAfter(start) && dayjs(date).isSameOrBefore(end)
|
||||
}
|
||||
|
||||
absencerequests.value.filter(i => (dayjs(i.startDate).isBetween(dayjs(selectedStartDay.value),dayjs(selectedEndDay.value)) || dayjs(i.endDate).isBetween(dayjs(selectedStartDay.value),dayjs(selectedEndDay.value)) ) && (i.reason === "Urlaub" || i.reason === "Berufsschule") && i.approved === "Genehmigt").forEach(absenceRequest => {
|
||||
let durationInDays = 0
|
||||
|
||||
console.log(absenceRequest)
|
||||
|
||||
if(isBetween(absenceRequest.startDate,selectedStartDay.value,selectedEndDay.value) && isBetween(absenceRequest.endDate,selectedStartDay.value,selectedEndDay.value)) {
|
||||
//Full in Range
|
||||
console.log("Full in Range")
|
||||
durationInDays = dayjs(absenceRequest.endDate).diff(absenceRequest.startDate, "days") + 1
|
||||
console.log(durationInDays)
|
||||
} else if(isBetween(absenceRequest.startDate,selectedStartDay.value,selectedEndDay.value) && !isBetween(absenceRequest.endDate,selectedStartDay.value,selectedEndDay.value)) {
|
||||
//Start in Range
|
||||
console.log("Start in Range")
|
||||
durationInDays = dayjs(selectedEndDay.value).diff(absenceRequest.startDate, "days") + 1
|
||||
} else if(!isBetween(absenceRequest.startDate,selectedStartDay.value,selectedEndDay.value) && isBetween(absenceRequest.endDate,selectedStartDay.value,selectedEndDay.value)) {
|
||||
//End in Range
|
||||
console.log("End in Range")
|
||||
durationInDays = dayjs(absenceRequest.endDate).diff(selectedStartDay.value, "days") + 1
|
||||
|
||||
}
|
||||
sumVacationDays += durationInDays
|
||||
sumWorkingMinutesVacationDays += dailyMinutes * durationInDays
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Saldo
|
||||
let saldo = (sumWorkingMinutesApproved + sumWorkingMinutesRecreationDays +sumWorkingMinutesVacationDays - workingMinutesTarget).toFixed(2)
|
||||
let saldoInOfficial = (sumWorkingMinutesEingereicht + sumWorkingMinutesRecreationDays + sumWorkingMinutesVacationDays - workingMinutesTarget).toFixed(2)
|
||||
|
||||
return {
|
||||
monthlyWorkingMinutes,
|
||||
workingMinutesTarget,
|
||||
sumWorkingMinutesEingereicht,
|
||||
sumWorkingMinutesApproved,
|
||||
sumWorkingMinutesRecreationDays,
|
||||
sumRecreationDays,
|
||||
sumWorkingMinutesVacationDays,
|
||||
sumVacationDays,
|
||||
saldo,
|
||||
saldoInOfficial,
|
||||
times,
|
||||
}
|
||||
})*/
|
||||
|
||||
const getDuration = (time) => {
|
||||
const minutes = Math.floor(dayjs(time.endDate).diff(dayjs(time.startDate),'minutes',true))
|
||||
const hours = Math.floor(minutes/60)
|
||||
@@ -254,34 +154,6 @@ changeRange()
|
||||
:class="['text-xl','font-medium']"
|
||||
>{{itemInfo ? `Auswertung Anwesenheiten: ${itemInfo.fullName}` : ``}}</h1>
|
||||
</template>
|
||||
<template #right>
|
||||
<!-- <UButton
|
||||
v-if="mode === 'edit'"
|
||||
@click="dataStore.updateItem('customers',itemInfo,oldItemInfo)"
|
||||
>
|
||||
Speichern
|
||||
</UButton>
|
||||
<UButton
|
||||
v-else-if="mode === 'create'"
|
||||
@click="dataStore.createNewItem('customers',itemInfo)"
|
||||
>
|
||||
Erstellen
|
||||
</UButton>
|
||||
<UButton
|
||||
@click="cancelEditorCreate"
|
||||
color="red"
|
||||
class="ml-2"
|
||||
v-if="mode === 'edit' || mode === 'create'"
|
||||
>
|
||||
Abbrechen
|
||||
</UButton>
|
||||
<UButton
|
||||
v-if="mode === 'show'"
|
||||
@click="editItem"
|
||||
>
|
||||
Bearbeiten
|
||||
</UButton>-->
|
||||
</template>
|
||||
|
||||
</UDashboardNavbar>
|
||||
<UDashboardToolbar>
|
||||
|
||||
Reference in New Issue
Block a user