File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.21cef1c0.js
Back
import{w as M,L}from"./index.e90b797d.js";import{C as j}from"./index.609bcb7c.js";import{B as H}from"./index.1e572db2.js";import{B as z}from"./index.8925dff3.js";import{I as D}from"./index.a5110576.js";import{I as G}from"./index.d1aceaee.js";import{l as q}from"./lodash.adf89e63.js";import{_ as R,r as a,o as m,c as _,w as f,j as p,d as o,f as T,t as h,k as N,e as n,b as g,p as W,s as Y}from"./index.3a33b88d.js";import{E as b}from"./EmployeeUndertimeService.7d45dcd6.js";import{A as Q}from"./main.esm.786d3a20.js";import{A as Z}from"./ActionCellRenderer.3c622cae.js";import{F as K}from"./index.cb60a4a1.js";import{C as B}from"./CloseButton.d312e091.js";import{C as J}from"./CreateButton.96a43e5c.js";import{D as X}from"./DeleteButton.3d4df072.js";import{E as $}from"./EditButton.5d564d58.js";/* empty css */import{S as P}from"./SubmitButton.16c237a6.js";import{V as ee}from"./ViewButton.a3057bdc.js";import{F as te}from"./index.f8c90c2f.js";import{F as ie}from"./index.8531a646.js";/* empty css */import{T as oe}from"./index.a785f83f.js";import{T as se}from"./index.aaf22f12.js";import{U as re}from"./UpdateButton.285ca87f.js";import"./jspdf.es.min.763284f3.js";/* empty css */import{c as ne,a as A,V as ae}from"./array.0146f311.js";import{L as U}from"./Loading.d8a54a1a.js";import{A as le}from"./ApproverService.fd062fd5.js";import{F as me}from"./FileService.3bf05a89.js";import{M as ce}from"./Multiselect.c4704026.js";import{C as de}from"./index.ecbbc19d.js";import{F as fe}from"./index.3646a8b7.js";import{F as he}from"./index.25258c66.js";import{A as ue}from"./index.c983e8aa.js";import{p as ge,j as pe}from"./scr-1.d9aaecca.js";import{P as _e}from"./index.1269b959.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.bee8c07d.js";import"./vue-cleave.min.88d00a75.js";import"./es.string.replace.f897d4b0.js";import"./index.a174c639.js";import"./index.212d4b04.js";import"./ck-white.4bf441fa.js";const ye={components:{Alert:ue,FileType:he,Fileinput:fe,FormModal:ie,FormGroup:te,TextInput:oe,Textarea:se,SubmitButton:P,UpdateButton:re,CloseButton:B,Loading:U,Multiselect:ce,Icon:D,Checkbox:de},data(){return{recommending:"",recommending_img:"",approving:"",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:ge,jpg:pe,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,r={id:t,attachment:e};await b.removeAttachment(r).then(s=>{s.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(s=>{s.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:s.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 me.Reader2("employee-overtime",t),r;if(t.endsWith(".pdf"))r="application/pdf";else if(t.endsWith(".png"))r="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))r="image/jpeg";else if(t.endsWith(".svg"))r="image/svg+xml";else throw new Error("Unsupported file type");const s=atob(e),i=new Array(s.length);for(let u=0;u<s.length;u++)i[u]=s.charCodeAt(u);const l=new Uint8Array(i),d=new Blob([l],{type:r}),x=URL.createObjectURL(d);window.open(x),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.state.isLoading=!0,await le.fetchApproverRecords().then(t=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&t.data.map(e=>{this.form.allow_higher_approval?((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==3&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.approving==""&&e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")):((e.classification_id==2||e.classification_id==1)&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""),this.recommending==""&&e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||"",this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||""))}),this.$store.userSettings.getActiveUser.employees.classification_id==2&&t.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.$store.userSettings.getActiveUser.employees.classification_id==3&&t.data.map(e=>{e.classification_id==3&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),this.recommending==""&&e.classification_id==4&&(this.form.recommending_id=e.employee_id,this.recommending=e.firstname+" "+e.lastname,this.recommending_img=e.attachment||""),e.classification_id==4&&(this.form.approver_id=e.employee_id,this.approving=e.firstname+" "+e.lastname,this.approving_img=e.attachment||"")}),this.state.isLoading=!1}).catch(t=>{console.log(t)})},async saveRecord(){if(this.state.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])}),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 ne().shape({date:A().required("Date from is required"),from_time:A().required("From time is required"),to_time:A().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 ae){const e={};t.inner.forEach(r=>{e[r.path]=r.message}),this.errors=e}}},calculateHours(){const t=this.form.from_time,e=this.form.to_time;if(t&&e){const[r,s]=this.form.from_time.split(":").map(Number),[i,l]=this.form.to_time.split(":").map(Number);let d=i-r;d+=(l-s)/60,d<0&&(d+=24),this.form.hours=d}}},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}}},xe={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},we={class:"grid grid-cols-12 gap-4"},be={class:"col-span-6"},ve={class:"col-span-6"},Fe={class:"col-span-6"},Ce={class:"col-span-6"},ke={class:"col-span-12"},Se={key:0,class:"text-[#ec4899]"},Ae={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},Te={class:"flex justify-between w-full items-center"},De={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},Re={class:"col-span-12"},Be={class:"grid grid-cols-12 gap-4"},Pe={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},Ue={class:"flex-shrink-0 mr-4"},Ee=["src"],Ie={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Ve={class:"text-left"},Oe={class:"text-sm font-semibold text-gray-600"},Me={class:"text-lg font-bold text-gray-900"},Le={key:0,class:"text-sm text-gray-900"},je={key:1,class:"text-sm text-gray-900"},He={key:0,class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},ze={class:"flex-shrink-0 mr-4"},Ge=["src"],qe={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Ne={class:"text-left"},We={class:"text-lg font-bold text-gray-900"},Ye={class:"text-sm text-gray-900"},Qe={class:"flex gap-2 justify-between"},Ze={class:"flex items-center cursor-pointer"},Ke=["checked"],Je={class:"flex gap-2"};function Xe(t,e,r,s,i,l){const d=a("Loading"),x=a("Alert"),u=a("flat-pickr"),y=a("FormGroup"),v=a("TextInput"),F=a("Fileinput"),C=a("Card"),k=a("FileType"),w=a("Icon"),S=a("Textarea"),E=a("SubmitButton"),I=a("UpdateButton"),V=a("CloseButton"),O=a("FormModal");return m(),_(O,{title:i.state.isEdit?"Edit Undertime":"Undertime Application Form",active:i.state.showModal,onSubmit:t.confirmSubmit,onClose:l.closeModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:f(()=>[i.state.isEdit&&i.state.isLoading?(m(),_(d,{key:0,text:"Fetching record"})):p("",!0),i.state.isLoading?(m(),_(d,{key:1,text:"Fetching Approver"})):p("",!0),i.form.denied_reason?(m(),_(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)),T(" "+h(i.form.denied_reason),1)]),_:1})):p("",!0),o("div",xe,[o("form",{onSubmit:e[9]||(e[9]=N((...c)=>t.confirmSubmit&&t.confirmSubmit(...c),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[i.state.isSaving?(m(),_(d,{key:0,text:"Saving record"})):p("",!0),o("div",we,[o("div",be,[n(y,{label:"Date",isRequired:!0},{default:f(()=>[n(u,{modelValue:i.form.date,"onUpdate:modelValue":e[0]||(e[0]=c=>i.form.date=c),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1})]),o("div",ve,[n(y,{label:"From Time",isRequired:!0},{default:f(()=>[n(u,{class:"form-control h-[48px]",placeholder:"From time",modelValue:i.form.from_time,"onUpdate:modelValue":e[1]||(e[1]=c=>i.form.from_time=c),onChange:l.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),o("div",Fe,[n(y,{label:"To Time",isRequired:!0},{default:f(()=>[n(u,{class:"form-control h-[48px]",placeholder:"To time",modelValue:i.form.to_time,"onUpdate:modelValue":e[2]||(e[2]=c=>i.form.to_time=c),onChange:l.calculateHours,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","onChange"])]),_:1})]),o("div",Ce,[n(y,{label:"Hours"},{default:f(()=>[n(v,{type:"text",modelValue:i.form.hours,"onUpdate:modelValue":e[3]||(e[3]=c=>i.form.hours=c),error:i.errors.hours,classInput:"h-[48px]",isReadonly:!0},null,8,["modelValue","error"])]),_:1})]),o("div",ke,[n(y,{label:"Attachment"},{default:f(()=>[n(C,{title:"File Input Basic"},{default:f(()=>[n(F,{modelValue:i.form.attachment,"onUpdate:modelValue":e[4]||(e[4]=c=>i.form.attachment=c),name:"basic",onChange:l.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),i.errors.attachment?(m(),g("div",Se,h(i.errors.attachment),1)):p("",!0)]),_:1}),typeof i.form.attachment=="string"&&i.form.attachment?(m(),g("div",Ae,[o("div",Te,[o("div",{class:"flex items-center cursor-pointer",onClick:e[5]||(e[5]=c=>l.viewAttachment(i.form.attachment))},[n(k,{image:l.getFileTypeImage(i.form.attachment)},null,8,["image"]),T(" "+h(i.form.attachment),1)]),i.form.status==0?(m(),g("div",De,[n(w,{icon:"mingcute:delete-2-fill",onClick:e[6]||(e[6]=c=>l.deleteFile(i.form.id))})])):p("",!0)])])):p("",!0)]),_:1})]),o("div",Re,[n(y,{label:"Remarks"},{default:f(()=>[n(S,{name:"pn4",placeholder:"Textarea",modelValue:i.form.description,"onUpdate:modelValue":e[7]||(e[7]=c=>i.form.description=c)},null,8,["modelValue"])]),_:1})])]),o("div",Be,[o("div",Pe,[o("div",Ue,[i.recommending_img?(m(),g("img",{key:0,src:i.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Ee)):(m(),g("div",Ie," No Image "))]),o("div",Ve,[o("div",Oe,h(i.form.allow_higher_approval?"Recommending":"Approving"),1),o("div",Me,h(i.recommending),1),i.form.allow_higher_approval?(m(),g("div",Le,h(i.form.recommended_at?"Date: ("+this.$formatDate(i.form.recommended_at)+")":""),1)):(m(),g("div",je,h(i.form.approved_at?"Date: ("+this.$formatDate(i.form.approved_at)+")":""),1))])]),i.form.allow_higher_approval?(m(),g("div",He,[o("div",ze,[i.approving_img?(m(),g("img",{key:0,src:i.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Ge)):(m(),g("div",qe," No Image "))]),o("div",Ne,[e[11]||(e[11]=o("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),o("div",We,h(i.approving),1),o("div",Ye,h(i.form.approved_at?"Date: ("+this.$formatDate(i.form.approved_at)+")":""),1)])])):p("",!0)]),o("div",Qe,[o("div",null,[o("label",Ze,[W(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:i.form.allow_higher_approval,"onUpdate:modelValue":e[8]||(e[8]=c=>i.form.allow_higher_approval=c)},null,8,Ke),[[Y,i.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",Je,[i.state.isEdit?i.form.status===0?(m(),_(I,{key:1,onClick:l.submitForm},null,8,["onClick"])):p("",!0):(m(),_(E,{key:0,onClick:l.submitForm},null,8,["onClick"])),n(V,{onClick:l.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const $e=R(ye,[["render",Xe],["__scopeId","data-v-30c6cff1"]]);const et={mixins:[M],components:{FilterTimekeeping:K,ActionCellRenderer:Z,AgGridVue:Q,Pagination:_e,Card:j,Button:H,Badge:z,Layout:L,Icon:D,CreateButton:J,SubmitButton:P,CloseButton:B,EditButton:$,DeleteButton:X,ViewButton:ee,Form:$e,InputGroup:G,Loading:U},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,cellRenderer:t=>{const e=t.value,r=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||r==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},code:"listOfUndertime"}}],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"}],columns:[{label:"#",field:"#"},{label:"Date",field:"date",formatFn:t=>this.$formatDate(t)},{label:"From Time",field:"from_time",formatFn:t=>this.formatTime(t)},{label:"To Time",field:"to_time",formatFn:t=>this.formatTime(t)},{label:"Hours",field:"hours"},{label:"Remarks",field:"description"},{label:"Created Date",field:"created_at",formatFn:t=>this.$formatDate(t)},{label:"Status",field:"status"},{label:"Action",field:"action"}],perPageOptions:[{value:"10",label:"10"},{value:"50",label:"50"},{value:"100",label:"100"}],items:[],totalItems:0,searchQuery:null,serverOptions:{page:1,rowsPerPage:10,sortBy:"created_at",sortType:"asc"},state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{serverOptions:{handler(){console.log(`perPage: ${this.serverOptions.rowsPerPage}`),this.fetchRecords()},deep:!0},searchQuery:q.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{applyFilters(t){this.fetchRecords(t)},onGridReady(t){this.gridApi=t.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(t=>t.field!=="actions").map(t=>t.field)}):console.error("Grid API is not ready.")},formatTime(t){let[e,r]=t.split(":");e=parseInt(e);const s=e>=12;return e=e%12||12,`${e}:${r} ${s?"PM":"AM"}`},formatDate(t){const e=new Date(t),r=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),s=new Date(r.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),i=s.getFullYear(),l=String(s.getMonth()+1).padStart(2,"0"),d=String(s.getDate()).padStart(2,"0");return`${i}-${l}-${d}`},async fetchRecords(t={}){this.state.isLoading=!0,await b.fetchRecordList({dealership:this.$store.userSettings.activeDealership,...t}).then(e=>{let r=e.data.data.data;this.items=r,this.items=r.map((s,i)=>({...s,"#":i+1,employee_id:s.employee_id,name:s.employee.lastname+", "+s.employee.firstname,date:this.$formatDate(s.date),"time coverage":this.$formatTime(s.from_time)+" - "+this.$formatTime(s.to_time)+" ("+s.hours+" Hours)","date created":this.$formatDate(s.created_at),status:s.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(r=>{r.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.fetchRecords(),this.state.isDeleting=!1})},createRecord(){this.$refs.form.resetForm(),this.$refs.form.state.showModal=!0},editRecord(t){console.log(t),this.$refs.form.resetForm(),this.$refs.form.loadRecord(t),this.$refs.form.state.showModal=!0},handlePageChange(t){console.log(t),console.log(this.serverOptions.page),this.serverOptions.page!=t&&(this.serverOptions.page=t)},handlePerPageChange(t){this.serverOptions.page=1,this.serverOptions.rowsPerPage=t}},mounted(){this.fetchRecords()}},tt={class:"space-y-4 mt-4"},it={class:"flex items-center justify-between"},ot={class:"text-2xl font-bold text-slate-900 dark:text-white"},st={class:"relative"},rt={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},nt={class:"flex items-center justify-center gap-4 text-gray-900"},at={class:"flex items-center gap-4"},lt={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function mt(t,e,r,s,i,l){const d=a("FilterTimekeeping"),x=a("Icon"),u=a("Button"),y=a("ag-grid-vue"),v=a("Card"),F=a("Loading"),C=a("Form"),k=a("Layout");return m(),_(k,{breadcrumbs:i.breadcrumbs},{default:f(()=>[o("div",tt,[n(v,{title:"Undertime Applications"},{default:f(()=>{var w;return[o("div",it,[o("h2",ot,h(t.title),1)]),o("div",st,[o("div",rt,[o("div",nt,h(((w=this.$store.userSettings.dealershipAccess.find(S=>S.id==this.$store.userSettings.activeDealership))==null?void 0:w.name)+" - REQUESTED UNDERTIME"||"REQUESTED UNDERTIME"),1),o("div",at,[n(d,{onFilterChanged:l.applyFilters},null,8,["onFilterChanged"]),n(u,{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:l.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",lt,[n(x,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[1]||(e[1]=T(" Export to CSV "))])]),_:1},8,["onClick"])])])]),n(y,{ref:"agGrid",rowData:i.items,columnDefs:i.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:i.paginationPageSize,paginationPageSizeSelector:i.paginationPageSizeSelector,onGridReady:l.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])]}),_:1}),i.state.isLoading?(m(),_(F,{key:0,text:"Fetching records"})):p("",!0),n(C,{onCloseModal:e[0]||(e[0]=w=>i.state.showModal=!1),ref:"form",onReload:l.fetchRecords},null,8,["onReload"])])]),_:1},8,["breadcrumbs"])}const ii=R(et,[["render",mt],["__scopeId","data-v-a37ead65"]]);export{ii as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.13 |
proxy
|
phpinfo
|
Settings