File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.0aa0a79d.js
Back
import{w as M,L as U}from"./index.09b28a7f.js";import{C as A}from"./index.5a868516.js";import{B as j}from"./index.95db1698.js";import{B as q}from"./index.ae1bb6da.js";import{I as D}from"./index.163ce270.js";import{I as G}from"./index.fd1302f6.js";import{l as W}from"./lodash.7ba26c92.js";import{c as H,a as E,V as Q}from"./array.057dff5d.js";import{a as w,_ as I,r,o as a,c as y,w as f,j as d,d as l,k as Y,e as i,b as h,t as v,f as N,h as z}from"./index.3a0d1437.js";import{C as T}from"./CloseButton.f9c39bb8.js";import{C as J}from"./CreateButton.83988a87.js";import{D as K}from"./DeleteButton.3eb26d6c.js";import{E as X}from"./EditButton.f8156944.js";/* empty css */import{S as L}from"./SubmitButton.53a3866c.js";import"./jspdf.es.min.a68db437.js";/* empty css *//* empty css */import"./vue-cleave.min.da4c1c61.js";import{L as V}from"./Loading.2fa16091.js";import"./vue-quill.snow.08c5baab.js";/* empty css */import{F as Z}from"./index.5338216a.js";import{F as $}from"./index.4888d65f.js";import{T as ee}from"./index.53519759.js";import{T as te}from"./index.e6d15a49.js";import{U as oe}from"./UpdateButton.161928d8.js";import{F as se}from"./FileService.9a8ade8c.js";import{M as re}from"./Multiselect.4d70245a.js";import{F as ie}from"./index.a504f7c5.js";import{F as ne}from"./index.b440e312.js";import{C as ae}from"./index.30a24c9f.js";import{a as le,b as me}from"./apiUtils.383f63f4.js";import{p as ce,j as de}from"./scr-1.d9aaecca.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.eb053693.js";import"./EmployeeService.0d36c049.js";import"./es.string.replace.6e729815.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.717f943d.js";import"./index.57af9821.js";import"./ck-white.4bf441fa.js";import"./CompanyService.335c4e27.js";import"./DealershipService.65dee167.js";import"./DepartmentService.b6e0d2c2.js";import"./DivisionService.849bf539.js";import"./EmploymentTypeService.ba01c8db.js";import"./GroupService.8a431bdb.js";import"./JobClassficationService.4b92c33f.js";import"./JobTitleService.e1202c4d.js";import"./SectionService.70d2587b.js";import"./SupportingDocumentService.fafc9fc6.js";import"./UnitService.d6432c35.js";import"./CitizenshipService.960d3008.js";import"./CivilStatusService.ff01e4ed.js";import"./ReligionService.45dd14d1.js";const b="https://staging-ahg-hr-api.autohub.ph/api/v1/document-tracker",S={fetchRecords(e={}){return w.get(`${b}`,{params:e})},fetchRecord(e){return w.get(`${b}/${e}`)},async create(e){return w.post(`${b}`,e)},async update(e,t){return w.put(`${b}/${e}`,t)},async remove(e){return w.delete(`${b}/${e}`)}};const pe={components:{Fileinput:ie,FileType:ne,FormModal:$,FormGroup:Z,TextInput:ee,Textarea:te,SubmitButton:L,UpdateButton:oe,CloseButton:T,Loading:V,Multiselect:re,Icon:D,Checkbox:ae},data(){return{currentEmployeeId:this.$store.userSettings.getActiveUser.employees?this.$store.userSettings.getActiveUser.employees.employee_id:"admin",employeeOptions:[],supportingDocumentsOptions:[],form:{send_to:"",document_id:"",remarks:"",attachment:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isSupportingDocumentsLoading:!1,isEmployeeLoading:!1},fileIcons:{pdf:ce,jpg:de,default:""}}},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 se.Reader2("document-tracker",e),m;if(e.endsWith(".pdf"))m="application/pdf";else if(e.endsWith(".png"))m="image/png";else if(e.endsWith(".jpg")||e.endsWith(".jpeg"))m="image/jpeg";else if(e.endsWith(".svg"))m="image/svg+xml";else throw new Error("Unsupported file type");const g=atob(t),o=new Array(g.length);for(let p=0;p<g.length;p++)o[p]=g.charCodeAt(p);const n=new Uint8Array(o),u=new Blob([n],{type:m}),_=URL.createObjectURL(u);window.open(_),this.state.isLoadingPDF=!1},reload(){this.$emit("reload")},async fetchEmployeeRecords(){this.state.isEmployeeLoading=!0;try{this.employeeOptions=await le(),this.state.isEmployeeLoading=!1}catch(e){this.state.isEmployeeLoading=!1,console.error("Failed to fetch employee data:",e)}},async fetchSupportingDocumentRecords(){this.state.isSupportingDocuments=!0;try{this.supportingDocumentsOptions=await me(),this.state.isSupportingDocuments=!1}catch(e){console.error("Failed to fetch employee data:",e),this.state.isSupportingDocuments=!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)},loadRecord(e){this.resetForm(),this.state.isEdit=!0,this.form=e},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={send_to:"",document_id:"",remarks:"",attachment:""}},async saveRecord(){if(this.state.isSaving=!0,this.state.isEdit){this.form.id,this.state.isSaving=!1;let e=new FormData;Object.keys(this.form).forEach(t=>{e.append(t,this.form[t])}),await EmployeeOb.update(e).then(t=>{t.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(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})})}else{this.state.isSaving=!1;let e=new FormData;Object.keys(this.form).forEach(t=>{e.append(t,this.form[t])}),await S.create(e).then(t=>{t.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(t=>{console.log(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(){try{await H().shape({send_to:E().required("Employee is required"),document_id:E().required("Document is required")}).validate(this.form,{abortEarly:!1}),this.state.isSaving=!0,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(t=>{t.value&&this.saveRecord()})}catch(e){if(e instanceof Q){const t={};e.inner.forEach(m=>{t[m.path]=m.message}),this.errors=t}this.state.isSaving=!1}},calculateHours(){const e=this.form.from_time,t=this.form.to_time;if(e&&t){const[m,g]=this.form.from_time.split(":").map(Number),[o,n]=this.form.to_time.split(":").map(Number);let u=o-m;u+=(n-g)/60,u<0&&(u+=24),this.form.hours=u}}},mounted(){this.fetchEmployeeRecords(),this.fetchSupportingDocumentRecords()}},ue={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},fe={class:"grid grid-cols-2 gap-4"},he={class:"grid grid-cols-12 gap-4"},ge={class:"col-span-12"},ye={class:"col-span-12"},_e={key:0,class:"text-[#ec4899]"},ve={key:0,class:"flex items-center gap-2 mt-2 cursor-pointer"},we={class:"flex justify-between w-full items-center"},be={key:0,class:"flex justify-end text-xl text-red-500 cursor-pointer"},xe={class:"flex gap-1 justify-end"};function Ce(e,t,m,g,o,n){const u=r("Loading"),_=r("Multiselect"),p=r("FormGroup"),x=r("TextInput"),C=r("Fileinput"),k=r("Card"),O=r("FileType"),P=r("Icon"),F=r("SubmitButton"),B=r("UpdateButton"),s=r("CloseButton"),R=r("FormModal");return a(),y(R,{title:o.state.isEdit?"Edit Record":"Create Record",active:o.state.showModal,onSubmit:e.confirmSubmit,onClose:n.closeModal,themeClass:o.state.isEdit?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-2/4"},{default:f(()=>[o.state.isEdit&&o.state.isLoading?(a(),y(u,{key:0,text:"Fetching record"})):d("",!0),l("div",ue,[l("form",{onSubmit:t[7]||(t[7]=Y((...c)=>e.confirmSubmit&&e.confirmSubmit(...c),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[o.state.isSaving?(a(),y(u,{key:0,text:"Saving record"})):d("",!0),l("div",fe,[o.form.employee_id==o.currentEmployeeId||o.form.send_to==""?(a(),y(p,{key:0,label:"Send To",isRequired:!0},{default:f(()=>[i(_,{modelValue:o.form.send_to,"onUpdate:modelValue":t[0]||(t[0]=c=>o.form.send_to=c),"close-on-select":!0,searchable:!0,id:"send_to",options:o.employeeOptions,loading:o.state.isEmployeeLoading},null,8,["modelValue","options","loading"])]),_:1})):(a(),y(p,{key:1,label:"From",isRequired:!0},{default:f(()=>[i(_,{modelValue:o.form.employee_id,"onUpdate:modelValue":t[1]||(t[1]=c=>o.form.employee_id=c),"close-on-select":!0,searchable:!0,id:"send_to",options:o.employeeOptions,loading:o.state.isEmployeeLoading,disabled:"true"},null,8,["modelValue","options","loading"])]),_:1})),i(p,{label:"Document Type",isRequired:!0},{default:f(()=>[i(_,{modelValue:o.form.document_id,"onUpdate:modelValue":t[2]||(t[2]=c=>o.form.document_id=c),class:"form-control h-[48px]",id:"document_id",options:o.supportingDocumentsOptions,loading:e.isSupportingDocumentsLoading},null,8,["modelValue","options","loading"])]),_:1})]),l("div",he,[l("div",ge,[i(p,{label:"Remarks"},{default:f(()=>[i(x,{type:"text",modelValue:o.form.remarks,"onUpdate:modelValue":t[3]||(t[3]=c=>o.form.remarks=c),error:o.errors.remarks,classInput:"h-[48px]"},null,8,["modelValue","error"])]),_:1})]),l("div",ye,[i(p,{label:"Attachment"},{default:f(()=>[i(k,{title:"File Input Basic"},{default:f(()=>[i(C,{modelValue:o.form.attachment,"onUpdate:modelValue":t[4]||(t[4]=c=>o.form.attachment=c),name:"basic",onChange:n.handleMainImageUpload,class:"h-[48px] w-full"},null,8,["modelValue","onChange"]),o.errors.attachment?(a(),h("div",_e,v(o.errors.attachment),1)):d("",!0)]),_:1}),typeof o.form.attachment=="string"&&o.form.attachment?(a(),h("div",ve,[l("div",we,[l("div",{class:"flex items-center cursor-pointer",onClick:t[5]||(t[5]=c=>n.viewAttachment(o.form.attachment))},[i(O,{image:n.getFileTypeImage(o.form.attachment)},null,8,["image"]),N(" "+v(o.form.attachment),1)]),o.form.status==0&&o.form.days<3?(a(),h("div",be,[i(P,{icon:"mingcute:delete-2-fill",onClick:t[6]||(t[6]=c=>e.deleteFile(o.form.id))})])):d("",!0)])])):d("",!0)]),_:1})])]),l("div",xe,[o.state.isEdit?(a(),y(B,{key:1,onClick:n.submitForm},null,8,["onClick"])):(a(),y(F,{key:0,onClick:n.submitForm},null,8,["onClick"])),i(s,{onClick:n.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const ke=I(pe,[["render",Ce],["__scopeId","data-v-91e9a90f"]]);const Oe={mixins:[M],components:{Card:A,Button:j,Badge:q,Layout:U,Icon:D,CreateButton:J,SubmitButton:L,CloseButton:T,EditButton:X,DeleteButton:K,Form:ke,InputGroup:G,Loading:V},data(){return{breadcrumbs:[{text:"Home",href:"/"},{text:"Dcument Tracker",href:"/document-tracker"},{text:"Doument Tracker",active:!0}],columns:[{label:"#",field:"#"},{label:"Employee",field:"employee_id"},{label:"Sent To",field:"send_to"},{label:"Document Type",field:"document_type"},{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:W.debounce(function(){this.fetchRecords()},800)},computed:{perPage:function(){return this.serverOptions.rowsPerPage}},methods:{async fetchRecords(){this.state.isLoading=!0,await S.fetchRecords({keyword:this.searchQuery,page:this.serverOptions.page,per_page:this.serverOptions.rowsPerPage,sortBy:this.serverOptions.sortBy,sortType:this.serverOptions.sortType}).then(e=>{let t=e.data.data;console.log(t),this.items=t,this.items=t.map((m,g)=>({...m,"#":(this.serverOptions.page-1)*this.serverOptions.rowsPerPage+(g+1)})),this.totalItems=e.data.total}).finally(()=>{this.state.isLoading=!1})},reload(){this.$emit("reload")},handlePageChange(e){console.log(e),console.log(this.serverOptions.page),this.serverOptions.page!=e&&(this.serverOptions.page=e)},handlePerPageChange(e){this.serverOptions.page=1,this.serverOptions.rowsPerPage=e},onSortChange(e){console.log(e),e[0].type!="none"&&(this.serverOptions.sortBy=e[0].field,this.serverOptions.sortType=e[0].type)},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,S.remove(e).then(m=>{m.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})},createRecord(){this.$refs.form.resetForm(),this.$refs.form.state.showModal=!0},editRecord(e){console.log(e),this.$refs.form.resetForm(),this.$refs.form.loadRecord(e),this.$refs.form.state.showModal=!0},handlePageChange(e){console.log(e),console.log(this.serverOptions.page),this.serverOptions.page!=e&&(this.serverOptions.page=e)},handlePerPageChange(e){this.serverOptions.page=1,this.serverOptions.rowsPerPage=e}},mounted(){this.fetchRecords()}},Pe={class:"space-y-4 mt-4"},Fe={class:"md:flex pb-6 items-center"},Be={class:"flex-1 md:mb-0 mb-3"},Re={key:0,class:"block min-w-[140px] text-left"},Se={class:"inline-block text-center mx-auto py-1"},Ee={key:0,class:"flex items-center space-x-3 rtl:space-x-reverse"},De={key:1,class:"flex items-center space-x-3 rtl:space-x-reverse"},Ie={key:1,class:"flex gap-1"},Te={key:2,class:"flex gap-1"},Le={key:3,class:"flex gap-1"},Ve={key:4,class:"flex gap-1"},Me={class:"py-4 flex justify-end"};function Ue(e,t,m,g,o,n){const u=r("InputGroup"),_=r("Button"),p=r("EditButton"),x=r("DeleteButton"),C=r("Pagination"),k=r("vue-good-table"),O=r("Card"),P=r("Loading"),F=r("Form"),B=r("Layout");return a(),y(B,{breadcrumbs:o.breadcrumbs},{default:f(()=>[l("div",Pe,[i(O,{title:"Document Tracker"},{default:f(()=>[l("div",Fe,[l("h6",Be,v(e.title),1),l("div",{class:z(["md:flex md:space-x-3 items-center flex-none rtl:space-x-reverse my-3 float-right",e.window.width<768?"space-x-rb":""])},[i(u,{modelValue:o.searchQuery,"onUpdate:modelValue":t[0]||(t[0]=s=>o.searchQuery=s),placeholder:"Search",type:"text",prependIcon:"heroicons-outline:search",merged:""},null,8,["modelValue"]),i(_,{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"}),i(_,{icon:"heroicons-outline:plus-sm",text:"Add Record",btnClass:" btn-dark font-normal btn-sm ",iconClass:"text-lg",onClick:t[1]||(t[1]=s=>n.createRecord())})],2)]),i(k,{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:n.onSortChange,"max-height":"600px"},{"table-row":f(s=>[s.column.field=="status"?(a(),h("span",Re,[l("span",Se,[s.row.status=="0"?(a(),h("span",Ee,t[3]||(t[3]=[l("span",{class:"h-[6px] w-[6px] bg-warning-500 rounded-full inline-block ring-4 ring-opacity-30 ring-warning-500"},null,-1),l("span",null," Pending ",-1)]))):d("",!0),s.row.status=="1"?(a(),h("span",De,t[4]||(t[4]=[l("span",{class:"h-[6px] w-[6px] bg-success-500 rounded-full inline-block ring-4 ring-opacity-30 ring-success-500"},null,-1),l("span",null," Approved ",-1)]))):d("",!0)])])):d("",!0),s.column.field=="employee_id"?(a(),h("div",Ie,v(s.row.employee.firstname+" "+s.row.employee.lastname),1)):d("",!0),s.column.field=="send_to"?(a(),h("div",Te,v(s.row.sent_to.firstname+" "+s.row.sent_to.lastname),1)):d("",!0),s.column.field=="document_type"?(a(),h("div",Le,v(s.row.supporting_document.module_name),1)):d("",!0),s.column.field=="action"?(a(),h("div",Ve,[i(p,{onClick:R=>n.editRecord(s.row)},null,8,["onClick"]),i(x,{onClick:R=>n.deleteRecord(s.row.id)},null,8,["onClick"])])):d("",!0)]),"pagination-bottom":f(s=>[l("div",Me,[i(C,{total:o.totalItems,current:o.serverOptions.page,"per-page":o.serverOptions.rowsPerPage,onPageChanged:n.handlePageChange,pageChanged:s.pageChanged,perPageChanged:o.serverOptions.rowsPerPage,enableSelect:"",perPageOptions:o.perPageOptions,onChangePerPage:n.handlePerPageChange},null,8,["total","current","per-page","onPageChanged","pageChanged","perPageChanged","perPageOptions","onChangePerPage"])])]),_:1},8,["columns","rows","onSortChange"])]),_:1}),o.state.isLoading?(a(),y(P,{key:0,text:"Fetching records"})):d("",!0),i(F,{onCloseModal:t[2]||(t[2]=s=>o.state.showModal=!1),onReload:n.fetchRecords,ref:"form"},null,8,["onReload"])])]),_:1},8,["breadcrumbs"])}const qt=I(Oe,[["render",Ue],["__scopeId","data-v-d256711a"]]);export{qt as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.13 |
proxy
|
phpinfo
|
Settings