File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.6c459ffd.js
Back
import{w as ce,L as de}from"./index.a2e6eae1.js";import{C as fe}from"./index.80034d43.js";import{B as P}from"./index.cc73f214.js";import{B as he}from"./index.6e6276ec.js";import{I as M}from"./index.0683473b.js";import{I as ue}from"./index.a2c793b0.js";import"./lodash.436e061f.js";import{_ as E,r as l,o as m,c as y,w as f,j as p,d as s,f as b,t as _,k as H,e as n,b as u,p as z,s as q,q as j,h as I,m as ge,F as pe}from"./index.85badd64.js";import{E as w}from"./EmployeeOffsetService.09d4083e.js";import{F as G}from"./index.d64b81fa.js";import{F as Y}from"./index.1361a4ca.js";/* empty css */import{T as N}from"./index.4b5a3e02.js";import{T as W}from"./index.00e97a5e.js";import{C as L}from"./CloseButton.d4d5b449.js";/* empty css */import{S as O}from"./SubmitButton.fbd40930.js";import{U as $}from"./UpdateButton.7c791611.js";import"./jspdf.es.min.23081428.js";/* empty css */import{A as Z}from"./ApproverService.ab09ac07.js";import{F as K}from"./FileService.f48416f8.js";import{c as Q,b as _e,a as V,V as J}from"./array.e024b95a.js";import{L as U}from"./Loading.585cd43f.js";import{M as X}from"./Multiselect.a507ebe0.js";import"./vue-quill.snow.37e2074d.js";import{F as ee}from"./index.95c1c484.js";import{F as te}from"./index.2b90fc01.js";import{C as ie}from"./index.a33bfc5d.js";import{A as se}from"./index.554b08cb.js";import{p as oe,j as ne}from"./scr-1.d9aaecca.js";import{E as xe}from"./EmployeeLeaveService.e6ec877d.js";import{A as ye}from"./main.esm.35b2f04c.js";import{E as ae}from"./EditButton.f8e95215.js";import{D as re}from"./DeleteButton.f13880af.js";import{F as we}from"./index.90fa1727.js";import{m as ve,p as be,x as Ce,I as Fe,y as ke}from"./tabs.17c91258.js";import{C as De}from"./CreateButton.69489aea.js";import{V as Ae}from"./ViewButton.13bd1aa9.js";import"./vue-cleave.min.5fe175a4.js";/* empty css */import{P as Re}from"./index.cf4c1c51.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.47a550d7.js";import"./EmployeeService.9af9860f.js";import"./es.string.replace.52fb44b9.js";import"./index.9cc1ebc8.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.ffa9415b.js";import"./ck-white.4bf441fa.js";import"./index.53d9b6cb.js";const Se={components:{Alert:se,FileType:te,Fileinput:ee,FormModal:Y,FormGroup:G,TextInput:N,Textarea:W,SubmitButton:O,UpdateButton:$,CloseButton:L,Loading:U,Multiselect:X,Icon:M,Checkbox:ie},data(){return{recommending:"",recommending_img:"",approving:"",approving_img:"",form:{date:"",from_time:"",to_time:"",destination:"",description:"",attachment:"",recommending_id:"",allow_higher_approval:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},fileIcons:{pdf:oe,jpg:ne,default:""}}},methods:{calculateHours(){const i=this.form.from_time,e=this.form.to_time;if(i&&e){const[a,o]=this.form.from_time.split(":").map(Number),[t,r]=this.form.to_time.split(":").map(Number);let d=t-a;d+=(r-o)/60,d<0&&(d+=24),this.form.hours=d}},deleteFile(i){this.$swal.fire({title:"Are you sure you want remove the attachment?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.deleteFileAttachment()})},async deleteFileAttachment(){const i=this.form.id,e=this.form.attachment,a={id:i,attachment:e};await w.removeAttachmentEarning(a).then(o=>{o.status==201?(this.$swal.fire({title:"Great!",text:"Attachment successfully deleted.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.form.attachment=""):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(o=>{o.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:o.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},getFileTypeImage(i){if(typeof i=="string"){if(!i)return this.fileIcons.default;const e=i.substring(i.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(i){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await K.Reader2("employee-overtime",i),a;if(i.endsWith(".pdf"))a="application/pdf";else if(i.endsWith(".png"))a="image/png";else if(i.endsWith(".jpg")||i.endsWith(".jpeg"))a="image/jpeg";else if(i.endsWith(".svg"))a="image/svg+xml";else throw new Error("Unsupported file type");const o=atob(e),t=new Array(o.length);for(let h=0;h<o.length;h++)t[h]=o.charCodeAt(h);const r=new Uint8Array(t),d=new Blob([r],{type:a}),x=URL.createObjectURL(d);window.open(x),this.state.isLoadingPDF=!1},handleMainImageUpload(){const i=event.target.files[0];this.form.attachment=i;const e=new FileReader;e.onload=()=>{i.type.startsWith("image/")?this.form.imageView=e.result:i.type==="application/pdf"?this.form.imageView=this.pdf_file_view:i.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},e.readAsDataURL(i)},loadRecord(i){this.resetForm(),this.state.isEdit=!0,this.form=i,this.form.date=new Date(i.date).toLocaleDateString("en-CA").split("T")[0],this.form.allow_higher_approval=i.allow_higher_approval==1},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date:"",from_time:"",to_time:"",destination:"",description:"",attachment:"",allow_higher_approval:"",recommending_id:this.form.recommending_id,approver_id:this.form.approver_id}},reload(){return this.$emit("reload")},async fetchApprover(){this.state.isLoading=!0,await Z.fetchApproverRecords().then(i=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&i.data.map(e=>{this.form.allow_higher_approval?((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==3&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.approving==""&&e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")):((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""))}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&i.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&i.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.state.isLoading=!1}).catch(i=>{console.log(i)})},async saveRecord(){if(this.state.isSaving=!0,this.state.isEdit){this.form.id;let i=new FormData;Object.keys(this.form).forEach(e=>{i.append(e,this.form[e])}),await w.updateEarning(i).then(e=>{e.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(e=>{e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})}else{let i=new FormData;Object.keys(this.form).forEach(e=>{i.append(e,this.form[e])}),await w.createEarning(i).then(e=>{e.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3}),this.state.showModal=!1,this.state.isSaving=!1,this.resetForm(),this.reload())}).catch(e=>{console.log(e),e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})}},async submitForm(){try{const i=Q().shape({date:_e().required("Date is required").typeError("Date is required"),hours:V().required("Hours is required")});this.form.date.length==0&&(this.errors.date=!0),this.form.hours>this.availableOffset?this.errors.hours="Hours must not exceed the available hours":this.errors.hours=!1,await i.validate(this.form,{abortEarly:!1}),this.errors.hours||this.$swal.fire({title:"Are you sure you want to save this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.saveRecord()})}catch(i){if(i instanceof J){const e={};i.inner.forEach(a=>{e[a.path]=a.message}),this.errors=e}}}},mounted(){this.fetchApprover()},watch:{"form.from_time":"calculateHours","form.to_time":"calculateHours","form.allow_higher_approval":{handler:"fetchApprover",immediate:!0}}},Te={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Be={class:"grid grid-cols-12 gap-4"},Ee={class:"col-span-12"},Ve={class:"text-[#ed539f]"},Me={class:"col-span-4"},Ie={class:"col-span-4"},Le={class:"col-span-4"},Oe={class:"col-span-12"},Ue={key:0,class:"text-[#ec4899]"},je={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},Pe={class:"flex justify-between w-full items-center"},He={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},ze={class:"col-span-12"},qe={class:"grid grid-cols-12 gap-4"},Ge={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},Ye={class:"flex-shrink-0 mr-4"},Ne=["src"],We={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},$e={class:"text-left"},Ze={class:"text-sm font-semibold text-gray-600"},Ke={class:"text-lg font-bold text-gray-900"},Qe={key:0,class:"text-sm text-gray-900"},Je={key:1,class:"text-sm text-gray-900"},Xe={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},et={class:"flex-shrink-0 mr-4"},tt=["src"],it={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},st={class:"text-left"},ot={class:"text-lg font-bold text-gray-900"},nt={class:"text-sm text-gray-900"},at={class:"flex gap-2 justify-between"},rt={class:"flex items-center cursor-pointer"},lt=["checked"],mt={class:"flex gap-2"};function ct(i,e,a,o,t,r){const d=l("Loading"),x=l("Alert"),h=l("flat-pickr"),g=l("FormGroup"),C=l("TextInput"),F=l("Fileinput"),D=l("Card"),k=l("FileType"),A=l("Icon"),R=l("Textarea"),S=l("SubmitButton"),v=l("UpdateButton"),T=l("CloseButton"),B=l("FormModal");return m(),y(B,{title:t.state.isEdit?"Edit Offset Earning":"Offset Earning Form",active:t.state.showModal,onSubmit:i.confirmSubmit,onClose:r.closeModal,themeClass:t.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:f(()=>[t.state.isEdit&&t.state.isLoading?(m(),y(d,{key:0,text:"Fetching record"})):p("",!0),t.state.isLoading?(m(),y(d,{key:1,text:"Fetching Approver"})):p("",!0),t.form.denied_reason?(m(),y(x,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:f(()=>[e[10]||(e[10]=s("span",{class:"font-semibold"},"Denied Reason:",-1)),b(" "+_(t.form.denied_reason),1)]),_:1})):p("",!0),s("div",Te,[s("form",{onSubmit:e[9]||(e[9]=H((...c)=>i.confirmSubmit&&i.confirmSubmit(...c),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[t.state.isSaving?(m(),y(d,{key:0,text:"Saving record"})):p("",!0),s("div",Be,[s("div",Ee,[n(g,{label:"Date",isRequired:!0},{default:f(()=>[n(h,{modelValue:t.form.date,"onUpdate:modelValue":e[0]||(e[0]=c=>t.form.date=c),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1}),s("div",Ve,_(t.errors.date),1)]),s("div",Me,[n(g,{label:"From Time",isRequired:!0},{default:f(()=>[n(h,{modelValue:t.form.from_time,"onUpdate:modelValue":e[1]||(e[1]=c=>t.form.from_time=c),class:"form-control h-12",placeholder:"From time",onChange:r.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),s("div",Ie,[n(g,{label:"To Time",isRequired:!0},{default:f(()=>[n(h,{modelValue:t.form.to_time,"onUpdate:modelValue":e[2]||(e[2]=c=>t.form.to_time=c),class:"form-control h-12",placeholder:"To time",onChange:r.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),s("div",Le,[n(g,{label:"Hours",isRequired:!0},{default:f(()=>[n(C,{type:"text",modelValue:t.form.hours,"onUpdate:modelValue":e[3]||(e[3]=c=>t.form.hours=c),error:t.errors.hours,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1})]),s("div",Oe,[n(g,{label:"Attachment"},{default:f(()=>[n(D,{title:"File Input Basic"},{default:f(()=>[n(F,{modelValue:t.form.attachment,"onUpdate:modelValue":e[4]||(e[4]=c=>t.form.attachment=c),name:"basic",onChange:r.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),t.errors.attachment?(m(),u("div",Ue,_(t.errors.attachment),1)):p("",!0)]),_:1}),typeof t.form.attachment=="string"&&t.form.attachment?(m(),u("div",je,[s("div",Pe,[s("div",{class:"flex items-center cursor-pointer",onClick:e[5]||(e[5]=c=>r.viewAttachment(t.form.attachment))},[n(k,{image:r.getFileTypeImage(t.form.attachment)},null,8,["image"]),b(" "+_(t.form.attachment),1)]),t.form.status==0?(m(),u("div",He,[n(A,{icon:"mingcute:delete-2-fill",onClick:e[6]||(e[6]=c=>r.deleteFile(t.form.id))})])):p("",!0)])])):p("",!0)]),_:1})]),s("div",ze,[n(g,{label:"Remarks"},{default:f(()=>[n(R,{name:"pn4",placeholder:"Textarea",modelValue:t.form.description,"onUpdate:modelValue":e[7]||(e[7]=c=>t.form.description=c)},null,8,["modelValue"])]),_:1})])]),s("div",qe,[s("div",Ge,[s("div",Ye,[t.recommending_img?(m(),u("img",{key:0,src:t.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Ne)):(m(),u("div",We," No Image "))]),s("div",$e,[s("div",Ze,_(t.form.allow_higher_approval?"Recommending":"Approving"),1),s("div",Ke,_(t.recommending),1),t.form.allow_higher_approval?(m(),u("div",Qe,_(t.form.recommended_at?"Date: ("+this.$formatDate(t.form.recommended_at)+")":""),1)):(m(),u("div",Je,_(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1))])]),t.form.allow_higher_approval?(m(),u("div",Xe,[s("div",et,[t.approving_img?(m(),u("img",{key:0,src:t.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,tt)):(m(),u("div",it," No Image "))]),s("div",st,[e[11]||(e[11]=s("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),s("div",ot,_(t.approving),1),s("div",nt,_(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1)])])):p("",!0)]),s("div",at,[s("div",null,[s("label",rt,[z(s("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:t.form.allow_higher_approval,"onUpdate:modelValue":e[8]||(e[8]=c=>t.form.allow_higher_approval=c)},null,8,lt),[[q,t.form.allow_higher_approval]]),e[12]||(e[12]=s("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[s("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",stroke:"currentColor","stroke-width":"1"},[s("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"})])],-1)),e[13]||(e[13]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])]),s("div",mt,[t.state.isEdit?t.form.status===0?(m(),y(v,{key:1,onClick:r.submitForm},null,8,["onClick"])):p("",!0):(m(),y(S,{key:0,onClick:r.submitForm},null,8,["onClick"])),n(T,{onClick:r.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const le=E(Se,[["render",ct],["__scopeId","data-v-8678f2ca"]]);const dt={components:{Alert:se,FileType:te,Fileinput:ee,FormModal:Y,FormGroup:G,TextInput:N,Textarea:W,SubmitButton:O,UpdateButton:$,CloseButton:L,Loading:U,Multiselect:X,Icon:M,Checkbox:ie},data(){return{recommending:"",recommending_img:"",approving:"",approving_img:"",form:{date_from:"",date_to:"",from_time:"",to_time:"",hours:"",destination:"",description:"",attachment:"",recommending_id:"",allow_higher_approval:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},fileIcons:{pdf:oe,jpg:ne,default:""},hoursBasedOnDays:!1}},methods:{async calculateHours(){var a,o;const i=this.form.from_time,e=this.form.to_time;if(console.log(e),this.form.date_from!=this.form.date_to){if(this.form.date_from&&this.form.date_to){this.hoursBasedOnDays=!0,this.state.isLoadingApprovers=!0;const t=j(this.form.date_from),r=j(this.form.date_to);let d={date_from:t.format("YYYY-MM-DD"),date_to:r.format("YYYY-MM-DD")};try{let g=(await xe.fetchHolidayDayoff(d)).data;this.form.hours=g}catch(x){((o=(a=x.response)==null?void 0:a.data)==null?void 0:o.message)==='Attempt to read property "schedule" on null'?this.noSchedule=!0:console.log(x)}}}else if(this.hoursBasedOnDays=!1,this.form.hours="",i&&e){const[t,r]=i.split(":").map(g=>parseFloat(g)||0),[d,x]=e.split(":").map(g=>parseFloat(g)||0);let h=d-t+(x-r)/60;h<0&&(h+=24),console.log(h.toFixed(2)),this.form.hours=h}},deleteFile(i){this.$swal.fire({title:"Are you sure you want remove the attachment?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.deleteFileAttachment()}),console.log("wawawawa",i)},async deleteFileAttachment(){const i=this.form.id,e=this.form.attachment,a={id:i,attachment:e};await w.removeAttachment(a).then(o=>{o.status==201?(this.$swal.fire({title:"Great!",text:"Attachment successfully deleted.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.form.attachment="",console.log("null dapat",this.form.attachment)):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(o=>{o.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:o.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},getFileTypeImage(i){if(typeof i=="string"){if(!i)return this.fileIcons.default;const e=i.substring(i.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(i){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await K.Reader2("employee-overtime",i),a;if(i.endsWith(".pdf"))a="application/pdf";else if(i.endsWith(".png"))a="image/png";else if(i.endsWith(".jpg")||i.endsWith(".jpeg"))a="image/jpeg";else if(i.endsWith(".svg"))a="image/svg+xml";else throw new Error("Unsupported file type");const o=atob(e),t=new Array(o.length);for(let h=0;h<o.length;h++)t[h]=o.charCodeAt(h);const r=new Uint8Array(t),d=new Blob([r],{type:a}),x=URL.createObjectURL(d);window.open(x),this.state.isLoadingPDF=!1},handleMainImageUpload(){const i=event.target.files[0];this.form.attachment=i;const e=new FileReader;e.onload=()=>{i.type.startsWith("image/")?this.form.imageView=e.result:i.type==="application/pdf"?this.form.imageView=this.pdf_file_view:i.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(i),e.readAsDataURL(i)},loadRecord(i){this.resetForm(),this.state.isEdit=!0,this.form=i,this.form.date=new Date(i.date).toLocaleDateString("en-CA").split("T")[0],this.form.allow_higher_approval=i.allow_higher_approval==1},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date_from:"",date_to:"",from_time:"",to_time:"",hours:"",destination:"",description:"",attachment:"",allow_higher_approval:"",recommending_id:this.form.recommending_id,approver_id:this.form.approver_id}},reload(){return this.$emit("reload")},async fetchApprover(){this.state.isLoading=!0,await Z.fetchApproverRecords().then(i=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&i.data.map(e=>{this.form.allow_higher_approval?((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==3&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.approving==""&&e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")):((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""))}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&i.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&i.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.state.isLoading=!1}).catch(i=>{console.log(i)})},async saveRecord(){if(console.log(this.form),this.state.isSaving=!0,this.state.isEdit){this.form.id;let i=new FormData;Object.keys(this.form).forEach(e=>{i.append(e,this.form[e])}),await w.update(i).then(e=>{e.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(e=>{e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})}else{let i=new FormData;Object.keys(this.form).forEach(e=>{i.append(e,this.form[e])}),await w.create(i).then(e=>{e.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3}),this.state.showModal=!1,this.resetForm(),this.reload())}).catch(e=>{console.log(e),e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})}},async submitForm(){try{const i=Q().shape({date_from:V().required("Date From is required"),date_to:V().required("Date To is required"),hours:V().required("Hours is required")});this.form.hours>this.availableOffset?this.errors.hours="Hours must not exceed the available hours":this.errors.hours=!1,await i.validate(this.form,{abortEarly:!1}),this.errors.hours||this.$swal.fire({title:"Are you sure you want to save this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.saveRecord()})}catch(i){if(i instanceof J){const e={};i.inner.forEach(a=>{e[a.path]=a.message}),this.errors=e}}}},mounted(){this.fetchApprover()},watch:{"form.from_time":"calculateHours","form.to_time":"calculateHours","form.allow_higher_approval":{handler:"fetchApprover",immediate:!0}}},ft={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},ht={class:"grid grid-cols-12 gap-4"},ut={key:0,class:"text-[#ec4899]"},gt={key:0,class:"text-[#ec4899]"},pt={key:0,class:"col-span-4"},_t={key:1,class:"col-span-4"},xt={class:"col-span-4"},yt={class:"col-span-12"},wt={key:0,class:"text-[#ec4899]"},vt={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},bt={class:"flex justify-between w-full items-center"},Ct={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},Ft={class:"col-span-12"},kt={class:"grid grid-cols-12 gap-4"},Dt={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},At={class:"flex-shrink-0 mr-4"},Rt=["src"],St={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Tt={class:"text-left"},Bt={class:"text-sm font-semibold text-gray-600"},Et={class:"text-lg font-bold text-gray-900"},Vt={key:0,class:"text-sm text-gray-900"},Mt={key:1,class:"text-sm text-gray-900"},It={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},Lt={class:"flex-shrink-0 mr-4"},Ot=["src"],Ut={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},jt={class:"text-left"},Pt={class:"text-lg font-bold text-gray-900"},Ht={class:"text-sm text-gray-900"},zt={class:"flex gap-2 justify-between"},qt={class:"flex items-center cursor-pointer"},Gt=["checked"],Yt={class:"flex gap-2"};function Nt(i,e,a,o,t,r){const d=l("Loading"),x=l("Alert"),h=l("flat-pickr"),g=l("FormGroup"),C=l("TextInput"),F=l("Fileinput"),D=l("Card"),k=l("FileType"),A=l("Icon"),R=l("Textarea"),S=l("SubmitButton"),v=l("UpdateButton"),T=l("CloseButton"),B=l("FormModal");return m(),y(B,{title:t.state.isEdit?"Edit Offset Availment":"Offset Availment Form",active:t.state.showModal,onSubmit:i.confirmSubmit,onClose:r.closeModal,themeClass:t.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:f(()=>[t.state.isEdit&&t.state.isLoading?(m(),y(d,{key:0,text:"Fetching record"})):p("",!0),t.state.isLoading?(m(),y(d,{key:1,text:"Fetching Approver"})):p("",!0),t.form.denied_reason?(m(),y(x,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:f(()=>[e[11]||(e[11]=s("span",{class:"font-semibold"},"Denied Reason:",-1)),b(" "+_(t.form.denied_reason),1)]),_:1})):p("",!0),s("div",ft,[s("form",{onSubmit:e[10]||(e[10]=H((...c)=>i.confirmSubmit&&i.confirmSubmit(...c),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[t.state.isSaving?(m(),y(d,{key:0,text:"Saving record"})):p("",!0),s("div",ht,[s("div",{class:I(`${t.hoursBasedOnDays?"col-span-4":"col-span-6"}`)},[n(g,{label:"Date From",isRequired:!0},{default:f(()=>[n(h,{modelValue:t.form.date_from,"onUpdate:modelValue":e[0]||(e[0]=c=>t.form.date_from=c),class:"form-control h-[48px]",id:"date_from",placeholder:"yyyy, dd M",onChange:r.calculateHours},null,8,["modelValue","onChange"])]),_:1}),t.errors.date_from?(m(),u("div",ut,"Date From is required")):p("",!0)],2),s("div",{class:I(`${t.hoursBasedOnDays?"col-span-4":"col-span-6"}`)},[n(g,{label:"Date To",isRequired:!0},{default:f(()=>[n(h,{modelValue:t.form.date_to,"onUpdate:modelValue":e[1]||(e[1]=c=>t.form.date_to=c),class:"form-control h-[48px]",id:"date_to",placeholder:"yyyy, dd M",onChange:r.calculateHours},null,8,["modelValue","onChange"])]),_:1}),t.errors.date_to?(m(),u("div",gt,"Date To is required")):p("",!0)],2),t.hoursBasedOnDays?p("",!0):(m(),u("div",pt,[n(g,{label:"From Time"},{default:f(()=>[n(h,{modelValue:t.form.from_time,"onUpdate:modelValue":e[2]||(e[2]=c=>t.form.from_time=c),class:"form-control h-12",placeholder:"From time",onChange:r.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})])),t.hoursBasedOnDays?p("",!0):(m(),u("div",_t,[n(g,{label:"To Time"},{default:f(()=>[n(h,{modelValue:t.form.to_time,"onUpdate:modelValue":e[3]||(e[3]=c=>t.form.to_time=c),class:"form-control h-12",placeholder:"To time",onChange:r.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})])),s("div",xt,[n(g,{label:"Hours"},{default:f(()=>[n(C,{type:"text",modelValue:t.form.hours,"onUpdate:modelValue":e[4]||(e[4]=c=>t.form.hours=c),error:t.errors.hours,classInput:"h-[48px]",disabled:""},null,8,["modelValue","error"])]),_:1})]),s("div",yt,[n(g,{label:"Attachment"},{default:f(()=>[n(D,{title:"File Input Basic"},{default:f(()=>[n(F,{modelValue:t.form.attachment,"onUpdate:modelValue":e[5]||(e[5]=c=>t.form.attachment=c),name:"basic",onChange:r.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),t.errors.attachment?(m(),u("div",wt,_(t.errors.attachment),1)):p("",!0)]),_:1}),typeof t.form.attachment=="string"&&t.form.attachment?(m(),u("div",vt,[s("div",bt,[s("div",{class:"flex items-center cursor-pointer",onClick:e[6]||(e[6]=c=>r.viewAttachment(t.form.attachment))},[n(k,{image:r.getFileTypeImage(t.form.attachment)},null,8,["image"]),b(" "+_(t.form.attachment),1)]),t.form.status==0?(m(),u("div",Ct,[n(A,{icon:"mingcute:delete-2-fill",onClick:e[7]||(e[7]=c=>r.deleteFile(t.form.id))})])):p("",!0)])])):p("",!0)]),_:1})]),s("div",Ft,[n(g,{label:"Remarks"},{default:f(()=>[n(R,{name:"pn4",placeholder:"Textarea",modelValue:t.form.description,"onUpdate:modelValue":e[8]||(e[8]=c=>t.form.description=c)},null,8,["modelValue"])]),_:1})])]),s("div",kt,[s("div",Dt,[s("div",At,[t.recommending_img?(m(),u("img",{key:0,src:t.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Rt)):(m(),u("div",St," No Image "))]),s("div",Tt,[s("div",Bt,_(t.form.allow_higher_approval?"Recommending":"Approving"),1),s("div",Et,_(t.recommending),1),t.form.allow_higher_approval?(m(),u("div",Vt,_(t.form.recommended_at?"Date: ("+this.$formatDate(t.form.recommended_at)+")":""),1)):(m(),u("div",Mt,_(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1))])]),t.form.allow_higher_approval?(m(),u("div",It,[s("div",Lt,[t.approving_img?(m(),u("img",{key:0,src:t.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Ot)):(m(),u("div",Ut," No Image "))]),s("div",jt,[e[12]||(e[12]=s("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),s("div",Pt,_(t.approving),1),s("div",Ht,_(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1)])])):p("",!0)]),s("div",zt,[s("div",null,[s("label",qt,[z(s("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:t.form.allow_higher_approval,"onUpdate:modelValue":e[9]||(e[9]=c=>t.form.allow_higher_approval=c)},null,8,Gt),[[q,t.form.allow_higher_approval]]),e[13]||(e[13]=s("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[s("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",stroke:"currentColor","stroke-width":"1"},[s("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"})])],-1)),e[14]||(e[14]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])]),s("div",Yt,[t.state.isEdit?t.form.status===0?(m(),y(v,{key:1,onClick:r.submitForm},null,8,["onClick"])):p("",!0):(m(),y(S,{key:0,onClick:r.submitForm},null,8,["onClick"])),n(T,{onClick:r.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const me=E(dt,[["render",Nt],["__scopeId","data-v-39ef6d7e"]]);const Wt={props:["params"],components:{EditButton:ae,DeleteButton:re},methods:{edit(){console.log(this.params.data),this.params.context.componentParent.editRecord(this.params.data)},deleteRecord(){this.params.context.componentParent.deleteRecord(this.params.data)}}},$t={class:"flex space-x-2"};function Zt(i,e,a,o,t,r){const d=l("EditButton"),x=l("DeleteButton");return m(),u("div",$t,[n(d,{onClick:r.edit},null,8,["onClick"]),n(x,{onClick:r.deleteRecord},null,8,["onClick"])])}const Kt=E(Wt,[["render",Zt],["__scopeId","data-v-e7bf136d"]]),Qt={components:{FilterTimekeeping:we,Availment:me,Earning:le,Button:P,ActionCellRenderer:Kt,AgGridVue:ye,TabGroup:ve,TabList:be,Tab:Ce,TabPanels:Fe,TabPanel:ke,Icon:M},props:{earnings:{type:Object,required:!0},availment:{type:Object,required:!0}},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:1},{field:"employee_id",filter:!0,floatingFilter:!0,flex:2},{field:"name",filter:!0,floatingFilter:!0,flex:2},{field:"date",filter:!0,floatingFilter:!0,flex:2},{field:"hours",filter:!0,floatingFilter:!0,flex:1},{field:"created_at",headerName:"Created At",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,cellRenderer:i=>{const e=i.value,a=i.data.validated;return e===0?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-yellow-600 bg-gray-100 px-4">For Recommendation</span>':e===1?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-blue-600 bg-gray-100 px-4">For Approval</span>':a===1&&e===2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-green-600 px-4">Approved & Validated </div>':a===99&&e===2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-orange-600 px-4">Denied </div>':e===2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-fuchsia-600 px-4">For Validation</div>':e===99?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-red-600 bg-gray-100 px-4">Denied</span>':""}},{headerName:"Actions",cellRenderer:"ActionCellRenderer",flex:1,cellRendererParams:{context:{componentParent:this},code:"listOfOffsetEarning"}}],colDefsAvailment:[{field:"#",flex:1},{field:"employee_id",filter:!0,floatingFilter:!0,flex:2},{field:"name",filter:!0,floatingFilter:!0,flex:2},{field:"date coverage",filter:!0,floatingFilter:!0,flex:2},{field:"time coverage",filter:!0,floatingFilter:!0,flex:2},{field:"created_at",headerName:"Created At",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,cellRenderer:i=>{const e=i.value,a=i.data.validated;return e===0?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-yellow-600 bg-gray-100 px-4">For Recommendation</span>':e===1?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-blue-600 bg-gray-100 px-4">For Approval</span>':a==1&&e==2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-green-600 px-4">Validated </div>':a===99&&e===2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-orange-600 px-4">Denied </div>':e===2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-fuchsia-600 px-4">For Validation</div>':e===99?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-red-600 bg-gray-100 px-4">Denied</span>':""}},{headerName:"Actions",cellRenderer:"ActionCellRenderer",flex:1,cellRendererParams:{context:{componentParent:this},code:"listOfOffsetAvailment"}}],buttons:[{title:"Earn Offset",icon:"hugeicons:money-receive-01"},{title:"Avail Offset",icon:"hugeicons:money-send-flow-01"}],state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},methods:{applyFilters(i){return console.log("blabla",i),this.$emit("handleReload",i)},reload(){return this.$emit("reload")},onGridReady(i){this.gridApi=i.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(i=>i.field!=="actions").map(i=>i.field)}):console.error("Grid API is not ready.")},editRecord(i){let e=i.ref;e=="earning"?(this.$refs.earning.resetForm(),this.$refs.earning.loadRecord(i),this.$refs.earning.state.showModal=!0):e=="availment"&&(this.$refs.availment.resetForm(),this.$refs.availment.loadRecord(i),this.$refs.availment.state.showModal=!0)},createRecord(i){i=="earning"?(this.$refs.earning.resetForm(),this.$refs.earning.state.showModal=!0):i=="availment"&&(this.$refs.availment.resetForm(),this.$refs.availment.state.showModal=!0)},async deleteRecord(i){let e=i.id,a=i.ref,o="";a=="earning"?o=w.removeEarning:a=="availment"&&(o=w.remove),this.$swal.fire({title:"Are you sure?",text:"You want to delete this record?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes, delete it!",background:this.$store.themeSettingsStore.isDark?"#1e293b":"#fff"}).then(t=>{console.log(t.value),t.value&&(this.state.isDeleting=!0,o(e).then(r=>{r.status==200&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.reloadRecords())}))}).catch(t=>{t.response&&t.response.status==401&&this.$swal.fire({title:"Ooops! something is wrong.",text:"Error deleting record. Please contact system administrator",type:"error",icon:"error",timer:2e3})})}}},Jt={class:"text-3xl relative top-[1px] ltr:mr-1 rtl:ml-1"},Xt={class:"relative"},ei={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},ti={class:"flex items-center gap-4"},ii={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},si={class:"relative"},oi={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},ni={class:"flex items-center gap-4"},ai={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function ri(i,e,a,o,t,r){const d=l("Icon"),x=l("Tab"),h=l("TabList"),g=l("FilterTimekeeping"),C=l("Button"),F=l("ag-grid-vue"),D=l("Earning"),k=l("TabPanel"),A=l("Availment"),R=l("TabPanels"),S=l("TabGroup");return m(),y(S,{as:"div",class:"flex flex-col"},{default:f(()=>[n(h,{class:"lg:space-x-8 md:space-x-4 space-x-0 rtl:space-x-reverse"},{default:f(()=>[(m(!0),u(pe,null,ge(t.buttons,(v,T)=>(m(),y(x,{as:"template",key:T},{default:f(B=>[s("button",{class:I([[B.selected?"text-primary-500 before:w-full":"text-slate-500 before:w-0 dark:text-slate-300"],"inline-flex items-center text-sm font-medium mb-7 capitalize bg-white dark:bg-slate-800 ring-0 focus:ring-0 focus:outline-none px-2 transition duration-150 before:transition-all before:duration-150 relative before:absolute before:left-1/2 before:bottom-[-6px] before:h-[1.5px] before:bg-primary-500 before:-translate-x-1/2"])},[s("span",Jt,[n(d,{icon:v.icon},null,8,["icon"])]),b(" "+_(v.title),1)],2)]),_:2},1024))),128))]),_:1}),n(R,null,{default:f(()=>[n(k,null,{default:f(()=>[s("div",Xt,[s("div",ei,[e[4]||(e[4]=s("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," Earning of offset ",-1)),s("div",ti,[n(g,{onFilterChanged:r.applyFilters},null,8,["onFilterChanged"]),n(C,{icon:"mdi:microsoft-excel",text:"Export to CSV",btnClass:"relative overflow-hidden font-normal px-4 py-2 rounded-lg shadow-md bg-white text-gray-900 border group transition-colors duration-300 group-hover:border-green-500",iconClass:"text-2xl",onClick:r.exportToCsv},{default:f(()=>[e[3]||(e[3]=s("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),s("span",ii,[n(d,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[2]||(e[2]=b(" Export to CSV "))])]),_:1},8,["onClick"])])])]),n(F,{ref:"agGrid",rowData:a.earnings,columnDefs:t.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:t.paginationPageSize,paginationPageSizeSelector:t.paginationPageSizeSelector,onGridReady:r.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"]),n(D,{onCloseModal:e[0]||(e[0]=v=>t.state.showModal=!1),ref:"earning",onReload:r.reload},null,8,["onReload"])]),_:1}),n(k,null,{default:f(()=>[s("div",si,[s("div",oi,[e[7]||(e[7]=s("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," Offset Availment ",-1)),s("div",ni,[n(g,{onFilterChanged:r.applyFilters},null,8,["onFilterChanged"]),n(C,{icon:"mdi:microsoft-excel",text:"Export to CSV",btnClass:"relative overflow-hidden font-normal px-4 py-2 rounded-lg shadow-md bg-white text-gray-900 border group transition-colors duration-300 group-hover:border-green-500",iconClass:"text-2xl",onClick:r.exportToCsv},{default:f(()=>[e[6]||(e[6]=s("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),s("span",ai,[n(d,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[5]||(e[5]=b(" Export to CSV "))])]),_:1},8,["onClick"])])])]),n(F,{ref:"agGrid",rowData:a.availment,columnDefs:t.colDefsAvailment,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:t.paginationPageSize,paginationPageSizeSelector:t.paginationPageSizeSelector,onGridReady:r.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"]),n(A,{onCloseModal:e[1]||(e[1]=v=>t.state.showModal=!1),ref:"availment",onReload:r.reload},null,8,["onReload"])]),_:1})]),_:1})]),_:1})}const li=E(Qt,[["render",ri]]);const mi={mixins:[ce],components:{TabIcon:li,Pagination:Re,Card:fe,Button:P,Badge:he,Layout:de,Icon:M,CreateButton:De,SubmitButton:O,CloseButton:L,EditButton:ae,DeleteButton:re,ViewButton:Ae,Availment:me,Earning:le,InputGroup:ue,Loading:U},data(){return{earnings:[],totalOffset:"",breadcrumbs:[{text:"Home",href:"/"},{text:"Timekeeping",href:"/attendance/employee-offset"},{text:"Offset Application",active:!0}],items:[],totalItems:0,searchQuery:null,state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{},methods:{async reloadRecords(){await this.fetchRecords(),await this.fetchEarningRecords()},formatDate(i){const e=new Date(i),a=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),o=new Date(a.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),t=o.getFullYear(),r=String(o.getMonth()+1).padStart(2,"0"),d=String(o.getDate()).padStart(2,"0");return`${t}-${r}-${d}`},async fetchEarningRecords(i={}){this.state.isLoading=!0,await w.fetchRecordListEarning({dealership:this.$store.userSettings.activeDealership,...i}).then(e=>{let a=e.data.data;this.earnings=a.data.map((o,t)=>({...o,"#":t+1,employee_id:o.employee_id,name:o.employee.lastname+", "+o.employee.firstname,date:this.$formatDate(o.date),hours:o.hours,created_at:this.$formatDate(o.created_at),status:o.status,ref:"earning"}))}).finally(()=>{this.state.isLoading=!1})},async fetchRecords(i={}){this.state.isLoading=!0,await w.fetchRecordListAvailment({dealership:this.$store.userSettings.activeDealership,...i}).then(e=>{let a=e.data.data.data;this.items=a.map((o,t)=>({...o,"#":t+1,employee_id:o.employee_id,name:o.employee.firstname+" "+o.employee.lastname,"date coverage":o.date_from===o.date_to?this.$formatDate(o.date_from):this.$formatDate(o.date_from)+" - "+this.$formatDate(o.date_to)+(o.half_day?o.meridiem?" (PM)":" (AM)":""),"time coverage":this.$formatTime(o.from_time)+" - "+this.$formatTime(o.to_time)+" ("+o.hours+" Hours)",created_at:this.$formatDate(o.created_at),status:o.status,ref:"availment"}))}).finally(()=>{this.state.isLoading=!1})},handleFilters(i){this.fetchRecords(i),this.fetchEarningRecords(i)},reload(){this.$emit("reload")},async deleteRecord(i,e){console.log("try"),console.log(e);let a="";e=="earning"?a=w.removeEarning:e=="availment"&&(a=w.remove),this.$swal.fire({title:"Are you sure?",text:"You want to delete this record?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes, delete it!",background:this.$store.themeSettingsStore.isDark?"#1e293b":"#fff"}).then(o=>{console.log(o.value),o.value&&(this.state.isDeleting=!0,a(i).then(t=>{t.status==200&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.reloadRecords())}))}).catch(o=>{o.response&&o.response.status==401&&this.$swal.fire({title:"Ooops! something is wrong.",text:"Error deleting record. Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{this.reloadRecords(),this.state.isDeleting=!1})},createRecord(i){console.log(i),i=="earning"?(this.$refs.earning.resetForm(),this.$refs.earning.state.showModal=!0):i=="availment"&&(this.$refs.availment.resetForm(),this.$refs.availment.state.showModal=!0)},editRecord(i,e){e=="earning"?(this.$refs.earning.resetForm(),this.$refs.earning.loadRecord(i),this.$refs.earning.state.showModal=!0):e=="availment"&&(this.$refs.availment.resetForm(),this.$refs.availment.loadRecord(i),this.$refs.availment.state.showModal=!0)}},mounted(){this.fetchRecords(),this.fetchEarningRecords()}},ci={class:"space-y-4 mt-4"},di={class:"flex-1 md:mb-0 mb-3"};function fi(i,e,a,o,t,r){const d=l("TabIcon"),x=l("Card"),h=l("Loading"),g=l("Layout");return m(),y(g,{breadcrumbs:t.breadcrumbs},{default:f(()=>[s("div",ci,[n(x,{title:"Offset Applications"},{default:f(()=>[s("h6",di,_(i.title),1),n(d,{earnings:t.earnings,availment:t.items,onHandleReload:r.handleFilters},null,8,["earnings","availment","onHandleReload"]),e[0]||(e[0]=s("div",{class:"grid grid-cols-2 gap-6 mt-4"},null,-1))]),_:1}),t.state.isLoading?(m(),y(h,{key:0,text:"Fetching records"})):p("",!0)])]),_:1},8,["breadcrumbs"])}const cs=E(mi,[["render",fi],["__scopeId","data-v-00e03ece"]]);export{cs as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings