File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.207b8fbf.js
Back
import{w as me,L as ce}from"./index.0fd81098.js";import{C as fe}from"./index.d162669d.js";import{B as he}from"./index.43ed8c16.js";import{B as ue}from"./index.833a76e1.js";import{I as j}from"./index.31d8f3a7.js";import{I as ge}from"./index.4a5fd1e6.js";import{F as _e}from"./index.37e7af0d.js";import{F as Z}from"./index.79d99a66.js";import{F as K}from"./index.3b9dd0da.js";import{_ as P,q as M,r as f,o as r,c as p,w as g,j as d,d as i,b as m,t as y,k as Q,e as a,p as T,s as I,f as A,m as G,h as Y,F as N}from"./index.836ff972.js";/* empty css */import{T as J}from"./index.705ea62e.js";import{T as X}from"./index.c2c1d7ba.js";import{C as W}from"./CloseButton.f70e8453.js";import{D as $}from"./DeleteButton.a3bc472f.js";import{D as pe}from"./DenyButton.eb754227.js";/* empty css */import{P as ye}from"./ProceedButton.298b1309.js";import{S as H}from"./SubmitButton.bd665ffe.js";import{U as ee}from"./UpdateButton.767a80b3.js";import"./jspdf.es.min.2bae4710.js";/* empty css */import{V,c as ve,a as B}from"./array.af0a862f.js";import{L as z}from"./Loading.8843dce9.js";import{A as S}from"./ApproverService.c11fdba0.js";import{F as te}from"./FileService.cf612604.js";import{L as O}from"./LeaveApprovalService.ab79c972.js";import{L as se}from"./LeaveReasonService.dca7f69a.js";import{L as ie}from"./LeaveTypeService.838cc30c.js";import{M as oe}from"./Multiselect.20e5cf80.js";import{F as re}from"./index.75d30dc2.js";import{p as ae,j as ne}from"./scr-1.d9aaecca.js";import"./lodash.16bcff66.js";import{E as C}from"./EmployeeLeaveService.71acdb53.js";import{C as we}from"./CreateButton.8ae1cc58.js";import{E as xe}from"./EditButton.0c71d9dd.js";import{V as be}from"./ViewButton.8513a950.js";import{A as Ce}from"./ActionCellRenderer.e25051af.js";import{E as ke}from"./EmployeeScheduleService.4ae5ebd9.js";import{F as Re}from"./index.3f16c6d6.js";import{A as Ae}from"./index.6db83932.js";import{P as De}from"./index.59a3d22b.js";import{A as Le}from"./main.esm.228b04c8.js";import{A as Fe}from"./ActionCellRendererApprover.a32e85d0.js";import{F as Ve}from"./index.15b43d58.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.624fb26d.js";import"./vue-cleave.min.6d14d8ca.js";import"./es.string.replace.f497f8c7.js";import"./index.03f8e544.js";const Se={components:{FileType:re,DenyButton:pe,FormModal:K,FormGroup:Z,TextInput:X,TextArea:J,SubmitButton:H,UpdateButton:ee,CloseButton:W,DeleteButton:$,ProceedButton:ye,Loading:z,Multiselect:oe,Icon:j},data(){return{meridiemOptions:["AM","PM"],isMeridiemRequired:!1,halfWholeDayOptions:[{value:"0",label:"Whole Day"},{value:"1",label:"Last Day Half Day"},{value:"2",label:"First Day Half Day"}],currentEmployeeId:this.$store.userSettings.getActiveUser.employees?this.$store.userSettings.getActiveUser.employees.employee_id:"",currentClassificationId:this.$store.userSettings.getActiveUser.employees?this.$store.userSettings.getActiveUser.employees.classification_id:"",currentRecommendingId:"",currentApprovingId:"",btnTitle:"",leaveOptions:[],leaveReasonOptions:[],recommendingOptions:[],approvingOptions:[],recommending:"",approving:"",status:[],form:{leave_id:"",without_pay:!1,half_day:"",date_from:"",date_to:"",days:"",meridiem:"",hours:"",description:"",leave_reason_id:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isLeaveReasonLoading:!1},fileIcons:{pdf:ae,jpg:ne,default:""}}},methods:{async fetchLeaveReason(s){console.log("this method has been called",this.form.leave_reason_id),console.log("leave",s),s!=this.form.leave_id&&(this.leaveReasonOptions=[],this.form.leave_reason_id=""),this.isLeaveReasonLoading=!0,await se.fetchRecords().then(e=>{e.status==200&&(this.leaveReasonOptions=e.data.data.filter(o=>o.leave_id==s).map(o=>({value:o.id,label:o.name})),this.isLeaveReasonLoading=!1)}).catch(e=>{console.log(e)})},getFileTypeImage(s){if(typeof s=="string"){if(!s)return this.fileIcons.default;const e=s.substring(s.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(s){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await te.Reader2("employee-leave",s),o;if(s.endsWith(".pdf"))o="application/pdf";else if(s.endsWith(".png"))o="image/png";else if(s.endsWith(".jpg")||s.endsWith(".jpeg"))o="image/jpeg";else if(s.endsWith(".svg"))o="image/svg+xml";else throw new Error("Unsupported file type");const l=atob(e),t=new Array(l.length);for(let h=0;h<l.length;h++)t[h]=l.charCodeAt(h);const n=new Uint8Array(t),v=new Blob([n],{type:o}),_=URL.createObjectURL(v);window.open(_),this.state.isLoadingPDF=!1},handleMainImageUpload(){const s=event.target.files[0];this.form.attachment=s;const e=new FileReader;e.onload=()=>{s.type.startsWith("image/")?this.form.imageView=e.result:s.type==="application/pdf"?this.form.imageView=this.pdf_file_view:s.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},e.readAsDataURL(s)},async fetchLeaveType(){await ie.fetchRecords().then(s=>{s.status==200&&(this.leaveOptions=s.data.data.map(e=>({value:e.id,label:e.name})))}).catch(s=>{console.log(s)})},async loadRecord(s){this.resetForm(),this.form=s,this.form.without_pay=!!this.form.without_pay,this.fetchLeaveReason(this.form.leave_id),this.currentRecommendingId=s.recommending?s.recommending[0].employee_id:"",this.currentApprovingId=s.approving?s.approving[0].employee_id:"",this.recommending=s.recommending?s.recommending[0].firstname+" "+s.recommending[0].lastname:"",this.approving=s.approving?s.approving[0].firstname+" "+s.approving[0].lastname:"",this.currentApprovingId==this.currentEmployeeId&&this.form.approver_id==this.currentEmployeeId?this.btnTitle="Approve":this.currentRecommendingId==this.currentEmployeeId&&this.form.status<1&&(this.btnTitle="Submit For Approval"),this.currentClassificationId>=3&&(this.state.isLoading=!0,await S.fetchEmployeeApprover(s.employee_id).then(e=>{if(e.status==200)this.recommendingOptions=e.data.map((o,l)=>({value:o.employee_id,label:o.firstname+" "+o.lastname})),this.approvingOptions=e.data.filter(o=>o.classification_id>=3).map((o,l)=>({value:o.employee_id,label:o.firstname+" "+o.lastname})),this.state.isLoading=!1;else throw new Error("Failed to fetch employee approvers")}))},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={leave_id:"",without_pay:!1,half_day:"",date_from:"",date_to:"",days:"",meridiem:"",hours:"",description:"",attachment:"",recommending_id:"",approver_id:""},console.log(this.form)},reload(){return this.state.showModal=!1,this.$emit("reload")},async updateApproverRecord(){this.state.isSaving=!0;const s=this.form.id;this.state.isSaving=!1;let e={recommending_id:this.form.recommending_id,approver_id:this.form.approver_id};console.log(e),await O.updateApprover(s,e).then(o=>{o.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(o=>{o.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:o.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},async updateRecordByHR(s,e=null){this.state.isSaving=!0;const o=this.form.id;let t={status:s,reason:e};await O.hrValidation(o,t).then(n=>{n.status==201?(console.log("response"),console.log(n),this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3})):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.state.isSaving=!1,this.reload()}).catch(n=>{n.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:n.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.state.isSaving=!1})},async saveRecord(){this.state.isSaving=!0;const s=this.form.id;await O.update(s,this.status).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})})},async submitForm(){this.form.approver_id==this.currentEmployeeId?this.status={status:2}:this.form.recommending_id==this.currentEmployeeId&&(this.status={status:1});try{this.$swal.fire({title:"Are you sure you want to save submit this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(s=>{s.value&&this.saveRecord()})}catch(s){if(s instanceof V){const e={};s.inner.forEach(o=>{e[o.path]=o.message}),this.errors=e}}},async updateApproverForm(){try{this.$swal.fire({title:"Are you sure you want to update the approver of this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(s=>{s.value&&this.updateApproverRecord()})}catch(s){if(s instanceof V){const e={};s.inner.forEach(o=>{e[o.path]=o.message}),this.errors=e}}},async denyForm(){try{this.$swal.fire({title:"Are you sure you want to deny this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No",html:` <textarea id="swal-input" style="width: 100%; height: 80px; padding: 8px; border: 1px solid #ced4da; border-radius: 4px;" placeholder="Enter reason"></textarea>`,preConfirm:()=>{const s=document.getElementById("swal-input").value;return s?this.denied_reason=s:(this.$swal.showValidationMessage("The reason field is required"),!1)}}).then(s=>{this.status={status:99,denied_reason:this.denied_reason},s.value&&this.saveRecord()})}catch(s){if(s instanceof V){const e={};s.inner.forEach(o=>{e[o.path]=o.message}),this.errors=e}}},async ReceiveByHr(s){try{if(s==99){const e=await this.$swal.fire({title:"State the Reason for Deferring this Request",input:"textarea",inputPlaceholder:"Enter your reason here...",inputAttributes:{"aria-label":"Reason for deferment"},showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Submit",cancelButtonText:"Cancel",preConfirm:o=>o||(this.$swal.showValidationMessage("Reason is required!"),!1)});e.isConfirmed&&e.value&&(console.log("Reason for deferment:",e.value),this.updateRecordByHR(s,e.value))}else this.$swal.fire({title:"Are you sure you want to receive/validate this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&(console.log("recieved by HR"),this.updateRecordByHR(s))})}catch(e){if(e instanceof V){const o={};e.inner.forEach(l=>{o[l.path]=l.message}),this.errors=o}}},onDateFromChange(){this.form.date_to="",this.calculateDays()},calculateDays(){if(this.form.half_day==="0"?this.isMeridiemRequired=!0:this.isMeridiemRequired=!1,this.form.date_from&&this.form.date_to){const s=M(this.form.date_from);let o=M(this.form.date_to).diff(s,"days")+1;this.form.half_day==="0"&&(o-=.5,this.isMeridiemRequired=!0),this.form.days=o}}},watch:{"form.half_day":{handler:"calculateDays",immediate:!0}},mounted(){this.fetchLeaveType()}},Be={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Te={key:0,class:"bg-red-50 dark:bg-red-900 dark:bg-opacity-30 border-l-4 border-red-500 p-4 rounded-md shadow-sm"},Ie={class:"text-red-600 dark:text-red-400 text-sm"},Me={class:"grid grid-cols-12 gap-4"},Ee={class:"col-span-6"},Ue={key:0,class:"text-[#ec4899]"},qe={class:"flex items-center gap-4"},Oe={class:"flex items-center cursor-pointer"},je=["checked"],Pe={class:"col-span-6"},We={key:0,class:"text-[#ec4899]"},He={class:"grid grid-cols-12 gap-4"},ze={key:0,class:"col-span-4"},Ge={key:0,class:"text-[#ec4899]"},Ye={class:"col-span-4"},Ne={key:0,class:"text-[#ec4899]"},Ze={class:"col-span-4"},Ke={key:0,class:"text-[#ec4899]"},Qe={class:"grid grid-cols-12 gap-4"},Je={class:"col-span-6"},Xe={class:"col-span-6"},$e={class:"grid grid-cols-12 gap-4"},et={key:0,class:"col-span-6"},tt={key:0,class:"text-[#ec4899]"},st={class:"col-span-6"},it={key:0,class:"text-[#ec4899]"},ot={key:1},rt={class:"grid grid-cols-12 justify-center items-center"},at={class:"col-span-8 flex justify-between items-center gap-4"},nt={class:"col-span-6 flex justify-center items-center gap-4"},lt={class:"font-bold"},dt={class:"col-span-6 flex justify-center items-center gap-4"},mt={class:"font-bold"},ct={key:2},ft={class:"grid grid-cols-12 gap-4"},ht={class:"col-span-6"},ut={class:"relative"},gt={class:"col-span-6"},_t={class:"relative"},pt={class:"flex gap-1 justify-end pt-8"},yt={key:0,class:"flex gap-1 justify-end"},vt={key:1,class:"flex gap-1 justify-end"};function wt(s,e,o,l,t,n){const v=f("Loading"),_=f("Multiselect"),h=f("FormGroup"),w=f("flat-pickr"),x=f("TextInput"),k=f("Fileinput"),R=f("Card"),D=f("FileType"),L=f("TextArea"),b=f("UpdateButton"),F=f("DenyButton"),E=f("CloseButton"),U=f("FormModal");return r(),p(U,{title:"View Leave Request",active:t.state.showModal,sideTitle:this.form.status==0?"for recommendation":this.form.status==1?"for approval":this.form.status==2&&this.form.validated==99?"Denied ":this.form.status==2&&this.form.validated==2?"Validated":this.form.status==2?"For Validation":this.form.status==99?"Denied":"",badgeColor:this.form.status==0?"warning":this.form.status==1?"info":this.form.status==2&&this.form.validated==99?"danger":this.form.status==2&&this.form.validate==1?"success":this.form.status==2?"purple":this.form.status==99?"danger":"",onSubmit:s.confirmSubmit,onClose:n.closeModal,themeClass:"bg-gray-800",sizeClass:"lg:w-3/4"},{default:g(()=>[t.state.isLoading?(r(),p(v,{key:0,text:"Fetching record"})):d("",!0),e[22]||(e[22]=i("div",{class:"grid lg:grid-cols-3 grid-cols-1 gap-4 mb-4"},null,-1)),i("div",Be,[this.form.status==2&&this.form.validated==99?(r(),m("div",Te,[e[17]||(e[17]=i("h3",{class:"text-red-700 dark:text-red-300 font-semibold mb-1 text-sm"}," Denied Reason : ",-1)),i("p",Ie,y(this.form.deferred_reason),1)])):d("",!0),i("form",{onSubmit:e[16]||(e[16]=Q((...u)=>s.confirmSubmit&&s.confirmSubmit(...u),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[t.state.isSaving?(r(),p(v,{key:0,text:"Saving record"})):d("",!0),i("div",Me,[i("div",Ee,[a(h,{label:"Leave Type",isRequired:!0},{default:g(()=>[a(_,{modelValue:t.form.leave_id,"onUpdate:modelValue":e[0]||(e[0]=u=>t.form.leave_id=u),error:t.errors.leave_id,options:t.leaveOptions,searchable:!0,onChange:n.calculateDays,class:"w-full"},null,8,["modelValue","error","options","onChange"]),t.errors.leave_id?(r(),m("div",Ue," Leave type is required ")):d("",!0)]),_:1}),i("div",qe,[i("label",Oe,[T(i("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:t.form.without_pay,"onUpdate:modelValue":e[1]||(e[1]=u=>t.form.without_pay=u),disabled:""},null,8,je),[[I,t.form.without_pay]]),e[18]||(e[18]=i("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[i("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"},[i("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[19]||(e[19]=i("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Without Pay",-1))])])]),i("div",Pe,[a(h,{label:"Half/Whole Day",isRequired:!0},{default:g(()=>[a(_,{modelValue:t.form.half_day,"onUpdate:modelValue":e[2]||(e[2]=u=>t.form.half_day=u),error:t.errors.half_day,options:t.halfWholeDayOptions,onChange:n.calculateDays,class:"w-full"},null,8,["modelValue","error","options","onChange"]),t.errors.half_day?(r(),m("div",We," Half/Whole day is required ")):d("",!0)]),_:1})])]),i("div",He,[t.form.half_day!==0?(r(),m("div",ze,[(t.isMeridiemRequired?s.isRequired="true":s.isRequired="false")?(r(),p(h,{key:0,label:"AM/PM"},{default:g(()=>[a(_,{modelValue:t.form.meridiem,"onUpdate:modelValue":e[3]||(e[3]=u=>t.form.meridiem=u),error:t.errors.meridiem,options:t.meridiemOptions,class:"form-control w-full h-[48px] mt-2"},null,8,["modelValue","error","options"]),t.errors.meridiem?(r(),m("div",Ge," AM/PM is required ")):d("",!0)]),_:1})):d("",!0)])):d("",!0),i("div",Ye,[a(h,{label:"Date From",isRequired:!0},{default:g(()=>[a(w,{modelValue:t.form.date_from,"onUpdate:modelValue":e[4]||(e[4]=u=>t.form.date_from=u),class:"form-control h-[48px]",onChange:n.onDateFromChange,placeholder:"Select date"},null,8,["modelValue","onChange"]),t.errors.date_from?(r(),m("div",Ne," Date from is required ")):d("",!0)]),_:1})]),i("div",Ze,[a(h,{label:"Date To",isRequired:!0},{default:g(()=>[a(w,{modelValue:t.form.date_to,"onUpdate:modelValue":e[5]||(e[5]=u=>t.form.date_to=u),class:"form-control h-[48px]",min:t.form.date_from,placeholder:"Select date",onChange:n.calculateDays},null,8,["modelValue","min","onChange"]),t.errors.date_to?(r(),m("div",Ke," Date to is required ")):d("",!0)]),_:1})])]),i("div",Qe,[i("div",Je,[a(h,{label:"Hours"},{default:g(()=>[a(x,{modelValue:t.form.hours,"onUpdate:modelValue":e[6]||(e[6]=u=>t.form.hours=u),error:t.errors.hours,placeholder:"Enter hours",classInput:"h-[48px] w-full"},null,8,["modelValue","error"])]),_:1})]),i("div",Xe,[a(h,{label:"Days"},{default:g(()=>[a(x,{modelValue:t.form.days,"onUpdate:modelValue":e[7]||(e[7]=u=>t.form.days=u),error:t.errors.days,isReadonly:!0,placeholder:"Calculated days",classInput:"h-[48px] w-full"},null,8,["modelValue","error"])]),_:1})])]),i("div",$e,[t.form.attachment!=""&&t.form.attachment!=null?(r(),m("div",et,[a(h,{label:"Attachment"},{default:g(()=>[a(R,{title:"File Input Basic"},{default:g(()=>[a(k,{modelValue:t.form.attachment,"onUpdate:modelValue":e[8]||(e[8]=u=>t.form.attachment=u),name:"basic",onChange:n.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),t.errors.attachment?(r(),m("div",tt,y(t.errors.attachment),1)):d("",!0)]),_:1}),typeof t.form.attachment=="string"?(r(),m("div",{key:0,class:"flex items-center gap-2 mt-2 cursor-pointer",onClick:e[9]||(e[9]=u=>n.viewAttachment(t.form.attachment))},[a(D,{image:n.getFileTypeImage(t.form.attachment)},null,8,["image"]),A(" "+y(t.form.attachment),1)])):d("",!0)]),_:1})])):d("",!0),i("div",st,[a(h,{label:"Reason",isRequired:!0},{default:g(()=>[a(_,{modelValue:t.form.leave_reason_id,"onUpdate:modelValue":e[10]||(e[10]=u=>t.form.leave_reason_id=u),error:t.errors.leave_reason_id,searchable:!0,options:t.leaveReasonOptions,loading:s.isLeaveReasonLoading,class:"form-control w-full h-[48px] mt-2"},null,8,["modelValue","error","options","loading"]),t.form.leave_reason_id==5||t.form.leave_reason_id==14?(r(),p(L,{key:0,class:"mt-2",modelValue:t.form.description,"onUpdate:modelValue":e[11]||(e[11]=u=>t.form.description=u),rows:"2",placeholder:"Enter reason",classInput:"w-full"},null,8,["modelValue"])):d("",!0)]),_:1}),t.errors.description?(r(),m("div",it," Reason is required ")):d("",!0)])]),t.currentClassificationId<=2?(r(),m("div",ot,[i("div",rt,[i("div",at,[i("div",nt,[e[20]||(e[20]=A(" Recommending: ")),i("p",lt,y(t.recommending),1)]),i("div",dt,[e[21]||(e[21]=A(" Approving: ")),i("p",mt,y(t.approving),1)])])])])):(r(),m("div",ct,[i("div",ft,[i("div",ht,[a(h,{label:"Recommending"},{default:g(()=>[i("div",ut,[a(_,{modelValue:t.form.recommending_id,"onUpdate:modelValue":e[12]||(e[12]=u=>t.form.recommending_id=u),"close-on-select":!0,searchable:!0,id:"recommending_id",options:t.recommendingOptions},null,8,["modelValue","options"])])]),_:1})]),i("div",gt,[a(h,{label:"Approver"},{default:g(()=>[i("div",_t,[a(_,{modelValue:t.form.approver_id,"onUpdate:modelValue":e[13]||(e[13]=u=>t.form.approver_id=u),"close-on-select":!0,searchable:!0,id:"approver_id",options:t.approvingOptions},null,8,["modelValue","options"])])]),_:1})])])])),i("div",pt,[this.form.status==0&&t.currentRecommendingId==t.currentEmployeeId||t.currentApprovingId==t.currentEmployeeId&&this.form.status==1&&t.currentApprovingId==this.form.approver_id||this.form.approver_id==this.form.recommending_id&&t.currentApprovingId==this.form.approver_id&&t.currentEmployeeId==this.form.approver_id?(r(),m("div",yt,[this.form.status<=1?(r(),p(b,{key:0,onClick:n.submitForm,text:t.btnTitle},null,8,["onClick","text"])):d("",!0),t.form.status<=1?(r(),p(F,{key:1,onClick:n.denyForm,text:"Deny"},null,8,["onClick"])):d("",!0)])):this.form.status==0&&t.currentApprovingId==t.currentEmployeeId||t.currentApprovingId!=this.form.approver_id?(r(),m("div",vt,[this.form.status<=1?(r(),p(b,{key:0,onClick:n.updateApproverForm,text:"Update Approver"},null,8,["onClick"])):d("",!0)])):d("",!0),this.form.status===2&&this.form.validated==0?(r(),p(b,{key:2,btnClass:"text-green-600 bg-transpanent hover:ring ring-green-600 ring-offset-1 border border-green-600 transition duration-150 ease-out hover:ease-in py-2 px-3",onClick:e[14]||(e[14]=u=>n.ReceiveByHr(1)),text:"Receive"})):d("",!0),this.form.status===2&&this.form.validated==0?(r(),p(b,{key:3,btnClass:"text-red-600 bg-transparent hover:ring ring-red-600 ring-offset-1 border border-red-600 transition duration-150 ease-out hover:ease-in py-2 px-3",icon:"material-symbols:unpublished",onClick:e[15]||(e[15]=u=>n.ReceiveByHr(99)),text:"Deny"})):d("",!0),a(E,{onClick:n.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["active","sideTitle","badgeColor","onSubmit","onClose"])}const xt=P(Se,[["render",wt],["__scopeId","data-v-b82a4484"]]);const bt={components:{Alert:Ae,FileType:re,Fileinput:Re,FormModal:K,FormGroup:Z,TextInput:X,TextArea:J,SubmitButton:H,UpdateButton:ee,CloseButton:W,Loading:z,Multiselect:oe,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:"",recommending_img:"",approving:"",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:ae,jpg:ne,default:""}}},methods:{deleteFile(s){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 s=this.form.id,e=this.form.attachment,o={id:s,attachment:e};await C.removeAttachment(o).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=""):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(s){if(typeof s=="string"){if(!s)return this.fileIcons.default;const e=s.substring(s.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(s){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await te.Reader2("employee-leave",s),o;if(s.endsWith(".pdf"))o="application/pdf";else if(s.endsWith(".png"))o="image/png";else if(s.endsWith(".jpg")||s.endsWith(".jpeg"))o="image/jpeg";else if(s.endsWith(".svg"))o="image/svg+xml";else throw new Error("Unsupported file type");const l=atob(e),t=new Array(l.length);for(let h=0;h<l.length;h++)t[h]=l.charCodeAt(h);const n=new Uint8Array(t),v=new Blob([n],{type:o}),_=URL.createObjectURL(v);window.open(_),this.state.isLoadingPDF=!1},handleMainImageUpload(){const s=event.target.files[0];this.form.attachment=s;const e=new FileReader;e.onload=()=>{s.type.startsWith("image/")?this.form.imageView=e.result:s.type==="application/pdf"?this.form.imageView=this.pdf_file_view:s.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},e.readAsDataURL(s)},async fetchEmployeeSchedule(){await ke.fetchRecord(1).then(s=>{s.status==200&&s.data&&(this.state.hasSchedule=!0)}).catch(s=>{console.log(s)})},async fetchLeaveType(){await ie.fetchRecordsEmployeeLeaveType().then(s=>{s.status==200&&(this.leaveOptions=s.data.map(e=>({value:e.id,label:e.name})))}).catch(s=>{console.log(s)})},async fetchLeaveReason(s){console.log("this method has been called",this.form.leave_reason_id),console.log("leave",s),s!=this.form.leave_id&&(this.leaveReasonOptions=[],this.form.leave_reason_id=""),this.isLeaveReasonLoading=!0,await se.fetchRecords().then(e=>{e.status==200&&(this.leaveReasonOptions=e.data.data.filter(o=>o.leave_id==s).map(o=>({value:o.id,label:o.name})),this.isLeaveReasonLoading=!1)}).catch(e=>{console.log(e)})},async fetchApprover(){this.state.isLoadingApprovers=!0,await S.fetchApproverRecords().then(s=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&s.data.map(e=>{console.log(e),(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||"")}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&s.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&&s.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.isLoadingApprovers=!1}).catch(s=>{console.log(s)})},loadRecord(s){this.resetForm(),this.state.isEdit=!0,this.form=s,this.form.without_pay=s.without_pay==1,this.form.allow_higher_approval=s.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 s=new FormData;Object.keys(this.form).forEach(e=>{s.append(e,this.form[e])}),await C.update(s).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 s=new FormData;Object.keys(this.form).forEach(e=>{s.append(e,this.form[e])}),await C.create(s).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 ve().shape({leave_id:B().required("Leave type is required"),half_day:B().required("Please select a half or whole day"),date_from:B().required("Date from is required"),date_to:B().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(s){if(s instanceof V){const e={};s.inner.forEach(o=>{e[o.path]=o.message}),this.errors=e}}},async fetchApprover3DaysOrMore(){this.state.isLoadingApprovers=!0,await S.fetchApproverRecords().then(s=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&s.data.map(e=>{e.classification_id==2&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==3&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),this.approving==""&&e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname)}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&s.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname)}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&s.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname)}),this.state.isLoadingApprovers=!1}).catch(s=>{console.log(s)})},async fetchApprover2DaysOrLess(){this.state.isLoadingApprovers=!0,await S.fetchApproverRecords().then(s=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&s.data.map(e=>{this.form.allow_higher_approval||this.form.days<3?((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==3&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),this.approving==""&&e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname)):((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname))}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&s.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname)}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&s.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname)}),this.state.isLoadingApprovers=!1}).catch(s=>{console.log(s)})},async fetchApprover2DaysOrLess(){this.state.isLoadingApprovers=!0,await S.fetchApproverRecords().then(s=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&s.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==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname),e.classification_id==3&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),this.approving==""&&e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname)):((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname))}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&s.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname)}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&s.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname)}),this.state.isLoadingApprovers=!1}).catch(s=>{console.log(s)})},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(s=>s.id==this.form.leave_id).map(s=>{s.total>.49?this.form.without_pay=!1:this.form.without_pay=!0}),this.form.date_from&&this.form.date_to){this.state.isLoadingApprovers=!0;const s=M(this.form.date_from),e=M(this.form.date_to);e.diff(s,"days")+1;let o={date_from:s.format("YYYY-MM-DD"),date_to:e.format("YYYY-MM-DD"),half_day:this.form.half_day};try{let t=(await C.fetchHolidayDayoff(o)).data,n=0,v=0;if(n=t/8,v=t,this.state.isLoadingApprovers=!1,n>2?this.fetchApprover3DaysOrMore():n<=2?this.fetchApprover2DaysOrLess():this.fetchApprover(),this.form.days=n,this.form.hours=v,this.statistics[0].count.filter(_=>_.id==this.form.leave_id).map(_=>{let h="";this.state.isEdit?h=parseFloat(_.total)+parseFloat(this.daysRecord):h=_.total,h<this.form.days&&!this.form.without_pay?this.errors.days="Days exceeded your remaining credits":this.errors.days=!1}),this.form.leave_id==3){let _=0,h=0;await this.statistics[0].count.map(w=>{w.id==2&&(_=w.total),w.id==3&&(h=w.total),_>.49&&this.form.days<=_&&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(l){l.response.data.message=='Attempt to read property "schedule" on null'?this.noSchedule=!0:console.log(l)}}}},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"(s){s&&(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()}},Ct={class:"grid lg:grid-cols-3 grid-cols-1 gap-4 mb-6"},kt={class:"flex flex-col items-center mb-2"},Rt={class:"text-sm font-semibold text-slate-600 dark:text-white"},At={class:"flex justify-center gap-6 text-xl text-slate-900 dark:text-white font-medium"},Dt={class:"block text-xs font-medium text-slate-600 dark:text-white"},Lt={class:"block"},Ft={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Vt={key:1,class:"text-red-400 italic items-center"},St={class:"grid grid-cols-12 gap-4"},Bt={class:"col-span-6"},Tt={key:0,class:"text-[#ec4899]"},It={key:0,class:"flex items-center gap-4 mb-2"},Mt={class:"flex items-center cursor-pointer"},Et=["checked"],Ut={class:"flex items-center gap-4"},qt={class:"flex items-center cursor-pointer"},Ot=["checked"],jt={class:"col-span-6"},Pt={key:0,class:"text-[#ec4899]"},Wt={class:"grid grid-cols-12 gap-4"},Ht={class:"col-span-4"},zt={key:0,class:"text-[#ec4899]"},Gt={class:"col-span-4"},Yt={key:0,class:"text-[#ec4899]"},Nt={class:"col-span-4"},Zt={key:0,class:"text-[#ec4899]"},Kt={class:"grid grid-cols-12 gap-4"},Qt={class:"col-span-6"},Jt={class:"col-span-6"},Xt={key:0,class:"text-[#ec4899]"},$t={class:"grid grid-cols-12 gap-4"},es={class:"col-span-6"},ts={key:0,class:"text-[#ec4899]"},ss={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},is={class:"flex justify-between w-full items-center"},os={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},rs={class:"col-span-6"},as={key:0,class:"text-[#ec4899]"},ns={class:"grid grid-cols-12 gap-4"},ls={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},ds={class:"flex-shrink-0 mr-4"},ms=["src"],cs={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},fs={class:"text-left"},hs={class:"text-sm font-semibold text-gray-600"},us={class:"text-lg font-bold text-gray-900"},gs={key:0,class:"text-sm text-gray-900"},_s={key:1,class:"text-sm text-gray-900"},ps={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},ys={class:"flex-shrink-0 mr-4"},vs=["src"],ws={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},xs={class:"text-left"},bs={class:"text-lg font-bold text-gray-900"},Cs={class:"text-sm text-gray-900"},ks={class:"flex justify-between gap-2"},Rs={key:0,class:"flex items-center cursor-pointer"},As=["checked"];function Ds(s,e,o,l,t,n){const v=f("Loading"),_=f("Alert"),h=f("Icon"),w=f("Multiselect"),x=f("FormGroup"),k=f("flat-pickr"),R=f("TextInput"),D=f("Fileinput"),L=f("Card"),b=f("FileType"),F=f("TextArea"),E=f("SubmitButton"),U=f("UpdateButton"),u=f("CloseButton"),le=f("FormModal");return r(),p(le,{disableBackdrop:!1,title:t.form.status!==0?"Leave Application Form":t.state.isEdit?"Edit Leave Request":"Leave Application Form",active:t.state.showModal,onSubmit:s.confirmSubmit,onClose:n.closeModal,themeClass:t.state.isEdit&&t.form.status==0?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-3/4"},{default:g(()=>[t.state.isEdit&&t.state.isLoading?(r(),p(v,{key:0,text:"Fetching record"})):d("",!0),t.state.isLoadingApprovers?(r(),p(v,{key:1,text:"Fetching approvers"})):d("",!0),t.form.denied_reason?(r(),p(_,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:g(()=>[e[17]||(e[17]=i("span",{class:"font-semibold"},"Denied Reason:",-1)),A(" "+y(t.form.denied_reason),1)]),_:1})):d("",!0),i("div",Ct,[(r(!0),m(N,null,G(o.statistics,(c,de)=>(r(),m("div",{key:de,class:Y([c.bg,"rounded-md p-4 bg-opacity-[0.15] dark:bg-opacity-50 text-center drop-shadow-lg"])},[i("div",kt,[a(h,{icon:c.icon,class:Y(["h-12 w-12 text-3xl bg-white rounded-full p-3 mb-3",c.text])},null,8,["icon","class"]),i("div",Rt,y(c.title),1)]),i("div",At,[(r(!0),m(N,null,G(c.count,q=>(r(),m("div",{key:q.type,class:"text-center"},[i("span",Dt,y(q.type),1),i("span",Lt,y(q.total),1)]))),128))])],2))),128))]),i("div",Ft,[i("form",{onSubmit:e[16]||(e[16]=Q((...c)=>s.confirmSubmit&&s.confirmSubmit(...c),["prevent"])),class:"space-y-6"},[t.state.isSaving?(r(),p(v,{key:0,text:"Saving record"})):d("",!0),t.state.hasSchedule?d("",!0):(r(),m("div",Vt,"* Schedule is required ")),i("div",St,[i("div",Bt,[a(x,{label:"Leave Type",isRequired:!0},{default:g(()=>[a(w,{modelValue:t.form.leave_id,"onUpdate:modelValue":e[0]||(e[0]=c=>t.form.leave_id=c),error:t.errors.leave_id,options:t.leaveOptions,searchable:!0,onChange:e[1]||(e[1]=c=>{n.calculateDays(),n.fetchLeaveReason(c)}),class:"w-full"},null,8,["modelValue","error","options"]),t.errors.leave_id?(r(),m("div",Tt,"Leave type is required")):d("",!0)]),_:1}),t.showCreditToVL?(r(),m("div",It,[i("label",Mt,[T(i("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:t.form.credit_to_vl,"onUpdate:modelValue":e[2]||(e[2]=c=>t.form.credit_to_vl=c)},null,8,Et),[[I,t.form.credit_to_vl]]),e[18]||(e[18]=i("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[i("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"},[i("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[19]||(e[19]=i("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Credit to Vacation Leave?",-1))])])):d("",!0),i("div",Ut,[i("label",qt,[T(i("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:t.form.without_pay,"onUpdate:modelValue":e[3]||(e[3]=c=>t.form.without_pay=c),disabled:""},null,8,Ot),[[I,t.form.without_pay]]),e[20]||(e[20]=i("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[i("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"},[i("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[21]||(e[21]=i("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Without Pay",-1))])])]),i("div",jt,[a(x,{label:"Half/Whole Day",isRequired:!0},{default:g(()=>[a(w,{modelValue:t.form.half_day,"onUpdate:modelValue":e[4]||(e[4]=c=>t.form.half_day=c),error:t.errors.half_day,options:t.halfWholeDayOptions,onChange:n.calculateDays,class:"w-full"},null,8,["modelValue","error","options","onChange"]),t.errors.half_day?(r(),m("div",Pt,"Half/Whole day is required")):d("",!0)]),_:1})])]),i("div",Wt,[i("div",Ht,[(t.isMeridiemRequired?s.isRequired="true":s.isRequired="false")?(r(),p(x,{key:0,label:"AM/PM"},{default:g(()=>[a(w,{modelValue:t.form.meridiem,"onUpdate:modelValue":e[5]||(e[5]=c=>t.form.meridiem=c),error:t.errors.meridiem,options:t.meridiemOptions,class:"form-control w-full h-[48px] mt-2"},null,8,["modelValue","error","options"]),t.errors.meridiem?(r(),m("div",zt,"AM/PM is required")):d("",!0)]),_:1})):d("",!0)]),i("div",Gt,[a(x,{label:"Date From",isRequired:!0},{default:g(()=>[a(k,{modelValue:t.form.date_from,"onUpdate:modelValue":e[6]||(e[6]=c=>t.form.date_from=c),class:"form-control h-[48px]",onChange:n.onDateFromChange,placeholder:"Select date"},null,8,["modelValue","onChange"]),t.errors.date_from?(r(),m("div",Yt,"Date from is required")):d("",!0)]),_:1})]),i("div",Nt,[a(x,{label:"Date To",isRequired:!0},{default:g(()=>[a(k,{modelValue:t.form.date_to,"onUpdate:modelValue":e[7]||(e[7]=c=>t.form.date_to=c),class:"form-control h-[48px]",placeholder:"Select date",config:{minDate:t.form.date_from},onChange:n.calculateDays},null,8,["modelValue","config","onChange"]),t.errors.date_to?(r(),m("div",Zt,"Date to is required")):d("",!0)]),_:1})])]),i("div",Kt,[i("div",Qt,[a(x,{label:"Hours"},{default:g(()=>[a(R,{modelValue:t.form.hours,"onUpdate:modelValue":e[8]||(e[8]=c=>t.form.hours=c),error:t.errors.hours,placeholder:"Enter hours",classInput:"h-[48px] w-full"},null,8,["modelValue","error"])]),_:1})]),i("div",Jt,[a(x,{label:"Days"},{default:g(()=>[a(R,{modelValue:t.form.days,"onUpdate:modelValue":e[9]||(e[9]=c=>t.form.days=c),error:t.errors.days,isReadonly:!0,placeholder:"Calculated days",classInput:"h-[48px] w-full"},null,8,["modelValue","error"]),t.errors.days?(r(),m("div",Xt)):d("",!0)]),_:1})])]),i("div",$t,[i("div",es,[a(x,{label:"Attachment"},{default:g(()=>[a(L,{title:"File Input Basic"},{default:g(()=>[a(D,{modelValue:t.form.attachment,"onUpdate:modelValue":e[10]||(e[10]=c=>t.form.attachment=c),name:"basic",onChange:n.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),t.errors.attachment?(r(),m("div",ts,y(t.errors.attachment),1)):d("",!0)]),_:1}),typeof t.form.attachment=="string"&&t.form.attachment?(r(),m("div",ss,[i("div",is,[i("div",{class:"flex items-center cursor-pointer",onClick:e[11]||(e[11]=c=>n.viewAttachment(t.form.attachment))},[a(b,{image:n.getFileTypeImage(t.form.attachment)},null,8,["image"]),A(" "+y(t.form.attachment),1)]),t.form.status==0&&t.form.days<3?(r(),m("div",os,[a(h,{icon:"mingcute:delete-2-fill",onClick:e[12]||(e[12]=c=>n.deleteFile(t.form.id))})])):d("",!0)])])):d("",!0)]),_:1})]),i("div",rs,[a(x,{label:"Reason",isRequired:!0},{default:g(()=>[a(w,{modelValue:t.form.leave_reason_id,"onUpdate:modelValue":e[13]||(e[13]=c=>t.form.leave_reason_id=c),error:t.errors.leave_reason_id,searchable:!0,options:t.leaveReasonOptions,loading:s.isLeaveReasonLoading,class:"form-control w-full h-[48px] mt-2"},null,8,["modelValue","error","options","loading"]),t.form.leave_reason_id==5||t.form.leave_reason_id==14?(r(),p(F,{key:0,class:"mt-2",modelValue:t.form.description,"onUpdate:modelValue":e[14]||(e[14]=c=>t.form.description=c),rows:"2",placeholder:"Enter reason",classInput:"w-full"},null,8,["modelValue"])):d("",!0)]),_:1}),t.errors.description?(r(),m("div",as,"Reason is required")):d("",!0)])]),i("div",ns,[i("div",ls,[i("div",ds,[t.recommending_img?(r(),m("img",{key:0,src:t.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,ms)):(r(),m("div",cs," No Image "))]),i("div",fs,[i("div",hs,y(t.form.allow_higher_approval||t.form.days>2?"Recommending":"Approving"),1),i("div",us,y(t.recommending),1),t.form.allow_higher_approval||t.form.days>2?(r(),m("div",gs,y(t.form.recommended_at?"Date: ("+this.$formatDate(t.form.recommended_at)+")":""),1)):(r(),m("div",_s,y(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1))])]),t.form.allow_higher_approval||t.form.days>2?(r(),m("div",ps,[i("div",ys,[t.approving_img?(r(),m("img",{key:0,src:t.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,vs)):(r(),m("div",ws," No Image "))]),i("div",xs,[e[22]||(e[22]=i("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),i("div",bs,y(t.approving),1),i("div",Cs,y(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1)])])):d("",!0)]),i("div",ks,[i("div",null,[t.form.days<3&&t.form.days!=""?(r(),m("label",Rs,[T(i("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:t.form.allow_higher_approval,"onUpdate:modelValue":e[15]||(e[15]=c=>t.form.allow_higher_approval=c)},null,8,As),[[I,t.form.allow_higher_approval]]),e[23]||(e[23]=i("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[i("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"},[i("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[24]||(e[24]=i("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])):d("",!0)]),i("div",null,[(!t.state.isEdit&&o.statistics[0].count.length!==0||t.form.without_pay)&&t.state.hasSchedule?(r(),p(E,{key:0,onClick:n.submitForm},null,8,["onClick"])):t.form.status===0&&t.state.hasSchedule?(r(),p(U,{key:1,onClick:n.submitForm},null,8,["onClick"])):d("",!0),a(u,{onClick:n.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const Ls=P(bt,[["render",Ds],["__scopeId","data-v-650ccd97"]]);const Fs={mixins:[me],components:{FilterTimekeeping:_e,FromGroup:Ve,ActionCellRenderer:Ce,ActionCellRendererApprover:Fe,AgGridVue:Le,Pagination:De,Card:fe,Button:he,Badge:ue,Layout:ce,Icon:j,CreateButton:we,SubmitButton:H,CloseButton:W,EditButton:xe,DeleteButton:$,ViewButton:be,Form:Ls,InputGroup:ge,Loading:z,View:xt},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:1},{field:"employee_id",filter:!0,floatingFilter:!0,flex:2},{field:"name",filter:!0,floatingFilter:!0,flex:2},{field:"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:s=>{const e=s.value,o=s.data.validated;return e===0?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-yellow-600 bg-gray-100 px-4">For Recommendation</span>':e===1?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-blue-600 bg-gray-100 px-4">For Approval</span>':o===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>':o===99&&e===2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-orange-600 px-4">Denied </div>':e===2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-fuchsia-600 px-4">For Validation</div>':e===99?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-red-600 bg-gray-100 px-4">Denied</span>':""}},{headerName:"Actions",cellRenderer:"ActionCellRendererApprover",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:{onGridReady(s){this.gridApi=s.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(s=>s.field!=="actions").map(s=>s.field)}):console.error("Grid API is not ready.")},async reloadRecords(){await this.fetchEmployeeLeaveCreditRecords(),await this.fetchRecords()},formatDate(s){const e=new Date(s),o=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),l=new Date(o.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),t=l.getFullYear(),n=String(l.getMonth()+1).padStart(2,"0"),v=String(l.getDate()).padStart(2,"0");return`${t}-${n}-${v}`},async fetchEmployeeLeaveCreditRecords(){this.state.isLoading=!0,await C.fetchEmployeeLeaveCreditRecords().then(s=>{this.leaveCredits=s.data,this.statistics[0].count=[],s.data.map(e=>{this.statistics[0].count.push({id:e.leave_type.id,type:e.leave_type.name,total:e.remaining})})}).finally(()=>{this.state.isLoading=!1})},async fetchRecords(s={}){this.state.isLoading=!0,await C.fetchRecordList({dealership:this.$store.userSettings.activeDealership,...s}).then(e=>{let o=e.data.data;this.items=o.map((l,t)=>({...l,"#":t+1,employee_id:l.employee_id,name:l.employee.lastname+", "+l.employee.firstname,type:l.leave_type.name+(l.without_pay?" (Without Pay)":""),"date coverage":l.date_from===l.date_to?this.$formatDate(l.date_from):this.$formatDate(l.date_from)+" - "+this.$formatDate(l.date_to)+(l.half_day?l.meridiem?" (PM)":" (AM)":""),"days/hours":l.days+" Day/s ("+l.hours+" Hour/s)","date created":this.$formatDate(l.created_at),status:l.status,validated:l.validated}))}).finally(()=>{this.state.isLoading=!1})},applyFilters(s){this.fetchRecords(s)},reload(){this.$emit("reload")},async deleteRecord(s){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,C.remove(s).then(o=>{o.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(s){this.$refs.form.resetForm(),this.$refs.form.loadRecord(s),this.$refs.form.state.showModal=!0},viewRecord(s){console.log(s),this.$refs.view.resetForm(),this.$refs.view.loadRecord(s),this.$refs.view.state.showModal=!0}},mounted(){this.fetchRecords(),this.fetchEmployeeLeaveCreditRecords()}},Vs={class:"space-y-10 mt-4"},Ss={class:"flex items-center justify-between"},Bs={class:"text-2xl font-bold text-slate-900 dark:text-white"},Ts={class:"relative"},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"},Ms={class:"flex items-center justify-center gap-4 text-gray-900"},Es={class:"flex items-center gap-4"},Us={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function qs(s,e,o,l,t,n){const v=f("FilterTimekeeping"),_=f("Icon"),h=f("Button"),w=f("ag-grid-vue"),x=f("Card"),k=f("Loading"),R=f("View"),D=f("Form"),L=f("Layout");return r(),p(L,{breadcrumbs:t.breadcrumbs},{default:g(()=>[i("div",Vs,[a(x,{title:"Leave Applications"},{default:g(()=>{var b;return[i("div",Ss,[i("h2",Bs,y(s.title),1)]),i("div",Ts,[i("div",Is,[i("div",Ms,y(((b=s.$store.userSettings.dealershipAccess.find(F=>F.id==s.$store.userSettings.activeDealership))==null?void 0:b.name)+" - REQUESTED LEAVE"||"Requested Leave"),1),i("div",Es,[a(v,{onFilterChanged:n.applyFilters},null,8,["onFilterChanged"]),a(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:n.exportToCsv},{default:g(()=>[e[3]||(e[3]=i("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),i("span",Us,[a(_,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[2]||(e[2]=A(" Export to CSV "))])]),_:1},8,["onClick"])])])]),a(w,{ref:"agGrid",rowData:t.items,columnDefs:t.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:t.paginationPageSize,paginationPageSizeSelector:t.paginationPageSizeSelector,onGridReady:n.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])]}),_:1}),t.state.isLoading?(r(),p(k,{key:0,text:"Fetching records"})):d("",!0),a(R,{onCloseModal:e[0]||(e[0]=b=>t.state.showModal=!1),ref:"view",onReload:n.fetchRecords},null,8,["onReload"]),a(D,{onCloseModal:e[1]||(e[1]=b=>t.state.showModal=!1),ref:"form",statistics:t.statistics,onReload:n.reloadRecords},null,8,["statistics","onReload"])])]),_:1},8,["breadcrumbs"])}const Ei=P(Fs,[["render",qs],["__scopeId","data-v-64c1f19f"]]);export{Ei as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.13 |
proxy
|
phpinfo
|
Settings