File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.3ac3396c.js
Back
import{w as ie,L as re}from"./index.2f12c00b.js";import{C as ne}from"./index.73a721da.js";import{B as ae}from"./index.d5f9070d.js";import{B as le}from"./index.dd345587.js";import{I as M}from"./index.0cc90e2a.js";import{I as me}from"./index.082b43f0.js";import"./lodash.73665e2b.js";import{_ as L,q as de,A as ce,r as c,o as m,c as w,w as h,j as p,d as s,f as k,t as y,k as j,b as u,e as r,p as O,s as I,m as fe,h as B,F as ue}from"./index.6f826883.js";import{E as S}from"./EmployeeOvertimeService.9e1f8f6d.js";import{A as he}from"./main.esm.720326be.js";import{A as pe}from"./ActionCellRenderer.b841a599.js";import{F as ge}from"./index.c15e8af0.js";import{C as E}from"./CloseButton.d6e96b7d.js";import{C as _e}from"./CreateButton.2b14c008.js";import{D as ye}from"./DeleteButton.1177ae51.js";import{E as ve}from"./EditButton.234ef2e8.js";/* empty css */import{S as H}from"./SubmitButton.4efa94a6.js";import{V as we}from"./ViewButton.a34ed5c7.js";/* empty css */import"./vue-cleave.min.2c699dc6.js";import{c as xe,a as T,V as R}from"./array.b1e0d30e.js";import{L as U}from"./Loading.a7caf7be.js";import"./vue-quill.snow.8a0635dc.js";/* empty css */import{U as P}from"./UpdateButton.feaaf9dc.js";import"./jspdf.es.min.9b897a33.js";/* empty css */import{A as q}from"./ApproverService.dbafd287.js";import{E as be}from"./EmployeeScheduleService.69d04718.js";import{F as z}from"./FileService.12c44bcb.js";import{F as G}from"./index.8944847c.js";import{F as N}from"./index.30a5caa1.js";import{T as W}from"./index.8e02d38d.js";import{M as Y}from"./Multiselect.30f38e61.js";import{F as ke}from"./index.da2168dc.js";import{F as Z}from"./index.025ace30.js";import{A as Ce}from"./index.e9da77bf.js";import{C as K}from"./index.0abb9ccc.js";import{T as J}from"./index.0885aab1.js";import{f as Q}from"./apiUtils.c9d55e6b.js";import{p as X,j as $}from"./scr-1.d9aaecca.js";import{P as Fe}from"./index.c8e81a7d.js";import{D as Ae}from"./DenyButton.8d66bccd.js";import{O as D}from"./OvertimeApprovalService.0cb75be7.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.75ebe11b.js";import"./EmployeeService.b8be485c.js";import"./es.string.replace.f9ff181c.js";import"./index.a538f310.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.feec42bc.js";import"./index.58a64031.js";import"./ck-white.4bf441fa.js";import"./CompanyService.1b97fd33.js";import"./DealershipService.5b263c9d.js";import"./DepartmentService.b2fb95e4.js";import"./DivisionService.8915c98c.js";import"./EmploymentTypeService.ceebba18.js";import"./GroupService.f006f84b.js";import"./JobClassficationService.2ba440de.js";import"./JobTitleService.bab1c32f.js";import"./SectionService.274b84ab.js";import"./SupportingDocumentService.234d6f89.js";import"./UnitService.d49084c2.js";import"./CitizenshipService.1dbb0db7.js";import"./CivilStatusService.4ad3e9ec.js";import"./ReligionService.ac7b7e5b.js";const Te={components:{Alert:Ce,FileType:Z,Fileinput:ke,FormModal:N,FormGroup:G,TextInput:W,Textarea:J,SubmitButton:H,UpdateButton:P,CloseButton:E,Loading:U,Multiselect:Y,Icon:M,Checkbox:K},data(){return{companyOptions:[],recommending:"",recommending_img:"",approving:"",approving_img:"",form:{date_from:"",date_to:"",from_time:"",to_time:"",allow_higher_approval:"",hours:"",charge_to:"",meal:!1,transportation:!1,description:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isCompanyLoading:!1,hasSchedule:!1,isDayOff:!1,isHoliday:!1},fileIcons:{pdf:X,jpg:$,default:""}}},methods:{async fetchEmployeeSchedule(){await be.fetchRecord(1).then(t=>{t.status==200&&(console.log("schedule",t.data),t.data&&(this.state.hasSchedule=!0))}).catch(t=>{console.log(t)})},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 S.removeAttachment(i).then(a=>{a.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(a=>{a.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:a.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 z.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 a=atob(e),o=new Array(a.length);for(let f=0;f<a.length;f++)o[f]=a.charCodeAt(f);const l=new Uint8Array(o),n=new Blob([l],{type:i}),_=URL.createObjectURL(n);window.open(_),this.state.isLoadingPDF=!1},reload(){return this.$emit("reload")},async fetchCompanyRecords(){try{this.state.isCompanyLoading=!0,this.companyOptions=await Q()}catch(t){console.error("Failed to fetch company data:",t)}finally{this.state.isCompanyLoading=!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.meal=t.meal==1,this.form.transportation=t.transportation==1},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date_from:"",date_to:"",from_time:"",to_time:"",allow_higher_approval:"",charge_to:"",hours:"",meal:!1,transportation:!1,description:"",attachment:"",recommending_id:this.form.recommending_id,approver_id:this.form.approver_id}},async fetchApprover(){await q.fetchApproverRecords().then(t=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&t.data.map(e=>{this.form.allow_higher_approval||this.form.hours>3||!this.state.isDayOff||!this.form.isHoliday?((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||"")})}).catch(t=>{console.log(t)})},async saveRecord(){if(this.state.isEdit){this.form.id;let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await S.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.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})}else{this.state.isSaving=!0;let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await S.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 xe().shape({date_from:T().required("Date from is required"),date_to:T().required("Date to is required"),from_time:T().required("From time is required"),to_time:T().required("To time is required"),description:T().required("Description 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 R){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}this.state.isSaving=!1}},calculateHours(){const t=this.form.from_time,e=this.form.to_time;if(t&&e){const[i,a]=this.form.from_time.split(":").map(Number),[o,l]=this.form.to_time.split(":").map(Number);let n=o-i;n+=(l-a)/60,n<0&&(n+=24),this.form.hours=n,this.form.meal=n>=3,console.log("toHours",o),console.log("toTIme",e),this.form.transportation=o>=22||o>0&&o<=6}},async checkIfWfh(){if(this.state.isLoading=!0,this.form.date_from!=""&&this.state.hasSchedule){const t=de(this.form.date_from);let e={start_date:t,end_date:t};const i=await ce.fetchRecords(e);this.holidayList=i.data.holiday?i.data.holiday:[],this.scheduleList=i.data.schedule?i.data.schedule:[],this.holidayList.length!=0?this.state.isHoliday=!0:this.state.isHoliday=!1,this.scheduleList.filter(a=>a.date===this.form.date_from).map(a=>{a.title.includes("Day Off")?this.state.isDayOff=!0:this.state.isDayOff=!1,a.title.includes("WFH")?this.errors.wfhNotAllowed=!0:this.errors.wfhNotAllowed=!1}),this.state.isLoading=!1}else this.state.isLoading=!1}},mounted(){this.fetchEmployeeSchedule(),this.fetchCompanyRecords(),this.fetchApprover()},watch:{"form.date_from":{handler(){this.checkIfWfh()},immediate:!0},"form.hours"(t){t>=3?this.form.meal=!0:this.form.meal=!1,console.log(this.form.meal)},"form.from_time":{handler:"calculateHours",immediate:!0},"form.to_time":{handler:"calculateHours",immediate:!0}}},Re={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Se={key:1,class:"text-red-400 italic items-center"},Ve={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-6"},De={key:0,class:"text-[#ec4899]"},Oe={key:1,class:"text-[#ec4899]"},Ie={key:0,class:"text-[#ec4899]"},Be={key:0,class:"text-[#ec4899]"},Me={key:0,class:"text-[#ec4899]"},Le={key:0,class:"flex items-center gap-4"},Ee={class:"flex items-center cursor-pointer"},He={key:1,class:"flex items-center gap-4"},Ue={class:"flex items-center cursor-pointer"},je={class:"grid grid-cols-1"},Pe={class:"grid grid-cols-1"},qe={key:0,class:"text-[#ec4899]"},ze={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},Ge={class:"flex justify-between w-full items-center"},Ne={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},We={class:"grid grid-cols-12 gap-4"},Ye={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},Ze={class:"flex-shrink-0 mr-4"},Ke=["src"],Je={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Qe={class:"text-left"},Xe={class:"text-sm font-semibold text-gray-600"},$e={class:"text-lg font-bold text-gray-900"},et={key:0,class:"text-sm text-gray-900"},tt={key:1,class:"text-sm text-gray-900"},ot={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},st={class:"flex-shrink-0 mr-4"},it=["src"],rt={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},nt={class:"text-left"},at={class:"text-lg font-bold text-gray-900"},lt={class:"text-sm text-gray-900"},mt={class:"flex justify-between gap-2"},dt={key:0,class:"flex items-center cursor-pointer"},ct=["checked"];function ft(t,e,i,a,o,l){const n=c("Loading"),_=c("Alert"),f=c("flat-pickr"),v=c("FormGroup"),x=c("TextInput"),C=c("Multiselect"),b=c("Icon"),F=c("Textarea"),A=c("Fileinput"),d=c("Card"),V=c("FileType"),ee=c("SubmitButton"),te=c("UpdateButton"),oe=c("CloseButton"),se=c("FormModal");return m(),w(se,{title:o.form.status!==0?"Overtime Application Form":o.state.isEdit?"Edit Overtime":"Overtime Application Form",active:o.state.showModal,onSubmit:t.confirmSubmit,onClose:l.closeModal,themeClass:o.state.isEdit&&o.form.status==0?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:h(()=>[o.state.isEdit&&o.state.isLoading?(m(),w(n,{key:0,text:"Fetching record"})):p("",!0),o.state.isLoading?(m(),w(n,{key:1,text:"Fetching record"})):p("",!0),o.form.denied_reason?(m(),w(_,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:h(()=>[e[12]||(e[12]=s("span",{class:"font-semibold"},"Denied Reason:",-1)),k(" "+y(o.form.denied_reason),1)]),_:1})):p("",!0),s("div",Re,[s("form",{onSubmit:e[11]||(e[11]=j((...g)=>t.confirmSubmit&&t.confirmSubmit(...g),["prevent"])),class:"space-y-6",enctype:"multipart/form-data"},[o.state.isSaving?(m(),w(n,{key:0,text:"Saving record"})):p("",!0),o.state.hasSchedule?p("",!0):(m(),u("div",Se," * Schedule is required ")),s("div",Ve,[s("div",null,[r(v,{label:"From Date",isRequired:!0},{default:h(()=>[r(f,{modelValue:o.form.date_from,"onUpdate:modelValue":e[0]||(e[0]=g=>o.form.date_from=g),class:"form-control h-12",id:"date_from",placeholder:"yyyy, dd M",disabled:o.form.status==2||o.form.status==1},null,8,["modelValue","disabled"])]),_:1}),o.errors.date_from?(m(),u("div",De," Date From is required ")):p("",!0),o.errors.wfhNotAllowed?(m(),u("div",Oe," Overtime is not allowed on WFH Schedule ")):p("",!0)]),s("div",null,[r(v,{label:"To Date",isRequired:!0},{default:h(()=>[r(f,{modelValue:o.form.date_to,"onUpdate:modelValue":e[1]||(e[1]=g=>o.form.date_to=g),class:"form-control h-12",id:"date_to",placeholder:"yyyy, dd M",disabled:o.form.status==2||o.form.status==1},null,8,["modelValue","disabled"])]),_:1}),o.errors.date_to?(m(),u("div",Ie," Date to is required ")):p("",!0)]),s("div",null,[r(v,{label:"From Time",isRequired:!0},{default:h(()=>[r(f,{modelValue:o.form.from_time,"onUpdate:modelValue":e[2]||(e[2]=g=>o.form.from_time=g),class:"form-control h-12",placeholder:"From time",onChange:l.calculateHours,disabled:o.form.status==2||o.form.status==1,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange","disabled"])]),_:1}),o.errors.from_time?(m(),u("div",Be," From Time is required ")):p("",!0)]),s("div",null,[r(v,{label:"To Time",isRequired:!0},{default:h(()=>[r(f,{modelValue:o.form.to_time,"onUpdate:modelValue":e[3]||(e[3]=g=>o.form.to_time=g),class:"form-control h-12",placeholder:"To time",onChange:l.calculateHours,disabled:o.form.status==2||o.form.status==1,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange","disabled"])]),_:1}),o.errors.to_time?(m(),u("div",Me," To Time is required ")):p("",!0)]),s("div",null,[r(v,{label:"Hours"},{default:h(()=>[r(x,{type:"text",modelValue:o.form.hours,"onUpdate:modelValue":e[4]||(e[4]=g=>o.form.hours=g),error:o.errors.hours,disabled:o.form.status==2||o.form.status==1,classInput:"h-12"},null,8,["modelValue","error","disabled"])]),_:1})]),s("div",null,[r(v,{label:"Charge To"},{default:h(()=>[r(C,{modelValue:o.form.charge_to,"onUpdate:modelValue":e[5]||(e[5]=g=>o.form.charge_to=g),error:o.errors.charge_to,disabled:o.form.status==2||o.form.status==1,classInput:"h-12",options:o.companyOptions,loading:t.isCompanyLoading},null,8,["modelValue","error","disabled","options","loading"])]),_:1})]),o.form.meal?(m(),u("div",Le,[s("label",Ee,[r(b,{icon:"mdi:check",class:"border border-blue-500 p-1 text-blue-500 rounded"}),e[13]||(e[13]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Meal",-1))])])):p("",!0),o.form.transportation?(m(),u("div",He,[s("label",Ue,[r(b,{icon:"mdi:check",class:"border border-blue-500 p-1 text-blue-500 rounded"}),e[14]||(e[14]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Transportation",-1))])])):p("",!0)]),s("div",je,[s("div",Pe,[r(v,{label:"Outputs/Deliverables",isRequired:!0},{default:h(()=>[r(F,{placeholder:"Outputs/Deliverables",modelValue:o.form.description,"onUpdate:modelValue":e[6]||(e[6]=g=>o.form.description=g),error:o.errors.description,disabled:o.form.status==2||o.form.status==1},null,8,["modelValue","error","disabled"])]),_:1})]),s("div",null,[r(v,{label:"Attachment"},{default:h(()=>[r(d,{title:"File Input Basic"},{default:h(()=>[r(A,{modelValue:o.form.attachment,"onUpdate:modelValue":e[7]||(e[7]=g=>o.form.attachment=g),name:"basic",onChange:l.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),o.errors.attachment?(m(),u("div",qe,y(o.errors.attachment),1)):p("",!0)]),_:1}),typeof o.form.attachment=="string"&&o.form.attachment?(m(),u("div",ze,[s("div",Ge,[s("div",{class:"flex items-center cursor-pointer",onClick:e[8]||(e[8]=g=>l.viewAttachment(o.form.attachment))},[r(V,{image:l.getFileTypeImage(o.form.attachment)},null,8,["image"]),k(" "+y(o.form.attachment),1)]),o.form.status==0?(m(),u("div",Ne,[r(b,{icon:"mingcute:delete-2-fill",onClick:e[9]||(e[9]=g=>l.deleteFile(o.form.id))})])):p("",!0)])])):p("",!0)]),_:1})])]),s("div",We,[s("div",Ye,[s("div",Ze,[o.recommending_img?(m(),u("img",{key:0,src:o.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Ke)):(m(),u("div",Je," No Image "))]),s("div",Qe,[s("div",Xe,y(o.form.allow_higher_approval||o.form.hours>3||o.state.isDayOff||o.state.isHoliday?"Recommending":"Approving"),1),s("div",$e,y(o.recommending),1),o.form.allow_higher_approval||o.form.hours>3||o.state.isDayOff||o.state.isHoliday?(m(),u("div",et,y(o.form.recommended_at?"Date: ("+this.$formatDate(o.form.recommended_at)+")":""),1)):(m(),u("div",tt,y(o.form.approved_at?"Date: ("+this.$formatDate(o.form.approved_at)+")":""),1))])]),o.form.allow_higher_approval||o.form.hours>3||o.state.isDayOff||o.state.isHoliday?(m(),u("div",ot,[s("div",st,[o.approving_img?(m(),u("img",{key:0,src:o.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,it)):(m(),u("div",rt," No Image "))]),s("div",nt,[e[15]||(e[15]=s("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),s("div",at,y(o.approving),1),s("div",lt,y(o.form.approved_at?"Date: ("+this.$formatDate(o.form.approved_at)+")":""),1)])])):p("",!0)]),s("div",mt,[s("div",null,[o.form.hours<=3&&o.form.hours!=""&&!o.state.isDayOff&&!o.state.isHoliday?(m(),u("label",dt,[O(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,ct),[[I,o.form.allow_higher_approval]]),e[16]||(e[16]=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[17]||(e[17]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])):p("",!0)]),s("div",null,[!o.state.isEdit&&o.state.hasSchedule&&!o.errors.wfhNotAllowed?(m(),w(ee,{key:0,onClick:l.submitForm},null,8,["onClick"])):o.form.status===0&&o.state.hasSchedule&&!o.errors.wfhNotAllowed?(m(),w(te,{key:1,onClick:l.submitForm},null,8,["onClick"])):p("",!0),r(oe,{onClick:l.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const ut=L(Te,[["render",ft],["__scopeId","data-v-ece05b33"]]);const ht={components:{FileType:Z,DenyButton:Ae,FormModal:N,FormGroup:G,TextInput:W,Textarea:J,SubmitButton:H,UpdateButton:P,CloseButton:E,Loading:U,Multiselect:Y,Icon:M,Checkbox:K},data(){return{companyOptions:[],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:[],form:{date_from:"",date_to:"",from_from:"",to_time:"",hours:"",charge_to:"",meal:"",transportation:"",meal_amount:"",transportation_amount:"",description:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isCompanyLoading:!1,isLoadRecord:!1,isDownloading:!1},fileIcons:{pdf:X,jpg:$,default:""}}},methods:{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 z.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 a=atob(e),o=new Array(a.length);for(let f=0;f<a.length;f++)o[f]=a.charCodeAt(f);const l=new Uint8Array(o),n=new Blob([l],{type:i}),_=URL.createObjectURL(n);window.open(_),this.state.isLoadingPDF=!1},async fetchCompanyRecords(){try{this.state.isCompanyLoading=!0,this.companyOptions=await Q()}catch(t){console.error("Failed to fetch company data:",t)}finally{this.state.isCompanyLoading=!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)},e.readAsDataURL(t)},async loadRecord(t){this.resetForm(),this.form=t,this.form.meal=t.meal==1,this.form.transportation=t.transportation==1,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:"",console.log(this.currentRecommendingId+this.currentEmployeeId),this.currentRecommendingId==this.currentEmployeeId&&this.form.status==0&&(this.btnTitle="Submit For Approval"),this.currentApprovingId==this.currentEmployeeId&&(this.btnTitle="Approve"),this.currentClassificationId>=3&&(console.log("dito"),await q.fetchEmployeeApprover(t.employee_id).then(e=>{if(e.status==200)this.recommendingOptions=e.data.map((i,a)=>({value:i.employee_id,label:i.firstname+" "+i.lastname})),this.approvingOptions=e.data.filter(i=>i.classification_id>=3).map((i,a)=>({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:"",charge_to:"",hours:"",meal:"",transportation:"",meal_amount:"",transportation_amount:"",description:"",attachment:"",recommending_id:"",approver_id:""}},reload(){return 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 D.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=this.form.id,e={status:this.status,meal:this.form.meal,transportation:this.form.transportation};await D.update(t,e).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 updateMealOrTranspoAmount(){const t=this.form.id;try{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.mealOrTranspoValue={meal:this.form.meal,transportation:this.form.transportation,meal_amount:this.form.meal_amount,transportation_amount:this.form.transportation_amount},D.update(t,this.mealOrTranspoValue).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})}))})}catch(e){if(e instanceof R){const i={};e.inner.forEach(a=>{i[a.path]=a.message}),this.errors=i}}},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 R){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 R){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 R){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,a]=this.form.from_time.split(":").map(Number),[o,l]=this.form.to_time.split(":").map(Number);let n=o-i;n+=(l-a)/60,n<0&&(n+=24),this.form.hours=n}}},mounted(){this.fetchCompanyRecords()},watch:{"form.from_time":{handler:"calculateHours",immediate:!0},"form.to_time":{handler:"calculateHours",immediate:!0}}},pt={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},gt={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"},_t={class:"text-red-600 dark:text-red-400 text-sm"},yt={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-6"},vt={class:"flex items-center gap-4"},wt={class:"flex justify-between items-center w-full"},xt={class:"flex items-center cursor-pointer"},bt=["checked","disabled"],kt={class:"flex items-center gap-4"},Ct={class:"flex justify-between items-center w-full"},Ft={class:"flex items-center cursor-pointer"},At=["checked","disabled"],Tt={class:"grid grid-cols-1"},Rt={class:"grid grid-cols-1"},St={class:"col-span-6"},Vt={key:1},Dt={class:"grid grid-cols-12 justify-center items-center"},Ot={class:"col-span-8 flex justify-between items-center gap-4"},It={key:0,class:"col-span-6 flex justify-center items-center gap-4"},Bt={class:"font-bold"},Mt={class:"col-span-6 flex justify-center items-center gap-4"},Lt={class:"font-bold"},Et={key:2},Ht={class:"grid grid-cols-12 gap-4"},Ut={class:"col-span-6"},jt={class:"relative"},Pt={class:"col-span-6"},qt={class:"relative"},zt={class:"flex gap-1 justify-end pt-8"},Gt={key:0,class:"flex gap-1 justify-end"};function Nt(t,e,i,a,o,l){const n=c("Loading"),_=c("flat-pickr"),f=c("FormGroup"),v=c("TextInput"),x=c("Multiselect"),C=c("Textarea"),b=c("FileType"),F=c("CloseButton"),A=c("FormModal");return m(),w(A,{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?"approved":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:h(()=>[o.state.isEdit&&o.state.isLoading?(m(),w(n,{key:0,text:"Fetching record"})):p("",!0),s("div",pt,[this.form.status==2&&this.form.validated==99?(m(),u("div",gt,[e[13]||(e[13]=s("h3",{class:"text-red-700 dark:text-red-300 font-semibold mb-1 text-sm"}," Denied Reason ",-1)),s("p",_t,y(this.form.deferred_reason),1)])):p("",!0),s("form",{onSubmit:e[12]||(e[12]=j((...d)=>t.confirmSubmit&&t.confirmSubmit(...d),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[o.state.isSaving?(m(),w(n,{key:0,text:"Saving record"})):p("",!0),s("div",yt,[s("div",null,[r(f,{label:"From Date",isRequired:!0},{default:h(()=>[r(_,{modelValue:o.form.date_from,"onUpdate:modelValue":e[0]||(e[0]=d=>o.form.date_from=d),class:"form-control h-12",id:"date_from",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1})]),s("div",null,[r(f,{label:"To Date",isRequired:!0},{default:h(()=>[r(_,{modelValue:o.form.date_to,"onUpdate:modelValue":e[1]||(e[1]=d=>o.form.date_to=d),class:"form-control h-12",id:"date_to",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1})]),s("div",null,[r(f,{label:"From Time",isRequired:!0},{default:h(()=>[r(_,{modelValue:o.form.from_time,"onUpdate:modelValue":e[2]||(e[2]=d=>o.form.from_time=d),class:"form-control h-12",placeholder:"From time",onChange:l.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),s("div",null,[r(f,{label:"To Time",isRequired:!0},{default:h(()=>[r(_,{modelValue:o.form.to_time,"onUpdate:modelValue":e[3]||(e[3]=d=>o.form.to_time=d),class:"form-control h-12",placeholder:"To time",onChange:l.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),s("div",null,[r(f,{label:"Hours"},{default:h(()=>[r(v,{type:"text",modelValue:o.form.hours,"onUpdate:modelValue":e[4]||(e[4]=d=>o.form.hours=d),error:o.errors.hours,classInput:"h-12"},null,8,["modelValue","error"])]),_:1})]),s("div",null,[r(f,{label:"Charge To"},{default:h(()=>[r(x,{modelValue:o.form.charge_to,"onUpdate:modelValue":e[5]||(e[5]=d=>o.form.charge_to=d),error:o.errors.charge_to,classInput:"h-12",options:o.companyOptions,loading:t.isCompanyLoading},null,8,["modelValue","error","options","loading"])]),_:1})]),s("div",vt,[s("div",wt,[s("div",null,[s("label",xt,[O(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[6]||(e[6]=d=>o.form.meal=d),disabled:o.form.status!=1},null,8,bt),[[I,o.form.meal]]),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"},"Meal",-1))])])])]),s("div",kt,[s("div",Ct,[s("div",null,[s("label",Ft,[O(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[7]||(e[7]=d=>o.form.transportation=d),disabled:o.form.status!=1},null,8,At),[[I,o.form.transportation]]),e[16]||(e[16]=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[17]||(e[17]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Transportation",-1))])])])])]),s("div",Tt,[s("div",Rt,[r(f,{label:"Outputs/Deliverables"},{default:h(()=>[r(C,{placeholder:"Outputs/Deliverables",modelValue:o.form.description,"onUpdate:modelValue":e[8]||(e[8]=d=>o.form.description=d)},null,8,["modelValue"])]),_:1})]),s("div",St,[r(f,{label:"Attachment"},{default:h(()=>[typeof o.form.attachment=="string"?(m(),u("div",{key:0,class:"flex items-center gap-2 mt-2 cursor-pointer",onClick:e[9]||(e[9]=d=>l.viewAttachment(o.form.attachment))},[r(b,{image:l.getFileTypeImage(o.form.attachment)},null,8,["image"]),k(" "+y(o.form.attachment),1)])):p("",!0)]),_:1})])]),o.currentClassificationId<=2?(m(),u("div",Vt,[s("div",Dt,[s("div",Ot,[o.form.allow_higher_approval?(m(),u("div",It,[e[18]||(e[18]=k(" Recommending: ")),s("p",Bt,y(o.recommending),1)])):p("",!0),s("div",Mt,[e[19]||(e[19]=k(" Approving: ")),s("p",Lt,y(o.approving),1)])])])])):(m(),u("div",Et,[s("div",Ht,[s("div",Ut,[r(f,{label:"Recommending"},{default:h(()=>[s("div",jt,[r(x,{modelValue:o.form.recommending_id,"onUpdate:modelValue":e[10]||(e[10]=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",Pt,[r(f,{label:"Approver"},{default:h(()=>[s("div",qt,[r(x,{modelValue:o.form.approver_id,"onUpdate:modelValue":e[11]||(e[11]=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",zt,[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?(m(),u("div",Gt)):p("",!0),r(F,{onClick:l.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["active","sideTitle","badgeColor","onSubmit","onClose"])}const Wt=L(ht,[["render",Nt],["__scopeId","data-v-5657ff56"]]);const Yt={mixins:[ie],components:{FilterTimekeeping:ge,ActionCellRenderer:pe,AgGridVue:he,Pagination:Fe,Card:ne,Button:ae,Badge:le,Layout:re,Icon:M,CreateButton:_e,SubmitButton:H,CloseButton:E,EditButton:ve,DeleteButton:ye,ViewButton:we,Form:ut,InputGroup:me,Loading:U,View:Wt},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:1},{field:"date coverage",filter:!0,floatingFilter:!0,flex:2},{field:"time coverage",filter:!0,floatingFilter:!0,flex:3},{field:"meal_label",headerName:"Transportation",filter:!0,floatingFilter:!0,flex:1},{field:"transportation_label",headerName:"Transportation",filter:!0,floatingFilter:!0,flex:1},{field:"date created",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,valueGetter:t=>{if(t.data.status==2&&t.data.validated==1)return"Validated";if(t.data.status==2&&t.data.validated==99)return"Deferred by HR";switch(t.data.status){case 0:return"For Recommendation";case 1:return"For Approval";case 2:return"Approved";case 99:return"Denied";default:return""}},cellRenderer:t=>{const e=t.value,i=document.createElement("div");switch(e){case"For Recommendation":i.innerHTML='<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>';break;case"For Approval":i.innerHTML='<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>';break;case"Validated":i.innerHTML='<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>';break;case"Deferred by HR":i.innerHTML=` <div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-red-600 px-4"> Denied <button class="ml-2 inline-flex items-center px-2 py-1 text-white text-sm font-medium rounded hover:bg-white-700 focus:ring-2 focus:ring-yellow-500 focus:outline-none view-button" title="View details of why it was denied"> <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1 text-yellow-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"> <path stroke-linecap="round" stroke-linejoin="round" d="M10 4H4a2 2 0 00-2 2v12a2 2 0 002 2h16a2 2 0 002-2V8a2 2 0 00-2-2h-6l-2-2H10a2 2 0 00-2 2v0z" /> </svg> </button> </div>`,i.querySelector(".view-button").addEventListener("click",()=>{this.view(t.data)});break;case"Approved":i.innerHTML='<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>';break;case"Denied":i.innerHTML='<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>';break;default:i.innerHTML=""}return i}},{headerName:"Actions",cellRenderer:"ActionCellRenderer",flex:1,cellRendererParams:{context:{componentParent:this}}}],breadcrumbs:[{text:"Home",href:"/"},{text:"Timekeeping",href:"/attendance/employee-overtime"},{text:"Overtime Application",active:!0}],statistics:[{title:"OT Hours Rendered",subtitle:"For this month",count:"0",bg:"bg-info-500",text:"text-info-500",icon:"heroicons-outline:menu-alt-1"},{title:"Average OT Hours",subtitle:"For this month",count:"0",bg:"bg-warning-500",text:"text-warning-500",icon:"heroicons-outline:chart-pie"},{title:"Total OT Hours",subtitle:"For this year",count:"0",bg:"bg-purple-500",text:"text-purple-500",icon:"fa6-solid:chart-bar"}],statuses:[{count:1,status:"Pending"},{count:2,status:"Approved"},{count:1,status:"Denied"}],overtimes:[],items:[],totalItems:0,state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{},computed:{},methods:{applyFilters(t){if(!t||Object.keys(t).length===0){const e=new Date;let i=e.getFullYear(),a=e.getMonth()+1,o=a-1||12;o===12&&(i-=1);const l=a.toString().padStart(2,"0"),n=o.toString().padStart(2,"0"),_=e.getDate();t={range:_>1&&_<15?`${i}-${n}-21 to ${e.getFullYear()+1}-${l}-05`:`${e.getFullYear()}-${l}-06 to ${e.getFullYear()+1}-${l}-20`}}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 a=e>=12;return e=e%12||12,`${e}:${i} ${a?"PM":"AM"}`},formatDate(t){const e=new Date(t),i=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),a=new Date(i.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),o=a.getFullYear(),l=String(a.getMonth()+1).padStart(2,"0"),n=String(a.getDate()).padStart(2,"0");return`${o}-${l}-${n}`},async fetchRecords(t={}){this.state.isLoading=!0,await S.fetchRecords({...t}).then(e=>{let i=e.data.data.data,a=e.data.total_ot_for_the_month,o=e.data.total_ot_for_the_year,l=e.data.avg_ot_for_the_month;this.statistics[0].count=a.total_hours??0,this.statistics[1].count=l,this.statistics[2].count=o.total_hours??0,this.items=i,this.items=i.map((n,_)=>({...n,"#":_+1,"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)+" ("+n.hours+" Hours)",meal_label:n.meal?"Yes":"No",transportation_label:n.transportation?"Yes":"No","date created":this.$formatDate(n.created_at),status:n.status}))}).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,S.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.reload(),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.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},view(t){this.viewRecord(t)},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.applyFilters()}},Zt={class:"space-y-10 mt-4"},Kt={class:"flex items-center justify-between"},Jt={class:"text-2xl font-bold text-slate-900 dark:text-white"},Qt={class:"grid grid-cols-1 gap-4 pb-4 md:grid-cols-3"},Xt={class:B("h-14 w-14 flex items-center justify-center rounded-md text-4xl mb-4 shadow-lg bg-white")},$t={class:"text-sm font-semibold text-slate-600 dark:text-white mb-2"},eo={class:"flex justify-center gap-4"},to={class:"block text-sm text-slate-500 dark:text-white mb-1"},oo={class:"block mb- text-xl text-slate-900 dark:text-white font-medium"},so={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"},ro={class:"flex items-center gap-4"},no={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},ao={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function lo(t,e,i,a,o,l){const n=c("Icon"),_=c("FilterTimekeeping"),f=c("Button"),v=c("ag-grid-vue"),x=c("Card"),C=c("Loading"),b=c("Form"),F=c("View"),A=c("Layout");return m(),w(A,{breadcrumbs:o.breadcrumbs},{default:h(()=>[s("div",Zt,[r(x,{title:"Overtime Applications"},{default:h(()=>[s("div",Kt,[s("h2",Jt,y(t.title),1)]),s("div",Qt,[(m(!0),u(ue,null,fe(o.statistics,(d,V)=>(m(),u("div",{key:V,class:B([d.bg,"flex flex-col items-center rounded-lg p-2 bg-opacity-[0.15] dark:bg-opacity-50 text-center shadow-md hover:shadow-xl transition-transform transform hover:scale-101 w-full"])},[s("div",Xt,[r(n,{icon:d.icon,class:B(["text-2xl",d.text])},null,8,["icon","class"])]),s("div",$t,y(d.title),1),s("div",eo,[s("div",to,y(d.subtitle),1),s("div",null,[s("span",oo,y(d.count),1)])])],2))),128))]),s("div",so,[s("div",io,[e[5]||(e[5]=s("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," Requested Overtime ",-1)),s("div",ro,[r(_,{onFilterChanged:l.applyFilters},null,8,["onFilterChanged"]),r(f,{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:h(()=>[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",no,[r(n,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[1]||(e[1]=k(" Export to CSV "))])]),_:1},8,["onClick"]),r(f,{icon:"heroicons-outline:plus-sm",text:"Add Record",btnClass:"relative overflow-hidden font-normal px-4 py-2 rounded-lg shadow-md bg-white text-gray-900 border group transition-colors duration-300 group-hover:border-gray-500 group-hover:border",iconClass:"text-lg",onClick:l.createRecord},{default:h(()=>[e[4]||(e[4]=s("span",{class:"absolute inset-0 bg-gray-900 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),s("span",ao,[r(n,{icon:"heroicons-outline:plus-sm",class:"text-2xl mr-2"}),e[3]||(e[3]=k(" Add Record "))])]),_:1},8,["onClick"])])])]),r(v,{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?(m(),w(C,{key:0,text:"Fetching records"})):p("",!0),r(b,{onCloseModal:e[0]||(e[0]=d=>o.state.showModal=!1),ref:"form",onReload:l.applyFilters},null,8,["onReload"]),r(F,{ref:"view",onReload:l.fetchRecords},null,8,["onReload"])])]),_:1},8,["breadcrumbs"])}const Cs=L(Yt,[["render",lo],["__scopeId","data-v-048f7946"]]);export{Cs as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.08 |
proxy
|
phpinfo
|
Settings