File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.c6760691.js
Back
import{w as X,L as ee}from"./index.3c190fb8.js";import{C as te}from"./index.fb3a5789.js";import{B as se}from"./index.edca6480.js";import{B as ie}from"./index.bd314dbf.js";import{I as D}from"./index.48097a46.js";import{I as oe}from"./index.1fa545a8.js";import{l as re}from"./lodash.946ada64.js";import{_ as I,r as c,o as a,c as p,w as h,j as m,d as i,f as C,t as g,k as U,e as l,b as u,p as ne,s as ae}from"./index.e8902503.js";import{E as S}from"./EmployeeTimeAdjusmentService.78140286.js";import{F as le}from"./index.69909e73.js";import{C as V}from"./CloseButton.7e0edf88.js";import{C as ce}from"./CreateButton.69c40d9f.js";import{D as me}from"./DeleteButton.85a5f71a.js";import{E as de}from"./EditButton.3881a749.js";/* empty css */import{S as O}from"./SubmitButton.8f4c4681.js";import{V as fe}from"./ViewButton.bab3942f.js";import{A as ue}from"./ActionCellRenderer.703146a6.js";/* empty css */import"./vue-cleave.min.795cb0c2.js";import{c as he,a as M,V as B}from"./array.29c46f9b.js";import{L as E}from"./Loading.587e211a.js";import"./vue-quill.snow.2184ee49.js";/* empty css */import{F as P}from"./index.b0868b90.js";import{F as j}from"./index.fbdde90a.js";import{T as L}from"./index.c1433bbe.js";import{T as G}from"./index.437e4071.js";import{U as q}from"./UpdateButton.af135175.js";import"./jspdf.es.min.e8517b60.js";/* empty css */import{A as z}from"./ApproverService.5035b950.js";import{F as H}from"./FileService.f245fd6f.js";import{M as N}from"./Multiselect.b44a8b2e.js";import{F as pe}from"./index.ec6cdce2.js";import{F as W}from"./index.553d4f42.js";import{C as Y}from"./index.9d01a5d9.js";import{A as ge}from"./index.4abb8977.js";import{p as $,j as Q}from"./scr-1.d9aaecca.js";import{P as _e}from"./index.09aa51ae.js";import{A as ye}from"./main.esm.4c666faa.js";import{A as ve}from"./ActionCellRendererApprover.fddcab16.js";import{D as we}from"./DenyButton.7246b185.js";import{T}from"./TimeAdjustmentApprovalService.e0f4e365.js";import{f as xe}from"./apiUtils.8ed5a398.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.e3cedc97.js";import"./EmployeeService.0b822608.js";import"./es.string.replace.b08ed996.js";import"./index.82e22688.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.4f499d44.js";import"./index.a4f02fc5.js";import"./ck-white.4bf441fa.js";import"./CompanyService.d8bdc467.js";import"./DealershipService.2aec68fa.js";import"./DepartmentService.ce03defe.js";import"./DivisionService.34fb22c3.js";import"./EmploymentTypeService.363d60e3.js";import"./GroupService.49928d55.js";import"./JobClassficationService.5dad0abe.js";import"./JobTitleService.894deba9.js";import"./SectionService.f82c7314.js";import"./SupportingDocumentService.d7dd71d8.js";import"./UnitService.a4782286.js";import"./CitizenshipService.87890626.js";import"./CivilStatusService.d8da82d0.js";import"./ReligionService.0c62d641.js";const be={components:{Alert:ge,FileType:W,Fileinput:pe,FormModal:j,FormGroup:P,TextInput:L,Textarea:G,SubmitButton:O,UpdateButton:q,CloseButton:V,Loading:E,Multiselect:N,Icon:D,Checkbox:Y},data(){return{inOutOptions:[{value:0,label:"IN"},{value:1,label:"OUT"}],recommending:"",recommending_img:"",approving:"",approving_img:"",form:{date:"",date_to:"",time:null,in_out:"",description:"",attachment:"",recommending_id:"",allow_higher_approval:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isCompanyLoading:!1},fileIcons:{pdf:$,jpg:Q,default:""}}},methods:{deleteFile(t){this.$swal.fire({title:"Are you sure you want remove the attachment?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.deleteFileAttachment()}),console.log("wawawawa",t)},async deleteFileAttachment(){const t=this.form.id,e=this.form.attachment,o={id:t,attachment:e};await S.removeAttachment(o).then(r=>{r.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(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})})},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 H.Reader2("employee-overtime",t),o;if(t.endsWith(".pdf"))o="application/pdf";else if(t.endsWith(".png"))o="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))o="image/jpeg";else if(t.endsWith(".svg"))o="image/svg+xml";else throw new Error("Unsupported file type");const r=atob(e),s=new Array(r.length);for(let d=0;d<r.length;d++)s[d]=r.charCodeAt(d);const n=new Uint8Array(s),y=new Blob([n],{type:o}),w=URL.createObjectURL(y);window.open(w),this.state.isLoadingPDF=!1},reload(){return this.$emit("reload")},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:"",in_out:"",time:null,description:"",attachment:"",allow_higher_approval:"",recommending_id:this.form.recommending_id,approver_id:this.form.approver_id}},async fetchApprover(){this.state.isLoading=!0,await z.fetchApproverRecords().then(t=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&t.data.map(e=>{this.form.allow_higher_approval?((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==3&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.approving==""&&e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")):((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""))}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&t.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&t.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.state.isLoading=!1}).catch(t=>{console.log(t)})},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 he().shape({date:M().required("Date from is required"),time:M().nullable().required("Time from is required")}).validate(this.form,{abortEarly:!1}),this.$swal.fire({title:"Are you sure you want to save this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.saveRecord()})}catch(t){if(t instanceof B){const e={};t.inner.forEach(o=>{e[o.path]=o.message}),this.errors=e}this.state.isSaving=!1}}},mounted(){this.fetchApprover()},watch:{"form.allow_higher_approval":{handler:"fetchApprover",immediate:!0}}},Ce={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Ae={key:0,class:"text-[#ec4899]"},ke={class:"relative"},Re={key:0,class:"text-[#ec4899]"},Fe={class:"grid grid-cols-1"},Be={class:"grid grid-cols-1"},Se={key:0,class:"text-[#ec4899]"},Te={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},De={class:"flex justify-between w-full items-center"},Ie={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},Ve={class:"grid grid-cols-12 gap-4"},Oe={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},Ee={class:"flex-shrink-0 mr-4"},Me=["src"],Ue={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Pe={class:"text-left"},je={class:"text-sm font-semibold text-gray-600"},Le={class:"text-lg font-bold text-gray-900"},Ge={key:0,class:"text-sm text-gray-900"},qe={key:1,class:"text-sm text-gray-900"},ze={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},He={class:"flex-shrink-0 mr-4"},Ne=["src"],We={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Ye={class:"text-left"},$e={class:"text-lg font-bold text-gray-900"},Qe={class:"text-sm text-gray-900"},Je={class:"flex gap-2 justify-between"},Ze={class:"flex items-center cursor-pointer"},Ke=["checked"],Xe={class:"flex gap-2"};function et(t,e,o,r,s,n){const y=c("Loading"),w=c("Alert"),d=c("flat-pickr"),v=c("FormGroup"),A=c("Multiselect"),k=c("Textarea"),x=c("Fileinput"),R=c("Card"),F=c("FileType"),b=c("Icon"),f=c("SubmitButton"),J=c("UpdateButton"),Z=c("CloseButton"),K=c("FormModal");return a(),p(K,{title:s.state.isEdit?"Edit Time Adjustment":"Time Adjustment Application Form",active:s.state.showModal,onSubmit:t.confirmSubmit,onClose:n.closeModal,themeClass:s.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:h(()=>[s.state.isEdit&&s.state.isLoading?(a(),p(y,{key:0,text:"Fetching record"})):m("",!0),s.state.isLoading?(a(),p(y,{key:1,text:"Fetching Approver"})):m("",!0),s.form.denied_reason?(a(),p(w,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:h(()=>[e[9]||(e[9]=i("span",{class:"font-semibold"},"Denied Reason:",-1)),C(" "+g(s.form.denied_reason),1)]),_:1})):m("",!0),i("div",Ce,[i("form",{onSubmit:e[8]||(e[8]=U((..._)=>t.confirmSubmit&&t.confirmSubmit(..._),["prevent"])),class:"space-y-6",enctype:"multipart/form-data"},[s.state.isSaving?(a(),p(y,{key:0,text:"Saving record"})):m("",!0),i("div",null,[l(v,{label:"Date",isRequired:!0},{default:h(()=>[l(d,{modelValue:s.form.date,"onUpdate:modelValue":e[0]||(e[0]=_=>s.form.date=_),class:"form-control h-12",id:"date",placeholder:"yyyy, dd M"},null,8,["modelValue"]),s.errors.date?(a(),u("div",Ae,"Date is required")):m("",!0)]),_:1})]),l(v,{label:"Int / Out"},{default:h(()=>[i("div",ke,[l(A,{modelValue:s.form.in_out,"onUpdate:modelValue":e[1]||(e[1]=_=>s.form.in_out=_),"close-on-select":!0,searchable:!0,id:"in_out",options:s.inOutOptions},null,8,["modelValue","options"])])]),_:1}),i("div",null,[l(v,{label:"Time",isRequired:!0},{default:h(()=>[l(d,{modelValue:s.form.time,"onUpdate:modelValue":e[2]||(e[2]=_=>s.form.time=_),class:"form-control h-12",placeholder:"Time",config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue"]),s.errors.time?(a(),u("div",Re,"Time is required")):m("",!0)]),_:1})]),i("div",Fe,[i("div",Be,[l(v,{label:"Remarks"},{default:h(()=>[l(k,{placeholder:"Remarks",modelValue:s.form.description,"onUpdate:modelValue":e[3]||(e[3]=_=>s.form.description=_)},null,8,["modelValue"])]),_:1})]),i("div",null,[l(v,{label:"Attachment"},{default:h(()=>[l(R,{title:"File Input Basic"},{default:h(()=>[l(x,{modelValue:s.form.attachment,"onUpdate:modelValue":e[4]||(e[4]=_=>s.form.attachment=_),name:"basic",onChange:n.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),s.errors.attachment?(a(),u("div",Se,g(s.errors.attachment),1)):m("",!0)]),_:1}),typeof s.form.attachment=="string"&&s.form.attachment?(a(),u("div",Te,[i("div",De,[i("div",{class:"flex items-center cursor-pointer",onClick:e[5]||(e[5]=_=>n.viewAttachment(s.form.attachment))},[l(F,{image:n.getFileTypeImage(s.form.attachment)},null,8,["image"]),C(" "+g(s.form.attachment),1)]),s.form.status==0?(a(),u("div",Ie,[l(b,{icon:"mingcute:delete-2-fill",onClick:e[6]||(e[6]=_=>n.deleteFile(s.form.id))})])):m("",!0)])])):m("",!0)]),_:1})])]),i("div",Ve,[i("div",Oe,[i("div",Ee,[s.recommending_img?(a(),u("img",{key:0,src:s.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Me)):(a(),u("div",Ue," No Image "))]),i("div",Pe,[i("div",je,g(s.form.allow_higher_approval?"Recommending":"Approving"),1),i("div",Le,g(s.recommending),1),s.form.allow_higher_approval?(a(),u("div",Ge,g(s.form.recommended_at?"Date: ("+this.$formatDate(s.form.recommended_at)+")":""),1)):(a(),u("div",qe,g(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1))])]),s.form.allow_higher_approval?(a(),u("div",ze,[i("div",He,[s.approving_img?(a(),u("img",{key:0,src:s.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Ne)):(a(),u("div",We," No Image "))]),i("div",Ye,[e[10]||(e[10]=i("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),i("div",$e,g(s.approving),1),i("div",Qe,g(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1)])])):m("",!0)]),i("div",Je,[i("div",null,[i("label",Ze,[ne(i("input",{type:"checkbox",class:"peer h-6 w-6 cursor-pointer rounded-full bg-slate-100 border border-slate-300 checked:bg-blue-500 checked:border-blue-500",checked:s.form.allow_higher_approval,"onUpdate:modelValue":e[7]||(e[7]=_=>s.form.allow_higher_approval=_)},null,8,Ke),[[ae,s.form.allow_higher_approval]]),e[11]||(e[11]=i("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[i("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",stroke:"currentColor","stroke-width":"1"},[i("path",{"fill-rule":"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z","clip-rule":"evenodd"})])],-1)),e[12]||(e[12]=i("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])]),i("div",Xe,[s.state.isEdit?s.form.status===0?(a(),p(J,{key:1,onClick:n.submitForm},null,8,["onClick"])):m("",!0):(a(),p(f,{key:0,onClick:n.submitForm},null,8,["onClick"])),l(Z,{onClick:n.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const tt=I(be,[["render",et],["__scopeId","data-v-a0d40508"]]);const st={components:{FileType:W,DenyButton:we,FormModal:j,FormGroup:P,TextInput:L,Textarea:G,SubmitButton:O,UpdateButton:q,CloseButton:V,Loading:E,Multiselect:N,Icon:D,Checkbox:Y},data(){return{inOutOptions:[{value:0,label:"IN"},{value:1,label:"OUT"}],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:"",in_out:"",time:"",description:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isCompanyLoading:!1},fileIcons:{pdf:$,jpg:Q,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 H.Reader2("employee-overtime",t),o;if(t.endsWith(".pdf"))o="application/pdf";else if(t.endsWith(".png"))o="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))o="image/jpeg";else if(t.endsWith(".svg"))o="image/svg+xml";else throw new Error("Unsupported file type");const r=atob(e),s=new Array(r.length);for(let d=0;d<r.length;d++)s[d]=r.charCodeAt(d);const n=new Uint8Array(s),y=new Blob([n],{type:o}),w=URL.createObjectURL(y);window.open(w),this.state.isLoadingPDF=!1},async fetchCompanyRecords(){try{this.state.isCompanyLoading=!0,this.companyOptions=await xe()}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=!!this.form.meal,this.form.transportation=!!this.form.transportation,this.currentRecommendingId=t.recommending?t.recommending[0].employee_id:"",this.currentApprovingId=t.approving?t.approving[0].employee_id:"",this.recommending=t.recommending?t.recommending[0].firstname+" "+t.recommending[0].lastname:"",this.approving=t.approving?t.approving[0].firstname+" "+t.approving[0].lastname:"",this.currentRecommendingId==this.currentEmployeeId&&this.form.status<1?this.btnTitle="Submit For Approval":this.currentApprovingId==this.currentEmployeeId&&(this.btnTitle="Approve"),this.currentClassificationId>=3&&await z.fetchEmployeeApprover(t.employee_id).then(e=>{if(e.status==200)this.recommendingOptions=e.data.map((o,r)=>({value:o.employee_id,label:o.firstname+" "+o.lastname})),this.approvingOptions=e.data.filter(o=>o.classification_id>=3).map((o,r)=>({value:o.employee_id,label:o.firstname+" "+o.lastname}));else throw new Error("Failed to fetch employee approvers")})},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date:"",in_out:"",time:"",description:"",attachment:"",recommending_id:"",approver_id:""}},reload(){return this.state.isSaving=!1,this.state.showModal=!1,this.$emit("reload")},async updateApproverRecord(){this.state.isSaving=!0;const t=this.form.id;this.state.isSaving=!1;let e={recommending_id:this.form.recommending_id,approver_id:this.form.approver_id};await T.updateApprover(t,e).then(o=>{o.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(o=>{o.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:o.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},async saveRecord(){this.state.isSaving=!0;const t=this.form.id;await T.update(t,this.status).then(e=>{e.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(e=>{e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},async submitForm(){this.form.recommending_id==this.currentEmployeeId&&(this.status={status:1}),this.form.approver_id==this.currentEmployeeId&&(this.status={status:2});try{this.$swal.fire({title:"Are you sure you want to save submit this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(t=>{t.value&&this.saveRecord()})}catch(t){if(t instanceof B){const e={};t.inner.forEach(o=>{e[o.path]=o.message}),this.errors=e}}},async updateApproverForm(){try{this.$swal.fire({title:"Are you sure you want to update the approver of this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(t=>{t.value&&this.updateApproverRecord()})}catch(t){if(t instanceof B){const e={};t.inner.forEach(o=>{e[o.path]=o.message}),this.errors=e}}},async denyForm(){this.status={status:99};try{this.$swal.fire({title:"Are you sure you want to deny this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No",html:` <textarea id="swal-input" style="width: 100%; height: 80px; padding: 8px; border: 1px solid #ced4da; border-radius: 4px;" placeholder="Enter reason"></textarea>`,preConfirm:()=>{const t=document.getElementById("swal-input").value;return t?this.denied_reason=t:(this.$swal.showValidationMessage("The reason field is required"),!1)}}).then(t=>{this.status={status:99,denied_reason:this.denied_reason},t.value&&this.saveRecord()})}catch(t){if(t instanceof B){const e={};t.inner.forEach(o=>{e[o.path]=o.message}),this.errors=e}}},async ReceiveByHr(t){try{if(t==99){const e=await this.$swal.fire({title:"State the Reason for Deferring this Request",input:"textarea",inputPlaceholder:"Enter your reason here...",inputAttributes:{"aria-label":"Reason for deferment"},showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Submit",cancelButtonText:"Cancel",preConfirm:o=>o||(this.$swal.showValidationMessage("Reason is required!"),!1)});e.isConfirmed&&e.value&&(console.log("Reason for deferment:",e.value),this.updateRecordByHR(t,e.value))}else this.$swal.fire({title:"Are you sure you want to receive/validate this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&(console.log("recieved by HR"),this.updateRecordByHR(t))})}catch(e){if(e instanceof B){const o={};e.inner.forEach(r=>{o[r.path]=r.message}),this.errors=o}}},async updateRecordByHR(t,e=null){this.state.isSaving=!0;const o=this.form.id;let s={status:t,reason:e};await T.hrValidation(o,s).then(n=>{n.status==201?(console.log("response"),console.log(n),this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3})):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(n=>{n.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:n.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.state.isSaving=!1})}},mounted(){this.fetchCompanyRecords()},watch:{}},it={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},ot={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"},rt={class:"text-red-600 dark:text-red-400 text-sm"},nt={key:0,class:"text-[#ec4899]"},at={class:"relative"},lt={class:"grid grid-cols-1"},ct={class:"grid grid-cols-1"},mt={class:"col-span-6"},dt={key:1},ft={class:"grid grid-cols-12 justify-center items-center"},ut={class:"col-span-8 flex justify-between items-center gap-4"},ht={class:"col-span-6 flex justify-center items-center gap-4"},pt={class:"font-bold"},gt={class:"col-span-6 flex justify-center items-center gap-4"},_t={class:"font-bold"},yt={key:2},vt={class:"grid grid-cols-12 gap-4"},wt={class:"col-span-6"},xt={class:"relative"},bt={class:"col-span-6"},Ct={class:"relative"},At={class:"flex gap-1 justify-end pt-8"},kt={key:0,class:"flex gap-1 justify-end"},Rt={key:1,class:"flex gap-1 justify-end"};function Ft(t,e,o,r,s,n){const y=c("Loading"),w=c("flat-pickr"),d=c("FormGroup"),v=c("Multiselect"),A=c("Textarea"),k=c("FileType"),x=c("UpdateButton"),R=c("DenyButton"),F=c("CloseButton"),b=c("FormModal");return a(),p(b,{title:"View Record",active:s.state.showModal,sideTitle:this.form.status==0?"for recommendation":this.form.status==1?"for approval":this.form.status==2&&this.form.validated==1?"Approved & Validated":this.form.status==2&&this.form.validated==99?"Denied":this.form.status==2?"For Validation":this.form.status==99?"denied":"",badgeColor:this.form.status==0?"warning":this.form.status==1?"info":this.form.status==2&&this.form.validated==1?"success":this.form.status==2&&this.form.validated==99?"danger":this.form.status==2?"purple":this.form.status==99?"danger":"",onSubmit:t.confirmSubmit,onClose:n.closeModal,themeClass:"bg-gray-800",sizeClass:"lg:w-3/4"},{default:h(()=>[s.state.isEdit&&s.state.isLoading?(a(),p(y,{key:0,text:"Fetching record"})):m("",!0),i("div",it,[this.form.status==2&&this.form.validated==99?(a(),u("div",ot,[e[10]||(e[10]=i("h3",{class:"text-red-700 dark:text-red-300 font-semibold mb-1 text-sm"}," Denied Reason : ",-1)),i("p",rt,g(s.form.deferred_reason),1)])):m("",!0),i("form",{onSubmit:e[9]||(e[9]=U((...f)=>t.confirmSubmit&&t.confirmSubmit(...f),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[s.state.isSaving?(a(),p(y,{key:0,text:"Saving record"})):m("",!0),i("div",null,[l(d,{label:"Date",isRequired:!0},{default:h(()=>[l(w,{modelValue:s.form.date,"onUpdate:modelValue":e[0]||(e[0]=f=>s.form.date=f),class:"form-control h-12",id:"date",placeholder:"yyyy, dd M"},null,8,["modelValue"]),s.errors.date?(a(),u("div",nt,g(s.errors.date),1)):m("",!0)]),_:1})]),l(d,{label:"Int / Out"},{default:h(()=>[i("div",at,[l(v,{modelValue:s.form.in_out,"onUpdate:modelValue":e[1]||(e[1]=f=>s.form.in_out=f),"close-on-select":!0,searchable:!0,id:"in_out",options:s.inOutOptions},null,8,["modelValue","options"])])]),_:1}),i("div",null,[l(d,{label:"Time"},{default:h(()=>[l(w,{modelValue:s.form.time,"onUpdate:modelValue":e[2]||(e[2]=f=>s.form.time=f),class:"form-control h-12",placeholder:"time",config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue"])]),_:1})]),i("div",lt,[i("div",ct,[l(d,{label:"Remarks"},{default:h(()=>[l(A,{placeholder:"Remarks",modelValue:s.form.description,"onUpdate:modelValue":e[3]||(e[3]=f=>s.form.description=f)},null,8,["modelValue"])]),_:1})]),i("div",mt,[l(d,{label:"Attachment"},{default:h(()=>[typeof s.form.attachment=="string"?(a(),u("div",{key:0,class:"flex items-center gap-2 mt-2 cursor-pointer",onClick:e[4]||(e[4]=f=>n.viewAttachment(s.form.attachment))},[l(k,{image:n.getFileTypeImage(s.form.attachment)},null,8,["image"]),C(" "+g(s.form.attachment),1)])):m("",!0)]),_:1})])]),s.currentClassificationId<=2?(a(),u("div",dt,[i("div",ft,[i("div",ut,[i("div",ht,[e[11]||(e[11]=C(" Recommending: ")),i("p",pt,g(s.recommending),1)]),i("div",gt,[e[12]||(e[12]=C(" Approving: ")),i("p",_t,g(s.approving),1)])])])])):(a(),u("div",yt,[i("div",vt,[i("div",wt,[l(d,{label:"Recommending"},{default:h(()=>[i("div",xt,[l(v,{modelValue:s.form.recommending_id,"onUpdate:modelValue":e[5]||(e[5]=f=>s.form.recommending_id=f),"close-on-select":!0,searchable:!0,id:"recommending_id",options:s.recommendingOptions},null,8,["modelValue","options"])])]),_:1})]),i("div",bt,[l(d,{label:"Approver"},{default:h(()=>[i("div",Ct,[l(v,{modelValue:s.form.approver_id,"onUpdate:modelValue":e[6]||(e[6]=f=>s.form.approver_id=f),"close-on-select":!0,searchable:!0,id:"approver_id",options:s.approvingOptions},null,8,["modelValue","options"])])]),_:1})])])])),i("div",At,[this.form.status==0&&s.currentRecommendingId==s.currentEmployeeId||s.currentApprovingId==s.currentEmployeeId&&this.form.status==1&&s.currentApprovingId==this.form.approver_id||this.form.approver_id==this.form.recommending_id&&s.currentApprovingId==this.form.approver_id&&s.currentEmployeeId==this.form.approver_id?(a(),u("div",kt,[this.form.status<=1?(a(),p(x,{key:0,onClick:n.submitForm,text:s.btnTitle},null,8,["onClick","text"])):m("",!0),this.form.status<=1?(a(),p(R,{key:1,onClick:n.denyForm,text:"Deny"},null,8,["onClick"])):m("",!0)])):this.form.status==0&&s.currentApprovingId==s.currentEmployeeId||s.currentApprovingId!=this.form.approver_id?(a(),u("div",Rt,[this.form.status<=1?(a(),p(x,{key:0,onClick:n.updateApproverForm,text:"Update Approver"},null,8,["onClick"])):m("",!0)])):m("",!0),this.form.status===2&&this.form.validated==0?(a(),p(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[7]||(e[7]=f=>n.ReceiveByHr(1)),text:"Receive"})):m("",!0),this.form.status===2&&this.form.validated==0?(a(),p(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[8]||(e[8]=f=>n.ReceiveByHr(99)),text:"Defer"})):m("",!0),l(F,{onClick:n.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["active","sideTitle","badgeColor","onSubmit","onClose"])}const Bt=I(st,[["render",Ft],["__scopeId","data-v-da24711a"]]);const St={mixins:[X],components:{FilterTimekeeping:le,ActionCellRenderer:ue,ActionCellRendererApprover:ve,AgGridVue:ye,Pagination:_e,Card:te,Button:se,Badge:ie,Layout:ee,Icon:D,CreateButton:ce,SubmitButton:O,CloseButton:V,EditButton:de,DeleteButton:me,ViewButton:fe,Form:tt,InputGroup:oe,Loading:E,View:Bt},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 & time",filter:!0,floatingFilter:!0,flex:2},{field:"in/out",filter:!0,floatingFilter:!0,flex:2},{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=>{switch(t.value){case"For Recommendation":return'<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>';case"For Approval":return'<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>';case"Validated":return'<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>';case"Deferred by HR":return'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-red-600 px-4">Denied</div>';case"Approved":return'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-green-600 px-4">For Validation</div>';case"Denied":return'<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>';default:return""}}},{headerName:"Actions",cellRenderer:"ActionCellRendererApprover",flex:1,cellRendererParams:{context:{componentParent:this}}}],breadcrumbs:[{text:"Home",href:"/"},{text:"Timekeeping",href:"/attendance/employee-overtime"},{text:"Time Adjustment Application",active:!0}],statistics:[{title:"Time Adjusted",subtitle:"For this month",count:"20",bg:"bg-info-500",text:"text-info-500",icon:"heroicons-outline:menu-alt-1"}],statuses:[{count:1,status:"Pending"},{count:2,status:"Approved"},{count:1,status:"Denied"}],columns:[{label:"#",field:"#"},{label:"Date",field:"date"},{label:"Time",field:"time"},{label:"IN / OUT",field:"in_out"},{label:"Remarks",field:"description"},{label:"Status",field:"status"},{label:"Action",field:"action"}],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],items:[],totalItems:0,searchQuery:null,serverOptions:{page:1,rowsPerPage:10,sortBy:"status",sortType:"asc"},state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:re.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{applyFilters(t){this.fetchRecords(t)},onGridReady(t){this.gridApi=t.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(t=>t.field!=="actions").map(t=>t.field)}):console.error("Grid API is not ready.")},formatTime(t){let[e,o]=t.split(":");e=parseInt(e);const r=e>=12;return e=e%12||12,`${e}:${o} ${r?"PM":"AM"}`},formatDate(t){const e=new Date(t),o=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),r=new Date(o.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),s=r.getFullYear(),n=String(r.getMonth()+1).padStart(2,"0"),y=String(r.getDate()).padStart(2,"0");return`${s}-${n}-${y}`},async fetchRecords(t={}){this.state.isLoading=!0,await S.fetchRecordList({dealership:this.$store.userSettings.activeDealership,...t}).then(e=>{let o=e.data.data;this.items=o,console.log("DATA"),console.log(o),this.items=o.map((r,s)=>({...r,"#":s+1,employee_id:r.employee_id,name:r.employee.lastname+", "+r.employee.firstname,"date & time":this.$formatDate(r.date)+" - "+this.$formatTime(r.time),"in/out":r.in_out==1?"OUT":"IN","date created":this.$formatDate(r.created_at),status:r.status})),this.totalItems=e.data.total}).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(o=>{o.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.fetchRecords(),this.state.isDeleting=!1})},createRecord(){this.$refs.form.resetForm(),this.$refs.form.state.showModal=!0},editRecord(t){console.log(t),this.$refs.form.resetForm(),this.$refs.form.loadRecord(t),this.$refs.form.state.showModal=!0},viewRecord(t){console.log(t),this.$refs.view.resetForm(),this.$refs.view.loadRecord(t),this.$refs.view.state.showModal=!0},handlePageChange(t){console.log(t),console.log(this.serverOptions.page),this.serverOptions.page!=t&&(this.serverOptions.page=t)},handlePerPageChange(t){this.serverOptions.page=1,this.serverOptions.rowsPerPage=t}},mounted(){this.fetchRecords()}},Tt={class:"space-y-4 mt-4"},Dt={class:"flex items-center justify-between mb-4"},It={class:"text-lg font-semibold"},Vt={class:"relative"},Ot={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},Et={class:"flex items-center justify-center gap-4 text-gray-900"},Mt={class:"flex items-center gap-4"},Ut={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function Pt(t,e,o,r,s,n){const y=c("FilterTimekeeping"),w=c("Icon"),d=c("Button"),v=c("ag-grid-vue"),A=c("Card"),k=c("Loading"),x=c("View"),R=c("Form"),F=c("Layout");return a(),p(F,{breadcrumbs:s.breadcrumbs},{default:h(()=>[i("div",Tt,[l(A,{title:"Time Adjustment Applications"},{default:h(()=>{var b;return[i("div",Dt,[i("h6",It,g(t.title),1)]),i("div",Vt,[i("div",Ot,[i("div",Et,g(((b=this.$store.userSettings.dealershipAccess.find(f=>f.id==this.$store.userSettings.activeDealership))==null?void 0:b.name)+" - REQUESTED TIME ADJUSTMENT"||"REQUESTED TIME ADJUSTMENT"),1),i("div",Mt,[l(y,{onFilterChanged:n.applyFilters},null,8,["onFilterChanged"]),l(d,{icon:"mdi:microsoft-excel",text:"Export to CSV",btnClass:"relative overflow-hidden font-normal px-4 py-2 rounded-lg shadow-md bg-white text-gray-900 border group transition-colors duration-300 group-hover:border-green-500",iconClass:"text-2xl",onClick:n.exportToCsv},{default:h(()=>[e[2]||(e[2]=i("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),i("span",Ut,[l(w,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[1]||(e[1]=C(" Export to CSV "))])]),_:1},8,["onClick"])])])]),l(v,{ref:"agGrid",rowData:s.items,columnDefs:s.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:s.paginationPageSize,paginationPageSizeSelector:s.paginationPageSizeSelector,onGridReady:n.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])]}),_:1}),s.state.isLoading?(a(),p(k,{key:0,text:"Fetching records"})):m("",!0),l(x,{onCloseModal:s.state.showModal,ref:"view",onReload:n.fetchRecords},null,8,["onCloseModal","onReload"]),l(R,{onCloseModal:e[0]||(e[0]=b=>s.state.showModal=!1),ref:"form",onReload:n.fetchRecords},null,8,["onReload"])])]),_:1},8,["breadcrumbs"])}const Xs=I(St,[["render",Pt],["__scopeId","data-v-a3fbc4ff"]]);export{Xs as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings