- | ToDo Eingangsrechnungsrechnungen: |
+ ToDo Eingangsrechnungsrechnungen: |
{
- 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"
/>
+
+
+
{
- Keine Anwesenheit gestartet
+ Keine Zeit gestartet
+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 = {}
+ }
+}
+
+
+
+
+
+
+ Start: {{dayjs(runningTimeInfo.startDate).format("HH:mm")}}
+ 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' }}
+
+
+
+
+
+ Stop
+
+
+
+ Keine Anwesenheit gestartet
+ Starten
+
+
+
+
\ No newline at end of file
diff --git a/pages/index.vue b/pages/index.vue
index c25855d..0deb634 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -47,6 +47,10 @@
>
+
+
+
diff --git a/pages/mobile/index.vue b/pages/mobile/index.vue
index 38a2686..f10a1d8 100644
--- a/pages/mobile/index.vue
+++ b/pages/mobile/index.vue
@@ -23,6 +23,11 @@ const profileStore = useProfileStore()
+
+
+
diff --git a/pages/mobile/menu.vue b/pages/mobile/menu.vue
index aa27041..1ecc458 100644
--- a/pages/mobile/menu.vue
+++ b/pages/mobile/menu.vue
@@ -4,6 +4,8 @@ definePageMeta({
layout: 'mobile',
})
+const profileStore = useProfileStore()
+
@@ -38,6 +40,17 @@ definePageMeta({
Objekte
+ Unternehmen wechseln
+
+
+ {{profileStore.tenants.find(i => i.id === option.tenant).name}}
+
+
diff --git a/pages/employees/timetracking.vue b/pages/times/index.vue
similarity index 73%
rename from pages/employees/timetracking.vue
rename to pages/times/index.vue
index 3bbd807..5e56d29 100644
--- a/pages/employees/timetracking.vue
+++ b/pages/times/index.vue
@@ -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) => {
Start
Stop
@@ -251,9 +246,9 @@ const setState = async (newState) => {
-
+
- Start: {{dayjs(runningTimeInfo.start).format("DD.MM.YY HH:mm")}}
+ Start: {{dayjs(runningTimeInfo.startDate).format("DD.MM.YY HH:mm")}}
{
:options="dataStore.projects"
option-attribute="name"
value-attribute="id"
- v-model="runningTimeInfo.projectId"
+ v-model="runningTimeInfo.project"
>
- {{ 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" }}
@@ -305,34 +300,32 @@ 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'))"
>
{{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) => {
>
{
:disabled="configTimeMode === 'create' ? false : itemInfo.state !== 'Entwurf'"
>
- {{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"}}
@@ -443,20 +436,17 @@ const setState = async (newState) => {
>{{row.state}}
- {{profileStore.profiles.find(profile => profile.id === row.user) ? profileStore.profiles.find(profile => profile.id === row.user).fullName : row.user }}
+ {{row.profile ? row.profile.fullName : "" }}
-
- {{dayjs(row.start).format("DD.MM.YY HH:mm")}}
+
+ {{dayjs(row.startDate).format("DD.MM.YY HH:mm")}}
-
- {{dayjs(row.end).format("DD.MM.YY HH:mm")}}
+
+ {{dayjs(row.endDate).format("DD.MM.YY HH:mm")}}
-
- {{getDuration(row).composed}}
-
-
- {{dataStore.projects.find(project => project.id === row.projectId) ? dataStore.projects.find(project => project.id === row.projectId).name : ""}}
+
+ {{row.project ? row.project.name : "" }}
diff --git a/stores/data.js b/stores/data.js
index cb9ee8f..f4589f8 100644
--- a/stores/data.js
+++ b/stores/data.js
@@ -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"
},{
|