File manager - Edit - /home/autoph/.trash/assets/process-122a437c.js
Back
import{B as W}from"./index-4e86a4b0.js";import{_ as z,r as _,o as r,d as m,c as b,b as p,e as a,g as c,f as e,h as f,w as P,I as u,J as w,G as F,K as Q,L as X,H as j}from"./index-bed30964.js";import{C as J}from"./CloseButton-027f9165.js";import{D as K}from"./DeleteButton-f4cac9f2.js";import{S as Z,U as ee}from"./UpdateButton-2307ad7d.js";import{F as te,I as he}from"./vue-flatpickr.min-16607892.js";import{F as se}from"./index-f0021562.js";import{F as ie}from"./lodash-a2af4e6f.js";import{I as oe,T as ae,s as le,A as me}from"./index-3b103499.js";import{T as re}from"./index-44f6193c.js";import{L as ne}from"./Loading-317adae4.js";import{A as ue}from"./AssetItemService-b5bc35a1.js";import{E as pe}from"./ExpenseCategoryService-2531e5db.js";import{I as fe}from"./ItemClassificationService-c2b422bd.js";import{I as _e}from"./ItemTypeService-8e85285c.js";import{P as V}from"./PurchaseRequestService-775351fa.js";import{U as ge}from"./UnitOfMeasureService-210d6d22.js";import{F as de}from"./FileService-fe8f1258.js";import{c as B,a as A,b as ye,V as R,d as ve}from"./array-2d279bb5.js";import{f as N}from"./file-type-pdf-a9709057.js";import{I as ce}from"./index-249aa51d.js";/* empty css */import{A as H}from"./ApprovalService-a25e5bd3.js";import{P as be}from"./PurchaseRequestItemService-b9d95606.js";import we from"./index-12ed102b.js";import{P as xe}from"./index-ef155dc1.js";import{h as U}from"./moment-a9aaa855.js";import{B as Ce}from"./index-9c96c4c3.js";const ke={components:{FormModal:se,FormGroup:ie,InputGroup:oe,TextInput:ae,TextArea:re,SubmitButton:Z,UpdateButton:ee,CloseButton:J,DeleteButton:K,Button:W,Multiselect:le,Loading:ne,FlatPickr:te,Info:he,Icon:ce},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:N,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 pe.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 fe.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 _e.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 ue.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 ge.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),h=o.getFullYear(),i=String(o.getMonth()+1).padStart(2,"0"),n=String(o.getDate()).padStart(2,"0");this.form.needed_at=`${h}-${i}-${n}`,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:A().nullable().required("Company is required"),dealership_id:A().nullable().required("Dealership is required"),needed_at:A().nullable().required("Date Needed is required"),approving_head:A().nullable().required("Approving Head is required"),purpose:A().nullable().required("Purpose is required").min(10,"Purpose must be at least ten (10) characters"),items:ye().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:A().nullable().required("Item is required"),quantity:ve().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:A().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 h=t.target.files;if(!this.state.isEdit)this.form[s]=h,this.form.file_attachment_names=Array.from(h).map(i=>i.name);else{this.form[s]||(this.form[s]=[]),this.form[s]=[...this.form[s],...h];const i=this.form.file_attachment_names||[];this.form.file_attachment_names=[...i,...Array.from(h).map(n=>n.name)],console.log("EDITING>>>>"),console.log(h)}Array.from(h).forEach(i=>{const n=new FileReader;n.onload=()=>{let g="";i.type.startsWith("image/")?g=n.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)},n.readAsDataURL(i)})},async viewAttachment(t){if(this.state.isLoadingFileAttachment)return;this.state.isLoadingFileAttachment=!0;let s=await de.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 h=atob(s),i=new Array(h.length);for(let v=0;v<h.length;v++)i[v]=h.charCodeAt(v);const n=new Uint8Array(i),g=new Blob([n],{type:o}),M=URL.createObjectURL(g);window.open(M),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(){}},y=t=>(Q("data-v-47773404"),t=t(),X(),t),Fe=y(()=>e("div",{class:"font-semibold px-2 text-primary-700"},"Notes:",-1)),Ae=y(()=>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)),Me={class:"list-decimal space-y-2 p-4"},Se=y(()=>e("li",null,"Select the Date on when the Purchase request is needed.",-1)),Ie=y(()=>e("li",null,"Select the Approving Head.",-1)),Te=y(()=>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)),Ee=y(()=>e("li",null," A confirmation message will prompt, click Yes if you want to proceed with submission OR click No if not ",-1)),qe=y(()=>e("li",null," The disclaimer will show, select Agree or Disagree on the Disclaimer page ",-1)),De={class:"lg:p-2"},Oe={class:"grid lg:grid-cols-4 gap-2"},Be={key:0,class:"text-error"},Re={key:0,class:"text-error"},Ve={key:0,class:"text-error"},Ue={key:1,class:"text-error"},Pe={class:"grid grid-cols-3"},Le={class:"col-span-2"},$e={key:0,class:"text-error"},He={class:"p-2"},Ne={class:"w-full flex justify-between relative"},Ye=y(()=>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)),Ge={key:0,class:"mt-4"},je={class:"flex items-center space-x-2 mb-2"},We={class:"space-y-2"},ze={class:"flex items-cener space-x-2"},Qe={key:1,src:N,class:"w-6 h-6 mr-2 shadow-inner",alt:"PDF icon"},Xe=["onClick"],Je={class:"bg-primary-50 border border-primary-200"},Ke={class:"grid lg:grid-cols-3 gap-3 px-4 pt-2"},Ze={class:"flex gap-4"},et=y(()=>e("span",null,"EXPENSE CATEGORY",-1)),tt={key:0,class:"align-middle"},st=y(()=>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)),it={class:"flex gap-4"},ot=y(()=>e("span",null,"EXPENSE TYPE",-1)),at={key:0,class:"align-middle"},lt=y(()=>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)),rt={class:"flex gap-4"},nt=y(()=>e("span",null,"ITEM TYPE",-1)),dt={class:"align-middle"},ct=y(()=>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)),ht={class:"grid lg:flex lg:gap-2 px-4"},mt={class:"flex-grow"},ut={class:"flex gap-4"},pt=y(()=>e("span",null,"ITEM",-1)),ft={class:"align-middle"},_t=y(()=>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)),gt={key:0,class:"text-error"},yt={key:0,class:"text-error"},vt={key:0,class:"text-error"},bt={class:"flex justify-end"},wt={class:"border border-primary-100 mb-4"},xt={class:"p-2 text-xl font-semibold"},Ct=y(()=>e("span",{class:"text-sm text-red-500"},"*",-1)),kt={class:"list-none"},Ft=y(()=>e("li",null," List of items to be requested with their request quantity and uom. ",-1)),At={key:0,class:"text-error"},Mt={class:"min-h-[250px] max-h-[350px] overflow-auto"},St={class:"table"},It=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,"Remove")])],-1)),Tt={class:"flex gap-1 justify-end mt-4"},Et={class:"grid gap-2"},qt={class:"grid gap-2"},Dt={class:"w-full mb-2"},Ot={class:"grid gap-2"},Bt={class:"w-full mb-2"},Rt={class:"grid gap-2"},Vt=y(()=>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)),Ut={class:"flex justify-end gap-2"};function Pt(t,s,o,h,i,n){const g=_("Loading"),M=_("SubmitButton"),v=_("UpdateButton"),x=_("Info"),D=_("TextInput"),C=_("FormGroup"),O=_("FlatPickr"),E=_("Multiselect"),L=_("TextArea"),I=_("Button"),$=_("Icon"),d=_("DeleteButton"),T=_("CloseButton"),q=_("FormModal"),Y=_("InputGroup");return r(),m(w,null,[i.state.isLoading?(r(),b(g,{key:0,text:"Fetching resources"})):p("",!0),a(q,{title:i.state.isEdit?"Edit Purchase Request":"New Purchase Request",active:i.state.showModal,onClose:n.closeModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full h-full"},{info:c(()=>[a(x,{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(()=>[Fe,Ae,e("ul",Me,[Se,Ie,Te,e("li",null,[f(" Click "),i.state.isEdit?p("",!0):(r(),b(M,{key:0})),i.state.isEdit?(r(),b(v,{key:1})):p("",!0),f(" Button ")]),Ee,qe])]),_:1})]),default:c(()=>[i.state.isSaving?(r(),b(g,{key:0,text:"Saving record"})):p("",!0),e("div",De,[e("form",{onSubmit:s[17]||(s[17]=P((...l)=>t.confirmSubmit&&t.confirmSubmit(...l),["prevent"])),class:"space-y-1",enctype:"multipart/form-data"},[e("div",Oe,[a(C,{label:"Company",isRequired:!0},{info:c(()=>[a(x,{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(()=>[a(D,{type:"text",modelValue:n.company,"onUpdate:modelValue":s[0]||(s[0]=l=>n.company=l),isReadonly:!0},null,8,["modelValue"]),i.errors.company_id?(r(),m("span",Be,u(i.errors.company_id),1)):p("",!0)]),_:1}),a(C,{label:"Dealership",isRequired:!0},{info:c(()=>[a(x,{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(()=>[a(D,{type:"text",modelValue:n.dealership,"onUpdate:modelValue":s[1]||(s[1]=l=>n.dealership=l),isReadonly:!0},null,8,["modelValue"]),i.errors.dealership_id?(r(),m("span",Re,u(i.errors.dealership_id),1)):p("",!0)]),_:1}),a(C,{label:"Date Needed",isRequired:!0},{info:c(()=>[a(x,{header:"Date Needed",content:"This is the date when your items to be requested is needed."})]),default:c(()=>[a(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?(r(),m("span",Ve,u(i.errors.needed_at),1)):p("",!0)]),_:1}),a(C,{label:"Approving Head",isRequired:!0},{info:c(()=>[a(x,{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?(r(),b(E,{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?(r(),m("span",Ue,u(i.errors.approving_head),1)):p("",!0)]),_:1})]),e("div",Pe,[e("div",Le,[a(C,{label:"Purpose of Request",isRequired:!0},{info:c(()=>[a(x,{header:"Purpose of Request",content:"Input here the purpose of your request. This accepts at least ten (10) characters."})]),default:c(()=>[a(L,{placeholder:"",modelValue:i.form.purpose,"onUpdate:modelValue":s[4]||(s[4]=l=>i.form.purpose=l)},null,8,["modelValue"]),i.errors.purpose?(r(),m("span",$e,u(i.errors.purpose),1)):p("",!0)]),_:1})]),e("div",He,[a(C,{label:"Attachment",isRequired:!0,labelClass:"px-2"},{default:c(()=>[e("div",Ne,[e("input",{type:"file",id:"file_attachment",name:"file_attachment",onChange:s[5]||(s[5]=l=>n.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),Ye,a(I,{onClick:s[6]||(s[6]=l=>n.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,[(r(!0),m(w,null,F(i.form.file_attachment_names,(l,S)=>(r(),m("li",{key:S},u(l),1))),128))])]),i.form.file_attachment_exist&&i.form.file_attachment_exist.length>0?(r(),m("div",Ge,[e("div",je,[e("ul",We,[(r(!0),m(w,null,F(i.form.file_attachment_exist,(l,S)=>(r(),m("li",{key:S,class:"inline-block bg-gray-100 rounded px-2 py-1 mr-2"},[e("div",ze,[i.state.isEdit?(r(),b($,{key:0,title:"Remove "+l.filename,onClick:G=>n.removeFile(S),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"?(r(),m("img",Qe)):p("",!0),e("a",{href:"#",title:"View Attachment",class:"text-indigo-600 hover:underline",onClick:P(G=>n.viewAttachment(l.filename),["prevent"]),target:"_blank"},u(l.filename),9,Xe)])]))),128))])])])):p("",!0)])]),e("div",Je,[e("div",Ke,[a(C,null,{label:c(()=>[e("div",Ze,[et,i.form.items.length==0?(r(),m("span",tt,[e("a",{onClick:s[7]||(s[7]=l=>i.state.showCategoriesModal=!0),class:"text-primary-700 text-xs font-semibold"},"View Categories")])):p("",!0),a(x,{header:"Expense Category",btnClass:"p-0"},{default:c(()=>[st]),_:1})])]),default:c(()=>[a(E,{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:n.setCategory},null,8,["modelValue","options","disabled","onChange"])]),_:1}),a(C,null,{label:c(()=>[e("div",it,[ot,i.form.items.length==0?(r(),m("span",at,[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),a(x,{header:"Expense Type",btnClass:"p-0"},{default:c(()=>[lt]),_:1})])]),default:c(()=>[a(E,{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:n.setClassification},null,8,["modelValue","options","disabled","onChange"])]),_:1}),a(C,null,{label:c(()=>[e("div",rt,[nt,e("span",dt,[e("a",{onClick:s[11]||(s[11]=l=>i.state.showTypesModal=!0),class:"text-primary-700 text-xs font-semibold"},"View Item Types")]),a(x,{header:"Item Type",btnClass:"p-0"},{default:c(()=>[ct]),_:1})])]),default:c(()=>[a(E,{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:n.setType},null,8,["modelValue","options","onChange"])]),_:1})]),e("div",ht,[e("div",mt,[a(C,null,{label:c(()=>[e("div",ut,[pt,e("span",ft,[e("a",{onClick:s[13]||(s[13]=l=>i.state.showItemsModal=!0),class:"text-primary-700 text-xs font-semibold"},"View Items")]),a(x,{header:"Asset Item",btnClass:"p-0"},{default:c(()=>[_t]),_:1})])]),default:c(()=>[a(E,{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:n.setItem},null,8,["modelValue","options","onChange"]),i.errors.asset_item_id?(r(),m("div",gt,u(i.errors.asset_item_id),1)):p("",!0)]),_:1})]),e("div",null,[a(C,{label:"Quantity"},{info:c(()=>[a(x,{btnClass:"py-0 px-1",header:"Quantity",content:"The request quantity of this item."})]),default:c(()=>[a(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?(r(),m("div",yt,u(i.errors.quantity),1)):p("",!0)]),_:1})]),e("div",null,[a(C,{label:"UoM",formClass:"lg:w-[200px]"},{info:c(()=>[a(x,{btnClass:"py-0 px-1",header:"Unit of Measure",content:`The\r unit of measure of this item.`})]),default:c(()=>[a(E,{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?(r(),m("div",vt,u(i.errors.uom),1)):p("",!0)]),_:1})]),e("div",bt,[a(C,{formClass:"lg:pt-8 pt-2 "},{default:c(()=>[a(I,{class:"bg-slate-800",onClick:n.addItem},{default:c(()=>[f("Add Item")]),_:1},8,["onClick"])]),_:1})])]),e("div",wt,[e("header",xt,[f(" Items "),Ct,a(x,{header:"Items",content:""},{default:c(()=>[e("ul",kt,[Ft,e("li",null,[f(" The added items here can be removed via the "),a(d,{iconClass:"text-base"}),f(" button on each row ")])])]),_:1}),i.errors.items?(r(),m("span",At," "+u(i.errors.items),1)):p("",!0)]),e("div",Mt,[e("table",St,[It,e("tbody",null,[(r(!0),m(w,null,F(i.form.items,(l,S)=>(r(),m("tr",{key:S},[e("td",null,u(l.type),1),e("td",null,u(l.description),1),e("td",null,u(l.uom),1),e("td",null,u(l.quantity),1),e("td",null,[a(d,{onClick:G=>n.removeItem(S)},null,8,["onClick"])])]))),128))])])])])]),e("div",Tt,[i.state.isEdit?(r(),b(v,{key:1,onClick:n.submitForm},null,8,["onClick"])):(r(),b(M,{key:0,onClick:n.submitForm},null,8,["onClick"])),a(T,{onClick:n.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onClose","themeClass"]),a(q,{title:"Expense Categories",active:i.state.showCategoriesModal,onClose:n.closeCategoriesModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[e("div",Et,[(r(!0),m(w,null,F(i.categoryOptions,l=>(r(),m("div",{key:l.value,class:"border-b border-slate-200 w-full"},[a(I,{onClick:S=>n.setCategory(l.value),btnClass:"bg-slate-50 text-left py-1"},{default:c(()=>[f(u(l.label),1)]),_:2},1032,["onClick"])]))),128))])]),_:1},8,["active","onClose","themeClass"]),a(q,{title:"Expense Types",active:i.state.showClassificationsModal,onClose:n.closeClassificationsModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[e("div",qt,[(r(!0),m(w,null,F(i.classificationOptions,l=>(r(),m("div",{key:l.value,class:"border-b border-slate-200 w-full"},[a(I,{onClick:S=>n.setClassification(l.value),btnClass:"bg-slate-50 text-left py-1"},{default:c(()=>[f(u(l.label),1)]),_:2},1032,["onClick"])]))),128))])]),_:1},8,["active","onClose","themeClass"]),a(q,{title:"Item Types",active:i.state.showTypesModal,onClose:n.closeTypesModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[e("div",Dt,[a(Y,{icon:"heroicons:magnifying-glass-20-solid"},{default:c(()=>[a(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",Ot,[(r(!0),m(w,null,F(n.filteredTypeOptions,l=>(r(),m("div",{key:l.value,class:"border-b border-slate-200 w-full"},[a(I,{onClick:S=>n.setType(l.value),btnClass:"bg-slate-50 text-left py-1"},{default:c(()=>[f(u(l.label),1)]),_:2},1032,["onClick"])]))),128))])]),_:1},8,["active","onClose","themeClass"]),a(q,{title:"Items",active:i.state.showItemsModal,onClose:n.closeItemsModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[e("div",Bt,[a(Y,{icon:"heroicons:magnifying-glass-20-solid"},{default:c(()=>[a(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",Rt,[(r(!0),m(w,null,F(n.filteredItemOptions,l=>(r(),m("div",{key:l.value,class:"border-b border-slate-200 w-full"},[a(I,{onClick:S=>n.setItem(l.value),btnClass:"bg-slate-50 text-left py-1"},{default:c(()=>[f(u(l.label),1)]),_:2},1032,["onClick"])]))),128))])]),_:1},8,["active","onClose","themeClass"]),a(q,{title:"Disclaimer",active:i.state.showDisclaimerModal,onClose:n.closeDisclaimerModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full lg:w-1/2"},{default:c(()=>[Vt,e("div",Ut,[a(I,{onClick:s[20]||(s[20]=l=>n.setDisclaimer(1)),btnClass:"bg-primary-600 text-white text-left py-1"},{default:c(()=>[f("Yes")]),_:1}),a(I,{onClick:s[21]||(s[21]=l=>n.setDisclaimer(0)),btnClass:"bg-slate-300 text-black text-left py-1"},{default:c(()=>[f("No")]),_:1})])]),_:1},8,["active","onClose","themeClass"])],64)}const Si=z(ke,[["render",Pt],["__scopeId","data-v-47773404"]]);const Lt={components:{FormModal:se,FormGroup:ie,InputGroup:oe,TextInput:ae,TextArea:re,SubmitButton:Z,UpdateButton:ee,CloseButton:J,DeleteButton:K,Button:W,Multiselect:le,Loading:ne,FlatPickr:te,Avatar:me,ProposalMapping:xe,CanvassCreation:we,Icon:ce,Badge:Ce},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},searchType:null,searchItem: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:U(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,V.fetchDetails(t).then(s=>{s.status==200&&(this.data.items=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:A().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(h=>{h.value?this.updateRecord(t):this.state.showModal=!1})}catch(o){if(o instanceof R){const h={};o.inner.forEach(i=>{h[i.path]=i.message}),this.errors=h}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:A().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(h){if(h instanceof R){const i={};h.inner.forEach(n=>{i[n.path]=n.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(h=>{h.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(h=>{console.log(h),h.response.status==422?this.$swal.fire({title:"Ooops! something is wrong.",text:h.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=U(t),h=U(s),i=h.diff(o,"days"),g=U.duration(h.diff(o)).asHours()-i*24,M=Math.floor(g),v=Math.floor((g-M)*60);return`${i} days, ${M} hours, and ${v} minutes`},async handleHeadApproval(t,s){this.errors={};try{await B().shape({remarks:A().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(h=>{h.value?this.submitHeadApproval(t):this.$refs.proposal.state.showModal=!1})}catch(o){o instanceof R&&o.inner.forEach(h=>{h.path==="remarks"&&(this.errors.remarks=h.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:A().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(h=>{h.value?this.submitAssetValidation(t):this.$refs.proposal.state.showModal=!1})}catch(o){o instanceof R&&o.inner.forEach(h=>{h.path==="remarks"&&(this.errors.remarks=h.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:A().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(h=>{h.value?this.submitAdminValidation(t):this.$refs.proposal.state.showModal=!1})}catch(o){o instanceof R&&o.inner.forEach(h=>{h.path==="remarks"&&(this.errors.remarks=h.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;be.cancelItem({id:t.id,request_header_id:t.request_header_id,reason:o}).then(h=>{h.status==201&&this.$swal.fire({title:"Great!",text:"Record successfully saved.",icon:"success",timer:2e3})}).catch(h=>{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 de.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 h=atob(s),i=new Array(h.length);for(let v=0;v<h.length;v++)i[v]=h.charCodeAt(v);const n=new Uint8Array(i),g=new Blob([n],{type:o}),M=URL.createObjectURL(g);window.open(M),this.state.isLoadingFileAttachment=!1}},mounted(){}},k=t=>(Q("data-v-ee04bb7a"),t=t(),X(),t),$t={class:"lg:p-2"},Ht={class:"space-y-2"},Nt={class:"grid lg:grid-cols-2"},Yt={class:"flex gap-2 border-b border-slate-300 border-dashed py-1"},Gt=k(()=>e("div",{class:"label"},"Company:",-1)),jt={class:"value"},Wt={class:"flex gap-2 border-b border-slate-300 border-dashed py-1"},zt=k(()=>e("div",{class:"label"},"Dealership:",-1)),Qt={class:"value"},Xt={class:"grid lg:grid-cols-2"},Jt={class:"flex gap-2 border-b border-slate-300 border-dashed py-1"},Kt=k(()=>e("div",{class:"label"},"Date Needed:",-1)),Zt={class:"value"},es={class:"flex gap-1 border-b border-slate-300 border-dashed py-1"},ts=k(()=>e("div",{class:"label"},"Approving Head:",-1)),ss={class:"value"},is={class:"flex gap-1 border-b border-slate-300 border-dashed py-1"},os=k(()=>e("div",{class:"label"},"Requested By:",-1)),as={class:"value"},ls={class:"flex gap-1 border-b border-slate-300 border-dashed py-1"},rs=k(()=>e("div",{class:"label"},"Purpose:",-1)),ns={class:"value"},ds={key:0,class:"mt-4"},cs={class:"flex items-center space-x-2 mb-2"},hs=k(()=>e("div",{class:"label"},"Attachment :",-1)),ms={class:"space-y-2"},us={class:"flex items-cener space-x-2"},ps={key:0,src:N,class:"w-6 h-6 mr-2 shadow-inner",alt:"PDF icon"},fs=["onClick"],_s={class:"bg-primary-50 mt-8 border border-primary-300 p-4 mb-8 drop-shadow-md"},gs={class:"grid lg:grid-cols-2 gap-3 py-2"},ys={class:"flex gap-4"},vs=k(()=>e("span",{class:"label"},"EXPENSE CATEGORY:",-1)),bs={class:"value"},ws={class:"flex gap-4"},xs=k(()=>e("span",{class:"label"},"EXPENSE TYPE",-1)),Cs={class:"value"},ks={class:"mb-4"},Fs=k(()=>e("header",{class:"text-xl font-semibold"},"Items",-1)),As={class:"max-h-[350px] overflow-auto"},Ms={class:"table"},Ss=k(()=>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)),Is=["onClick"],Ts=k(()=>e("span",null,"Cancel",-1)),Es={key:0,class:"mb-4"},qs={class:"grid lg:grid-cols-2 gap-2"},Ds={class:"space-y-3"},Os=k(()=>e("div",{class:"text-lg font-semibold text-gray-700"}," Remarks History ",-1)),Bs={class:"bg-gray-50 p-5 border border-gray-200 rounded-lg shadow-lg h-72 overflow-y-auto"},Rs={class:"relative border-s border-gray-200 dark:border-gray-700"},Vs=k(()=>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)),Us={class:"mb-1 text-sm font-normal leading-none text-gray-400 dark:text-gray-500"},Ps={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ls={key:0},$s={key:1},Hs={class:"mb-4 text-base font-normal text-gray-500 dark:text-gray-400"},Ns={class:"space-y-3"},Ys=k(()=>e("div",{class:"text-lg font-semibold text-gray-700"},"SLA Logs",-1)),Gs={class:"bg-amber-50 p-5 border border-amber-200 rounded-lg shadow-lg"},js={class:"h-60 overflow-y-auto space-y-3 divide-y divide-amber-200"},Ws={class:"text-sm font-semibold text-amber-700"},zs={class:"mt-1 text-xs text-gray-600"},Qs={class:"text-xs text-gray-500"},Xs={class:"mt-8"},Js={key:0,class:"text-danger-500"},Ks={class:"flex gap-1 justify-end mt-4"};function Zs(t,s,o,h,i,n){const g=_("Loading"),M=_("Badge"),v=_("Icon"),x=_("Avatar"),D=_("TextArea"),C=_("FormGroup"),O=_("Button"),E=_("CloseButton"),L=_("FormModal"),I=_("ProposalMapping"),$=_("CanvassCreation");return r(),m(w,null,[a(L,{title:`Purchase Request Reference No: ${i.data.reference_no}`,active:i.state.showModal,onSubmit:t.confirmSubmit,onClose:n.closeModal,themeClass:i.state.isEdit?"bg-primary-600":"bg-primary-800",sizeClass:"w-full h-full",back:""},{default:c(()=>[i.state.isLoading?(r(),b(g,{key:0,text:"Fetching resource data"})):p("",!0),i.state.isSaving?(r(),b(g,{key:1,text:"Saving record"})):p("",!0),i.state.isLoadingFileAttachment?(r(),b(g,{key:2,searching:!0,text:"Browsing attached document"})):p("",!0),e("div",$t,[e("form",{onSubmit:s[1]||(s[1]=P((...d)=>t.confirmSubmit&&t.confirmSubmit(...d),["prevent"]))},[e("div",Ht,[e("div",Nt,[e("div",Yt,[Gt,e("div",jt,u(i.data.company_name),1)]),e("div",Wt,[zt,e("div",Qt,u(i.data.dealership_name),1)])]),e("div",Xt,[e("div",Jt,[Kt,e("div",Zt,u(i.data.needed_at),1)]),e("div",es,[ts,e("div",ss,u(i.data.approving_head_name),1)])]),e("div",is,[os,e("div",as,u(i.data.requested_by_name),1)]),e("div",ls,[rs,e("div",ns,u(i.data.purpose),1)]),i.data.file_attachment&&i.data.file_attachment.length>0?(r(),m("div",ds,[e("div",cs,[hs,e("ul",ms,[(r(!0),m(w,null,F(i.data.file_attachment,(d,T)=>(r(),m("li",{key:T,class:"inline-block bg-gray-100 rounded px-2 py-1 mr-2"},[e("div",us,[d.extension==="pdf"?(r(),m("img",ps)):p("",!0),e("a",{href:"#",title:"View Attachment",class:"text-indigo-600 hover:underline",onClick:P(q=>n.viewAttachment(d.filename),["prevent"]),target:"_blank"},u(d.filename),9,fs)])]))),128))])])])):p("",!0)]),e("div",_s,[e("div",gs,[e("div",ys,[vs,e("span",bs,u(i.data.expense_category_name),1)]),e("div",ws,[xs,e("span",Cs,u(i.data.item_classification_name),1)])]),e("div",ks,[Fs,e("div",As,[e("table",Ms,[Ss,e("tbody",null,[(r(!0),m(w,null,F(i.data.items,(d,T)=>(r(),m("tr",{key:T,class:j({"opacity-50 bg-gray-200":d.cancelled===1})},[e("td",null,u(d.type),1),e("td",null,u(d.description),1),e("td",null,u(d.uom),1),e("td",null,u(d.quantity),1),e("td",null,[a(M,{badgeClass:d.cancelled!==1?i.badgeClass:"bg-gray-400 text-white"},{default:c(()=>[f(u(d.cancelled!==1?d.status_name:"Cancelled item"),1)]),_:2},1032,["badgeClass"])]),e("td",null,[d.cancelled!==1&&![8,10].includes(d.status)?(r(),m("button",{key:0,onClick:q=>n.cancelItem(d),class:"flex items-center bg-gray-400 text-white rounded p-1 hover:bg-yellow-500 transition duration-200",title:"Cancel Item"},[a(v,{icon:"heroicons-solid:x-circle",class:"mr-1"}),Ts],8,Is)):p("",!0)])],2))),128))])])])])]),i.data.remarks_history?(r(),m("div",Es,[e("div",qs,[e("div",Ds,[Os,e("div",Bs,[e("ol",Rs,[(r(!0),m(w,null,F(i.data.remarks_history,d=>(r(),m("li",{key:d.id,class:"mb-7 ms-4"},[Vs,e("time",Us,u(d.created_at),1),e("h3",Ps,[d.user?(r(),m("div",Ls,[a(x,{firstName:d.user.first_name,lastName:d.user.last_name,class:"flex-shrink-0 w-10 h-10 rounded-full bg-gray-300"},null,8,["firstName","lastName"]),f(" "+u(d.user.name),1)])):(r(),m("div",$s))]),e("p",Hs,u(d.remarks),1)]))),128))])])]),e("div",Ns,[Ys,e("div",Gs,[e("div",js,[(r(!0),m(w,null,F(i.data.sla_logs,d=>(r(),m("div",{key:d.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",Ws,u(d.status.name),1),e("div",zs," Duration: "+u(n.computeElapsed(d.start,d.end??new Date)),1)]),e("div",Qs,u(d.user?d.user.name:"N/A"),1)]))),128))])])])])])):p("",!0),e("div",Xs,[a(C,{label:"Remarks",isRequired:""},{default:c(()=>[e("div",{class:j({"border border-danger-500 rounded":i.errors.remarks,"":!i.errors.remarks&&i.form.remarks})},[a(D,{modelValue:i.form.remarks,"onUpdate:modelValue":s[0]||(s[0]=d=>i.form.remarks=d),class:"p-2 w-full",placeholder:""},null,8,["modelValue"])],2)]),_:1}),i.errors.remarks?(r(),m("span",Js,u(i.errors.remarks),1)):p("",!0)]),e("div",Ks,[i.state.process?(r(!0),m(w,{key:0},F(i.data.next_statuses,d=>(r(),m(w,{key:d.id},[d.sub_process_code?(r(),m(w,{key:0},[d.sub_process_code=="headApproval"?(r(),b(O,{key:0,class:"bg-primary-500 rounded py-1",onClick:T=>n.handleHeadApproval(d.id,d.action)},{default:c(()=>[f(u(d.action),1)]),_:2},1032,["onClick"])):p("",!0),d.sub_process_code=="assetValidation"?(r(),b(O,{key:1,class:"bg-primary-500 rounded py-1",onClick:T=>n.handleAssetValidation(d.id,d.action)},{default:c(()=>[f(u(d.action),1)]),_:2},1032,["onClick"])):p("",!0),d.sub_process_code=="adminValidation"?(r(),b(O,{key:2,class:"bg-primary-500 rounded py-1",onClick:T=>n.handleAdminValidation(d.id,d.action)},{default:c(()=>[f(u(d.action),1)]),_:2},1032,["onClick"])):p("",!0),d.sub_process_code=="mapProposal"?(r(),b(O,{key:3,class:"bg-primary-500 rounded py-1",onClick:T=>n.showProposals(d.id,d.action)},{default:c(()=>[f(u(d.action),1)]),_:2},1032,["onClick"])):p("",!0)],64)):(r(),b(O,{key:1,class:"bg-primary-500 rounded py-1",onClick:T=>n.submitForm(d.id,d.action)},{default:c(()=>[f(u(d.action),1)]),_:2},1032,["onClick"]))],64))),128)):p("",!0),a(E,{onClick:n.closeModal},null,8,["onClick"])])],32)])]),_:1},8,["title","active","onSubmit","onClose","themeClass"]),a(I,{ref:"proposal",onSubmit:n.submitMapProposal},null,8,["onSubmit"]),a($,{ref:"canvass",onSubmit:t.submitCanvass},null,8,["onSubmit"])],64)}const Ii=z(Lt,[["render",Zs],["__scopeId","data-v-ee04bb7a"]]);export{Si as F,Ii as P};
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings