Merge branch 'devCorrected' into 'beta'
Fixed Show Workingtimes See merge request fedeo/software!24
This commit is contained in:
@@ -7,20 +7,9 @@ export const useFunctions = () => {
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const getWorkingTimesEvaluationData = async (profileId, startDate, endDate) => {
|
||||
const {data:{session:{access_token}}} = await supabase.auth.getSession()
|
||||
|
||||
return (await axios({
|
||||
method: "POST",
|
||||
url: `${baseURL}/functions/workingtimeevaluation`,
|
||||
data: {
|
||||
profile: profileId,
|
||||
startDate: dayjs(startDate).format("YYYY-MM-DD"),
|
||||
endDate: dayjs(endDate).format("YYYY-MM-DD"),
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${access_token}`
|
||||
}
|
||||
})).data
|
||||
return (await useNuxtApp().$api(`/api/functions/workingtimeevaluation/${profileId}?start_date=${startDate}&end_date=${endDate}`))
|
||||
|
||||
}
|
||||
|
||||
const useNextNumber = async (numberRange) => {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -10,15 +10,17 @@ dayjs.extend(customParseFormat)
|
||||
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const supabase = useSupabaseClient()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const auth = useAuthStore()
|
||||
|
||||
const platform = await useCapacitor().getIsPhone() ? "mobile" : "default"
|
||||
|
||||
|
||||
const filterUser = ref(profileStore.activeProfile.id || "")
|
||||
const filterUser = ref(auth.profile.old_profile_id || "c149b249-5baf-43a2-9cc0-1947d3710a43")
|
||||
const profiles = ref([])
|
||||
const selectableProfiles = ref([])
|
||||
|
||||
const workingtimes = ref([])
|
||||
|
||||
@@ -31,8 +33,18 @@ const setupPage = async () => {
|
||||
if(route.query.profile) filterUser.value = route.query.profile
|
||||
}
|
||||
|
||||
workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",filterUser.value).order("startDate",{ascending: false})).data
|
||||
//workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",filterUser.value).order("startDate",{ascending: false})).data
|
||||
workingtimes.value = (await useEntities("workingtimes").select(null,"startDate",false))
|
||||
|
||||
let res = await useNuxtApp().$api("/api/tenant/profiles")
|
||||
console.log(res)
|
||||
|
||||
|
||||
profiles.value = res.data
|
||||
selectableProfiles.value = res.data.filter(i => i.old_profile_id)
|
||||
|
||||
console.log(profiles.value)
|
||||
console.log(selectableProfiles.value)
|
||||
|
||||
|
||||
|
||||
@@ -155,7 +167,7 @@ const setEndDate = (row) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FloatingActionButton
|
||||
<!-- <FloatingActionButton
|
||||
:label="`+ Anwesenheit`"
|
||||
variant="outline"
|
||||
v-if="platform === 'mobile'"
|
||||
@@ -168,11 +180,12 @@ const setEndDate = (row) => {
|
||||
v-if="platform === 'mobile'"
|
||||
@click="router.push(`/workingtimes/evaluate/${profileStore.activeProfile.id}`)"
|
||||
:pos="1"
|
||||
/>
|
||||
<UDashboardNavbar title="Anwesenheiten" v-if="platform !== 'mobile'">
|
||||
/>-->
|
||||
<UDashboardNavbar title="Anwesenheiten" v-if="platform !== 'mobile'" :badge="filteredRows.length">
|
||||
<template #right>
|
||||
<UButton
|
||||
@click="router.push(`/workingtimes/edit?profile=${filterUser}`)"
|
||||
disabled
|
||||
>
|
||||
+ Anwesenheit
|
||||
</UButton>
|
||||
@@ -187,14 +200,14 @@ const setEndDate = (row) => {
|
||||
<template #left>
|
||||
|
||||
<USelectMenu
|
||||
:options="profileStore.profiles"
|
||||
option-attribute="fullName"
|
||||
value-attribute="id"
|
||||
:options="selectableProfiles"
|
||||
option-attribute="full_name"
|
||||
value-attribute="old_profile_id"
|
||||
v-model="filterUser"
|
||||
@change="changeFilterUser"
|
||||
>
|
||||
<template #label>
|
||||
{{profileStore.getProfileById(filterUser) ? profileStore.getProfileById(filterUser).fullName : "Kein Benutzer ausgewählt"}}
|
||||
{{ selectableProfiles.find(i => i.old_profile_id === filterUser) ? selectableProfiles.find(i => i.old_profile_id === filterUser).full_name : "Kein Benutzer ausgewählt"}}
|
||||
</template>
|
||||
</USelectMenu>
|
||||
<UButton
|
||||
@@ -278,7 +291,9 @@ const setEndDate = (row) => {
|
||||
|
||||
</div>
|
||||
<div class="px-4 pb-4" v-else>
|
||||
<!--
|
||||
<p><span class="font-bold">Mitarbeitende/r:</span> {{profileStore.getProfileById(row.profile).fullName}}</p>
|
||||
-->
|
||||
<p><span class="font-bold">Start:</span> {{dayjs(row.startDate).format("DD.MM.YYYY HH:mm")}}</p>
|
||||
<p><span class="font-bold">Ende:</span> {{dayjs(row.endDate).format("DD.MM.YYYY HH:mm")}}</p>
|
||||
<p><span class="font-bold">Genehmigt:</span> {{row.approved ? "Ja" : "Nein"}}</p>
|
||||
@@ -286,7 +301,7 @@ const setEndDate = (row) => {
|
||||
</div>
|
||||
</template>
|
||||
<template #profile-data="{row}">
|
||||
{{profileStore.profiles.find(profile => profile.id === row.profile) ? profileStore.profiles.find(profile => profile.id === row.profile).fullName : row.profile }}
|
||||
{{ profiles.find(i => i.old_profile_id === row.profile) ? profiles.find(i => i.old_profile_id === row.profile).full_name : ""}}
|
||||
</template>
|
||||
<template #approved-data="{row}">
|
||||
<span v-if="row.approved" class="text-primary-500">Ja</span>
|
||||
|
||||
Reference in New Issue
Block a user