File manager - Edit - /home/autoph/public_html/projects/ahg-hr/assets/index.bae2e90c.js
Back
import{w as K,L as Q}from"./index.f5fec97e.js";import{C as J}from"./index.2ecb62fe.js";import{B as X}from"./index.b36b35c2.js";import{B as $}from"./index.84e315d2.js";import{I as M}from"./index.7c87e136.js";import{I as ee}from"./index.44224e48.js";import"./lodash.8c8ef874.js";import{_ as T,q as V,r as d,o as a,c as _,w as f,j as h,b as c,d as o,k as U,p as L,s as q,e as r,t as y,f as R}from"./index.d09cba45.js";import{E as S,C as H}from"./EmployeeChangeScheduleService.bbe96781.js";import{C as B}from"./CloseButton.ad974e55.js";import{C as te}from"./CreateButton.cdb3dab6.js";import{D as se}from"./DeleteButton.f830e860.js";import{E as oe}from"./EditButton.3ca5c2a0.js";/* empty css */import{S as E}from"./SubmitButton.8e326bc2.js";import{A as ie}from"./ActionCellRenderer.00e0a176.js";/* empty css */import"./vue-cleave.min.3d6c67b7.js";import{c as re,a as D,V as A}from"./array.41230547.js";import{L as I}from"./Loading.10020070.js";import"./vue-quill.snow.4fe86b91.js";/* empty css */import{F as O}from"./index.97ec51ba.js";import{F as z}from"./index.55a245df.js";import{T as N}from"./index.78f61ffe.js";import{T as j}from"./index.b10a2de6.js";import{U as Y}from"./UpdateButton.6d6860a3.js";import"./jspdf.es.min.41d1f521.js";/* empty css */import{A as P}from"./ApproverService.76f54c21.js";import{M as G}from"./Multiselect.a5040e09.js";import{F as W}from"./index.691693c1.js";import{C as Z}from"./index.89324a83.js";import{A as ae}from"./main.esm.9a8e7f98.js";import{D as ne}from"./DenyButton.d9171afd.js";import{F as le}from"./index.1a164470.js";import"./logo-black.7c15feb3.js";import"./logo-white.b04c5a89.js";import"./transition.979a347a.js";import"./EmployeeService.b43eb678.js";import"./es.string.replace.f405e891.js";import"./ViewButton.6bb26f2f.js";import"./Loading.vue_vue_type_style_index_0_scoped_cbded5a2_lang.0b8030ab.js";import"./index.a8395b59.js";import"./ck-white.4bf441fa.js";import"./index.43f4db3f.js";const de={components:{Fileinput:W,FormModal:z,FormGroup:O,TextInput:N,Textarea:j,SubmitButton:E,UpdateButton:Y,CloseButton:B,Loading:I,Multiselect:G,Icon:M,Checkbox:Z},data(){return{recommending:"",recommending_img:"",approving:"",approving_img:"",form:{date:"",date_to:null,from_time:null,to_time:null,dayoff:!1,description:"",attachment:"",dayoff_date:null,recommending_id:"",allow_higher_approval:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isCompanyLoading:!1,isHoursValidationLoading:!1},isHoursEqual:!1,isAllDaysEqual:!1}},methods:{reload(){return this.$emit("reload")},handleMainImageUpload(){const s=event.target.files[0];this.form.attachment=s;const e=new FileReader;e.onload=()=>{s.type.startsWith("image/")?this.form.imageView=e.result:s.type==="application/pdf"?this.form.imageView=this.pdf_file_view:s.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},console.log(s),e.readAsDataURL(s)},loadRecord(s){this.resetForm(),this.state.isEdit=!0,this.form=s,this.form.dayoff=s.dayoff==1},closeModal(){this.state.showModal=!1},resetForm(){this.state.isSaving=!1,this.state.isEdit=!1,this.form={date:"",date_to:"",from_time:"",to_time:"",dayoff:!1,description:"",attachment:"",dayoff_date:null,allow_higher_approval:"",recommending_id:this.form.recommending_id,approver_id:this.form.approver_id}},async fetchApprover(){this.state.isLoading=!0,await P.fetchApproverRecords().then(s=>{this.$store.userSettings.getActiveUser.employees.classification_id==1&&s.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&&s.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&&s.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(s=>{console.log(s)})},async calculateDays(){if(this.form.date&&(this.form.date_to||this.form.dayoff&&this.form.dayoff_date)&&this.form.from_time&&this.form.to_time){this.state.isHoursValidationLoading=!0;const s=this.form.dayoff?V(this.form.dayoff_date):V(this.form.date);console.log("asddddsadsadsa",this.form.dayoff);const e=this.form.dayoff?s:V(this.form.date_to);let i={date_from:s.format("YYYY-MM-DD"),date_to:e.format("YYYY-MM-DD")};try{let t=(await S.fetchWorkingHours(i)).data;t.status?(this.isAllDaysEqual=!1,console.log("total hours",t.hoursTotal)):(this.isAllDaysEqual=!0,console.log("hours are not the same kindly file a different request for different time schedule"));const[l,p]=this.form.from_time.split(":").map(Number),[g,u]=this.form.to_time.split(":").map(Number),x=new Date(0,0,0,l,p);let v=(new Date(0,0,0,g,u)-x)/(1e3*60*60)-1;console.log("total hours"),console.log(t.hoursTotal),console.log(v),t.hoursTotal%v!=0?(this.isHoursEqual=!0,console.log("Hours is not the same to your regular schedule")):(this.isHoursEqual=!1,console.log("Hours is the same to your regular schedule")),this.state.isHoursValidationLoading=!1}catch(m){m.response.data.message=='Attempt to read property "schedule" on null'?this.noSchedule=!0:console.log(m)}}},async saveRecord(){if(this.state.isEdit){this.form.id;let s=new FormData;Object.keys(this.form).forEach(e=>{s.append(e,this.form[e])}),await S.update(s).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.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})}).finally(()=>this.state.isSaving=!1)}else{this.state.isSaving=!0;let s=new FormData;Object.keys(this.form).forEach(e=>{s.append(e,this.form[e])}),await S.create(s).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})}).finally(()=>this.state.isSaving=!1)}},async submitForm(){try{!this.isHoursEqual&&!this.isAllDaysEqual&&(await re().shape({date:D().required("Date is required"),from_time:D().nullable().required("From time is required"),to_time:D().nullable().required("To time is required"),dayoff_date:this.form.dayoff?D().nullable().required("New dayoff date 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(s){if(s instanceof A){const e={};s.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}this.state.isSaving=!1}}},mounted(){this.fetchApprover()},watch:{"form.allow_higher_approval":{handler:"fetchApprover",immediate:!0},"form.dayoff"(s){s?(this.form.date_to=this.form.dayoff_date,this.calculateDays()):(this.form.date_to=this.form.date_to,this.calculateDays())},"form.from_time":{handler:"calculateDays",immediate:!0},"form.to_time":{handler:"calculateDays",immediate:!0}}},me={key:1,class:"text-slate-600 dark:text-slate-400 text-sm font-normal mb-6"},ce={class:"bg-red-50 dark:bg-red-900 dark:bg-opacity-30 border-l-4 border-red-500 p-4 rounded-md shadow-sm"},fe={class:"text-red-600 dark:text-red-400 text-sm"},ue={type:"disc",class:"list-inside list-disc"},he={key:0},pe={key:1},ge={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},_e={class:"grid grid-cols-12 gap-4"},ye={class:"col-span-12 flex items-center gap-4"},ve={class:"flex items-center cursor-pointer"},xe=["checked","disabled"],be={key:0,class:"col-span-12"},we={key:0,class:"text-[#ec4899]"},ke={key:1,class:"col-span-6"},Ce={key:0,class:"text-[#ec4899]"},Fe={key:2,class:"col-span-6"},Se={class:"col-span-6"},De={key:0,class:"text-[#ec4899]"},Ae={class:"col-span-6"},Re={key:0,class:"text-[#ec4899]"},Ve={key:3,class:"col-span-12"},Me={key:0,class:"text-[#ec4899]"},Te={class:"col-span-12"},Be={class:"col-span-12"},Ee={class:"grid grid-cols-12 gap-4"},Ie={class:"col-span-6 flex items-center p-4 bg-gray-100 rounded-lg shadow-md"},Le={class:"flex-shrink-0 mr-4"},qe=["src"],He={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Ue={class:"text-left"},Oe={class:"text-sm font-semibold text-gray-600"},ze={class:"text-lg font-bold text-gray-900"},Ne={key:0,class:"text-sm text-gray-900"},je={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"},Pe={class:"flex-shrink-0 mr-4"},Ge=["src"],We={key:1,class:"w-16 h-16 rounded-full object-cover bg-black-200 flex justify-center items-center"},Ze={class:"text-left"},Ke={class:"text-lg font-bold text-gray-900"},Qe={class:"text-sm text-gray-900"},Je={class:"flex gap-2 justify-between"},Xe={class:"flex items-center cursor-pointer"},$e=["checked","disabled"],et={class:"flex gap-2"};function tt(s,e,i,m,t,l){const p=d("Loading"),g=d("flat-pickr"),u=d("FormGroup"),x=d("Textarea"),k=d("Fileinput"),b=d("Card"),w=d("SubmitButton"),v=d("UpdateButton"),C=d("CloseButton"),F=d("FormModal");return a(),_(F,{title:t.form.status!==0?"Change Schedule Application Form":t.state.isEdit?"Edit OB":"Change Schedule Application Form",active:t.state.showModal,onSubmit:s.confirmSubmit,onClose:l.closeModal,themeClass:t.state.isEdit&&t.form.status==0?"bg-primary-600":"bg-gray-800",sizeClass:"lg:w-3/4"},{default:f(()=>[t.state.isLoading?(a(),_(p,{key:0,text:"Fetching record"})):h("",!0),t.isHoursEqual||t.isAllDaysEqual?(a(),c("div",me,[o("div",ce,[e[11]||(e[11]=o("h3",{class:"text-red-700 dark:text-red-300 font-semibold mb-1 text-sm"}," Reason: ",-1)),o("p",fe,[o("ul",ue,[t.isHoursEqual?(a(),c("li",he," Hours must be equal to your schedule ")):h("",!0),t.isAllDaysEqual?(a(),c("li",pe," Both dates hours are not the same kindly file a different request for different time schedule ")):h("",!0)])])])])):h("",!0),o("div",ge,[o("form",{onSubmit:e[10]||(e[10]=U((...n)=>s.confirmSubmit&&s.confirmSubmit(...n),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[t.state.isSaving?(a(),_(p,{key:0,text:"Saving record"})):h("",!0),o("div",_e,[o("div",ye,[o("label",ve,[L(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:t.form.dayoff,"onUpdate:modelValue":e[0]||(e[0]=n=>t.form.dayoff=n),disabled:t.form.status==2||t.form.status==1},null,8,xe),[[q,t.form.dayoff]]),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"},"Change Day Off",-1))])]),t.form.dayoff?(a(),c("div",be,[r(u,{label:"Select the date of day-off you want to change",isRequired:!0,labelClass:"font-semibold text-blue-500"},{default:f(()=>[r(g,{modelValue:t.form.date,"onUpdate:modelValue":e[1]||(e[1]=n=>t.form.date=n),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M",disabled:t.form.status==2||t.form.status==1},null,8,["modelValue","disabled"]),t.errors.date?(a(),c("div",we,"Date is required")):h("",!0)]),_:1})])):(a(),c("div",ke,[r(u,{label:"Date From",isRequired:!0},{default:f(()=>[r(g,{modelValue:t.form.date,"onUpdate:modelValue":e[2]||(e[2]=n=>t.form.date=n),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M",onInput:l.calculateDays,disabled:t.form.status==2||t.form.status==1},null,8,["modelValue","onInput","disabled"]),t.errors.date?(a(),c("div",Ce,"Date is required")):h("",!0)]),_:1})])),t.form.dayoff?h("",!0):(a(),c("div",Fe,[r(u,{label:"Date To"},{default:f(()=>[r(g,{modelValue:t.form.date_to,"onUpdate:modelValue":e[3]||(e[3]=n=>t.form.date_to=n),class:"form-control h-[48px]",id:"dateto",placeholder:"yyyy, dd M",onInput:l.calculateDays,disabled:t.form.status==2||t.form.status==1},null,8,["modelValue","onInput","disabled"])]),_:1})])),o("div",Se,[r(u,{label:"From Time",isRequired:!0},{default:f(()=>[r(g,{class:"form-control h-[48px]",placeholder:"From time",modelValue:t.form.from_time,"onUpdate:modelValue":e[4]||(e[4]=n=>t.form.from_time=n),disabled:t.form.status==2||t.form.status==1,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","disabled"]),t.errors.from_time?(a(),c("div",De,"From Time is required")):h("",!0)]),_:1})]),o("div",Ae,[r(u,{label:"To Time",isRequired:!0},{default:f(()=>[r(g,{class:"form-control h-[48px]",placeholder:"To time",modelValue:t.form.to_time,"onUpdate:modelValue":e[5]||(e[5]=n=>t.form.to_time=n),disabled:t.form.status==2||t.form.status==1,config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue","disabled"]),t.errors.from_time?(a(),c("div",Re,"To Time is required")):h("",!0)]),_:1})]),t.form.dayoff?(a(),c("div",Ve,[r(u,{label:"Select new day-off",labelClass:"font-semibold text-blue-500",isRequired:""},{default:f(()=>[r(g,{modelValue:t.form.dayoff_date,"onUpdate:modelValue":e[6]||(e[6]=n=>t.form.dayoff_date=n),class:"form-control h-[48px]",id:"dateto",placeholder:"yyyy, dd M",onInput:l.calculateDays,disabled:t.form.status==2||t.form.status==1},null,8,["modelValue","onInput","disabled"]),t.errors.dayoff_date?(a(),c("div",Me,y(t.errors.dayoff_date),1)):h("",!0)]),_:1})])):h("",!0),o("div",Te,[r(u,{label:"Remarks"},{default:f(()=>[r(x,{name:"pn4",placeholder:"",modelValue:t.form.description,"onUpdate:modelValue":e[7]||(e[7]=n=>t.form.description=n),disabled:t.form.status==2||t.form.status==1},null,8,["modelValue","disabled"])]),_:1})]),o("div",Be,[r(u,{label:"Attachment"},{default:f(()=>[r(b,{title:"File Input Basic"},{default:f(()=>[r(k,{name:"basic",onChange:e[8]||(e[8]=n=>l.handleMainImageUpload()),class:"h-[48px]",multiple:"",disabled:t.form.status==2||t.form.status==1},null,8,["disabled"])]),_:1})]),_:1})])]),o("div",Ee,[o("div",Ie,[o("div",Le,[t.recommending_img?(a(),c("img",{key:0,src:t.recommending_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,qe)):(a(),c("div",He," No Image "))]),o("div",Ue,[o("div",Oe,y(t.form.allow_higher_approval?"Recommending":"Approving"),1),o("div",ze,y(t.recommending),1),t.form.allow_higher_approval?(a(),c("div",Ne,y(t.form.recommended_at?"Date: ("+this.$formatDate(t.form.recommended_at)+")":""),1)):(a(),c("div",je,y(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1))])]),t.form.allow_higher_approval?(a(),c("div",Ye,[o("div",Pe,[t.approving_img?(a(),c("img",{key:0,src:t.approving_img,alt:"Profile",class:"w-16 h-16 rounded-full object-cover"},null,8,Ge)):(a(),c("div",We," No Image "))]),o("div",Ze,[e[14]||(e[14]=o("div",{class:"text-sm font-semibold text-gray-600"},"Approving",-1)),o("div",Ke,y(t.approving),1),o("div",Qe,y(t.form.approved_at?"Date: ("+this.$formatDate(t.form.approved_at)+")":""),1)])])):h("",!0)]),o("div",Je,[o("div",null,[o("label",Xe,[L(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:t.form.allow_higher_approval,"onUpdate:modelValue":e[9]||(e[9]=n=>t.form.allow_higher_approval=n),disabled:t.form.status==2||t.form.status==1},null,8,$e),[[q,t.form.allow_higher_approval]]),e[15]||(e[15]=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[16]||(e[16]=o("span",{class:"ml-2 text-slate-500 dark:text-slate-400 text-sm"},"Allow Higher Head Approval?",-1))])]),o("div",et,[t.state.isEdit?t.form.status===0?(a(),_(v,{key:1,onClick:l.submitForm},null,8,["onClick"])):h("",!0):(a(),_(w,{key:0,onClick:l.submitForm,icon:t.state.isHoursValidationLoading?"svg-spinners:tadpole":"carbon:save",text:t.state.isHoursValidationLoading?"Loading":"Submit",disabled:t.state.isHoursValidationLoading},null,8,["onClick","icon","text","disabled"])),r(C,{onClick:l.closeModal},null,8,["onClick"])])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"])}const st=T(de,[["render",tt],["__scopeId","data-v-722fbb7f"]]);const ot={components:{Fileinput:W,DenyButton:ne,FormModal:z,FormGroup:O,TextInput:N,Textarea:j,SubmitButton:E,UpdateButton:Y,CloseButton:B,Loading:I,Multiselect:G,Icon:M,Checkbox:Z},data(){return{companyOptions:[],currentEmployeeId:this.$store.userSettings.getActiveUser.employees?this.$store.userSettings.getActiveUser.employees.employee_id:"",currentClassificationId:this.$store.userSettings.getActiveUser.employees?this.$store.userSettings.getActiveUser.employees.classification_id:"",currentRecommendingId:"",currentApprovingId:"",btnTitle:"",recommendingOptions:[],approvingOptions:[],recommending:"",approving:"",status:[],form:{date:"",from_from:"",to_time:"",description:"",attachment:"",recommending_id:"",approver_id:""},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,isCompanyLoading:!1}}},methods:{handleMainImageUpload(){const s=event.target.files[0];this.form.attachment=s;const e=new FileReader;e.onload=()=>{s.type.startsWith("image/")?this.form.imageView=e.result:s.type==="application/pdf"?this.form.imageView=this.pdf_file_view:s.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&&(this.form.imageView=this.excel_file_view)},e.readAsDataURL(s)},async loadRecord(s){this.resetForm(),this.form=s,this.form.date=new Date(s.date).toLocaleDateString("en-CA").split("T")[0],this.currentRecommendingId=s.recommending?s.recommending[0].employee_id:"",this.currentApprovingId=s.approving?s.approving[0].employee_id:"",this.recommending=s.recommending?s.recommending[0].firstname+" "+s.recommending[0].lastname:"",this.approving=s.approving?s.approving[0].firstname+" "+s.approving[0].lastname:"",this.currentRecommendingId==this.currentEmployeeId&&this.form.status<1?this.btnTitle="Submit For Approval":this.currentApprovingId==this.currentEmployeeId&&(this.btnTitle="Approve"),this.currentClassificationId>=3&&await P.fetchEmployeeApprover(s.employee_id).then(e=>{if(e.status==200)this.recommendingOptions=e.data.map((i,m)=>({value:i.employee_id,label:i.firstname+" "+i.lastname})),this.approvingOptions=e.data.filter(i=>i.classification_id>=3).map((i,m)=>({value:i.employee_id,label:i.firstname+" "+i.lastname}));else throw new Error("Failed to fetch employee approvers")})},closeModal(){this.state.showModal=!1},resetForm(){this.state.isEdit=!1,this.form={date:"",from_time:"",to_time:"",description:"",attachment:"",recommending_id:"",approver_id:""}},reload(){return this.state.showModal=!1,this.state.isSaving=!1,this.$emit("reload")},async updateApproverRecord(){this.state.isSaving=!0;const s=this.form.id;this.state.isSaving=!1;let e={recommending_id:this.form.recommending_id,approver_id:this.form.approver_id};await H.updateApprover(s,e).then(i=>{i.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(i=>{i.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:i.response.data.message,icon:"warning"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})})},async saveRecord(){this.state.isSaving=!0;const s=this.form.id;await H.update(s,this.status).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})})},async submitForm(){this.form.recommending_id==this.currentEmployeeId&&(this.status={status:1}),this.form.approver_id==this.currentEmployeeId&&(this.status={status:2});try{this.$swal.fire({title:"Are you sure you want to save submit this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(s=>{s.value&&this.saveRecord()})}catch(s){if(s instanceof A){const e={};s.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},async updateApproverForm(){try{this.$swal.fire({title:"Are you sure you want to update the approver of this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(s=>{s.value&&this.updateApproverRecord()})}catch(s){if(s instanceof A){const e={};s.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},async denyForm(){this.status={status:99};try{this.$swal.fire({title:"Are you sure you want to deny this record?",text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No",html:` <textarea id="swal-input" style="width: 100%; height: 80px; padding: 8px; border: 1px solid #ced4da; border-radius: 4px;" placeholder="Enter reason"></textarea>`,preConfirm:()=>{const s=document.getElementById("swal-input").value;return s?this.denied_reason=s:(this.$swal.showValidationMessage("The reason field is required"),!1)}}).then(s=>{this.status={status:99,denied_reason:this.denied_reason},s.value&&this.saveRecord()})}catch(s){if(s instanceof A){const e={};s.inner.forEach(i=>{e[i.path]=i.message}),this.errors=e}}},calculateHours(){const s=this.form.from_time,e=this.form.to_time;if(s&&e){const[i,m]=this.form.from_time.split(":").map(Number),[t,l]=this.form.to_time.split(":").map(Number);let p=t-i;p+=(l-m)/60,p<0&&(p+=24),this.form.hours=p}}}},it={class:"text-slate-600 dark:text-slate-400 text-sm font-normal"},rt={key:0,class:"bg-red-50 dark:bg-red-900 dark:bg-opacity-30 border-l-4 border-red-500 p-4 rounded-md shadow-sm"},at={class:"text-red-600 dark:text-red-400 text-sm"},nt={class:"grid grid-cols-12 gap-4"},lt={class:"col-span-12"},dt={class:"col-span-6"},mt={class:"col-span-6"},ct={class:"col-span-12"},ft={class:"col-span-12"},ut={key:1},ht={class:"grid grid-cols-12 justify-center items-center"},pt={class:"col-span-8 flex justify-between items-center gap-4"},gt={class:"col-span-6 flex justify-center items-center gap-4"},_t={class:"font-bold"},yt={class:"col-span-6 flex justify-center items-center gap-4"},vt={class:"font-bold"},xt={key:2},bt={class:"grid grid-cols-12 gap-4"},wt={class:"col-span-6"},kt={class:"relative"},Ct={class:"col-span-6"},Ft={class:"relative"},St={class:"flex gap-1 justify-end pt-8"},Dt={key:0,class:"flex gap-1 justify-end"},At={key:1,class:"flex gap-1 justify-end"};function Rt(s,e,i,m,t,l){const p=d("Loading"),g=d("flat-pickr"),u=d("FormGroup"),x=d("Textarea"),k=d("Fileinput"),b=d("Multiselect"),w=d("UpdateButton"),v=d("DenyButton"),C=d("CloseButton"),F=d("FormModal");return a(),_(F,{title:"View Record",active:t.state.showModal,sideTitle:this.form.status==0?"for recommendation":this.form.status==1?"for approval":this.form.status==2&&this.form.validated==1?"Approved & Validated":this.form.status==2&&this.form.validated==99?"Denied":this.form.status==2?"For Validation":this.form.status==99?"denied":"",badgeColor:this.form.status==0?"warning":this.form.status==1?"info":this.form.status==2&&this.form.validated==1?"success":this.form.status==2&&this.form.validated==99?"danger":this.form.status==2?"purple":this.form.status==99?"danger":"",onSubmit:s.confirmSubmit,onClose:l.closeModal,themeClass:"bg-gray-800",sizeClass:"lg:w-3/4"},{default:f(()=>[t.state.isEdit&&t.state.isLoading?(a(),_(p,{key:0,text:"Fetching record"})):h("",!0),o("div",it,[this.form.status==2&&this.form.validated==99?(a(),c("div",rt,[e[8]||(e[8]=o("h3",{class:"text-red-700 dark:text-red-300 font-semibold mb-1 text-sm"}," Deferred Reason ",-1)),o("p",at,y(this.form.deferred_reason),1)])):h("",!0),o("form",{onSubmit:e[7]||(e[7]=U((...n)=>s.confirmSubmit&&s.confirmSubmit(...n),["prevent"])),class:"space-y-4",enctype:"multipart/form-data"},[t.state.isSaving?(a(),_(p,{key:0,text:"Saving record"})):h("",!0),o("div",nt,[o("div",lt,[r(u,{label:"Date",isRequired:!0},{default:f(()=>[r(g,{modelValue:t.form.date,"onUpdate:modelValue":e[0]||(e[0]=n=>t.form.date=n),class:"form-control h-[48px]",id:"date",placeholder:"yyyy, dd M"},null,8,["modelValue"])]),_:1})]),o("div",dt,[r(u,{label:"From Time",isRequired:!0},{default:f(()=>[r(g,{class:"form-control h-[48px]",placeholder:"From time",modelValue:t.form.from_time,"onUpdate:modelValue":e[1]||(e[1]=n=>t.form.from_time=n),config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue"])]),_:1})]),o("div",mt,[r(u,{label:"To Time",isRequired:!0},{default:f(()=>[r(g,{class:"form-control h-[48px]",placeholder:"To time",modelValue:t.form.to_time,"onUpdate:modelValue":e[2]||(e[2]=n=>t.form.to_time=n),config:{enableTime:!0,noCalendar:!0,dateFormat:"H:i"}},null,8,["modelValue"])]),_:1})]),o("div",ct,[r(u,{label:"Remarks"},{default:f(()=>[r(x,{name:"pn4",placeholder:"",modelValue:t.form.description,"onUpdate:modelValue":e[3]||(e[3]=n=>t.form.description=n)},null,8,["modelValue"])]),_:1})]),o("div",ft,[r(u,{label:"Attachment"},{default:f(()=>[r(k,{name:"basic",onChange:e[4]||(e[4]=n=>l.handleMainImageUpload()),class:"h-[48px]",multiple:""})]),_:1})])]),t.currentClassificationId<=2?(a(),c("div",ut,[o("div",ht,[o("div",pt,[o("div",gt,[e[9]||(e[9]=R(" Recommending: ")),o("p",_t,y(t.recommending),1)]),o("div",yt,[e[10]||(e[10]=R(" Approving: ")),o("p",vt,y(t.approving),1)])])])])):(a(),c("div",xt,[o("div",bt,[o("div",wt,[r(u,{label:"Recommending"},{default:f(()=>[o("div",kt,[r(b,{modelValue:t.form.recommending_id,"onUpdate:modelValue":e[5]||(e[5]=n=>t.form.recommending_id=n),"close-on-select":!0,searchable:!0,id:"recommending_id",options:t.recommendingOptions},null,8,["modelValue","options"])])]),_:1})]),o("div",Ct,[r(u,{label:"Approver"},{default:f(()=>[o("div",Ft,[r(b,{modelValue:t.form.approver_id,"onUpdate:modelValue":e[6]||(e[6]=n=>t.form.approver_id=n),"close-on-select":!0,searchable:!0,id:"approver_id",options:t.approvingOptions},null,8,["modelValue","options"])])]),_:1})])])])),o("div",St,[this.form.status==0&&t.currentRecommendingId==t.currentEmployeeId||t.currentApprovingId==t.currentEmployeeId&&this.form.status==1&&t.currentApprovingId==this.form.approver_id||this.form.approver_id==this.form.recommending_id&&t.currentApprovingId==this.form.approver_id&&t.currentEmployeeId==this.form.approver_id?(a(),c("div",Dt,[this.form.status<=1?(a(),_(w,{key:0,onClick:l.submitForm,text:t.btnTitle},null,8,["onClick","text"])):h("",!0),r(v,{onClick:l.denyForm,text:"Deny"},null,8,["onClick"])])):this.form.status==0&&t.currentApprovingId==t.currentEmployeeId||t.currentApprovingId!=this.form.approver_id?(a(),c("div",At,[this.form.status<=1?(a(),_(w,{key:0,onClick:l.updateApproverForm,text:"Update Approver"},null,8,["onClick"])):h("",!0)])):h("",!0),r(C,{onClick:l.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["active","sideTitle","badgeColor","onSubmit","onClose"])}const Vt=T(ot,[["render",Rt],["__scopeId","data-v-659bcef9"]]);const Mt={mixins:[K],components:{FilterTimekeeping:le,ActionCellRenderer:ie,AgGridVue:ae,Card:J,Button:X,Badge:$,Layout:Q,Icon:M,CreateButton:te,SubmitButton:E,CloseButton:B,EditButton:oe,DeleteButton:se,Form:st,InputGroup:ee,Loading:I,View:Vt},data(){return{paginationPageSize:10,paginationPageSizeSelector:[10,25,50],colDefs:[{field:"#",flex:1},{field:"date",filter:!0,floatingFilter:!0,flex:2},{headerName:"Date To",field:"date_to",filter:!0,floatingFilter:!0,flex:2},{field:"time coverage",filter:!0,floatingFilter:!0,flex:2},{headerName:"Change Dayoff",field:"dayoff",filter:!0,floatingFilter:!0,valueGetter:s=>{switch(s.data.dayoff){case 0:return"No";case 1:return"Yes";default:return""}},cellRenderer:s=>{switch(s.value){case"No":return'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-slate-600 bg-slate-100 px-4">No</span>';case"Yes":return'<span class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 text-green-600 bg-green-100 px-4">Yes</span>';default:return""}}},{headerName:"New Dayoff",field:"dayoff_date",filter:!0,floatingFilter:!0},{field:"date created",filter:!0,floatingFilter:!0},{headerName:"Status",field:"status",filter:!0,floatingFilter:!0,valueGetter:s=>{if(s.data.status==2&&s.data.validated==1)return"Approved & validated";if(s.data.status==2&&s.data.validated==99)return"Deferred by HR";switch(s.data.status){case 0:return"For Recommendation";case 1:return"For Approval";case 2:return"Approved";case 99:return"Denied";default:return""}},cellRenderer:s=>{const e=s.value,i=document.createElement("div");switch(e){case"For Recommendation":i.innerHTML='<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>';break;case"For Approval":i.innerHTML='<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>';break;case"Approved & validated":i.innerHTML='<div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-green-600 px-4">Approved & validated</div>';break;case"Deferred by HR":i.innerHTML=` <div class="inline-block rounded-full text-xs capitalize whitespace-nowrap text-center py-1 bg-gray-100 text-red-600 px-4"> Deferred by HR <button class="ml-2 inline-flex items-center px-2 py-1 text-white text-sm font-medium rounded hover:bg-white-700 focus:ring-2 focus:ring-yellow-500 focus:outline-none view-button" title="View details of why it was deferred"> <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1 text-yellow-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"> <path stroke-linecap="round" stroke-linejoin="round" d="M10 4H4a2 2 0 00-2 2v12a2 2 0 002 2h16a2 2 0 002-2V8a2 2 0 00-2-2h-6l-2-2H10a2 2 0 00-2 2v0z" /> </svg> </button> </div>`,i.querySelector(".view-button").addEventListener("click",()=>{this.view(s.data)});break;case"Approved":i.innerHTML='<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>';break;case"Denied":i.innerHTML='<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>';break;default:i.innerHTML=""}return i}},{headerName:"Actions",cellRenderer:"ActionCellRenderer",flex:1,cellRendererParams:{context:{componentParent:this}}}],breadcrumbs:[{text:"Home",href:"/"},{text:"Timekeeping",href:"/attendance/employee-change-schedule"},{text:"Change Schedule Application",active:!0}],items:[],totalItems:0,searchQuery:null,state:{isLoading:!1,isEdit:!1,isDeleting:!1}}},watch:{},computed:{},methods:{applyFilters(s){if(!s||Object.keys(s).length===0){const e=new Date;let i=e.getFullYear(),m=e.getMonth()+1,t=m-1||12;t===12&&(i-=1);const l=m.toString().padStart(2,"0"),p=t.toString().padStart(2,"0"),g=e.getDate();s={range:g>1&&g<15?`${i}-${p}-21 to ${e.getFullYear()+1}-${l}-05`:`${e.getFullYear()}-${l}-06 to ${e.getFullYear()+1}-${l}-20`}}this.fetchRecords(s)},onGridReady(s){this.gridApi=s.api},exportToCsv(){this.gridApi?this.gridApi.exportDataAsCsv({onlySelected:!1,columnKeys:this.colDefs.filter(s=>s.field!=="actions").map(s=>s.field)}):console.error("Grid API is not ready.")},formatDate(s){const e=new Date(s),i=new Date(e.toLocaleString("en-US",{timeZone:"UTC"})),m=new Date(i.toLocaleString("en-US",{timeZone:"Asia/Singapore"})),t=m.getFullYear(),l=String(m.getMonth()+1).padStart(2,"0"),p=String(m.getDate()).padStart(2,"0");return`${t}-${l}-${p}`},async fetchRecords(s={}){this.state.isLoading=!0,await S.fetchRecords({...s}).then(e=>{let i=e.data.data;console.log(i),this.items=i,this.items=i.map((m,t)=>({...m,"#":t+1,"date & time":this.$formatDate(m.date),"time coverage":this.$formatTime(m.from_time)+" - "+this.$formatTime(m.to_time),"date created":this.$formatDate(m.created_at),status:m.status})),this.state.isLoading=!1,this.totalItems=e.data.total}).catch(e=>{console.log(e)})},reload(){this.$emit("reload")},async deleteRecord(s){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,S.remove(s).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.reload(),this.state.isDeleting=!1})},createRecord(){this.$refs.form.resetForm(),this.$refs.form.state.showModal=!0},editRecord(s){console.log(s),this.$refs.form.resetForm(),this.$refs.form.loadRecord(s),this.$refs.form.state.showModal=!0},view(s){this.viewRecord(s)},viewRecord(s){console.log(s),this.$refs.view.resetForm(),this.$refs.view.loadRecord(s),this.$refs.view.state.showModal=!0}},mounted(){this.applyFilters()}},Tt={class:"space-y-4 mt-4"},Bt={class:"flex items-center justify-between mb-4"},Et={class:"text-lg font-semibold"},It={class:"relative"},Lt={class:"ag-grid-toolbar flex items-center justify-between px-4 py-2 bg-gray-100 border-b rounded-t-xl border-gray-200"},qt={class:"flex items-center gap-4"},Ht={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"},Ut={class:"relative z-10 flex items-center transition-colors duration-300 group-hover:text-white"};function Ot(s,e,i,m,t,l){const p=d("FilterTimekeeping"),g=d("Icon"),u=d("Button"),x=d("View"),k=d("ag-grid-vue"),b=d("Card"),w=d("Loading"),v=d("Form"),C=d("Layout");return a(),_(C,{breadcrumbs:t.breadcrumbs},{default:f(()=>[o("div",Tt,[r(b,{title:"Change Schedule Applications"},{default:f(()=>[o("div",Bt,[o("h6",Et,y(s.title),1)]),o("div",It,[o("div",Lt,[e[6]||(e[6]=o("div",{class:"flex items-center justify-center gap-4 text-gray-900"}," Change Schedule List ",-1)),o("div",qt,[r(p,{onFilterChanged:l.applyFilters},null,8,["onFilterChanged"]),r(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[3]||(e[3]=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",Ht,[r(g,{icon:"mdi:microsoft-excel",class:"text-2xl mr-2"}),e[2]||(e[2]=R(" Export to CSV "))])]),_:1},8,["onClick"]),r(u,{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:l.createRecord},{default:f(()=>[e[5]||(e[5]=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",Ut,[r(g,{icon:"heroicons-outline:plus-sm",class:"text-2xl mr-2"}),e[4]||(e[4]=R(" Add Record "))])]),_:1},8,["onClick"])])])]),r(x,{onCloseModal:e[0]||(e[0]=F=>t.state.showModal=!1),ref:"view",onReload:l.fetchRecords},null,8,["onReload"]),r(k,{ref:"agGrid",rowData:t.items,columnDefs:t.colDefs,style:{height:"500px"},class:"ag-theme-quartz",pagination:!0,paginationPageSize:t.paginationPageSize,paginationPageSizeSelector:t.paginationPageSizeSelector,onGridReady:l.onGridReady},null,8,["rowData","columnDefs","paginationPageSize","paginationPageSizeSelector","onGridReady"])]),_:1}),t.state.isLoading?(a(),_(w,{key:0,text:"Fetching records"})):h("",!0),r(v,{onCloseModal:e[1]||(e[1]=F=>t.state.showModal=!1),ref:"form",onReload:l.applyFilters},null,8,["onReload"])])]),_:1},8,["breadcrumbs"])}const Bs=T(Mt,[["render",Ot],["__scopeId","data-v-526557d9"]]);export{Bs as default};
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.22 |
proxy
|
phpinfo
|
Settings