File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.8b4d0f77.js
Back
import{w as xe,L as we}from"./index.a2e6eae1.js";import{C as be}from"./index.80034d43.js";import{B as Ce}from"./index.cc73f214.js";import{B as ke}from"./index.6e6276ec.js";import{I as P}from"./index.0683473b.js";import{I as Se}from"./index.a2c793b0.js";import{l as Fe}from"./lodash.436e061f.js";import{_ as j,r as m,o as a,c as v,w as u,j as c,d as s,f as S,t as h,k as ae,e as r,b as f,p as A,s as L,X as ne}from"./index.85badd64.js";import{E as V}from"./EmployeeObService.5ccd9f39.js";import{A as Te}from"./main.esm.35b2f04c.js";import{A as Re}from"./ActionCellRenderer.e268db3d.js";import{C as q}from"./CloseButton.d4d5b449.js";import{C as Ae}from"./CreateButton.69489aea.js";import{D as Be}from"./DeleteButton.f13880af.js";import{E as Ve}from"./EditButton.f8e95215.js";/* empty css */import{S as H}from"./SubmitButton.fbd40930.js";import{V as De}from"./ViewButton.13bd1aa9.js";/* empty css */import"./vue-cleave.min.5fe175a4.js";import{c as Ie,a as E,V as B}from"./array.e024b95a.js";import{L as z}from"./Loading.585cd43f.js";import"./vue-quill.snow.37e2074d.js";/* empty css */import{F as le}from"./index.d64b81fa.js";import{F as me}from"./index.1361a4ca.js";import{T as ce}from"./index.4b5a3e02.js";import{T as de}from"./index.00e97a5e.js";import{U as fe}from"./UpdateButton.7c791611.js";import"./jspdf.es.min.23081428.js";/* empty css */import{A as ue}from"./ApproverService.ab09ac07.js";import{F as he}from"./FileService.f48416f8.js";import{M as pe}from"./Multiselect.a507ebe0.js";import{F as Oe}from"./index.95c1c484.js";import{F as ge}from"./index.2b90fc01.js";import{C as _e}from"./index.a33bfc5d.js";import{A as Ee}from"./index.554b08cb.js";import{p as ye,j as ve}from"./scr-1.d9aaecca.js";import{P as Me}from"./index.cf4c1c51.js";import{A as Ue}from"./ActionCellRendererApprover.5071b01e.js";import{D as Le}from"./DenyButton.8ee62a2e.js";import{E as Pe}from"./EmployeeScheduleService.1cff5500.js";import{T as U}from"./TravelApprovalService.78be8fc3.js";import{f as je}from"./apiUtils.a5c0e9e2.js";import{F as qe}from"./index.90fa1727.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.47a550d7.js";import"./EmployeeService.9af9860f.js";import"./es.string.replace.52fb44b9.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.ffa9415b.js";import"./index.9cc1ebc8.js";import"./ck-white.4bf441fa.js";import"./CompanyService.3bc3e8e7.js";import"./DealershipService.f84ce80b.js";import"./DepartmentService.f3eac72a.js";import"./DivisionService.ccdd7240.js";import"./EmploymentTypeService.722aa14d.js";import"./GroupService.fd7dccf7.js";import"./JobClassficationService.05b84574.js";import"./JobTitleService.f399f1b2.js";import"./SectionService.4f10ceb0.js";import"./SupportingDocumentService.d68a6798.js";import"./UnitService.5565ff86.js";import"./CitizenshipService.b30ca72f.js";import"./CivilStatusService.4a6966f9.js";import"./ReligionService.b056f0be.js";import"./index.53d9b6cb.js";const He={components:{Alert:Ee,FileType:ge,Fileinput:Oe,FormModal:me,FormGroup:le,TextInput:ce,Textarea:de,SubmitButton:H,UpdateButton:fe,CloseButton:q,Loading:z,Multiselect:pe,Icon:P,Checkbox:_e},data(){return{recommending:"",recommending_img:"",approving:"",approving_img:"",form:{date_from:"",date_to:"",from_time:"",to_time:"",destination:"",description:"",attachment:"",allow_higher_approval:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},fileIcons:{pdf:ye,jpg:ve,default:""}}},methods:{deleteFile(t){this.$swal.fire({title:"Are you sure you want remove the attachment?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.deleteFileAttachment()}),console.log("wawawawa",t)},async deleteFileAttachment(){const t=this.form.id,e=this.form.attachment,i={id:t,attachment:e};await V.removeAttachment(i).then(n=>{n.status==201?(this.$swal.fire({title:"Great!",text:"Attachment successfully deleted.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.form.attachment="",console.log("null dapat",this.form.attachment)):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(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})})},getFileTypeImage(t){if(typeof t=="string"){if(!t)return this.fileIcons.default;const e=t.substring(t.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(t){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await he.Reader2("employee-overtime",t),i;if(t.endsWith(".pdf"))i="application/pdf";else if(t.endsWith(".png"))i="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))i="image/jpeg";else if(t.endsWith(".svg"))i="image/svg+xml";else throw new Error("Unsupported file type");const n=atob(e),o=new Array(n.length);for(let y=0;y<n.length;y++)o[y]=n.charCodeAt(y);const l=new Uint8Array(o),p=new Blob([l],{type:i}),x=URL.createObjectURL(p);window.open(x),this.state.isLoadingPDF=!1},handleMainImageUpload(){const t=event.target.files[0];this.form.attachment=t;const e=new FileReader;e.onload=()=>{t.type.startsWith("image/")?this.form.imageView=e.result:t.type==="application/pdf"?this.form.imageView=this.pdf_file_view:t.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(t),e.readAsDataURL(t)},loadRecord(t){this.resetForm(),this.state.isEdit=!0,this.form=t,this.form.allow_higher_approval=t.allow_higher_approval==1},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date_from:"",date_to:"",from_time:"",to_time:"",destination:"",description:"",attachment:"",allow_higher_approval:"",recommending_id:this.form.recommending_id,approver_id:this.form.approver_id}},async fetchApprover(){this.state.isLoading=!0,await ue.fetchApproverRecords().then(t=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&t.data.map(e=>{this.form.allow_higher_approval?((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==3&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.approving==""&&e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")):((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""))}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&t.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&t.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.state.isLoading=!1}).catch(t=>{console.log(t)})},reload(){return this.$emit("reload")},async saveRecord(){if(this.state.isSaving=!0,this.state.isEdit){this.form.id;let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await V.update(t).then(e=>{e.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(e=>{e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})}else{let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await V.create(t).then(e=>{e.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3}),this.state.showModal=!1,this.state.isSaving=!1,this.resetForm(),this.reload())}).catch(e=>{console.log(e),e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})}},async submitForm(){try{await Ie().shape({date_from:E().required("Date from is required"),date_to:E().required("Date to is required"),from_time:E().required("From time is required"),to_time:E().required("To time 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(t){if(t instanceof B){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},calculateHours(){const t=this.form.from_time,e=this.form.to_time;if(t&&e){const[i,n]=this.form.from_time.split(":").map(Number),[o,l]=this.form.to_time.split(":").map(Number);let p=o-i;p+=(l-n)/60,p<0&&(p+=24),this.form.hours=p}}},mounted(){this.fetchApprover()},watch:{"form.from_time":{handler:"calculateHours",immediate:!0},"form.to_time":{handler:"calculateHours",immediate:!0},"form.allow_higher_approval":{handler:"fetchApprover",immediate:!0}}},ze={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Ge={class:"grid grid-cols-12 gap-4"},We={class:"col-span-6"},Ne={key:0,class:"text-[#ec4899]"},Ye={class:"col-span-6"},Qe={key:0,class:"text-[#ec4899]"},Ze={class:"col-span-6"},Ke={key:0,class:"text-[#ec4899]"},Xe={class:"col-span-6"},Je={key:0,class:"text-[#ec4899]"},$e={class:"col-span-6"},et={class:"col-span-6"},tt={class:"col-span-12"},ot={key:0,class:"text-[#ec4899]"},st={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},it={class:"flex justify-between w-full items-center"},rt={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},nt={class:"col-span-12"},at={class:"grid grid-cols-12 gap-4"},lt={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},mt={class:"flex-shrink-0 mr-4"},ct=["src"],dt={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},ft={class:"text-left"},ut={class:"text-sm font-semibold text-gray-600"},ht={class:"text-lg font-bold text-gray-900"},pt={key:0,class:"text-sm text-gray-900"},gt={key:1,class:"text-sm text-gray-900"},_t={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},yt={class:"flex-shrink-0 mr-4"},vt=["src"],xt={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},wt={class:"text-left"},bt={class:"text-lg font-bold text-gray-900"},Ct={class:"text-sm text-gray-900"},kt={class:"flex gap-2 justify-between"},St={class:"flex items-center cursor-pointer"},Ft=["checked"],Tt={class:"flex gap-2"};function Rt(t,e,i,n,o,l){const p=m("Loading"),x=m("Alert"),y=m("flat-pickr"),_=m("FormGroup"),b=m("Multiselect"),C=m("TextInput"),F=m("Fileinput"),T=m("Card"),w=m("FileType"),k=m("Icon"),R=m("Textarea"),M=m("SubmitButton"),D=m("UpdateButton"),I=m("CloseButton"),O=m("FormModal");return a(),v(O,{title:o.state.isEdit?"Edit OB":"OB Application Form",active:o.state.showModal,onSubmit:t.confirmSubmit,onClose:l.closeModal,themeClass:o.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:u(()=>[o.state.isEdit&&o.state.isLoading?(a(),v(p,{key:0,text:"Fetching record"})):c("",!0),o.state.isLoading?(a(),v(p,{key:1,text:"Fetching Approver"})):c("",!0),o.form.denied_reason?(a(),v(x,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:u(()=>[e[12]||(e[12]=s("span",{class:"font-semibold"},"Denied Reason:",-1)),S(" "+h(o.form.denied_reason),1)]),_:1})):c("",!0),s("div",ze,[s("form",{onSubmit:e[11]||(e[11]=ae((...g)=>t.confirmSubmit&&t.confirmSubmit(...g),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[o.state.isSaving?(a(),v(p,{key:0,text:"Saving record"})):c("",!0),s("div",Ge,[s("div",We,[r(_,{label:"Date From",isRequired:!0},{default:u(()=>[r(y,{modelValue:o.form.date_from,"onUpdate:modelValue":e[0]||(e[0]=g=>o.form.date_from=g),class:"form-control h-[48px]",id:"date_from",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1}),o.errors.date_from?(a(),f("div",Ne,"Date From is required")):c("",!0)]),s("div",Ye,[r(_,{label:"Date To",isRequired:!0},{default:u(()=>[r(y,{modelValue:o.form.date_to,"onUpdate:modelValue":e[1]||(e[1]=g=>o.form.date_to=g),class:"form-control h-[48px]",id:"date_to",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1}),o.errors.date_to?(a(),f("div",Qe,"Date To is required")):c("",!0)]),s("div",Ze,[r(_,{label:"From Time",isRequired:!0},{default:u(()=>[r(y,{class:"form-control h-[48px]",placeholder:"From time",modelValue:o.form.from_time,"onUpdate:modelValue":e[2]||(e[2]=g=>o.form.from_time=g),onChange:l.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1}),o.errors.from_time?(a(),f("div",Ke,"From Time is required")):c("",!0)]),s("div",Xe,[r(_,{label:"To Time",isRequired:!0},{default:u(()=>[r(y,{class:"form-control h-[48px]",placeholder:"To time",modelValue:o.form.to_time,"onUpdate:modelValue":e[3]||(e[3]=g=>o.form.to_time=g),onChange:l.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1}),o.errors.to_time?(a(),f("div",Je,"To Time is required")):c("",!0)]),s("div",$e,[r(_,{label:"Charge To"},{default:u(()=>[r(b,{modelValue:o.form.charge_to,"onUpdate:modelValue":e[4]||(e[4]=g=>o.form.charge_to=g),error:o.errors.charge_to,classInput:"h-12",options:t.companyOptions,loading:t.isCompanyLoading},null,8,["modelValue","error","options","loading"])]),_:1})]),s("div",et,[r(_,{label:"Destination"},{default:u(()=>[r(C,{type:"text",modelValue:o.form.destination,"onUpdate:modelValue":e[5]||(e[5]=g=>o.form.destination=g),error:o.errors.destination,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1})]),s("div",tt,[r(_,{label:"Attachment"},{default:u(()=>[r(T,{title:"File Input Basic"},{default:u(()=>[r(F,{modelValue:o.form.attachment,"onUpdate:modelValue":e[6]||(e[6]=g=>o.form.attachment=g),name:"basic",onChange:l.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),o.errors.attachment?(a(),f("div",ot,h(o.errors.attachment),1)):c("",!0)]),_:1}),typeof o.form.attachment=="string"&&o.form.attachment?(a(),f("div",st,[s("div",it,[s("div",{class:"flex items-center cursor-pointer",onClick:e[7]||(e[7]=g=>l.viewAttachment(o.form.attachment))},[r(w,{image:l.getFileTypeImage(o.form.attachment)},null,8,["image"]),S(" "+h(o.form.attachment),1)]),o.form.status==0?(a(),f("div",rt,[r(k,{icon:"mingcute:delete-2-fill",onClick:e[8]||(e[8]=g=>l.deleteFile(o.form.id))})])):c("",!0)])])):c("",!0)]),_:1})]),s("div",nt,[r(_,{label:"Reason"},{default:u(()=>[r(R,{name:"pn4",placeholder:"Textarea",modelValue:o.form.description,"onUpdate:modelValue":e[9]||(e[9]=g=>o.form.description=g)},null,8,["modelValue"])]),_:1})])]),s("div",at,[s("div",lt,[s("div",mt,[o.recommending_img?(a(),f("img",{key:0,src:o.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,ct)):(a(),f("div",dt," No Image "))]),s("div",ft,[s("div",ut,h(o.form.allow_higher_approval?"Recommending":"Approving"),1),s("div",ht,h(o.recommending),1),o.form.allow_higher_approval?(a(),f("div",pt,h(o.form.recommended_at?"Date: ("+this.$formatDate(o.form.recommended_at)+")":""),1)):(a(),f("div",gt,h(o.form.approved_at?"Date: ("+this.$formatDate(o.form.approved_at)+")":""),1))])]),o.form.allow_higher_approval?(a(),f("div",_t,[s("div",yt,[o.approving_img?(a(),f("img",{key:0,src:o.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,vt)):(a(),f("div",xt," No Image "))]),s("div",wt,[e[13]||(e[13]=s("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),s("div",bt,h(o.approving),1),s("div",Ct,h(o.form.approved_at?"Date: ("+this.$formatDate(o.form.approved_at)+")":""),1)])])):c("",!0)]),s("div",kt,[s("div",null,[s("label",St,[A(s("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:o.form.allow_higher_approval,"onUpdate:modelValue":e[10]||(e[10]=g=>o.form.allow_higher_approval=g)},null,8,Ft),[[L,o.form.allow_higher_approval]]),e[14]||(e[14]=s("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[s("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",stroke:"currentColor","stroke-width":"1"},[s("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"})])],-1)),e[15]||(e[15]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])]),s("div",Tt,[o.state.isEdit?o.form.status===0?(a(),v(D,{key:1,onClick:l.submitForm},null,8,["onClick"])):c("",!0):(a(),v(M,{key:0,onClick:l.submitForm},null,8,["onClick"])),r(I,{onClick:l.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const At=j(He,[["render",Rt],["__scopeId","data-v-a89a5fb5"]]);const Bt={components:{FileType:ge,DenyButton:Le,FormModal:me,FormGroup:le,TextInput:ce,Textarea:de,SubmitButton:H,UpdateButton:fe,CloseButton:q,Loading:z,Multiselect:pe,Icon:P,Checkbox:_e},data(){return{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:"",recommendingOptions:[],approvingOptions:[],recommending:"",approving:"",status:[],companyOptions:[],currentSchedule:[],form:{date_from:"",date_to:"",from_time:"",to_time:"",meal:"",transportation:"",meal_amount:"",transportation_amount:"",destination:"",description:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isLoadingSchedule:!1},fileIcons:{pdf:ye,jpg:ve,default:""}}},methods:{async fetchCurrentEmployeeSchedules(t){this.state.isLoading=!0,await Pe.fetchCurrentScheduleRecord(t).then(e=>{e.status==200&&(this.currentSchedule=e.data,this.state.isLoadingSchedule=!1,console.log("current schedule",e.data))}).catch(e=>{console.log(e),this.currentSchedule=[],this.state.isLoadingSchedule=!1})},getFileTypeImage(t){if(typeof t=="string"){if(!t)return this.fileIcons.default;const e=t.substring(t.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(t){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await he.Reader2("employee-overtime",t),i;if(t.endsWith(".pdf"))i="application/pdf";else if(t.endsWith(".png"))i="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))i="image/jpeg";else if(t.endsWith(".svg"))i="image/svg+xml";else throw new Error("Unsupported file type");const n=atob(e),o=new Array(n.length);for(let y=0;y<n.length;y++)o[y]=n.charCodeAt(y);const l=new Uint8Array(o),p=new Blob([l],{type:i}),x=URL.createObjectURL(p);window.open(x),this.state.isLoadingPDF=!1},handleMainImageUpload(){const t=event.target.files[0];this.form.attachment=t;const e=new FileReader;e.onload=()=>{t.type.startsWith("image/")?this.form.imageView=e.result:t.type==="application/pdf"?this.form.imageView=this.pdf_file_view:t.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(t),e.readAsDataURL(t)},async loadRecord(t){this.resetForm(),this.form=t,await this.fetchCurrentEmployeeSchedules(t),this.form.meal=t.meal==1,this.form.transportation=t.transportation==1,this.form.date_from=new Date(t.date_from).toLocaleDateString("en-CA").split("T")[0],this.form.date_to=new Date(t.date_to).toLocaleDateString("en-CA").split("T")[0],this.currentRecommendingId=t.recommending?t.recommending[0].employee_id:"",this.currentApprovingId=t.approving?t.approving[0].employee_id:"",this.recommending=t.recommending?t.recommending[0].firstname+" "+t.recommending[0].lastname:"",this.approving=t.approving?t.approving[0].firstname+" "+t.approving[0].lastname:"",this.currentRecommendingId==this.currentEmployeeId&&this.form.status<1?this.btnTitle="Submit For Approval":this.currentApprovingId==this.currentEmployeeId&&(this.btnTitle="Approve"),this.currentClassificationId>=3&&await ue.fetchEmployeeApprover(t.employee_id).then(e=>{if(e.status==200)this.recommendingOptions=e.data.map((i,n)=>({value:i.employee_id,label:i.firstname+" "+i.lastname})),this.approvingOptions=e.data.filter(i=>i.classification_id>=3).map((i,n)=>({value:i.employee_id,label:i.firstname+" "+i.lastname}));else throw new Error("Failed to fetch employee approvers")})},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date_from:"",date_to:"",from_time:"",to_time:"",meal:"",transportation:"",meal_amount:"",transportation_amount:"",destination:"",description:"",attachment:"",recommending_id:"",approver_id:""},this.currentSchedule=[]},reload(){return this.state.showModal=!1,this.state.isSaving=!1,this.$emit("reload")},async updateApproverRecord(){this.state.isSaving=!0;const t=this.form.id;this.state.isSaving=!1;let e={recommending_id:this.form.recommending_id,approver_id:this.form.approver_id};await U.updateApprover(t,e).then(i=>{i.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(i=>{i.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:i.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},async saveRecord(){this.state.isSaving=!0;const t={status:this.status,meal:this.form.meal,transportation:this.form.transportation,meal_amount:this.form.meal_amount,transportation_amount:this.form.transportation_amount};console.log(t);const e=this.form.id;await U.update(e,t).then(i=>{i.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(i=>{i.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:i.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.recommending_id==this.currentEmployeeId&&(this.status={status:1}),this.form.approver_id==this.currentEmployeeId&&(this.status={status:2});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(t=>{t.value&&this.saveRecord()})}catch(t){if(t instanceof B){const e={};t.inner.forEach(i=>{e[i.path]=i.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(t=>{t.value&&this.updateApproverRecord()})}catch(t){if(t instanceof B){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},async denyForm(){this.status={status:99};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 t=document.getElementById("swal-input").value;return t?this.denied_reason=t:(this.$swal.showValidationMessage("The reason field is required"),!1)}}).then(t=>{this.status={status:99,denied_reason:this.denied_reason},t.value&&this.saveRecord()})}catch(t){if(t instanceof B){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},calculateHours(){const t=this.form.from_time,e=this.form.to_time;if(t&&e){const[i,n]=this.form.from_time.split(":").map(Number),[o,l]=this.form.to_time.split(":").map(Number);let p=o-i;p+=(l-n)/60,p<0&&(p+=24),this.form.hours=p}},async ReceiveByHr(t){try{if(t==99){const e=await this.$swal.fire({title:"State the Reason for Denying this Request",input:"textarea",inputPlaceholder:"Enter your reason here...",inputAttributes:{"aria-label":"Reason for denial"},showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Submit",cancelButtonText:"Cancel",preConfirm:i=>i||(this.$swal.showValidationMessage("Reason is required!"),!1)});e.isConfirmed&&e.value&&(console.log("Reason for denial:",e.value),this.updateRecordByHR(t,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(t))})}catch(e){if(e instanceof B){const i={};e.inner.forEach(n=>{i[n.path]=n.message}),this.errors=i}}},async updateRecordByHR(t,e=null){this.state.isSaving=!0;const i=this.form.id;let o={status:t,reason:e,meal:this.form.meal,meal_amount:this.form.meal_amount,transportation:this.form.transportation,transportation_amount:this.form.transportation_amount};await U.hrValidation(i,o).then(l=>{l.status==201?(console.log("response"),console.log(l),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.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}),this.state.isSaving=!1})},async fetchCompanyRecords(){try{this.state.isCompanyLoading=!0,this.companyOptions=await je()}catch(t){console.error("Failed to fetch company data:",t)}finally{this.state.isCompanyLoading=!1}}},mounted(){this.fetchCompanyRecords()},watch:{"form.from_time":{handler:"calculateHours",immediate:!0},"form.to_time":{handler:"calculateHours",immediate:!0}}},Vt={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Dt={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"},It={class:"text-red-600 dark:text-red-400 text-sm"},Ot={key:1,class:"text-slate-600 dark:text-slate-400 text-sm font-normal mb-6"},Et={class:"flex items-center gap-2 mb-2",title:"Current Schedule"},Mt={key:0},Ut={key:1},Lt={class:"flex items-center gap-2",title:"Time In/Out"},Pt={key:0},jt={class:"grid grid-cols-12 gap-4"},qt={class:"col-span-6"},Ht={key:0,class:"text-[#ec4899]"},zt={class:"col-span-6"},Gt={key:0,class:"text-[#ec4899]"},Wt={class:"col-span-6"},Nt={class:"col-span-6"},Yt={class:"flex items-center gap-4 col-span-6"},Qt={class:"flex justify-between items-center w-full"},Zt={class:"flex items-center cursor-pointer"},Kt=["checked","disabled"],Xt={key:0},Jt={class:"flex items-center gap-4 col-span-6"},$t={class:"flex justify-between items-center w-full"},eo={class:"flex items-center cursor-pointer"},to=["checked","disabled"],oo={key:0},so={class:"col-span-6"},io={key:0,class:"text-red-400"},ro={class:"col-span-6"},no={class:"col-span-12"},ao={class:"col-span-12"},lo={key:1},mo={class:"grid grid-cols-12 justify-center items-center"},co={class:"col-span-8 flex justify-between items-center gap-4"},fo={class:"col-span-6 flex justify-center items-center gap-4"},uo={class:"font-bold"},ho={class:"col-span-6 flex justify-center items-center gap-4"},po={class:"font-bold"},go={key:2},_o={class:"grid grid-cols-12 gap-4"},yo={class:"col-span-6"},vo={class:"relative"},xo={class:"col-span-6"},wo={class:"relative"},bo={class:"flex gap-1 justify-end pt-8"},Co={key:0,class:"flex gap-1 justify-end"},ko={key:1,class:"flex gap-1 justify-end"},So={class:"flex gap-1 justify-end"};function Fo(t,e,i,n,o,l){const p=m("Loading"),x=m("Icon"),y=m("flat-pickr"),_=m("FormGroup"),b=m("TextInput"),C=m("Multiselect"),F=m("Textarea"),T=m("FileType"),w=m("UpdateButton"),k=m("DenyButton"),R=m("CloseButton"),M=m("FormModal");return a(),v(M,{title:"View Record",active:o.state.showModal,sideTitle:this.form.status==0?"for recommendation":this.form.status==1?"for approval":this.form.status==2&&this.form.validated==1?"Approved & Validated":this.form.status==2&&this.form.validated==99?"Denied":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==1?"success":this.form.status==2&&this.form.validated==99?"danger":this.form.status==2?"purple":this.form.status==99?"danger":"",onSubmit:t.confirmSubmit,onClose:l.closeModal,themeClass:"bg-gray-800",sizeClass:"lg:w-2/4"},{default:u(()=>{var D,I,O,g,G,W,N,Y,Q,Z,K,X,J,$,ee,te,oe,se,ie,re;return[o.state.isEdit&&o.state.isLoading?(a(),v(p,{key:0,text:"Fetching record"})):c("",!0),s("div",Vt,[this.form.status==2&&this.form.validated==99?(a(),f("div",Dt,[e[17]||(e[17]=s("h3",{class:"text-red-700 dark:text-red-300 font-semibold mb-1 text-sm"}," Denied Reason : ",-1)),s("p",It,h(this.form.deferred_reason),1)])):c("",!0),o.state.isScheduleLoading?c("",!0):(a(),f("div",Ot,[s("div",Et,[r(x,{icon:"uim:schedule",class:"text-slate-500 text-3xl"}),s("span",null,[((I=(D=o.currentSchedule)==null?void 0:D.schedule)==null?void 0:I.cws_day)!=null?(a(),f("div",Mt," Regular Day: "+h(this.$formatTime((g=(O=o.currentSchedule)==null?void 0:O.schedule)==null?void 0:g.from_time))+" - "+h(this.$formatTime(o.currentSchedule.schedule.to_time))+" Dayoff - "+h(o.currentSchedule.schedule.day_off)+" CWS Day: "+h((W=(G=o.currentSchedule)==null?void 0:G.schedule)==null?void 0:W.cws_day)+" ("+h(this.$formatTime(o.currentSchedule.schedule.cws_from_time))+" - "+h(this.$formatTime(o.currentSchedule.schedule.cws_to_time))+") ",1)):(a(),f("div",Ut,h(this.$formatTime((Y=(N=o.currentSchedule)==null?void 0:N.schedule)==null?void 0:Y.from_time))+" - "+h(this.$formatTime((Z=(Q=o.currentSchedule)==null?void 0:Q.schedule)==null?void 0:Z.to_time))+". Dayoff - "+h((X=(K=o.currentSchedule)==null?void 0:K.schedule)==null?void 0:X.day_off),1))])]),s("div",Lt,[r(x,{icon:"ic:twotone-schedule",class:"text-slate-500 text-3xl"}),s("span",null,[(($=(J=o.currentSchedule)==null?void 0:J.timelogs)==null?void 0:$.length)!=0?(a(),f("div",Pt,[s("div",null,h((te=(ee=o.currentSchedule)==null?void 0:ee.timelogs)!=null&&te.time_in?this.$formatTime((se=(oe=o.currentSchedule)==null?void 0:oe.timelogs)==null?void 0:se.time_in):"No Time In")+" - "+h((re=(ie=o.currentSchedule)==null?void 0:ie.timelogs)!=null&&re.time_out?this.$formatTime(o.currentSchedule.timelogs.time_out):"No Time Out"),1)])):c("",!0)])])])),s("form",{onSubmit:e[16]||(e[16]=ae((...d)=>t.confirmSubmit&&t.confirmSubmit(...d),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[o.state.isSaving?(a(),v(p,{key:0,text:"Saving record"})):c("",!0),s("div",jt,[s("div",qt,[r(_,{label:"Date From",isRequired:!0},{default:u(()=>[r(y,{modelValue:o.form.date_from,"onUpdate:modelValue":e[0]||(e[0]=d=>o.form.date_from=d),class:"form-control h-[48px]",id:"date_from",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1}),o.errors.date_from?(a(),f("div",Ht," Date From is required ")):c("",!0)]),s("div",zt,[r(_,{label:"Date To",isRequired:!0},{default:u(()=>[r(y,{modelValue:o.form.date_to,"onUpdate:modelValue":e[1]||(e[1]=d=>o.form.date_to=d),class:"form-control h-[48px]",id:"date_to",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1}),o.errors.date_to?(a(),f("div",Gt," Date To is required ")):c("",!0)]),s("div",Wt,[r(_,{label:"From Time",isRequired:!0},{default:u(()=>[r(y,{class:"form-control h-[48px]",placeholder:"From time",modelValue:o.form.from_time,"onUpdate:modelValue":e[2]||(e[2]=d=>o.form.from_time=d),config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue"])]),_:1})]),s("div",Nt,[r(_,{label:"To Time",isRequired:!0},{default:u(()=>[r(y,{class:"form-control h-[48px]",placeholder:"To time",modelValue:o.form.to_time,"onUpdate:modelValue":e[3]||(e[3]=d=>o.form.to_time=d),onChange:l.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),s("div",Yt,[s("div",Qt,[s("div",null,[s("label",Zt,[A(s("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:o.form.meal,"onUpdate:modelValue":e[4]||(e[4]=d=>o.form.meal=d),disabled:o.form.status!=2},null,8,Kt),[[L,o.form.meal]]),e[18]||(e[18]=s("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[s("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",stroke:"currentColor","stroke-width":"1"},[s("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"})])],-1)),e[19]||(e[19]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Meal",-1))])]),o.form.status==2&&(this.form.validated==0||this.form.validated>0)?A((a(),f("div",Xt,[r(_,{label:"Amount"},{default:u(()=>[r(b,{type:"text",modelValue:o.form.meal_amount,"onUpdate:modelValue":e[5]||(e[5]=d=>o.form.meal_amount=d),disabled:this.form.validated>0,classInput:"h-12"},null,8,["modelValue","disabled"])]),_:1})],512)),[[ne,o.form.meal]]):c("",!0)])]),s("div",Jt,[s("div",$t,[s("div",null,[s("label",eo,[A(s("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:o.form.transportation,"onUpdate:modelValue":e[6]||(e[6]=d=>o.form.transportation=d),disabled:o.form.status!=2},null,8,to),[[L,o.form.transportation]]),e[20]||(e[20]=s("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[s("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",stroke:"currentColor","stroke-width":"1"},[s("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"})])],-1)),e[21]||(e[21]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Transportation",-1))])]),o.form.status==2&&(this.form.validated==0||this.form.validated>0)?A((a(),f("div",oo,[r(_,{label:"Amount"},{default:u(()=>[r(b,{type:"text",modelValue:o.form.transportation_amount,"onUpdate:modelValue":e[7]||(e[7]=d=>o.form.transportation_amount=d),disabled:this.form.validated>0,classInput:"h-12"},null,8,["modelValue","disabled"])]),_:1})],512)),[[ne,o.form.transportation]]):c("",!0)])]),s("div",so,[r(_,{label:"Charge To"},{default:u(()=>[r(C,{modelValue:o.form.charge_to,"onUpdate:modelValue":e[8]||(e[8]=d=>o.form.charge_to=d),error:o.errors.charge_to,classInput:"h-[48px]",options:o.companyOptions,loading:t.isCompanyLoading,searchable:!0,disabled:!0},null,8,["modelValue","error","options","loading"])]),_:1}),o.errors.charge_to?(a(),f("span",io," Field is required ")):c("",!0)]),s("div",ro,[r(_,{label:"Destination"},{default:u(()=>[r(b,{type:"text",modelValue:o.form.destination,"onUpdate:modelValue":e[9]||(e[9]=d=>o.form.destination=d),error:o.errors.destination,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1})]),s("div",no,[r(_,{label:"Reason"},{default:u(()=>[r(F,{name:"pn4",placeholder:"Textarea",modelValue:o.form.description,"onUpdate:modelValue":e[10]||(e[10]=d=>o.form.description=d)},null,8,["modelValue"])]),_:1})])]),s("div",ao,[r(_,{label:"Attachment"},{default:u(()=>[typeof o.form.attachment=="string"?(a(),f("div",{key:0,class:"flex items-center gap-2 mt-2 cursor-pointer",onClick:e[11]||(e[11]=d=>l.viewAttachment(o.form.attachment))},[r(T,{image:l.getFileTypeImage(o.form.attachment)},null,8,["image"]),S(" "+h(o.form.attachment),1)])):c("",!0)]),_:1})]),o.currentClassificationId<=2?(a(),f("div",lo,[s("div",mo,[s("div",co,[s("div",fo,[e[22]||(e[22]=S(" Recommending: ")),s("p",uo,h(o.recommending),1)]),s("div",ho,[e[23]||(e[23]=S(" Approving: ")),s("p",po,h(o.approving),1)])])])])):(a(),f("div",go,[s("div",_o,[s("div",yo,[r(_,{label:"Recommending"},{default:u(()=>[s("div",vo,[r(C,{modelValue:o.form.recommending_id,"onUpdate:modelValue":e[12]||(e[12]=d=>o.form.recommending_id=d),"close-on-select":!0,searchable:!0,id:"recommending_id",options:o.recommendingOptions},null,8,["modelValue","options"])])]),_:1})]),s("div",xo,[r(_,{label:"Approver"},{default:u(()=>[s("div",wo,[r(C,{modelValue:o.form.approver_id,"onUpdate:modelValue":e[13]||(e[13]=d=>o.form.approver_id=d),"close-on-select":!0,searchable:!0,id:"approver_id",options:o.approvingOptions},null,8,["modelValue","options"])])]),_:1})])])])),s("div",bo,[this.form.status==0&&o.currentRecommendingId==o.currentEmployeeId||o.currentApprovingId==o.currentEmployeeId&&this.form.status==1&&o.currentApprovingId==this.form.approver_id||this.form.approver_id==this.form.recommending_id&&o.currentApprovingId==this.form.approver_id&&o.currentEmployeeId==this.form.approver_id?(a(),f("div",Co,[this.form.status<=1?(a(),v(w,{key:0,onClick:l.submitForm,text:o.btnTitle},null,8,["onClick","text"])):c("",!0),this.form.status<=1?(a(),v(k,{key:1,onClick:l.denyForm,text:"Deny"},null,8,["onClick"])):c("",!0)])):this.form.status==0&&o.currentApprovingId==o.currentEmployeeId||o.currentApprovingId!=this.form.approver_id?(a(),f("div",ko,[this.form.status<=1?(a(),v(w,{key:0,onClick:l.updateApproverForm,text:"Update Approver"},null,8,["onClick"])):c("",!0)])):c("",!0),s("div",So,[this.form.status===2&&this.form.validated==0?(a(),v(w,{key:0,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]=d=>l.ReceiveByHr(1)),text:"Receive"})):c("",!0),this.form.status===2&&this.form.validated==0?(a(),v(w,{key:1,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]=d=>l.ReceiveByHr(99)),text:"Deny"})):c("",!0),r(R,{onClick:l.closeModal},null,8,["onClick"])])])],32)])]}),_:1},8,["active","sideTitle","badgeColor","onSubmit","onClose"])}const To=j(Bt,[["render",Fo],["__scopeId","data-v-25fe9f2e"]]);const Ro={mixins:[xe],components:{FilterTimekeeping:qe,ActionCellRenderer:Re,ActionCellRendererApprover:Ue,AgGridVue:Te,Pagination:Me,Card:be,Button:Ce,Badge:ke,Layout:we,Icon:P,CreateButton:Ae,SubmitButton:H,CloseButton:q,EditButton:Ve,DeleteButton:Be,ViewButton:De,Form:At,InputGroup:Se,Loading:z,View:To},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50,100,200],colDefs:[{field:"#",flex:1},{field:"employee_id",filter:!0,floatingFilter:!0,flex:1},{field:"name",filter:!0,floatingFilter:!0,flex:2},{field:"date coverage",filter:!0,floatingFilter:!0,flex:1.5},{field:"time coverage",filter:!0,floatingFilter:!0,flex:2},{field:"destination",filter:!0,floatingFilter:!0},{field:"date created",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,flex:1,cellRenderer:t=>{const e=t.value,i=t.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>':i===1&&e===2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-green-600 px-4">Approved & Validated </div>':i===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},code:"listOfOvertimes"}}],breadcrumbs:[{text:"Home",href:"/"},{text:"Timekeeping",href:"/attendance/employee-ob"},{text:"OB Application",active:!0}],statistics:[{title:"OB Days Rendered",subtitle:"For this month",count:"0",bg:"bg-info-500",text:"text-info-500",icon:"heroicons-outline:menu-alt-1"},{title:"Average OB Days",subtitle:"For this month",count:"0",bg:"bg-warning-500",text:"text-warning-500",icon:"heroicons-outline:chart-pie"},{title:"Total OB Days",subtitle:"For this Year",count:"0",bg:"bg-purple-500",text:"text-purple-500",icon:"fa6-solid:chart-bar"}],columns:[{label:"#",field:"#"},{label:"Date",field:"created_at",formatFn:t=>this.formatDate(t)},{label:"From Time",field:"from_time",formatFn:t=>this.formatTime(t)},{label:"To Time",field:"to_time",formatFn:t=>this.formatTime(t)},{label:"Destination",field:"destination"},{label:"Remarks",field:"description"},{label:"Status",field:"status"},{label:"Action",field:"action"}],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],items:[],totalItems:0,searchQuery:null,serverOptions:{page:1,rowsPerPage:10,sortBy:"created_at",sortType:"asc"},state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:Fe.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{applyFilters(t){this.fetchRecords(t)},onGridReady(t){this.gridApi=t.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(t=>t.field!=="actions").map(t=>t.field)}):console.error("Grid API is not ready.")},formatTime(t){let[e,i]=t.split(":");e=parseInt(e);const n=e>=12;return e=e%12||12,`${e}:${i} ${n?"PM":"AM"}`},formatDate(t){const e=new Date(t),i=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),n=new Date(i.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),o=n.getFullYear(),l=String(n.getMonth()+1).padStart(2,"0"),p=String(n.getDate()).padStart(2,"0");return`${o}-${l}-${p}`},async fetchRecords(t={}){this.state.isLoading=!0,await V.fetchRecordList({dealership:this.$store.userSettings.activeDealership,...t}).then(e=>{console.log("response");let i=e.data.data.data;this.items=i,this.items=i.map((n,o)=>({...n,"#":o+1,employee_id:n.employee_id,name:n.employee.lastname+", "+n.employee.firstname,"date coverage":n.date_from===n.date_to?this.$formatDate(n.date_from):this.$formatDate(n.date_from)+" - "+this.$formatDate(n.date_to),"time coverage":this.$formatTime(n.from_time)+" - "+this.$formatTime(n.to_time),destination:n.destination,"date created":this.$formatDate(n.created_at),status:n.status,validated_at:n.validated_at,validated_by:n.validated_by,validated:n.validated,deferred_reason:n.deferred_reason}))}).finally(()=>{this.state.isLoading=!1})},reload(){this.$emit("reload")},handlePageChange(t){console.log(t),console.log(this.serverOptions.page),this.serverOptions.page!=t&&(this.serverOptions.page=t)},handlePerPageChange(t){this.serverOptions.page=1,this.serverOptions.rowsPerPage=t},onSortChange(t){console.log(t),t[0].type!="none"&&(this.serverOptions.sortBy=t[0].field,this.serverOptions.sortType=t[0].type)},async deleteRecord(t){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=>{console.log(e.value),e.value&&(this.state.isDeleting=!0,V.remove(t).then(i=>{i.status==200&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.fetchRecords())}))}).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.fetchRecords(),this.state.isDeleting=!1})},createRecord(){this.$refs.form.resetForm(),this.$refs.form.state.showModal=!0},editRecord(t){console.log(t),this.$refs.form.resetForm(),this.$refs.form.loadRecord(t),this.$refs.form.state.showModal=!0},viewRecord(t){console.log(t),this.$refs.view.resetForm(),this.$refs.view.loadRecord(t),this.$refs.view.state.showModal=!0},handlePageChange(t){console.log(t),console.log(this.serverOptions.page),this.serverOptions.page!=t&&(this.serverOptions.page=t)},handlePerPageChange(t){this.serverOptions.page=1,this.serverOptions.rowsPerPage=t}},mounted(){this.fetchRecords()}},Ao={class:"space-y-10 mt-4"},Bo={class:"flex items-center justify-between"},Vo={class:"text-2xl font-bold text-slate-900 dark:text-white"},Do={class:"relative"},Io={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},Oo={class:"flex items-center justify-center gap-4 text-gray-900"},Eo={class:"flex items-center gap-4"},Mo={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function Uo(t,e,i,n,o,l){const p=m("FilterTimekeeping"),x=m("Icon"),y=m("Button"),_=m("ag-grid-vue"),b=m("Card"),C=m("Loading"),F=m("Form"),T=m("View"),w=m("Layout");return a(),v(w,{breadcrumbs:o.breadcrumbs},{default:u(()=>[s("div",Ao,[r(b,{title:"OB Applications"},{default:u(()=>{var k;return[s("div",Bo,[s("h2",Vo,h(t.title),1)]),s("div",Do,[s("div",Io,[s("div",Oo,h(((k=this.$store.userSettings.dealershipAccess.find(R=>R.id==this.$store.userSettings.activeDealership))==null?void 0:k.name)+" - REQUESTED OB"||"REQUESTED OB"),1),s("div",Eo,[r(p,{onFilterChanged:l.applyFilters},null,8,["onFilterChanged"]),r(y,{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:l.exportToCsv},{default:u(()=>[e[2]||(e[2]=s("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),s("span",Mo,[r(x,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[1]||(e[1]=S(" Export to CSV "))])]),_:1},8,["onClick"])])])]),r(_,{ref:"agGrid",rowData:o.items,columnDefs:o.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:o.paginationPageSize,paginationPageSizeSelector:o.paginationPageSizeSelector,onGridReady:l.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])]}),_:1}),o.state.isLoading?(a(),v(C,{key:0,text:"Fetching records"})):c("",!0),r(F,{onCloseModal:e[0]||(e[0]=k=>o.state.showModal=!1),ref:"form",onReload:l.fetchRecords},null,8,["onReload"]),r(T,{onCloseModal:t.closeModal,ref:"view",onReload:l.fetchRecords},null,8,["onCloseModal","onReload"])])]),_:1},8,["breadcrumbs"])}const $s=j(Ro,[["render",Uo],["__scopeId","data-v-f279b087"]]);export{$s as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.15 |
proxy
|
phpinfo
|
Settings