File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.68b764fe.js
Back
import{n as z,w as H,L as G}from"./index.ca4614c1.js";import{C as q}from"./index.4f06d02e.js";import{B as Y}from"./index.8a5f8558.js";import{B as N}from"./index.85943672.js";import{I as P}from"./index.1b36081b.js";import{I as W}from"./index.ae574076.js";import"./lodash.45138f16.js";import{_ as U,r as d,o as r,c as x,w as f,j as p,d as o,f as v,t as u,k as J,e as m,b as h,m as T,F as B,p as Z,s as K,h as R}from"./index.28ae41da.js";import{E as b}from"./EmployeeUndertimeService.6d193059.js";import{A as Q}from"./main.esm.9cee2c92.js";import{A as X}from"./ActionCellRenderer.4d4d9d35.js";import{C as I}from"./CloseButton.dacc4a7b.js";import{C as $}from"./CreateButton.7e6095de.js";import{D as ee}from"./DeleteButton.89d918f5.js";import{E as te}from"./EditButton.4c7b9ec2.js";/* empty css */import{S as M}from"./SubmitButton.be4371c4.js";import{V as se}from"./ViewButton.d67c4349.js";/* empty css */import"./vue-cleave.min.10e51f16.js";import{c as ie,a as D,V as oe}from"./array.19531b35.js";import{L as V}from"./Loading.fa197db1.js";import"./vue-quill.snow.464b7516.js";/* empty css */import{U as ne}from"./UpdateButton.a9e9b37b.js";import"./jspdf.es.min.cdd8e899.js";/* empty css */import{A as ae}from"./ApproverService.108289da.js";import{F as le}from"./FileService.09441775.js";import{F as re}from"./index.975c3902.js";import{F as me}from"./index.164dfd27.js";import{T as ce}from"./index.43beecaf.js";import{M as de}from"./Multiselect.3c2ca79b.js";import{F as he}from"./index.9a016648.js";import{F as fe}from"./index.d93f9125.js";import{A as ue}from"./index.e14b9ad3.js";import{C as ge}from"./index.008f577c.js";import{T as _e}from"./index.3178f5fc.js";import{p as pe,j as ye}from"./scr-1.d9aaecca.js";import{P as xe}from"./index.4d0f347c.js";import{F as we}from"./index.32e578cc.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.4769b1c9.js";import"./EmployeeService.67ccb7ea.js";import"./es.string.replace.a39053f7.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.e35c8e45.js";import"./index.17d4213d.js";import"./ck-white.4bf441fa.js";import"./index.50628127.js";const be={components:{Alert:ue,FileType:fe,Fileinput:he,FormModal:me,FormGroup:re,TextInput:ce,Textarea:_e,SubmitButton:M,UpdateButton:ne,CloseButton:I,Loading:V,Multiselect:de,Icon:P,Checkbox:ge},data(){return{recommending:"",recommendings:[],recommending_img:"",approving:"",approvings:[],approving_img:"",form:{date:"",from_from:"",to_time:"",hours:"",allow_higher_approval:"",description:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},fileIcons:{pdf:pe,jpg:ye,default:""},noImage:z}},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 b.removeAttachment(i).then(c=>{c.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(c=>{c.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:c.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 le.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 c=atob(e),s=new Array(c.length);for(let g=0;g<c.length;g++)s[g]=c.charCodeAt(g);const n=new Uint8Array(s),l=new Blob([n],{type:i}),_=URL.createObjectURL(l);window.open(_),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){console.log("s",t),this.resetForm(),this.state.isEdit=!0,this.form=t,this.form.date=new Date(t.date).toLocaleDateString("en-CA").split("T")[0],this.form.allow_higher_approval=t.allow_higher_approval==1},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date:"",from_time:"",to_time:"",hours:"",description:"",attachment:"",allow_higher_approval:"",recommending_id:this.form.recommending_id,approver_id:this.form.approver_id}},async fetchApprover(){this.approvings=[],this.recommendings=[],this.state.isLoading=!0,await ae.fetchApproverRecords().then(t=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&t.data.sort((e,i)=>e.classification_id-i.classification_id).map(e=>{this.form.allow_higher_approval?((e.classification_id==2||e.classification_id==1)&&!this.recommendings.some(i=>i.employee_id===e.employee_id)&&(this.recommendings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommendings.length===0&&e.classification_id==3&&!this.recommendings.some(i=>i.employee_id===e.employee_id)&&(this.recommendings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==3&&!this.approvings.some(i=>i.employee_id===e.employee_id)&&(this.approvings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.approvings.length===0&&e.classification_id==4&&!this.approvings.some(i=>i.employee_id===e.employee_id)&&(this.approvings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),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.recommendings.some(i=>i.employee_id===e.employee_id)||(this.recommendings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.approvings.some(i=>i.employee_id===e.employee_id)||(this.approvings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")),this.recommendings.length===0&&e.classification_id==3&&(this.recommendings.some(i=>i.employee_id===e.employee_id)||(this.recommendings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.approvings.some(i=>i.employee_id===e.employee_id)||(this.approvings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment: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.sort((e,i)=>e.classification_id-i.classification_id).map(e=>{e.classification_id==3&&(this.recommendings.some(i=>i.employee_id===e.employee_id)||(this.recommendings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"")),this.recommendings.length===0&&e.classification_id==4&&(this.recommendings.some(i=>i.employee_id===e.employee_id)||(this.recommendings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"")),e.classification_id==4&&(this.approvings.some(i=>i.employee_id===e.employee_id)||(this.approvings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment: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==3&&t.data.sort((e,i)=>e.classification_id-i.classification_id).map(e=>{e.classification_id==3&&(this.recommendings.some(i=>i.employee_id===e.employee_id)||(this.recommendings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"")),this.recommendings.length===0&&e.classification_id==4&&(this.recommendings.some(i=>i.employee_id===e.employee_id)||(this.recommendings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"")),e.classification_id==4&&(this.approvings.some(i=>i.employee_id===e.employee_id)||(this.approvings.push({name:e.firstname+" "+e.lastname,employee_id:e.employee_id,attachment:e.attachment||""}),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.isSaving=!0,this.state.isEdit){this.form.id;let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await b.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])}),t.append("approvings",JSON.stringify(this.approvings)),t.append("recommendings",JSON.stringify(this.recommendings)),await b.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 ie().shape({date:D().required("Date from is required"),from_time:D().required("From time is required"),to_time:D().required("To 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 oe){const e={};t.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},calculateHours(){const t=this.form.from_time,e=this.form.to_time;if(t&&e){const[i,c]=this.form.from_time.split(":").map(Number),[s,n]=this.form.to_time.split(":").map(Number);let l=s-i;l+=(n-c)/60,l<0&&(l+=24),this.form.hours=l}}},mounted(){this.fetchApprover()},watch:{"form.from_time":{handler:"calculateHours",immediate:!0},"form.to_time":{handler:"calculateHours",immediate:!0},"form.allow_higher_approval":{handler:"fetchApprover",immediate:!0}}},ve={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Fe={class:"grid grid-cols-12 gap-4"},Ce={class:"col-span-12"},ke={class:"col-span-5"},Ae={class:"col-span-5"},Se={class:"col-span-2"},De={class:"col-span-12"},Te={key:0,class:"text-[#ec4899]"},Be={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},Re={class:"flex justify-between w-full items-center"},Pe={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},Ue={class:"col-span-12"},Ie={class:"grid grid-cols-2 gap-4"},Me={class:"flex items-center p-4 bg-gray-100 rounded-lg shadow-md mb-2"},Ve={class:"flex-shrink-0 mr-4"},Oe=["src"],Le={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},je=["src"],Ee={class:"text-left"},ze={class:"text-sm font-semibold text-gray-600"},He={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"},Ye={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md mb-2"},Ne={class:"flex-shrink-0 mr-4"},We=["src"],Je={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Ze=["src"],Ke={class:"text-left"},Qe={class:"text-lg font-bold text-gray-900"},Xe={class:"text-sm text-gray-900"},$e={class:"flex gap-2 justify-between"},et={class:"flex items-center cursor-pointer"},tt=["checked","disabled"],st={class:"flex gap-2"};function it(t,e,i,c,s,n){const l=d("Loading"),_=d("Alert"),g=d("flat-pickr"),w=d("FormGroup"),F=d("TextInput"),C=d("Fileinput"),k=d("Card"),A=d("FileType"),y=d("Icon"),S=d("Textarea"),O=d("SubmitButton"),L=d("UpdateButton"),j=d("CloseButton"),E=d("FormModal");return r(),x(E,{title:s.form.status!==0?"Undertime Application Form":s.state.isEdit?"Edit Undertime":"Undertime Application Form",active:s.state.showModal,onSubmit:t.confirmSubmit,onClose:n.closeModal,themeClass:s.state.isEdit&&s.form.status==0?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:f(()=>[s.state.isEdit&&s.state.isLoading?(r(),x(l,{key:0,text:"Fetching record"})):p("",!0),s.state.isLoading?(r(),x(l,{key:1,text:"Fetching Approver"})):p("",!0),s.form.denied_reason?(r(),x(_,{key:2,type:"danger-light",icon:"heroicons-outline:exclamation",class:"mb-4"},{default:f(()=>[e[10]||(e[10]=o("span",{class:"font-semibold"},"Denied Reason:",-1)),v(" "+u(s.form.denied_reason),1)]),_:1})):p("",!0),o("div",ve,[o("form",{onSubmit:e[9]||(e[9]=J((...a)=>t.confirmSubmit&&t.confirmSubmit(...a),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[s.state.isSaving?(r(),x(l,{key:0,text:"Saving record"})):p("",!0),o("div",Fe,[o("div",Ce,[m(w,{label:"Date",isRequired:!0},{default:f(()=>[m(g,{modelValue:s.form.date,"onUpdate:modelValue":e[0]||(e[0]=a=>s.form.date=a),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M",disabled:s.form.status==2||s.form.status==1||s.form.status==99},null,8,["modelValue","disabled"])]),_:1})]),o("div",ke,[m(w,{label:"From Time",isRequired:!0},{default:f(()=>[m(g,{class:"form-control h-[48px]",placeholder:"From time",modelValue:s.form.from_time,"onUpdate:modelValue":e[1]||(e[1]=a=>s.form.from_time=a),onChange:n.calculateHours,disabled:s.form.status==2||s.form.status==1||s.form.status==99,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange","disabled"])]),_:1})]),o("div",Ae,[m(w,{label:"To Time",isRequired:!0},{default:f(()=>[m(g,{class:"form-control h-[48px]",placeholder:"To time",modelValue:s.form.to_time,"onUpdate:modelValue":e[2]||(e[2]=a=>s.form.to_time=a),onChange:n.calculateHours,disabled:s.form.status==2||s.form.status==1||s.form.status==99,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange","disabled"])]),_:1})]),o("div",Se,[m(w,{label:"Hours"},{default:f(()=>[m(F,{type:"text",modelValue:s.form.hours,"onUpdate:modelValue":e[3]||(e[3]=a=>s.form.hours=a),error:s.errors.hours,classInput:"h-[48px]",disabled:s.form.status==2||s.form.status==1||s.form.status==99,isReadonly:!0},null,8,["modelValue","error","disabled"])]),_:1})]),o("div",De,[m(w,{label:"Attachment"},{default:f(()=>[m(k,{title:"File Input Basic"},{default:f(()=>[m(C,{modelValue:s.form.attachment,"onUpdate:modelValue":e[4]||(e[4]=a=>s.form.attachment=a),name:"basic",onChange:n.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),s.errors.attachment?(r(),h("div",Te,u(s.errors.attachment),1)):p("",!0)]),_:1}),typeof s.form.attachment=="string"&&s.form.attachment?(r(),h("div",Be,[o("div",Re,[o("div",{class:"flex items-center cursor-pointer",onClick:e[5]||(e[5]=a=>n.viewAttachment(s.form.attachment))},[m(A,{image:n.getFileTypeImage(s.form.attachment)},null,8,["image"]),v(" "+u(s.form.attachment),1)]),s.form.status==0?(r(),h("div",Pe,[m(y,{icon:"mingcute:delete-2-fill",onClick:e[6]||(e[6]=a=>n.deleteFile(s.form.id))})])):p("",!0)])])):p("",!0)]),_:1})]),o("div",Ue,[m(w,{label:"Remarks"},{default:f(()=>[m(S,{name:"pn4",placeholder:"Input remarks here",disabled:s.form.status==2||s.form.status==1||s.form.status==99,modelValue:s.form.description,"onUpdate:modelValue":e[7]||(e[7]=a=>s.form.description=a)},null,8,["disabled","modelValue"])]),_:1})])]),o("div",Ie,[o("div",null,[(r(!0),h(B,null,T(s.recommendings,a=>(r(),h("div",{key:a.employee_id},[o("div",Me,[o("div",Ve,[a.attachment?(r(),h("img",{key:0,src:a.attachment,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Oe)):(r(),h("div",Le,[o("img",{src:s.noImage,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,je)]))]),o("div",Ee,[o("div",ze,u(s.form.allow_higher_approval?"Recommending":"Approving"),1),o("div",He,u(a.name),1),s.form.allow_higher_approval?(r(),h("div",Ge,u(s.form.recommended_at?"Date: ("+this.$formatDate(s.form.recommended_at)+")":""),1)):(r(),h("div",qe,u(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1))])])]))),128))]),o("div",null,[o("div",null,[(r(!0),h(B,null,T(s.approvings,a=>(r(),h("div",{key:a.employee_id},[s.form.allow_higher_approval?(r(),h("div",Ye,[o("div",Ne,[a.attachment?(r(),h("img",{key:0,src:a.attachment,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,We)):(r(),h("div",Je,[o("img",{src:s.noImage,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Ze)]))]),o("div",Ke,[e[11]||(e[11]=o("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),o("div",Qe,u(a.name),1),o("div",Xe,u(s.form.approved_at?"Date: ("+this.$formatDate(s.form.approved_at)+")":""),1)])])):p("",!0)]))),128))])])]),o("div",$e,[o("div",null,[o("label",et,[Z(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,disabled:s.form.status==2||s.form.status==1||s.form.status==99,"onUpdate:modelValue":e[8]||(e[8]=a=>s.form.allow_higher_approval=a)},null,8,tt),[[K,s.form.allow_higher_approval]]),e[12]||(e[12]=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[13]||(e[13]=o("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])]),o("div",st,[s.state.isEdit?s.form.status===0?(r(),x(L,{key:1,onClick:n.submitForm},null,8,["onClick"])):p("",!0):(r(),x(O,{key:0,onClick:n.submitForm},null,8,["onClick"])),m(j,{onClick:n.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const ot=U(be,[["render",it],["__scopeId","data-v-ddff69a7"]]);const nt={mixins:[H],components:{FilterTimekeeping:we,ActionCellRenderer:X,AgGridVue:Q,Pagination:xe,Card:q,Button:Y,Badge:N,Layout:G,Icon:P,CreateButton:$,SubmitButton:M,CloseButton:I,EditButton:te,DeleteButton:ee,ViewButton:se,Form:ot,InputGroup:W,Loading:V},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:1},{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,cellRenderer:t=>{const e=t.value,i=t.data.approver_id;return e===0?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-yellow-600 bg-gray-100 px-4">For Recommendation</span>':e===1?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-blue-600 bg-gray-100 px-4">For Approval</span>':e===2?'<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-green-600 px-4">Approved</div>':e===99?'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-red-600 bg-gray-100 px-4">Denied</span>':e===0||i==this.$store.userSettings.getActiveUser.employee_id?'<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>':""}},{headerName:"Actions",cellRenderer:"ActionCellRenderer",flex:1,cellRendererParams:{context:{componentParent:this}}}],breadcrumbs:[{text:"Home",href:"/"},{text:"Timekeeping",href:"/attendance/employee-undertime"},{text:"Undertime Application",active:!0}],statistics:[{title:"UT Hours",subtitle:"For this month",count:"0",bg:"bg-info-500",text:"text-info-500",icon:"heroicons-outline:menu-alt-1"},{title:"Average UT Hours",subtitle:"For this month",count:"0",bg:"bg-warning-500",text:"text-warning-500",icon:"heroicons-outline:chart-pie"},{title:"Total UT Hours",subtitle:"For this year",count:"0",bg:"bg-purple-500",text:"text-purple-500",icon:"fa6-solid:chart-bar"}],items:[],totalItems:0,searchQuery:null,serverOptions:{page:1,rowsPerPage:10,sortBy:"created_at",sortType:"asc"},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(),c=e.getMonth()+1,s=c-1||12;s===12&&(i-=1);const n=c.toString().padStart(2,"0"),l=s.toString().padStart(2,"0"),_=e.getDate();t={range:_>1&&_<15?`${i}-${l}-21 to ${e.getFullYear()+1}-${n}-05`:`${e.getFullYear()}-${n}-06 to ${e.getFullYear()+1}-${n}-20`}}this.fetchRecords(t)},onGridReady(t){this.gridApi=t.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(t=>t.field!=="actions").map(t=>t.field)}):console.error("Grid API is not ready.")},formatTime(t){let[e,i]=t.split(":");e=parseInt(e);const c=e>=12;return e=e%12||12,`${e}:${i} ${c?"PM":"AM"}`},formatDate(t){const e=new Date(t),i=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),c=new Date(i.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),s=c.getFullYear(),n=String(c.getMonth()+1).padStart(2,"0"),l=String(c.getDate()).padStart(2,"0");return`${s}-${n}-${l}`},async fetchRecords(t={}){this.state.isLoading=!0,await b.fetchRecords({...t}).then(e=>{console.log("response");let i=e.data.data.data,c=e.data.total_ut_for_the_month,s=e.data.total_ut_for_the_year,n=e.data.avg_ut_for_the_month;this.statistics[0].count=c.total_hours==null?0:c.total_hours,this.statistics[1].count=n,this.statistics[2].count=s.total_hours,this.items=i,this.items=i.map((l,_)=>({...l,"#":_+1,date:this.$formatDate(l.date),"time coverage":this.$formatTime(l.from_time)+" - "+this.$formatTime(l.to_time)+" ("+l.hours+" Hours)","date created":this.$formatDate(l.created_at),status:l.status}))}).finally(()=>{this.state.isLoading=!1})},reload(){this.$emit("reload")},handlePageChange(t){console.log(t),console.log(this.serverOptions.page),this.serverOptions.page!=t&&(this.serverOptions.page=t)},handlePerPageChange(t){this.serverOptions.page=1,this.serverOptions.rowsPerPage=t},onSortChange(t){console.log(t),t[0].type!="none"&&(this.serverOptions.sortBy=t[0].field,this.serverOptions.sortType=t[0].type)},async deleteRecord(t){this.$swal.fire({title:"Are you sure?",text:"You want to delete this record?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes, delete it!",background:this.$store.themeSettingsStore.isDark?"#1e293b":"#fff"}).then(e=>{console.log(e.value),e.value&&(this.state.isDeleting=!0,b.remove(t).then(i=>{i.status==200&&(this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.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.applyFilters(),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},handlePageChange(t){console.log(t),console.log(this.serverOptions.page),this.serverOptions.page!=t&&(this.serverOptions.page=t)},handlePerPageChange(t){this.serverOptions.page=1,this.serverOptions.rowsPerPage=t}},mounted(){this.applyFilters()}},at={class:"space-y-4 mt-4"},lt={class:"flex items-center justify-between"},rt={class:"text-2xl font-bold text-slate-900 dark:text-white"},mt={class:"grid grid-cols-1 gap-4 pb-4 md:grid-cols-3"},ct={class:R("h-14 w-14 flex items-center justify-center rounded-md text-4xl mb-4 shadow-lg bg-white")},dt={class:"text-sm font-semibold text-slate-600 dark:text-white mb-2"},ht={class:"flex justify-center gap-4"},ft={class:"block text-sm text-slate-500 dark:text-white mb-1"},ut={class:"block mb- text-xl text-slate-900 dark:text-white font-medium"},gt={class:"relative"},_t={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},pt={class:"flex items-center gap-4"},yt={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},xt={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function wt(t,e,i,c,s,n){const l=d("Icon"),_=d("FilterTimekeeping"),g=d("Button"),w=d("ag-grid-vue"),F=d("Card"),C=d("Loading"),k=d("Form"),A=d("Layout");return r(),x(A,{breadcrumbs:s.breadcrumbs},{default:f(()=>[o("div",at,[m(F,{title:"Undertime Applications"},{default:f(()=>[o("div",lt,[o("h2",rt,u(t.title),1)]),o("div",mt,[(r(!0),h(B,null,T(s.statistics,(y,S)=>(r(),h("div",{key:S,class:R([y.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"])},[o("div",ct,[m(l,{icon:y.icon,class:R(["text-2xl",y.text])},null,8,["icon","class"])]),o("div",dt,u(y.title),1),o("div",ht,[o("div",ft,u(y.subtitle),1),o("div",null,[o("span",ut,u(y.count),1)])])],2))),128))]),o("div",gt,[o("div",_t,[e[5]||(e[5]=o("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," Requested overtime ",-1)),o("div",pt,[m(_,{onFilterChanged:n.applyFilters},null,8,["onFilterChanged"]),m(g,{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:f(()=>[e[2]||(e[2]=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",yt,[m(l,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[1]||(e[1]=v(" Export to CSV "))])]),_:1},8,["onClick"]),m(g,{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:n.createRecord},{default:f(()=>[e[4]||(e[4]=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",xt,[m(l,{icon:"heroicons-outline:plus-sm",class:"text-2xl mr-2"}),e[3]||(e[3]=v(" Add Record "))])]),_:1},8,["onClick"])])])]),m(w,{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?(r(),x(C,{key:0,text:"Fetching records"})):p("",!0),m(k,{onCloseModal:e[0]||(e[0]=y=>s.state.showModal=!1),ref:"form",onReload:n.applyFilters},null,8,["onReload"])])]),_:1},8,["breadcrumbs"])}const ps=U(nt,[["render",wt],["__scopeId","data-v-96cb2b67"]]);export{ps as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.05 |
proxy
|
phpinfo
|
Settings