File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.e78edaf9.js
Back
import{_ as O,r as a,o as m,c as g,w as f,j as h,d as l,k as b,e as r,b as w,t as P,f as L,h as H}from"./index.28ae41da.js";import{E as x}from"./EmployeeLoanService.d5c384f9.js";import{w as K,L as J}from"./index.ca4614c1.js";import{L as D}from"./Loading.fa197db1.js";import{l as X}from"./lodash.45138f16.js";import{B as A}from"./index.8a5f8558.js";import{C as Z}from"./CreateButton.7e6095de.js";import{D as $}from"./DeleteButton.89d918f5.js";import{E as ee}from"./EditButton.4c7b9ec2.js";/* empty css */import{V as te}from"./ViewButton.d67c4349.js";import{I as q}from"./index.1b36081b.js";import"./jspdf.es.min.cdd8e899.js";/* empty css *//* empty css */import"./vue-cleave.min.10e51f16.js";import{c as oe,a as k,e as se,V as re}from"./array.19531b35.js";import"./vue-quill.snow.464b7516.js";/* empty css */import{I as ie}from"./index.ae574076.js";import{P as ae}from"./index.4d0f347c.js";import{F as I}from"./index.975c3902.js";import{F as T}from"./index.164dfd27.js";import{T as M}from"./index.33bd7660.js";import{T as U}from"./index.43beecaf.js";import{C as j}from"./CloseButton.dacc4a7b.js";import{S as G}from"./SubmitButton.be4371c4.js";import{U as z}from"./UpdateButton.a9e9b37b.js";import{E as ne}from"./EmployeeService.67ccb7ea.js";import{L as le}from"./LoanTypeService.8125b3d2.js";import{M as Y}from"./Multiselect.3c2ca79b.js";import{F as W}from"./index.9a016648.js";import{F as N}from"./index.d93f9125.js";import{p as ce,j as de}from"./scr-1.d9aaecca.js";import{A as me}from"./ActionCellRenderer.4d4d9d35.js";import{H as ue}from"./HelperService.86a88cb6.js";import{F as fe}from"./FileService.09441775.js";import{A as pe}from"./main.esm.9cee2c92.js";import{C as he}from"./index.4f06d02e.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.4769b1c9.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"./index.85943672.js";const ge={components:{FileType:N,Fileinput:W,FormModal:T,FormGroup:I,TextInput:U,TextArea:M,SubmitButton:G,UpdateButton:z,CloseButton:j,Loading:D,Multiselect:Y},data(){return{frequencyOptions:[{value:"1",label:"1st Cutoff"},{value:"2",label:"2nd Cutoff"},{value:"3",label:"Every Cutoff"}],employeeOptions:"",loanOptions:"",form:{employee_id:"",loan_id:"",amount:"",frequency:"",term:"",monthly:"",balance:"",effectivity_date:"",attachment:"",remarks:"",paused:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1},fileIcons:{pdf:ce,jpg:de,default:""},datePickerConfig:{allowInput:!0,dateFormat:"Y-m-d"}}},computed:{activeCompany(){return this.$store.userSettings.getActiveCompany},activeDealer(){return this.$store.userSettings.getActiveDealership}},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,s={id:t,attachment:e};await EmployeeLeave.removeAttachment(s).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 FileService.Reader2("employee-leave",t),s;if(t.endsWith(".pdf"))s="application/pdf";else if(t.endsWith(".png"))s="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))s="image/jpeg";else if(t.endsWith(".svg"))s="image/svg+xml";else throw new Error("Unsupported file type");const c=atob(e),o=new Array(c.length);for(let n=0;n<c.length;n++)o[n]=c.charCodeAt(n);const i=new Uint8Array(o),y=new Blob([i],{type:s}),p=URL.createObjectURL(y);window.open(p),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)},e.readAsDataURL(t)},async fetchEmployee(){await ne.fetchAllEmployeePayrollAccessRecords({company_id:this.activeCompany,dealership_id:this.activeDealer}).then(t=>{t.status==200&&(this.employeeOptions=t.data.map(e=>({value:e.employee_id,label:e.employee_id+" - "+e.firstname+" "+e.lastname})))}).catch(t=>{console.log(t)})},async fetchLoanType(){await le.fetchRecords().then(t=>{t.status==200&&(this.loanOptions=t.data.data.map(e=>({value:e.id,label:e.name})))}).catch(t=>{console.log(t)})},loadRecord(t){this.resetForm(),this.state.isEdit=!0,this.form=t},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={employee_id:"",loan_id:"",amount:"",frequency:"",term:"",monthly:"",balance:"",effectivity_date:"",attachment:"",remarks:"",paused:""}},reload(){this.$emit("reload")},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 x.update(t).then(e=>{e.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.state.showModal=!1)}).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})}).finally(()=>{this.state.isSaving=!1,this.reload()})}else{this.state.isSaving=!1;let t=new FormData;Object.keys(this.form).forEach(e=>{t.append(e,this.form[e])}),await x.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.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 oe().shape({employee_id:k().required("Employee field is required"),loan_id:k().required("Loan field is required"),amount:k().required("Amount field is required"),frequency:k().required("Frequency field is required"),term:k().required("Term field is required"),balance:se().typeError("Balance must be a number").required("Balance field is required"),effectivity_date:k().required("Effectivity Date field 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 re){const e={};t.inner.forEach(s=>{e[s.path]=s.message}),this.errors=e}this.state.isSaving=!1}},calculateMonthlyTerm(){this.form.term=(this.form.balance/this.form.monthly).toFixed(2)}},watch:{"form.monthly":{handler:"calculateMonthlyTerm",immediate:!1}},mounted(){this.fetchLoanType(),this.fetchEmployee()}},ye={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},we={class:"relative"},ve={key:0,class:"text-[#ec4899]"},be={class:"relative"},xe={key:0,class:"text-[#ec4899]"},_e={class:"grid grid-cols-2 gap-2"},Ce={class:"relative"},ke={key:0,class:"text-[#ec4899]"},Pe={class:"grid grid-cols-2 gap-2"},Fe={class:"grid grid-cols-2 gap-2"},Be={key:0,class:"text-[#ec4899]"},Re={key:0,class:"text-[#ec4899]"},Se={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},Ee={class:"flex justify-between w-full items-center"},Ve={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},Le={class:"flex gap-1 justify-end"};function Oe(t,e,s,c,o,i){const y=a("Loading"),p=a("Multiselect"),n=a("FormGroup"),v=a("TextInput"),F=a("flat-pickr"),_=a("Fileinput"),B=a("Card"),R=a("FileType"),S=a("Icon"),E=a("TextArea"),V=a("SubmitButton"),u=a("UpdateButton"),C=a("CloseButton"),Q=a("FormModal");return m(),g(Q,{title:o.state.isEdit?"Edit Loan Record":"Create Loan Record",active:o.state.showModal,onSubmit:t.confirmSubmit,onClose:i.closeModal,themeClass:o.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:f(()=>[o.state.isEdit&&o.state.isLoading?(m(),g(y,{key:0,text:"Fetching record"})):h("",!0),l("div",ye,[l("form",{onSubmit:e[12]||(e[12]=b((...d)=>t.confirmSubmit&&t.confirmSubmit(...d),["prevent"])),class:"space-y-4"},[o.state.isSaving?(m(),g(y,{key:0,text:"Saving record"})):h("",!0),r(n,{label:"Employee",isRequired:!0},{default:f(()=>[l("div",we,[r(p,{modelValue:o.form.employee_id,"onUpdate:modelValue":e[0]||(e[0]=d=>o.form.employee_id=d),"close-on-select":!0,searchable:!0,id:"employee_id",class:"h-[48px]",options:o.employeeOptions,disabled:o.state.isEdit},null,8,["modelValue","options","disabled"])]),o.errors.employee_id?(m(),w("div",ve,"Employee field is required")):h("",!0)]),_:1}),r(n,{label:"Loan Type",isRequired:!0},{default:f(()=>[l("div",be,[r(p,{modelValue:o.form.loan_id,"onUpdate:modelValue":e[1]||(e[1]=d=>o.form.loan_id=d),"close-on-select":!0,searchable:!0,id:"loan_id",class:"h-[48px]",options:o.loanOptions,disabled:o.state.isEdit},null,8,["modelValue","options","disabled"])]),o.errors.loan_id?(m(),w("div",xe,"Loan field is required")):h("",!0)]),_:1}),l("div",_e,[r(n,{label:"Amount",isRequired:!0},{default:f(()=>[r(v,{type:"text",placeholder:"Input amount",modelValue:o.form.amount,"onUpdate:modelValue":e[2]||(e[2]=d=>o.form.amount=d),error:o.errors.amount,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),r(n,{label:"Frequency",isRequired:!0},{default:f(()=>[l("div",Ce,[r(p,{modelValue:o.form.frequency,"onUpdate:modelValue":e[3]||(e[3]=d=>o.form.frequency=d),"close-on-select":!0,searchable:!0,id:"frequency",class:"h-[48px]",options:o.frequencyOptions},null,8,["modelValue","options"])]),o.errors.frequency?(m(),w("div",ke,"Frequency field is required")):h("",!0)]),_:1})]),l("div",Pe,[r(n,{label:"Monthly",isRequired:!0},{default:f(()=>[r(v,{type:"number",placeholder:"Input monthly ",modelValue:o.form.monthly,"onUpdate:modelValue":e[4]||(e[4]=d=>o.form.monthly=d),error:o.errors.monthly,max:Number(o.form.balance),classInput:"h-[48px]"},null,8,["modelValue","error","max"])]),_:1}),r(n,{label:"Term",isRequired:!0},{default:f(()=>[r(v,{type:"text",placeholder:"Input term ",modelValue:o.form.term,"onUpdate:modelValue":e[5]||(e[5]=d=>o.form.term=d),error:o.errors.term,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1})]),l("div",Fe,[r(n,{label:"Balance",isRequired:!0},{default:f(()=>[r(v,{type:"number",placeholder:"Input balance ",modelValue:o.form.balance,"onUpdate:modelValue":e[6]||(e[6]=d=>o.form.balance=d),error:o.errors.balance,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1}),r(n,{label:"Effectivity Date",isRequired:!0},{default:f(()=>[r(F,{modelValue:o.form.effectivity_date,"onUpdate:modelValue":e[7]||(e[7]=d=>o.form.effectivity_date=d),class:"form-control h-[48px]",min:o.form.effectivity_date,config:o.datePickerConfig,placeholder:"Select date"},null,8,["modelValue","min","config"]),o.errors.effectivity_date?(m(),w("div",Be,"Effectivity Date field is required")):h("",!0)]),_:1})]),r(n,{label:"Attachment"},{default:f(()=>[r(B,{title:"File Input Basic"},{default:f(()=>[r(_,{modelValue:o.form.attachment,"onUpdate:modelValue":e[8]||(e[8]=d=>o.form.attachment=d),name:"basic",onChange:i.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),o.errors.attachment?(m(),w("div",Re,P(o.errors.attachment),1)):h("",!0)]),_:1}),typeof o.form.attachment=="string"&&o.form.attachment?(m(),w("div",Se,[l("div",Ee,[l("div",{class:"flex items-center cursor-pointer",onClick:e[9]||(e[9]=d=>i.viewAttachment(o.form.attachment))},[r(R,{image:i.getFileTypeImage(o.form.attachment)},null,8,["image"]),L(" "+P(o.form.attachment),1)]),o.form.status==0&&o.form.days<3?(m(),w("div",Ve,[r(S,{icon:"mingcute:delete-2-fill",onClick:e[10]||(e[10]=d=>i.deleteFile(o.form.id))})])):h("",!0)])])):h("",!0)]),_:1}),r(n,{label:"Remarks"},{default:f(()=>[r(E,{modelValue:o.form.remarks,"onUpdate:modelValue":e[11]||(e[11]=d=>o.form.remarks=d),error:o.errors.remarks,placeholder:"Enter remarks here",rows:"2",classInput:"w-full"},null,8,["modelValue","error"])]),_:1}),l("div",Le,[o.state.isEdit?(m(),g(u,{key:1,onClick:i.submitForm},null,8,["onClick"])):(m(),g(V,{key:0,onClick:i.submitForm},null,8,["onClick"])),r(C,{onClick:i.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const De=O(ge,[["render",Oe]]),Ae={components:{Icon:q,ActionCellRenderer:me,AgGridVue:pe,FileType:N,Fileinput:W,FormModal:T,FormGroup:I,TextInput:U,TextArea:M,Button:A,SubmitButton:G,UpdateButton:z,CloseButton:j,Loading:D,Multiselect:Y},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:1},{field:"amount",filter:!0,floatingFilter:!0,flex:2},{field:"date paid",filter:!0,floatingFilter:!0,flex:2}],loans:[],loanName:"",attachment:"",state:{isEdit:!1,isSaving:!1,isLoading:!1}}},methods:{async viewAttachment(t){if(this.state.isDownloading)return;this.state.isDownloading=!0;let e=await fe.Reader2("employee-loans",t),s;if(t.endsWith(".pdf"))s="application/pdf";else if(t.endsWith(".png"))s="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))s="image/jpeg";else if(t.endsWith(".svg"))s="image/svg+xml";else throw new Error("Unsupported file type");const c=atob(e),o=new Array(c.length);for(let n=0;n<c.length;n++)o[n]=c.charCodeAt(n);const i=new Uint8Array(o),y=new Blob([i],{type:s}),p=URL.createObjectURL(y);window.open(p),this.state.isLoadingPDF=!1},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.")},async loadRecord(t,e,s){this.state.isLoading=!0,console.log("loan",this.state.isLoading),this.loans=[],this.loanName=e,this.attachment=s,await x.fetchRecord(t).then(c=>{this.loans=c.data.map((o,i)=>({...o,"#":i+1,amount:ue.formatNumber(o.amount),"date paid":o.date_paid?this.$formatDate(o.date_paid):"Not Yet Paid"}))}),this.state.isLoading=!1,console.log("loan",this.state.isLoading)},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={employee_id:"",loan_id:"",amount:"",frequency:"",term:"",monthly:"",balance:"",effectivity_date:"",attachment:"",remarks:"",paused:""}},reload(){this.$emit("reload")}},mounted(){}},qe={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},Ie={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-t rounded-t-xl border-gray-200"},Te={class:"flex items-center justify-center gap-4 text-gray-900 text-lg font-bold"},Me={class:"flex items-center gap-4"},Ue={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},je={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function Ge(t,e,s,c,o,i){const y=a("Loading"),p=a("Icon"),n=a("Button"),v=a("ag-grid-vue"),F=a("FormModal");return m(),g(F,{title:"Loan List",active:o.state.showModal,onSubmit:t.confirmSubmit,onClose:i.closeModal,themeClass:"bg-gray-800",sizeClass:"lg:w-3/4"},{default:f(()=>[o.state.isLoading?(m(),g(y,{key:0,text:"Fetching record"})):h("",!0),l("div",qe,[l("form",{onSubmit:e[1]||(e[1]=b((..._)=>t.confirmSubmit&&t.confirmSubmit(..._),["prevent"])),class:""},[l("div",Ie,[l("div",Te,P(o.loanName),1),l("div",Me,[r(n,{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:i.exportToCsv},{default:f(()=>[e[3]||(e[3]=l("span",{class:"absolute inset-0 bg-green-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),l("span",Ue,[r(p,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[2]||(e[2]=L(" Export to CSV "))])]),_:1},8,["onClick"]),o.attachment?(m(),g(n,{key:0,icon:"line-md:downloading-loop",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-blue-500",iconClass:"text-2xl",onClick:e[0]||(e[0]=_=>i.viewAttachment(o.attachment))},{default:f(()=>[e[5]||(e[5]=l("span",{class:"absolute inset-0 bg-blue-500 transition-transform duration-300 transform -translate-x-full group-hover:translate-x-0"},null,-1)),l("span",je,[r(p,{icon:"line-md:downloading-loop",class:"text-2xl mr-2"}),e[4]||(e[4]=L(" View Attached File "))])]),_:1})):h("",!0)])]),r(v,{ref:"agGrid",rowData:o.loans,columnDefs:o.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:o.paginationPageSize,paginationPageSizeSelector:o.paginationPageSizeSelector,onGridReady:i.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])],32)])]),_:1},8,["active","onSubmit","onClose"])}const ze=O(Ae,[["render",Ge]]),Ye={mixins:[K],components:{Layout:J,CreateButton:Z,InputGroup:ie,Loading:D,EditButton:ee,DeleteButton:$,ViewButton:te,Pagination:ae,Form:De,View:ze,Card:he,Icon:q,Button:A},data(){return{title:"Employee Loans",breadcrumbs:[{text:"Home",href:"/"},{text:"Employee Loans",active:!0}],columns:[{label:"#",field:"#"},{label:"Employee ID",field:"employee_id"},{label:"Name",field:"fullname"},{label:"Loan",field:"loan.name"},{label:"Start Date",field:"effectivity_date",formatFn:t=>this.$formatDate(t)},{label:"Amount",field:"amount",formatFn:t=>this.$formatNumber(t)},{label:"Monthly",field:"monthly"},{label:"Term",field:"term"},{label:"Balance",field:"balance",formatFn:t=>this.$formatNumber(t)},{label:"Paused",field:"paused"},{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:X.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{rowClass(){return"cursor-pointer"},onRowClick(t){this.viewLoans(t.row.id,t.row.loan.name,t.row.attachment),console.log("clicked",t.row.id,t.row)},async reloadRecords(){await this.fetchRecords()},async fetchRecords(){this.state.isLoading=!0,await x.fetchRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType}).then(t=>{console.log("response");let e=t.data.data;console.log(e),this.items=e,this.items=e.map((s,c)=>({...s,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(c+1)})),this.totalItems=t.data.total}).finally(()=>{this.state.isLoading=!1})},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 payInFull(t){this.$swal.fire({title:"Are you sure?",text:"This loan will pay in full?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes, Pay in Full!",background:this.$store.themeSettingsStore.isDark?"#1e293b":"#fff",html:` <label>Date to be paid? </label> <input id="swal-input" type="date" style="width: 70%; padding: 8px; border: 1px solid #ced4da; border-radius: 4px;" placeholder="Enter Date"></input>`,preConfirm:()=>{const e=document.getElementById("swal-input").value;return e?this.paid_date=e:(this.$swal.showValidationMessage("The date paid field is required"),!1)}}).then(e=>{if(e.value)try{x.fullPayment(t,{paid_date:this.paid_date}).then(s=>{s.status==200&&this.$swal.fire({title:"Yaaay!",text:"Record has been updated successfully.",type:"success",icon:"success",timer:2e3}),this.reloadRecords()})}catch(s){console.log(s)}}).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.state.isDeleting=!1})},async activateLoan(t,e){this.$swal.fire({title:"Are you sure?",text:"You want to "+e+" this record?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes, "+e+" it!",background:this.$store.themeSettingsStore.isDark?"#1e293b":"#fff",html:e=="pause"?` <label>Date to be resume? </label> <input id="swal-input" type="date" style="width: 70%; padding: 8px; border: 1px solid #ced4da; border-radius: 4px;" placeholder="Enter Date"></input>`:"",preConfirm:()=>{if(e=="pause"){const s=document.getElementById("swal-input").value;return s?this.resume_date=s:(this.$swal.showValidationMessage("The date resume field is required"),!1)}}}).then(s=>{if(s.value)try{x.activate(t,{formType:e,resume_date:this.resume_date}).then(c=>{console.log("asdaddadadadasd"),c.status==200&&this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.reloadRecords()})}catch(c){console.log(c)}}).catch(s=>{s.response&&s.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.state.isDeleting=!1})},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,x.remove(t).then(s=>{s.status==200&&this.$swal.fire({title:"Yaaay!",text:"Record has been deleted successfully.",type:"success",icon:"success",timer:2e3}),this.reloadRecords()}))}).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.state.isDeleting=!1})},createRecord(){this.$refs.form.resetForm(),this.$refs.form.state.showModal=!0},editRecord(t){this.$refs.form.resetForm(),this.$refs.form.loadRecord(t),this.$refs.form.state.showModal=!0},viewLoans(t,e,s){this.$refs.view.loadRecord(t,e,s),this.$refs.view.state.showModal=!0},handlePageChange(t){console.log(t),console.log(this.serverOptions.page),this.serverOptions.page!=t&&(this.serverOptions.page=t)},handlePerPageChange(t){this.serverOptions.page=1,this.serverOptions.rowsPerPage=t}},mounted(){this.fetchRecords()}},We={class:"my-5"},Ne={class:"md:flex pb-6 items-center"},Qe={class:"flex-1 md:mb-0 mb-3"},He={key:0,class:"flex gap-1"},Ke={key:1,class:"flex gap-1"},Je={key:2,class:"flex items-center gap-1"},Xe={class:"py-4 flex justify-end"};function Ze(t,e,s,c,o,i){const y=a("InputGroup"),p=a("Button"),n=a("EditButton"),v=a("DeleteButton"),F=a("Pagination"),_=a("vue-good-table"),B=a("Card"),R=a("Loading"),S=a("Form"),E=a("View"),V=a("Layout");return m(),g(V,{breadcrumbs:o.breadcrumbs},{default:f(()=>[l("div",We,[r(B,{noborder:""},{default:f(()=>[l("div",Ne,[l("h6",Qe,P(o.title),1),l("div",{class:H(["md:flex md:space-x-3 items-center flex-none rtl:space-x-reverse my-3 float-right",t.window.width<768?"space-x-rb":""])},[r(y,{modelValue:o.searchQuery,"onUpdate:modelValue":e[0]||(e[0]=u=>o.searchQuery=u),placeholder:"Search",type:"text",prependIcon:"heroicons-outline:search",merged:""},null,8,["modelValue"]),r(p,{icon:"heroicons-outline:filter",text:"Filter",btnClass:" btn-outline-secondary text-slate-600 dark:border-slate-700 dark:text-slate-300 font-normal btn-sm ",iconClass:"text-lg"}),r(p,{icon:"heroicons-outline:plus-sm",text:"Add Record",btnClass:" btn-dark font-normal btn-sm ",iconClass:"text-lg",onClick:e[1]||(e[1]=u=>i.createRecord())})],2)]),r(_,{class:"",styleClass:"vgt-table lesspadding v-middle",columns:o.columns,rows:o.items,mode:"remote",search:!0,"sort-options":{enabled:!0},"pagination-options":{enabled:!0},onSortChange:i.onSortChange,"max-height":"600px",onRowClick:i.onRowClick,rowStyleClass:"cursor-pointer hover:bg-gray-100"},{"table-row":f(u=>[u.column.field=="paused"?(m(),w("div",He,P(u.row.paused?"Yes":"No"),1)):h("",!0),u.column.field=="fullname"?(m(),w("div",Ke,P(u.row.employee.lastname+" "+u.row.employee.firstname),1)):h("",!0),u.column.field=="action"?(m(),w("div",Je,[u.row.paused?(m(),g(p,{key:1,btnClass:"text-warning-500 hover:text-warning-700 py-2 px-1",icon:"ic:twotone-play-circle-filled-white",iconClass:"text-2xl",onClick:b(C=>i.activateLoan(u.row.id,"resume"),["stop"])},null,8,["onClick"])):(m(),g(p,{key:0,btnClass:"text-warning-500 hover:text-warning-700 py-2 px-1",icon:"ic:twotone-pause-circle-filled",iconClass:"text-2xl",onClick:b(C=>i.activateLoan(u.row.id,"pause"),["stop"])},null,8,["onClick"])),r(n,{onClick:b(C=>i.editRecord(u.row),["stop"])},null,8,["onClick"]),r(p,{btnClass:"text-green-500 hover:text-green-700 py-2 px-1",icon:"hugeicons:payment-02",iconClass:"text-2xl",onClick:b(C=>i.payInFull(u.row.id),["stop"])},null,8,["onClick"]),r(v,{onClick:b(C=>i.deleteRecord(u.row.id),["stop"])},null,8,["onClick"])])):h("",!0)]),"pagination-bottom":f(u=>[l("div",Xe,[r(F,{total:o.totalItems,current:o.serverOptions.page,"per-page":o.serverOptions.rowsPerPage,onPageChanged:i.handlePageChange,pageChanged:u.pageChanged,perPageChanged:o.serverOptions.rowsPerPage,enableSelect:"",perPageOptions:o.perPageOptions,onChangePerPage:i.handlePerPageChange},null,8,["total","current","per-page","onPageChanged","pageChanged","perPageChanged","perPageOptions","onChangePerPage"])])]),_:1},8,["columns","rows","onSortChange","onRowClick"])]),_:1}),o.state.isLoading?(m(),g(R,{key:0,text:"Fetching records"})):h("",!0),r(S,{onCloseModal:e[2]||(e[2]=u=>o.state.showModal=!1),ref:"form",onReload:i.fetchRecords},null,8,["onReload"]),r(E,{onCloseModal:e[3]||(e[3]=u=>o.state.showModal=!1),ref:"view"},null,512)])]),_:1},8,["breadcrumbs"])}const Wt=O(Ye,[["render",Ze]]);export{Wt as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.04 |
proxy
|
phpinfo
|
Settings