File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.414f955e.js
Back
import{w as X,L as ee}from"./index.09b28a7f.js";import{C as te}from"./index.5a868516.js";import{B as se}from"./index.95db1698.js";import{B as ie}from"./index.ae1bb6da.js";import{I as D}from"./index.163ce270.js";import{I as oe}from"./index.fd1302f6.js";import"./lodash.7ba26c92.js";import{_ as V,A as ne,r as l,o as c,c as y,w as m,j as p,d as o,f as x,t as g,k as L,e as a,b as u,p as re,s as ae}from"./index.3a0d1437.js";import{E as R}from"./EmployeeWfhService.2c3f8002.js";import{C as T}from"./CloseButton.f9c39bb8.js";import{C as le}from"./CreateButton.83988a87.js";import{D as ce}from"./DeleteButton.3eb26d6c.js";import{E as de}from"./EditButton.f8156944.js";/* empty css */import{S as I}from"./SubmitButton.53a3866c.js";import{V as me}from"./ViewButton.dc0ba0bc.js";import{A as fe}from"./ActionCellRenderer.012f772e.js";/* empty css */import"./vue-cleave.min.da4c1c61.js";import{c as he,a as E,V as A}from"./array.057dff5d.js";import{L as M}from"./Loading.2fa16091.js";import"./vue-quill.snow.08c5baab.js";/* empty css */import{F as U}from"./index.5338216a.js";import{F as j}from"./index.4888d65f.js";import{T as O}from"./index.53519759.js";import{T as W}from"./index.e6d15a49.js";import{U as P}from"./UpdateButton.161928d8.js";import"./jspdf.es.min.a68db437.js";/* empty css */import{A as H}from"./ApproverService.c958b637.js";import{F as z}from"./FileService.9a8ade8c.js";import{M as G}from"./Multiselect.4d70245a.js";import{F as ue}from"./index.a504f7c5.js";import{F as q}from"./index.b440e312.js";import{C as Y}from"./index.30a24c9f.js";import{A as pe}from"./index.f6898162.js";import{p as $,j as N}from"./scr-1.d9aaecca.js";import{P as ge}from"./index.ceaa4080.js";import{A as _e}from"./main.esm.51ee4e77.js";import{D as we}from"./DenyButton.b86f5692.js";import{W as B}from"./WfhApprovalService.6d688aec.js";import{F as ye}from"./index.efca9d49.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.eb053693.js";import"./EmployeeService.0d36c049.js";import"./es.string.replace.6e729815.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.717f943d.js";import"./index.57af9821.js";import"./ck-white.4bf441fa.js";import"./index.463da3d2.js";const ve={components:{Alert:pe,FileType:q,Fileinput:ue,FormModal:j,FormGroup:U,TextInput:O,Textarea:W,SubmitButton:I,UpdateButton:P,CloseButton:T,Loading:M,Multiselect:G,Icon:D,Checkbox:Y},data(){return{isWfh:!1,wfhStatus:"",recommending:"",recommending_img:"",approving:"",approving_img:"",form:{date:new Date,hours:8,destination:"",description:"",attachment:"",recommending_id:"",allow_higher_approval:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},fileIcons:{pdf:$,jpg:N,default:""}}},methods:{deleteFile(t){this.$swal.fire({title:"Are you sure you want remove the attachment?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.deleteFileAttachment()}),console.log("wawawawa",t)},async deleteFileAttachment(){const t=this.form.id,e=this.form.attachment,i={id:t,attachment:e};await R.removeAttachment(i).then(n=>{n.status==201?(this.$swal.fire({title:"Great!",text:"Attachment successfully deleted.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.form.attachment="",console.log("null dapat",this.form.attachment)):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(n=>{n.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:n.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},getFileTypeImage(t){if(typeof t=="string"){if(!t)return this.fileIcons.default;const e=t.substring(t.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(t){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await z.Reader2("employee-overtime",t),i;if(t.endsWith(".pdf"))i="application/pdf";else if(t.endsWith(".png"))i="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))i="image/jpeg";else if(t.endsWith(".svg"))i="image/svg+xml";else throw new Error("Unsupported file type");const n=atob(e),s=new Array(n.length);for(let d=0;d<n.length;d++)s[d]=n.charCodeAt(d);const r=new Uint8Array(s),f=new Blob([r],{type:i}),_=URL.createObjectURL(f);window.open(_),this.state.isLoadingPDF=!1},handleMainImageUpload(){const t=event.target.files[0];this.form.attachment=t;const e=new FileReader;e.onload=()=>{t.type.startsWith("image/")?this.form.imageView=e.result:t.type==="application/pdf"?this.form.imageView=this.pdf_file_view:t.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(t),e.readAsDataURL(t)},loadRecord(t){this.resetForm(),this.state.isEdit=!0,this.form=t,this.form.date=new Date(t.date).toLocaleDateString("en-CA").split("T")[0],this.wfhStatus=t.status,console.log(this.wfhStatus)},closeModal(){this.state.showModal=!1},resetForm(){this.wfhStatus="",this.state.isEdit=!1,this.form={date:new Date,hours:8,destination:"",description:"",attachment:"",allow_higher_approval:"",recommending_id:this.form.recommending_id,approver_id:this.form.approver_id}},async fetchApprover(){this.state.isLoading=!0,await H.fetchApproverRecords().then(t=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&t.data.map(e=>{this.form.allow_higher_approval?((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==3&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.approving==""&&e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")):((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""))}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&t.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&t.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.state.isLoading=!1}).catch(t=>{console.log(t)})},reload(){return this.$emit("reload")},async saveRecord(){if(this.state.isSaving=!0,this.state.isEdit){this.state.isSaving=!1,this.form.id;let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),this.wfhStatus==2&&(console.log("Appending status: 3"),t.append("status","3")),console.log(this.wfhStatus),console.log("asd",t),await R.update(t).then(e=>{e.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(e=>{e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})}else{let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await R.create(t).then(e=>{e.status==201&&(this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3}),this.state.isSaving=!1,this.state.showModal=!1,this.resetForm(),this.reload())}).catch(e=>{console.log(e),e.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:e.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})}},async submitForm(){try{await he().shape({date:E().required("Date from is required"),hours:E().required("From time is required")}).validate(this.form,{abortEarly:!1}),this.$swal.fire({title:"Are you sure you want to save this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(e=>{e.value&&this.saveRecord()})}catch(t){if(t instanceof A){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},async checkifWfh(){this.state.isLoading=!0;let t={start_date:this.form.date,end_date:this.form.date};try{const e=await ne.fetchRecords(t);this.scheduleList=e.data.schedule?e.data.schedule:[];const i=new Date().toISOString().split("T")[0];this.scheduleList.filter(n=>n.date===this.form.date).map(n=>{n.title.includes("WFH")?(this.isWfh=!0,this.form.status=3):(this.isWfh=!1,this.form.status=0)}),this.state.isLoading=!1}catch(e){console.log(e)}}},mounted(){this.fetchApprover()},watch:{"form.allow_higher_approval":{handler:"fetchApprover",immediate:!0}}},xe={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},be={class:"grid grid-cols-12 gap-4"},Ce={class:"col-span-6"},Se={class:"col-span-6"},ke={class:"col-span-12"},Fe={key:0,class:"col-span-12"},Ae={key:0,class:"text-[#ec4899]"},Re={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},Be={class:"flex justify-between w-full items-center"},De={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},Ve={class:"grid grid-cols-12 gap-4"},Te={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},Ie={class:"flex-shrink-0 mr-4"},Me=["src"],Ee={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Le={class:"text-left"},Ue={class:"text-sm font-semibold text-gray-600"},je={class:"text-lg font-bold text-gray-900"},Oe={key:0,class:"text-sm text-gray-900"},We={key:1,class:"text-sm text-gray-900"},Pe={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"},ze=["src"],Ge={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},qe={class:"text-left"},Ye={class:"text-lg font-bold text-gray-900"},$e={class:"text-sm text-gray-900"},Ne={class:"flex gap-2 justify-between"},Ze={class:"flex items-center cursor-pointer"},Ke=["checked"],Qe={class:"flex gap-2"};function Je(t,e,i,n,s,r){const f=l("Loading"),_=l("Alert"),d=l("flat-pickr"),v=l("FormGroup"),C=l("TextInput"),S=l("Textarea"),b=l("Fileinput"),k=l("Card"),F=l("FileType"),h=l("Icon"),Z=l("SubmitButton"),K=l("UpdateButton"),Q=l("CloseButton"),J=l("FormModal");return c(),y(J,{title:s.state.isEdit&&(s.wfhStatus==2||s.wfhStatus==0)?"Edit Wfh":s.wfhStatus==2?"Accomplishment Report Submission":"Wfh Application Form",active:s.state.showModal,onSubmit:t.confirmSubmit,onClose:r.closeModal,themeClass:s.state.isEdit&&(s.wfhStatus==2||s.wfhStatus==0)?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:m(()=>[s.state.isEdit&&s.state.isLoading?(c(),y(f,{key:0,text:"Fetching record"})):p("",!0),s.state.isLoading?(c(),y(f,{key:1,text:"Fetching record"})):p("",!0),s.form.denied_reason?(c(),y(_,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:m(()=>[e[8]||(e[8]=o("span",{class:"font-semibold"},"Denied Reason:",-1)),x(" "+g(s.form.denied_reason),1)]),_:1})):p("",!0),o("div",xe,[o("form",{onSubmit:e[7]||(e[7]=L((...w)=>t.confirmSubmit&&t.confirmSubmit(...w),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[s.state.isSaving?(c(),y(f,{key:0,text:"Saving record"})):p("",!0),o("div",be,[o("div",Ce,[a(v,{label:"Date",isRequired:!0},{default:m(()=>[a(d,{modelValue:s.form.date,"onUpdate:modelValue":e[0]||(e[0]=w=>s.form.date=w),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M",disabled:!(s.wfhStatus.length==0||s.wfhStatus==0),onChange:r.checkifWfh},null,8,["modelValue","disabled","onChange"])]),_:1})]),o("div",Se,[a(v,{label:"Hours",isRequired:!0},{default:m(()=>[a(C,{type:"text",modelValue:s.form.hours,"onUpdate:modelValue":e[1]||(e[1]=w=>s.form.hours=w),error:s.errors.hours,classInput:"h-[48px]",disabled:!(s.wfhStatus.length==0||s.wfhStatus==2||s.wfhStatus==0)},null,8,["modelValue","error","disabled"])]),_:1})]),o("div",ke,[a(v,{label:"Remarks"},{default:m(()=>[a(S,{name:"pn4",placeholder:"Enter remarks....",modelValue:s.form.description,"onUpdate:modelValue":e[2]||(e[2]=w=>s.form.description=w),disabled:!(s.wfhStatus.length==0||s.wfhStatus==2||s.wfhStatus==0)},null,8,["modelValue","disabled"])]),_:1})]),s.isWfh&&s.wfhStatus.length==0||s.wfhStatus>=2?(c(),u("div",Fe,[a(v,{label:"Attachment"},{default:m(()=>[a(k,{title:"File Input Basic"},{default:m(()=>[a(b,{modelValue:s.form.attachment,"onUpdate:modelValue":e[3]||(e[3]=w=>s.form.attachment=w),name:"basic",onChange:r.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),s.errors.attachment?(c(),u("div",Ae,g(s.errors.attachment),1)):p("",!0)]),_:1}),typeof s.form.attachment=="string"&&s.form.attachment?(c(),u("div",Re,[o("div",Be,[o("div",{class:"flex items-center cursor-pointer",onClick:e[4]||(e[4]=w=>r.viewAttachment(s.form.attachment))},[a(F,{image:r.getFileTypeImage(s.form.attachment)},null,8,["image"]),x(" "+g(s.form.attachment),1)]),s.form.status==0?(c(),u("div",De,[a(h,{icon:"mingcute:delete-2-fill",onClick:e[5]||(e[5]=w=>r.deleteFile(s.form.id))})])):p("",!0)])])):p("",!0)]),_:1})])):p("",!0)]),o("div",Ve,[o("div",Te,[o("div",Ie,[s.recommending_img?(c(),u("img",{key:0,src:s.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Me)):(c(),u("div",Ee," No Image "))]),o("div",Le,[o("div",Ue,g(s.form.allow_higher_approval?"Recommending":"Approving"),1),o("div",je,g(s.recommending),1),s.form.allow_higher_approval?(c(),u("div",Oe,g(s.form.recommended_at?"Date: ("+this.$formatDate(s.form.recommended_at)+")":""),1)):(c(),u("div",We,g(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1))])]),s.form.allow_higher_approval?(c(),u("div",Pe,[o("div",He,[s.approving_img?(c(),u("img",{key:0,src:s.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,ze)):(c(),u("div",Ge," No Image "))]),o("div",qe,[e[9]||(e[9]=o("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),o("div",Ye,g(s.approving),1),o("div",$e,g(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1)])])):p("",!0)]),o("div",Ne,[o("div",null,[o("label",Ze,[re(o("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[6]||(e[6]=w=>s.form.allow_higher_approval=w)},null,8,Ke),[[ae,s.form.allow_higher_approval]]),e[10]||(e[10]=o("span",{class:"absolute text-white opacity-0 peer-checked:opacity-100"},[o("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"},[o("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[11]||(e[11]=o("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])]),o("div",Qe,[s.state.isEdit?s.form.status===0?(c(),y(K,{key:1,onClick:r.submitForm},null,8,["onClick"])):p("",!0):(c(),y(Z,{key:0,onClick:r.submitForm},null,8,["onClick"])),a(Q,{onClick:r.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const Xe=V(ve,[["render",Je],["__scopeId","data-v-333e090f"]]);const et={components:{FileType:q,DenyButton:we,FormModal:j,FormGroup:U,TextInput:O,Textarea:W,SubmitButton:I,UpdateButton:P,CloseButton:T,Loading:M,Multiselect:G,Icon:D,Checkbox:Y},data(){return{currentEmployeeId:this.$store.userSettings.getActiveUser.employees?this.$store.userSettings.getActiveUser.employees.employee_id:"",currentClassificationId:this.$store.userSettings.getActiveUser.employees?this.$store.userSettings.getActiveUser.employees.classification_id:"",currentRecommendingId:"",currentApprovingId:"",btnTitle:"",recommendingOptions:[],approvingOptions:[],recommending:"",approving:"",status:[],form:{date:"",hours:"",destination:"",description:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},fileIcons:{pdf:$,jpg:N,default:""}}},methods:{getFileTypeImage(t){if(typeof t=="string"){if(!t)return this.fileIcons.default;const e=t.substring(t.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[e]||this.fileIcons.default}},async viewAttachment(t){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await z.Reader2("employee-overtime",t),i;if(t.endsWith(".pdf"))i="application/pdf";else if(t.endsWith(".png"))i="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))i="image/jpeg";else if(t.endsWith(".svg"))i="image/svg+xml";else throw new Error("Unsupported file type");const n=atob(e),s=new Array(n.length);for(let d=0;d<n.length;d++)s[d]=n.charCodeAt(d);const r=new Uint8Array(s),f=new Blob([r],{type:i}),_=URL.createObjectURL(f);window.open(_),this.state.isLoadingPDF=!1},handleMainImageUpload(){const t=event.target.files[0];this.form.attachment=t;const e=new FileReader;e.onload=()=>{t.type.startsWith("image/")?this.form.imageView=e.result:t.type==="application/pdf"?this.form.imageView=this.pdf_file_view:t.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(t),e.readAsDataURL(t)},async loadRecord(t){this.resetForm(),this.form=t,this.form.date=new Date(t.date).toLocaleDateString("en-CA").split("T")[0],this.currentRecommendingId=t.recommending?t.recommending[0].employee_id:"",this.currentApprovingId=t.approving?t.approving[0].employee_id:"",this.recommending=t.recommending?t.recommending[0].firstname+" "+t.recommending[0].lastname:"",this.approving=t.approving?t.approving[0].firstname+" "+t.approving[0].lastname:"",this.currentRecommendingId==this.currentEmployeeId&&this.form.status<1||this.currentRecommendingId==this.currentEmployeeId&&this.form.status==3?this.btnTitle="Submit For Approval":this.currentApprovingId==this.currentEmployeeId&&(this.btnTitle="Approve"),this.currentClassificationId>=3&&await H.fetchEmployeeApprover(t.employee_id).then(e=>{if(e.status==200)this.recommendingOptions=e.data.map((i,n)=>({value:i.employee_id,label:i.firstname+" "+i.lastname})),this.approvingOptions=e.data.filter(i=>i.classification_id>=3).map((i,n)=>({value:i.employee_id,label:i.firstname+" "+i.lastname}));else throw new Error("Failed to fetch employee approvers")})},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date:"",hours:"",destination:"",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 B.updateApprover(t,e).then(i=>{i.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",icon:"success",timer:2e3}),this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3}),this.reload()}).catch(i=>{i.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:i.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},async saveRecord(){this.state.isSaving=!0;const t=this.form.id;await B.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(){if(this.form.recommending_id==this.currentEmployeeId){let t="";this.form.status==3?t=4:t=1,this.status={hours:this.form.hours,status:t}}this.form.approver_id==this.currentEmployeeId&&this.form.status<=1&&(this.status={status:2}),this.form.approver_id==this.currentEmployeeId&&this.form.status>=3&&(this.status={status:5});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 A){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},async updateApproverForm(){try{this.$swal.fire({title:"Are you sure you want to update the approver of this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(t=>{t.value&&this.updateApproverRecord()})}catch(t){if(t instanceof A){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},async denyForm(){this.status={status:99};try{this.$swal.fire({title:"Are you sure you want to deny this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No",html:` <textarea id="swal-input" style="width: 100%; height: 80px; padding: 8px; border: 1px solid #ced4da; border-radius: 4px;" placeholder="Enter reason"></textarea>`,preConfirm:()=>{const t=document.getElementById("swal-input").value;return t?this.denied_reason=t:(this.$swal.showValidationMessage("The reason field is required"),!1)}}).then(t=>{this.status={status:99,denied_reason:this.denied_reason},t.value&&this.saveRecord()})}catch(t){if(t instanceof A){const e={};t.inner.forEach(i=>{e[i.path]=i.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:i=>i||(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 A){const i={};e.inner.forEach(n=>{i[n.path]=n.message}),this.errors=i}}},async updateRecordByHR(t,e=null){this.state.isSaving=!0;const i=this.form.id;let s={status:t,reason:e};await B.hrValidation(i,s).then(r=>{r.status==201?(console.log("response"),console.log(r),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(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}),this.state.isSaving=!1})}},mounted(){}},tt={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},st={key:0,class:"bg-red-50 dark:bg-red-900 dark:bg-opacity-30 border-l-4 border-red-500 p-4 rounded-md shadow-sm"},it={class:"text-red-600 dark:text-red-400 text-sm"},ot={class:"grid grid-cols-12 gap-4"},nt={class:"col-span-6"},rt={class:"col-span-6"},at={class:"col-span-12"},lt={key:1},ct={class:"grid grid-cols-12 justify-center items-center"},dt={class:"col-span-8 flex justify-between items-center gap-4"},mt={class:"col-span-6 flex justify-center items-center gap-4"},ft={class:"font-bold"},ht={class:"col-span-6 flex justify-center items-center gap-4"},ut={class:"font-bold"},pt={key:2},gt={class:"grid grid-cols-12 gap-4"},_t={class:"col-span-6"},wt={class:"relative"},yt={class:"col-span-6"},vt={class:"relative"},xt={class:"flex gap-1 justify-end pt-8"};function bt(t,e,i,n,s,r){const f=l("Loading"),_=l("flat-pickr"),d=l("FormGroup"),v=l("TextInput"),C=l("Textarea"),S=l("FileType"),b=l("Multiselect"),k=l("CloseButton"),F=l("FormModal");return c(),y(F,{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?"approved":this.form.status==99?"denied":"",badgeColor:this.form.status==0?"warning":this.form.status==1?"info":this.form.status==2&&this.form.validated==1?"success":this.form.status==2&&this.form.validated==99?"danger":this.form.status==2?"success":this.form.status==99?"danger":"",onSubmit:t.confirmSubmit,onClose:r.closeModal,themeClass:"bg-gray-800",sizeClass:"lg:w-2/4"},{default:m(()=>[s.state.isEdit&&s.state.isLoading?(c(),y(f,{key:0,text:"Fetching record"})):p("",!0),o("div",tt,[this.form.status==2&&this.form.validated==99?(c(),u("div",st,[e[7]||(e[7]=o("h3",{class:"text-red-700 dark:text-red-300 font-semibold mb-1 text-sm"}," Denied Reason ",-1)),o("p",it,g(this.form.deferred_reason),1)])):p("",!0),o("form",{onSubmit:e[6]||(e[6]=L((...h)=>t.confirmSubmit&&t.confirmSubmit(...h),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[s.state.isSaving?(c(),y(f,{key:0,text:"Saving record"})):p("",!0),o("div",ot,[o("div",nt,[a(d,{label:"Date",isRequired:!0},{default:m(()=>[a(_,{modelValue:s.form.date,"onUpdate:modelValue":e[0]||(e[0]=h=>s.form.date=h),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M",disabled:!0},null,8,["modelValue"])]),_:1})]),o("div",rt,[a(d,{label:"Hours",isRequired:!0},{default:m(()=>[a(v,{type:"text",modelValue:s.form.hours,"onUpdate:modelValue":e[1]||(e[1]=h=>s.form.hours=h),error:s.errors.hours,classInput:"h-[48px]",disabled:!0},null,8,["modelValue","error"])]),_:1})]),o("div",at,[a(d,{label:"Remarks"},{default:m(()=>[a(C,{name:"pn4",placeholder:"Enter remarks....",modelValue:s.form.description,"onUpdate:modelValue":e[2]||(e[2]=h=>s.form.description=h),disabled:!0},null,8,["modelValue"])]),_:1})]),a(d,{label:"Attachment"},{default:m(()=>[typeof s.form.attachment=="string"?(c(),u("div",{key:0,class:"flex items-center gap-2 mt-2 cursor-pointer",onClick:e[3]||(e[3]=h=>r.viewAttachment(s.form.attachment))},[a(S,{image:r.getFileTypeImage(s.form.attachment)},null,8,["image"]),x(" "+g(s.form.attachment),1)])):p("",!0)]),_:1})]),s.currentClassificationId<=2?(c(),u("div",lt,[o("div",ct,[o("div",dt,[o("div",mt,[e[8]||(e[8]=x(" Recommending: ")),o("p",ft,g(s.recommending),1)]),o("div",ht,[e[9]||(e[9]=x(" Approving: ")),o("p",ut,g(s.approving),1)])])])])):(c(),u("div",pt,[o("div",gt,[o("div",_t,[a(d,{label:"Recommending"},{default:m(()=>[o("div",wt,[a(b,{modelValue:s.form.recommending_id,"onUpdate:modelValue":e[4]||(e[4]=h=>s.form.recommending_id=h),"close-on-select":!0,searchable:!0,id:"recommending_id",options:s.recommendingOptions},null,8,["modelValue","options"])])]),_:1})]),o("div",yt,[a(d,{label:"Approver"},{default:m(()=>[o("div",vt,[a(b,{modelValue:s.form.approver_id,"onUpdate:modelValue":e[5]||(e[5]=h=>s.form.approver_id=h),"close-on-select":!0,searchable:!0,id:"approver_id",options:s.approvingOptions},null,8,["modelValue","options"])])]),_:1})])])])),o("div",xt,[a(k,{onClick:r.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["active","sideTitle","badgeColor","onSubmit","onClose"])}const Ct=V(et,[["render",bt],["__scopeId","data-v-6d19ad05"]]);const St={mixins:[X],components:{FilterTimekeeping:ye,ActionCellRenderer:fe,AgGridVue:_e,Pagination:ge,Card:te,Button:se,Badge:ie,Layout:ee,Icon:D,CreateButton:le,SubmitButton:I,CloseButton:T,EditButton:de,ViewButton:me,DeleteButton:ce,Form:Xe,InputGroup:oe,Loading:M,View:Ct},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:1},{field:"date",filter:!0,floatingFilter:!0,flex:2},{field:"hours",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"For Validation";case 99:return"Denied";default:return""}},cellRenderer:t=>{const e=t.value,i=document.createElement("div");switch(e){case"For Recommendation":i.innerHTML='<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-yellow-600 bg-gray-100 px-4">For Recommendation</span>';break;case"For Approval":i.innerHTML='<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-blue-600 bg-gray-100 px-4">For Approval</span>';break;case"Validated":i.innerHTML='<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-green-600 px-4">Validated</div>';break;case"Deferred by HR":i.innerHTML=` <div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-red-600 px-4"> Denied <button class="ml-2 inline-flex items-center px-2 py-1 text-white text-sm font-medium rounded hover:bg-white-700 focus:ring-2 focus:ring-yellow-500 focus:outline-none view-button" title="View details of why it was deferred"> <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1 text-yellow-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"> <path stroke-linecap="round" stroke-linejoin="round" d="M10 4H4a2 2 0 00-2 2v12a2 2 0 002 2h16a2 2 0 002-2V8a2 2 0 00-2-2h-6l-2-2H10a2 2 0 00-2 2v0z" /> </svg> </button> </div>`,i.querySelector(".view-button").addEventListener("click",()=>{this.view(t.data)});break;case"For Validation":i.innerHTML='<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-fuchsia-600 px-4">For Validation</div>';break;case"Denied":i.innerHTML='<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-red-600 bg-gray-100 px-4">Denied</span>';break;default:i.innerHTML=""}return i}},{headerName:"Actions",cellRenderer:"ActionCellRenderer",flex:1,cellRendererParams:{context:{componentParent:this}}}],breadcrumbs:[{text:"Home",href:"/"},{text:"Timekeeping",href:"/attendance/wfh"},{text:"Wfh Application",active:!0}],items:[],totalItems:0,searchQuery:null,state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{},computed:{},methods:{applyFilters(t){if(!t||Object.keys(t).length===0){const e=new Date;let i=e.getFullYear(),n=e.getMonth()+1,s=n-1||12;s===12&&(i-=1);const r=n.toString().padStart(2,"0"),f=s.toString().padStart(2,"0"),_=e.getDate();t={range:_>1&&_<15?`${i}-${f}-21 to ${e.getFullYear()+1}-${r}-05`:`${e.getFullYear()}-${r}-06 to ${e.getFullYear()+1}-${r}-20`}}this.fetchRecords(t)},onGridReady(t){this.gridApi=t.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(t=>t.field!=="actions").map(t=>t.field)}):console.error("Grid API is not ready.")},formatDate(t){const e=new Date(t),i=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),n=new Date(i.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),s=n.getFullYear(),r=String(n.getMonth()+1).padStart(2,"0"),f=String(n.getDate()).padStart(2,"0");return`${s}-${r}-${f}`},async fetchRecords(t={}){this.state.isLoading=!0,await R.fetchRecords({...t}).then(e=>{console.log("response");let i=e.data.data;console.log(i),this.items=i,this.items=i.map((n,s)=>({...n,"#":s+1,date:this.$formatDate(n.date),hours:n.hours,"date created":this.$formatDate(n.created_at),status:n.status}))}).finally(()=>{this.state.isLoading=!1})},reload(){this.$emit("reload")},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,R.remove(t).then(i=>{i.status==201&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.applyFilters())}))}).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.reload(),this.state.isDeleting=!1})},createRecord(){this.$refs.form.resetForm(),this.$refs.form.state.showModal=!0},editRecord(t){console.log(t),this.$refs.form.resetForm(),this.$refs.form.loadRecord(t),this.$refs.form.state.showModal=!0},view(t){this.viewRecord(t)},viewRecord(t){console.log(t),this.$refs.view.resetForm(),this.$refs.view.loadRecord(t),this.$refs.view.state.showModal=!0}},mounted(){this.applyFilters()}},kt={class:"space-y-4 mt-4"},Ft={class:"flex items-center justify-between mb-4"},At={class:"text-lg font-semibold"},Rt={class:"relative"},Bt={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},Dt={class:"flex items-center gap-4"},Vt={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},Tt={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function It(t,e,i,n,s,r){const f=l("FilterTimekeeping"),_=l("Icon"),d=l("Button"),v=l("View"),C=l("ag-grid-vue"),S=l("Card"),b=l("Loading"),k=l("Form"),F=l("Layout");return c(),y(F,{breadcrumbs:s.breadcrumbs},{default:m(()=>[o("div",kt,[a(S,{title:"Wfh Applications"},{default:m(()=>[o("div",Ft,[o("h6",At,g(t.title),1)]),o("div",Rt,[o("div",Bt,[e[6]||(e[6]=o("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," WFH List ",-1)),o("div",Dt,[a(f,{onFilterChanged:r.applyFilters},null,8,["onFilterChanged"]),a(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:r.exportToCsv},{default:m(()=>[e[3]||(e[3]=o("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),o("span",Vt,[a(_,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[2]||(e[2]=x(" Export to CSV "))])]),_:1},8,["onClick"]),a(d,{icon:"heroicons-outline:plus-sm",text:"Add Record",btnClass:"relative overflow-hidden font-normal px-4 py-2 rounded-lg shadow-md bg-white text-gray-900 border group transition-colors duration-300 group-hover:border-gray-500 group-hover:border",iconClass:"text-lg",onClick:r.createRecord},{default:m(()=>[e[5]||(e[5]=o("span",{class:"absolute inset-0 bg-gray-900 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),o("span",Tt,[a(_,{icon:"heroicons-outline:plus-sm",class:"text-2xl mr-2"}),e[4]||(e[4]=x(" Add Record "))])]),_:1},8,["onClick"])])])]),a(v,{onCloseModal:e[0]||(e[0]=h=>s.state.showModal=!1),ref:"view",onReload:r.fetchRecords},null,8,["onReload"]),a(C,{ref:"agGrid",rowData:s.items,columnDefs:s.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:s.paginationPageSize,paginationPageSizeSelector:s.paginationPageSizeSelector,onGridReady:r.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])]),_:1}),s.state.isLoading?(c(),y(b,{key:0,text:"Fetching records"})):p("",!0),a(k,{onCloseModal:e[1]||(e[1]=h=>s.state.showModal=!1),ref:"form",onReload:r.applyFilters},null,8,["onReload"])])]),_:1},8,["breadcrumbs"])}const Ts=V(St,[["render",It],["__scopeId","data-v-927e6376"]]);export{Ts as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings