File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.dffa7840.js
Back
import{w as re,L as ie}from"./index.15d773bc.js";import{C as ne}from"./index.b5116294.js";import{B as le}from"./index.9affbcc7.js";import{B as ae}from"./index.de756f91.js";import{I as L}from"./index.39289473.js";import{I as ce}from"./index.38283705.js";import{l as me}from"./lodash.0a0ce71b.js";import{_ as U,q as de,A as ue,r as m,o as n,c as v,w as h,j as f,b as d,d as s,e as i,t as c,k as z,p as T,s as I,f as O,X as q,n as N}from"./index.0409e1b2.js";import{E as V}from"./EmployeeOvertimeService.c55ffed2.js";import{A as fe}from"./main.esm.afa68281.js";import{A as he}from"./ActionCellRendererApprover.853c6829.js";import{F as pe}from"./index.9fb167ef.js";import{C as P}from"./CloseButton.5f2b3ff2.js";import{C as ge}from"./CreateButton.3cacf0d7.js";import{D as _e}from"./DeleteButton.7df36dab.js";import{E as ye}from"./EditButton.16b17e01.js";/* empty css */import{S as H}from"./SubmitButton.16346f33.js";import{V as ve}from"./ViewButton.074b6bc6.js";import"./jspdf.es.min.4dda79e8.js";/* empty css *//* empty css */import"./vue-cleave.min.18e79662.js";import{c as we,a as D,V as k}from"./array.6ad60c2c.js";import{L as j}from"./Loading.490cab57.js";import"./vue-quill.snow.d79094c0.js";/* empty css */import{F as G}from"./index.209240bf.js";import{F as W}from"./index.e35ce9e9.js";import{T as Y}from"./index.535682d0.js";import{T as Q}from"./index.61dcb620.js";import{U as Z}from"./UpdateButton.24df4af0.js";import{E as M}from"./EmployeeScheduleService.3193cc37.js";import{F as K}from"./FileService.5c843715.js";import{M as X}from"./Multiselect.bcca6a98.js";import{F as xe}from"./index.95692785.js";import{F as J}from"./index.a38b0ff2.js";import{C as $}from"./index.67fe51d0.js";import{f as ee}from"./apiUtils.2219b302.js";import{A as be}from"./index.faa210e2.js";import{p as te,j as oe}from"./scr-1.d9aaecca.js";import{P as Ce}from"./index.9cd030c0.js";import{D as Se}from"./DenyButton.1fd46c88.js";import{A as ke}from"./ApproverService.3b1246b2.js";import{O as B}from"./OvertimeApprovalService.3441239d.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.31efaf2a.js";import"./EmployeeService.a7f96e81.js";import"./es.string.replace.33548c32.js";import"./index.9f3ff4ef.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.ea365faf.js";import"./index.3560e594.js";import"./ck-white.4bf441fa.js";import"./CompanyService.ee45576d.js";import"./DealershipService.a21b6e26.js";import"./DepartmentService.17b85813.js";import"./DivisionService.be1e8ff3.js";import"./EmploymentTypeService.16c01f9c.js";import"./GroupService.14a6f45e.js";import"./JobClassficationService.9b8fcf51.js";import"./JobTitleService.cf3393b5.js";import"./SectionService.dff129b2.js";import"./SupportingDocumentService.c1e6c225.js";import"./UnitService.dbf1cfee.js";import"./CitizenshipService.90c91de2.js";import"./CivilStatusService.71578228.js";import"./ReligionService.915283e9.js";const Te={components:{Alert:be,FileType:J,Fileinput:xe,FormModal:W,FormGroup:G,TextInput:Y,Textarea:Q,SubmitButton:H,UpdateButton:Z,CloseButton:P,Loading:j,Multiselect:X,Icon:L,Checkbox:$},data(){return{currentSchedule:[],isScheduleLoading:!0,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:te,jpg:oe,default:""}}},methods:{async fetchCurrentEmployeeSchedule(o){this.isScheduleLoading=!0,await M.fetchCurrentScheduleRecord(o).then(e=>{e.status==200&&(this.currentSchedule=e.data,this.isScheduleLoading=!1,console.log("current schedule",e.data))}).catch(e=>{console.log(e),this.isScheduleLoading=!1})},async fetchEmployeeSchedule(){await M.fetchRecord(1).then(o=>{o.status==200&&(console.log("schedule",o.data),o.data&&(this.state.hasSchedule=!0))}).catch(o=>{console.log(o)})},deleteFile(o){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",o)},async deleteFileAttachment(){const o=this.form.id,e=this.form.attachment,r={id:o,attachment:e};await V.removeAttachment(r).then(l=>{l.status==201?(this.$swal.fire({title:"Great!",text:"Attachment successfully deleted.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.form.attachment="",console.log("null dapat",this.form.attachment)):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(l=>{l.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:l.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},getFileTypeImage(o){if(typeof o=="string"){if(!o)return this.fileIcons.default;const e=o.substring(o.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(o){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await K.Reader2("employee-overtime",o),r;if(o.endsWith(".pdf"))r="application/pdf";else if(o.endsWith(".png"))r="image/png";else if(o.endsWith(".jpg")||o.endsWith(".jpeg"))r="image/jpeg";else if(o.endsWith(".svg"))r="image/svg+xml";else throw new Error("Unsupported file type");const l=atob(e),t=new Array(l.length);for(let y=0;y<l.length;y++)t[y]=l.charCodeAt(y);const a=new Uint8Array(t),p=new Blob([a],{type:r}),w=URL.createObjectURL(p);window.open(w),this.state.isLoadingPDF=!1},reload(){return this.$emit("reload")},async fetchCompanyRecords(){try{this.state.isCompanyLoading=!0,this.companyOptions=await ee()}catch(o){console.error("Failed to fetch company data:",o)}finally{this.state.isCompanyLoading=!1}},handleMainImageUpload(){const o=event.target.files[0];this.form.attachment=o;const e=new FileReader;e.onload=()=>{o.type.startsWith("image/")?this.form.imageView=e.result:o.type==="application/pdf"?this.form.imageView=this.pdf_file_view:o.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(o),e.readAsDataURL(o)},loadRecord(o){this.resetForm(),this.state.isEdit=!0,this.form=o,this.form.meal=o.meal==1,this.form.transportation=o.transportation==1,this.fetchCurrentEmployeeSchedule(o),this.recommending=o.recommending[0].firstname+" "+o.recommending[0].lastname,this.approving=o.approving[0].firstname+" "+o.approving[0].lastname,console.log("recommending",o.approving[0].firstname)},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 saveRecord(){if(this.state.isEdit){this.form.id;let o=new FormData;Object.keys(this.form).forEach(e=>{o.append(e,this.form[e])}),await V.update(o).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 o=new FormData;Object.keys(this.form).forEach(e=>{o.append(e,this.form[e])}),await V.create(o).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 we().shape({date_from:D().required("Date from is required"),date_to:D().required("Date to is required"),from_time:D().required("From time is required"),to_time:D().required("To time is required"),description:D().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(o){if(o instanceof k){const e={};o.inner.forEach(r=>{e[r.path]=r.message}),this.errors=e}this.state.isSaving=!1}},calculateHours(){const o=this.form.from_time,e=this.form.to_time;if(o&&e){const[r,l]=this.form.from_time.split(":").map(Number),[t,a]=this.form.to_time.split(":").map(Number);let p=t-r;p+=(a-l)/60,p<0&&(p+=24),this.form.hours=p,this.form.meal=p>=3,this.form.transportation=t>=22||t>0&&t<=6}},async checkIfWfh(){if(this.state.isLoading=!0,this.form.date_from!=""&&this.state.hasSchedule){const o=de(this.form.date_from);let e={start_date:o,end_date:o};const r=await ue.fetchRecords(e);this.holidayList=r.data.holiday?r.data.holiday:[],this.scheduleList=r.data.schedule?r.data.schedule:[],this.holidayList.length!=0?this.state.isHoliday=!0:this.state.isHoliday=!1,this.scheduleList.filter(l=>l.date===this.form.date_from).map(l=>{l.title.includes("Day Off")?this.state.isDayOff=!0:this.state.isDayOff=!1,l.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()},watch:{"form.date_from":{handler(){this.checkIfWfh()},immediate:!0},"form.hours"(o){o>=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={key:2,class:"text-slate-600 dark:text-slate-400 text-sm font-normal mb-6"},Ae={class:"flex items-center gap-2 mb-2"},Fe={key:0},De={key:1},Oe={class:"flex items-center gap-2"},Ve={key:0},Be={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Ie={key:1,class:"text-red-400 italic items-center"},Ee={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-6"},Me={key:0,class:"text-[#ec4899]"},Le={key:1,class:"text-[#ec4899]"},Ue={key:0,class:"text-[#ec4899]"},Pe={key:0,class:"text-[#ec4899]"},He={key:0,class:"text-[#ec4899]"},je={class:"flex items-center gap-4"},qe={class:"flex items-center cursor-pointer"},Ne=["checked"],ze={class:"flex items-center gap-4"},Ge={class:"flex items-center cursor-pointer"},We=["checked"],Ye={class:"grid grid-cols-1"},Qe={class:"grid grid-cols-1"},Ze={key:0,class:"text-[#ec4899]"},Ke={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},Xe={class:"flex justify-between w-full items-center"},Je={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},$e={class:"grid grid-cols-12 gap-4"},et={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},tt={class:"flex-shrink-0 mr-4"},ot=["src"],st={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},rt={class:"text-left"},it={class:"text-sm font-semibold text-gray-600"},nt={class:"text-lg font-bold text-gray-900"},lt={key:0,class:"text-sm text-gray-900"},at={key:1,class:"text-sm text-gray-900"},ct={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},mt={class:"flex-shrink-0 mr-4"},dt=["src"],ut={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},ft={class:"text-left"},ht={class:"text-lg font-bold text-gray-900"},pt={class:"text-sm text-gray-900"},gt={class:"flex justify-between gap-2"};function _t(o,e,r,l,t,a){const p=m("Loading"),w=m("Icon"),y=m("flat-pickr"),g=m("FormGroup"),b=m("TextInput"),C=m("Multiselect"),R=m("Textarea"),A=m("Fileinput"),x=m("Card"),S=m("FileType"),F=m("SubmitButton"),E=m("UpdateButton"),u=m("CloseButton"),se=m("FormModal");return n(),v(se,{title:"Overtime",active:t.state.showModal,onSubmit:o.confirmSubmit,onClose:a.closeModal,themeClass:t.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:h(()=>[t.state.isEdit&&t.state.isLoading?(n(),v(p,{key:0,text:"Fetching record"})):f("",!0),t.state.isLoading?(n(),v(p,{key:1,text:"Fetching record"})):f("",!0),t.isScheduleLoading?f("",!0):(n(),d("div",Re,[s("div",Ae,[i(w,{icon:"uim:schedule",class:"text-slate-500 text-3xl"}),s("span",null,[t.currentSchedule.schedule.cws_day!=null?(n(),d("div",Fe," Regular Day: "+c(this.$formatTime(t.currentSchedule.schedule.from_time))+" - "+c(this.$formatTime(t.currentSchedule.schedule.to_time))+" Dayoff - "+c(t.currentSchedule.schedule.day_off)+" CWS Day: "+c(t.currentSchedule.schedule.cws_day)+" ("+c(this.$formatTime(t.currentSchedule.schedule.cws_from_time))+" - "+c(this.$formatTime(t.currentSchedule.schedule.cws_to_time))+") ",1)):(n(),d("div",De,c(this.$formatTime(t.currentSchedule.schedule.from_time))+" - "+c(this.$formatTime(t.currentSchedule.schedule.to_time))+". Dayoff - "+c(t.currentSchedule.schedule.day_off),1))])]),s("div",Oe,[i(w,{icon:"ic:twotone-schedule",class:"text-slate-500 text-3xl"}),s("span",null,[t.currentSchedule.timelogs.length!=0?(n(),d("div",Ve,[s("div",null,c(t.currentSchedule.timelogs.time_in?this.$formatTime(t.currentSchedule.timelogs.time_in):"No Time In")+" - "+c(t.currentSchedule.timelogs.time_out?this.$formatTime(t.currentSchedule.timelogs.time_out):"No Time Out"),1)])):f("",!0)])])])),s("div",Be,[s("form",{onSubmit:e[12]||(e[12]=z((..._)=>o.confirmSubmit&&o.confirmSubmit(..._),["prevent"])),class:"space-y-6",enctype:"multipart/form-data"},[t.state.isSaving?(n(),v(p,{key:0,text:"Saving record"})):f("",!0),t.state.hasSchedule?f("",!0):(n(),d("div",Ie,"* Schedule is required ")),s("div",Ee,[s("div",null,[i(g,{label:"From Date",isRequired:!0},{default:h(()=>[i(y,{modelValue:t.form.date_from,"onUpdate:modelValue":e[0]||(e[0]=_=>t.form.date_from=_),class:"form-control h-12",id:"date_from",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1}),t.errors.date_from?(n(),d("div",Me,"Date From is required")):f("",!0),t.errors.wfhNotAllowed?(n(),d("div",Le,"Overtime is not allowed on WFH Schedule")):f("",!0)]),s("div",null,[i(g,{label:"To Date",isRequired:!0},{default:h(()=>[i(y,{modelValue:t.form.date_to,"onUpdate:modelValue":e[1]||(e[1]=_=>t.form.date_to=_),class:"form-control h-12",id:"date_to",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1}),t.errors.date_to?(n(),d("div",Ue,"Date to is required")):f("",!0)]),s("div",null,[i(g,{label:"From Time",isRequired:!0},{default:h(()=>[i(y,{modelValue:t.form.from_time,"onUpdate:modelValue":e[2]||(e[2]=_=>t.form.from_time=_),class:"form-control h-12",placeholder:"From time",onChange:a.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1}),t.errors.from_time?(n(),d("div",Pe,"From Time is required")):f("",!0)]),s("div",null,[i(g,{label:"To Time",isRequired:!0},{default:h(()=>[i(y,{modelValue:t.form.to_time,"onUpdate:modelValue":e[3]||(e[3]=_=>t.form.to_time=_),class:"form-control h-12",placeholder:"To time",onChange:a.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1}),t.errors.to_time?(n(),d("div",He,"To Time is required")):f("",!0)]),s("div",null,[i(g,{label:"Hours"},{default:h(()=>[i(b,{type:"text",modelValue:t.form.hours,"onUpdate:modelValue":e[4]||(e[4]=_=>t.form.hours=_),error:t.errors.hours,classInput:"h-12"},null,8,["modelValue","error"])]),_:1})]),s("div",null,[i(g,{label:"Charge To"},{default:h(()=>[i(C,{modelValue:t.form.charge_to,"onUpdate:modelValue":e[5]||(e[5]=_=>t.form.charge_to=_),error:t.errors.charge_to,classInput:"h-12",options:t.companyOptions,loading:o.isCompanyLoading},null,8,["modelValue","error","options","loading"])]),_:1})]),s("div",je,[s("label",qe,[T(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:t.form.meal,"onUpdate:modelValue":e[6]||(e[6]=_=>t.form.meal=_)},null,8,Ne),[[I,t.form.meal]]),e[13]||(e[13]=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[14]||(e[14]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Meal",-1))])]),s("div",ze,[s("label",Ge,[T(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:t.form.transportation,"onUpdate:modelValue":e[7]||(e[7]=_=>t.form.transportation=_)},null,8,We),[[I,t.form.transportation]]),e[15]||(e[15]=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[16]||(e[16]=s("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Transportation",-1))])])]),s("div",Ye,[s("div",Qe,[i(g,{label:"Outputs/Deliverables",isRequired:!0},{default:h(()=>[i(R,{placeholder:"Outputs/Deliverables",modelValue:t.form.description,"onUpdate:modelValue":e[8]||(e[8]=_=>t.form.description=_),error:t.errors.description},null,8,["modelValue","error"])]),_:1})]),s("div",null,[i(g,{label:"Attachment"},{default:h(()=>[i(x,{title:"File Input Basic"},{default:h(()=>[i(A,{modelValue:t.form.attachment,"onUpdate:modelValue":e[9]||(e[9]=_=>t.form.attachment=_),name:"basic",onChange:a.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),t.errors.attachment?(n(),d("div",Ze,c(t.errors.attachment),1)):f("",!0)]),_:1}),typeof t.form.attachment=="string"&&t.form.attachment?(n(),d("div",Ke,[s("div",Xe,[s("div",{class:"flex items-center cursor-pointer",onClick:e[10]||(e[10]=_=>a.viewAttachment(t.form.attachment))},[i(S,{image:a.getFileTypeImage(t.form.attachment)},null,8,["image"]),O(" "+c(t.form.attachment),1)]),t.form.status==0?(n(),d("div",Je,[i(w,{icon:"mingcute:delete-2-fill",onClick:e[11]||(e[11]=_=>a.deleteFile(t.form.id))})])):f("",!0)])])):f("",!0)]),_:1})])]),s("div",$e,[s("div",et,[s("div",tt,[t.recommending_img?(n(),d("img",{key:0,src:t.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,ot)):(n(),d("div",st," No Image "))]),s("div",rt,[s("div",it,c(t.form.allow_higher_approval||t.form.hours>3||t.state.isDayOff||t.state.isHoliday?"Recommending":"Approving"),1),s("div",nt,c(t.recommending),1),t.form.allow_higher_approval||t.form.hours>3||t.state.isDayOff||t.state.isHoliday?(n(),d("div",lt,c(t.form.recommended_at?"Date: ("+this.$formatDate(t.form.recommended_at)+")":""),1)):(n(),d("div",at,c(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1))])]),t.form.allow_higher_approval||t.form.hours>3||t.state.isDayOff||t.state.isHoliday?(n(),d("div",ct,[s("div",mt,[t.approving_img?(n(),d("img",{key:0,src:t.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,dt)):(n(),d("div",ut," No Image "))]),s("div",ft,[e[17]||(e[17]=s("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),s("div",ht,c(t.approving)+" asdasdasadsad ",1),s("div",pt,c(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1)])])):f("",!0)]),s("div",gt,[e[18]||(e[18]=s("div",null,null,-1)),s("div",null,[!t.state.isEdit&&t.state.hasSchedule&&!t.errors.wfhNotAllowed?(n(),v(F,{key:0,onClick:a.submitForm},null,8,["onClick"])):t.form.status===0&&t.state.hasSchedule&&!t.errors.wfhNotAllowed?(n(),v(E,{key:1,onClick:a.submitForm},null,8,["onClick"])):f("",!0),i(u,{onClick:a.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["active","onSubmit","onClose","themeClass"])}const yt=U(Te,[["render",_t],["__scopeId","data-v-95a56bd1"]]);const vt={components:{FileType:J,DenyButton:Se,FormModal:W,FormGroup:G,TextInput:Y,Textarea:Q,SubmitButton:H,UpdateButton:Z,CloseButton:P,Loading:j,Multiselect:X,Icon:L,Checkbox:$},data(){return{currentSchedule:[],companyOptions:[],isRestDayOt:!1,days:[],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,isShow:!1,isScheduleLoading:!1},fileIcons:{pdf:te,jpg:oe,default:""}}},methods:{async fetchCurrentEmployeeSchedule(o){this.state.isScheduleLoading=!0,await M.fetchCurrentScheduleRecord(o).then(e=>{e.status==200&&(this.currentSchedule=e.data,this.state.isScheduleLoading=!1,console.log("current schedule",e.data))}).catch(e=>{console.log(e),this.state.isScheduleLoading=!1})},async getDays(){this.days=[];const o=new Date(this.form.date_from),e=new Date(this.form.date_to);console.log("dateFrom",o),console.log("dateTo",e);const r=this.currentSchedule.schedule.day_off.split(",").map(l=>l.trim());for(console.log("dayOffArray",r);o<=e;){const l=o.toLocaleDateString("en-US",{weekday:"long"});console.log("dayOfWeek",l),this.days.push(l),console.log("days",this.days),o.setDate(o.getDate()+1)}this.isRestDayOt=this.days.some(l=>r.includes(l)),console.log("isRestday OT",this.isRestDayOt)},getFileTypeImage(o){if(typeof o=="string"){if(!o)return this.fileIcons.default;const e=o.substring(o.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(o){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await K.Reader2("employee-overtime",o),r;if(o.endsWith(".pdf"))r="application/pdf";else if(o.endsWith(".png"))r="image/png";else if(o.endsWith(".jpg")||o.endsWith(".jpeg"))r="image/jpeg";else if(o.endsWith(".svg"))r="image/svg+xml";else throw new Error("Unsupported file type");const l=atob(e),t=new Array(l.length);for(let y=0;y<l.length;y++)t[y]=l.charCodeAt(y);const a=new Uint8Array(t),p=new Blob([a],{type:r}),w=URL.createObjectURL(p);window.open(w),this.state.isLoadingPDF=!1},async fetchCompanyRecords(){try{this.state.isCompanyLoading=!0,this.companyOptions=await ee()}catch(o){console.error("Failed to fetch company data:",o)}finally{this.state.isCompanyLoading=!1}},handleMainImageUpload(){const o=event.target.files[0];this.form.attachment=o;const e=new FileReader;e.onload=()=>{o.type.startsWith("image/")?this.form.imageView=e.result:o.type==="application/pdf"?this.form.imageView=this.pdf_file_view:o.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},e.readAsDataURL(o)},async loadRecord(o){this.resetForm(),this.form=o,this.form.meal=o.meal==1,this.form.transportation=o.transportation==1,await this.fetchCurrentEmployeeSchedule(o),await this.getDays(),this.computeMealAmount(),this.currentRecommendingId=Array.isArray(o.recommending)&&o.recommending.length>0?o.recommending[0].employee_id:"",this.currentApprovingId=Array.isArray(o.approving)&&o.approving.length>0?o.approving[0].employee_id:"",this.recommending=Array.isArray(o.recommending)&&o.recommending.length>0?o.recommending[0].firstname+" "+o.recommending[0].lastname:"",this.approving=o.approving.length>0?o.approving[0].firstname+" "+o.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&&await ke.fetchEmployeeApprover(o.employee_id).then(e=>{if(e.status==200)this.recommendingOptions=e.data.map((r,l)=>({value:r.employee_id,label:r.firstname+" "+r.lastname})),this.approvingOptions=e.data.filter(r=>r.classification_id>=3).map((r,l)=>({value:r.employee_id,label:r.firstname+" "+r.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.state.showModal=!1,this.state.isSaving=!1,this.$emit("reload")},async updateApproverRecord(){this.state.isSaving=!0;const o=this.form.id;this.state.isSaving=!1;let e={recommending_id:this.form.recommending_id,approver_id:this.form.approver_id};await B.updateApprover(o,e).then(r=>{r.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(r=>{r.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:r.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 o=this.form.id,e={status:this.status,meal:this.form.meal,transportation:this.form.transportation};await B.update(o,e).then(r=>{r.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(r=>{r.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:r.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 o=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},B.update(o,this.mealOrTranspoValue).then(r=>{r.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(r=>{r.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:r.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 k){const r={};e.inner.forEach(l=>{r[l.path]=l.message}),this.errors=r}}},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(o=>{o.value&&this.saveRecord()})}catch(o){if(o instanceof k){const e={};o.inner.forEach(r=>{e[r.path]=r.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(o=>{o.value&&this.updateApproverRecord()})}catch(o){if(o instanceof k){const e={};o.inner.forEach(r=>{e[r.path]=r.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 o=document.getElementById("swal-input").value;return o?this.denied_reason=o:(this.$swal.showValidationMessage("The reason field is required"),!1)}}).then(o=>{this.status={status:99,denied_reason:this.denied_reason},o.value&&this.saveRecord()})}catch(o){if(o instanceof k){const e={};o.inner.forEach(r=>{e[r.path]=r.message}),this.errors=e}}},calculateHours(){const o=this.form.from_time,e=this.form.to_time;if(o&&e){const[r,l]=this.form.from_time.split(":").map(Number),[t,a]=this.form.to_time.split(":").map(Number);let p=t-r;p+=(a-l)/60,p<0&&(p+=24),this.form.hours=p}},async ReceiveByHr(o){try{if(o==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 deny"},showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Submit",cancelButtonText:"Cancel",preConfirm:r=>r||(this.$swal.showValidationMessage("Reason is required!"),!1)});e.isConfirmed&&e.value&&this.updateRecordByHR(o,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(o))})}catch(e){if(e instanceof k){const r={};e.inner.forEach(l=>{r[l.path]=l.message}),this.errors=r}}},async updateRecordByHR(o,e=null){this.state.isSaving=!0;const r=this.form.id;let t={status:o,reason:e,meal:this.form.meal,meal_amount:this.form.meal_amount,transportation:this.form.transportation,transportation_amount:this.form.transportation_amount};await B.hrValidation(r,t).then(a=>{a.status==201?(console.log("response"),console.log(a),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(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}),this.state.isSaving=!1})},computeMealAmount(){console.log("FORM",this.form);let o=0;o=parseInt(this.form.hours/this.form.PayrollSettings.overtime_meal_every_hours)*this.form.PayrollSettings.overtime_meal_amount,console.log("COMPUTE MEAL AMOUNT",this.isRestDayOt),this.isRestDayOt&&(o=parseInt(this.form.hours/4)*this.form.PayrollSettings.overtime_meal_amount),console.log("TOTAL_MEAL",o),this.form.meal&&(this.form.meal_amount=o.toFixed(2))}},mounted(){this.fetchCompanyRecords()},watch:{"form.from_time":{handler:"calculateHours",immediate:!0},"form.to_time":{handler:"calculateHours",immediate:!0}}},wt={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},xt={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"},bt={class:"text-red-600 dark:text-red-400 text-sm"},Ct={key:1,class:"text-slate-600 dark:text-slate-400 text-sm font-normal mb-6"},St={class:"flex items-center gap-2 mb-2",title:"Current Schedule"},kt={key:0},Tt={key:1},Rt={class:"flex items-center gap-2",title:"Time In/Out"},At={key:0},Ft={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-6"},Dt={class:"flex items-center gap-4"},Ot={class:"flex justify-between items-center w-full"},Vt={class:"flex items-center cursor-pointer"},Bt=["checked"],It={key:0},Et={class:"flex items-center gap-4"},Mt={class:"flex justify-between items-center w-full"},Lt={class:"flex items-center cursor-pointer"},Ut=["checked"],Pt={key:0},Ht={class:"grid grid-cols-1"},jt={class:"grid grid-cols-1"},qt={class:"col-span-6"},Nt={key:1},zt={class:"grid grid-cols-12 justify-center items-center"},Gt={class:"col-span-8 flex justify-between items-center gap-4"},Wt={key:0,class:"col-span-6 flex justify-center items-center gap-4"},Yt={class:"font-bold"},Qt={class:"col-span-6 flex justify-center items-center gap-4"},Zt={class:"font-bold"},Kt={key:2},Xt={class:"grid grid-cols-12 gap-4"},Jt={class:"col-span-6"},$t={class:"relative"},eo={class:"col-span-6"},to={class:"relative"},oo={class:"flex gap-1 justify-end pt-8"},so={key:0,class:"flex gap-1 justify-end"},ro={key:1,class:"flex gap-1 justify-end"};function io(o,e,r,l,t,a){const p=m("Loading"),w=m("Icon"),y=m("flat-pickr"),g=m("FormGroup"),b=m("TextInput"),C=m("Multiselect"),R=m("Textarea"),A=m("FileType"),x=m("UpdateButton"),S=m("DenyButton"),F=m("CloseButton"),E=m("FormModal");return n(),v(E,{title:"View Record",active:t.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:o.confirmSubmit,onClose:a.closeModal,themeClass:"bg-gray-800",sizeClass:"lg:w-2/4"},{default:h(()=>[t.state.isEdit&&t.state.isLoading?(n(),v(p,{key:0,text:"Fetching record"})):f("",!0),s("div",wt,[this.form.status==2&&this.form.validated==99?(n(),d("div",xt,[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",bt,c(this.form.deferred_reason),1)])):f("",!0),t.state.isScheduleLoading?f("",!0):(n(),d("div",Ct,[s("div",St,[i(w,{icon:"uim:schedule",class:"text-slate-500 text-3xl"}),s("span",null,[t.currentSchedule.schedule.cws_day!=null?(n(),d("div",kt," Regular Day: "+c(this.$formatTime(t.currentSchedule.schedule.from_time))+" - "+c(this.$formatTime(t.currentSchedule.schedule.to_time))+" Dayoff - "+c(t.currentSchedule.schedule.day_off)+" CWS Day: "+c(t.currentSchedule.schedule.cws_day)+" ("+c(this.$formatTime(t.currentSchedule.schedule.cws_from_time))+" - "+c(this.$formatTime(t.currentSchedule.schedule.cws_to_time))+") ",1)):(n(),d("div",Tt,c(this.$formatTime(t.currentSchedule.schedule.from_time))+" - "+c(this.$formatTime(t.currentSchedule.schedule.to_time))+". Dayoff - "+c(t.currentSchedule.schedule.day_off),1))])]),s("div",Rt,[i(w,{icon:"ic:twotone-schedule",class:"text-slate-500 text-3xl"}),s("span",null,[t.currentSchedule.timelogs.length!=0?(n(),d("div",At,[s("div",null,c(t.currentSchedule.timelogs.time_in?this.$formatTime(t.currentSchedule.timelogs.time_in):"No Time In")+" - "+c(t.currentSchedule.timelogs.time_out?this.$formatTime(t.currentSchedule.timelogs.time_out):"No Time Out"),1)])):f("",!0)])])])),s("form",{onSubmit:e[16]||(e[16]=z((...u)=>o.confirmSubmit&&o.confirmSubmit(...u),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[t.state.isSaving?(n(),v(p,{key:0,text:"Saving record"})):f("",!0),s("div",Ft,[s("div",null,[i(g,{label:"From Date",isRequired:!0},{default:h(()=>[i(y,{modelValue:t.form.date_from,"onUpdate:modelValue":e[0]||(e[0]=u=>t.form.date_from=u),class:"form-control h-12",id:"date_from",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1})]),s("div",null,[i(g,{label:"To Date",isRequired:!0},{default:h(()=>[i(y,{modelValue:t.form.date_to,"onUpdate:modelValue":e[1]||(e[1]=u=>t.form.date_to=u),class:"form-control h-12",id:"date_to",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1})]),s("div",null,[i(g,{label:"From Time",isRequired:!0},{default:h(()=>[i(y,{modelValue:t.form.from_time,"onUpdate:modelValue":e[2]||(e[2]=u=>t.form.from_time=u),class:"form-control h-12",placeholder:"From time",onChange:a.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),s("div",null,[i(g,{label:"To Time",isRequired:!0},{default:h(()=>[i(y,{modelValue:t.form.to_time,"onUpdate:modelValue":e[3]||(e[3]=u=>t.form.to_time=u),class:"form-control h-12",placeholder:"To time",onChange:a.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),s("div",null,[i(g,{label:"Hours"},{default:h(()=>[i(b,{type:"text",modelValue:t.form.hours,"onUpdate:modelValue":e[4]||(e[4]=u=>t.form.hours=u),error:t.errors.hours,classInput:"h-12"},null,8,["modelValue","error"])]),_:1})]),s("div",null,[i(g,{label:"Charge To"},{default:h(()=>[i(C,{modelValue:t.form.charge_to,"onUpdate:modelValue":e[5]||(e[5]=u=>t.form.charge_to=u),error:t.errors.charge_to,classInput:"h-12",options:t.companyOptions,loading:o.isCompanyLoading},null,8,["modelValue","error","options","loading"])]),_:1})]),s("div",Dt,[s("div",Ot,[s("div",null,[s("label",Vt,[T(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:t.form.meal,"onUpdate:modelValue":e[6]||(e[6]=u=>t.form.meal=u)},null,8,Bt),[[I,t.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))])]),t.form.status==2?T((n(),d("div",It,[i(g,{label:"Amount"},{default:h(()=>[i(b,{type:"text",modelValue:t.form.meal_amount,"onUpdate:modelValue":e[7]||(e[7]=u=>t.form.meal_amount=u),disabled:this.form.validated!=0,classInput:"h-12 border-2 border-blue-500",style:N({backgroundColor:t.form.validated!=0?"#f0f0f0":""})},null,8,["modelValue","disabled","style"])]),_:1})],512)),[[q,t.form.meal]]):f("",!0)])]),s("div",Et,[s("div",Mt,[s("div",null,[s("label",Lt,[T(s("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-red-500 checked:border-red-500",checked:t.form.transportation,"onUpdate:modelValue":e[8]||(e[8]=u=>t.form.transportation=u)},null,8,Ut),[[I,t.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))])]),t.form.status==2?T((n(),d("div",Pt,[i(g,{label:"Amount"},{default:h(()=>[i(b,{type:"text",modelValue:t.form.transportation_amount,"onUpdate:modelValue":e[9]||(e[9]=u=>t.form.transportation_amount=u),disabled:this.form.validated!=0,classInput:"h-12",style:N({backgroundColor:t.form.validated!=0?"#f0f0f0":""})},null,8,["modelValue","disabled","style"])]),_:1})],512)),[[q,t.form.transportation]]):f("",!0)])])]),s("div",Ht,[s("div",jt,[i(g,{label:"Outputs/Deliverables"},{default:h(()=>[i(R,{placeholder:"Outputs/Deliverables",modelValue:t.form.description,"onUpdate:modelValue":e[10]||(e[10]=u=>t.form.description=u)},null,8,["modelValue"])]),_:1})]),s("div",qt,[i(g,{label:"Attachment"},{default:h(()=>[typeof t.form.attachment=="string"?(n(),d("div",{key:0,class:"flex items-center gap-2 mt-2 cursor-pointer",onClick:e[11]||(e[11]=u=>a.viewAttachment(t.form.attachment))},[i(A,{image:a.getFileTypeImage(t.form.attachment)},null,8,["image"]),O(" "+c(t.form.attachment),1)])):f("",!0)]),_:1})])]),t.currentClassificationId<=2?(n(),d("div",Nt,[s("div",zt,[s("div",Gt,[t.form.allow_higher_approval?(n(),d("div",Wt,[e[22]||(e[22]=O(" Recommending: ")),s("p",Yt,c(t.recommending),1)])):f("",!0),s("div",Qt,[e[23]||(e[23]=O(" Approving: ")),s("p",Zt,c(t.approving),1)])])])])):(n(),d("div",Kt,[s("div",Xt,[s("div",Jt,[i(g,{label:"Recommending"},{default:h(()=>[s("div",$t,[i(C,{modelValue:t.form.recommending_id,"onUpdate:modelValue":e[12]||(e[12]=u=>t.form.recommending_id=u),"close-on-select":!0,searchable:!0,id:"recommending_id",options:t.recommendingOptions},null,8,["modelValue","options"])])]),_:1})]),s("div",eo,[i(g,{label:"Approver"},{default:h(()=>[s("div",to,[i(C,{modelValue:t.form.approver_id,"onUpdate:modelValue":e[13]||(e[13]=u=>t.form.approver_id=u),"close-on-select":!0,searchable:!0,id:"approver_id",options:t.approvingOptions},null,8,["modelValue","options"])])]),_:1})])])])),s("div",oo,[this.form.status==0&&t.currentRecommendingId==t.currentEmployeeId||t.currentApprovingId==t.currentEmployeeId&&this.form.status==1&&t.currentApprovingId==this.form.approver_id||this.form.approver_id==this.form.recommending_id&&t.currentApprovingId==this.form.approver_id&&t.currentEmployeeId==this.form.approver_id?(n(),d("div",so,[this.form.status<=1?(n(),v(x,{key:0,onClick:a.submitForm,text:t.btnTitle},null,8,["onClick","text"])):f("",!0),this.form.status!=2?(n(),v(S,{key:1,onClick:a.denyForm,text:"Deny"},null,8,["onClick"])):f("",!0)])):this.form.status==0&&t.currentApprovingId==t.currentEmployeeId||t.currentApprovingId!=this.form.approver_id?(n(),d("div",ro,[this.form.status<=1?(n(),v(x,{key:0,onClick:a.updateApproverForm,text:"Update Approver"},null,8,["onClick"])):f("",!0)])):f("",!0),this.form.status===2&&this.form.validated==0?(n(),v(x,{key:2,btnClass:"text-green-600 bg-transpanent hover:ring ring-green-600 ring-offset-1 border border-green-600 transition duration-150 ease-out hover:ease-in py-2 px-3",onClick:e[14]||(e[14]=u=>a.ReceiveByHr(1)),text:"Receive"})):f("",!0),this.form.status===2&&this.form.validated==0?(n(),v(x,{key:3,btnClass:"text-red-600 bg-transparent hover:ring ring-red-600 ring-offset-1 border border-red-600 transition duration-150 ease-out hover:ease-in py-2 px-3",icon:"material-symbols:unpublished",onClick:e[15]||(e[15]=u=>a.ReceiveByHr(99)),text:"Deny"})):f("",!0),i(F,{onClick:a.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["active","sideTitle","badgeColor","onSubmit","onClose"])}const no=U(vt,[["render",io],["__scopeId","data-v-acc4d826"]]);const lo={mixins:[re],components:{FilterTimekeeping:pe,ActionCellRendererApprover:he,AgGridVue:fe,Pagination:Ce,Card:ne,Button:le,Badge:ae,Layout:ie,Icon:L,CreateButton:ge,SubmitButton:H,CloseButton:P,EditButton:ye,DeleteButton:_e,ViewButton:ve,Form:yt,InputGroup:ce,Loading:j,View:no},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:1},{field:"employee_id",filter:!0,floatingFilter:!0,flex:2},{field:"name",filter:!0,floatingFilter:!0,flex:2},{field:"date coverage",filter:!0,floatingFilter:!0,flex:2},{field:"time coverage",filter:!0,floatingFilter:!0,flex:3.5},{field:"meal_label",headerName:"Meal",filter:!0,floatingFilter:!0,flex:1},{field:"transportation_label",headerName:"Transporation",filter:!0,floatingFilter:!0,flex:1},{field:"date created",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,cellRenderer:o=>{const e=o.value,r=o.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>':r===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>':r===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-overtime"},{text:"Overtime Application",active:!0}],statuses:[{count:1,status:"Pending"},{count:2,status:"Approved"},{count:1,status:"Denied"}],overtimes:[],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],items:[],totalItems:0,searchQuery:null,serverOptions:{page:1,rowsPerPage:10,sortBy:"status",sortType:"asc"},state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:me.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{applyFilters(o){this.fetchRecords(o)},onGridReady(o){this.gridApi=o.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(o=>o.field!=="actions").map(o=>o.field)}):console.error("Grid API is not ready.")},formatTime(o){let[e,r]=o.split(":");e=parseInt(e);const l=e>=12;return e=e%12||12,`${e}:${r} ${l?"PM":"AM"}`},formatDate(o){const e=new Date(o),r=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),l=new Date(r.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),t=l.getFullYear(),a=String(l.getMonth()+1).padStart(2,"0"),p=String(l.getDate()).padStart(2,"0");return`${t}-${a}-${p}`},async fetchRecords(o={}){this.state.isLoading=!0,await V.fetchRecordList({dealership:this.$store.userSettings.activeDealership,...o}).then(e=>{console.log("response");let r=e.data.data.data;e.data.total_ot_for_the_month,e.data.total_ot_for_the_year,e.data.avg_ot_for_the_month;const l=e.data.PayrollSettings;this.items=r,this.items=r.map((t,a)=>({...t,"#":a+1,employee_id:t.employee_id,name:t.employee.lastname+", "+t.employee.firstname,"date coverage":t.date_from===t.date_to?this.$formatDate(t.date_from):this.$formatDate(t.date_from)+" - "+this.$formatDate(t.date_to),"time coverage":this.$formatTime(t.from_time)+" - "+this.$formatTime(t.to_time)+" ("+t.hours+" Hours)",meal_label:t.meal?"Yes":"No",transportation_label:t.transportation?"Yes":"No","date created":this.$formatDate(t.created_at),status:t.status,PayrollSettings:l}))}).finally(()=>{this.state.isLoading=!1})},reload(){this.$emit("reload")},handlePageChange(o){console.log(o),console.log(this.serverOptions.page),this.serverOptions.page!=o&&(this.serverOptions.page=o)},handlePerPageChange(o){this.serverOptions.page=1,this.serverOptions.rowsPerPage=o},onSortChange(o){console.log(o),o[0].type!="none"&&(this.serverOptions.sortBy=o[0].field,this.serverOptions.sortType=o[0].type)},async deleteRecord(o){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(o).then(r=>{r.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(o){console.log(o),this.$refs.form.resetForm(),this.$refs.form.loadRecord(o),this.$refs.form.state.showModal=!0},viewRecord(o){console.log("DATA",o),this.$refs.view.resetForm(),this.$refs.view.loadRecord(o),this.$refs.view.state.showModal=!0},handlePageChange(o){console.log(o),console.log(this.serverOptions.page),this.serverOptions.page!=o&&(this.serverOptions.page=o)},handlePerPageChange(o){this.serverOptions.page=1,this.serverOptions.rowsPerPage=o}},mounted(){this.fetchRecords()}},ao={class:"space-y-10 mt-4"},co={class:"flex items-center justify-between"},mo={class:"text-2xl font-bold text-slate-900 dark:text-white"},uo={class:"relative"},fo={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},ho={class:"flex items-center justify-center gap-4 text-gray-900"},po={class:"flex items-center gap-4"},go={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function _o(o,e,r,l,t,a){const p=m("FilterTimekeeping"),w=m("Icon"),y=m("Button"),g=m("ag-grid-vue"),b=m("Card"),C=m("Loading"),R=m("Form"),A=m("View"),x=m("Layout");return n(),v(x,{breadcrumbs:t.breadcrumbs},{default:h(()=>[s("div",ao,[i(b,{title:"Overtime Applications"},{default:h(()=>{var S;return[s("div",co,[s("h2",mo,c(o.title),1)]),s("div",uo,[s("div",fo,[s("div",ho,c(((S=this.$store.userSettings.dealershipAccess.find(F=>F.id==this.$store.userSettings.activeDealership))==null?void 0:S.name)+" - REQUESTED OVERTIME"||"REQUESTED OVERTIME"),1),s("div",po,[i(p,{onFilterChanged:a.applyFilters},null,8,["onFilterChanged"]),i(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:a.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",go,[i(w,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[1]||(e[1]=O(" Export to CSV "))])]),_:1},8,["onClick"])])])]),i(g,{ref:"agGrid",rowData:t.items,columnDefs:t.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:t.paginationPageSize,paginationPageSizeSelector:t.paginationPageSizeSelector,onGridReady:a.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])]}),_:1}),t.state.isLoading?(n(),v(C,{key:0,text:"Fetching records"})):f("",!0),i(R,{onCloseModal:e[0]||(e[0]=S=>t.state.showModal=!1),ref:"form",onReload:a.fetchRecords},null,8,["onReload"]),i(A,{onCloseModal:o.closeModal,ref:"view",onReload:a.fetchRecords},null,8,["onCloseModal","onReload"])])]),_:1},8,["breadcrumbs"])}const Vs=U(lo,[["render",_o],["__scopeId","data-v-2d9396ec"]]);export{Vs as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings