File manager - Edit - /home/autoph/.trash/assets/process-8fc5e07d.js
Back
import{B as K}from"./index-ba97739a.js";import{_ as Z,r as _,o as n,d as u,c as x,b as p,e as r,g as c,f as e,h as f,w as $,I as h,J as C,G as F,K as ee,L as te,H as J}from"./index-3ade5c76.js";import{C as se}from"./CloseButton-d2eebd1f.js";import{D as ie}from"./DeleteButton-835f7446.js";import{S as oe,U as ae}from"./UpdateButton-9d990a49.js";import{F as le,I as _e}from"./vue-flatpickr.min-e07cc43d.js";import{F as re}from"./index-9334fed0.js";import{F as ne}from"./lodash-9a5070a4.js";import{I as de,T as ce,s as me,A as ge}from"./index-c954d15a.js";import{T as he}from"./index-fc98f9a1.js";import{L as ue}from"./Loading-cfed3691.js";import{A as ye}from"./AssetItemService-2a1b0acd.js";import{E as ve}from"./ExpenseCategoryService-b2f915eb.js";import{I as be}from"./ItemClassificationService-052dd926.js";import{I as we}from"./ItemTypeService-9be774d3.js";import{P as V}from"./PurchaseRequestService-9c893d5a.js";import{U as xe}from"./UnitOfMeasureService-82d0bdb8.js";import{F as pe}from"./FileService-346499c9.js";import{c as B,a as M,b as Ce,V as R,d as ke}from"./array-2d279bb5.js";import{f as G}from"./file-type-pdf-a9709057.js";import{I as fe}from"./index-83fa9446.js";/* empty css */import{A as H}from"./ApprovalService-ba863ef2.js";import{P as Ae}from"./PurchaseRequestItemService-9936a718.js";import Fe from"./index-b614eac9.js";import{P as Me}from"./index-ac60177a.js";import{h as L}from"./moment-a9aaa855.js";import{B as Se}from"./index-7ef7d090.js";const Ie={components:{FormModal:re,FormGroup:ne,InputGroup:de,TextInput:ce,TextArea:he,SubmitButton:oe,UpdateButton:ae,CloseButton:se,DeleteButton:ie,Button:K,Multiselect:me,Loading:ue,FlatPickr:le,Info:_e,Icon:fe},data(){return{categories:[],classifications:[],uomOptions:[],approvingHeadOptions:[],types:[],assetItems:[],categoryOptions:[],classificationOptions:[],typeOptions:[],itemOptions:[],addForm:{expense_category_id:null,item_classification_id:null,item_type_id:null,asset_item_id:null,quantity:null,uom:null},form:{company_id:this.$store.userSettings.getActiveCompany??null,dealership_id:this.$store.userSettings.getActiveDealership??null,needed_at:null,approving_head:null,disclaimer:0,pdf_file_view:G,file_attachment:null,file_attachment_exist:null,file_attachment_preview:null,file_attachment_names:"",items:[]},errors:{},state:{isEdit:!1,isSaving:!1,isLoading:!1,showModal:!1,showCategoriesModal:!1,showClassificationsModal:!1,showTypesModal:!1,showItemsModal:!1,showDisclaimerModal:!1,addingItem:!1,isSubmitting:!1,fetchingApprovingHead:!1,isFetchingPrfDtls:!1,isFetchingExpenseCategories:!1,isFetchingUom:!1,isFetchingItemClassification:!1,isFetchingItemType:!1},searchType:null,searchItem:null}},watch:{"addForm.expense_category_id":{handler(){this.fetchItemClassifications()}},"addForm.item_classification_id":{handler(){this.fetchItemTypes()}},"addForm.item_type_id":{handler(){this.fetchAssetItems()}}},computed:{activeUser:function(){return console.log("this.$store.userSettings.getActiveUser"),console.log(this.$store.userSettings.getActiveUser),this.$store.userSettings.getActiveUser??null},activeCompany:function(){return this.$store.userSettings.getActiveCompany??null},activeDealership:function(){return this.$store.userSettings.getActiveDealership??null},activeDepartment:function(){return this.$store.userSettings.getActiveDepartment??null},companies:function(){return this.$store.userSettings.getCompanyAccess??null},dealerships:function(){return this.$store.userSettings.getDealershipAccess??null},company:function(){return this.companies.filter(t=>t.id==this.activeCompany).map(t=>t.name).toString()},dealership:function(){return this.dealerships.filter(t=>t.id==this.activeDealership).map(t=>t.name).toString()},filteredTypeOptions:function(){let t=this.typeOptions;return this.searchType&&this.typeOptions.length>0&&(t=this.typeOptions.filter(s=>s.label.toString().toLowerCase().includes(this.searchType.toString().toLowerCase()))),t},filteredItemOptions:function(){let t=this.itemOptions;return this.searchItem&&this.itemOptions.length>0&&(t=this.itemOptions.filter(s=>s.label.toString().toLowerCase().includes(this.searchItem.toString().toLowerCase()))),t}},methods:{async fetchExpenseCategories(){this.state.isFetchingExpenseCategories||(this.state.isFetchingExpenseCategories=!0,await ve.fetchRecords().then(t=>{t.status==200&&(this.categoryOptions=t.data.data.map(s=>({value:s.id,label:s.name})))}).catch(t=>{console.log(t)}))},async fetchItemClassifications(){this.classificationOptions=[],this.addForm.expense_category_id&&await be.fetchRecords({expense_category_id:this.addForm.expense_category_id}).then(t=>{t.status==200&&(this.classificationOptions=t.data.data.map(s=>({value:s.id,label:s.name})))}).catch(t=>{console.log(t)})},async fetchItemTypes(){this.typeOptions=[],this.addForm.item_classification_id&&(this.state.isLoading=!0,await we.fetchRecords({item_classification_id:this.addForm.item_classification_id}).then(t=>{t.status==200&&(this.typeOptions=t.data.data.map(s=>({value:s.id,label:s.name})))}).catch(t=>{console.log(t)}).finally(()=>{this.state.isLoading=!1}))},async fetchAssetItems(){this.itemOptions=[],this.addForm.item_type_id&&(this.state.isLoading=!0,await ye.fetchRecords({item_type_id:this.addForm.item_type_id}).then(t=>{t.status==200&&(this.itemOptions=t.data.data.map(s=>({value:s.id,label:s.name})))}).catch(t=>{console.log(t)}).finally(()=>{this.state.isLoading=!1}))},async fetchUnitOfMeasures(){this.state.isFetchingUom||(this.state.isFetchingUom=!0,await xe.fetchRecords().then(t=>{t.status==200&&(this.uomOptions=t.data.data.map(s=>({value:s.name,label:s.name})))}).catch(t=>{console.log(t)}))},async fetchApprovingHeads(){this.state.fetchingApprovingHead||(this.state.fetchingApprovingHead=!0,await V.fetchApprovingHead({company_id:this.form.company_id,dealership_id:this.form.dealership_id,department_id:this.form.department_id}).then(t=>{t.status==200&&(this.approvingHeadOptions=t.data.map(s=>({value:s.employee_id,label:s.name})),console.log("this.approvingHeadOptions"),console.log(this.approvingHeadOptions))}).catch(t=>{console.log(t)}))},async loadRecord(t){console.log("EDITING..."),console.log(t);let s=Object.assign(t);this.resetForm(),this.state.isEdit=!0,this.form.id=t.id;const o=new Date(s.needed_at),m=o.getFullYear(),i=String(o.getMonth()+1).padStart(2,"0"),d=String(o.getDate()).padStart(2,"0");this.form.needed_at=`${m}-${i}-${d}`,this.form.approving_head=s.approving_head,this.form.purpose=s.purpose,this.form.items=[],this.addForm.expense_category_id=t.expense_category_id,this.addForm.item_classification_id=t.item_classification_id,this.addForm.item_type_id=t.item_type_id,this.form.file_attachment_exist=s.file_attachment.map(g=>({file_id:g.file_id,reference_id:g.reference_id,filename:g.filename,folder:g.folder})),this.form.file_attachment=[],await this.fetchDetails(t.id),console.log("form data.."),console.log(this.form)},async fetchDetails(t){if(this.state.isLoading=!0,!this.state.isFetchingPrfDtls){this.state.isFetchingPrfDtls=!0;try{const s=await V.fetchDetails(t);s.status===200&&(this.form.items=s.data)}catch(s){console.log(s)}finally{this.state.isLoading=!1,this.state.isFetchingPrfDtls=!1,console.log("WHAT ITEMS>>>>>"),console.log(this.form.items)}}},resetForm(){this.state.isEdit=!1,this.form={company_id:this.activeCompany??null,dealership_id:this.activeDealership??null,department_id:this.activeDepartment??null,needed_at:null,approving_head:null,items:[]}},async submitForm(){this.errors=[],this.state.isSubmitting=!0;try{await B().shape({company_id:M().nullable().required("Company is required"),dealership_id:M().nullable().required("Dealership is required"),needed_at:M().nullable().required("Date Needed is required"),approving_head:M().nullable().required("Approving Head is required"),purpose:M().nullable().required("Purpose is required").min(10,"Purpose must be at least ten (10) characters"),items:Ce().nullable().min(1,"There must be at least one (1) item. Please add.")}).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(s=>{s.value?this.state.showDisclaimerModal=!0:this.state.showModal=!1})}catch(t){if(t instanceof R){const s={};t.inner.forEach(o=>{s[o.path]=o.message}),this.errors=s}this.state.isSaving=!1}},async saveRecord(){this.state.isSaving=!0;let t=new FormData;this.state.isEdit?(this.form.file_attachment.length>0&&this.form.file_attachment.forEach((s,o)=>{t.append(`file_attachment_new[${o}]`,s)}),t.append("file_attachment_exist",JSON.stringify(this.form.file_attachment_exist))):this.form.file_attachment&&this.form.file_attachment.length>0&&Array.from(this.form.file_attachment).forEach((s,o)=>{t.append(`file_attachment[${o}]`,s)}),t.append("company_id",this.form.company_id),t.append("dealership_id",this.form.dealership_id),t.append("department_id",this.form.department_id),t.append("needed_at",this.form.needed_at),t.append("approving_head",this.form.approving_head),t.append("purpose",this.form.purpose),t.append("disclaimer",this.form.disclaimer),t.append("division_id",this.activeUser.employees.division_id),t.append("requested_by",this.activeUser.employee_id),t.append("created_by",this.activeUser.id),t.append("expense_category_id",this.addForm.expense_category_id),t.append("item_classification_id",this.addForm.item_classification_id),this.form.items.forEach((s,o)=>{t.append(`items[${o}][expense_category_id]`,s.expense_category_id),t.append(`items[${o}][item_classification_id]`,s.item_classification_id),t.append(`items[${o}][item_type_id]`,s.item_type_id),t.append(`items[${o}][asset_item_id]`,s.asset_item_id),t.append(`items[${o}][quantity]`,s.quantity),t.append(`items[${o}][uom]`,s.uom)}),console.log("FINAL FORM DATA>>>>"),console.log(t),this.state.isSubmitting&&(this.state.isSubmitting=!1,this.state.isEdit?(t.append("id",this.form.id),await V.update2(t).then(s=>{s.status==201?this.$swal.fire({title:"Great!",text:"Record successfully updated.",type:"success",icon:"success",timer:2e3}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3}),this.state.isSubmitting=!1,this.state.isEdit=!1,this.state.isSaving=!1}).catch(s=>{console.log(s),s.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:s.response.data.message,type:"error",icon:"error"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{this.state.isSaving=!1,this.state.isSubmitting=!1,this.reload()})):await V.create(t).then(s=>{s.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3}),this.closeModal(),this.reload()):this.$swall.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})}).catch(s=>{console.log(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})}).finally(()=>{this.state.isSaving=!1,this.state.isSubmitting=!1}))},setCategory(t){console.log(t),this.addForm.expense_category_id=t,this.closeCategoriesModal(),this.state.showModal=!0,this.addForm.item_classification_id=null,this.addForm.item_type_id=null,this.addForm.asset_item_id=null,this.addForm.quantity=null,this.addForm.uom=null,console.log("state.showModal"),console.log(this.state.showModal)},setClassification(t){this.addForm.item_classification_id=t,this.closeClassificationsModal(),this.state.showModal=!0,this.addForm.item_type_id=null,this.addForm.asset_item_id=null,this.addForm.quantity=null,this.addForm.uom=null},setType(t){console.log("setting type"),this.addForm.item_type_id=t,this.closeTypesModal(),this.state.showModal=!0,this.addForm.asset_item_id=null,this.addForm.quantity=null,this.addForm.uom=null},setItem(t){this.addForm.asset_item_id=t,this.closeItemsModal(),this.state.showModal=!0},async addItem(){this.errors=[];try{await B().shape({asset_item_id:M().nullable().required("Item is required"),quantity:ke().required("Quantity is required.").min(1,"Quantity must be at least 1").typeError("Quantity must be a number.").positive("Quantity must be a greater than zero").integer("Quantity must be an integer"),uom:M().nullable().required("UoM is required")}).validate(this.addForm,{abortEarly:!1});let s=Object.assign({},this.addForm);s.type=this.typeOptions.filter(o=>o.value==s.item_type_id).map(o=>o.label).toString(),s.description=this.itemOptions.filter(o=>o.value==s.asset_item_id).map(o=>o.label).toString(),console.log("detail"),console.log(s),this.form.items.push(s),s={},this.resetAddForm()}catch(t){if(t instanceof R){const s={};t.inner.forEach(o=>{s[o.path]=o.message}),this.errors=s}}},removeItem(t){this.$swal.fire({title:"Are you sure?",text:"You want to remove this item?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes, remove it!",background:this.$store.themeSettingsStore.isDark?"#1e293b":"#fff"}).then(s=>{s.value&&this.form.items.splice(t,1)})},resetAddForm(){this.addForm={...this.addForm,asset_item_id:null,quantity:null,uom:null}},setDisclaimer(t){this.form.disclaimer=t,this.saveRecord(),this.state.showDisclaimerModal=!1},closeModal(){this.state.showModal=!1},reload(){this.$emit("reload")},closeCategoriesModal(){this.state.showCategoriesModal=!1},closeClassificationsModal(){this.state.showClassificationsModal=!1},closeTypesModal(){this.state.showTypesModal=!1},closeItemsModal(){this.state.showItemsModal=!1},closeDisclaimerModal(){this.state.showDisclaimerModal=!1},handleMainImageUpload(t,s,o){const m=t.target.files;if(!this.state.isEdit)this.form[s]=m,this.form.file_attachment_names=Array.from(m).map(i=>i.name);else{this.form[s]||(this.form[s]=[]),this.form[s]=[...this.form[s],...m];const i=this.form.file_attachment_names||[];this.form.file_attachment_names=[...i,...Array.from(m).map(d=>d.name)],console.log("EDITING>>>>"),console.log(m)}Array.from(m).forEach(i=>{const d=new FileReader;d.onload=()=>{let g="";i.type.startsWith("image/")?g=d.result:i.type==="application/pdf"?g=this.pdf_file_view:(i.type==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"||i.type==="application/vnd.ms-excel")&&(g=this.excel_file_view),this.form[o].push(g)},d.readAsDataURL(i)})},async viewAttachment(t){if(this.state.isLoadingFileAttachment)return;this.state.isLoadingFileAttachment=!0;let s=await pe.Reader2("purchase_request",t),o;if(t.endsWith(".pdf"))o="application/pdf";else if(t.endsWith(".png"))o="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))o="image/jpeg";else if(t.endsWith(".svg"))o="image/svg+xml";else throw new Error("Unsupported file type");const m=atob(s),i=new Array(m.length);for(let b=0;b<m.length;b++)i[b]=m.charCodeAt(b);const d=new Uint8Array(i),g=new Blob([d],{type:o}),S=URL.createObjectURL(g);window.open(S),this.state.isLoadingFileAttachment=!1},Clearfile_attachment(t,s){this.$refs[t].value=null,this.form.file_attachment=null,this.form.file_attachment_names=[],this.form[s]=[]},removeFile(t){this.form.file_attachment_exist.splice(t,1)}},mounted(){}},v=t=>(ee("data-v-47773404"),t=t(),te(),t),Ee=v(()=>e("div",{class:"font-semibold px-2 text-primary-700"},"Notes:",-1)),Te=v(()=>e("ul",{class:"list-disc space-y-1 py-1 px-6 italic text-primary-600"},[e("li",null,"Those with asterisk (*) are required fields"),e("li",null,"The company and dealership is auto-populated")],-1)),qe={class:"list-decimal space-y-2 p-4"},De=v(()=>e("li",null,"Select the Date on when the Purchase request is needed.",-1)),Oe=v(()=>e("li",null,"Select the Approving Head.",-1)),Be=v(()=>e("li",null,[f(" Add Item/s "),e("div",{class:"px-4 py-2"},[e("span",{class:"font-semibold"}," Notes: "),e("ul",{class:"list-disc space-y-1 py-1 px-6 text-slate-700 italic"},[e("li",null,"Item, quantity, and Uom are required fields"),e("li",null," Once an item has been added the Expense Category and Expense Type cannot be selected anymore ")])]),e("ul",{class:"list-decimal space-y-2 py-2 px-6 text-slate-700"},[e("li",null,"Select expense category"),e("li",null,"Select expense type"),e("li",null,"Select item type"),e("li",null,"Select item"),e("li",null,"Enter the quantity of the item"),e("li",null,"Select UoM"),e("li",null,"Click Add Item button"),e("li",null,"To add more items repeat from #3")])],-1)),Re=v(()=>e("li",null," A confirmation message will prompt, click Yes if you want to proceed with submission OR click No if not ",-1)),Ve=v(()=>e("li",null," The disclaimer will show, select Agree or Disagree on the Disclaimer page ",-1)),Ue={class:"lg:p-2"},Pe={class:"grid lg:grid-cols-4 gap-2"},Le={key:0,class:"text-error"},$e={key:0,class:"text-error"},Ne={key:0,class:"text-error"},Ye={key:1,class:"text-error"},He={class:"grid grid-cols-3"},Ge={class:"col-span-2"},je={key:0,class:"text-error"},We={class:"p-2"},ze={class:"w-full flex justify-between relative"},Qe=v(()=>e("div",{class:"bg-white rounded border border-gray-300 p-0 flex-grow items-center flex justify-between"},[e("span",{class:"mr-2 pl-2 text-sm text-slate-500"},"Choose a file..."),e("button",{type:"button",class:"px-4 py-2 bg-slate-200 text-slate-500 rounded hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"}," Browse ")],-1)),Xe={key:0,class:"mt-4"},Je={class:"flex items-center space-x-2 mb-2"},Ke={class:"space-y-2"},Ze={class:"flex items-cener space-x-2"},et={key:1,src:G,class:"w-6 h-6 mr-2 shadow-inner",alt:"PDF icon"},tt=["onClick"],st={class:"bg-primary-50 border border-primary-200"},it={class:"grid lg:grid-cols-3 gap-3 px-4 pt-2"},ot={class:"flex gap-4"},at=v(()=>e("span",null,"EXPENSE CATEGORY",-1)),lt={key:0,class:"align-middle"},rt=v(()=>e("ul",{class:"list-none space-y-1"},[e("li",null,[f(" Select from the dropdown or click the "),e("span",{class:"text-primary-500"}," View Categories "),f(" link to show all the list then select from that list. ")]),e("li",null," Once an item is added you will not be able to select expense category anymore unless you remove all the items below. ")],-1)),nt={class:"flex gap-4"},dt=v(()=>e("span",null,"EXPENSE TYPE",-1)),ct={key:0,class:"align-middle"},mt=v(()=>e("ul",{class:"list-none space-y-1"},[e("li",null," You need to select the expense category first before you can select from this. "),e("li",null,[f(" Select from the dropdown or click the "),e("span",{class:"text-primary-500"}," View Expense Types "),f(" link to show all the list then select from that list. ")]),e("li",null," Once an item is added you will not be able to select expense type anymore unless you remove all the items below. ")],-1)),ht={class:"flex gap-4"},ut=v(()=>e("span",null,"ITEM TYPE",-1)),pt={class:"align-middle"},ft=v(()=>e("ul",{class:"list-none space-y-1"},[e("li",null," You need to select the expense category and expense type first before you can select from this. "),e("li",null,[f(" Select from the dropdown or click the "),e("span",{class:"text-primary-500"}," View Item Types "),f(" link to show all the list then search and select from that list. ")])],-1)),_t={class:"grid lg:flex lg:gap-2 px-4"},gt={class:"flex-grow"},yt={class:"flex gap-4"},vt=v(()=>e("span",null,"ITEM",-1)),bt={class:"align-middle"},wt=v(()=>e("ul",{class:"list-none space-y-1"},[e("li",null," You need to select the expense category, expense type, and item type first before you can select from this. "),e("li",null,[f(" Select from the dropdown or click the "),e("span",{class:"text-primary-500"}," View Items "),f(" link to show all the list then search and select from that list. ")])],-1)),xt={key:0,class:"text-error"},Ct={key:0,class:"text-error"},kt={key:0,class:"text-error"},At={class:"flex justify-end"},Ft={class:"border border-primary-100 mb-4"},Mt={class:"p-2 text-xl font-semibold"},St=v(()=>e("span",{class:"text-sm text-red-500"},"*",-1)),It={class:"list-none"},Et=v(()=>e("li",null," List of items to be requested with their request quantity and uom. ",-1)),Tt={key:0,class:"text-error"},qt={class:"min-h-[250px] max-h-[350px] overflow-auto"},Dt={class:"table"},Ot=v(()=>e("thead",null,[e("tr",null,[e("th",null,"ITEM TYPE"),e("th",null,"ITEM DESCRIPTION"),e("th",null,"UoM"),e("th",null,"QUANTITY"),e("th",null,"Remove")])],-1)),Bt={class:"flex gap-1 justify-end mt-4"},Rt={class:"grid gap-2"},Vt={class:"grid gap-2"},Ut={class:"w-full mb-2"},Pt={class:"grid gap-2"},Lt={class:"w-full mb-2"},$t={class:"grid gap-2"},Nt=v(()=>e("div",{class:"w-full mb-2"},[e("div",{class:"text-2xl"},"Do you want to agree on the following?"),e("div",null,[e("ul",{class:"list-disc p-4 space-y-3"},[e("li",null,"Receive notifications on the status of your request."),e("li",null,"The canvasses will be subject for your ranking/ratings.")])])],-1)),Yt={class:"flex justify-end gap-2"};function Ht(t,s,o,m,i,d){const g=_("Loading"),S=_("SubmitButton"),b=_("UpdateButton"),w=_("Info"),D=_("TextInput"),k=_("FormGroup"),O=_("FlatPickr"),q=_("Multiselect"),N=_("TextArea"),I=_("Button"),Y=_("Icon"),a=_("DeleteButton"),E=_("CloseButton"),T=_("FormModal"),U=_("InputGroup");return n(),u(C,null,[i.state.isLoading?(n(),x(g,{key:0,text:"Fetching resources"})):p("",!0),r(T,{title:i.state.isEdit?"Edit Purchase Request":"New Purchase Request",active:i.state.showModal,onClose:d.closeModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full h-full"},{info:c(()=>[r(w,{infoClass:"pb-0",btnClass:"px-4 pt-0 pb-0",infoWidth:"600px",iconClass:"text-3xl text-white",header:"How to use the form?",headerClass:"text-base bg-slate-900 text-white"},{default:c(()=>[Ee,Te,e("ul",qe,[De,Oe,Be,e("li",null,[f(" Click "),i.state.isEdit?p("",!0):(n(),x(S,{key:0})),i.state.isEdit?(n(),x(b,{key:1})):p("",!0),f(" Button ")]),Re,Ve])]),_:1})]),default:c(()=>[i.state.isSaving?(n(),x(g,{key:0,text:"Saving record"})):p("",!0),e("div",Ue,[e("form",{onSubmit:s[17]||(s[17]=$((...l)=>t.confirmSubmit&&t.confirmSubmit(...l),["prevent"])),class:"space-y-1",enctype:"multipart/form-data"},[e("div",Pe,[r(k,{label:"Company",isRequired:!0},{info:c(()=>[r(w,{header:"Company",content:"This data is the current active company. To change this, you need to switch company using the company/dealership switcher dropdown"})]),default:c(()=>[r(D,{type:"text",modelValue:d.company,"onUpdate:modelValue":s[0]||(s[0]=l=>d.company=l),isReadonly:!0},null,8,["modelValue"]),i.errors.company_id?(n(),u("span",Le,h(i.errors.company_id),1)):p("",!0)]),_:1}),r(k,{label:"Dealership",isRequired:!0},{info:c(()=>[r(w,{header:"Dealership",content:"This data is the current active dealership. To change this, you need to switch company using the company/dealership switcher dropdown"})]),default:c(()=>[r(D,{type:"text",modelValue:d.dealership,"onUpdate:modelValue":s[1]||(s[1]=l=>d.dealership=l),isReadonly:!0},null,8,["modelValue"]),i.errors.dealership_id?(n(),u("span",$e,h(i.errors.dealership_id),1)):p("",!0)]),_:1}),r(k,{label:"Date Needed",isRequired:!0},{info:c(()=>[r(w,{header:"Date Needed",content:"This is the date when your items to be requested is needed."})]),default:c(()=>[r(O,{modelValue:i.form.needed_at,"onUpdate:modelValue":s[2]||(s[2]=l=>i.form.needed_at=l),class:"form-control",placeholder:"mm/dd/yyyy",config:{altInput:!0,altFormat:"m/d/Y",dateFormat:"Y-m-d",minDate:new Date().fp_incr(1)}},null,8,["modelValue","config"]),i.errors.needed_at?(n(),u("span",Ne,h(i.errors.needed_at),1)):p("",!0)]),_:1}),r(k,{label:"Approving Head",isRequired:!0},{info:c(()=>[r(w,{header:"Approving Head",content:"This is your immediate Department Head. If you cannot see any data please contact the system support"})]),default:c(()=>[i.approvingHeadOptions?(n(),x(q,{key:0,modelValue:i.form.approving_head,"onUpdate:modelValue":s[3]||(s[3]=l=>i.form.approving_head=l),"close-on-select":!0,searchable:!0,options:i.approvingHeadOptions,loading:!(i.approvingHeadOptions&&i.approvingHeadOptions.length>0),disabled:!(i.approvingHeadOptions&&i.approvingHeadOptions.length>0)},null,8,["modelValue","options","loading","disabled"])):p("",!0),i.errors.approving_head?(n(),u("span",Ye,h(i.errors.approving_head),1)):p("",!0)]),_:1})]),e("div",He,[e("div",Ge,[r(k,{label:"Purpose of Request",isRequired:!0},{info:c(()=>[r(w,{header:"Purpose of Request",content:"Input here the purpose of your request. This accepts at least ten (10) characters."})]),default:c(()=>[r(N,{placeholder:"",modelValue:i.form.purpose,"onUpdate:modelValue":s[4]||(s[4]=l=>i.form.purpose=l)},null,8,["modelValue"]),i.errors.purpose?(n(),u("span",je,h(i.errors.purpose),1)):p("",!0)]),_:1})]),e("div",We,[r(k,{label:"Attachment",isRequired:!0,labelClass:"px-2"},{default:c(()=>[e("div",ze,[e("input",{type:"file",id:"file_attachment",name:"file_attachment",onChange:s[5]||(s[5]=l=>d.handleMainImageUpload(l,"file_attachment","file_attachment_previews")),ref:"file_attachment",class:"absolute inset-0 opacity-0 w-full h-full cursor-pointer",multiple:""},null,544),Qe,r(I,{onClick:s[6]||(s[6]=l=>d.Clearfile_attachment("file_attachment","file_attachment_previews")),btnClass:"bg-red-500 mx-1 text-gray-100 min-h-3 pt-2"},{default:c(()=>[f(" Clear ")]),_:1})])]),_:1}),e("div",null,[e("ul",null,[(n(!0),u(C,null,F(i.form.file_attachment_names,(l,A)=>(n(),u("li",{key:A},h(l),1))),128))])]),i.form.file_attachment_exist&&i.form.file_attachment_exist.length>0?(n(),u("div",Xe,[e("div",Je,[e("ul",Ke,[(n(!0),u(C,null,F(i.form.file_attachment_exist,(l,A)=>(n(),u("li",{key:A,class:"inline-block bg-gray-100 rounded px-2 py-1 mr-2"},[e("div",Ze,[i.state.isEdit?(n(),x(Y,{key:0,title:"Remove "+l.filename,onClick:P=>d.removeFile(A),icon:"raphael:trash",class:"hover:scale-150 cursor-pointer transition-shadow text-red-500",width:"32",height:"32"},null,8,["title","onClick"])):p("",!0),l.extension==="pdf"?(n(),u("img",et)):p("",!0),e("a",{href:"#",title:"View Attachment",class:"text-indigo-600 hover:underline",onClick:$(P=>d.viewAttachment(l.filename),["prevent"]),target:"_blank"},h(l.filename),9,tt)])]))),128))])])])):p("",!0)])]),e("div",st,[e("div",it,[r(k,null,{label:c(()=>[e("div",ot,[at,i.form.items.length==0?(n(),u("span",lt,[e("a",{onClick:s[7]||(s[7]=l=>i.state.showCategoriesModal=!0),class:"text-primary-700 text-xs font-semibold"},"View Categories")])):p("",!0),r(w,{header:"Expense Category",btnClass:"p-0"},{default:c(()=>[rt]),_:1})])]),default:c(()=>[r(q,{modelValue:i.addForm.expense_category_id,"onUpdate:modelValue":s[8]||(s[8]=l=>i.addForm.expense_category_id=l),"close-on-select":!0,searchable:!0,options:i.categoryOptions,disabled:i.form.items.length>0,onChange:d.setCategory},null,8,["modelValue","options","disabled","onChange"])]),_:1}),r(k,null,{label:c(()=>[e("div",nt,[dt,i.form.items.length==0?(n(),u("span",ct,[e("a",{onClick:s[9]||(s[9]=l=>i.state.showClassificationsModal=!0),class:"text-primary-700 text-xs font-semibold"},"View Expense Types")])):p("",!0),r(w,{header:"Expense Type",btnClass:"p-0"},{default:c(()=>[mt]),_:1})])]),default:c(()=>[r(q,{modelValue:i.addForm.item_classification_id,"onUpdate:modelValue":s[10]||(s[10]=l=>i.addForm.item_classification_id=l),"close-on-select":!0,searchable:!0,options:i.classificationOptions,disabled:i.form.items.length>0,onChange:d.setClassification},null,8,["modelValue","options","disabled","onChange"])]),_:1}),r(k,null,{label:c(()=>[e("div",ht,[ut,e("span",pt,[e("a",{onClick:s[11]||(s[11]=l=>i.state.showTypesModal=!0),class:"text-primary-700 text-xs font-semibold"},"View Item Types")]),r(w,{header:"Item Type",btnClass:"p-0"},{default:c(()=>[ft]),_:1})])]),default:c(()=>[r(q,{modelValue:i.addForm.item_type_id,"onUpdate:modelValue":s[12]||(s[12]=l=>i.addForm.item_type_id=l),"close-on-select":!0,searchable:!0,options:i.typeOptions,onChange:d.setType},null,8,["modelValue","options","onChange"])]),_:1})]),e("div",_t,[e("div",gt,[r(k,null,{label:c(()=>[e("div",yt,[vt,e("span",bt,[e("a",{onClick:s[13]||(s[13]=l=>i.state.showItemsModal=!0),class:"text-primary-700 text-xs font-semibold"},"View Items")]),r(w,{header:"Asset Item",btnClass:"p-0"},{default:c(()=>[wt]),_:1})])]),default:c(()=>[r(q,{modelValue:i.addForm.asset_item_id,"onUpdate:modelValue":s[14]||(s[14]=l=>i.addForm.asset_item_id=l),"close-on-select":!0,searchable:!0,options:i.itemOptions,onChange:d.setItem},null,8,["modelValue","options","onChange"]),i.errors.asset_item_id?(n(),u("div",xt,h(i.errors.asset_item_id),1)):p("",!0)]),_:1})]),e("div",null,[r(k,{label:"Quantity"},{info:c(()=>[r(w,{btnClass:"py-0 px-1",header:"Quantity",content:"The request quantity of this item."})]),default:c(()=>[r(D,{type:"number",placeholder:"",modelValue:i.addForm.quantity,"onUpdate:modelValue":s[15]||(s[15]=l=>i.addForm.quantity=l),classInput:"lg:w-[100px]",min:"1"},null,8,["modelValue"]),i.errors.quantity?(n(),u("div",Ct,h(i.errors.quantity),1)):p("",!0)]),_:1})]),e("div",null,[r(k,{label:"UoM",formClass:"lg:w-[200px]"},{info:c(()=>[r(w,{btnClass:"py-0 px-1",header:"Unit of Measure",content:`The\r unit of measure of this item.`})]),default:c(()=>[r(q,{modelValue:i.addForm.uom,"onUpdate:modelValue":s[16]||(s[16]=l=>i.addForm.uom=l),"close-on-select":!0,searchable:!0,options:i.uomOptions},null,8,["modelValue","options"]),i.errors.uom?(n(),u("div",kt,h(i.errors.uom),1)):p("",!0)]),_:1})]),e("div",At,[r(k,{formClass:"lg:pt-8 pt-2 "},{default:c(()=>[r(I,{class:"bg-slate-800",onClick:d.addItem},{default:c(()=>[f("Add Item")]),_:1},8,["onClick"])]),_:1})])]),e("div",Ft,[e("header",Mt,[f(" Items "),St,r(w,{header:"Items",content:""},{default:c(()=>[e("ul",It,[Et,e("li",null,[f(" The added items here can be removed via the "),r(a,{iconClass:"text-base"}),f(" button on each row ")])])]),_:1}),i.errors.items?(n(),u("span",Tt," "+h(i.errors.items),1)):p("",!0)]),e("div",qt,[e("table",Dt,[Ot,e("tbody",null,[(n(!0),u(C,null,F(i.form.items,(l,A)=>(n(),u("tr",{key:A},[e("td",null,h(l.type),1),e("td",null,h(l.description),1),e("td",null,h(l.uom),1),e("td",null,h(l.quantity),1),e("td",null,[r(a,{onClick:P=>d.removeItem(A)},null,8,["onClick"])])]))),128))])])])])]),e("div",Bt,[i.state.isEdit?(n(),x(b,{key:1,onClick:d.submitForm},null,8,["onClick"])):(n(),x(S,{key:0,onClick:d.submitForm},null,8,["onClick"])),r(E,{onClick:d.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onClose","themeClass"]),r(T,{title:"Expense Categories",active:i.state.showCategoriesModal,onClose:d.closeCategoriesModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[e("div",Rt,[(n(!0),u(C,null,F(i.categoryOptions,l=>(n(),u("div",{key:l.value,class:"border-b border-slate-200 w-full"},[r(I,{onClick:A=>d.setCategory(l.value),btnClass:"bg-slate-50 text-left py-1"},{default:c(()=>[f(h(l.label),1)]),_:2},1032,["onClick"])]))),128))])]),_:1},8,["active","onClose","themeClass"]),r(T,{title:"Expense Types",active:i.state.showClassificationsModal,onClose:d.closeClassificationsModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[e("div",Vt,[(n(!0),u(C,null,F(i.classificationOptions,l=>(n(),u("div",{key:l.value,class:"border-b border-slate-200 w-full"},[r(I,{onClick:A=>d.setClassification(l.value),btnClass:"bg-slate-50 text-left py-1"},{default:c(()=>[f(h(l.label),1)]),_:2},1032,["onClick"])]))),128))])]),_:1},8,["active","onClose","themeClass"]),r(T,{title:"Item Types",active:i.state.showTypesModal,onClose:d.closeTypesModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[e("div",Ut,[r(U,{icon:"heroicons:magnifying-glass-20-solid"},{default:c(()=>[r(D,{modelValue:i.searchType,"onUpdate:modelValue":s[18]||(s[18]=l=>i.searchType=l),placeholder:"Search",classInput:"focus:border-slate-300"},null,8,["modelValue"])]),_:1})]),e("div",Pt,[(n(!0),u(C,null,F(d.filteredTypeOptions,l=>(n(),u("div",{key:l.value,class:"border-b border-slate-200 w-full"},[r(I,{onClick:A=>d.setType(l.value),btnClass:"bg-slate-50 text-left py-1"},{default:c(()=>[f(h(l.label),1)]),_:2},1032,["onClick"])]))),128))])]),_:1},8,["active","onClose","themeClass"]),r(T,{title:"Items",active:i.state.showItemsModal,onClose:d.closeItemsModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[e("div",Lt,[r(U,{icon:"heroicons:magnifying-glass-20-solid"},{default:c(()=>[r(D,{modelValue:i.searchItem,"onUpdate:modelValue":s[19]||(s[19]=l=>i.searchItem=l),placeholder:"Search",classInput:"focus:border-slate-300"},null,8,["modelValue"])]),_:1})]),e("div",$t,[(n(!0),u(C,null,F(d.filteredItemOptions,l=>(n(),u("div",{key:l.value,class:"border-b border-slate-200 w-full"},[r(I,{onClick:A=>d.setItem(l.value),btnClass:"bg-slate-50 text-left py-1"},{default:c(()=>[f(h(l.label),1)]),_:2},1032,["onClick"])]))),128))])]),_:1},8,["active","onClose","themeClass"]),r(T,{title:"Disclaimer",active:i.state.showDisclaimerModal,onClose:d.closeDisclaimerModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[Nt,e("div",Yt,[r(I,{onClick:s[20]||(s[20]=l=>d.setDisclaimer(1)),btnClass:"bg-primary-600 text-white text-left py-1"},{default:c(()=>[f("Yes")]),_:1}),r(I,{onClick:s[21]||(s[21]=l=>d.setDisclaimer(0)),btnClass:"bg-slate-300 text-black text-left py-1"},{default:c(()=>[f("No")]),_:1})])]),_:1},8,["active","onClose","themeClass"])],64)}const Yi=Z(Ie,[["render",Ht],["__scopeId","data-v-47773404"]]);const Gt={components:{FormModal:re,FormGroup:ne,InputGroup:de,TextInput:ce,TextArea:he,SubmitButton:oe,UpdateButton:ae,CloseButton:se,DeleteButton:ie,Button:K,Multiselect:me,Loading:ue,FlatPickr:le,Avatar:ge,ProposalMapping:Me,CanvassCreation:Fe,Icon:fe,Badge:Se},data(){return{data:{company_id:this.$store.userSettings.getActiveCompany??null,dealership_id:this.$store.userSettings.getActiveDealership??null,needed_at:null,approving_head:null,items:[]},badgeClass:"bg-pink-400 text-white",form:{remarks:null},errors:{remarks:""},state:{isEdit:!1,isSaving:!1,isLoading:!1,showModal:!1,process:!1,isLoadingFileAttachment:!1,isLoadRecord:!1},searchType:null,searchItem:null,isCancancelled:!1,cancelledItem:{request_header_id:null,prf_dtl_id:null,remarks:null,cancelled_by:null}}},computed:{activeUser:function(){return console.log("this.$store.userSettings.getActiveUser"),console.log(this.$store.userSettings.getActiveUser),this.$store.userSettings.getActiveUser??null},activeCompany:function(){return this.$store.userSettings.getActiveCompany??null},activeDealership:function(){return this.$store.userSettings.getActiveDealership??null},activeDepartment:function(){return this.$store.userSettings.getActiveDepartment??null},companies:function(){return this.$store.userSettings.getCompanyAccess??null},dealerships:function(){return this.$store.userSettings.getDealershipAccess??null},company:function(){return this.companies.filter(t=>t.id==this.activeCompany).map(t=>t.name).toString()},dealership:function(){return this.dealerships.filter(t=>t.id==this.activeDealership).map(t=>t.name).toString()},roleGroups:function(){return this.activeUser?this.activeUser.roles.flatMap(t=>t.group_id):null}},methods:{loadRecord(t){let s=Object.assign({},t);this.resetData(),this.state.isEdit=!0,console.log("loading data to form",t),this.data=s,this.data.items=[],this.data.next_statuses=s.next_statuses,this.data.remarks_history=s.remarks_history.map(o=>({...o,created_at:L(o.created_at).format("MMM D, YYYY h:mm a"),timeLapsed:this.computeElapsed("2024-10-01","2024-10-02")})),this.fetchDetails(s.id),this.form.remarks="",console.log(this.data),console.log("this.data")},resetData(){this.state.isEdit=!1,this.data={company_id:this.activeCompany??null,dealership_id:this.activeDealership??null,department_id:this.activeDepartment??null,needed_at:null,approving_head:null,items:[]}},async fetchDetails(t){this.state.isLoading=!0,!this.state.isLoadRecord&&(this.state.isLoadRecord=!0,V.fetchDetails(t).then(s=>{s.status==200&&(this.data.items=s.data,console.log("RESPONSE",s.data))}).catch(s=>{console.log(s)}).finally(()=>this.state.isLoading=!1))},async submitForm(t,s){console.log("form"),console.log(this.form),this.errors=[];try{await B().shape({remarks:M().nullable().required("Remarks is required").min(10,"Remarks must be at least ten (10) characters")}).validate(this.form,{abortEarly:!1}),this.$swal.fire({title:`Are you sure you want to ${s} this record?`,text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(m=>{m.value?this.updateRecord(t):this.state.showModal=!1})}catch(o){if(o instanceof R){const m={};o.inner.forEach(i=>{m[i.path]=i.message}),this.errors=m}this.state.isSaving=!1}},async submitMapProposal(){console.log("form"),console.log("submitting proposal"),this.state.showModal=!1;const t=this.$refs.proposal.form.status_id,s=this.$refs.proposal.form.action,o=this.$refs.proposal.form.id;console.log(this.$refs.proposal.form),this.errors=[];try{await B().shape({remarks:M().nullable().required("Remarks is required").min(10,"Remarks must be at least ten (10) characters")}).validate(this.$refs.proposal.form,{abortEarly:!1}),this.form.proposal_id=o,this.form.remarks=this.$refs.proposal.form.remarks,this.$swal.fire({title:`Are you sure you want to ${s} this record?`,text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(i=>{i.value?this.updateRecord(t):this.$refs.proposal.state.showModal=!1})}catch(m){if(m instanceof R){const i={};m.inner.forEach(d=>{i[d.path]=d.message}),this.errors=i}this.state.isSaving=!1}},async updateRecord(t){let s={remarks:this.form.remarks,status:t,updated_by:this.activeUser.id,proposal_id:this.form.proposal_id??null};console.log("this.activeUser"),console.log(this.activeUser);const o=this.data.id;await V.updateStatus(o,s).then(m=>{m.status==201?(this.$swal.fire({title:"Great!",text:"Record successfully updated.",type:"success",icon:"success",timer:2e3}).then(()=>{}),this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).catch(m=>{console.log(m),m.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:m.response.data.message,type:"error",icon:"error"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{this.state.isSaving=!1,this.reload()})},closeModal(){this.state.showModal=!1},reload(){this.state.showModal=!1,this.$emit("reload")},computeElapsed(t,s){const o=L(t),m=L(s),i=m.diff(o,"days"),g=L.duration(m.diff(o)).asHours()-i*24,S=Math.floor(g),b=Math.floor((g-S)*60);return`${i} days, ${S} hours, and ${b} minutes`},async handleHeadApproval(t,s){this.errors={};try{await B().shape({remarks:M().required("Remarks field is required.")}).validate(this.form,{abortEarly:!1}),this.$swal.fire({title:`Are you sure you want to ${s} this record?`,text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(m=>{m.value?this.submitHeadApproval(t):this.$refs.proposal.state.showModal=!1})}catch(o){o instanceof R&&o.inner.forEach(m=>{m.path==="remarks"&&(this.errors.remarks=m.message)})}},async submitHeadApproval(t){let s={record_id:this.data.id,transaction_type:"purchase-request",approver_role:"head",approved_by:this.activeUser.employee_id??null};await H.create(s).then(o=>{o.status==201?(this.updateRecord(t),this.$swal.fire({title:"Great!",text:"Record successfully updated.",type:"success",icon:"success",timer:2e3}),this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).catch(o=>{console.log(o),o.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:o.response.data.message,type:"error",icon:"error"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{this.state.isSaving=!1,this.reload()})},async handleAssetValidation(t,s){this.errors={};try{await B().shape({remarks:M().nullable().required("Remarks field is required.")}).validate(this.form,{abortEarly:!1}),this.$swal.fire({title:`Are you sure you want to tag as ${s} this record?`,text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(m=>{m.value?this.submitAssetValidation(t):this.$refs.proposal.state.showModal=!1})}catch(o){o instanceof R&&o.inner.forEach(m=>{m.path==="remarks"&&(this.errors.remarks=m.message)})}},async submitAssetValidation(t){let s={record_id:this.data.id,transaction_type:"purchase-request",approver_role:"asset-validator",approved_by:this.activeUser.employee_id??null};await H.create(s).then(o=>{o.status==201?(this.updateRecord(t),this.$swal.fire({title:"Great!",text:"Record successfully updated.",type:"success",icon:"success",timer:2e3}),this.state.showModal=!1,this.form.remarks="",this.fetchRecords()):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).catch(o=>{console.log(o),o.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:o.response.data.message,type:"error",icon:"error"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{this.state.isSaving=!1,this.reload()})},async handleAdminValidation(t,s){this.errors={};try{await B().shape({remarks:M().nullable().required("Remarks field is required.")}).validate(this.form,{abortEarly:!1}),this.$swal.fire({title:`Are you sure you want to tag as ${s} this record?`,text:"",icon:"question",showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(m=>{m.value?this.submitAdminValidation(t):this.$refs.proposal.state.showModal=!1})}catch(o){o instanceof R&&o.inner.forEach(m=>{m.path==="remarks"&&(this.errors.remarks=m.message)})}},async submitAdminValidation(t){let s={record_id:this.data.id,transaction_type:"purchase-request",approver_role:"admin-validator",approved_by:this.activeUser.employee_id??null};await H.create(s).then(o=>{o.status==201?(this.updateRecord(t),this.$swal.fire({title:"Great!",text:"Record successfully updated.",type:"success",icon:"success",timer:2e3}),this.state.showModal=!1):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).catch(o=>{console.log(o),o.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:o.response.data.message,type:"error",icon:"error"}):this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",type:"error",icon:"error",timer:2e3})}).finally(()=>{this.state.isSaving=!1,this.reload()})},showProposals(t,s){console.log("SHOW PROPOSALS"),this.$refs.proposal.fetchRecords(),this.$refs.proposal.form.status_id=t,this.$refs.proposal.form.action=s,this.$refs.proposal.form.PrInfo=this.data,this.$refs.proposal.state.showModal=!0},showCanvass(t){const s=Object.assign({},t);console.log(s),t=s,t.asset_items=s.items.map(o=>({prf_id:o.request_header_id,asset_item_id:o.asset_item_id,asset_item_name:o.description,purchase_request_dtls_id:o.id,pivot:{request_header_id:o.request_header_id,purchase_request_dtls_id:o.id,reference_no:o.reference_no,uom:o.uom,quantity:o.quantity}})),this.$refs.canvass.viewDetails(t),this.$refs.canvass.state.showModal=!0},closeProposal(){this.$refs.proposal.state.showModal=!1},mapProposals(){},cancelItem(t){console.log("cancelled item "),console.log(t),this.$swal.fire({title:`Are you sure you want to remove ${t.quantity} ${t.uom} ${t.description} in this PRF?`,text:"Please provide a reason for cancellation:",icon:"question",input:"text",inputPlaceholder:"Enter reason for cancellation",inputValidator:s=>{if(!s)return"A reason is required!"},showCancelButton:!0,confirmButtonColor:"#34c38f",cancelButtonColor:"#f46a6a",confirmButtonText:"Yes",cancelButtonText:"No"}).then(s=>{if(s.isConfirmed&&s.value){const o=s.value;Ae.cancelItem({id:t.id,request_header_id:t.request_header_id,reason:o}).then(m=>{m.status==201&&this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3})}).catch(m=>{this.$swal.fire({title:"Ooops! something is wrong.",text:"Please contact system administrator",icon:"error",timer:2e3})}).finally(()=>{this.state.showModal=!1,this.state.isLoading=!1,this.reload()})}else this.state.showModal=!1})},async viewAttachment(t){if(this.state.isLoadingFileAttachment)return;this.state.isLoadingFileAttachment=!0;let s=await pe.Reader2("purchase_request",t),o;if(t.endsWith(".pdf"))o="application/pdf";else if(t.endsWith(".png"))o="image/png";else if(t.endsWith(".jpg")||t.endsWith(".jpeg"))o="image/jpeg";else if(t.endsWith(".svg"))o="image/svg+xml";else throw new Error("Unsupported file type");const m=atob(s),i=new Array(m.length);for(let b=0;b<m.length;b++)i[b]=m.charCodeAt(b);const d=new Uint8Array(i),g=new Blob([d],{type:o}),S=URL.createObjectURL(g);window.open(S),this.state.isLoadingFileAttachment=!1},formatDate(t){return t?L(t).format("MMMM D, YYYY [at] h:mm A"):"N/A"}},mounted(){}},y=t=>(ee("data-v-5c4c4565"),t=t(),te(),t),jt={class:"lg:p-2"},Wt={class:"space-y-2"},zt={class:"grid lg:grid-cols-2"},Qt={class:"flex gap-2 border-b border-slate-300 border-dashed py-1"},Xt=y(()=>e("div",{class:"label"},"Company:",-1)),Jt={class:"value"},Kt={class:"flex gap-2 border-b border-slate-300 border-dashed py-1"},Zt=y(()=>e("div",{class:"label"},"Dealership:",-1)),es={class:"value"},ts={class:"grid lg:grid-cols-2"},ss={class:"flex gap-2 border-b border-slate-300 border-dashed py-1"},is=y(()=>e("div",{class:"label"},"Date Needed:",-1)),os={class:"value"},as={class:"flex gap-1 border-b border-slate-300 border-dashed py-1"},ls=y(()=>e("div",{class:"label"},"Approving Head:",-1)),rs={class:"value"},ns={class:"flex gap-1 border-b border-slate-300 border-dashed py-1"},ds=y(()=>e("div",{class:"label"},"Requested By:",-1)),cs={class:"value"},ms={class:"flex gap-1 border-b border-slate-300 border-dashed py-1"},hs=y(()=>e("div",{class:"label"},"Purpose:",-1)),us={class:"value"},ps={key:0,class:"mt-4"},fs={class:"flex items-center space-x-2 mb-2"},_s=y(()=>e("div",{class:"label"},"Attachment :",-1)),gs={class:"space-y-2"},ys={class:"flex items-cener space-x-2"},vs={key:0,src:G,class:"w-6 h-6 mr-2 shadow-inner",alt:"PDF icon"},bs=["onClick"],ws={class:"bg-primary-50 mt-8 border border-primary-300 p-4 mb-8 drop-shadow-md"},xs={class:"grid lg:grid-cols-2 gap-3 py-2"},Cs={class:"flex gap-4"},ks=y(()=>e("span",{class:"label"},"EXPENSE CATEGORY:",-1)),As={class:"value"},Fs={class:"flex gap-4"},Ms=y(()=>e("span",{class:"label"},"EXPENSE TYPE",-1)),Ss={class:"value"},Is={class:"mb-4"},Es=y(()=>e("header",{class:"text-xl font-semibold"},"Items",-1)),Ts={class:"max-h-[350px] overflow-auto"},qs={class:"table"},Ds=y(()=>e("thead",null,[e("tr",null,[e("th",null,"ITEM TYPE"),e("th",null,"ITEM DESCRIPTION"),e("th",null,"UOM"),e("th",null,"QUANTITY"),e("th",null,"STATUS"),e("th",null,"ACTION")])],-1)),Os=["onClick"],Bs=y(()=>e("span",null,"Cancel",-1)),Rs={key:1},Vs={key:0,class:"border border-red-500 bg-red-100 rounded-md p-2"},Us=y(()=>e("label",{class:"font-bold"}," Date : ",-1)),Ps=y(()=>e("br",null,null,-1)),Ls=y(()=>e("label",{class:"font-bold"},"Cancelled by : ",-1)),$s=y(()=>e("br",null,null,-1)),Ns=y(()=>e("label",{class:"font-bold"},"Remarks : ",-1)),Ys={class:"text-red-500 font-semibold"},Hs=y(()=>e("br",null,null,-1)),Gs={key:0,class:"mb-4"},js={class:"grid lg:grid-cols-2 gap-2"},Ws={class:"space-y-3"},zs=y(()=>e("div",{class:"text-lg font-semibold text-gray-700"}," Remarks History ",-1)),Qs={class:"bg-gray-50 p-5 border border-gray-200 rounded-lg shadow-lg h-72 overflow-y-auto"},Xs={class:"relative border-s border-gray-200 dark:border-gray-700"},Js=y(()=>e("div",{class:"absolute w-3 h-3 bg-gray-200 rounded-full mt-1.5 -start-1.5 border border-white dark:border-gray-900 dark:bg-gray-700"},null,-1)),Ks={class:"mb-1 text-sm font-normal leading-none text-gray-400 dark:text-gray-500"},Zs={class:"text-lg font-semibold text-gray-900 dark:text-white"},ei={key:0},ti={key:1},si={class:"mb-4 text-base font-normal text-gray-500 dark:text-gray-400"},ii={class:"space-y-3"},oi=y(()=>e("div",{class:"text-lg font-semibold text-gray-700"},"SLA Logs",-1)),ai={class:"bg-amber-50 p-5 border border-amber-200 rounded-lg shadow-lg"},li={class:"h-60 overflow-y-auto space-y-3 divide-y divide-amber-200"},ri={class:"text-sm font-semibold text-amber-700"},ni={class:"mt-1 text-xs text-gray-600"},di={class:"text-xs text-gray-500"},ci={class:"mt-8"},mi={key:0,class:"text-danger-500"},hi={class:"flex gap-1 justify-end mt-4"};function ui(t,s,o,m,i,d){const g=_("Loading"),S=_("Badge"),b=_("Icon"),w=_("Avatar"),D=_("TextArea"),k=_("FormGroup"),O=_("Button"),q=_("CloseButton"),N=_("FormModal"),I=_("ProposalMapping"),Y=_("CanvassCreation");return n(),u(C,null,[r(N,{title:`Purchase Request Reference No: ${i.data.reference_no}`,active:i.state.showModal,onSubmit:t.confirmSubmit,onClose:d.closeModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full h-full",back:""},{default:c(()=>[i.state.isLoading?(n(),x(g,{key:0,text:"Fetching resource data"})):p("",!0),i.state.isSaving?(n(),x(g,{key:1,text:"Saving record"})):p("",!0),i.state.isLoadingFileAttachment?(n(),x(g,{key:2,searching:!0,text:"Browsing attached document"})):p("",!0),e("div",jt,[e("form",{onSubmit:s[1]||(s[1]=$((...a)=>t.confirmSubmit&&t.confirmSubmit(...a),["prevent"]))},[e("div",Wt,[e("div",zt,[e("div",Qt,[Xt,e("div",Jt,h(i.data.company_name),1)]),e("div",Kt,[Zt,e("div",es,h(i.data.dealership_name),1)])]),e("div",ts,[e("div",ss,[is,e("div",os,h(i.data.needed_at),1)]),e("div",as,[ls,e("div",rs,h(i.data.approving_head_name),1)])]),e("div",ns,[ds,e("div",cs,h(i.data.requested_by_name),1)]),e("div",ms,[hs,e("div",us,h(i.data.purpose),1)]),i.data.file_attachment&&i.data.file_attachment.length>0?(n(),u("div",ps,[e("div",fs,[_s,e("ul",gs,[(n(!0),u(C,null,F(i.data.file_attachment,(a,E)=>(n(),u("li",{key:E,class:"inline-block bg-gray-100 rounded px-2 py-1 mr-2"},[e("div",ys,[a.extension==="pdf"?(n(),u("img",vs)):p("",!0),e("a",{href:"#",title:"View Attachment",class:"text-indigo-600 hover:underline",onClick:$(T=>d.viewAttachment(a.filename),["prevent"]),target:"_blank"},h(a.filename),9,bs)])]))),128))])])])):p("",!0)]),e("div",ws,[e("div",xs,[e("div",Cs,[ks,e("span",As,h(i.data.expense_category_name),1)]),e("div",Fs,[Ms,e("span",Ss,h(i.data.item_classification_name),1)])]),e("div",Is,[Es,e("div",Ts,[e("table",qs,[Ds,e("tbody",null,[(n(!0),u(C,null,F(i.data.items,(a,E)=>{var T,U,l,A,P,j,W,z,Q,X;return n(),u("tr",{key:E,class:J({"opacity-70 bg-gray-200":a.cancelled===1})},[e("td",null,h(a.type),1),e("td",null,h(a.description),1),e("td",null,h(a.uom),1),e("td",null,h(a.quantity),1),e("td",null,[r(S,{badgeClass:a.cancelled!==1?i.badgeClass:"bg-gray-400 text-white"},{default:c(()=>[f(h(a.cancelled!==1?a.status_name:"Cancelled item"),1)]),_:2},1032,["badgeClass"])]),e("td",null,[a.cancelled!==1&&![8,10].includes(a.status)?(n(),u("button",{key:0,onClick:pi=>d.cancelItem(a),class:"flex items-center bg-gray-400 text-white rounded p-1 hover:bg-yellow-500 transition duration-200",title:"Cancel Item"},[r(b,{icon:"heroicons-solid:x-circle",class:"mr-1"}),Bs],8,Os)):p("",!0),a.cancelled==1?(n(),u("div",Rs,[a.id==a.cancelled_item.prf_dtl_id?(n(),u("div",Vs,[Us,e("span",null,h(d.formatDate((T=a.cancelled_item)==null?void 0:T.created_at)),1),f(),Ps,Ls,r(w,{firstName:(l=(U=a.cancelled_item)==null?void 0:U.employee)==null?void 0:l.first_name,lastName:(P=(A=a.cancelled_item)==null?void 0:A.employee)==null?void 0:P.last_name,class:"flex-shrink-0 w-10 h-10 rounded-full bg-gray-300 border border-slate-200"},null,8,["firstName","lastName"]),f(" "+h((W=(j=a.cancelled_item)==null?void 0:j.employee)==null?void 0:W.first_name)+" "+h((Q=(z=a.cancelled_item)==null?void 0:z.employee)==null?void 0:Q.last_name)+" ",1),$s,Ns,e("span",Ys,h((X=a.cancelled_item)==null?void 0:X.remarks),1),Hs])):p("",!0)])):p("",!0)])],2)}),128))])])])])]),i.data.remarks_history?(n(),u("div",Gs,[e("div",js,[e("div",Ws,[zs,e("div",Qs,[e("ol",Xs,[(n(!0),u(C,null,F(i.data.remarks_history,a=>(n(),u("li",{key:a.id,class:"mb-7 ms-4"},[Js,e("time",Ks,h(a.created_at),1),e("h3",Zs,[a.user?(n(),u("div",ei,[r(w,{firstName:a.user.first_name,lastName:a.user.last_name,class:"flex-shrink-0 w-10 h-10 rounded-full bg-gray-300"},null,8,["firstName","lastName"]),f(" "+h(a.user.name),1)])):(n(),u("div",ti))]),e("p",si,h(a.remarks),1)]))),128))])])]),e("div",ii,[oi,e("div",ai,[e("div",li,[(n(!0),u(C,null,F(i.data.sla_logs,a=>(n(),u("div",{key:a.id,class:"flex justify-between items-start gap-4 p-3 bg-white rounded-lg shadow-sm hover:shadow-md transition-shadow duration-200 ease-in-out"},[e("div",null,[e("div",ri,h(a.status.name),1),e("div",ni," Duration: "+h(d.computeElapsed(a.start,a.end??new Date)),1)]),e("div",di,h(a.user?a.user.name:"N/A"),1)]))),128))])])])])])):p("",!0),e("div",ci,[r(k,{label:"Remarks",isRequired:""},{default:c(()=>[e("div",{class:J({"border border-danger-500 rounded":i.errors.remarks,"":!i.errors.remarks&&i.form.remarks})},[r(D,{modelValue:i.form.remarks,"onUpdate:modelValue":s[0]||(s[0]=a=>i.form.remarks=a),class:"p-2 w-full",placeholder:""},null,8,["modelValue"])],2)]),_:1}),i.errors.remarks?(n(),u("span",mi,h(i.errors.remarks),1)):p("",!0)]),e("div",hi,[i.state.process?(n(!0),u(C,{key:0},F(i.data.next_statuses,a=>(n(),u(C,{key:a.id},[a.sub_process_code?(n(),u(C,{key:0},[a.sub_process_code=="headApproval"?(n(),x(O,{key:0,class:"bg-primary-500 rounded py-1",onClick:E=>d.handleHeadApproval(a.id,a.action)},{default:c(()=>[f(h(a.action),1)]),_:2},1032,["onClick"])):p("",!0),a.sub_process_code=="assetValidation"?(n(),x(O,{key:1,class:"bg-primary-500 rounded py-1",onClick:E=>d.handleAssetValidation(a.id,a.action)},{default:c(()=>[f(h(a.action),1)]),_:2},1032,["onClick"])):p("",!0),a.sub_process_code=="adminValidation"?(n(),x(O,{key:2,class:"bg-primary-500 rounded py-1",onClick:E=>d.handleAdminValidation(a.id,a.action)},{default:c(()=>[f(h(a.action),1)]),_:2},1032,["onClick"])):p("",!0),a.sub_process_code=="mapProposal"?(n(),x(O,{key:3,class:"bg-primary-500 rounded py-1",onClick:E=>d.showProposals(a.id,a.action)},{default:c(()=>[f(h(a.action),1)]),_:2},1032,["onClick"])):p("",!0)],64)):(n(),x(O,{key:1,class:"bg-primary-500 rounded py-1",onClick:E=>d.submitForm(a.id,a.action)},{default:c(()=>[f(h(a.action),1)]),_:2},1032,["onClick"]))],64))),128)):p("",!0),r(q,{onClick:d.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"]),r(I,{ref:"proposal",onSubmit:d.submitMapProposal},null,8,["onSubmit"]),r(Y,{ref:"canvass",onSubmit:t.submitCanvass},null,8,["onSubmit"])],64)}const Hi=Z(Gt,[["render",ui],["__scopeId","data-v-5c4c4565"]]);export{Yi as F,Hi as P};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings