File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.3b78f9fe.js
Back
import{w as fe,L as he}from"./index.e90b797d.js";import{C as ue}from"./index.609bcb7c.js";import{B as q}from"./index.1e572db2.js";import{B as ge}from"./index.8925dff3.js";import{I as P}from"./index.a5110576.js";import{I as pe}from"./index.d1aceaee.js";import{l as _e}from"./lodash.adf89e63.js";import{_ as B,r as m,o as a,c as x,w as h,j as p,d as o,f as b,t as _,k as M,e as n,b as g,p as G,s as N,q as j,h as A,F as I,m as z}from"./index.3a33b88d.js";import{E as v}from"./EmployeeOffsetService.e4fc6909.js";import{C as L}from"./CloseButton.d312e091.js";/* empty css */import{S as H}from"./SubmitButton.16c237a6.js";import{U as Y}from"./UpdateButton.285ca87f.js";import"./jspdf.es.min.763284f3.js";/* empty css */import{A as $}from"./index.c983e8aa.js";import{C as W}from"./index.ecbbc19d.js";import{F as Q}from"./index.3646a8b7.js";import{F as Z}from"./index.25258c66.js";import{F as K}from"./index.f8c90c2f.js";import{F as J}from"./index.8531a646.js";/* empty css */import{T as X}from"./index.a785f83f.js";import{L as U}from"./Loading.d8a54a1a.js";import{T as ee}from"./index.aaf22f12.js";import{A as te}from"./ApproverService.fd062fd5.js";import{F as se}from"./FileService.3bf05a89.js";import{M as oe}from"./Multiselect.c4704026.js";import{c as ie,b as ye,a as E,V as ne}from"./array.0146f311.js";import{p as re,j as ae}from"./scr-1.d9aaecca.js";import{E as xe}from"./EmployeeLeaveService.1fc77861.js";import{A as we}from"./main.esm.786d3a20.js";import{E as le}from"./EditButton.5d564d58.js";import{D as me}from"./DeleteButton.3d4df072.js";import{m as ve,p as be,x as Ce,I as ke,y as Fe}from"./tabs.0182c6c2.js";import{C as Ae}from"./CreateButton.96a43e5c.js";import{V as De}from"./ViewButton.a3057bdc.js";import{P as Re}from"./index.1269b959.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.bee8c07d.js";import"./vue-cleave.min.88d00a75.js";import"./es.string.replace.f897d4b0.js";import"./ck-white.4bf441fa.js";import"./index.212d4b04.js";const Te={components:{Alert:$,FileType:Z,Fileinput:Q,FormModal:J,FormGroup:K,TextInput:X,Textarea:ee,SubmitButton:H,UpdateButton:Y,CloseButton:L,Loading:U,Multiselect:oe,Icon:P,Checkbox:W},data(){return{recommending:"",recommending_img:"",approving:"",approving_img:"",temp_from_time:"",temp_to_time:"",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:re,jpg:ae,default:""}}},methods:{async CheckTitoOrWFH(){var t,e;await v.fetchTiToOWfh({date:this.form.date,employee_id:(t=this.$store.userSettings.getActiveUser.employees)==null?void 0:t.employee_id,time_keeping_id:(e=this.$store.userSettings.getActiveUser.employees)==null?void 0:e.time_keeping_id}).then(i=>{try{this.form.from_time=i.data.from_time,this.form.to_time=i.data.to_time,this.form.hours=i.data.hours,this.temp_from_time=i.data.from_time,this.temp_to_time=i.data.to_time}catch{console.log("error")}}).catch(i=>{console.log(i)})},calculateHours(){const t=this.form.from_time,e=this.form.to_time;if(t&&e){const[i,l]=this.form.from_time.split(":").map(Number),[s,r]=this.form.to_time.split(":").map(Number);let c=s-i;c+=(r-l)/60,c<0&&(c+=24),c<4?this.errors.hours="Hours must be at least 4":this.errors.hours=!1,c>0&&c>8&&(c=c-1),this.form.hours=c}},deleteFile(t){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",t)},async deleteFileAttachment(){const t=this.form.id,e=this.form.attachment,i={id:t,attachment:e};await v.removeAttachmentEarning(i).then(l=>{l.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(l=>{l.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:l.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},getFileTypeImage(t){if(typeof t=="string"){if(!t)return this.fileIcons.default;const e=t.substring(t.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(t){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await se.Reader2("employee-overtime",t),i;if(t.endsWith(".pdf"))i="application/pdf";else if(t.endsWith(".png"))i="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))i="image/jpeg";else if(t.endsWith(".svg"))i="image/svg+xml";else throw new Error("Unsupported file type");const l=atob(e),s=new Array(l.length);for(let f=0;f<l.length;f++)s[f]=l.charCodeAt(f);const r=new Uint8Array(s),c=new Blob([r],{type:i}),y=URL.createObjectURL(c);window.open(y),this.state.isLoadingPDF=!1},handleMainImageUpload(){const t=event.target.files[0];this.form.attachment=t;const e=new FileReader;e.onload=()=>{t.type.startsWith("image/")?this.form.imageView=e.result:t.type==="application/pdf"?this.form.imageView=this.pdf_file_view:t.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(t),e.readAsDataURL(t)},loadRecord(t){this.resetForm(),this.state.isEdit=!0,this.form=t,this.form.date=new Date(t.date).toLocaleDateString("en-CA").split("T")[0],this.form.allow_higher_approval=t.allow_higher_approval==1},closeModal(){this.state.showModal=!1},resetForm(){this.errors={},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 te.fetchApproverRecords().then(t=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&t.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&&t.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&&t.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(t=>{console.log(t)})},async saveRecord(){if(console.log(this.form),this.state.isSaving=!0,this.state.isEdit){this.form.id;let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await v.updateEarning(t).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 t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await v.createEarning(t).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 t=ie().shape({date:ye().required("Date is required").typeError("Date is required"),hours:E().required("Hours is required").test("min-hours","Hours must be at least 4",e=>!isNaN(e)&&Number(e)>=4)});this.form.date.length==0&&(this.errors.date=!0),console.log(t),this.form.hours>this.availableOffset?this.errors.hours="Hours must not exceed the available hours":this.errors.hours=!1,await t.validate(this.form,{abortEarly:!1}),this.form.hours<4?this.errors.hours="Hours must be at least 4":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(t){if(t instanceof ne){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}}},mounted(){this.fetchApprover()},watch:{"form.from_time":"calculateHours","form.to_time":"calculateHours","form.allow_higher_approval":{handler:"fetchApprover",immediate:!0}}},Se={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Oe={class:"grid grid-cols-12 gap-4"},Be={class:"col-span-12"},Ee={class:"text-[#ed539f]"},Pe={class:"col-span-4"},Ve={class:"col-span-4"},Ie={class:"col-span-4"},Me={class:"col-span-12"},Le={key:0,class:"text-[#ec4899]"},He={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},Ue={class:"flex justify-between w-full items-center"},je={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"},Ne={class:"flex-shrink-0 mr-4"},Ye=["src"],$e={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},We={class:"text-left"},Qe={class:"text-sm font-semibold text-gray-600"},Ze={class:"text-lg font-bold text-gray-900"},Ke={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"],st={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},ot={class:"text-left"},it={class:"text-lg font-bold text-gray-900"},nt={class:"text-sm text-gray-900"},rt={class:"flex gap-2 justify-between"},at={class:"flex items-center cursor-pointer"},lt=["checked"],mt={class:"flex gap-2"};function ct(t,e,i,l,s,r){const c=m("Loading"),y=m("Alert"),f=m("flat-pickr"),u=m("FormGroup"),k=m("TextInput"),D=m("Fileinput"),F=m("Card"),R=m("FileType"),T=m("Icon"),S=m("Textarea"),w=m("SubmitButton"),C=m("UpdateButton"),O=m("CloseButton"),V=m("FormModal");return a(),x(V,{title:s.state.isEdit?"Edit Offset Earning":"Offset Earning Form",active:s.state.showModal,onSubmit:t.confirmSubmit,onClose:r.closeModal,themeClass:s.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:h(()=>[s.state.isEdit&&s.state.isLoading?(a(),x(c,{key:0,text:"Fetching record"})):p("",!0),s.state.isLoading?(a(),x(c,{key:1,text:"Fetching Approver"})):p("",!0),s.form.denied_reason?(a(),x(y,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:h(()=>[e[11]||(e[11]=o("span",{class:"font-semibold"},"Denied Reason:",-1)),b(" "+_(s.form.denied_reason),1)]),_:1})):p("",!0),o("div",Se,[o("form",{onSubmit:e[10]||(e[10]=M((...d)=>t.confirmSubmit&&t.confirmSubmit(...d),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[s.state.isSaving?(a(),x(c,{key:0,text:"Saving record"})):p("",!0),o("div",Oe,[o("div",Be,[n(u,{label:"Date",isRequired:!0},{default:h(()=>[n(f,{modelValue:s.form.date,"onUpdate:modelValue":e[0]||(e[0]=d=>s.form.date=d),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M",onChange:e[1]||(e[1]=M(d=>r.CheckTitoOrWFH(),["prevent"]))},null,8,["modelValue"])]),_:1}),o("div",Ee,_(s.errors.date),1)]),o("div",Pe,[n(u,{label:"From Time",isRequired:!0},{default:h(()=>[n(f,{modelValue:s.form.from_time,"onUpdate:modelValue":e[2]||(e[2]=d=>s.form.from_time=d),class:"form-control h-12",placeholder:"From time",onChange:r.calculateHours,disabled:"true",config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),o("div",Ve,[n(u,{label:"To Time",isRequired:!0},{default:h(()=>[n(f,{modelValue:s.form.to_time,"onUpdate:modelValue":e[3]||(e[3]=d=>s.form.to_time=d),class:"form-control h-12",placeholder:"To time",onChange:r.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i",minTime:s.temp_from_time,maxTime:s.temp_to_time}},null,8,["modelValue","onChange","config"])]),_:1})]),o("div",Ie,[n(u,{label:"Hours",isRequired:!0},{default:h(()=>[n(k,{disabled:"true",type:"text",modelValue:s.form.hours,"onUpdate:modelValue":e[4]||(e[4]=d=>s.form.hours=d),error:s.errors.hours,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1})]),o("div",Me,[n(u,{label:"Attachment"},{default:h(()=>[n(F,{title:"File Input Basic"},{default:h(()=>[n(D,{modelValue:s.form.attachment,"onUpdate:modelValue":e[5]||(e[5]=d=>s.form.attachment=d),name:"basic",onChange:r.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),s.errors.attachment?(a(),g("div",Le,_(s.errors.attachment),1)):p("",!0)]),_:1}),typeof s.form.attachment=="string"&&s.form.attachment?(a(),g("div",He,[o("div",Ue,[o("div",{class:"flex items-center cursor-pointer",onClick:e[6]||(e[6]=d=>r.viewAttachment(s.form.attachment))},[n(R,{image:r.getFileTypeImage(s.form.attachment)},null,8,["image"]),b(" "+_(s.form.attachment),1)]),s.form.status==0?(a(),g("div",je,[n(T,{icon:"mingcute:delete-2-fill",onClick:e[7]||(e[7]=d=>r.deleteFile(s.form.id))})])):p("",!0)])])):p("",!0)]),_:1})]),o("div",ze,[n(u,{label:"Remarks"},{default:h(()=>[n(S,{name:"pn4",placeholder:"Enter your remarks here",modelValue:s.form.description,"onUpdate:modelValue":e[8]||(e[8]=d=>s.form.description=d)},null,8,["modelValue"])]),_:1})])]),o("div",qe,[o("div",Ge,[o("div",Ne,[s.recommending_img?(a(),g("img",{key:0,src:s.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Ye)):(a(),g("div",$e," No Image "))]),o("div",We,[o("div",Qe,_(s.form.allow_higher_approval?"Recommending":"Approving"),1),o("div",Ze,_(s.recommending),1),s.form.allow_higher_approval?(a(),g("div",Ke,_(s.form.recommended_at?"Date: ("+this.$formatDate(s.form.recommended_at)+")":""),1)):(a(),g("div",Je,_(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1))])]),s.form.allow_higher_approval?(a(),g("div",Xe,[o("div",et,[s.approving_img?(a(),g("img",{key:0,src:s.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,tt)):(a(),g("div",st," No Image "))]),o("div",ot,[e[12]||(e[12]=o("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),o("div",it,_(s.approving),1),o("div",nt,_(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1)])])):p("",!0)]),o("div",rt,[o("div",null,[o("label",at,[G(o("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:s.form.allow_higher_approval,"onUpdate:modelValue":e[9]||(e[9]=d=>s.form.allow_higher_approval=d)},null,8,lt),[[N,s.form.allow_higher_approval]]),e[13]||(e[13]=o("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[o("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"},[o("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]=o("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])]),o("div",mt,[s.state.isEdit?s.form.status===0?(a(),x(C,{key:1,onClick:r.submitForm},null,8,["onClick"])):p("",!0):(a(),x(w,{key:0,onClick:r.submitForm},null,8,["onClick"])),n(O,{onClick:r.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const ce=B(Te,[["render",ct],["__scopeId","data-v-b968401a"]]);const dt={components:{Alert:$,FileType:Z,Fileinput:Q,FormModal:J,FormGroup:K,TextInput:X,Textarea:ee,SubmitButton:H,UpdateButton:Y,CloseButton:L,Loading:U,Multiselect:oe,Icon:P,Checkbox:W},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:re,jpg:ae,default:""},hoursBasedOnDays:!1}},methods:{async calculateHours(){var i,l;const t=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 s=j(this.form.date_from),r=j(this.form.date_to);let c={date_from:s.format("YYYY-MM-DD"),date_to:r.format("YYYY-MM-DD")};try{let u=(await xe.fetchHolidayDayoff(c)).data;u<4?this.errors.hours="Hours must be at least 4":this.errors.hours=!1,this.form.hours=u>4?u-1:u}catch(y){((l=(i=y.response)==null?void 0:i.data)==null?void 0:l.message)==='Attempt to read property "schedule" on null'?this.noSchedule=!0:console.log(y)}}}else if(this.hoursBasedOnDays=!1,this.form.hours="",t&&e){const[s,r]=t.split(":").map(u=>parseFloat(u)||0),[c,y]=e.split(":").map(u=>parseFloat(u)||0);let f=c-s+(y-r)/60;f<0&&(f+=24),f<4?this.errors.hours="Hours must be at least 4":this.errors.hours=!1,f>0&&f>8&&(f=f-1),this.form.hours=f}},deleteFile(t){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",t)},async deleteFileAttachment(){const t=this.form.id,e=this.form.attachment,i={id:t,attachment:e};await v.removeAttachment(i).then(l=>{l.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(l=>{l.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:l.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},getFileTypeImage(t){if(typeof t=="string"){if(!t)return this.fileIcons.default;const e=t.substring(t.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(t){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await se.Reader2("employee-overtime",t),i;if(t.endsWith(".pdf"))i="application/pdf";else if(t.endsWith(".png"))i="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))i="image/jpeg";else if(t.endsWith(".svg"))i="image/svg+xml";else throw new Error("Unsupported file type");const l=atob(e),s=new Array(l.length);for(let f=0;f<l.length;f++)s[f]=l.charCodeAt(f);const r=new Uint8Array(s),c=new Blob([r],{type:i}),y=URL.createObjectURL(c);window.open(y),this.state.isLoadingPDF=!1},handleMainImageUpload(){const t=event.target.files[0];this.form.attachment=t;const e=new FileReader;e.onload=()=>{t.type.startsWith("image/")?this.form.imageView=e.result:t.type==="application/pdf"?this.form.imageView=this.pdf_file_view:t.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(t),e.readAsDataURL(t)},loadRecord(t){this.resetForm(),this.state.isEdit=!0,this.form=t,this.form.date=new Date(t.date).toLocaleDateString("en-CA").split("T")[0],this.form.allow_higher_approval=t.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 te.fetchApproverRecords().then(t=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&t.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&&t.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&&t.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(t=>{console.log(t)})},async saveRecord(){if(console.log(this.form),this.state.isSaving=!0,this.state.isEdit){this.form.id;let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await v.update(t).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 t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await v.create(t).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 t=ie().shape({date_from:E().required("Date From is required"),date_to:E().required("Date To is required"),hours:E().required("Hours is required").test("min-hours","Hours must be at least 4",e=>!isNaN(e)&&Number(e)>=4)});this.form.hours>this.availableOffset?this.errors.hours="Hours must not exceed the available hours":this.errors.hours=!1,await t.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(t){if(t instanceof ne){const e={};t.inner.forEach(i=>{e[i.path]=i.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"},yt={class:"col-span-4"},xt={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"},kt={class:"col-span-12"},Ft={class:"grid grid-cols-12 gap-4"},At={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},Dt={class:"flex-shrink-0 mr-4"},Rt=["src"],Tt={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-sm font-semibold text-gray-600"},Bt={class:"text-lg font-bold text-gray-900"},Et={key:0,class:"text-sm text-gray-900"},Pt={key:1,class:"text-sm text-gray-900"},Vt={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},It={class:"flex-shrink-0 mr-4"},Mt=["src"],Lt={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Ht={class:"text-left"},Ut={class:"text-lg font-bold text-gray-900"},jt={class:"text-sm text-gray-900"},zt={class:"flex gap-2 justify-between"},qt={class:"flex items-center cursor-pointer"},Gt=["checked"],Nt={class:"flex gap-2"};function Yt(t,e,i,l,s,r){const c=m("Loading"),y=m("Alert"),f=m("flat-pickr"),u=m("FormGroup"),k=m("TextInput"),D=m("Fileinput"),F=m("Card"),R=m("FileType"),T=m("Icon"),S=m("Textarea"),w=m("SubmitButton"),C=m("UpdateButton"),O=m("CloseButton"),V=m("FormModal");return a(),x(V,{title:s.state.isEdit?"Edit Offset Availment":"Offset Availment Form",active:s.state.showModal,onSubmit:t.confirmSubmit,onClose:r.closeModal,themeClass:s.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:h(()=>[s.state.isEdit&&s.state.isLoading?(a(),x(c,{key:0,text:"Fetching record"})):p("",!0),s.state.isLoading?(a(),x(c,{key:1,text:"Fetching Approver"})):p("",!0),s.form.denied_reason?(a(),x(y,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:h(()=>[e[11]||(e[11]=o("span",{class:"font-semibold"},"Denied Reason:",-1)),b(" "+_(s.form.denied_reason),1)]),_:1})):p("",!0),o("div",ft,[o("form",{onSubmit:e[10]||(e[10]=M((...d)=>t.confirmSubmit&&t.confirmSubmit(...d),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[s.state.isSaving?(a(),x(c,{key:0,text:"Saving record"})):p("",!0),o("div",ht,[o("div",{class:A(`${s.hoursBasedOnDays?"col-span-4":"col-span-6"}`)},[n(u,{label:"Date From",isRequired:!0},{default:h(()=>[n(f,{modelValue:s.form.date_from,"onUpdate:modelValue":e[0]||(e[0]=d=>s.form.date_from=d),class:"form-control h-[48px]",id:"date_from",placeholder:"yyyy, dd M",onChange:r.calculateHours},null,8,["modelValue","onChange"])]),_:1}),s.errors.date_from?(a(),g("div",ut," Date From is required ")):p("",!0)],2),o("div",{class:A(`${s.hoursBasedOnDays?"col-span-4":"col-span-6"}`)},[n(u,{label:"Date To",isRequired:!0},{default:h(()=>[n(f,{modelValue:s.form.date_to,"onUpdate:modelValue":e[1]||(e[1]=d=>s.form.date_to=d),class:"form-control h-[48px]",id:"date_to",placeholder:"yyyy, dd M",onChange:r.calculateHours},null,8,["modelValue","onChange"])]),_:1}),s.errors.date_to?(a(),g("div",gt," Date To is required ")):p("",!0)],2),s.hoursBasedOnDays?p("",!0):(a(),g("div",pt,[n(u,{label:"From Time"},{default:h(()=>[n(f,{modelValue:s.form.from_time,"onUpdate:modelValue":e[2]||(e[2]=d=>s.form.from_time=d),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.hoursBasedOnDays?p("",!0):(a(),g("div",_t,[n(u,{label:"To Time"},{default:h(()=>[n(f,{modelValue:s.form.to_time,"onUpdate:modelValue":e[3]||(e[3]=d=>s.form.to_time=d),class:"form-control h-12",placeholder:"To time",onChange:r.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})])),o("div",yt,[n(u,{label:"Hours"},{default:h(()=>[n(k,{type:"text",modelValue:s.form.hours,"onUpdate:modelValue":e[4]||(e[4]=d=>s.form.hours=d),error:s.errors.hours,classInput:"h-[48px]",disabled:""},null,8,["modelValue","error"])]),_:1})]),o("div",xt,[n(u,{label:"Attachment"},{default:h(()=>[n(F,{title:"File Input Basic"},{default:h(()=>[n(D,{modelValue:s.form.attachment,"onUpdate:modelValue":e[5]||(e[5]=d=>s.form.attachment=d),name:"basic",onChange:r.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),s.errors.attachment?(a(),g("div",wt,_(s.errors.attachment),1)):p("",!0)]),_:1}),typeof s.form.attachment=="string"&&s.form.attachment?(a(),g("div",vt,[o("div",bt,[o("div",{class:"flex items-center cursor-pointer",onClick:e[6]||(e[6]=d=>r.viewAttachment(s.form.attachment))},[n(R,{image:r.getFileTypeImage(s.form.attachment)},null,8,["image"]),b(" "+_(s.form.attachment),1)]),s.form.status==0?(a(),g("div",Ct,[n(T,{icon:"mingcute:delete-2-fill",onClick:e[7]||(e[7]=d=>r.deleteFile(s.form.id))})])):p("",!0)])])):p("",!0)]),_:1})]),o("div",kt,[n(u,{label:"Remarks"},{default:h(()=>[n(S,{name:"pn4",placeholder:"Enter your text here",modelValue:s.form.description,"onUpdate:modelValue":e[8]||(e[8]=d=>s.form.description=d)},null,8,["modelValue"])]),_:1})])]),o("div",Ft,[o("div",At,[o("div",Dt,[s.recommending_img?(a(),g("img",{key:0,src:s.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Rt)):(a(),g("div",Tt," No Image "))]),o("div",St,[o("div",Ot,_(s.form.allow_higher_approval?"Recommending":"Approving"),1),o("div",Bt,_(s.recommending),1),s.form.allow_higher_approval?(a(),g("div",Et,_(s.form.recommended_at?"Date: ("+this.$formatDate(s.form.recommended_at)+")":""),1)):(a(),g("div",Pt,_(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1))])]),s.form.allow_higher_approval?(a(),g("div",Vt,[o("div",It,[s.approving_img?(a(),g("img",{key:0,src:s.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Mt)):(a(),g("div",Lt," No Image "))]),o("div",Ht,[e[12]||(e[12]=o("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),o("div",Ut,_(s.approving),1),o("div",jt,_(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1)])])):p("",!0)]),o("div",zt,[o("div",null,[o("label",qt,[G(o("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:s.form.allow_higher_approval,"onUpdate:modelValue":e[9]||(e[9]=d=>s.form.allow_higher_approval=d)},null,8,Gt),[[N,s.form.allow_higher_approval]]),e[13]||(e[13]=o("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[o("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"},[o("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]=o("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])]),o("div",Nt,[s.state.isEdit?s.form.status===0?(a(),x(C,{key:1,onClick:r.submitForm},null,8,["onClick"])):p("",!0):(a(),x(w,{key:0,onClick:r.submitForm},null,8,["onClick"])),n(O,{onClick:r.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const de=B(dt,[["render",Yt],["__scopeId","data-v-1e885fcb"]]);const $t={props:["params"],components:{EditButton:le,DeleteButton:me},methods:{edit(){console.log(this.params.data),this.params.context.componentParent.editRecord(this.params.data)},deleteRecord(){this.params.context.componentParent.deleteRecord(this.params.data)}}},Wt={class:"flex space-x-2"};function Qt(t,e,i,l,s,r){const c=m("EditButton"),y=m("DeleteButton");return a(),g("div",Wt,[n(c,{onClick:r.edit},null,8,["onClick"]),n(y,{onClick:r.deleteRecord},null,8,["onClick"])])}const Zt=B($t,[["render",Qt],["__scopeId","data-v-45f86db4"]]),Kt={components:{Availment:de,Earning:ce,Button:q,ActionCellRenderer:Zt,AgGridVue:we,TabGroup:ve,TabList:be,Tab:Ce,TabPanels:ke,TabPanel:Fe,Icon:P},props:{earnings:{type:Object,required:!0},availment:{type:Object,required:!0},statistics:{type:Object,required:!0}},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:0},{field:"date coverage",headerName:"Date",filter:!0,floatingFilter:!0,flex:2},{field:"hours",filter:!0,floatingFilter:!0,flex:2},{field:"date created",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,cellRenderer:t=>{const e=t.value;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>':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</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}}}],colDefsAvailment:[{field:"#",flex:0},{field:"date coverage",headerName:"Date",filter:!0,floatingFilter:!0,flex:2},{field:"time coverage",filter:!0,floatingFilter:!0,flex:2},{field:"date created",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,cellRenderer:t=>{const e=t.value;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>':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</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}}}],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:{reload(){return this.$emit("reload")},onGridReady(t){this.gridApi=t.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(t=>t.field!=="actions").map(t=>t.field)}):console.error("Grid API is not ready.")},editRecord(t){let e=t.ref;e=="earning"?(this.$refs.earning.resetForm(),this.$refs.earning.loadRecord(t),this.$refs.earning.state.showModal=!0):e=="availment"&&(this.$refs.availment.resetForm(),this.$refs.availment.loadRecord(t),this.$refs.availment.state.showModal=!0)},createRecord(t){t=="earning"?(this.$refs.earning.resetForm(),this.$refs.earning.state.showModal=!0):t=="availment"&&(this.$refs.availment.resetForm(),this.$refs.availment.availableOffset=this.statistics[0].count,this.$refs.availment.totalOffset=this.statistics[1].count,this.$refs.availment.state.showModal=!0)},async deleteRecord(t){let e=t.id,i=t.ref,l="";i=="earning"?l=v.removeEarning:i=="availment"&&(l=v.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(s=>{console.log(s.value),s.value&&(this.state.isDeleting=!0,l(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(s=>{s.response&&s.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:"grid grid-cols-1 gap-4 pb-4 mb-5 md:grid-cols-2"},Xt={class:A("h-14 w-14 flex items-center justify-center rounded-md text-4xl mb-4 shadow-lg bg-white")},es={class:"text-md font-semibold text-slate-700 dark:text-white mb-2"},ts={class:"flex justify-center gap-4"},ss={class:"text-2xl text-slate-900 dark:text-white font-semibold"},os={class:"text-3xl relative top-[1px] ltr:mr-1 rtl:ml-1"},is={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},ns={class:"flex items-center gap-4"},rs={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},as={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},ls={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},ms={class:"flex items-center gap-4"},cs={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},ds={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function fs(t,e,i,l,s,r){const c=m("Icon"),y=m("Tab"),f=m("TabList"),u=m("Button"),k=m("ag-grid-vue"),D=m("Earning"),F=m("TabPanel"),R=m("Availment"),T=m("TabPanels"),S=m("TabGroup");return a(),g(I,null,[o("div",Jt,[(a(!0),g(I,null,z(i.statistics,(w,C)=>(a(),g("div",{key:C,class:A([w.bg,"flex flex-col items-center rounded-lg p-2 bg-opacity-[0.15] dark:bg-opacity-50 text-center shadow-md hover:shadow-xl transition-transform transform hover:scale-101 w-full"])},[o("div",Xt,[n(c,{icon:w.icon,class:A(["text-2xl",w.text])},null,8,["icon","class"])]),o("div",es,_(w.title),1),o("div",ts,[o("div",ss,_(w.count),1)])],2))),128))]),n(S,null,{default:h(()=>[n(f,{class:"lg:space-x-8 md:space-x-4 space-x-0 rtl:space-x-reverse"},{default:h(()=>[(a(!0),g(I,null,z(s.buttons,(w,C)=>(a(),x(y,{as:"template",key:C},{default:h(O=>[o("button",{class:A([[O.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"])},[o("span",os,[n(c,{icon:w.icon},null,8,["icon"])]),b(" "+_(w.title),1)],2)]),_:2},1024))),128))]),_:1}),n(T,null,{default:h(()=>[n(F,null,{default:h(()=>[o("div",is,[e[8]||(e[8]=o("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," Earning of offset ",-1)),o("div",ns,[n(u,{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:h(()=>[e[5]||(e[5]=o("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),o("span",rs,[n(c,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[4]||(e[4]=b(" Export to CSV "))])]),_:1},8,["onClick"]),n(u,{icon:"heroicons-outline:plus-sm",text:"Add Record",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-gray-500 group-hover:border",iconClass:"text-lg",onClick:e[0]||(e[0]=w=>r.createRecord("earning"))},{default:h(()=>[e[7]||(e[7]=o("span",{class:"absolute inset-0 bg-gray-900 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),o("span",as,[n(c,{icon:"heroicons-outline:plus-sm",class:"text-2xl mr-2"}),e[6]||(e[6]=b(" Add Record "))])]),_:1})])]),n(k,{ref:"agGrid",rowData:i.earnings,columnDefs:s.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:s.paginationPageSize,paginationPageSizeSelector:s.paginationPageSizeSelector,onGridReady:r.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"]),n(D,{onCloseModal:e[1]||(e[1]=w=>s.state.showModal=!1),ref:"earning",onReload:r.reload},null,8,["onReload"])]),_:1}),n(F,null,{default:h(()=>[o("div",ls,[e[13]||(e[13]=o("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," Offset Availment ",-1)),o("div",ms,[n(u,{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:h(()=>[e[10]||(e[10]=o("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),o("span",cs,[n(c,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[9]||(e[9]=b(" Export to CSV "))])]),_:1},8,["onClick"]),n(u,{icon:"heroicons-outline:plus-sm",text:"Add Record",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-gray-500 group-hover:border",iconClass:"text-lg",onClick:e[2]||(e[2]=w=>r.createRecord("availment"))},{default:h(()=>[e[12]||(e[12]=o("span",{class:"absolute inset-0 bg-gray-900 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),o("span",ds,[n(c,{icon:"heroicons-outline:plus-sm",class:"text-2xl mr-2"}),e[11]||(e[11]=b(" Add Record "))])]),_:1})])]),n(k,{ref:"agGrid",rowData:i.availment,columnDefs:s.colDefsAvailment,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:s.paginationPageSize,paginationPageSizeSelector:s.paginationPageSizeSelector,onGridReady:r.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"]),n(R,{onCloseModal:e[3]||(e[3]=w=>s.state.showModal=!1),ref:"availment",onReload:r.reload},null,8,["onReload"])]),_:1})]),_:1})]),_:1})],64)}const hs=B(Kt,[["render",fs]]);const us={mixins:[fe],components:{TabIcon:hs,Pagination:Re,Card:ue,Button:q,Badge:ge,Layout:he,Icon:P,CreateButton:Ae,SubmitButton:H,CloseButton:L,EditButton:le,DeleteButton:me,ViewButton:De,Availment:de,Earning:ce,InputGroup:pe,Loading:U},data(){return{earnings:[],totalOffset:"",breadcrumbs:[{text:"Home",href:"/"},{text:"Timekeeping",href:"/attendance/employee-offset"},{text:"Offset Application",active:!0}],statistics:[{title:"Available Offset Hours",count:"0",bg:"bg-info-500",text:"text-info-500",icon:"heroicons-outline:menu-alt-1"},{title:"Total Offset Hours Used",count:"0",bg:"bg-warning-500",text:"text-warning-500",icon:"heroicons-outline:chart-pie"}],columns:[{label:"#",field:"#"},{label:"Date",field:"date",formatFn:t=>this.formatDate(t)},{label:"Hours",field:"hours"},{label:"Remarks",field:"description"},{label:"Status",field:"status"},{label:"Action",field:"action"}],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],items:[],totalItems:0,searchQuery:null,serverOptions:{page:1,rowsPerPage:10,sortBy:"created_at",sortType:"asc"},state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:_e.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{async reloadRecords(){await this.fetchRecords(),await this.fetchEarningRecords()},formatDate(t){const e=new Date(t),i=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),l=new Date(i.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),s=l.getFullYear(),r=String(l.getMonth()+1).padStart(2,"0"),c=String(l.getDate()).padStart(2,"0");return`${s}-${r}-${c}`},async fetchEarningRecords(){this.state.isLoading=!0,await v.fetchEarningRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType}).then(t=>{let e=t.data.data;this.statistics[0].count=t.data.offset_remaining?t.data.offset_remaining.remaining:0,this.earnings=e.data.map((i,l)=>({...i,"#":l+1,"date coverage":this.$formatDate(i.date),hours:i.hours,"date created":this.$formatDate(i.created_at),status:i.status,ref:"earning"}))}).finally(()=>{this.state.isLoading=!1})},async fetchRecords(){this.state.isLoading=!0,await v.fetchRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType}).then(t=>{this.statistics[1].count=t.data.offset_used.totalOffset!=null?t.data.offset_used.totalOffset:0;let e=t.data.data.data;this.items=e.map((i,l)=>({...i,"#":l+1,"date coverage":i.date_from===i.date_to?this.$formatDate(i.date_from):this.$formatDate(i.date_from)+" - "+this.$formatDate(i.date_to)+(i.half_day?i.meridiem?" (PM)":" (AM)":""),"time coverage":this.$formatTime(i.from_time)+" - "+this.$formatTime(i.to_time)+" ("+i.hours+" Hours)","date created":this.$formatDate(i.created_at),status:i.status,ref:"availment"}))}).finally(()=>{this.state.isLoading=!1})},reload(){this.$emit("reload")},handlePageChange(t){console.log(t),console.log(this.serverOptions.page),this.serverOptions.page!=t&&(this.serverOptions.page=t)},handlePerPageChange(t){this.serverOptions.page=1,this.serverOptions.rowsPerPage=t},onSortChange(t){console.log(t),t[0].type!="none"&&(this.serverOptions.sortBy=t[0].field,this.serverOptions.sortType=t[0].type)},async deleteRecord(t,e){console.log("try"),console.log(e);let i="";e=="earning"?i=v.removeEarning:e=="availment"&&(i=v.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(l=>{console.log(l.value),l.value&&(this.state.isDeleting=!0,i(t).then(s=>{s.status==200&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.reloadRecords())}))}).catch(l=>{l.response&&l.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(t){console.log(t),t=="earning"?(this.$refs.earning.resetForm(),this.$refs.earning.state.showModal=!0):t=="availment"&&(this.$refs.availment.resetForm(),this.$refs.availment.availableOffset=this.statistics[0].count,this.$refs.availment.totalOffset=this.statistics[1].count,this.$refs.availment.state.showModal=!0)},editRecord(t,e){e=="earning"?(this.$refs.earning.resetForm(),this.$refs.earning.loadRecord(t),this.$refs.earning.state.showModal=!0):e=="availment"&&(this.$refs.availment.resetForm(),this.$refs.availment.loadRecord(t),this.$refs.availment.state.showModal=!0)},handlePageChange(t){console.log(t),console.log(this.serverOptions.page),this.serverOptions.page!=t&&(this.serverOptions.page=t)},handlePerPageChange(t){this.serverOptions.page=1,this.serverOptions.rowsPerPage=t}},mounted(){this.fetchRecords(),this.fetchEarningRecords()}},gs={class:"space-y-4 mt-4"},ps={class:"flex-1 md:mb-0 mb-3"};function _s(t,e,i,l,s,r){const c=m("TabIcon"),y=m("Card"),f=m("Loading"),u=m("Layout");return a(),x(u,{breadcrumbs:s.breadcrumbs},{default:h(()=>[o("div",gs,[n(y,{title:"Offset Applications"},{default:h(()=>[o("h6",ps,_(t.title),1),n(c,{earnings:s.earnings,availment:s.items,statistics:s.statistics},null,8,["earnings","availment","statistics"]),e[0]||(e[0]=o("div",{class:"grid grid-cols-2 gap-6 mt-4"},null,-1))]),_:1}),s.state.isLoading?(a(),x(f,{key:0,text:"Fetching records"})):p("",!0)])]),_:1},8,["breadcrumbs"])}const mo=B(us,[["render",_s],["__scopeId","data-v-e2f1afa8"]]);export{mo as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.11 |
proxy
|
phpinfo
|
Settings