import{u as J,m as K,h as Q,z as W,t as T,s as X,v as Y,r as a,j as Z,o as n,a as m,f as o,l as s,e as l,k as c,b as _,F as V,L as x,x as f,y as i,A as P,d as y,w as ee}from"./app-44623493.js";import{_ as te}from"./Filter-159905ee.js";const ae={class:"p-2"},ne={class:"divide-y divide-gray-200 dark:divide-gray-700"},se={class:"col-span-3 sm:col-span-1"},oe={key:0,class:"ml-2"},re=y("i",{class:"fas fa-clock text-info"},null,-1),de=[re],le={class:"col-span-3 sm:col-span-1"},ce={class:"col-span-3 sm:col-span-1"},ie={name:"AttendanceMark"},_e=Object.assign(ie,{setup(ue){const g=J(),D=K(),U=Q(),k={employees:[]},h="attendance/",B=W(!1),b=T({attendanceTypes:[]}),A=X(h),u=T({...k}),p=T({meta:{},defaultAttendanceType:{}}),C=e=>{p.defaultAttendanceType=e,u.employees.forEach(v=>{v.timeBasedAttendance||(v.attendanceType=e.uuid)})},$=async()=>{B.value=!0,await U.dispatch(h+"fetchEmployee",{params:g.query}).then(e=>{B.value=!1,k.employees=e.data,p.meta=e.meta,Object.assign(u,x(k))}).catch(e=>{B.value=!1})},q=e=>{Object.assign(b,e)};return Y(async()=>{g.query.date&&await $()}),(e,v)=>{const F=a("BaseButton"),E=a("PageHeaderAction"),R=a("PageHeader"),L=a("ParentTransition"),N=a("DropdownItem"),S=a("DropdownButton"),j=a("BaseAlert"),w=a("BaseDataView"),H=a("BaseSelect"),O=a("BaseTextarea"),z=a("FormAction"),I=a("Pagination"),M=a("BaseCard"),G=Z("tooltip");return n(),m(V,null,[o(R,{title:e.$trans(l(g).meta.label),navs:[{label:e.$trans("attendance.attendance"),path:"Attendance"}]},{default:s(()=>[o(E,null,{default:s(()=>[o(F,{design:"white",onClick:v[0]||(v[0]=t=>l(D).push({name:"AttendanceList"}))},{default:s(()=>[f(i(e.$trans("global.list",{attribute:e.$trans("attendance.attendance")})),1)]),_:1})]),_:1})]),_:1},8,["title","navs"]),o(L,{appear:"",visibility:!0},{default:s(()=>[o(te,{onAfterFilter:$,"init-url":h})]),_:1}),l(g).query.date?(n(),c(M,{key:0,"no-padding":"","no-content-padding":"","is-loading":B.value},{title:s(()=>[f(i(e.$trans("attendance.mark")),1)]),action:s(()=>[b.attendanceTypes?(n(),c(S,{key:0,label:p.defaultAttendanceType.uuid?p.defaultAttendanceType.name:e.$trans("attendance.type.type")},{default:s(()=>[(n(!0),m(V,null,P(b.attendanceTypes,t=>(n(),m("div",{key:t.uuid},[t.uuid!=p.defaultAttendanceType.name?(n(),c(N,{key:0,as:"span",onClick:r=>C(t)},{default:s(()=>[f(i(t.name),1)]),_:2},1032,["onClick"])):_("",!0)]))),128))]),_:1},8,["label"])):_("",!0)]),default:s(()=>[y("div",ae,[u.employees.length==0?(n(),c(j,{key:0,size:"xs",design:"error"},{default:s(()=>[f(i(e.$trans("general.errors.record_not_found")),1)]),_:1})):_("",!0)]),u.employees.length?(n(),c(z,{key:0,"no-card":"","button-padding":"","keep-adding":!1,"stay-on":!0,"init-url":h,"pre-requisites":!0,onSetPreRequisites:q,action:"markAttendance","init-form":k,form:u},{default:s(()=>[y("div",ne,[(n(!0),m(V,null,P(u.employees,(t,r)=>(n(),m("div",{class:"grid grid-cols-3 gap-6 px-4 py-2",key:t.uuid},[y("div",se,[o(w,{label:t.name+" ("+t.codeNumber+")",revert:""},{default:s(()=>[f(i(t.designation)+" "+i(t.branch)+" ",1),t.timeBasedAttendance?ee((n(),m("span",oe,de)),[[G,e.$trans("attendance.is_time_based")]]):_("",!0)]),_:2},1032,["label"])]),y("div",le,[t.onLeave?(n(),c(w,{key:0,label:e.$trans("leave.on_leave"),revert:""},{default:s(()=>[f(i(t.leavePeriod),1)]),_:2},1032,["label"])):(n(),c(H,{key:1,disabled:t.timeBasedAttendance,modelValue:t.attendanceType,"onUpdate:modelValue":d=>t.attendanceType=d,name:`employees.${r}.attendanceType`,placeholder:e.$trans("attendance.type.type"),options:b.attendanceTypes,"value-prop":"uuid","label-prop":"name",error:l(A)[`employees.${r}.attendanceType`],"onUpdate:error":d=>l(A)[`employees.${r}.attendanceType`]=d},null,8,["disabled","modelValue","onUpdate:modelValue","name","placeholder","options","error","onUpdate:error"]))]),y("div",ce,[o(O,{rows:1,modelValue:t.remarks,"onUpdate:modelValue":d=>t.remarks=d,name:`employees.${r}.remarks`,placeholder:e.$trans("attendance.props.remarks"),error:l(A)[`details.${r}.remarks`],"onUpdate:error":d=>l(A)[`details.${r}.remarks`]=d},null,8,["modelValue","onUpdate:modelValue","name","placeholder","error","onUpdate:error"])])]))),128))])]),_:1},8,["form"])):_("",!0),o(I,{meta:p.meta,onRefresh:$},null,8,["meta"])]),_:1},8,["is-loading"])):_("",!0)],64)}}});export{_e as default};
