File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.e55894f4.js
Back
import{w as N,L as Z}from"./index.ca4614c1.js";import{B as K}from"./index.8a5f8558.js";import{_ as q,q as O,r as f,o,c as w,w as x,j as c,b as r,d as n,t as _,m as F,h as C,e as m,F as v,k as J,p as B,s as U,f as E}from"./index.28ae41da.js";import{C as I}from"./CloseButton.dacc4a7b.js";import{C as Q}from"./CreateButton.7e6095de.js";import{D as X}from"./DeleteButton.89d918f5.js";import{E as $}from"./EditButton.4c7b9ec2.js";/* empty css */import{S as P}from"./SubmitButton.be4371c4.js";import{V as ee}from"./ViewButton.d67c4349.js";import{I as j}from"./index.1b36081b.js";import{A as te}from"./ActionCellRenderer.4d4d9d35.js";import{E as p}from"./EmployeeLeaveService.38bcb995.js";import{B as se}from"./index.85943672.js";/* empty css */import"./vue-cleave.min.10e51f16.js";import{c as ie,a as S,V as ne}from"./array.19531b35.js";import{L as z}from"./Loading.fa197db1.js";import"./vue-quill.snow.464b7516.js";/* empty css */import{C as ae}from"./index.4f06d02e.js";import{I as oe}from"./index.ae574076.js";import{P as le}from"./index.4d0f347c.js";import{U as me}from"./UpdateButton.a9e9b37b.js";import"./jspdf.es.min.cdd8e899.js";/* empty css */import{A as R}from"./ApproverService.108289da.js";import{E as re}from"./EmployeeScheduleService.b3abdf47.js";import{F as de}from"./FileService.09441775.js";import{L as ce}from"./LeaveReasonService.3108a643.js";import{L as fe}from"./LeaveTypeService.b84f7001.js";import{F as he}from"./index.975c3902.js";import{F as ue}from"./index.164dfd27.js";import{T as ge}from"./index.33bd7660.js";import{T as _e}from"./index.43beecaf.js";import{M as ye}from"./Multiselect.3c2ca79b.js";import{F as xe}from"./index.9a016648.js";import{F as we}from"./index.d93f9125.js";import{A as be}from"./index.e14b9ad3.js";import{p as pe,j as ke}from"./scr-1.d9aaecca.js";import{A as Ce}from"./main.esm.9cee2c92.js";import{F as De}from"./index.32e578cc.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.4769b1c9.js";import"./EmployeeService.67ccb7ea.js";import"./es.string.replace.a39053f7.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.e35c8e45.js";import"./index.17d4213d.js";import"./index.50628127.js";const Le={components:{Alert:be,FileType:we,Fileinput:xe,FormModal:ue,FormGroup:he,TextInput:_e,TextArea:ge,SubmitButton:P,UpdateButton:me,CloseButton:I,Loading:z,Multiselect:ye,Icon:j},props:{statistics:{type:Object,required:!0}},data(){return{meridiemOptions:[{value:"0",label:"AM"},{value:"1",label:"PM"}],isMeridiemRequired:!1,halfWholeDayOptions:[{value:"0",label:"Whole Day"},{value:"1",label:"Last Day Half Day"},{value:"2",label:"First Day Half Day"}],daysRecord:"",leaveOptions:[],leaveReasonOptions:[],recommending:"",recommendings:[],recommending_img:"",approving:"",approvings:[],approving_img:"",noSchedule:!1,showCreditToVL:!1,form:{leave_id:"",without_pay:"",allow_higher_approval:"",half_day:0,date_from:"",date_to:"",days:"",meridiem:"",hours:"",description:null,leave_reason_id:"",credit_to_vl:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isLoadingApprovers:!1,isLeaveReasonLoading:!1,hasSchedule:!1},fileIcons:{pdf:pe,jpg:ke,default:""}}},methods:{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,t={id:i,attachment:e};await p.removeAttachment(t).then(d=>{d.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(d=>{d.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:d.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 de.Reader2("employee-leave",i),t;if(i.endsWith(".pdf"))t="application/pdf";else if(i.endsWith(".png"))t="image/png";else if(i.endsWith(".jpg")||i.endsWith(".jpeg"))t="image/jpeg";else if(i.endsWith(".svg"))t="image/svg+xml";else throw new Error("Unsupported file type");const d=atob(e),s=new Array(d.length);for(let h=0;h<d.length;h++)s[h]=d.charCodeAt(h);const a=new Uint8Array(s),u=new Blob([a],{type:t}),g=URL.createObjectURL(u);window.open(g),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)},async fetchEmployeeSchedule(){await re.fetchRecord(1).then(i=>{i.status==200&&i.data&&(this.state.hasSchedule=!0)}).catch(i=>{console.log(i)})},async fetchLeaveType(){await fe.fetchRecordsEmployeeLeaveType().then(i=>{i.status==200&&(this.leaveOptions=i.data.map(e=>({value:e.id,label:e.name})))}).catch(i=>{console.log(i)})},async fetchLeaveReason(i){i!=this.form.leave_id&&(this.leaveReasonOptions=[],this.form.leave_reason_id=""),this.isLeaveReasonLoading=!0,await ce.fetchRecords().then(e=>{e.status==200&&(this.leaveReasonOptions=e.data.data.filter(t=>t.leave_id==i).map(t=>({value:t.id,label:t.name})),this.isLeaveReasonLoading=!1)}).catch(e=>{console.log(e)})},async fetchApprover(){this.approvings=[],this.recommendings=[],this.state.isLoadingApprovers=!0,await R.fetchApproverRecords({dealership:this.$store.userSettings.activeDealership}).then(i=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{console.log("first classification",e.classification_id),e.classification_id==2&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.recommending_id=e.employee_id,this.recommendings.push({name:e.firstname+" "+e.lastname}),console.log(this.recommendings),this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),console.log(this.recommendings.length),this.recommendings.length===0&&e.classification_id==3&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.recommending_id=e.employee_id,this.recommendings.push({name:e.firstname+" "+e.lastname}),this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==3&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.approvings.length===0&&e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id==3&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.recommending_id=e.employee_id,this.recommendings.push({name:e.firstname+" "+e.lastname}),this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommendings.length===0&&e.classification_id==4&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.recommending_id=e.employee_id,this.recommendings.push({name:e.firstname+" "+e.lastname}),this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id==3&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.recommending_id=e.employee_id,this.recommendings.push({name:e.firstname+" "+e.lastname}),this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommendings.length===0&&e.classification_id==4&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.recommending_id=e.employee_id,this.recommendings.push({name:e.firstname+" "+e.lastname}),this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.state.isLoadingApprovers=!1}).catch(i=>{console.log(i)})},loadRecord(i){this.resetForm(),this.state.isEdit=!0,this.form=i,this.form.without_pay=i.without_pay==1,this.form.allow_higher_approval=i.allow_higher_approval==1,this.fetchLeaveReason(this.form.leave_id),this.daysRecord=this.form.days},closeModal(){this.state.showModal=!1},resetForm(){this.state.isLoadingApprovers=!1,this.errors={},this.state.isEdit=!1,this.form={leave_id:"",without_pay:!1,allow_higher_approval:"",half_day:0,date_from:"",date_to:"",days:"",meridiem:"",hours:"",credit_to_vl:!1,description:null,leave_reason_id:"",attachment:"",recommending_id:this.form.recommending_id,approver_id:this.form.approver_id}},reload(){return this.$emit("reload")},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 p.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 p.create(i).then(e=>{e.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3}),this.state.isSaving=!1,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{this.form.leave_id==3&&this.form.days>2&&new Date().toISOString().split("T")[0]<this.form.date_from&&(this.form.attachment==null||this.form.attachment=="")?this.errors.attachment="Attachment is required":this.form.leave_id==2&&this.form.days>29&&(this.form.attachment==null||this.form.attachment=="")?this.errors.attachment="Attachment is required":this.errors.days?this.errors.days="Days exceeded your remaining credits":this.form.leave_reason_id==""||this.form.leave_reason_id==null?this.errors.description="Reason is required":(this.form.description==null||this.form.description=="")&&(this.form.leave_reason_id==5||this.form.leave_reason_id==14)?this.errors.description="Reason is required":(this.errors.attachment="",await ie().shape({leave_id:S().required("Leave type is required"),half_day:S().required("Please select a half or whole day"),date_from:S().required("Date from is required"),date_to:S().required("Date to is required")}).validate(this.form,{abortEarly:!1}),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 ne){const e={};i.inner.forEach(t=>{e[t.path]=t.message}),this.errors=e}}},async fetchApprover5DaysOrMore(){this.approvings=[],this.recommendings=[],this.state.isLoadingApprovers=!0,await R.fetchApproverRecords().then(i=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id==3&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommendings.length===0&&e.classification_id>=4&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id>=4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname),this.approvings.length===0&&e.classification_id>=4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id==3&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommendings.length===0&&e.classification_id>=4&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id>=4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id>=4&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommendings.length===0&&e.classification_id>=4&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)}),this.state.isLoadingApprovers=!1}).catch(i=>{console.log(i)})},async fetchApprover3DaysOrMore(){this.approvings=[],this.recommendings=[],this.state.isLoadingApprovers=!0,await R.fetchApproverRecords().then(i=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id==2&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommendings.length===0&&e.classification_id==3&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==3&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname),this.approvings.length===0&&e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id==3&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommendings.length===0&&e.classification_id==4&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id==3&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommendings.length===0&&e.classification_id==4&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)}),this.state.isLoadingApprovers=!1}).catch(i=>{console.log(i)})},async fetchApprover2DaysOrLess(){this.approvings=[],this.recommendings=[],this.state.isLoadingApprovers=!0,await R.fetchApproverRecords().then(i=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{this.form.allow_higher_approval||this.form.days<3?((e.classification_id==2||e.classification_id==1)&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommendings.length===0&&e.classification_id==3&&!this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==3&&(this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)),this.approvings.length===0&&e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)):((e.classification_id==2||e.classification_id==1)&&(this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)),this.recommendings.length===0&&e.classification_id==3&&(this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)))}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id==3&&(this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)),this.recommendings.length===0&&e.classification_id==4&&(this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)),e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&i.data.sort((e,t)=>e.classification_id-t.classification_id).map(e=>{e.classification_id==3&&(this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)),this.recommendings.length===0&&e.classification_id==4&&(this.recommendings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.recommendings.push({name:e.firstname+" "+e.lastname}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)||(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)),e.classification_id==4&&!this.approvings.some(t=>t.name===e.firstname+" "+e.lastname)&&(this.form.approver_id=e.employee_id,this.approvings.push({name:e.firstname+" "+e.lastname}),this.approving=e.firstname+" "+e.lastname)}),this.state.isLoadingApprovers=!1}).catch(i=>{console.log(i)})},onDateFromChange(){this.form.date_to="",this.calculateDays()},async calculateDays(){if(this.form.days>2&&(this.form.allow_higher_approval=""),await this.statistics[0].count.filter(i=>i.id==this.form.leave_id).map(i=>{i.total>.49||this.form.without_pay==0&&this.state.isEdit?this.form.without_pay=!1:this.form.without_pay=!0}),this.form.date_from&&this.form.date_to){this.state.isLoadingApprovers=!0;const i=O(this.form.date_from),e=O(this.form.date_to);e.diff(i,"days")+1;let t={date_from:i.format("YYYY-MM-DD"),date_to:e.format("YYYY-MM-DD"),half_day:this.form.half_day};try{let s=(await p.fetchHolidayDayoff(t)).data,a=0,u=0;if(a=s/8,u=s,this.state.isLoadingApprovers=!1,a>4.99?this.fetchApprover5DaysOrMore():a>2?this.fetchApprover3DaysOrMore():a<=2?this.fetchApprover2DaysOrLess():this.fetchApprover(),this.form.days=a,this.form.hours=u,this.statistics[0].count.filter(g=>g.id==this.form.leave_id).map(g=>{let h="";this.state.isEdit?h=parseFloat(g.total)+parseFloat(this.daysRecord):h=g.total,h<.5&&!this.form.without_pay?this.errors.days="Days exceeded your remaining credits":this.errors.days=!1}),this.form.leave_id==3){let g=0,h=0;await this.statistics[0].count.map(y=>{y.id==2&&(g=y.total),y.id==3&&(h=y.total),g>.49&&this.form.days<=g&&h<.5?(this.showCreditToVL=!0,this.form.credit_to_vl=!1):(this.showCreditToVL=!1,this.form.credit_to_vl=!1)})}else this.form.credit_to_vl=!1,this.showCreditToVL=!1}catch(d){d.response.data.message=='Attempt to read property "schedule" on null'?this.noSchedule=!0:console.log(d)}}}},watch:{"form.half_day":{handler:"calculateDays",immediate:!0},"form.leave_id":{handler:"calculateDays",immediate:!0},"form.allow_higher_approval":{handler:"calculateDays",immediate:!0},"form.credit_to_vl"(i){i&&(this.form.leave_id==3?this.form.without_pay=!1:this.form.without_pay="")},"form.allow_higher_approval":{handler:"calculateDays",immediate:!0}},mounted(){this.fetchEmployeeSchedule(),this.fetchApprover(),this.fetchLeaveType()}},Ae={key:2,class:"bg-red-50 dark:bg-red-900 dark:bg-opacity-30 border-l-4 border-red-500 p-4 rounded-md shadow-sm mb-2"},Se={class:"text-red-600 dark:text-red-400 text-sm"},Re={class:"grid lg:grid-cols-3 grid-cols-1 gap-4 mb-6"},Fe={class:"flex flex-col items-center mb-2"},ve={class:"text-sm font-semibold text-slate-600 dark:text-white"},Ve={class:"w-full table-panel"},Me={class:"text-xs font-medium text-slate-500 dark:text-white mb-1"},Te={class:"text-base text-slate-900 dark:text-white text-center font-semibold"},Be={class:"w-full text-center"},Ue={class:"text-base text-slate-900 dark:text-white text-center font-semibold"},Ee={class:"w-full text-center"},Oe={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},qe={key:1,class:"text-red-400 italic items-center"},Ie={class:"grid grid-cols-12 gap-4"},Pe={class:"col-span-6"},je={key:0,class:"text-[#ec4899]"},ze={key:0,class:"flex items-center gap-4 mb-2"},Ye={class:"flex items-center cursor-pointer"},Ge=["checked"],He={class:"flex items-center gap-4"},We={class:"flex items-center cursor-pointer"},Ne=["checked"],Ze={class:"col-span-6"},Ke={key:0,class:"text-[#ec4899]"},Je={class:"grid grid-cols-12 gap-4"},Qe={class:"col-span-4"},Xe={key:0,class:"text-[#ec4899]"},$e={class:"col-span-4"},et={key:0,class:"text-[#ec4899]"},tt={class:"col-span-4"},st={key:0,class:"text-[#ec4899]"},it={class:"grid grid-cols-12 gap-4"},nt={class:"col-span-6"},at={class:"col-span-6"},ot={key:0,class:"text-[#ec4899]"},lt={class:"grid grid-cols-12 gap-4"},mt={class:"col-span-6"},rt={key:0,class:"text-[#ec4899]"},dt={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},ct={class:"flex justify-between w-full items-center"},ft={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},ht={class:"col-span-6"},ut={key:0,class:"text-[#ec4899]"},gt={class:"grid grid-cols-12 gap-4"},_t={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},yt={class:"flex-shrink-0 mr-4"},xt=["src"],wt={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},bt={class:"text-left"},pt={class:"text-sm font-semibold text-gray-600"},kt={class:"text-lg font-bold text-gray-900"},Ct={key:0,class:"text-sm text-gray-900"},Dt={key:1,class:"text-sm text-gray-900"},Lt={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},At={class:"flex-shrink-0 mr-4"},St=["src"],Rt={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Ft={class:"text-left"},vt={class:"text-lg font-bold text-gray-900"},Vt={class:"text-sm text-gray-900"},Mt={class:"flex justify-between gap-2"},Tt={key:0,class:"flex items-center cursor-pointer"},Bt=["checked","disabled"];function Ut(i,e,t,d,s,a){const u=f("Loading"),g=f("Icon"),h=f("Multiselect"),y=f("FormGroup"),D=f("flat-pickr"),L=f("TextInput"),V=f("Fileinput"),M=f("Card"),b=f("FileType"),T=f("TextArea"),k=f("SubmitButton"),Y=f("UpdateButton"),G=f("CloseButton"),H=f("FormModal");return o(),w(H,{title:s.form.status!==0?"Leave Application Form":s.state.isEdit?"Edit Leave Request":"Leave Application Form",activeModal:s.state.showModal,onSubmit:i.confirmSubmit,onClose:a.closeModal,themeClass:s.state.isEdit&&s.form.status==0?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-3/4"},{default:x(()=>[s.state.isEdit&&s.state.isLoading?(o(),w(u,{key:0,text:"Fetching record"})):c("",!0),s.state.isLoadingApprovers?(o(),w(u,{key:1,text:"Fetching approvers"})):c("",!0),this.form.status==99?(o(),r("div",Ae,[e[17]||(e[17]=n("h3",{class:"text-red-700 dark:text-red-300 font-semibold mb-1 text-sm"}," Denied Reason ",-1)),n("p",Se,_(this.form.denied_reason),1)])):c("",!0),n("div",Re,[(o(!0),r(v,null,F(t.statistics,(l,W)=>(o(),r("div",{key:W,class:C([l.bg,"rounded-md p-4 bg-opacity-[0.15] dark:bg-opacity-50 text-center drop-shadow-lg"])},[n("div",Fe,[m(g,{icon:l.icon,class:C(["h-12 w-12 text-3xl bg-white rounded-full p-3 mb-3",l.text])},null,8,["icon","class"]),n("div",ve,_(l.title),1)]),n("div",null,[n("table",Ve,[e[18]||(e[18]=n("tr",null,[n("td",null,"Type"),n("td",null,"Hours"),n("td",null,"Days")],-1)),(o(!0),r(v,null,F(l.count,A=>(o(),r("tr",{key:A.type},[n("td",Me,_(A.type),1),n("td",Te,[n("div",Be,_(A.hours||0),1)]),n("td",Ue,[n("div",Ee,_(A.total),1)])]))),128))])])],2))),128))]),n("div",Oe,[n("form",{onSubmit:e[16]||(e[16]=J((...l)=>i.confirmSubmit&&i.confirmSubmit(...l),["prevent"])),class:"space-y-6"},[s.state.isSaving?(o(),w(u,{key:0,text:"Saving record"})):c("",!0),s.state.hasSchedule?c("",!0):(o(),r("div",qe," * Schedule is required ")),n("div",Ie,[n("div",Pe,[m(y,{label:"Leave Type",isRequired:!0},{default:x(()=>[m(h,{modelValue:s.form.leave_id,"onUpdate:modelValue":e[0]||(e[0]=l=>s.form.leave_id=l),error:s.errors.leave_id,options:s.leaveOptions,searchable:!0,disabled:s.form.status==2||s.form.status==1,onChange:e[1]||(e[1]=l=>{a.calculateDays(),a.fetchLeaveReason(l)}),class:"w-full"},null,8,["modelValue","error","options","disabled"]),s.errors.leave_id?(o(),r("div",je," Leave type is required ")):c("",!0)]),_:1}),s.showCreditToVL?(o(),r("div",ze,[n("label",Ye,[B(n("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.credit_to_vl,"onUpdate:modelValue":e[2]||(e[2]=l=>s.form.credit_to_vl=l)},null,8,Ge),[[U,s.form.credit_to_vl]]),e[19]||(e[19]=n("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[n("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"},[n("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[20]||(e[20]=n("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Credit to Vacation Leave?",-1))])])):c("",!0),n("div",He,[n("label",We,[B(n("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.without_pay,"onUpdate:modelValue":e[3]||(e[3]=l=>s.form.without_pay=l),disabled:""},null,8,Ne),[[U,s.form.without_pay]]),e[21]||(e[21]=n("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[n("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"},[n("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[22]||(e[22]=n("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Without Pay",-1))])])]),n("div",Ze,[m(y,{label:"Half/Whole Day",isRequired:!0},{default:x(()=>[m(h,{modelValue:s.form.half_day,"onUpdate:modelValue":e[4]||(e[4]=l=>s.form.half_day=l),error:s.errors.half_day,options:s.halfWholeDayOptions,onChange:a.calculateDays,disabled:s.form.status==2||s.form.status==1,class:"w-full"},null,8,["modelValue","error","options","onChange","disabled"]),s.errors.half_day?(o(),r("div",Ke," Half/Whole day is required ")):c("",!0)]),_:1})])]),n("div",Je,[n("div",Qe,[(s.isMeridiemRequired?i.isRequired="true":i.isRequired="false")?(o(),w(y,{key:0,label:"AM/PM"},{default:x(()=>[m(h,{disabled:s.form.status==2||s.form.status==1,modelValue:s.form.meridiem,"onUpdate:modelValue":e[5]||(e[5]=l=>s.form.meridiem=l),error:s.errors.meridiem,options:s.meridiemOptions,class:"form-control w-full h-[48px] mt-2"},null,8,["disabled","modelValue","error","options"]),s.errors.meridiem?(o(),r("div",Xe," AM/PM is required ")):c("",!0)]),_:1})):c("",!0)]),n("div",$e,[m(y,{label:"Date From",isRequired:!0},{default:x(()=>[m(D,{disabled:s.form.status==2||s.form.status==1,modelValue:s.form.date_from,"onUpdate:modelValue":e[6]||(e[6]=l=>s.form.date_from=l),class:"form-control h-[48px]",onChange:a.onDateFromChange,placeholder:"Select date"},null,8,["disabled","modelValue","onChange"]),s.errors.date_from?(o(),r("div",et," Date from is required ")):c("",!0)]),_:1})]),n("div",tt,[m(y,{label:"Date To",isRequired:!0},{default:x(()=>[m(D,{disabled:s.form.status==2||s.form.status==1,modelValue:s.form.date_to,"onUpdate:modelValue":e[7]||(e[7]=l=>s.form.date_to=l),class:"form-control h-[48px]",placeholder:"Select date",config:{minDate:s.form.date_from},onChange:a.calculateDays},null,8,["disabled","modelValue","config","onChange"]),s.errors.date_to?(o(),r("div",st," Date to is required ")):c("",!0)]),_:1})])]),n("div",it,[n("div",nt,[m(y,{label:"Hours"},{default:x(()=>[m(L,{modelValue:s.form.hours,"onUpdate:modelValue":e[8]||(e[8]=l=>s.form.hours=l),error:s.errors.hours,isReadonly:!0,placeholder:"Enter hours",classInput:"h-[48px] w-full"},null,8,["modelValue","error"])]),_:1})]),n("div",at,[m(y,{label:"Days"},{default:x(()=>[m(L,{modelValue:s.form.days,"onUpdate:modelValue":e[9]||(e[9]=l=>s.form.days=l),error:s.errors.days,isReadonly:!0,placeholder:"Calculated days",classInput:"h-[48px] w-full"},null,8,["modelValue","error"]),s.errors.days?(o(),r("div",ot)):c("",!0)]),_:1})])]),n("div",lt,[n("div",mt,[m(y,{label:"Attachment"},{default:x(()=>[m(M,{title:"File Input Basic"},{default:x(()=>[m(V,{modelValue:s.form.attachment,"onUpdate:modelValue":e[10]||(e[10]=l=>s.form.attachment=l),name:"basic",onChange:a.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),s.errors.attachment?(o(),r("div",rt,_(s.errors.attachment),1)):c("",!0)]),_:1}),typeof s.form.attachment=="string"&&s.form.attachment?(o(),r("div",dt,[n("div",ct,[n("div",{class:"flex items-center cursor-pointer",onClick:e[11]||(e[11]=l=>a.viewAttachment(s.form.attachment))},[m(b,{image:a.getFileTypeImage(s.form.attachment)},null,8,["image"]),E(" "+_(s.form.attachment),1)]),s.form.status==0&&s.form.days<3?(o(),r("div",ft,[m(g,{icon:"mingcute:delete-2-fill",onClick:e[12]||(e[12]=l=>a.deleteFile(s.form.id))})])):c("",!0)])])):c("",!0)]),_:1})]),n("div",ht,[m(y,{label:"Reason",isRequired:!0},{default:x(()=>[m(h,{modelValue:s.form.leave_reason_id,"onUpdate:modelValue":e[13]||(e[13]=l=>s.form.leave_reason_id=l),error:s.errors.leave_reason_id,searchable:!0,options:s.leaveReasonOptions,loading:i.isLeaveReasonLoading,class:"form-control w-full h-[48px] mt-2"},null,8,["modelValue","error","options","loading"]),s.form.leave_reason_id==5||s.form.leave_reason_id==14?(o(),w(T,{key:0,class:"mt-2",modelValue:s.form.description,"onUpdate:modelValue":e[14]||(e[14]=l=>s.form.description=l),rows:"2",placeholder:"Enter reason",classInput:"w-full"},null,8,["modelValue"])):c("",!0)]),_:1}),s.errors.description?(o(),r("div",ut," Reason is required ")):c("",!0)])]),n("div",gt,[n("div",_t,[n("div",yt,[s.recommending_img?(o(),r("img",{key:0,src:s.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,xt)):(o(),r("div",wt," No Image "))]),n("div",bt,[n("div",pt,_(s.form.allow_higher_approval||s.form.days>2?"Recommending":"Approving"),1),n("div",kt,_(s.recommending),1),s.form.allow_higher_approval||s.form.days>2?(o(),r("div",Ct,_(s.form.recommended_at?"Date: ("+this.$formatDateTime(s.form.recommended_at)+")":""),1)):(o(),r("div",Dt,_(s.form.approved_at?"Date: ("+this.$formatDateTime(s.form.approved_at)+")":""),1))])]),s.form.allow_higher_approval||s.form.days>2?(o(),r("div",Lt,[n("div",At,[s.approving_img?(o(),r("img",{key:0,src:s.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,St)):(o(),r("div",Rt," No Image "))]),n("div",Ft,[e[23]||(e[23]=n("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),n("div",vt,_(s.approving),1),n("div",Vt,_(s.form.approved_at?"Date: ("+this.$formatDateTime(s.form.approved_at)+")":""),1)])])):c("",!0)]),n("div",Mt,[n("div",null,[s.form.days<3&&s.form.days!=""?(o(),r("label",Tt,[B(n("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[15]||(e[15]=l=>s.form.allow_higher_approval=l),disabled:s.form.status==2||s.form.status==1},null,8,Bt),[[U,s.form.allow_higher_approval]]),e[24]||(e[24]=n("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[n("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"},[n("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[25]||(e[25]=n("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])):c("",!0)]),n("div",null,[(!s.state.isEdit&&t.statistics[0].count.length!==0||s.form.without_pay)&&s.state.hasSchedule&&this.form.status!=2?(o(),w(k,{key:0,onClick:a.submitForm},null,8,["onClick"])):s.form.status===0&&s.state.hasSchedule?(o(),w(Y,{key:1,onClick:a.submitForm},null,8,["onClick"])):c("",!0),m(G,{onClick:a.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","activeModal","onSubmit","onClose","themeClass"])}const Et=q(Le,[["render",Ut],["__scopeId","data-v-18428ee5"]]);const Ot={mixins:[N],components:{FilterTimekeeping:De,ActionCellRenderer:te,AgGridVue:Ce,Pagination:le,Card:ae,Button:K,Badge:se,Layout:Z,Icon:j,CreateButton:Q,SubmitButton:P,CloseButton:I,EditButton:$,DeleteButton:X,ViewButton:ee,Form:Et,InputGroup:oe,Loading:z},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:1},{field:"type",filter:!0,floatingFilter:!0,flex:2},{field:"date coverage",filter:!0,floatingFilter:!0,flex:2},{field:"days/hours",filter:!0,floatingFilter:!0},{field:"date created",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,cellRenderer:i=>{const e=i.value,t=i.data.validated,d=i.data.denied_reason;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>':t===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>':t===99&&e===2?` <div title='Reason : ${d}' class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-orange-600 px-4"> Denied </div> <div class="mt-2 text-sm text-gray-700"> <strong>Reason:</strong> ${d} </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}}}],breadcrumbs:[{text:"Home",href:"/"},{text:"Timekeeping",href:"/attendance/employee-leave"},{text:"Leave Application",active:!0}],statistics:[{title:"Leave Credits",count:[],bg:"bg-info-500",text:"text-info-500",percent:"25.67% ",icon:"heroicons-outline:menu-alt-1"},{title:"Used Credits",count:[],bg:"bg-warning-500",text:"text-warning-500",percent:"8.67%",icon:"heroicons-outline:chart-pie"},{title:"Unpaid Leaves",count:[],bg:"bg-purple-500",text:"text-purple-500",percent:"8.67%",icon:"fa6-solid:chart-bar"}],items:[],state:{isLoading:!1,isEdit:!1,isDeleting:!1},leaveCredits:[]}},watch:{},computed:{},methods:{applyFilters(i){if(!i||Object.keys(i).length===0){const e=new Date;let t=e.getFullYear(),d=e.getMonth()+1,s=d-1||12;s===12&&(t-=1);const a=d.toString().padStart(2,"0"),u=s.toString().padStart(2,"0"),g=e.getDate();i={range:g>1&&g<15?`${t}-${u}-21 to ${e.getFullYear()+1}-${a}-05`:`${e.getFullYear()}-${a}-06 to ${e.getFullYear()+1}-${a}-20`}}this.fetchRecords(i)},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.")},async reloadRecords(){await this.fetchEmployeeLeaveCreditRecords(),this.applyFilters()},formatDate(i){const e=new Date(i),t=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),d=new Date(t.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),s=d.getFullYear(),a=String(d.getMonth()+1).padStart(2,"0"),u=String(d.getDate()).padStart(2,"0");return`${s}-${a}-${u}`},async fetchEmployeeLeaveCreditRecords(){this.state.isLoading=!0,await p.fetchEmployeeLeaveCreditRecords().then(i=>{this.leaveCredits=i.data,this.statistics[0].count=[],i.data.filter(e=>e.remaining!=0||e.leave_type.id==2||e.leave_type.id==3).map(e=>{this.statistics[0].count.push({id:e.leave_type.id,type:e.leave_type.name,total:e.remaining,hours:e.hours})})}).finally(()=>{this.state.isLoading=!1})},async fetchRecords(i={}){this.state.isLoading=!0,await p.fetchRecords({...i}).then(e=>{let t=e.data.data.data;this.statistics[1].count=[];const d=new Set,s=new Set;e.data.used_credits.forEach(a=>{d.add(a.id),this.statistics[1].count.push({id:a.id,type:a.id===2?"Vacation Leave":a.id===3?"Sick Leave":"Other",total:a.total,hours:a.hours||0})}),d.has(2)||this.statistics[1].count.push({id:2,type:"Vacation Leave",total:0,hours:0}),d.has(3)||this.statistics[1].count.push({id:3,type:"Sick Leave",total:0,hours:0}),this.statistics[2].count=[],e.data.used_withoutpay.map(a=>{s.add(a.id),this.statistics[2].count.push({id:a.id,type:a.name,total:a.total,hours:a.hours})}),s.has(2)||this.statistics[2].count.push({id:2,type:"Vacation Leave",total:0,hours:0}),s.has(3)||this.statistics[2].count.push({id:3,type:"Sick Leave",total:0,hours:0}),this.items=t.map((a,u)=>({...a,"#":u+1,type:a.leave_type.name+(a.without_pay?" (Without Pay)":""),"date coverage":a.date_from===a.date_to?this.$formatDate(a.date_from):this.$formatDate(a.date_from)+" - "+this.$formatDate(a.date_to)+(a.half_day?a.meridiem?" (PM)":" (AM)":""),"days/hours":a.days+" Day/s ("+a.hours+" Hour/s)","date created":this.$formatDate(a.created_at),status:a.status,validated:a.validated,denied_reason:a.denied_reason}))}).finally(()=>{this.state.isLoading=!1})},reload(){this.$emit("reload")},async deleteRecord(i){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(e=>{e.value&&(this.state.isDeleting=!0,p.remove(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(e=>{e.response&&e.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.state.isDeleting=!1})},createRecord(){this.$refs.form.resetForm(),this.$refs.form.state.showModal=!0},editRecord(i){this.$refs.form.resetForm(),this.$refs.form.loadRecord(i),this.$refs.form.state.showModal=!0}},mounted(){this.applyFilters(),this.fetchEmployeeLeaveCreditRecords()}},qt={class:"space-y-10 mt-4"},It={class:"flex items-center justify-between"},Pt={class:"text-2xl font-bold text-slate-900 dark:text-white"},jt={class:"grid grid-cols-2 gap-4 pb-4 md:grid-cols-1"},zt={class:C("h-14 w-14 flex items-center justify-center rounded-md text-4xl mb-4 shadow-lg bg-white")},Yt={class:"text-md font-semibold text-slate-700 dark:text-white mb-2"},Gt={class:"w-full table-panel"},Ht={class:"text-xs font-medium text-slate-500 dark:text-white mb-1"},Wt={class:"text-slate-900 dark:text-white text-center font-semibold"},Nt={class:"w-full text-center text-base"},Zt={class:"text-slate-900 dark:text-white text-center font-semibold"},Kt={class:"w-full text-center text-base"},Jt={class:"relative"},Qt={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},Xt={class:"flex items-center gap-4"},$t={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},es={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function ts(i,e,t,d,s,a){const u=f("Icon"),g=f("FilterTimekeeping"),h=f("Button"),y=f("ag-grid-vue"),D=f("Card"),L=f("Loading"),V=f("Form"),M=f("Layout");return o(),w(M,{breadcrumbs:s.breadcrumbs},{default:x(()=>[n("div",qt,[m(D,{title:"Leave Applications"},{default:x(()=>[n("div",It,[n("h2",Pt,_(i.title),1)]),n("div",jt,[(o(!0),r(v,null,F(s.statistics,(b,T)=>(o(),r("div",{key:T,class:C([b.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"])},[n("div",zt,[m(u,{icon:b.icon,class:C(["text-2xl",b.text])},null,8,["icon","class"])]),n("div",Yt,_(b.title),1),n("div",null,[n("table",Gt,[e[1]||(e[1]=n("tr",null,[n("td",null,"Type"),n("td",null,"Hours"),n("td",null,"Days")],-1)),(o(!0),r(v,null,F(b.count,k=>(o(),r("tr",{key:k.type},[n("td",Ht,_(k.type),1),n("td",Wt,[n("div",Nt,_(k.hours||0),1)]),n("td",Zt,[n("div",Kt,_(k.total),1)])]))),128))])])],2))),128))]),n("div",Jt,[n("div",Qt,[e[6]||(e[6]=n("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," Requested Leave ",-1)),n("div",Xt,[m(g,{onFilterChanged:a.applyFilters},null,8,["onFilterChanged"]),m(h,{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:a.exportToCsv},{default:x(()=>[e[3]||(e[3]=n("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),n("span",$t,[m(u,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[2]||(e[2]=E(" Export to CSV "))])]),_:1},8,["onClick"]),m(h,{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:a.createRecord},{default:x(()=>[e[5]||(e[5]=n("span",{class:"absolute inset-0 bg-gray-900 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),n("span",es,[m(u,{icon:"heroicons-outline:plus-sm",class:"text-2xl mr-2"}),e[4]||(e[4]=E(" Add Record "))])]),_:1},8,["onClick"])])])]),m(y,{ref:"agGrid",rowData:s.items,columnDefs:s.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:s.paginationPageSize,paginationPageSizeSelector:s.paginationPageSizeSelector,onGridReady:a.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])]),_:1}),s.state.isLoading?(o(),w(L,{key:0,text:"Fetching records"})):c("",!0),m(V,{onCloseModal:e[0]||(e[0]=b=>s.state.showModal=!1),ref:"form",statistics:s.statistics,onReload:a.applyFilters},null,8,["statistics","onReload"])])]),_:1},8,["breadcrumbs"])}const Xs=q(Ot,[["render",ts],["__scopeId","data-v-3be3ecf2"]]);export{Xs as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings