Merge branch 'refs/heads/beta'

This commit is contained in:
2025-06-01 18:37:27 +02:00
11 changed files with 353 additions and 86 deletions

View File

@@ -1,5 +1,7 @@
<script setup>
import EntityShowSubTimes from "~/components/EntityShowSubTimes.vue";
const props = defineProps({
type: {
required: true,
@@ -251,6 +253,12 @@ const onTabChange = (index) => {
v-else-if="tab.label === 'Buchungen'"
:platform="platform"
/>
<EntityShowSubTimes
:top-level-type="type"
:item="props.item"
v-else-if="tab.label === 'Zeiten'"
:platform="platform"
/>
<EntityShowSub

View File

@@ -0,0 +1,117 @@
<script setup>
import dayjs from "dayjs";
const supabase = useSupabaseClient()
const route = useRoute()
const router = useRouter()
const profileStore = useProfileStore()
const props = defineProps({
queryStringData: {
type: String
},
item: {
type: Object,
required: true
},
topLevelType: {
type: String,
required: true
},
platform: {
type: String,
required: true
}
})
const setup = async () => {
}
setup()
const columns = [
{
key:"state",
label: "Status",
},
{
key: "user",
label: "Benutzer",
},
{
key:"startDate",
label:"Start",
},
{
key: "endDate",
label: "Ende",
},
{
key: "duration",
label: "Dauer",
},
{
key:"type",
label:"Typ",
},
{
key: "project",
label: "Projekt",
},
{
key: "notes",
label: "Notizen",
}
]
</script>
<template>
<UCard class="mt-5">
<UTable
class="mt-3"
:columns="columns"
:rows="props.item.times"
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Noch keine Einträge' }"
>
<template #state-data="{row}">
<span
v-if="row.state === 'Entwurf'"
class="text-rose-500"
>{{row.state}}</span>
<span
v-if="row.state === 'Eingereicht'"
class="text-cyan-500"
>{{row.state}}</span>
<span
v-if="row.state === 'Bestätigt'"
class="text-primary-500"
>{{row.state}}</span>
</template>
<template #user-data="{row}">
{{row.profile ? row.profile.fullName : "" }}
</template>
<template #startDate-data="{row}">
{{dayjs(row.startDate).format("DD.MM.YY HH:mm")}}
</template>
<template #endDate-data="{row}">
{{dayjs(row.endDate).format("DD.MM.YY HH:mm")}}
</template>
<template #duration-data="{row}">
{{Math.floor(dayjs(row.endDate).diff(row.startDate, "minutes")/60)}}:{{String(dayjs(row.endDate).diff(row.startDate, "minutes") % 60).padStart(2,"0")}} h
</template>
<template #project-data="{row}">
{{row.project ? row.project.name : "" }}
</template>
</UTable>
</UCard>
</template>
<style scoped>
</style>

View File

@@ -126,7 +126,7 @@ const links = computed(() => {
children: [
... profileStore.ownTenant.features.timeTracking ? [{
label: "Zeiterfassung",
to: "/employees/timetracking",
to: "/times",
icon: "i-heroicons-clock"
}] : [],
... profileStore.ownTenant.features.workingTimeTracking ? [{
@@ -319,6 +319,10 @@ const links = computed(() => {
label: "Projekttypen",
to: "/projecttypes",
icon: "i-heroicons-clipboard-document-list"
},{
label: "Export",
to: "/export",
icon: "i-heroicons-clipboard-document-list"
}
]
}

View File

@@ -52,7 +52,7 @@ setupPage()
<template>
<table>
<tr>
<td>Offene Rechnungen:</td>
<td class="break-all">Offene Rechnungen:</td>
<td
v-if="unpaidInvoicesSum > 0"
class="text-orange-500 font-bold text-nowrap"
@@ -60,7 +60,7 @@ setupPage()
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk / 0,00</td>
</tr>
<tr>
<td>Überfällige Rechnungen:</td>
<td class="break-all">Überfällige Rechnungen:</td>
<td
v-if="unpaidOverdueInvoicesSum > 0"
class="text-rose-600 font-bold text-nowrap"
@@ -68,7 +68,7 @@ setupPage()
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk / 0,00</td>
</tr>
<tr>
<td>Angelegte Rechnungsentwürfe:</td>
<td class="break-all">Angelegte Rechnungsentwürfe:</td>
<td
v-if="draftInvoicesSum > 0"
class="text-orange-500 font-bold text-nowrap"
@@ -76,7 +76,7 @@ setupPage()
<td v-else class="text-primary-500 font-bold text-no-wrap">0 Stk / 0,00</td>
</tr>
<tr>
<td>ToDo Eingangsrechnungsrechnungen:</td>
<td class="break-all">ToDo Eingangsrechnungsrechnungen:</td>
<td
v-if="countUnfinishedOpenIncomingInvoices > 0"
class="text-orange-500 font-bold text-nowrap"

View File

@@ -7,9 +7,18 @@ const toast = useToast()
const runningTimeInfo = ref({})
const projects = ref([])
const platform = ref("default")
const setupPage = async () => {
runningTimeInfo.value = (await supabase.from("workingtimes").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
console.log(runningTimeInfo.value)
runningTimeInfo.value = (await supabase.from("times").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
projects.value = (await useSupabaseSelect("projects"))
if(await useCapacitor().getIsPhone()) {
platform.value = "mobile"
}
}
setupPage()
@@ -24,12 +33,12 @@ const startTime = async () => {
profile: profileStore.activeProfile.id,
startDate: dayjs(),
tenant: profileStore.currentTenant,
state: "Im Web gestartet",
state: platform.value === "mobile" ? "In der App gestartet" : "Im Web gestartet",
source: "Dashboard"
}
const {data,error} = await supabase
.from("workingtimes")
.from("times")
.insert([runningTimeInfo.value])
.select()
if(error) {
@@ -38,16 +47,16 @@ const startTime = async () => {
} else if(data) {
toast.add({title: "Zeit erfolgreich gestartet"})
runningTimeInfo.value = data[0]
console.log(runningTimeInfo.value)
//console.log(runningTimeInfo.value)
}
}
const stopStartedTime = async () => {
runningTimeInfo.value.endDate = dayjs()
runningTimeInfo.value.state = "Im Web gestoppt"
runningTimeInfo.value.state = platform.value === "mobile" ? "In der App gestoppt" : "Im Web gestoppt"
const {error,status} = await supabase
.from("workingtimes")
.from("times")
.update(runningTimeInfo.value)
.eq('id',runningTimeInfo.value.id)
@@ -79,6 +88,20 @@ const stopStartedTime = async () => {
v-model="runningTimeInfo.notes"
/>
</UFormGroup>
<UFormGroup
class="mt-2"
label="Projekt:"
>
<USelectMenu
v-model="runningTimeInfo.project"
:options="projects"
searchable
:search-attributes="['name','notes','customer']"
searchable-placeholder="Suche"
value-attribute="id"
option-attribute="name"
/>
</UFormGroup>
<UButton
class="mt-3"
@click="stopStartedTime"
@@ -88,7 +111,7 @@ const stopStartedTime = async () => {
</UButton>
</div>
<div v-else>
<p>Keine Anwesenheit gestartet</p>
<p>Keine Zeit gestartet</p>
<UButton
class="mt-3"
@click="startTime"

View File

@@ -0,0 +1,101 @@
<script setup>
import dayjs from "dayjs";
const profileStore = useProfileStore();
const supabase = useSupabaseClient()
const toast = useToast()
const runningTimeInfo = ref({})
const setupPage = async () => {
runningTimeInfo.value = (await supabase.from("workingtimes").select().eq("profile", profileStore.activeProfile.id).is("endDate", null).single()).data || {}
console.log(runningTimeInfo.value)
}
setupPage()
/*if(dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.endDate)) {
runningTimeInfo.value = dataStore.workingtimes.find(time => time.profile === profileStore.activeProfile.id && !time.end)
}*/
const startTime = async () => {
console.log("started")
runningTimeInfo.value = {
profile: profileStore.activeProfile.id,
startDate: dayjs(),
tenant: profileStore.currentTenant,
state: "Im Web gestartet",
source: "Dashboard"
}
const {data,error} = await supabase
.from("workingtimes")
.insert([runningTimeInfo.value])
.select()
if(error) {
console.log(error)
toast.add({title: "Fehler beim starten der Zeit",color:"rose"})
} else if(data) {
toast.add({title: "Anwesenheit erfolgreich gestartet"})
runningTimeInfo.value = data[0]
console.log(runningTimeInfo.value)
}
}
const stopStartedTime = async () => {
runningTimeInfo.value.endDate = dayjs()
runningTimeInfo.value.state = "Im Web gestoppt"
const {error,status} = await supabase
.from("workingtimes")
.update(runningTimeInfo.value)
.eq('id',runningTimeInfo.value.id)
if(error) {
console.log(error)
let errorId = await useError().logError(`${status} - ${JSON.stringify(error)}`)
toast.add({title: errorId ? `Fehler beim stoppen der Anwesenheit (Fehler ID: ${errorId})` : `Fehler beim stoppen der Anwesenheit`,color:"rose"})
} else {
toast.add({title: "Anwesenheit erfolgreich gestoppt"})
runningTimeInfo.value = {}
}
}
</script>
<template>
<div v-if="runningTimeInfo.startDate">
<p>Start: {{dayjs(runningTimeInfo.startDate).format("HH:mm")}}</p>
<p>Dauer: {{dayjs().diff(dayjs(runningTimeInfo.startDate),'minutes') > 59 ? `${Math.floor(dayjs().diff(dayjs(runningTimeInfo.startDate),'minutes') / 60)}:${dayjs().diff(dayjs(runningTimeInfo.startDate),'minutes') % 60} h` : dayjs().diff(dayjs(runningTimeInfo.startDate),'minutes') + ' min' }}</p>
<UFormGroup
class="mt-2"
label="Notizen:"
>
<UTextarea
v-model="runningTimeInfo.notes"
/>
</UFormGroup>
<UButton
class="mt-3"
@click="stopStartedTime"
:disabled="!runningTimeInfo.id"
>
Stop
</UButton>
</div>
<div v-else>
<p>Keine Anwesenheit gestartet</p>
<UButton
class="mt-3"
@click="startTime"
>Starten</UButton>
</div>
</template>
<style scoped>
</style>

View File

@@ -47,6 +47,10 @@
>
<display-running-time/>
</UDashboardCard>
<UDashboardCard
>
<display-running-working-time/>
</UDashboardCard>
<UDashboardCard
title="Aufgaben"
>

View File

@@ -23,6 +23,11 @@ const profileStore = useProfileStore()
</UDashboardCard>
<UDashboardCard
title="Anwesenheit"
>
<display-running-working-time/>
</UDashboardCard>
<UDashboardCard
title="Zeit"
>
<display-running-time/>
</UDashboardCard>

View File

@@ -4,6 +4,8 @@ definePageMeta({
layout: 'mobile',
})
const profileStore = useProfileStore()
</script>
<template>
@@ -38,6 +40,17 @@ definePageMeta({
Objekte
</UButton>
<UDivider class="my-5">Unternehmen wechseln</UDivider>
<UButton
v-for="option in profileStore.ownProfiles"
class="my-1"
variant="outline"
@click="profileStore.changeProfile(option.id)"
>
{{profileStore.tenants.find(i => i.id === option.tenant).name}}
</UButton>
</UDashboardPanelContent>
</template>

View File

@@ -15,7 +15,7 @@ const user = useSupabaseUser()
const toast = useToast()
const timeTypes = dataStore.getTimeTypes
const timeTypes = profileStore.ownTenant.timeConfig.timeTypes
const timeInfo = ref({
profile: "",
startDate: "",
@@ -28,9 +28,21 @@ const timeInfo = ref({
const filterUser = ref(profileStore.activeProfile.id || "")
const times = ref([])
const runningTimeInfo = ref({})
const showConfigTimeModal = ref(false)
const configTimeMode = ref("create")
const setup = async () => {
times.value = await useSupabaseSelect("times","*, profile(*)")
times.value = await useSupabaseSelect("times","*, profile(*), project(id, name)")
runningTimeInfo.value = (await supabase
.from("times")
.select()
.eq("tenant", profileStore.currentTenant)
.eq("profile", profileStore.activeProfile.id)
.is("endDate",null)
.single()).data
}
setup()
@@ -60,7 +72,7 @@ const itemInfo = ref({
start: new Date(),
end: "",
notes: null,
projectId: null,
project: null,
type: null,
state: "Entwurf"
})
@@ -87,10 +99,6 @@ const columns = [
key:"type",
label:"Typ",
},
{
key: "duration",
label: "Dauer",
},
{
key: "project",
label: "Projekt",
@@ -101,16 +109,14 @@ const columns = [
}
]
const runningTimeInfo = ref({})
const showConfigTimeModal = ref(false)
const configTimeMode = ref("create")
const startTime = async () => {
console.log("started")
timeInfo.value.profile = profileStore.activeProfile.id
timeInfo.value.start = new Date().toISOString()
timeInfo.value.startDate = dayjs()
timeInfo.value.tenant = profileStore.currentTenant
const {data,error} = await supabase
@@ -120,45 +126,34 @@ const startTime = async () => {
if(error) {
console.log(error)
toast.add({title: "Fehler beim starten der Zeit",color:"rose"})
} else if(data) {
//timeInfo.value = data[0]
await dataStore.fetchTimes()
runningTimeInfo.value = dataStore.times.find(time => time.profile === profileStore.activeProfile.id && !time.end)
toast.add({title: "Zeit erfolgreich gestartet"})
runningTimeInfo.value = data[0]
}
}
const stopStartedTime = async () => {
console.log(runningTimeInfo.value)
runningTimeInfo.value.endDate = dayjs()
runningTimeInfo.value.state = "Im Web gestoppt"
runningTimeInfo.value.end = new Date().toISOString()
const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
runningTimeInfo.value.duration = Math.round(mapNumRange(Math.abs(new Date(runningTimeInfo.value.end) - new Date(runningTimeInfo.value.start))/1000/60,0,60,0,1)*100)/100
const {data,error} = await supabase
.from("times")
.update(runningTimeInfo.value)
.eq('id',runningTimeInfo.value.id)
.select()
console.log(data)
if(error) {
console.log(error)
} else {
toast.add({title: "Zeit erfolgreich gestoppt"})
runningTimeInfo.value = {}
dataStore.fetchTimes()
runningTimeInfo.value = null
setup()
}
}
if(times.value.find(time => time.profile == profileStore.activeProfile.id && !time.end)) {
runningTimeInfo.value = times.value.find(time => time.profile == profileStore.activeProfile.id && !time.end)
}
const createTime = async () => {
const {data,error} = await supabase
.from("times")
@@ -224,13 +219,13 @@ const setState = async (newState) => {
<template #left>
<UButton
@click="startTime"
:disabled="runningTimeInfo.id "
:disabled="runningTimeInfo "
>
Start
</UButton>
<UButton
@click="stopStartedTime"
:disabled="!runningTimeInfo.id"
:disabled="!runningTimeInfo"
>
Stop
</UButton>
@@ -251,9 +246,9 @@ const setState = async (newState) => {
</USelectMenu>
</template>
</UDashboardToolbar>
<div v-if="runningTimeInfo.id" class="m-3">
<div v-if="runningTimeInfo" class="m-3">
Start: {{dayjs(runningTimeInfo.start).format("DD.MM.YY HH:mm")}}
Start: {{dayjs(runningTimeInfo.startDate).format("DD.MM.YY HH:mm")}}
<UFormGroup
label="Notizen:"
@@ -270,10 +265,10 @@ const setState = async (newState) => {
:options="dataStore.projects"
option-attribute="name"
value-attribute="id"
v-model="runningTimeInfo.projectId"
v-model="runningTimeInfo.project"
>
<template #label>
{{ dataStore.projects.find(project => project.id === runningTimeInfo.projectId) ? dataStore.projects.find(project => project.id === runningTimeInfo.projectId).name : "Projekt auswählen" }}
{{ dataStore.projects.find(project => project.id === runningTimeInfo.project) ? dataStore.projects.find(project => project.id === runningTimeInfo.project).name : "Projekt auswählen" }}
</template>
</USelectMenu>
</UFormGroup>
@@ -305,34 +300,32 @@ const setState = async (newState) => {
<UFormGroup
label="Start:"
>
<VueDatePicker
v-model="itemInfo.start"
locale="de"
cancel-text="Abbrechen"
select-text="Auswählen"
now-button-label="Jetzt"
text-input="MM.dd.yyyy HH:mm"
:dark="useColorMode().value !== 'light'"
:format="format"
:preview-format="format"
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
/>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton
icon="i-heroicons-calendar-days-20-solid"
:label="itemInfo.startDate ? dayjs(itemInfo.startDate).format('DD.MM.YYYY') : 'Datum auswählen'"
variant="outline"
/>
<template #panel="{ close }">
<LazyDatePicker v-model="itemInfo.startDate" @close="close" mode="dateTime" />
</template>
</UPopover>
</UFormGroup>
<UFormGroup
label="Ende:"
>
<VueDatePicker
v-model="itemInfo.end"
locale="de"
cancel-text="Abbrechen"
select-text="Auswählen"
now-button-label="Jetzt"
text-input="MM.dd.yyyy HH:mm"
:dark="useColorMode().value !== 'light'"
:format="format"
:preview-format="format"
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
/>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton
icon="i-heroicons-calendar-days-20-solid"
:label="itemInfo.endDate ? dayjs(itemInfo.endDate).format('DD.MM.YYYY') : 'Datum auswählen'"
variant="outline"
/>
<template #panel="{ close }">
<LazyDatePicker v-model="itemInfo.endDate" @close="close" mode="dateTime" />
</template>
</UPopover>
</UFormGroup>
<UFormGroup
label="Benutzer:"
@@ -342,7 +335,7 @@ const setState = async (newState) => {
v-model="itemInfo.user"
option-attribute="fullName"
value-attribute="id"
:disabled="(configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf') || (!dataStore.hasRight('createTime') || !dataStore.hasRight('createOwnTime'))"
:disabled="(configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf') || (!dataStore.hasRight('createTime') || !useRole().hasRight('createOwnTime'))"
>
<template #label>
{{profileStore.profiles.find(profile => profile.id === itemInfo.user) ? profileStore.profiles.find(profile => profile.id === itemInfo.user).fullName : "Benutzer auswählen"}}
@@ -354,7 +347,7 @@ const setState = async (newState) => {
>
<USelectMenu
:options="dataStore.projects"
v-model="itemInfo.projectId"
v-model="itemInfo.project"
option-attribute="name"
value-attribute="id"
searchable
@@ -363,7 +356,7 @@ const setState = async (newState) => {
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
>
<template #label>
{{dataStore.projects.find(project => project.id === itemInfo.projectId) ? dataStore.projects.find(project => project.id === itemInfo.projectId).name : "Projekt auswählen"}}
{{dataStore.projects.find(project => project.id === itemInfo.project) ? dataStore.projects.find(project => project.id === itemInfo.project).name : "Projekt auswählen"}}
</template>
</USelectMenu>
</UFormGroup>
@@ -443,20 +436,17 @@ const setState = async (newState) => {
>{{row.state}}</span>
</template>
<template #user-data="{row}">
{{profileStore.profiles.find(profile => profile.id === row.user) ? profileStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
{{row.profile ? row.profile.fullName : "" }}
</template>
<template #start-data="{row}">
{{dayjs(row.start).format("DD.MM.YY HH:mm")}}
<template #startDate-data="{row}">
{{dayjs(row.startDate).format("DD.MM.YY HH:mm")}}
</template>
<template #end-data="{row}">
{{dayjs(row.end).format("DD.MM.YY HH:mm")}}
<template #endDate-data="{row}">
{{dayjs(row.endDate).format("DD.MM.YY HH:mm")}}
</template>
<template #duration-data="{row}">
{{getDuration(row).composed}}
</template>
<template #projectId-data="{row}">
{{dataStore.projects.find(project => project.id === row.projectId) ? dataStore.projects.find(project => project.id === row.projectId).name : ""}}
<template #project-data="{row}">
{{row.project ? row.project.name : "" }}
</template>
</UTable>
</template>

View File

@@ -978,7 +978,7 @@ export const useDataStore = defineStore('data', () => {
redirect:true,
historyItemHolder: "project",
numberRangeHolder: "projectNumber",
supabaseSelectWithInformation: "*, customer(id,name), plant(id,name), projecttype(name, id), tasks(*, project(id,name), customer(id,name), plant(id,name)), files(*), createddocuments(*, statementallocations(*)), events(*)",
supabaseSelectWithInformation: "*, customer(id,name), plant(id,name), projecttype(name, id), tasks(*, project(id,name), customer(id,name), plant(id,name)), files(*), createddocuments(*, statementallocations(*)), events(*), times(*, profile(id, fullName))",
supabaseSortColumn: "projectNumber",
filters: [
{
@@ -1086,6 +1086,8 @@ export const useDataStore = defineStore('data', () => {
},{
key: "files",
label: "Dateien"
},{
label: "Zeiten"
},{
label: "Ausgangsbelege"
},{