File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.b9bd2bbf.js
Back
import{n as z,w as O,L as H}from"./index.09b28a7f.js";import{C as G}from"./index.5a868516.js";import{B as q}from"./index.95db1698.js";import{B as $}from"./index.ae1bb6da.js";import{I}from"./index.163ce270.js";import{I as N}from"./index.fd1302f6.js";import"./lodash.7ba26c92.js";import{a as x,_ as U,r as m,o as a,c as v,w as f,j as g,d as r,b as c,t as h,k as Y,e as l,f as E,F as k,m as A,h as B}from"./index.3a0d1437.js";import{E as W}from"./EmployeeUndertimeService.b91143d6.js";import{C as M}from"./CloseButton.f9c39bb8.js";import{D as Z}from"./DeleteButton.3eb26d6c.js";import{E as J}from"./EditButton.f8156944.js";/* empty css */import{S as L}from"./SubmitButton.53a3866c.js";import{V as K}from"./ViewButton.dc0ba0bc.js";import"./jspdf.es.min.a68db437.js";/* empty css *//* empty css */import"./vue-cleave.min.da4c1c61.js";import{V as D}from"./array.057dff5d.js";import{L as j}from"./Loading.2fa16091.js";import"./vue-quill.snow.08c5baab.js";/* empty css */import{F as Q}from"./index.5338216a.js";import{F as X}from"./index.4888d65f.js";import{T as ee}from"./index.53519759.js";import{T as te}from"./index.e6d15a49.js";import{D as oe}from"./DenyButton.b86f5692.js";import{U as se}from"./UpdateButton.161928d8.js";import{A as re}from"./ApproverService.c958b637.js";import{F as ie}from"./FileService.9a8ade8c.js";import{M as ne}from"./Multiselect.4d70245a.js";import{F as ae}from"./index.b440e312.js";import{C as le}from"./index.30a24c9f.js";import{p as ce,j as de}from"./scr-1.d9aaecca.js";import{P as me}from"./index.ceaa4080.js";import{A as pe}from"./main.esm.51ee4e77.js";import{A as ue}from"./ActionCellRendererApprover.a30e06c8.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";const b="https://staging-ahg-hr-api.autohub.ph/api/v1/undertime-approval",fe="https://staging-ahg-hr-api.autohub.ph/api/v1/update-undertime-approval",T={fetchRecords(e={}){return x.get(`${b}`,{params:e})},fetchRecord(e){return x.get(`${b}/${e}`)},async create(e){return x.post(`${b}`,e)},async update(e,t){return x.put(`${b}/${e}`,t)},async updateApprover(e,t){return x.put(`${fe}/${e}`,t)},async remove(e){return x.delete(`${b}/${e}`)}};const he={components:{FileType:ae,DenyButton:oe,FormModal:X,FormGroup:Q,TextInput:ee,Textarea:te,SubmitButton:L,UpdateButton:se,CloseButton:M,Loading:j,Multiselect:ne,Icon:I,Checkbox:le},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:"",recommendings:"",approvings:"",isApprover:"",status:[],form:{date:"",from_from:"",to_time:"",hours:"",description:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},fileIcons:{pdf:ce,jpg:de,default:""},noImage:z}},methods:{getFileTypeImage(e){if(typeof e=="string"){if(!e)return this.fileIcons.default;const t=e.substring(e.lastIndexOf(".")+1).toLowerCase();return this.fileIcons[t]||this.fileIcons.default}},async viewAttachment(e){if(this.state.isDownloading)return;this.state.isDownloading=!0;let t=await ie.Reader2("employee-overtime",e),o;if(e.endsWith(".pdf"))o="application/pdf";else if(e.endsWith(".png"))o="image/png";else if(e.endsWith(".jpg")||e.endsWith(".jpeg"))o="image/jpeg";else if(e.endsWith(".svg"))o="image/svg+xml";else throw new Error("Unsupported file type");const n=atob(t),s=new Array(n.length);for(let p=0;p<n.length;p++)s[p]=n.charCodeAt(p);const d=new Uint8Array(s),u=new Blob([d],{type:o}),y=URL.createObjectURL(u);window.open(y),this.state.isLoadingPDF=!1},handleMainImageUpload(){const e=event.target.files[0];this.form.attachment=e;const t=new FileReader;t.onload=()=>{e.type.startsWith("image/")?this.form.imageView=t.result:e.type==="application/pdf"?this.form.imageView=this.pdf_file_view:e.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(e),t.readAsDataURL(e)},async loadRecord(e){this.resetForm(),this.form=e,this.form.date=new Date(e.date).toLocaleDateString("en-CA").split("T")[0],this.currentRecommendingId=e.recommending?e.recommending[0].employee_id:"",this.currentApprovingId=e.approving?e.approving[0].employee_id:"",this.recommending=e.recommending?e.recommending[0].firstname+" "+e.recommending[0].lastname:"",this.approving=e.approving?e.approving[0].firstname+" "+e.approving[0].lastname:"",this.recommendings=e.employee_approver.filter(o=>o.is_approver==0).map(o=>{var n;return{...o,name:o.employee.firstname+" "+o.employee.lastname,employee_id:o.employee.employee_id,attachment:((n=o==null?void 0:o.employee_profile_approver)==null?void 0:n.attachment)||""}}),this.approvings=e.employee_approver.filter(o=>o.is_approver==1).map(o=>{var n;return{...o,name:o.employee.firstname+" "+o.employee.lastname,employee_id:o.employee.employee_id,attachment:((n=o==null?void 0:o.employee_profile_approver)==null?void 0:n.attachment)||""}});const t=e.employee_approver.find(o=>o.signatory_id==this.currentEmployeeId);this.isApprover=t?t.is_approver:{},console.log("is recommendings?",this.recommendings),console.log("is approvers?",this.approvings),console.log("is approvers22222?",this.isApprover),this.isApprover&&this.form.approver_id==this.currentEmployeeId?this.btnTitle="Approve":!this.isApprover&&this.form.status<1&&(this.btnTitle="Submit For Approval"),this.currentClassificationId>=3&&await re.fetchEmployeeApprover(e.employee_id).then(o=>{if(o.status==200)this.recommendingOptions=o.data.map((n,s)=>({value:n.employee_id,label:n.firstname+" "+n.lastname})),this.approvingOptions=o.data.filter(n=>n.classification_id>=3).map((n,s)=>({value:n.employee_id,label:n.firstname+" "+n.lastname}));else throw new Error("Failed to fetch employee approvers")})},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date:"",from_time:"",to_time:"",hours:"",description:"",attachment:"",recommending_id:"",approver_id:""}},reload(){return this.$emit("reload")},async updateApproverRecord(){this.state.isSaving=!0;const e=this.form.id;this.state.isSaving=!1;let t={recommending_id:this.form.recommending_id,approver_id:this.form.approver_id};await T.updateApprover(e,t).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 e=this.form.id;await T.update(e,this.status).then(t=>{t.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(t=>{t.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:t.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(e=>{e.value&&this.saveRecord()})}catch(e){if(e instanceof D){const t={};e.inner.forEach(o=>{t[o.path]=o.message}),this.errors=t}}},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(e=>{e.value&&this.updateApproverRecord()})}catch(e){if(e instanceof D){const t={};e.inner.forEach(o=>{t[o.path]=o.message}),this.errors=t}}},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 e=document.getElementById("swal-input").value;return e?this.denied_reason=e:(this.$swal.showValidationMessage("The reason field is required"),!1)}}).then(e=>{this.status={status:99,denied_reason:this.denied_reason},e.value&&this.saveRecord()})}catch(e){if(e instanceof D){const t={};e.inner.forEach(o=>{t[o.path]=o.message}),this.errors=t}}},calculateHours(){const e=this.form.from_time,t=this.form.to_time;if(e&&t){const[o,n]=this.form.from_time.split(":").map(Number),[s,d]=this.form.to_time.split(":").map(Number);let u=s-o;u+=(d-n)/60,u<0&&(u+=24),this.form.hours=u}}},mounted(){},watch:{"form.from_time":{handler:"calculateHours",immediate:!0},"form.to_time":{handler:"calculateHours",immediate:!0}}},ge={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},_e={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"},ve={class:"text-red-600 dark:text-red-400 text-sm"},ye={class:"grid grid-cols-12 gap-4"},xe={class:"col-span-6"},we={class:"col-span-6"},be={class:"col-span-6"},Ce={class:"col-span-6"},ke={class:"col-span-12"},Ae={class:"col-span-12"},Fe={key:1},Se={class:"grid grid-cols-2 gap-4"},Re={class:"flex items-center p-4 bg-gray-100 rounded-lg shadow-md mb-2"},Ve={class:"flex-shrink-0 mr-4"},De=["src"],Be={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Te=["src"],Ie={class:"text-left"},Ue={class:"text-sm font-semibold text-gray-600"},Ee={class:"text-lg font-bold text-gray-900"},Me={key:0,class:"text-sm text-gray-900"},Le={key:1,class:"text-sm text-gray-900"},je={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md mb-2"},Pe={class:"flex-shrink-0 mr-4"},ze=["src"],Oe={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},He=["src"],Ge={class:"text-left"},qe={class:"text-lg font-bold text-gray-900"},$e={class:"text-sm text-gray-900"},Ne={key:2,class:""},Ye={class:"grid grid-cols-12 gap-4 mb-12"},We={class:"col-span-6"},Ze={class:"relative"},Je={class:"col-span-6"},Ke={class:"relative"},Qe={class:"flex gap-1 justify-end pt-8"},Xe={key:0,class:"flex gap-1 justify-end"},et={key:1,class:"flex gap-1 justify-end"};function tt(e,t,o,n,s,d){const u=m("Loading"),y=m("flat-pickr"),p=m("FormGroup"),F=m("TextInput"),S=m("FileType"),R=m("Textarea"),C=m("Multiselect"),_=m("UpdateButton"),V=m("DenyButton"),w=m("CloseButton"),P=m("FormModal");return a(),v(P,{title:"Undertime - View Record",active:s.state.showModal,sideTitle:this.form.status==0?"for recommendation":this.form.status==1?"for approval":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?"success":this.form.status==99?"danger":"",onSubmit:e.confirmSubmit,onClose:d.closeModal,themeClass:"bg-gray-800",sizeClass:"lg:w-2/4"},{default:f(()=>[s.state.isEdit&&s.state.isLoading?(a(),v(u,{key:0,text:"Fetching record"})):g("",!0),r("div",ge,[this.form.status==2&&this.form.validated==99?(a(),c("div",_e,[t[9]||(t[9]=r("h3",{class:"text-red-700 dark:text-red-300 font-semibold mb-1 text-sm"}," Denied Reason : ",-1)),r("p",ve,h(this.form.deferred_reason),1)])):g("",!0),r("form",{onSubmit:t[8]||(t[8]=Y((...i)=>e.confirmSubmit&&e.confirmSubmit(...i),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[s.state.isSaving?(a(),v(u,{key:0,text:"Saving record"})):g("",!0),r("div",ye,[r("div",xe,[l(p,{label:"Date",isRequired:!0},{default:f(()=>[l(y,{modelValue:s.form.date,"onUpdate:modelValue":t[0]||(t[0]=i=>s.form.date=i),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1})]),r("div",we,[l(p,{label:"From Time",isRequired:!0},{default:f(()=>[l(y,{class:"form-control h-[48px]",placeholder:"From time",modelValue:s.form.from_time,"onUpdate:modelValue":t[1]||(t[1]=i=>s.form.from_time=i),onChange:d.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),r("div",be,[l(p,{label:"To Time",isRequired:!0},{default:f(()=>[l(y,{class:"form-control h-[48px]",placeholder:"To time",modelValue:s.form.to_time,"onUpdate:modelValue":t[2]||(t[2]=i=>s.form.to_time=i),onChange:d.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),r("div",Ce,[l(p,{label:"Hours"},{default:f(()=>[l(F,{type:"text",modelValue:s.form.hours,"onUpdate:modelValue":t[3]||(t[3]=i=>s.form.hours=i),error:s.errors.hours,classInput:"h-[48px]",isReadonly:!0},null,8,["modelValue","error"])]),_:1})]),r("div",ke,[l(p,{label:"Attachment"},{default:f(()=>[typeof s.form.attachment=="string"?(a(),c("div",{key:0,class:"flex items-center gap-2 mt-2 cursor-pointer",onClick:t[4]||(t[4]=i=>d.viewAttachment(s.form.attachment))},[l(S,{image:d.getFileTypeImage(s.form.attachment)},null,8,["image"]),E(" "+h(s.form.attachment),1)])):g("",!0)]),_:1})]),r("div",Ae,[l(p,{label:"Remarks"},{default:f(()=>[l(R,{name:"pn4",placeholder:"Textarea",modelValue:s.form.description,"onUpdate:modelValue":t[5]||(t[5]=i=>s.form.description=i)},null,8,["modelValue"])]),_:1})])]),s.currentClassificationId<=2?(a(),c("div",Fe,[r("div",Se,[r("div",null,[(a(!0),c(k,null,A(s.recommendings,i=>(a(),c("div",{key:i.employee_id},[r("div",Re,[r("div",Ve,[i.attachment?(a(),c("img",{key:0,src:i.attachment,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,De)):(a(),c("div",Be,[r("img",{src:s.noImage,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Te)]))]),r("div",Ie,[r("div",Ue,h(s.form.allow_higher_approval?"Recommending":"Approving"),1),r("div",Ee,h(i.name),1),s.form.allow_higher_approval?(a(),c("div",Me,h(s.form.recommended_at?"Date: ("+this.$formatDate(s.form.recommended_at)+")":""),1)):(a(),c("div",Le,h(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1))])])]))),128))]),r("div",null,[r("div",null,[(a(!0),c(k,null,A(s.approvings,i=>(a(),c("div",{key:i.employee_id},[s.form.allow_higher_approval?(a(),c("div",je,[r("div",Pe,[i.attachment?(a(),c("img",{key:0,src:i.attachment,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,ze)):(a(),c("div",Oe,[r("img",{src:s.noImage,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,He)]))]),r("div",Ge,[t[10]||(t[10]=r("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),r("div",qe,h(i.name),1),r("div",$e,h(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1)])])):g("",!0)]))),128))])])])])):(a(),c("div",Ne,[r("div",Ye,[r("div",We,[l(p,{label:"Recommending"},{default:f(()=>[r("div",Ze,[l(C,{modelValue:s.form.recommending_id,"onUpdate:modelValue":t[6]||(t[6]=i=>s.form.recommending_id=i),"close-on-select":!0,searchable:!0,id:"recommending_id",options:s.recommendingOptions},null,8,["modelValue","options"])])]),_:1})]),r("div",Je,[l(p,{label:"Approver"},{default:f(()=>[r("div",Ke,[l(C,{modelValue:s.form.approver_id,"onUpdate:modelValue":t[7]||(t[7]=i=>s.form.approver_id=i),"close-on-select":!0,searchable:!0,id:"approver_id",options:s.approvingOptions},null,8,["modelValue","options"])])]),_:1})])])])),r("div",Qe,[this.form.status==0&&s.recommendings.some(i=>i.signatory_id==s.currentEmployeeId)||s.approvings.some(i=>i.signatory_id==s.currentEmployeeId)&&this.form.status==1&&s.approvings.some(i=>i.signatory_id==this.form.approver_id)||this.form.approver_id==this.form.recommending_id&&s.approvings.some(i=>i.signatory_id==this.form.approver_id)&&s.currentEmployeeId==this.form.approver_id?(a(),c("div",Xe,[this.form.status<=1?(a(),v(_,{key:0,onClick:d.submitForm,text:s.btnTitle},null,8,["onClick","text"])):g("",!0),this.form.status<=1?(a(),v(V,{key:1,onClick:d.denyForm,text:"Deny"},null,8,["onClick"])):g("",!0)])):this.form.status==0&&this.isApprover?(a(),c("div",et,[this.form.status<=1?(a(),v(_,{key:0,onClick:d.updateApproverForm,text:"Update Approver"},null,8,["onClick"])):g("",!0)])):g("",!0),l(w,{onClick:d.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["active","sideTitle","badgeColor","onSubmit","onClose"])}const ot=U(he,[["render",tt],["__scopeId","data-v-31c3f313"]]);const st={mixins:[O],components:{ActionCellRendererApprover:ue,AgGridVue:pe,Pagination:me,Card:G,Button:q,Badge:$,Layout:H,Icon:I,ViewButton:K,SubmitButton:L,CloseButton:M,EditButton:J,DeleteButton:Z,View:ot,InputGroup:N,Loading:j},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",filter:!0,floatingFilter:!0,flex:2},{field:"time coverage",filter:!0,floatingFilter:!0,flex:2},{field:"date created",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,filter:!0,floatingFilter:!0,valueGetter:e=>{switch(e.data.status){case 0:return"For Recommendation";case 1:return"For Approval";case 2:return e.data.validated==1?"Validated":e.data.validated==99?"Denied":"For Validation";case 99:return"Denied";default:return""}},cellRenderer:e=>{switch(e.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"For Validation":return'<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>';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">Validated</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-undertime"},{text:"Undertime Application",active:!0}],statistics:[{title:"Pending",count:[{total:0}],bg:"bg-primary-500",text:"text-primary-500",percent:"1.67% ",icon:"heroicons-outline:clock"},{title:"Approved",count:[{total:0}],bg:"bg-info-500",text:"text-info-500",percent:"25.67% ",icon:"heroicons-outline:menu-alt-1"},{title:"Denied",count:[{total:0}],bg:"bg-warning-500",text:"text-warning-500",percent:"8.67%",icon:"heroicons-outline:chart-pie"}],items:[],state:{isLoading:!1,isEdit:!1,isDeleting:!1,showModal:!1}}},methods:{formatTime(e){let[t,o]=e.split(":");t=parseInt(t);const n=t>=12;return t=t%12||12,`${t}:${o} ${n?"PM":"AM"}`},formatDate(e){const t=new Date(e),o=new Date(t.toLocaleString("en-US",{timeZone:"UTC"})),n=new Date(o.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),s=n.getFullYear(),d=String(n.getMonth()+1).padStart(2,"0"),u=String(n.getDate()).padStart(2,"0");return`${s}-${d}-${u}`},async fetchRecords(){this.state.isLoading=!0,await T.fetchRecords().then(e=>{let t=e.data.data;this.items=t,this.items=t.map((o,n)=>(this.statistics[0].count[0].total=o.pending,this.statistics[1].count[0].total=o.approved,this.statistics[2].count[0].total=o.denied,{...o,"#":n+1,"employee id":o.employee_id,name:o.employee.firstname+" "+o.employee.lastname,date:this.$formatDate(o.date),"time coverage":this.$formatTime(o.from_time)+" - "+this.$formatTime(o.to_time)+" ("+o.hours+" Hours)","date created":this.$formatDate(o.created_at),status:o.status}))}).finally(()=>{this.state.isLoading=!1})},reload(){this.state.showModal=!1,this.$emit("reload")},closeModal(){this.state.showModal=!1},async deleteRecord(e){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(t=>{console.log(t.value),t.value&&(this.state.isDeleting=!0,W.remove(e).then(o=>{o.status==200&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.fetchRecords())}))}).catch(t=>{t.response&&t.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})},viewRecord(e){console.log(e),this.$refs.view.resetForm(),this.$refs.view.loadRecord(e),this.$refs.view.state.showModal=!0}},mounted(){this.fetchRecords()}},rt={class:"space-y-4 mt-4"},it={class:"flex-1 md:mb-0 mb-3"},nt={class:"grid grid-cols-1 gap-4 pb-4 md:grid-cols-3"},at={class:B("h-14 w-14 flex items-center justify-center rounded-md text-4xl mb-4 shadow-lg bg-white")},lt={class:"text-md font-semibold text-slate-700 dark:text-white mb-2"},ct={class:"flex justify-center gap-4"},dt={class:"text-xs font-medium text-slate-500 dark:text-white mb-1"},mt={class:"text-2xl text-slate-900 dark:text-white font-semibold"},pt={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},ut={class:"flex items-center gap-4"},ft={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function ht(e,t,o,n,s,d){const u=m("Icon"),y=m("Button"),p=m("ag-grid-vue"),F=m("Card"),S=m("Loading"),R=m("View"),C=m("Layout");return a(),v(C,{breadcrumbs:s.breadcrumbs},{default:f(()=>[r("div",rt,[l(F,{title:"Undertime Applications"},{default:f(()=>[r("h6",it,h(e.title),1),r("div",nt,[(a(!0),c(k,null,A(s.statistics,(_,V)=>(a(),c("div",{key:V,class:B([_.bg,"flex flex-col items-center rounded-lg p-2 bg-opacity-[0.15] dark:bg-opacity-50 text-center shadow-md hover:shadow-xl transition-transform transform hover:scale-101 w-full"])},[r("div",at,[l(u,{icon:_.icon,class:B(["text-2xl",_.text])},null,8,["icon","class"])]),r("div",lt,h(_.title),1),r("div",ct,[(a(!0),c(k,null,A(_.count,w=>(a(),c("div",{key:w.type},[r("div",dt,h(w.type),1),r("div",mt,h(w.total),1)]))),128))])],2))),128))]),r("div",pt,[t[2]||(t[2]=r("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," Undertime Lists ",-1)),r("div",ut,[l(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:e.exportToCsv},{default:f(()=>[t[1]||(t[1]=r("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),r("span",ft,[l(u,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),t[0]||(t[0]=E(" Export to CSV "))])]),_:1},8,["onClick"])])]),l(p,{ref:"agGrid",rowData:s.items,columnDefs:s.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:s.paginationPageSize,paginationPageSizeSelector:s.paginationPageSizeSelector,onGridReady:e.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])]),_:1}),s.state.isLoading?(a(),v(S,{key:0,text:"Fetching records"})):g("",!0),l(R,{onCloseModal:d.closeModal,ref:"view",onReload:d.fetchRecords},null,8,["onCloseModal","onReload"])])]),_:1},8,["breadcrumbs"])}const lo=U(st,[["render",ht],["__scopeId","data-v-07615c8b"]]);export{lo as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings