PageSourceSearch

https://ims.drmgrdu.ac.in/client/chunk-EBTDZ625.js

js drmgrdu.ac.in collected 2026-10-02 04:43:20 UTC 408,317 bytes, 2,976 lines download raw bytes

1import"./chunk-7PBE3EFL.js";import{a as bt}from"./chunk-BWXINARZ.js";import{a as Ge}from"./chunk-OXGSOEBO.js";import{a as qe}from"./chunk-WXQS62KK.js";import"./chunk-L4KS4O4D.js";import"./chunk-OBL3UMJK.js";import{a as ve,b as xe,c as Se,d as Oe,e as Re,f as ft,g as ht,h as oi}from"./chunk-V5KJRP2K.js";import"./chunk-57S6Q36M.js";import"./chunk-QEGAIP75.js";import{a as li}from"./chunk-G65RGBKK.js";import{a as Qe}from"./chunk-3CO4C5KT.js";import{a as gt}from"./chunk-TGLJFD7R.js";import{c as Qt}from"./chunk-LBLKBDMD.js";import"./chunk-YLPDWZZX.js";import"./chunk-Y7PLHQ6M.js";import"./chunk-3R646RNR.js";import{e as ri,f as ai}from"./chunk-PLPK6HII.js";import{F as be,G as ii,H as ni,c as j,e as P,g as H,h as me,l as ue,m as fe,n as Ne,o as Kt,p as Xt,q as he,t as ge,u as Jt,v as ei,w as ti,y as Me,z as Ve}from"./chunk-UFCZWRLF.js";import{a as K}from"./chunk-7Q5L7ALI.js";import"./chunk-CARY4E7O.js";import{a as R}from"./chunk-2PT6A6VZ.js";import{$ as nt,$a as at,Ac as te,Bc as ie,Cc as W,D as it,Dc as Gt,Eb as Ee,Ec as Wt,Fb as ye,Fc as jt,Gb as Fe,Gc as mt,Hb as le,I as $t,Ib as o,Ja as d,Jb as w,Ka as D,Kb as A,L as Ut,Lb as st,Mb as dt,Nc as Q,Pc as se,Rc as Ht,Sb as X,Tb as J,U as zt,Ub as ee,Uc as de,Va as _,Xb as He,Xc as pe,Yb as $,Zb as Ze,_ as oe,_a as p,a as qt,ab as re,ba as Z,c as Lt,dd as Zt,ec as L,fa as q,fc as pt,ga as rt,gc as B,gd as ut,hd as ce,id as ne,jc as ct,jd as De,kb as r,kd as Te,l as Bt,lb as n,mb as c,md as wt,na as x,nb as ot,oa as S,ob as lt,pa as U,pc as Yt,qa as z,qb as I,ub as b,wb as g}from"./chunk-32W73H3G.js";import{a as T,b as N,d as tt,g as Ye,h as M}from"./chunk-WWX6BADO.js";var So={headers:new de({"Content-Type":"application/json"})},vt=(()=>{class l{http;constructor(e){this.http=e}createSupplierFormConfig(e){return this.http.post(R.URI+"/api/supplierFormConfig/create",e)}getSupplierFormConfigs(e,i,t){let a=R.URI+"/api/supplierFormConfig/get?order=des";return e!==void 0&&i!==void 0&&(a+="&start="+e+"&count="+i),t&&(a+="&regex="+encodeURIComponent(t)),this.http.get(a)}getSupplierFormConfigById(e){return this.http.get(R.URI+"/api/supplierFormConfig/"+e)}updateSupplierFormConfig(e,i){return this.http.put(R.URI+"/api/supplierFormConfig/update/"+e,i)}deleteSupplierFormConfig(e){return this.http.delete(R.URI+"/api/supplierFormConfig/delete/"+e)}checkDuplicateSupplierName(e,i){let t=R.URI+"/api/supplierFormConfig/exists?supplierName="+encodeURIComponent(e!=null?String(e):"");return i&&(t+="&excludeId="+encodeURIComponent(i)),this.http.get(t)}static \u0275fac=function(i){return new(i||l)(Z(pe))};static \u0275prov=oe({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();function Ni(l,f){l&1&&(r(0,"div",20)(1,"div",21)(2,"span",22),o(3,"Loading..."),n()()())}function Mi(l,f){if(l&1&&(ot(0),o(1),lt()),l&2){let e=g().$implicit;d(),A(" ",e.supplierName," ")}}function Vi(l,f){if(l&1&&c(0,"input",28),l&2){let e=g(3);p("formControl",e.editForm==null?null:e.editForm.controls.supplierName)}}function Oi(l,f){if(l&1&&(ot(0),o(1),lt()),l&2){let e=g().$implicit;d(),A(" ",e.contactNo," ")}}function Ri(l,f){if(l&1&&c(0,"input",28),l&2){let e=g(3);p("formControl",e.editForm==null?null:e.editForm.controls.contactNo)}}function qi(l,f){if(l&1){let e=I();ot(0),r(1,"button",29),b("click",function(){x(e);let t=g().index,a=g(2);return S(a.startEdit(t))}),o(2,"Edit"),n(),r(3,"button",30),b("click",function(){x(e);let t=g().index,a=g(2);return S(a.remove(t))}),o(4,"Delete"),n(),lt()}if(l&2){let e=g(3);d(),p("disabled",e.loading),d(2),p("disabled",e.loading)}}function Li(l,f){if(l&1){let e=I();r(0,"button",31),b("click",function(){x(e);let t=g(3);return S(t.saveEdit())}),o(1,"Save"),n(),r(2,"button",32),b("click",function(){x(e);let t=g(3);return S(t.cancelEdit())}),o(3,"Cancel"),n()}if(l&2){let e=g(3);p("disabled",e.loading),d(2),p("disabled",e.loading)}}function Bi(l,f){if(l&1&&(r(0,"tr")(1,"td"),o(2),n(),r(3,"td"),_(4,Mi,2,1,"ng-container",27)(5,Vi,1,1,"ng-template",null,0,ct),n(),r(7,"td"),_(8,Oi,2,1,"ng-container",27)(9,Ri,1,1,"ng-template",null,1,ct),n(),r(11,"td",24),_(12,qi,5,2,"ng-container",27)(13,Li,4,2,"ng-template",null,2,ct),n()()),l&2){let e=f.index,i=le(6),t=le(10),a=le(14),s=g(2);d(2),w(e+1),d(2),p("ngIf",s.editingIndex!==e)("ngIfElse",i),d(4),p("ngIf",s.editingIndex!==e)("ngIfElse",t),d(4),p("ngIf",s.editingIndex!==e)("ngIfElse",a)}}function $i(l,f){l&1&&(r(0,"tr")(1,"td",33),o(2,"No entries"),n()())}function Ui(l,f){if(l&1&&(r(0,"table",23)(1,"thead")(2,"tr")(3,"th"),o(4,"#"),n(),r(5,"th"),o(6,"Supplier Name"),n(),r(7,"th"),o(8,"Contact No"),n(),r(9,"th",24),o(10,"Actions"),n()()(),r(11,"tbody"),_(12,Bi,15,7,"tr",25)(13,$i,3,0,"tr",26),n()()),l&2){let e=g();d(12),p("ngForOf",e.paginatedEntries),d(),p("ngIf",e.paginatedEntries.length===0&&!e.loading)}}function zi(l,f){if(l&1){let e=I();r(0,"div",34)(1,"span",35),o(2),n(),r(3,"div",36)(4,"button",37),b("click",function(){x(e);let t=g();return S(t.paginate("prev"))}),o(5," \xAB Prev "),n(),r(6,"button",37),b("click",function(){x(e);let t=g();return S(t.paginate("next"))}),o(7," Next \xBB "),n()()()}if(l&2){let e=g();
1d(2),st(" Page ",e.ncount," (",e.paginatedEntries.length," records) "),d(2),p("disabled",e.isValueOne("prev")),d(2),p("disabled",e.isValueOne("next"))}}var di=(()=>{class l{fb;provider;toastr;errorHandler;form;paginatedEntries=[];loading=!1;editingIndex=null;editForm=null;ncount=1;pageSize=100;lastPageSize=0;constructor(e,i,t,a){this.fb=e,this.provider=i,this.toastr=t,this.errorHandler=a,this.form=this.fb.group({supplierName:["",[P.required,P.maxLength(100)]],contactNo:["",[P.maxLength(20)]]})}ngOnInit(){this.load()}add(){if(this.form.invalid||this.loading){this.form.markAllAsTouched();return}let e=this.form.value,i=(e.supplierName||"").trim();if(!i){this.toastr.warning("Supplier name is required.","Validation");return}this.loading=!0,this.provider.checkDuplicateSupplierName(i).subscribe({next:t=>{if(t&&t.exists){this.loading=!1,this.toastr.warning("A supplier with the same name already exists.","Duplicate Entry",{timeOut:4e3,progressBar:!0});return}this.provider.createSupplierFormConfig(e).subscribe({next:()=>{this.form.reset(),this.ncount=1,this.load()},error:a=>{this.loading=!1,this.toastr.error(this.errorHandler.getErrorMessage(a,"Failed to add supplier."),"Error",{timeOut:5e3,progressBar:!0})}})},error:t=>{this.loading=!1,this.toastr.error(this.errorHandler.getErrorMessage(t,"Failed to validate supplier name."),"Error",{timeOut:5e3,progressBar:!0})}})}remove(e){let i=this.paginatedEntries[e],t=i?._id||i?.id;!i||!t||this.loading||(this.loading=!0,this.provider.deleteSupplierFormConfig(t).subscribe({next:()=>{this.ncount=1,this.load()},error:()=>{this.loading=!1}}))}startEdit(e){let i=this.paginatedEntries[e];!i||this.loading||(this.editingIndex=e,this.editForm=this.fb.group({supplierName:[i.supplierName,[P.required,P.maxLength(100)]],contactNo:[i.contactNo,[P.maxLength(20)]]}))}cancelEdit(){this.editingIndex=null,this.editForm=null}saveEdit(){if(this.editingIndex===null||!this.editForm||this.editForm.invalid||this.loading){this.editForm?.markAllAsTouched();return}let e=this.paginatedEntries[this.editingIndex],i=e?._id||e?.id;if(!e||!i)return;let t=this.editForm.value,a=(t.supplierName||"").trim();if(!a){this.toastr.warning("Supplier name is required.","Validation");return}let s=(e.supplierName||"").trim().toLowerCase().replace(/\s+/g," "),m=a.toLowerCase().replace(/\s+/g," "),u=s!==m;this.loading=!0;let h=()=>{this.provider.updateSupplierFormConfig(i,t).subscribe({next:()=>{this.cancelEdit(),this.ncount=1,this.load()},error:v=>{this.loading=!1,this.toastr.error(this.errorHandler.getErrorMessage(v,"Failed to update supplier."),"Error",{timeOut:5e3,progressBar:!0})}})};if(!u){h();return}this.provider.checkDuplicateSupplierName(a,i).subscribe({next:v=>{if(v&&v.exists){this.loading=!1,this.toastr.warning("A supplier with the same name already exists.","Duplicate Entry",{timeOut:4e3,progressBar:!0});return}h()},error:v=>{this.loading=!1,this.toastr.error(this.errorHandler.getErrorMessage(v,"Failed to validate supplier name."),"Error",{timeOut:5e3,progressBar:!0})}})}paginate(e){return M(this,null,function*(){e==="prev"&&this.ncount>1?(this.ncount--,yield this.load(!1)):e==="next"&&this.lastPageSize===this.pageSize&&(this.ncount++,yield this.load(!1))})}isValueOne(e){return e==="prev"?this.ncount===1:e==="next"?this.lastPageSize<this.pageSize||this.paginatedEntries.length===0:!1}load(e=!0){return new Promise(i=>{e&&(this.ncount=1),this.loading=!0;let t=(this.ncount-1)*this.pageSize;this.provider.getSupplierFormConfigs(t,this.pageSize).subscribe({next:a=>{let s=Array.isArray(a?.data)?a.data:Array.isArray(a)?a:[];this.paginatedEntries=s,this.lastPageSize=this.paginatedEntries.length,this.loading=!1,i()},error:()=>{this.paginatedEntries=[],this.lastPageSize=0,this.loading=!1,i()}})})}static \u0275fac=function(i){return new(i||l)(D(be),D(vt),D(K),D(gt))};static \u0275cmp=q({type:l,selectors:[["app-supplier-form-config"]],decls:23,vars:6,consts:[["editName",""],["editContact",""],["editingActions",""],[1,"container-fluid"],[1,"row","mb-3"],[1,"col-md-6"],["novalidate","",3,"ngSubmit","formGroup"],[1,"mb-3"],[1,"form-label"],["formControlName","supplierName","placeholder","Enter supplier name",1,"form-control"],["formControlName","contactNo","placeholder","Enter contact number",1,"form-control"],["type","submit",1,"btn","btn-primary",3,"disabled"],[1,"row"],[1,"col-md-8"],[1,"card"],[1,"card-header"],[1,"card-body","p-0"],["class","p-3 text-center",4,"ngIf"],["class","table mb-0 align-middle",4,"ngIf"],["class","card-footer d-flex justify-content-between align-items-center",4,"ngIf"],[1,"p-3","text-center"],["role","status",1,"spinner-border"],[1,"visually-hidden"],[1,"table","mb-0","align-middle"],[1,"text-end"],[4,"ngFor","ngForOf"],[4,"ngIf"],[4,"ngIf","ngIfElse"],[1,"form-control","form-control-sm",3,"formControl"],[1,"btn","btn-sm","btn-outline-primary","me-2",3,"click","disabled"],[1,"btn","btn-sm","btn-outline-danger",3,"click","disabled"],[1,"btn","btn-sm","btn-primary","me-2",3,"click","disabled"],[1,"btn","btn-sm","btn-secondary",3,"click","disabled"],["colspan","4",1,"text-center","text-muted"],[1,"card-footer","d-flex","justify-content-between","align-items-center"],[1,"text-muted","small"],["role","group",1,"btn-group"],["type","button",1,"btn","btn-outline-primary","btn-sm",3,"click","disabled"]],template:function(i,t){i&1&&(r(0,"div",3)(1,"div",4)(2,"div",5)(3,"form",6),b("ngSubmit",function(){return t.add()}),r(4,"div",7)(5,"label",8),o(6,"Supplier Name"),n(),c(7,"input",9),n(),r(8,"div",7)(9,"label",8),o(10,"Contact No"),n(),c(11,"input",10),n(),r(12,"button",11),o(13),n()()()(),r(14,"div",12)(15,"div",13)(16,"div",14)(17,"div",15),o(18,"Saved Suppliers"),n(),r(19,"div",16),_(20,Ni,4,0,"div",17)(21,Ui,14,2,"table",18),n(),_(22,zi,8,4,"div",19),n()()()()),i&2&&(d(3),p("formGroup",t.form),d(9),p("disabled",t.loading),d(),w(t.loading?"Saving...":"Add"),d(7),p("ngIf",t.loading),d(),p("ngIf",!t.loading),d(),p("ngIf",t.paginatedEntries.length>0))},dependencies:[ie,W,fe,j,H,me,Xt,he,ge]})}return l})();var Et=Ye(Ge());var Fo={headers:new de({"Content-Type":"application/json"})},pi=(()=>{class l{http;constructor(e){this.http=e}createSupplierForm(e){return this.http.post(R.URI+"/api/supplierForm/create",e)}getSupplierForms(e=0,i=1e3,t){let a=R.URI+`/api/supplierForm/get?start=${e}&count=${i}`;return t!==void 0&&(a+=`&draft=${t}`),this.http.get(a)}getSupplierFormsByStatus(e=0,i=100){return this.http.get(R.URI+`/api/supplierForm/get?status=PUBLISHED&start=${e}&count=${i}`)}getSupplierFormById(e){return this.http.get(R.URI+"/api/supplierForm/"+e)}updateSupplierForm(e,i){return this.http.put(R.URI+"/api/supplierForm/update/"+e,i)}deleteSupplierForm(e){return this.http.delete(R.URI+"/api/supplierForm/delete/"+e)}publishSupplierForms(e){return this.http.post(R.URI+"/api/supplierForm/publish",e)}createRequestFormForApproval(e){return this.http.post(R.URI+"/api/requestform/create",e)}submitForApproval(e,i={}){return this.http.post(R.URI+"/api/supplierForm/submitForApproval/"+e,i)}checkDuplicateEntry(e,i,t,a){let s=R.URI+"/api/supplierForm/exists?supplierId="+encodeURIComponent(e||"")+"&billNo="+encodeURIComponent(i!=null?String(i):"")+"&amount="+encodeURIComponent(String(t??0));return a&&(s+="&excludeId="+encodeURIComponent(a)),this.http.get(s)}getRequestForms(e){let i=R.URI+"/api/requestform/get?requestType=SUPPLIER&order=des";return e&&(i+="&status="+e),this.http.get(i)}getPendingRequestForms(){return this.http.get(R.URI+"/api/requestform/get?requestType=SUPPLIER&status=PENDING&order=des")}getApprovedRequestForms(e=0,i=100,t){let a=R.URI+"/api/requestform/approvedPaymentForms?requestType=SUPPLIER&start="+e+"&count="+i;return t?.from!=null&&(a+="&from="+t.from),t?.to!=null&&(a+="&to="+t.to),t?.chequeOnly&&(a+="&chequeOnly=true"),t?.nameSearch&&t.n
1ameSearch.trim()&&(a+="&nameSearch="+encodeURIComponent(t.nameSearch.trim())),this.http.get(a)}getPreApprovedRequestForms(){return this.http.get(R.URI+"/api/requestform/get?requestType=SUPPLIER&approvalType=PRE_APPROVED&order=des")}static \u0275fac=function(i){return new(i||l)(Z(pe))};static \u0275prov=oe({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var Po={headers:new de({"Content-Type":"application/json"})},Be=(()=>{class l{http;cookieService;supplierFormProvider;constructor(e,i,t){this.http=e,this.cookieService=i,this.supplierFormProvider=t}createSupplierForm(e){return new Promise((i,t)=>{this.supplierFormProvider.createSupplierForm(e).subscribe(a=>{i(a)},a=>{console.error("Error creating supplier form:",a),t(a)})})}getSupplierForms(e=0,i=1e3,t){return new Promise((a,s)=>{this.supplierFormProvider.getSupplierForms(e,i,t).subscribe(m=>{a(m)},m=>{console.error("Error fetching supplier forms:",m),s(m)})})}getSupplierFormsByStatus(e=0,i=100){return new Promise((t,a)=>{this.supplierFormProvider.getSupplierFormsByStatus(e,i).subscribe(s=>{t(s)},s=>{console.error("Error fetching supplier forms by status:",s),a(s)})})}getSupplierFormById(e){return new Promise((i,t)=>{this.supplierFormProvider.getSupplierFormById(e).subscribe(a=>{i(a)},a=>{console.error("Error fetching supplier form by ID:",a),t(a)})})}updateSupplierForm(e,i){return new Promise((t,a)=>{this.supplierFormProvider.updateSupplierForm(e,i).subscribe(s=>{t(s)},s=>{console.error("Error updating supplier form:",s),a(s)})})}deleteSupplierForm(e){return new Promise((i,t)=>{this.supplierFormProvider.deleteSupplierForm(e).subscribe(a=>{i(a)},a=>{console.error("Error deleting supplier form:",a),t(a)})})}publishSupplierForms(e){return new Promise((i,t)=>{this.supplierFormProvider.publishSupplierForms(e).subscribe(a=>{i(a)},a=>{console.error("Error publishing supplier forms:",a),t(a)})})}createRequestFormForApproval(e){return new Promise((i,t)=>{this.supplierFormProvider.createRequestFormForApproval(e).subscribe(a=>{i(a)},a=>{console.error("Error creating request form for approval:",a),t(a)})})}submitForApproval(e,i={}){return new Promise((t,a)=>{this.supplierFormProvider.submitForApproval(e,i).subscribe(s=>{t(s)},s=>{console.error("Error submitting supplier form for approval:",s),a(s)})})}getRequestForms(e){return new Promise((i,t)=>{this.supplierFormProvider.getRequestForms(e).subscribe(a=>{i(a)},a=>{console.error("Error fetching request forms:",a),t(a)})})}getPendingRequestForms(){return new Promise((e,i)=>{this.supplierFormProvider.getPendingRequestForms().subscribe(t=>{e(t)},t=>{console.error("Error fetching pending request forms:",t),i(t)})})}getApprovedRequestForms(e=0,i=100,t){return new Promise((a,s)=>{this.supplierFormProvider.getApprovedRequestForms(e,i,t).subscribe(m=>{a(m)},m=>{console.error("Error fetching approved request forms:",m),s(m)})})}getPreApprovedRequestForms(){return new Promise((e,i)=>{this.supplierFormProvider.getPreApprovedRequestForms().subscribe(t=>{e(t)},t=>{console.error("Error fetching pre-approved request forms:",t),i(t)})})}checkBillNoExists(e){return new Promise((i,t)=>{this.getSupplierForms(0,1e3).then(a=>{let s=a.some(m=>m.billNo&&m.billNo.toString().trim().toLowerCase()===e.toString().trim().toLowerCase());i(s)}).catch(a=>{t(a)})})}checkSupplierIdWithBillNoExists(e,i){return this.checkSupplierDuplicateEntry(e,i,void 0)}checkSupplierDuplicateEntry(e,i,t,a){let s=t!=null?Number(t):0;return new Promise((m,u)=>{this.supplierFormProvider.checkDuplicateEntry(e,i,s,a).subscribe(h=>{m(!!(h&&h.exists))},h=>{console.error("Error checking supplier duplicate entry:",h),u(h)})})}static \u0275fac=function(i){return new(i||l)(Z(pe),Z(Qe),Z(pi))};static \u0275prov=oe({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var Io={headers:new de({"Content-Type":"application/json"})},St=(()=>{class l{http;cookieService;supplierFormConfigProvider;constructor(e,i,t){this.http=e,this.cookieService=i,this.supplierFormConfigProvider=t}createSupplierFormConfig(e){return new Promise((i,t)=>{this.supplierFormConfigProvider.createSupplierFormConfig(e).subscribe(a=>{i(a)},a=>{console.error("Error creating supplier form config:",a),t(a)})})}getSupplierFormConfigs(){return new Promise((e,i)=>{this.supplierFormConfigProvider.getSupplierFormConfigs(0,50).subscribe(t=>{e(t)},t=>{console.error("Error fetching supplier form configs:",t),i(t)})})}searchSupplierFormConfigs(e){return new Promise((i,t)=>{let a=e?`supplierName eq ${e}`:"";this.supplierFormConfigProvider.getSupplierFormConfigs(0,50,a).subscribe(s=>{i(s)},s=>{console.error("Error searching supplier form configs:",s),t(s)})})}updateSupplierFormConfig(e,i){return new Promise((t,a)=>{this.supplierFormConfigProvider.updateSupplierFormConfig(e,i).subscribe(s=>{t(s)},s=>{console.error("Error updating supplier form config:",s),a(s)})})}deleteSupplierFormConfig(e){return new Promise((i,t)=>{this.supplierFormConfigProvider.deleteSupplierFormConfig(e).subscribe(a=>{i(a)},a=>{console.error("Error deleting supplier form config:",a),t(a)})})}isValidSupplierId(e){return new Promise((i,t)=>{this.supplierFormConfigProvider.getSupplierFormConfigById(e).subscribe(a=>{let s=a&&(a._id===e||a.id===e);i(s)},a=>{console.error("Error validating supplier ID:",a),i(!1)})})}static \u0275fac=function(i){return new(i||l)(Z(pe),Z(Qe),Z(vt))};static \u0275prov=oe({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var $e=l=>({"is-invalid":l});function Gi(l,f){l&1&&(r(0,"div",73),o(1," Supplier Name is required. "),n())}function Wi(l,f){l&1&&(r(0,"div",73),o(1," Invoice Date is required. "),n())}function ji(l,f){l&1&&(r(0,"div",73),o(1," Particulars are required and must be at least 5 characters. "),n())}function Hi(l,f){l&1&&(r(0,"div",73),o(1," Bill Value is required and must be positive. "),n())}function Zi(l,f){l&1&&(r(0,"div",73),o(1," Bill Value GST is required and must be positive. "),n())}function Qi(l,f){l&1&&(r(0,"div",73),o(1," TDS is required and must be positive. "),n())}function Ki(l,f){l&1&&(r(0,"div",73),o(1," Amount is required and must be positive. "),n())}function Xi(l,f){l&1&&(r(0,"div",73),o(1," Advance Amount is required and must be positive. "),n())}function Ji(l,f){if(l&1&&(r(0,"div",74),c(1,"i",75),o(2),n()),l&2){let e=g(2);d(2),w(e.submitError)}}function en(l,f){if(l&1){let e=I();r(0,"form",38),b("ngSubmit",function(){x(e);let t=g();return S(t.onSubmit())}),r(1,"div",39)(2,"div",40)(3,"label",41),o(4,"Supplier Name:"),n(),r(5,"div"),c(6,"ng-select",42),r(7,"a",43),c(8,"i",44),n()(),r(9,"small",45),c(10,"i",46),o(11,"Click the + button to add new suppliers "),n(),_(12,Gi,2,0,"div",47),n(),r(13,"div",40)(14,"label",48),o(15,"Bill No / Invoice No :"),n(),c(16,"input",49),n()(),r(17,"div",39)(18,"div",40)(19,"label",50),o(20,"Invoice Date"),n(),c(21,"input",51),_(22,Wi,2,0,"div",47),n(),r(23,"div",40)(24,"label",52),o(25,"Particulars"),n(),c(26,"textarea",53),_(27,ji,2,0,"div",47),n()(),r(28,"div",39)(29,"div",54)(30,"label",55),o(31,"Bill Value (\u20B9)"),n(),c(32,"input",56),_(33,Hi,2,0,"div",47),n(),r(34,"div",54)(35,"label",57),o(36,"Bill Value Before GST (\u20B9)"),n(),c(37,"input",58),_(38,Zi,2,0,"div",47),n(),r(39,"div",54)(40,"label",59),o(41,"TDS (%)"),n(),c(42,"input",60),_(43,Qi,2,0,"div",47),n()(),r(44,"div",39)(45,"div",54)(46,"label",61),o(47,"TDS Amount (\u20B9)"),n(),c(48,"input",62),n(),r(49,"div",54)(50,"label",63),o(51,"Amount (\u20B9)"),n(),c(52,"input",64),_(53,Ki,2,0,"div",47),n(),r(54,"div",54)(55,"label",65),o(56,"Advance Amount (\u20B9)"),n(),c(57,"input",66),_(58,Xi,2,0,"div",47),n()(),r(59,"div",39)(60,"div",54)(61,"label",67),o(62,"Cheque Amou
1nt (\u20B9)"),n(),c(63,"input",68),n()(),r(64,"div",69)(65,"button",70),c(66,"i",71),o(67,"Continue "),n(),_(68,Ji,3,1,"div",72),n()()}if(l&2){let e,i,t,a,s,m,u,h,v,E,y,F,k,V,Y,O,C=g();p("formGroup",C.supplierForm),d(6),p("items",C.supplierConfigs)("typeahead",C.supplierSearch$)("minTermLength",2)("loading",C.loadingConfigs)("ngClass",$(24,$e,((e=C.supplierForm.get("supplierId"))==null?null:e.invalid)&&((e=C.supplierForm.get("supplierId"))==null?null:e.touched))),d(6),p("ngIf",((i=C.supplierForm.get("supplierId"))==null?null:i.invalid)&&((i=C.supplierForm.get("supplierId"))==null?null:i.touched)),d(9),p("bsConfig",C.bsConfig)("ngClass",$(26,$e,((t=C.supplierForm.get("date"))==null?null:t.invalid)&&((t=C.supplierForm.get("date"))==null?null:t.touched))),d(),p("ngIf",((a=C.supplierForm.get("date"))==null?null:a.invalid)&&((a=C.supplierForm.get("date"))==null?null:a.touched)),d(4),p("ngClass",$(28,$e,((s=C.supplierForm.get("particulars"))==null?null:s.invalid)&&((s=C.supplierForm.get("particulars"))==null?null:s.touched))),d(),p("ngIf",((m=C.supplierForm.get("particulars"))==null?null:m.invalid)&&((m=C.supplierForm.get("particulars"))==null?null:m.touched)),d(5),p("ngClass",$(30,$e,((u=C.supplierForm.get("billValue"))==null?null:u.invalid)&&((u=C.supplierForm.get("billValue"))==null?null:u.touched))),d(),p("ngIf",((h=C.supplierForm.get("billValue"))==null?null:h.invalid)&&((h=C.supplierForm.get("billValue"))==null?null:h.touched)),d(4),p("ngClass",$(32,$e,((v=C.supplierForm.get("billValueGst"))==null?null:v.invalid)&&((v=C.supplierForm.get("billValueGst"))==null?null:v.touched))),d(),p("ngIf",((E=C.supplierForm.get("billValueGst"))==null?null:E.invalid)&&((E=C.supplierForm.get("billValueGst"))==null?null:E.touched)),d(4),p("ngClass",$(34,$e,((y=C.supplierForm.get("tds"))==null?null:y.invalid)&&((y=C.supplierForm.get("tds"))==null?null:y.touched))),d(),p("ngIf",((F=C.supplierForm.get("tds"))==null?null:F.invalid)&&((F=C.supplierForm.get("tds"))==null?null:F.touched)),d(9),p("ngClass",$(36,$e,((k=C.supplierForm.get("amount"))==null?null:k.invalid)&&((k=C.supplierForm.get("amount"))==null?null:k.touched))),d(),p("ngIf",((V=C.supplierForm.get("amount"))==null?null:V.invalid)&&((V=C.supplierForm.get("amount"))==null?null:V.touched)),d(4),p("ngClass",$(38,$e,((Y=C.supplierForm.get("advance"))==null?null:Y.invalid)&&((Y=C.supplierForm.get("advance"))==null?null:Y.touched))),d(),p("ngIf",((O=C.supplierForm.get("advance"))==null?null:O.invalid)&&((O=C.supplierForm.get("advance"))==null?null:O.touched)),d(7),p("disabled",C.supplierForm.invali
1d||C.submitting),d(3),p("ngIf",C.submitError)}}function tn(l,f){l&1&&c(0,"span",95)}function nn(l,f){l&1&&c(0,"span",95)}function rn(l,f){l&1&&c(0,"span",95)}function an(l,f){l&1&&c(0,"span",95)}function on(l,f){if(l&1){let e=I();r(0,"div",76)(1,"div",77),c(2,"i",78),r(3,"strong"),o(4,"Form validated successfully!"),n(),o(5," Please choose what you would like to do next: "),n(),r(6,"div",79)(7,"div",80)(8,"div",81)(9,"div",82),c(10,"i",83),r(11,"h5",84),o(12,"Save as Draft"),n(),r(13,"p",85),o(14,"Save this form as a draft for later editing and review."),n(),r(15,"button",86),b("click",function(){x(e);let t=g();return S(t.saveAsDraft())}),_(16,tn,1,0,"span",17),c(17,"i",18),o(18,"Save as Draft "),n()()()(),r(19,"div",80)(20,"div",87)(21,"div",82),c(22,"i",88),r(23,"h5",84),o(24,"Send to Approval"),n(),r(25,"p",85),o(26,"Submit this form for approval workflow. It will be sent to approvers."),n(),r(27,"button",89),b("click",function(){x(e);let t=g();return S(t.sendToApproval())}),_(28,nn,1,0,"span",17),c(29,"i",26),o(30,"Send to Approval "),n()()()(),r(31,"div",80)(32,"div",90)(33,"div",82),c(34,"i",36),r(35,"h5",84),o(36,"Pre-Approved"),n(),r(37,"p",85),o(38,"Paper verified; final e-sign and cheque issuance in system."),n(),r(39,"button",91),b("click",function(){x(e);let t=g();return S(t.sendToPreApproval())}),_(40,rn,1,0,"span",17),c(41,"i",37),o(42,"Pre-Approved "),n()()()(),r(43,"div",80)(44,"div",92)(45,"div",82),c(46,"i",31),r(47,"h5",84),o(48,"Without Cheque"),n(),r(49,"p",85),o(50,"Cash, transfer, or adjustment \u2014 final e-sign only; no cheque."),n(),r(51,"button",93),b("click",function(){x(e);let t=g();return S(t.sendToWithoutCheque())}),_(52,an,1,0,"span",17),c(53,"i",94),o(54,"Without Cheque "),n()()()()()()}if(l&2){let e=g();d(15),p("disabled",e.draftSubmitting),d(),p("ngIf",e.draftSubmitting),d(11),p("disabled",e.approvalSubmitting),d(),p("ngIf",e.approvalSubmitting),d(11),p("disabled",e.preApprovalSubmitting),d(),p("ngIf",e.preApprovalSubmitting),d(11),p("disabled",e.withoutChequeSubmitting),d(),p("ngIf",e.withoutChequeSubmitting)}}function ln(l,f){l&1&&c(0,"span",95)}function sn(l,f){l&1&&c(0,"span",95)}function dn(l,f){l&1&&c(0,"span",95)}function pn(l,f){l&1&&c(0,"span",95)}var Ct=Et.default??Et,yt=(()=>{class l{fb;supplierFormService;supplierConfigService;router;toastr;validationService;bsLocaleService;errorHandler;supplierForm;submitting=!1;draftSubmitting=!1;approvalSubmitting=!1;preApprovalSubmitting=!1;withoutChequeSubmitting=!1;submitSuccess=!1;submitError="";showOptions=!1;formData=null;supplierConfigs=[];loadingConfigs=!1;supplierSearch$=new Lt;subscriptions=new qt;bsConfig={dateInputFormat:"DD/MM/YYYY",containerClass:"theme-default",showWeekNumbers:!1};constructor(e,i,t,a,s,m,u,h){this.fb=e,this.supplierFormService=i,this.supplierConfigService=t,this.router=a,this.toastr=s,this.validationService=m,this.bsLocaleService=u,this.errorHandler=h,this.supplierForm=this.fb.group({supplierId:["",P.required],billNo:[""],date:["",P.required],particulars:["",[P.required,P.minLength(5)]],billValue:[,[P.required,this.validationService.numericRangeValidator(0,Number.MAX_SAFE_INTEGER)]],billValueGst:[,[P.required,this.validationService.numericRangeValidator(0,Number.MAX_SAFE_INTEGER)]],tds:["",[P.required,P.min(0),P.max(100)]],tdsAmount:[,[P.required,this.validationService.numericRangeValidator(0,Number.MAX_SAFE_INTEGER)]],amount:[,[P.required,this.validationService.numericRangeValidator(0,Number.MAX_SAFE_INTEGER)]],chequeAmount:[,[P.required,this.validationService.numericRangeValidator(0,Number.MAX_SAFE_INTEGER)]],advance:[0,[P.required,this.validationService.numericRangeValidator(0,Number.MAX_SAFE_INTEGER)]]}),["tdsAmount","amount","chequeAmount"].forEach(v=>{this.supplierForm.get(v)?.disable({emitEvent:!1})})}mapSupplierConfigs(e){return(e||[]).map(i=>N(T({},i),{id:i.id??i._id}))}ngOnInit(){Ct.locale("en-GB"),ve("en-gb",xe),this.bsLocaleService.use("en-gb"),this.loadSupplierConfigs(),this.subscriptions.add(this.supplierSearch$.pipe($t(300),Ut(),it(e=>!!e&&e.trim().length>0),zt(e=>(this.loadingConfigs=!0,Bt(this.supplierConfigService.searchSupplierFormConfigs(e))))).subscribe({next:e=>{let i=Array.isArray(e?.data)?e.data:Array.isArray(e)?e:[];this.supplierConfigs=this.mapSupplierConfigs(i),this.loadingConfigs=!1},error:()=>{this.loadingConfigs=!1}}
1)),["tds","billValueGst","billValue","advance"].forEach(e=>{this.subscriptions.add(this.supplierForm.get(e).valueChanges.subscribe(()=>this.updateCalculatedFields()))})}ngOnDestroy(){this.subscriptions.unsubscribe()}loadSupplierConfigs(){this.loadingConfigs=!0,this.supplierConfigService.getSupplierFormConfigs().then(e=>{let i=Array.isArray(e?.data)?e.data:Array.isArray(e)?e:[];this.supplierConfigs=this.mapSupplierConfigs(i),this.loadingConfigs=!1}).catch(()=>{this.supplierConfigs=[],this.loadingConfigs=!1})}getSupplierNameById(e){let i=this.supplierConfigs.find(t=>t._id===e||t.id===e);return i?i.supplierName:"Unknown Supplier"}updateCalculatedFields(){let e=this.supplierForm.get("tds")?.value,i=this.supplierForm.get("billValueGst")?.value,t=this.supplierForm.get("tdsAmount")?.value,a=this.supplierForm.get("billValue")?.value;if(e!=null&&i!=null&&!isNaN(e)&&!isNaN(i)&&(t=Math.round(parseFloat(e)/100*parseFloat(i)),this.supplierForm.get("tdsAmount")?.setValue(t,{emitEvent:!1})),a!=null&&t!=null&&!isNaN(a)&&!isNaN(t)){let h=Math.round(parseFloat(a)-parseFloat(t));this.supplierForm.get("amount")?.setValue(h,{emitEvent:!1})}let s=this.supplierForm.get("advance")?.value,m=this.supplierForm.get("amount")?.value,u=null;m!=null&&!isNaN(m)&&(s!=null&&!isNaN(s)&&s>0?u=Math.round(m-parseFloat(s)):u=m,this.supplierForm.get("chequeAmount")?.setValue(u,{emitEvent:!1}))}resetLoadingStates(){this.submitting=!1,this.draftSubmitting=!1,this.approvalSubmitting=!1}closeModal(e){let i=document.getElementById(e);if(i){i.classList.add("fade"),new window.bootstrap.Modal(i).hide();let a=document.querySelector(".modal-backdrop");a&&(a.classList.add("fade"),setTimeout(()=>a.remove(),150)),setTimeout(()=>{document.body.classList.remove("modal-open"),document.body.style.paddingRight="",document.body.style.overflow="",document.body.style.position="",document.body.style.top=""},150)}}cleanupAfterNavigation(){document.querySelectorAll(".modal-backdrop").forEach(i=>i.remove()),document.body.classList.remove("modal-open"),document.body.style.paddingRight="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",window.scrollTo(0,0),document.documentElement.style.overflow="",document.body.style.overflow=""}
1onSubmit(){if(this.supplierForm.invalid){this.supplierForm.markAllAsTouched(),this.toastr.error("Please fill in all required fields correctly.","Validation Error");return}let e=this.supplierForm.get("billNo")?.value,i=this.supplierForm.get("supplierId")?.value;if(!i){this.toastr.error("Please select a supplier from the dropdown.","Validation Error");return}this.supplierConfigService.isValidSupplierId(i).then(t=>{if(!t)return this.toastr.error("Invalid supplier selected. Please select a valid supplier from the dropdown.","Validation Error"),null;let a=this.supplierForm.getRawValue()?.amount,s=parseInt(a,10)||0;return this.supplierFormService.checkSupplierDuplicateEntry(i,e||"",s)}).then(t=>{if(t===null)return;if(t){this.toastr.warning("A form with the same supplier, bill no, and amount already exists.","Duplicate Entry",{timeOut:4e3,progressBar:!0});return}let a=this.supplierForm.getRawValue(),s=a.date;if(a.date instanceof Date)s=Ct(a.date).format("YYYY-MM-DD");else if(a.date&&typeof a.date=="string"){let m=Ct(a.date,"DD/MM/YYYY");m.isValid()&&(s=m.format("YYYY-MM-DD"))}this.formData=N(T({},a),{supplierId:i,date:s,billValue:parseInt(a.billValue)||0,billValueGst:parseInt(a.billValueGst)||0,tds:parseFloat(a.tds)||0,tdsAmount:parseInt(a.tdsAmount)||0,amount:parseInt(a.amount)||0,chequeAmount:parseInt(a.chequeAmount)||0,advance:parseInt(a.advance)||0}),this.submitError="",this.resetLoadingStates(),this.showOptions=!0,this.toastr.success("Form validated successfully!","Success",{timeOut:2e3,progressBar:!0}),setTimeout(()=>{let m=document.querySelector(".options-section");m&&m.scrollIntoView({behavior:"smooth",block:"start"})},300)}).catch(()=>{this.toastr.error("An error occurred during validation. Please try again.","Validation Error")})}saveAsDraft(){if(!this.formData){this.toastr.error("No form data available.","Error",{timeOut:4e3,progressBar:!0});return}new window.bootstrap.Modal(document.getElementById("draftModal")).show()}confirmSaveAsDraft(){this.draftSubmitting=!0;let e=N(T({},this.formData),{draft:!0});this.supplierFormService.createSupplierForm(e).then(i=>{this.closeModal("draftModal"),this.toastr.success("Form saved as draft successfully!","Success",{timeOut:1500,progressBar:!0}),setTimeout(()=>{this.showOptions=!1,this.supplierForm.reset(),this.formData=null,this.router.navigate(["supplier/drafts/supplier"]),setTimeout(()=>{this.cleanupAfterNavigation()},50)},800)}).catch(i=>{this.toastr.error(this.errorHandler.getErrorMessage(i,"Failed to save as draft."),"Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.draftSubmitting=!1})}sendToApproval(){if(!this.formData){this.toastr.error("No form data available.","Error",{timeOut:4e3,progressBar:!0});return}new window.bootstrap.Modal(document.getElementById("approvalModal")).show()}confirmSendToApproval(){this.approvalSubmitting=!0;let e=N(T({},this.formData),{draft:!1,approvalType:"NONE"});this.supplierFormService.createSupplierForm(e).then(i=>{let t=i._id||i.id||"",a={approvalType:"NONE",draft:!1};return this.supplierFormService.submitForApproval(t,a)}).then(()=>{this.closeModal("approvalModal"),this.toastr.success("Form sent for approval successfully!","Success",{timeOut:1500,progressBar:!0}),setTimeout(()=>{this.showOptions=!1,this.supplierForm.reset(),this.formData=null,this.router.navigate(["supplier/publish/supplier"]),setTimeout(()=>{this.cleanupAfterNavigation()},50)},800)}).catch(i=>{this.toastr.error(this.errorHandler.getErrorMessage(i,"Failed to send for approval."),"Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.approvalSubmitting=!1})}sendToPreApproval(){if(!this.formData){this.toastr.error("No form data available.","Error",{timeOut:4e3,progressBar:!0});return}new window.bootstrap.Modal(document.getElementById("supplierConfirmPreApprovalModal")).show()}confirmSendToPreApproval(){this.preApprovalSubmitting=!0;let e=N(T({},this.formData),{draft:!1,approvalType:"PRE_APPROVED"});this.supplierFormService.createSupplierForm(e).then(i=>{let t=i._id||i.id||"",a={approvalType:"PRE_APPROVED",draft:!1};return this.supplierFormService.submitForApproval(t,a)}).then(()=>{this.closeModal("supplierConfirmPreApprovalModal"),this.toastr.success("Form pre-approved and published successfully!","Success",{timeOut:1500,progressBar:!0}),setTimeout(()=>{this.showOptions=!1,this.supplierForm.reset(),this.formData=null,this.router.navigate(["supplier/publish/supplier"]),this.cleanupAfterNavigation()},800)}).catch(i=>{this.toastr.error(this.errorHandler.getErrorMessage(i,"Failed to pre-approve form."),"Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.preApprovalSubmitting=!1})}sendToWithoutCheque(){if(!this.formData){this.toastr.error("No form data available.","Error",{timeOut:4e3,progressBar:!0});return}new window.bootstrap.Modal(document.getElementById("supplierConfirmWithoutChequeModal")).show()}confirmSendToWithoutCheque(){this.withoutChequeSubmitting=!0;let e=N(T({},this.formData),{draft:!1,approvalType:"WITHOUT_CHEQUE"});delete e.chequeNo,this.supplierFormService.createSupplierForm(e).then(i=>{let t=i._id||i.id||"",a={approvalType:"WITHOUT_CHEQUE",draft:!1};return this.supplierFormService.submitForApproval(t,a)}).then(()=>{this.closeModal("supplierConfirmWithoutChequeModal"),this.toastr.success("Form submitted for approval (without cheque).","Success",{timeOut:1500,progressBar:!0}),setTimeout(()=>{this.showOptions=!1,this.supplierForm.reset(),this.formData=null,this.router.navigate(["supplier/publish/supplier"]),this.cleanupAfterNavigation()},800)}).catch(i=>{this.toastr.error(this.errorHandler.getErrorMessage(i,"Failed to submit without-cheque form."),"Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.withoutChequeSubmitting=!1})}static \u0275fac=function(i){return new(i||l)(D(be),D(Be),D(St),D(ne),D(K),D(li),D(Se),D(gt))};static \u0275cmp=q({type:l,selectors:[["app-supplier-form"]],decls:88,vars:10,consts:[[3,"formGroup","ngSubmit",4,"ngIf"],["class","options-section animate__animated animate__fadeIn mt-4",4,"ngIf"],["id","draftModal","tabindex","-1","aria-labelledby","draftModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-dialog","modal
1-dialog-centered"],[1,"modal-content"],[1,"modal-header","bg-success","text-white"],["id","draftModalLabel",1,"modal-title"],[1,"fa","fa-file-text","me-2"],["type","button","data-bs-dismiss","modal","aria-label","Close",1,"btn-close","btn-close-white"],[1,"modal-body","text-center"],[1,"fa","fa-check-circle","text-success",2,"font-size","3rem"],[1,"mt-3"],[1,"text-muted","mb-0"],[1,"modal-footer"],["type","button","data-bs-dismiss","modal",1,"btn","btn-secondary"],[1,"fa","fa-x-circle","me-1"],["type","button",1,"btn","btn-success",3,"click","disabled"],["class","spinner-border spinner-border-sm me-2",4,"ngIf"],[1,"fa","fa-save","me-1"],["id","approvalModal","tabindex","-1","aria-labelledby","approvalModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-warning","text-dark"],["id","approvalModalLabel",1,"modal-title"],[1,"fa","fa-exclamation-triangle","me-2"],["type","button","data-bs-dismiss","modal","aria-label","Close",1,"btn-close"],[1,"fa","fa-send-check","text-warning",2,"font-size","3rem"],["type","button",1,"btn","btn-warning",3,"click","disabled"],[1,"fa","fa-send","me-1"],["id","supplierConfirmWithoutChequeModal","tabindex","-1","aria-labelledby","supplierConfirmWithoutChequeModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-secondary","text-white"],["id","supplierConfirmWithoutChequeModalLabel",1,"modal-title"],[1,"fa","fa-ban","me-2"],[1,"fa","fa-money","text-secondary",2,"font-size","3rem"],["type","button",1,"btn","btn-secondary",3,"click","disabled"],["id","supplierConfirmPreApprovalModal","tabindex","-1","aria-labelledby","supplierConfirmPreApprovalModalLabel","aria-hidden","true",1,"modal","fade"],["id","supplierConfirmPreApprovalModalLabel",1,"modal-title"],[1,"fa","fa-check-circle","me-2"],[1,"fa","fa-check-circle","text-warning",2,"font-size","3rem"],[1,"fa","fa-check","me-1"],[3,"ngSubmit","formGroup"],[1,"row"],[1,"col-md-6"],["for","supplierId",1,"form-label"],["id","supplierId","formControlName","supplierId","bindLabel","supplierName","bindValue","id","placeholder","Search supplier...",3,"items","typeahead","minTermLength","loading","ngClass"],["routerLink","../../config","title","Add new supplier",1,"btn","btn-outline-primary","btn-sm"],[1,"fa","fa-plus"],[1,"text-muted"],[1,"fa","fa-info-circle","me-1"],["class","invalid-feedback",4,"ngIf"],["for","billNo",1,"form-label"],["id","billNo","type","text","formControlName","billNo","placeholder","Enter Bill Value / Invoice No",1,"form-control"],["for","date",1,"form-label"],["id","date","type","text","formControlName","date","bsDatepicker","","placeholder","DD/MM/YYYY","required","",1,"form-control",3,"bsConfig","ngClass"],["for","particulars",1,"form-label"],["id","particulars","formControlName","particulars","required","",1,"form-control",3,"ngClass"],[1,"col-md-4"],["for","billValue",1,"form-label"],["id","billValue","type","number","formControlName","billValue","min","0","step","1","placeholder","Enter Bill Value","required","",1,"form-control",3,"ngClass"],["for","billValueGst",1,"form-label"],["id","billValueGst","type","number","formControlName","billValueGst","min","0","step","1","placeholder","Enter Bill Value Before GST","required","",1,"form-control",3,"ngClass"],["for","tds",1,"form-label"],["id","tds","type","number","formControlName","tds","min","0","step","0.1","placeholder","Enter TDS (%)","required","",1,"form-control",3,"ngClass"],["for","tdsAmount",1,"form-label"],["id","tdsAmount","type","number","formControlName","tdsAmount","min","0","step","1","placeholder","Enter TDS Amount","readonly","","tabindex","-1",1,"form-control"],["for","amount",1,"form-label"],["id","amount","type","number","formControlName","amount","min","0","step","1","placeholder","Enter Amount","readonly","","tabindex","-1",1,"form-control",3,"ngClass"],["for","advance",1,"form-label"],["id","advance","type","number","formControlName","advance","min","0","step","1","required","",1,"form-control",3,"ngClass"],["for","chequeAmount",1,"form-label"],["id","chequeAmount","type","number","formControlName","chequeAmount","min","0","step","1","placeholder","Enter Cheque Amou
1nt","readonly","","tabindex","-1",1,"form-control"],[1,"mt-4","d-flex","align-items-center","gap-3"],["type","submit",1,"btn","btn-primary","px-4",3,"disabled"],[1,"fa","fa-check-circle","me-1"],["class","alert alert-danger mb-0 py-1 px-3 animate__animated animate__fadeIn",4,"ngIf"],[1,"invalid-feedback"],[1,"alert","alert-danger","mb-0","py-1","px-3","animate__animated","animate__fadeIn"],[1,"fa","fa-exclamation-triangle-o","me-1"],[1,"options-section","animate__animated","animate__fadeIn","mt-4"],[1,"alert","alert-info","mb-4"],[1,"fa","fa-info-circle","me-2"],[1,"row","g-4"],[1,"col-md-3"],[1,"card","h-100","border-success"],[1,"card-body","text-center"],[1,"fa","fa-file-text-o","text-success",2,"font-size","3rem"],[1,"card-title","mt-3"],[1,"card-text"],[1,"btn","btn-outline-success",3,"click","disabled"],[1,"card","h-100","border-primary"],[1,"fa","fa-paper-plane","text-primary",2,"font-size","3rem"],[1,"btn","btn-outline-primary",3,"click","disabled"],[1,"card","h-100","border-warning"],[1,"btn","btn-outline-warning",3,"click","disabled"],[1,"card","h-100","border-secondary"],[1,"btn","btn-outline-secondary",3,"click","disabled"],[1,"fa","fa-ban","me-1"],[1,"spinner-border","spinner-border-sm","me-2"]],template:function(i,t){i&1&&(_(0,en,69,40,"form",0)(1,on,55,8,"div",1),r(2,"div",2)(3,"div",3)(4,"div",4)(5,"div",5)(6,"h5",6),c(7,"i",7),o(8,"Save as Draft "),n(),c(9,"button",8),n(),r(10,"div",9),c(11,"i",10),r(12,"h6",11),o(13,"Save this form as draft?"),n(),r(14,"p",12),o(15,"You can edit and delete it later from the Drafts tab."),n()(),r(16,"div",13)(17,"button",14),c(18,"i",15),o(19,"Cancel "),n(),r(20,"button",16),b("click",function(){return t.confirmSaveAsDraft()}),_(21,ln,1,0,"span",17),c(22,"i",18),o(23,"Save Draft "),n()()()()(),r(24,"div",19)(25,"div",3)(26,"div",4)(27,"div",20)(28,"h5",21),c(29,"i",22),o(30,"Send for Approval "),n(),c(31,"button",23),n(),r(32,"div",9),c(33,"i",24),r(34,"h6",11),o(35,"Send this form for approval?"),n(),r(36,"p",12),o(37,"Once approved, you cannot edit or delete it."),n()(),r(38,"div",13)(39,"button",14),c(40,"i",15),o(41,"Cancel "),n(),r(42,"button",25),b("click",function(){return t.confirmSendToApproval()}),_(43,sn,1,0,"span",17),c(44,"i",26),o(45,"Send for Approval "),n()()()()(),r(46,"div",27)(47,"div",3)(48,"div",4)(49,"div",28)(50,"h5",29),c(51,"i",30),o(52,"Without Cheque "),n(),c(53,"button",8),n(),r(54,"div",9),c(55,"i",31),r(56,"h6",11),o(57,"Submit without cheque?"),n(),r(58,"p",12),o(59,"No cheque will be issued. Approvers will complete final e-sign only."),n()(),r(60,"div",13)(61,"button",14),o(62,"Cancel"),n(),r(63,"button",32),b("click",function(){return t.confirmSendToWithoutCheque()}),_(64,dn,1,0,"span",17),o(65," Submit "),n()()()()(),r(66,"div",33)(67,"div",3)(68,"div",4)(69,"div",20)(70,"h5",34),c(71,"i",35),o(72,"Pre-Approval "),n(),c(73,"button",23),n(),r(74,"div",9),c(75,"i",36),r(76,"h6",11),o(77,"Pre-approve and publish this form?"),n(),r(78,"p",12),o(79,"This will bypass the approval workflow and mark as pre-approved."),n()(),r(80,"div",13)(81,"button",14),c(82,"i",15),o(83,"Cancel "),n(),r(84,"button",25),b("click",function(){return t.confirmSendToPreApproval()}),_(85,pn,1,0,"span",17),c(86,"i",37),o(87,"Pre-Approval "),n()()()()()),i&2&&(p("ngIf",!t.showOptions),d(),p("ngIf",t.showOptions),d(19),p("disabled",t.draftSubmitting),d(),p("ngIf",t.draftSubmitting),d(21),p("disabled",t.approvalSubmitting),d(),p("ngIf",t.approvalSubmitting),d(20),p("disabled",t.withoutChequeSubmitting),d(),p("ngIf",t.withoutChequeSubmitting),d(20),p("disabled",t.preApprovalSubmitting),d(),p("ngIf",t.preApprovalSubmitting))},dependencies:[te,W,De,fe,j,Ne,H,me,Ve,Me,he,ge,Oe,Re,ri],styles:[".supplier-form-container[_ngcontent-%COMP%]{max-width:600px;margin:32px auto 0;background:#ffffffd9;border-radius:12px;box-shadow:0 2px 12px #00000014;padding:32px 32px 16px}.supplier-form-container[_ngcontent-%COMP%]   h2[_ngcontent-%COMP%]{margin-bottom:24px;font-size:2rem;text-align:left}.form-grid[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px}.form-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:16px}.form-row[_ngcontent-%COMP%]   label[_ngcontent-%COMP%]{flex:0 0 180px;font-weight:500}.form-label[_ngcontent-%COMP%]{font-weight:500;color:#2c2f32;margin-bottom:.5rem}.form-row[_ngcontent-%COMP%]   input[_ngcontent-%COMP%], .form-row[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{flex:1 1 0;padding:8px;border:1px solid #bdbdbd;border-radius:4px;font-size:1rem}.form-row[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{min-height:60px;resize:vertical}.form-actions[_ngcontent-%COMP%]{justify-content:flex-end}button[type=submit][_ngcontent-%COMP%], .drafts-list-container[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{background:#1976d2;color:#fff;border:none;border-radius:4px;padding:8px 20px;font-size:1rem;cursor:pointer;transition:background .2s}button[type=submit][_ngcontent-%COMP%]:hover, .drafts-list-container[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:hover{background:#125ea2}.drafts-list-container[_ngcontent-%COMP%]{max-width:900px;margin:40px auto;background:#ffffffd9;border-radius:12px;box-shadow:0 2px 12px #00000014;padding:24px 24px 16px}.drafts-list-container[_ngcontent-%COMP%]   h2[_ngcontent-%COMP%]{margin-bottom:16px;font-size:1.5rem}table[_ngcontent-%COMP%]{width:100%;border-collapse:collapse;background:#fff}thead[_ngcontent-%COMP%]   th[_ngcontent-%COMP%]{background:#e3f2fd;font-weight:600;padding:10px 6px}tbody[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]{padding:8px 6px;border-bottom:1px solid #e0e0e0}tr[_ngcontent-%COMP%]:last-child   td[_ngcontent-%COMP%]{border-bottom:none}@media (max-width: 700px){.supplier-form-container[_ngcontent-%COMP%], .drafts-list-container[_ngcontent-%COMP%]{max-width:98vw;padding:10px}.form-row[_ngcontent-%COMP%]   label[_ngcontent-%COMP%]{flex:0 0 110px}}"]})}return l})();var Ft=Ye(Ge());var cn=["editBillValueInput"],mn=["editBillValueGstInput"],un=l=>({"is-invalid":l});function fn(l,f){l&1&&(r(0,"span"),c(1,"i",101),o(2,"Print Selected"),n())}function hn(l,f){l&1&&(r(0,"span"),c(1,"span",102),o(2,"Printing..."),n())}function gn(l,f){l&1&&(r(0,"span"),c(1,"i",103),o(2,"Delete Selected"),n())}function bn(l,f){l&1&&(r(0,"span"),c(1,"span",102),o(2,"Deleting..."),n())}function vn(l,f){l&1&&(r(0,"span"),c(1,"i",104),o(2,"Send for Approval"),n())}function xn(l,f){l&1&&(r(0,"span"),c(1,"span",102),o(2,"Sending..."),n())}function Sn(l,f){l&1&&(r(0,"span"),c(1,"i",105),o(2,"Mark as Pre-Approved"),n())}function _n(l,f){l&1&&(r(0,"span"),c(1,"span",102),o(2,"Processing..."),n())}function wn(l,f){l&1&&(r(0,"span"),c(1,"i",106),o(2,"Without Cheque"),n())}function Cn(l,f){l&1&&(r(0,"span"),c(1,"span",102),o(2,"Processing..."),n())}function En(l,f){if(l&1){let e=I();r(0,"div",93)(1,"div",94)(2,"span",95),o(3),n()(),r(4,"button",96),b("click",function(){x(e);let t=g();return S(t.printSelectedForms())}),_(5,fn,3,0,"span",76)(6,hn,3,0,"span",76),n(),r(7,"button",97),b("click",function(){x(e);let t=g();return S(t.onBulkDelete())}),_(8,gn,3,0,"span",76)(9,bn,3,0,"span",76),n(),r(10,"button",98),b("click",function(){x(e);let t=g();return S(t.onBulkApproval())}),_(11,vn,3,0,"span",76)(12,xn,3,0,"span",76),n(),r(13,"button",99),b("click",function(){x(e);let t=g();return S(t.onBulkPreApproval())}),_(14,Sn,3,0,"span",76)(15,_n,3,0,"span",76),n(),r(16,"button",100),b("click",function(){x(e);let t=g();return S(t.onBulkWithoutCheque())}),_(17,wn,3,0,"span",76)(18,Cn,3,0,"span",76),n()()}if(l&2){let e=g();d(3),A("",e.getSelectedFormsCount()," selected"),d(),p("disabled",e.getSelectedFormsCount()===0||e.printSelectedSubmitting),d(),p("ngIf",!e.printSelectedSubmitting),d(),p("ngIf",e.printSelectedSubmitting),d(),p("disabled",e.getSelectedFormsCount()===0||e.bulkDeleteSubmitting),d(),p("ngIf",!e.bulkDeleteSubmitting),d(),p("ngIf",e.bulkDeleteSubmitting),d(),p("disabled",e.getSelectedFormsCount()===0||e.bulkApprovalSubmitting),d(),p("ngIf",!e.bulkApprovalSubmitting),d(),p("ngIf",e.bulkApprovalSubmitting),d(),p("disabled",e.getSelectedFormsCount()===0||e.bulkPreApprovalSubmitting),d(),p("ngIf",!e.bulkPreApprovalSubmitting),d(),p("ngIf",e.bulkPreApprovalSubmitting),d(),p("disabled",e.getSelectedFormsCount()===0||e.bulkWithoutChequeSubmitting),d(),p("ngIf",!e.bulkWithoutChequeSubmitting),d(),p("ngIf",e.bulkWithoutChequeSubmitting)}}function yn(l,f){l&1&&(r(0,"div",107)(1,"div",108)(2,"span",109),o(3,"Loading..."),n()()())}function Fn(l,f){if(l&1&&(r(0,"div",110),o(1),n()),l&2){let e=g();d(),w(e.error)}}function Dn(l,f){if(l&1){let e=I();r(0,"button",138),b("click",function(){x(e);let t=g().$implicit,a=g(2);return S(a.onEdit(t))}),c(1,"i",139),n()}}function Pn(l,f){l&1&&(r(0,"span",140),o(1,"-"),n())}function An(l,f){if(l&1){let e=I();
1r(0,"tr")(1,"td",129)(2,"input",130),b("change",function(t){let a=x(e).$implicit,s=g(2);return S(s.toggleFormSelection(a,t))}),n()(),r(3,"td",129),o(4),n(),r(5,"td"),o(6),n(),r(7,"td",131),o(8),n(),r(9,"td",131),o(10),L(11,"date"),n(),r(12,"td",129)(13,"button",132),b("click",function(){let t=x(e).$implicit,a=g(2);return S(a.openParticularsModal(t.particulars))}),c(14,"i",133),n()(),r(15,"td",134),o(16),L(17,"number"),n(),r(18,"td",134),o(19),L(20,"number"),n(),r(21,"td",134),o(22),n(),r(23,"td",134),o(24),L(25,"number"),n(),r(26,"td",134),o(27),L(28,"number"),n(),r(29,"td",134),o(30),L(31,"number"),n(),r(32,"td",134),o(33),L(34,"number"),n(),r(35,"td",129)(36,"span",135),o(37),n()(),r(38,"td",129),_(39,Dn,2,0,"button",136)(40,Pn,2,0,"span",137),n()()}if(l&2){let e=f.$implicit,i=f.index,t=g(2);re("table-primary",t.isFormSelected(e)),d(2),p("checked",t.isFormSelected(e)),d(2),w(i+1),d(2),w(e.views.supplierName||"N/A"),d(2),w(e.billNo||"N/A"),d(2),w(B(11,18,e.date,"dd-MM-yyyy")),d(6),w(B(17,21,e.billValue,"1.0-0")),d(3),w(B(20,24,e.billValueGst,"1.0-0")),d(3),w(t.formatTdsDisplay(e.tds)),d(2),w(B(25,27,e.tdsAmount,"1.0-0")),d(3),w(B(28,30,e.amount,"1.0-0")),d(3),w(B(31,33,e.advance,"1.0-0")),d(3),w(B(34,36,e.chequeAmount,"1.0-0")),d(3),p("ngClass",t.getStatusBadgeClass(e)),d(),A(" ",t.getStatusDisplay(e)," "),d(2),p("ngIf",t.canEdit(e)),d(),p("ngIf",!t.canEdit(e))}}function In(l,f){if(l&1){let e=I();r(0,"div",111)(1,"table",112)(2,"thead",113)(3,"tr")(4,"th",114)(5,"input",115),b("change",function(t){x(e);let a=g();return S(a.toggleSelectAll(t))}),n()(),r(6,"th",114),o(7,"#"),n(),r(8,"th",116),o(9,"Supplier Name"),n(),r(10,"th",117),o(11,"Bill No."),n(),r(12,"th",118),o(13,"Date"),n(),r(14,"th",119),o(15,"Particulars"),n(),r(16,"th",120),o(17,"Bill Value"),n(),r(18,"th",120),o(19,"Bill Value Before GST"),n(),r(20,"th",121),o(21,"TDS"),n(),r(22,"th",122),o(23,"TDS Amt"),n(),r(24,"th",122),o(25,"Amount"),n(),r(26,"th",122),o(27,"Advance"),n(),r(28,"th",122),o(29,"Cheque Amt"),n(),r(30,"th",123),o(31,"Status"),n(),r(32,"th",124),o(33,"Actions"),n()()(),r(34,"tbody"),_(35,An,41,39,"tr",125),n()(),r(36,"div",126)(37,"button",127),b("click",function(){x(e);let t=g();return S(t.prevPage())}),o(38,"\xAB Prev"),n(),r(39,"span"),o(40),n(),r(41,"button",128),b("click",function(){x(e);let t=g();return S(t.nextPage())}),o(42,"Next \xBB"),n()()()}if(l&2){let e=g();d(5),p("checked",e.allSelected)("indeterminate",e.getSelectedFormsCount()>0&&e.getSelectedFormsCount()<e.supplierForms.length),d(30),p("ngForOf",e.supplierForms),d(2),p("disabled",e.isPrevDisabled()),d(3),A("Page ",e.pageNumber,""),d(),p("disabled",e.isNextDisabled())}}function kn(l,f){l&1&&(r(0,"div",141),o(1,"No forms available."),n())}function Tn(l,f){if(l&1&&(r(0,"option",142),o(1),n()),l&2){let e=f.$implicit;p("value",e._id||e.id),d(),A(" ",e.supplierName," ")}}function Nn(l,f){l&1&&(r(0,"div",143),o(1," Advance Amount is required and must be positive. "),n())}function Mn(l,f){l&1&&c(0,"span",144)}function Vn(l,f){l&1&&c(0,"span",144)}function On(l,f){l&1&&c(0,"span",144)}function Rn(l,f){l&1&&(r(0,"span"),c(1,"i",103),o(2,"Delete All"),n())}function qn(l,f){l&1&&(r(0,"span"),c(1,"span",102),o(2,"Deleting..."),n())}function Ln(l,f){l&1&&(r(0,"span"),c(1,"i",104),o(2,"Send for Approval"),n())}function Bn(l,f){l&1&&(r(0,"span"),c(1,"span",102),o(2,"Sending..."),n())}function $n(l,f){l&1&&(r(0,"span"),c(1,"i",105),o(2,"Mark as Pre-Approved"),n())}function Un(l,f){l&1&&(r(0,"span"),c(1,"span",102),o(2,"Processing..."),n())}function zn(l,f){l&1&&(r(0,"span"),c(1,"i",106),o(2,"Without Cheque"),n())}function Yn(l,f){l&1&&(r(0,"span"),c(1,"span",102),o(2,"Processing..."),n())}var We=Ft.default??Ft,ui=(()=>{class l{supplierFormService;supplierConfigService;router;fb;toastr;bsLocaleService;supplierForms=[];supplierConfigs=[];loading=!1;error="";pageNumber=1;pageSize=1e3;filterSupplierName="";editModalOpen=!1;editForm;editSubmitting=!1;editId=null;formToEdit=null;originalDraftStatus=!0;editAccessModal;editBillValueConfirmed=!1;editBillValueBlurred=!1;editBillValueGstBlurred=!1;formToDelete=null;deleteSubmitting=!1;deleteModal;formToApprove=null;approvalSubmitting=!1;preApprovalSubmitting=!1;sendToapprovalModal;selectedForms=new Set;allSelected=!1;bulkDeleteSubmitting=!1;bulkApprovalSubmitting=!1;bulkPreApprovalSubmitting=!1;bulkWithoutChequeSubmitting=!1;bulkDeleteModal;bulkApprovalModal;bulkPreApprovalModal;bulkWithoutChequeModal;printSelectedSubmitting=!1;viewParticularsText=null;openParticularsModal(e){this.viewParticularsText=e,this.particularsModal.show()}closeParticularsModal(){this.viewParticularsText=null}formatTdsDisplay(e){if(e==null||e==="")return"0";let i=parseFloat(e);return isNaN(i)?"0":Number.isInteger(i)?String(i):i.toFixed(2).replace(/\.?0+$/,"")}editBillValueInput;editBillValueGstInput;editModal;particularsModal;bsConfig={dateInputFormat:"DD/MM/YYYY",containerClass:"theme-default",showWeekNumbers:!1};constructor(e,i,t,a,s,m){this.supplierFormService=e,this.supplierConfigService=i,this.router=t,this.fb=a,this.toastr=s,this.bsLocaleService=m,this.editForm=this.fb.group({supplierId:["",P.required],billNo:[""],date:["",P.required],particulars:["",[P.required,P.minLength(5)]],billValue:[0,[P.required,P.min(0)]],billValueGst:[0,[P.required,P.min(0)]],tds:[0,[P.required,P.min(0)]],tdsAmount:[0,[P.required,P.min(0)]],amount:[0,[P.required,P.min(0)]],chequeAmount:[0,[P.required,P.min(0)]],advance:[0,[P.required,P.min(0)]]})}ngOnInit(){We.locale("en-GB"),ve("en-gb",xe),this.bsLocaleService.use("en-gb"),this.loadSupplierConfigs(),this.fetchSupplierForms()}fetchSupplierForms(){this.loading=!0,this.error="";let e=(this.pageNumber-1)*this.pageSize;this.supplierFormService.getSupplierForms(e,this.pageSize,!0).then(i=>{let t=Array.isArray(i)?i:[];this.filterSupplierName&&(t=t.filter(a=>{let s=this.getSupplierNameById(a.supplierId);return s&&s.toLowerCase().includes(this.filterSupplierName.toLowerCase())})),this.supplierForms=t,this.selectedForms.clear(),this.allSelected=!1}).catch(()=>{this.error="Failed to load supplier forms."}).finally(()=>{this.loading=!1})}loadSupplierConfigs(){this.supplierConfigService.getSupplierFormConfigs().then(e=>{let i=Array.isArray(e?.data)?e.data:Array.isArray(e)?e:[];this.supplierConfigs=i}).catch(e=>{console.error("Error loading supplier configs:",e),this.supplierConfigs=[]})}getSupplierNameById(e){let i=this.supplierConfigs.find(t=>t._id===e);return i?i.supplierName:"Unknown Supplier"}toggleSelectAll(e){e.target.checked?(this.selectedForms=new Set(this.supplierForms.map(i=>i._id||i.id)),this.allSelected=!0):(this.selectedForms.clear(),this.allSelected=!1)}toggleFormSelection(e,i){let t=e._id||e.id;i.target.checked?this.selectedForms.add(t):this.selectedForms.delete(t),this.allSelected=this.selectedForms.size===this.supplierForms.length}isFormSelected(e){let i=e._id||e.id;return this.selectedForms.has(i)}getSelectedFormsCount(){return this.selectedForms.size}onBulkDelete(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to delete.","No Selection");return}this.bulkDeleteModal.show()}confirmBulkDelete(){if(this.selectedForms.size===0)return;this.bulkDeleteSubmitting=!0;let e=Array.from(this.selectedForms),i=e.map(t=>this.supplierFormService.deleteSupplierForm(t));Promise.all(i).then(()=>{this.toastr.success(`${e.length} form(s) deleted successfully`,"Success"),this.bulkDeleteModal.hide(),this.selectedForms.clear(),this.allSelected=!1,this.fetchSupplierForms()}).catch(t=>{console.error("Error deleting forms:",t),this.toastr.error("Failed to delete some forms. Please try again.","Error")}).finally(()=>{this.bulkDeleteSubmitting=!1})}onBulkApproval(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to send for approval.","No Selection");return}this.bulkApprovalModal.show()}onBulkPreApproval(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to mark as pre-approved.","No Selection");return}this.bulkPreApprovalModal.show()}onBulkWithoutCheque(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form for without-cheque approval.","No Selection");return}this.bulkWithoutChequeModal.show()}buildWithoutChequeUpdateData(e){let i=N(T({},e),{draft:!1,approvalType:"WITHOUT_CHEQUE"});return delete i.chequeNo,i}confirmBulkApproval(){if(this.selectedForms.size===0)return;this.bulkApprovalSubmitting=!0;let e=Array.from(this.selectedForms),t=this.supplierForms.filter(a=>this.selectedForms.has(a._id||a.id)).map(a=>{let s=N(T({},a),{draft:!1,approvalType:"NONE"});return this.supplierFormService.updateSupplierForm(a._id||a.id,s).then(()=>{let m={approvalType:"NONE",draft:!1};return this.supplierFormService.submitForApproval(a._id||a.id,m)})});Promise.all(t).then(()=>{this.toastr.success(`${e.length} form(s) sent for approval successfully! They will appear in the publish tab once approved.`,"Success",{timeOut:3e3,progressBar:!0}),this.bulkApprovalModal.hide(),this.selectedForms.clear(),this.allSelected=!1,this.fetchSupplierForms(),setTimeout(()=>{this.router.navigate(["publish"])},1500)}).catch(a=>{console.error("Error sending forms for approval:",a),this.toastr.error("Failed to send some forms for approval. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.bulkApprovalSubmitting=!1})}confirmBulkPreApproval(){if(this.selectedForms.size===0)return;this.bulkPreApprovalSubmitting=!0;let e=Array.from(this.selectedForms),t=this.supplierForms.filter(a=>this.selectedForms.has(a._id||a.id)).map(a=>{let s=N(T({},a),{draft:!1,approvalType:"PRE_APPROVED"});return this.supplierFormService.updateSupplierForm(a._id||a.id,s).then(()=>{let m={approvalType:"PRE_APPROVED",draft:!1};return this.supplierFormService.submitForApproval(a._id||a.id,m)})});Promise.all(t).then(()=>{this.toastr.success(`${e.length} form(s) marked as pre-approved successfully! They will appear in the pre-approval tab.`,"Success",{timeOut:3e3,progressBar:!0}),this.bulkPreApprovalModal.hide(),this.selectedForms.clear(),this.allSelected=!1,this.fetchSupplierForms(),setTimeout(()=>{this.router.navigate(["supplier/pre-approval/supplier"],{replaceUrl:!0})},1500)}).catch(a=>{console.error("Error marking forms as pre-approved:",a),this.toastr.error("Failed to mark some forms as pre-approved. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.bulkPreApprovalSubmitting=!1})}confirmBulkWithoutCheque(){if(this.selectedForms.size===0)return;this.bulkWithoutChequeSubmitting=!0;let e=Array.from(this.selectedForms),t=this.supplierForms.filter(a=>this.selectedForms.has(a._id||a.id)).map(a=>{let s=this.buildWithoutChequeUpdateData(a),m=a._id||a.id;return this.supplierFormService.updateSupplierForm(m,s).then(()=>this.supplierFormService.submitForApproval(m,{approvalType:"WITHOUT_CHEQUE",draft:!1}))});Promise.all(t).then(()=>{this.toastr.success(`${e.length} form(s) submitted without cheque successfully!`,"Success",{timeOut:3e3,progressBar:!0}),this.bulkWithoutChequeModal.hide(),this.selectedForms.clear(),this.allSelected=!1,this.fetchSupplierForms(),setTimeout(()=>{this.router.navigate(["supplier/publish/supplier"],{replaceUrl:!0})},1500)}).catch(a=>{console.error("Error submitting without-cheque drafts:",a),this.toastr.error("Failed to submit some forms without cheque. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.bulkWithoutChequeSubmitting=!1})}nextPage(){this.supplierForms.length===this.pageSize&&(this.pageNumber++,this.fetchSupplierForms())}prevPage(){this.pageNumber>1&&(this.pageNumber--,this.fetchSupplierForms())}isPrevDisabled(){return this.pageNumber<=1}isNextDisabled(){return this.supplierForms.length<this.pageSize}onFilterChange(){this.pageNumber=1,this.fetchSupplierForms()}onEdit(e){this.formToEdit=e,this.editAccessModal.show()}confirmEditAccess(e){if(this.editAccessModal.hide(),e&&this.formToEdit){let i=this.formToEdit,t=i._id||i.id;this.editId=t,this.originalDraftStatus=i.draft!==void 0?i.draft:!0;let a="";if(i.date){let m;i.date instanceof Date?a=i.date:typeof i.date=="string"?(m=We(i.date,["YYYY-MM-DD","DD/MM/YYYY","YYYY/MM/DD","YYYY-MM-DDTHH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ssZ"],!0),m.isValid()?a=m.toDate():(m=We(i.date),m.isValid()?a=m.toDate():a=i.date)):a=i.date}let s={supplierId:i.supplierId||"",billNo:i.billNo||"",date:a,particulars:i.particulars||"",billValue:i.billValue||0,billValueGst:i.billValueGst||0,tds:i.tds||0,tdsAmount:i.tdsAmount||0,amount:i.amount||0,chequeAmount:i.chequeAmount||0,advance:i.advance||0};this.editForm.setValue(s),this.editModal.show(),setTimeout(()=>{a instanceof Date&&this.editForm.get("date")?.setValue(a,{emitEvent:!1})},200)}this.formToEdit=null}closeEditModal(){this.editModal.hide(),this.editId=null,this.editForm.reset(),this.editSubmitting=!1,this.originalDraftStatus=!0}
1onEditSubmit(){if(this.editForm.invalid||!this.editId){this.editForm.markAllAsTouched();return}this.editSubmitting=!0;let e=this.editForm.getRawValue(),i=e.date;if(e.date instanceof Date)i=We(e.date).format("YYYY-MM-DD");else if(e.date&&typeof e.date=="string"){let a=We(e.date,"DD/MM/YYYY");a.isValid()&&(i=a.format("YYYY-MM-DD"))}let t=N(T({},e),{date:i,billValue:parseInt(e.billValue)||0,billValueGst:parseInt(e.billValueGst)||0,tds:parseFloat(e.tds)||0,tdsAmount:parseInt(e.tdsAmount)||0,amount:parseInt(e.amount)||0,chequeAmount:parseInt(e.chequeAmount)||0,advance:parseInt(e.advance)||0,draft:this.originalDraftStatus});this.supplierFormService.updateSupplierForm(this.editId,t).then(()=>{this.closeEditModal(),this.fetchSupplierForms()}).catch(()=>{this.editSubmitting=!1,alert("Failed to update form.")})}ngAfterViewInit(){this.deleteModal=new window.bootstrap.Modal(document.getElementById("deleteModal")),this.sendToapprovalModal=new window.bootstrap.Modal(document.getElementById("sendToapprovalModal")),this.editAccessModal=new window.bootstrap.Modal(document.getElementById("editAccessConfirmModal")),this.editModal=new window.bootstrap.Modal(document.getElementById("editModal")),this.particularsModal=new window.bootstrap.Modal(document.getElementById("particularsModal")),this.bulkDeleteModal=new window.bootstrap.Modal(document.getElementById("bulkDeleteModal")),this.bulkApprovalModal=new window.bootstrap.Modal(document.getElementById("bulkApprovalModal")),this.bulkPreApprovalModal=new window.bootstrap.Modal(document.getElementById("bulkPreApprovalModal")),this.bulkWithoutChequeModal=new window.bootstrap.Modal(document.getElementById("bulkWithoutChequeModal")),this.editForm.get("tds")?.valueChanges.subscribe(()=>this.updateEditCalculatedFields()),this.editForm.get("billValueGst")?.valueChanges.subscribe(()=>this.updateEditCalculatedFields()),this.editForm.get("billValue")?.valueChanges.subscribe(()=>this.updateEditCalculatedFields()),this.editForm.get("tdsAmount")?.valueChanges.subscribe(()=>this.updateEditCalculatedFields()),this.editForm.get("advance")?.valueChanges?.subscribe(()=>this.updateEditCalculatedFields()),setTimeout(()=>{let e=document.getElementById("editBillValue"),i=document.getElementById("editBillValueGst");e&&e.addEventListener("blur",()=>{this.editBillValueBlurred=!0,this.checkShowEditBillValueConfirm()}),i&&i.addEventListener("blur",()=>{this.editBillValueGstBlurred=!0,this.checkShowEditBillValueConfirm()})},0)}updateEditCalculatedFields(){let e=this.editForm.get("tds")?.value,i=this.editForm.get("billValueGst")?.value,t=this.editForm.get("tdsAmount")?.value,a=this.editForm.get("billValue")?.value;if(e!=null&&i!=null&&!isNaN(e)&&!isNaN(i)&&(t=Math.round(parseFloat(e)/100*parseFloat(i)),this.editForm.get("tdsAmount")?.setValue(t,{emitEvent:!1})),a!=null&&t!=null&&!isNaN(a)&&!isNaN(t)){let h=Math.round(parseFloat(a)-parseFloat(t));this.editForm.get("amount")?.setValue(h,{emitEvent:!1})}let s=this.editForm.get("advance")?.value,m=this.editForm.get("amount")?.value,u=null;m!=null&&!isNaN(m)&&(s!=null&&!isNaN(s)&&s>0?u=Math.round(m-parseFloat(s)):u=m,this.editForm.get("chequeAmount")?.setValue(u,{emitEvent:!1}))}checkShowEditBillValueConfirm(){this.editForm.get("billValue")?.value&&this.editForm.get("billValueGst")?.value&&this.editBillValueBlurred&&this.editBillValueGstBlurred&&!this.editBillValueConfirmed&&new window.bootstrap.Modal(document.getElementById("editBillValueConfirmModal")).show()}confirmEditBillValues(e){this.editBillValueConfirmed=e,new window.bootstrap.Modal(document.getElementById("editBillValueConfirmModal")).hide(),e||(this.editBillValueBlurred=!1,this.editBillValueGstBlurred=!1,setTimeout(()=>{this.editBillValueInput?.nativeElement.focus()},0))}onDelete(e){this.formToDelete=e,this.deleteModal.show()}confirmDelete(){if(!this.formToDelete)return;let e=this.formToDelete._id||this.formToDelete.id;this.deleteSubmitting=!0,this.supplierFormService.deleteSupplierForm(e).then(()=>{this.toastr.success("Supplier form deleted successfully","Success"),this.deleteModal.hide(),this.formToDelete=null,this.fetchSupplierForms()}).catch(i=>{console.error("Error deleting form:",i),this.toastr.error("Failed to delete supplier form","Error")}).finally(()=>{this.deleteSubmitting=!1})}sendToApproval(e){this.formToApprove=e,this.sendToapprovalModal.show()}confirmSendToApproval(){if(!this.formToApprove)return;let e=this.formToApprove._id||this.formToApprove.id;this.approvalSubmitting=!0;let i=N(T({},this.formToApprove),{draft:!1,approvalType:"NONE"});this.supplierFormService.updateSupplierForm(i._id||i.id,i).then(()=>{let t={approvalType:"NONE",draft:!1};return this.supplierFormService.submitForApproval(e,t)}).then(()=>{this.toastr.success("Draft sent for approval successfully! It will appear in the publish tab once approved.","Success",{timeOut:3e3,progressBar:!0}),this.sendToapprovalModal.hide(),this.formToApprove=null,this.fetchSupplierForms(),setTimeout(()=>{this.router.navigate(["publish"])},1500)}).catch(t=>{console.error("Error sending draft for approval:",t),this.toastr.error("Failed to send draft for approval. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.approvalSubmitting=!1})}getStatusDisplay(e){return e.draft===!0?"Draft":e.submissionStatus==="APPROVED"?"Approved":e.submissionStatus==="PENDING"?"Pending Approval":"Unknown"}getStatusBadgeClass(e){return e.draft===!0?"bg-warning":e.submissionStatus==="APPROVED"?"bg-success":e.submissionStatus==="PENDING"?"bg-info":"bg-secondary"}canEdit(e){return e.draft===!0}canDelete(e){return e.draft===!0}canSendForApproval(e){return e.draft===!0}sendToPreApproval(e){if(!e||!e.draft){this.toastr.warning("Only draft forms can be sent for pre-approval.","Invalid Action");return}let i=e._id||e.id;this.preApprovalSubmitting=!0;let t=N(T({},e),{draft:!1,approvalType:"PRE_APPROVED"});this.supplierFormService.updateSupplierForm(i,t).then(()=>{let a={approvalType:"PRE_APPROVED",draft:!1};return this.supplierFormService.submitForApproval(i,a)}).then(()=>{this.toastr.success("Draft sent for pre-approval successfully! It will appear in the publish tab once approved.","Success",{timeOut:3e3,progressBar:!0}),this.fetchSupplierForms(),setTimeout(()=>{this.router.navigate(["publish"])},1500)}).catch(a=>{console.error("Error sending draft for pre-approval:",a),this.toastr.error("Failed to send draft for pre-approval. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.preApprovalSubmitting=!1})}printSelectedForms(){return M(this,null,function*(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to print.","No Selection");return}this.printSelectedSubmitting=!0,this.toastr.info("Preparing draft document...","Generating Print Document");let e=this.supplierForms.filter(s=>this.selectedForms.has(s._id||s.id)),i=window.open("","_blank");if(!i){this.toastr.error("Please allow popups to print the document.","Error"),this.printSelectedSubmitting=!1;return}let t=this.generateDraftPrintContent(e);i.document.write(`
2      <!DOCTYPE html>
3      <html>
4        <head>
5          <title>Draft Supplier Forms</title>
6          <style>
7            body { 
8              font-family: Arial, sans-serif; 
9              margin: 20px; 
10              font-size: 12px;
11            }
12            .header { 
13              text-align: center; 
14            }
15            .logo-container {
16            }
17            .logo {
18               max-width: 300px;
19               height: 120px;
20               margin: 0 auto;
21               display: block;
22               object-fit: contain;
23             }
24            table { 
25              width: 100%; 
26              border-collapse: collapse; 
27              margin-top: 20px;
28              table-layout: fixed;
29              border: 2px solid #000;
30            }
31            th, td { 
32              border: 1px solid #000; 
33              padding: 8px; 
34              text-align: left;
35              word-wrap: break-word;
36              overflow-wrap: break-word;
37              white-space: normal;
38              overflow: visible;
39              max-width: 100%;
40            }
41            th { 
42              background-color: #f2f2f2; 
43              font-weight: bold;
44              border: 1px solid #000;
45              font-size: 12px;
46            }
47            td {
48              font-size: 14px;
49            }
50            /* Numeric values - ensure readable font size */
51            td.text-right,
52            td.amount {
53              font-size: 14px;
54            }
55            tbody tr td {
56              border: 1px solid #000;
57            }
58            thead tr th {
59              border: 1px solid #000;
60            }
61            /* Column width adjustments for DRAFT print (11 columns) */
62            table.draft-print th:nth-child(1),
63            table.draft-print td:nth-child(1) {
64              width: 4%; /* Sl.No. */
65            }
66            table.draft-print th:nth-child(2),
67            table.draft-print td:nth-child(2) {
68              width: 12%; /* Name of the Company/Supplier */
69            }
70            table.draft-print th:nth-child(3),
71            table.draft-print td:nth-child(3) {
72              width: 7%; /* Inv./Bill No. */
73            }
74            table.draft-print th:nth-child(4),
75            table.draft-print td:nth-child(4) {
76              width: 7.5%; /* Date */
77              white-space: nowrap;
78              min-width: 85px;
79              padding-left: 12px;
80              padding-right: 12px;
81            }
82            table.draft-print th:nth-child(5),
83            table.draft-print td:nth-child(5) {
84              min-width: 200px;
85              width: 25%; /* Particulars - wider column for text content */
86            }
87            table.draft-print th:nth-child(5) {
88              text-align: center; /* Particulars header - centered */
89            }
90            table.draft-print td:nth-child(5) {
91              text-align: left; /* Particulars content - left aligned */
92            }
93            table.draft-print th:nth-child(6),
94            table.draft-print td:nth-child(6) {
95              width: 9.5%; /* Total Bill Value \u20B9 */
96            }
97            table.draft-print th:nth-child(7),
98            table.draft-print td:nth-child(7) {
99              width: 9.5%; /* Bill Value before GST \u20B9 */
100            }
101            table.draft-print th:nth-child(8),
102            table.draft-print td:nth-child(8) {
103              width: 5%; /* TDS @ */
104            }
105            table.draft-print th:nth-child(9),
106            table.draft-print td:nth-child(9) {
107              width: 8.5%; /* TDS Amount \u20B9 */
108            }
109            table.draft-print th:nth-child(10),
110            table.draft-print td:nth-child(10) {
111              width: 9.5%;
111 /* Cheque Amount \u20B9 */
112            }
113            table.draft-print th:nth-child(11),
114            table.draft-print td:nth-child(11) {
115              width: 7.5%; /* Advance */
116            }
117            .text-center { text-align: center; }
118            .text-right { text-align: right; }
119            .amount { font-weight: bold; }
120            .total-row {
121              background-color: #f8f9fa;
122              font-weight: bold;
123            }
124            .total-row td {
125              font-size: 14px;
126            }
127            .amount-in-words {
128              margin-top: 20px;
129              padding: 10px;
130              background-color: #f8f9fa;
131              border: 1px solid #ddd;
132              text-align: center;
133              font-weight: bold;
134              font-size: 14px;
135            }
136            .print-button {
137              position: fixed;
138              top: 20px;
139              right: 20px;
140              background-color: #007bff;
141              color: white;
142              border: none;
143              padding: 10px 20px;
144              border-radius: 5px;
145              cursor: pointer;
146              font-size: 14px;
147              font-weight: bold;
148              box-shadow: 0 2px 5px rgba(0,0,0,0.2);
149              z-index: 1000;
150            }
151            .print-button:hover {
152              background-color: #0056b3;
153            }
154            .generated-on {
155              position: fixed;
156              top: 60px;
157              right: 20px;
158              color: #555;
159              font-size: 12px;
160              background: rgba(255,255,255,0.9);
161              padding: 4px 8px;
162              border: 1px solid #ddd;
163              border-radius: 4px;
164              z-index: 999;
165            }
166            .page-number {
167              position: fixed;
168              top: 10px;
169              right: 20px;
170              font-size: 12px;
171              font-weight: bold;
172              color: #333;
173              z-index: 1000;
174              background: rgba(255, 255, 255, 0.9);
175              padding: 4px 8px;
176              border-radius: 4px;
177            }
178            @media print {
179              body { 
180                margin: 0; 
181                font-size: 13px;
182              }
183              .no-print { display: none; }
184              .print-button { display: none; }
185              .generated-on { top: 20px; }
186              .page-number {
187                display: none;
188              }
189              table {
190                width: 100% !important;
191                table-layout: fixed !important;
192                font-size: 13px;
193              }
194              th, td {
195                font-size: 13px;
196                padding: 4px 3px !important;
197                word-wrap: break-word !important;
198                overflow-wrap: break-word !important;
199                white-space: normal !important;
200                overflow: visible !important;
201                text-overflow: clip !important;
202                max-width: 100% !important;
203              }
204              table.draft-print th:nth-child(5),
205              table.draft-print td:nth-child(5) {
206                width: 25% !important;
207                min-width: 150px !important;
208              }
209              @page {
210                size: landscape;
211                margin: 10mm;
212                @top-right {
213                  content: counter(page) " of " counter(pages);
214                  font-size: 13px;
215                  font-weight: bold;
216                  color: #000;
217                  margin-top: 5mm;
218                  margin-right: 10mm;
219                }
220              }
221            }
222          </style>
223        </head>
224        <body>
225          <button class="print-button" onclick="window.print()">\u{1F5A8}\uFE0F Print Document</button>
226          <div class="page-number no-print">Page 1</div>
227          ${t}
228        </body>
229      </html>
230    `),i.document.close(),i.focus(),this.printSelectedSubmitting=!1})}generateDraftPrintContent(e){let i=0,t=0,a=0,s=0,m=0,u="";e.forEach((v,E)=>{let y=v.billValue||0,F=v.billValueGst||0,k=v.tdsAmount||0,V=v.chequeAmount||0,Y=v.advance||0,O="N/A";if(v.date){if(v.date instanceof Date)O=We(v.date).format("DD-MM-YYYY");else if(typeof v.date=="string"){let ae=We(v.date,["YYYY-MM-DD","DD/MM/YYYY","DD-MM-YYYY"],!0);ae.isValid()?O=ae.format("DD-MM-YYYY"):O=v.date}}
230let C=v.views?.supplierName||this.getSupplierNameById(v.supplierId)||"N/A";i+=y,t+=F,a+=k,s+=V,m+=Y,u+=`
231        <tr>
232          <td class="text-center">${E+1}</td>
233          <td>${C}</td>
234          <td>${v.billNo||"N/A"}</td>
235          <td class="text-center">${O}</td>
236          <td>${v.particulars||"N/A"}</td>
237          <td class="text-right amount">${y}</td>
238          <td class="text-right">${F}</td>
239          <td class="text-center">${this.formatTdsDisplay(v.tds)}</td>
240          <td class="text-right">${k}</td>
241          <td class="text-right amount">${V}</td>
242          <td class="text-right">${Y}</td>
243        </tr>
244      `});let h=this.numberToWords(s);return`
245      <div class="header">
246        <div class="logo-container">
247          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
248        </div>
249      </div>
250      
251      <table class="draft-print">
252        <thead>
253          <tr>
254            <th class="text-center">Sl.No.</th>
255            <th class="text-center">Name of the Company/Supplier</th>
256            <th class="text-center">Inv./Bill No.</th>
257            <th class="text-center">Date</th>
258            <th class="text-center">Particulars</th>
259            <th class="text-right">Total Bill Value \u20B9</th>
260            <th class="text-right">Bill Value before GST \u20B9</th>
261            <th class="text-center">TDS @</th>
262            <th class="text-right">TDS Amount \u20B9</th>
263            <th class="text-right">Cheque Amount \u20B9</th>
264            <th class="text-right">Advance \u20B9</th>
265          </tr>
266        </thead>
267        <tbody>
268          ${u}
269          <tr class="total-row">
270            <td colspan="5" class="text-center"><strong>Total \u20B9</strong></td>
271            <td class="text-right"><strong>${i}</strong></td>
272            <td class="text-right"><strong>${t}</strong></td>
273            <td></td>
274            <td class="text-right"><strong>${a}</strong></td>
275            <td class="text-right"><strong>${s}</strong></td>
276            <td class="text-right"><strong>${m}</strong></td>
277          </tr>
278        </tbody>
279      </table>
280      
281      <div class="amount-in-words">
282        (Rupees ${h} only)
283      </div>
284    `}numberToWords(e){let i=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"],t=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"],a=["Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"];if(e===0)return"Zero";let s=u=>u===0?"":u<10?i[u]:u<20?a[u-10]:u<100?t[Math.floor(u/10)]+(u%10!==0?" "+i[u%10]:""):u<1e3?i[Math.floor(u/100)]+" Hundred"+(u%100!==0?" and "+s(u%100):""):"";return(u=>{if(u===0)return"Zero";let h=Math.floor(u/1e7),v=Math.floor(u%1e7/1e5),E=Math.floor(u%1e5/1e3),y=u%1e3,F="";return h>0&&(F+=s(h)+" Crore "),v>0&&(F+=s(v)+" Lakh "),E>0&&(F+=s(E)+" Thousand "),y>0&&(F+=s(y)),F.trim()})(Math.floor(e))}static \u0275fac=function(i){return new(i||l)(D(Be),D(St),D(ne),D(be),D(K),D(Se))};static \u0275cmp=q({type:l,selectors:[["app-draft-view"]],viewQuery:function(i,t){if(i&1&&(Ee(cn,5),Ee(mn,5)),i&2){let a;ye(a=Fe())&&(t.editBillValueInput=a.first),ye(a=Fe())&&(t.editBillValueGstInput=a.first)}},decls:312,vars:52,consts:[["editBillValueInput",""],["editBillValueGstInput",""],["editAdvanceInput",""],[1,"mb-3","d-flex","flex-column","flex-md-row","justify-content-between","align-items-center","gap-2"],["type","text","placeholder","Filter by Supplier Name",1,"form-control","w-100","w-md-50",3,"ngModelChange","ngModel"],["class","mb-3 d-flex flex-wrap gap-2 align-items-center bulk-actions",4,"ngIf"],["class","text-center my-3",4,"ngIf"],["class","alert alert-danger animate__animated animate__fadeIn",4,"ngIf"],["class","table-responsive animate__animated animate__fadeIn",4,"ngIf"],["class","alert alert-info animate__animated animate__fadeIn",4,"ngIf"],["id","editModal","tabindex","-1","aria-labelledby","editModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-dialog","modal
284-lg"],[1,"modal-content"],[1,"modal-header"],["id","editModalLabel",1,"modal-title"],["type","button","data-bs-dismiss","modal","aria-label","Close",1,"btn-close"],[3,"ngSubmit","formGroup"],[1,"modal-body"],[1,"row","g-3"],[1,"col-md-6"],[1,"form-label"],["formControlName","supplierId","required","",1,"form-select"],["value",""],[3,"value",4,"ngFor","ngForOf"],["type","text","formControlName","billNo",1,"form-control"],["type","text","formControlName","date","bsDatepicker","","placeholder","DD/MM/YYYY","required","",1,"form-control",3,"bsConfig"],["formControlName","particulars","required","",1,"form-control"],[1,"col-md-4"],["id","editBillValue","type","number","formControlName","billValue","min","0","step","1","required","",1,"form-control"],["id","editBillValueGst","type","number","formControlName","billValueGst","min","0","step","1","required","",1,"form-control"],["type","number","formControlName","tds","min","0","step","0.1","required","",1,"form-control"],["type","number","formControlName","tdsAmount","min","0","step","1","placeholder","Enter TDS Amount","disabled","",1,"form-control"],["type","number","formControlName","amount","min","0","step","1","required","","disabled","",1,"form-control"],["id","editAdvance","type","number","formControlName","advance","min","0","step","1","required","",1,"form-control",3,"ngClass"],["class","invalid-feedback",4,"ngIf"],["type","number","formControlName","chequeAmount","min","0","step","1","placeholder","Enter Cheque Amount","disabled","",1,"form-control"],[1,"modal-footer"],["type","button","data-bs-dismiss","modal",1,"btn","btn-secondary"],["type","submit",1,"btn","btn-primary",3,"disabled"],["class","spinner-border spinner-border-sm me-2",4,"ngIf"],["id","deleteModal","tabindex","-1","aria-labelledby","deleteModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-dialog"],[1,"modal-header","bg-danger","text-white"],["id","deleteModalLabel",1,"modal-title"],["type","button","data-bs-dismiss","modal","aria-label","Close",1,"btn-close","btn-close-white"],[1,"mb-0"],["type","button",1,"btn","btn-danger",3,"click","disabled"],["id","sendToapprovalModal","tabindex","-1","aria-labelledby","sendToapprovalModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-success","text-white"],["id","sendToapprovalModalLabel",1,"modal-title"],[1,"text-muted","mb-0"],[1,"mb-0","mt-2"],["type","button",1,"btn","btn-success",3,"click","disabled"],["id","particularsModal","tabindex","-1","aria-labelledby","particularsModalLabel","aria-hidden","true",1,"modal","fade"],["id","particularsModalLabel",1,"modal-title"],["id","editAccessConfirmModal","tabindex","-1","aria-labelledby","editAccessConfirmModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-dialog","modal
284-dialog-centered"],[1,"modal-header","bg-info","text-dark"],["id","editAccessConfirmModalLabel",1,"modal-title"],[1,"fa","fa-question-circle","me-2"],[1,"modal-body","text-center"],[1,"mb-3"],[1,"mb-1"],[1,"modal-footer","justify-content-center"],["type","button",1,"btn","btn-success","px-4",3,"click"],[1,"fa","fa-check","me-1"],["type","button",1,"btn","btn-danger","px-4",3,"click"],[1,"fa","fa-times","me-1"],["id","editBillValueConfirmModal","tabindex","-1","aria-labelledby","editBillValueConfirmModalLabel","aria-hidden","true",1,"modal","fade"],["id","editBillValueConfirmModalLabel",1,"modal-title"],["id","bulkDeleteModal","tabindex","-1","aria-labelledby","bulkDeleteModalLabel","aria-hidden","true",1,"modal","fade"],["id","bulkDeleteModalLabel",1,"modal-title"],[1,"fa","fa-exclamation-triangle","me-2"],[1,"text-danger","mb-0"],["type","button","data-bs-dismiss","modal",1,"btn","btn-secondary","px-4"],["type","button",1,"btn","btn-danger","px-4",3,"click","disabled"],[4,"ngIf"],["id","bulkApprovalModal","tabindex","-1","aria-labelledby","bulkApprovalModalLabel","aria-hidden","true",1,"modal","fade"],["id","bulkApprovalModalLabel",1,"modal-title"],[1,"fa","fa-paper-plane","me-2"],["type","button",1,"btn","btn-success","px-4",3,"click","disabled"],["id","bulkPreApprovalModal","tabindex","-1","aria-labelledby","bulkPreApprovalModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-warning","text-dark"],["id","bulkPreApprovalModalLabel",1,"modal-title"],[1,"fa","fa-check-circle","me-2"],[1,"mb-0","mt-2","text-start",2,"display","inline-block"],["type","button",1,"btn","btn-warning","px-4",3,"click","disabled"],["id","bulkWithoutChequeModal","tabindex","-1","aria-labelledby","bulkWithoutChequeModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-secondary","text-white"],["id","bulkWithoutChequeModalLabel",1,"modal-title"],[1,"fa","fa-ban","me-2"],[1,"text-muted","small","mb-0"],["type","button",1,"btn","btn-secondary","px-4",3,"click","disabled"],[1,"mb-3","d-flex","flex-wrap","gap-2","align-items-center","bulk-actions"],[1,"d-flex","align-items-center","me-3"],[1,"badge","bg-primary","me-2"],[1,"btn","btn-info","btn-sm",3,"click","disabled"],[1,"btn","btn-danger","btn-sm",3,"click","disabled"],[1,"btn","btn-success","btn-sm",3,"click","disabled"],[1,"btn","btn-warning","btn-sm",3,"click","disabled"],[1,"btn","btn-secondary","btn-sm",3,"click","disabled"],[1,"fa","fa-print","me-1"],[1,"spinner-border","spinner-border-sm","me-1"],[1,"fa","fa-trash-o","me-1"],[1,"fa","fa-paper-plane","me-1"],[1,"fa","fa-check-circle","me-1"],[1,"fa","fa-ban","me-1"],[1,"text-center","my-3"],["role","status",1,"spinner-border","text-primary","spinner-border-lg","animate__animated","animate__fadeIn"],[1,"visually-hidden"],[1,"alert","alert-danger","animate__animated","animate__fadeIn"],[1,"table-responsive","animate__animated","animate__fadeIn"],[1,"table","table-sm","table-striped","table-hover","align-middle",2,"min-width","900px"],[1,"table-primary","sticky-top",2,"z-index","2"],[1,"text-center",2,"width","40px"],["type","checkbox",1,"form-check-input",3,"change","checked","indeterminate"],[2,"width","120px"],[1,"text-nowrap",2,"width","80px"],[1,"text-nowrap",2,"width","100px"],[1,"text-center",2,"width","60px"],[1,"text-end",2,"width","80px"],[1,"text-end",2,"width","60px"],[1,"text-end",2,"width","90px"],[1,"text-center",2,"width","80px"],[1,"text-center",2,"width","70px"],[3,"table-primary",4,"ngFor","ngForOf"],[1,"d-flex","justify-content-end","align-items-center","mt-2"],[1,"btn","btn-primary","me-2",3,"click","disabled"],[1,"btn","btn-secondary","ms-2",3,"click","disabled"],[1,"text-center"],["type","checkbox",1,"form-check-input",3,"change","checked"],[1,"text-nowrap"],["title","View Particulars",1,"btn","btn-link","p-0",3,"click"],[1,"fa","fa-eye"],[1,"text-end"],[1,"badge",3,"ngClass"],["class","btn btn-link p-0","data-bs-toggle","tooltip","title","Edit",3,"click",4,"ngIf"],["class","text-muted small",4,"ngIf"],["data-bs-toggle","tooltip","title","Edit",1,"btn","btn-link","p-0",3,"click"],[1,"fa","fa-pencil","text-primary","fs-5"],[1,"text-muted","small"],[1,"alert","alert-info","animate__animated","animate__fadeIn"],[3,"value"],[1,"invalid-feedback"],[1,"spinner-border","spinner-border-sm","me-2"]],template:function(i,t){if(i&1){let a=I();r(0,"div")(1,"div",3)(2,"input",4),ee("ngModelChange",function(m){return x(a),J(t.filterSupplierName,m)||(t.filterSupplierName=m),S(m)}),b("ngModelChange",function(){return x(a),S(t.onFilterChange())}),n()(),_(3,En,19,16,"div",5)(4,yn,4,0,"div",6)(5,Fn,2,1,"div",7)(6,In,43,6,"div",8)(7,kn,2,0,"div",9),r(8,"div",10)(9,"div",11)(10,"div",12)(11,"div",13)(12,"h5",14),o(13,"Edit Supplier Form"),n(),c(14,"button",15),n(),r(15,"form",16),b("ngSubmit",function(){return x(a),S(t.onEditSubmit())}),r(16,"div",17)(17,"div",18)(18,"div",19)(19,"label",20),o(20,"Supplier Name"),n(),r(21,"select",21)(22,"option",22),o(23,"Select a supplier..."),n(),_(24,Tn,2,2,"option",23),n()(),r(25,"div",19)(26,"label",20),o(27,"Bill No."),n(),c(28,"input",24),n(),r(29,"div",19)(30,"label",20),o(31,"Date"),n(),c(32,"input",25),n(),r(33,"div",19)(34,"label",20),o(35,"Particulars"),n(),c(36,"textarea",26),n(),r(37,"div",27)(38,"label",20),o(39,"Bill Value (\u20B9)"),n(),c(40,"input",28,0),n(),r(42,"div",27)(43,"label",20),o(44,"Bill Value Before GST (\u20B9)"),n(),c(45,"input",29,1),n(),r(47,"div",27)(48,"label",20),o(49,"TDS (%)"),n(),c(50,"input",30),n(),r(51,"div",27)(52,"label",20),o(53,"TDS Amount (\u20B9)"),n(),c(54,"input",31),n(),r(55,"div",27)(56,"label",20),o(57,"Amount (\u20B9)"),n(),c(58,"input",32),n(),r(59,"div",27)(60,"label",20),o(61,"Advance Amount (\u20B9)"),n(),c(62,"input",33,2),_(64,Nn,2,0,"div",34),n(),r(65,"div",27)(66,"label",20),o(67,"Cheque Amou
284nt (\u20B9)"),n(),c(68,"input",35),n()()(),r(69,"div",36)(70,"button",37),o(71,"Cancel"),n(),r(72,"button",38),_(73,Mn,1,0,"span",39),o(74," Update "),n()()()()()(),r(75,"div",40)(76,"div",41)(77,"div",12)(78,"div",42)(79,"h5",43),o(80,"Confirm Delete"),n(),c(81,"button",44),n(),r(82,"div",17)(83,"p"),o(84,"Are you sure you want to delete this supplier form?"),n(),r(85,"p",45)(86,"strong"),o(87,"Supplier Name:"),n(),o(88),n(),r(89,"p",45)(90,"strong"),o(91,"Bill No:"),n(),o(92),n(),r(93,"p",45)(94,"strong"),o(95,"Cheque Amount:"),n(),o(96),L(97,"number"),n()(),r(98,"div",36)(99,"button",37),o(100,"Cancel"),n(),r(101,"button",46),b("click",function(){return x(a),S(t.confirmDelete())}),_(102,Vn,1,0,"span",39),o(103," Delete "),n()()()()(),r(104,"div",47)(105,"div",41)(106,"div",12)(107,"div",48)(108,"h5",49),o(109,"Send for Approval"),n(),c(110,"button",44),n(),r(111,"div",17)(112,"p"),o(113,"Are you sure you want to send this supplier form for approval?"),n(),r(114,"p",45)(115,"strong"),o(116,"Supplier Name:"),n(),o(117),n(),r(118,"p",45)(119,"strong"),o(120,"Bill No:"),n(),o(121),n(),r(122,"p",45)(123,"strong"),o(124,"Cheque Amount:"),n(),o(125),L(126,"number"),n(),c(127,"hr"),r(128,"p",50),o(129,"The form will go through the following approval workflow:"),n(),r(130,"ol",51)(131,"li"),o(132,"DEAN"),n(),r(133,"li"),o(134,"REGISTRAR"),n(),r(135,"li"),o(136,"PRESIDENT"),n()()(),r(137,"div",36)(138,"button",37),o(139,"Cancel"),n(),r(140,"button",52),b("click",function(){return x(a),S(t.confirmSendToApproval())}),_(141,On,1,0,"span",39),o(142," Send for Approval "),n()()()()(),r(143,"div",53)(144,"div",41)(145,"div",12)(146,"div",13)(147,"h5",54),o(148,"Particulars"),n(),c(149,"button",15),n(),r(150,"div",17)(151,"p"),o(152),n()(),r(153,"div",36)(154,"button",37),o(155,"Close"),n()()()()(),r(156,"div",55)(157,"div",56)(158,"div",12)(159,"div",57)(160,"h5",58),c(161,"i",59),o(162,"Edit Draft Confirmation "),n(),c(163,"button",15),n(),r(164,"div",60)(165,"p",61),o(166,"Do you want to edit this draft?"),n(),r(167,"p",62),o(168,"Supplier Name: "),r(169,"strong"),o(170),n()(),r(171,"p"),o(172,"Bill No: "),r(173,"strong"),o(174),n()()(),r(175,"div",63)(176,"button",64),b("click",function(){return x(a),S(t.confirmEditAccess(!0))}),c(177,"i",65),o(178,"Yes "),n(),r(179,"button",66),b("click",function(){return x(a),S(t.confirmEditAccess(!1))}),c(180,"i",67),o(181,"No "),n()()()()(),r(182,"div",68)(183,"div",56)(184,"div",12)(185,"div",57)(186,"h5",69),c(187,"i",59),o(188,"Confirm Bill Values "),n(),c(189,"button",15),n(),r(190,"div",60)(191,"p",61),o(192,"Are the "),r(193,"strong"),o(194,"Bill Value"),n(),o(195," and "),r(196,"strong"),o(197,"Bill Value Before GST"),n(),o(198," entered correct?"),n(),r(199,"p",62),o(200,"Bill Value: "),r(201,"strong"),o(202),n()(),r(203,"p"),o(204,"Bill Value Before GST: "),r(205,"strong"),o(206),n()()(),r(207,"div",63)(208,"button",64),b("click",function(){return x(a),S(t.confirmEditBillValues(!0))}),c(209,"i",65),o(210,"Yes "),n(),r(211,"button",66),b("click",function(){return x(a),S(t.confirmEditBillValues(!1))}),c(212,"i",67),o(213,"No "),n()()()()(),r(214,"div",70)(215,"div",56)(216,"div",12)(217,"div",42)(218,"h5",71),c(219,"i",72),o(220,"Confirm Bulk Delete "),n(),c(221,"button",44),n(),r(222,"div",60)(223,"p",61),o(224,"Are you sure you want to delete "),r(225,"strong"),o(226),n(),o(227," selected form(s)?"),n(),r(228,"p",73)(229,"strong"),o(230,"This action cannot be undone!"),n()()(),r(231,"div",63)(232,"button",74),c(233,"i",67),o(234,"Cancel "),n(),r(235,"button",75),b("click",function(){return x(a),S(t.confirmBulkDelete())}),_(236,Rn,3,0,"span",76)(237,qn,3,0,"span",76),n()()()()(),r(238,"div",77)(239,"div",56)(240,"div",12)(241,"div",48)(242,"h5",78),c(243,"i",79),o(244,"Send for Bulk Approval "),n(),c(245,"button",44),n(),r(246,"div",60)(247,"p",61),o(248,"Are you sure you want to send "),r(249,"strong"),o(250),n(),o(251," selected form(s) for approval?"),n()(),r(252,"div",63)(253,"button",74),c(254,"i",67),o(255,"Cancel "),n(),r(256,"button",80),b("click",function(){return x(a),S(t.confirmBulkApproval())}),_(257,Ln,3,0,"span",76)(258,Bn,3,0,"span",76),n()()()()(),r(259,"div",81)(260,"div",56)(261,"div",12)(262,"div",82)(263,"h5",83),c(264,"i",84),o(265,"Mark as Pre-Approved "),n(),c(266,"button",15),n(),r(267,"div",60)(268,"p",61),o(269,"Are you sure you want to mark "),r(270,"strong"),o(271),n(),o(272," selected form(s) as pre-approved?"),n(),c(273,"hr"),r(274,"p",50),o(275,"This will:"),n(),r(276,"ul",85)(277,"li"),o(278,"Publish the forms immediately"),n(),r(279,"li"),o(280,"Bypass the approval workflow"),n(),r(281,"li"),o(282,"Mark all approval levels as approved"),n()()(),r(283,"div",63)(284,"button",74),c(285,"i",67),o(286,"Cancel "),n(),r(287,"button",86),b("click",function(){return x(a),S(t.confirmBulkPreApproval())}),_(288,$n,3,0,"span",76)(289,Un,3,0,"span",76),n()()()()(),r(290,"div",87)(291,"div",56)(292,"div",12)(293,"div",88)(294,"h5",89),c(295,"i",90),o(296,"Submit Without Cheque "),n(),c(297,"button",44),n(),r(298,"div",17)(299,"p",61),o(300,"Submit "),r(301,"strong"),o(302),n(),o(303," selected draft(s) for approval without cheque?"),n(),r(304,"p",91),o(305,"Full form details are saved; no cheque number is required. Approvers use the Amount Estimate tab for final e-sign."),n()(),r(306,"div",36)(307,"button",37),o(308,"Cancel"),n(),r(309,"button",92),b("click",function(){return x(a),S(t.confirmBulkWithoutCheque())}),_(310,zn,3,0,"span",76)(311,Yn,3,0,"span",76),n()()()()()()}if(i&2){let a,s,m,u;d(2),X("ngModel",t.filterSupplierName),d(),p("ngIf",!t.loading&&t.supplierForms.length>0),d(),p("ngIf",t.loading),d(),p("ngIf",t.error),d(),p("ngIf",!t.loading&&t.supplierForms.length>0),d(),p("ngIf",!t.loading&&t.supplierForms.length===0),d(8),p("formGroup",t.editForm),d(9),p("ngForOf",t.supplierConfigs),d(8),p("bsConfig",t.bsConfig),d(30),p("ngClass",$(50,un,((a=t.editForm.get("advance"))==null?null:a.invalid)&&
284((a=t.editForm.get("advance"))==null?null:a.touched))),d(2),p("ngIf",((s=t.editForm.get("advance"))==null?null:s.invalid)&&((s=t.editForm.get("advance"))==null?null:s.touched)),d(8),p("disabled",t.editForm.invalid||t.editSubmitting),d(),p("ngIf",t.editSubmitting),d(15),A(" ",t.formToDelete==null?null:t.formToDelete.views.supplierName,""),d(4),A(" ",t.formToDelete==null?null:t.formToDelete.billNo,""),d(4),A(" \u20B9",B(97,44,t.formToDelete==null?null:t.formToDelete.chequeAmount,"1.0-0"),""),d(5),p("disabled",t.deleteSubmitting),d(),p("ngIf",t.deleteSubmitting),d(15),A(" ",t.formToApprove==null?null:t.formToApprove.views.supplierName,""),d(4),A(" ",t.formToApprove==null?null:t.formToApprove.billNo,""),d(4),A(" \u20B9",B(126,47,t.formToApprove==null?null:t.formToApprove.chequeAmount,"1.0-0"),""),d(15),p("disabled",t.approvalSubmitting),d(),p("ngIf",t.approvalSubmitting),d(11),w(t.viewParticularsText),d(18),w(t.formToEdit==null?null:t.formToEdit.views.supplierName),d(4),w(t.formToEdit==null?null:t.formToEdit.billNo),d(28),w((m=t.editForm.get("billValue"))==null?null:m.value),d(4),w((u=t.editForm.get("billValueGst"))==null?null:u.value),d(20),w(t.getSelectedFormsCount()),d(9),p("disabled",t.bulkDeleteSubmitting),d(),p("ngIf",!t.bulkDeleteSubmitting),d(),p("ngIf",t.bulkDeleteSubmitting),d(13),w(t.getSelectedFormsCount()),d(6),p("disabled",t.bulkApprovalSubmitting),d(),p("ngIf",!t.bulkApprovalSubmitting),d(),p("ngIf",t.bulkApprovalSubmitting),d(13),w(t.getSelectedFormsCount()),d(16),p("disabled",t.bulkPreApprovalSubmitting),d(),p("ngIf",!t.bulkPreApprovalSubmitting),d(),p("ngIf",t.bulkPreApprovalSubmitting),d(13),w(t.getSelectedFormsCount()),d(7),p("disabled",t.bulkWithoutChequeSubmitting),d(),p("ngIf",!t.bulkWithoutChequeSubmitting),d(),p("ngIf",t.bulkWithoutChequeSubmitting)}},dependencies:[te,ie,W,fe,ei,ti,j,Ne,Jt,H,me,Ve,Me,ue,he,ge,Oe,Re,se,Q],styles:[".form-check-input[_ngcontent-%COMP%]{cursor:pointer}.form-check-input[_ngcontent-%COMP%]:checked{background-color:#0d6efd;border-color:#0d6efd}.table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   tr.table-primary[_ngcontent-%COMP%]{background-color:#0d6efd1a!important}.table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   tr.table-primary[_ngcontent-%COMP%]:hover{background-color:#0d6efd33!important}.bulk-actions[_ngcontent-%COMP%]{transition:all .3s ease}.bulk-actions[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]{transition:all .2s ease}.bulk-actions[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]:hover{transform:translateY(-1px);box-shadow:0 2px 4px #0000001a}.badge[_ngcontent-%COMP%]{font-size:.875rem;padding:.5rem .75rem}.nav-tabs[_ngcontent-%COMP%]{border-bottom:2px solid #e9ecef;margin-bottom:1.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{border:none;border-radius:8px 8px 0 0;padding:.75rem 1.5rem;font-weight:600;color:#6c757d;background-color:transparent;transition:all .3s ease;margin-right:.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]:hover{color:#007bff;background-color:#f8f9fa;border-color:transparent}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{color:#007bff;background-color:#fff;border-color:#007bff #007bff #fff;border-width:2px 2px 0;box-shadow:0 -2px 4px #007bff1a}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:.5rem;font-size:1.1em}@media (max-width: 768px){.nav-tabs[_ngcontent-%COMP%]{flex-direction:column}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{margin-right:0;margin-bottom:.5rem;border-radius:8px;text-align:center}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{border-width:2px;border-color:#007bff}.bulk-actions[_ngcontent-%COMP%]{flex-direction:column;align-items:stretch!important}.bulk-actions[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]{margin-bottom:.5rem}.table-responsive[_ngcontent-%COMP%]{font-size:.875rem}}.btn[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.modal-header.bg-danger[_ngcontent-%COMP%]{background-color:#dc3545!important}.modal-header.bg-success[_ngcontent-%COMP%]{background-color:#198754!important}.table[_ngcontent-%COMP%]   thead[_ngcontent-%COMP%]   th[_ngcontent-%COMP%]   .form-check-input[_ngcontent-%COMP%], .table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]   .form-check-input[_ngcontent-%COMP%]{margin:0}"]})}return l})();function Gn(l,f){if(l&1&&(r(0,"div",22)(1,"form",23)(2,"div",8)(3,"div",24),c(4,"input",25),r(5,"label",26),c(6,"i",27),o(7," Supplier Form "),n()(),r(8,"div",24),c(9,"input",28),r(10,"label",29),c(11,"i",30),o(12," Staff Form "),n()()()()()),l&2){let e=g();d(),p("formGroup",e.formTypeForm)}}var fi=(()=>{class l{router;route;fb;formTypeForm;isCreateRoute=!1;constructor(e,i,t){this.router=e,this.route=i,this.fb=t,this.formTypeForm=this.fb.group({formType:["supplier"]})}ngOnInit(){this.checkRoute(),this.router.events.pipe(it(e=>e instanceof Zt)).subscribe(()=>{this.checkRoute()}),this.formTypeForm.get("formType")?.valueChanges.subscribe(e=>{this.isCreateRoute&&this.router.navigate(["create",e],{relativeTo:this.route})})}checkRoute(){if(this.isCreateRoute=this.router.url.includes("/create"),this.isCreateRoute){let e=this.router.url.split("/"),i=e[e.length-1];i==="supplier"||i==="staff"?this.formTypeForm.patchValue({formType:i},{emitEvent:!1}):this.formTypeForm.patchValue({formType:"supplier"},{emitEvent:!1})}}static \u0275fac=function(i){return new(i||l)(D(ne),D(ut),D(be))};static \u0275cmp=q({type:l,selectors:[["app-supplier-form-parent"]],decls:31,vars:1,consts:[[1,"container-fluid","flex-grow","py-2"],[1,"card","shadow-sm","mb-2"],[1,"card-header","bg-primary","text-white","py-2"],[1,"mb-0"],[1,"fa","fa-folder-open","me-2"],[1,"card-body"],[1,"nav","nav-pills","mb-2","bg-light","p-1","rounded","d-flex","justify-content-between","align-items-center"],[1,"d-flex","flex-column"],[1,"d-flex"],["routerLink","create","routerLinkActive","active",1,"nav-link","d-inline-block"],[1,"fa","fa-plus-circle","me-1"],["routerLink","drafts","routerLinkActive","active",1,"nav-link","d-inline-block"],[1,"fa","fa-file-text-o","me-1"],["routerLink","publish","routerLinkActive","active",1,"nav-link","d-inline-block"],[1,"fa","fa-upload","me-1"],["routerLink","cheque","routerLinkActive","active",1,"nav-link","d-inline-block"],[1,"fa","fa-money-check","me-1"],["routerLink","all-approved","routerLinkActive","active",1,"nav-link","d-inline-block"],[1,"fa","fa-check-circle","me-1"],["class","mt-2",4,"ngIf"],["routerLink","config","routerLinkActive","active",1,"nav-link","d-inline-block"],[1,"fa","fa-cog","me-1"],[1,"mt-2"],[3,"formGroup"],[1,"form-check"],["type","radio","name","formType","id","supplierForm","formControlName","formType","value","supplier",1,"form-check-input"],["for","supplierForm",1,"form-check-label"],[1,"fa","fa-file-alt","me-2"],["type","radio","name","formType","id","staffForm","formControlName","formType","value","staff",1,"form-check-input"],["for","staffForm",1,"form-check-label"],[1,"fa","fa-user-tie","me-2"]],template:function(i,t){i&1&&(r(0,"div",0)(1,"div",1)(2,"div",2)(3,"h5",3),c(4,"i",4),o(5,"Form Management"),n()(),r(6,"div",5)(7,"nav",6)(8,"div",7)(9,"div",8)(10,"a",9),c(11,"i",10),o(12,"CREATE FORM"),n(),r(13,"a",11),c(14,"i",12),o(15,"DRAFTS"),n(),r(16,"a",13),c(17,"i",14),o(18,"PUBLISH"),n(),r(19,"a",15),c(20,"i",16),o(21,"CHEQUE"),n(),r(22,"a",17),c(23,"i",18),o(24,"ALL APPROVED"),n()(),_(25,Gn,13,1,"div",19),n(),r(26,"div")(27,"a",20),c(28,"i",21),o(29,"Config"),n()()(),c(30,"router-outlet"),n()()()),i&2&&(d(25),p("ngIf",t.isCreateRoute))},dependencies:[W,ce,De,Te,fe,j,Kt,H,me,he,ge],styles:[".container-fluid[_ngcontent-%COMP%]{padding:10px}.card[_ngcontent-%COMP%]{border:none;border-radius:8px;box-shadow:0 2px 4px #0000001a}.card-header[_ngcontent-%COMP%]{border-radius:8px 8px 0 0!important;border-bottom:none;padding:.5rem 1rem}.card-body[_ngcontent-%COMP%]{padding:1rem}.nav-pills[_ngcontent-%COMP%]{border-radius:8px;overflow:hidden}.nav-pills[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{border-radius:4px;margin:0 2px;padding:.5rem 1rem;font-weight:600;font-size:.9rem;transition:all .3s ease;color:#495057;border:2px solid transparent}.nav-pills[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]:hover{background-color:#e9ecef;color:#007bff;transform:translateY(-1px)}.nav-pills[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{background-color:#007bff;color:#fff;border-color:#007bff;box-shadow:0 2px 4px #007bff4d}.nav-pills[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]:hover{background-color:#0056b3;border-color:#0056b3}.nav-pills[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:.5rem;font-size:1.1em}@media (max-width: 768px){.nav-pills[_ngcontent-%COMP%]{flex-direction:column}.nav-pills[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{margin:2px 0;text-align:center}.card-body[_ngcontent-%COMP%]{padding:1.5rem}}.nav-pills[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_pulse .3s ease-in-out}@keyframes _ngcontent-%COMP%_pulse{0%{transform:scale(1)}50%{transform:scale(1.05)}to{transform:scale(1)}}"]})}return l})();var hi=(l,f)=>({display:l,background:f});function jn(l,f){if(l&1&&(r(0,"span",35),o(1),n()),l&2){let e=g();d(),A("",e.getSelectedFormsCount()," selected")}}function Hn(l,f){l&1&&c(0,"span",36)}function Zn(l,f){l&1&&c(0,"i",37)}function Qn(l,f){l&1&&(r(0,"div",38)(1,"div",39)(2,"span",40),o(3,"Loading..."),n()()())}function Kn(l,f){if(l&1&&(r(0,"div",41),o(1),n()),l&2){let e=g();d(),w(e.publishedError)}}function Xn(l,f){if(l&1&&(r(0,"span",62),o(1),n()),l&2){let e=g(2).$implicit;d(),w(e.chequeNo)}}function Jn(l,f){if(l&1){let e=I();r(0,"div",70),_(1,Xn,2,1,"span",71),r(2,"button",72),b("click",function(){x(e);let t=g().$implicit,a=g(2);return S(a.openEditChequeNoModal(t))}),c(3,"i",73),n()()}if(l&2){let e=g().$implicit,i=g(2);d(),p("ngIf",e.chequeNo),d(),p("disabled",i.editingChequeNo)}}function er(l,f){l&1&&(r(0,"span",27),o(1,"-"),n())}function tr(l,f){if(l&1){let e=I();r(0,"tr")(1,"td",60)(2,"input",61),b("change",function(t){let a=x(e).$implicit,s=g(2);return S(s.toggleFormSelection(a,t))}),n()(),r(3,"td",60),o(4),n(),r(5,"td"),o(6),n(),r(7,"td",62),o(8),n(),r(9,"td",62),o(10),L(11,"date"),n(),r(12,"td",60)(13,"button",63),b("click",function(){let t=x(e).$implicit,a=g(2);return S(a.openParticularsModal(t.particulars))}),c(14,"i",64),n()(),r(15,"td",65),o(16),L(17,"number"),n(),r(18,"td",65),o(19),L(20,"number"),n(),r(21,"td",65),o(22),n(),r(23,"td",65),o(24),L(25,"number"),n(),r(26,"td",65),o(27),L(28,"number"),n(),r(29,"td",65),o(30),L(31,"number"),n(),r(32,"td",65),o(33),L(34,"number"),n(),r(35,"td",60)(36,"span",66),o(37),n()(),r(38,"td",60),_(39,Jn,4,2,"div",67)(40,er,2,0,"span",68),n(),r(41,"td",60)(42,"span",69),o(43),n()()()}if(l&2){let e=f.$implicit,i=f.index,t=g(2);re("table-primary",t.isFormSelected(e)),d(2),p("checked",t.isFormSelected(e)),d(2),w(i+1),d(2),w(e.supplierName||"N/A"),d(2),w(e.billNo||"N/A"),d(2),w(B(11,20,e.date,"dd-MM-yyyy")),d(6),w(e.billValue?B(17,23,e.billValue,"1.0-0"):"0"),d(3),w(e.billValueGst?B(20,26,e.billValueGst,"1.0-0"):"0"),d(3),w(t.formatTdsDisplay(e.tds)),d(2),w(e.tdsAmount?B(25,29,e.tdsAmount,"1.0-0"):"0"),d(3),w(e.amount?B(28,32,e.amount,"1.0-0"):"0"),d(3),w(e.advance?B(31,35,e.advance,"1.0-0"):"0"),d(3),w(e.chequeAmount?B(34,38,e.chequeAmount,"1.0-0"):"0"),d(3),p("ngClass",t.getStageBadgeClass(e)),d(),A(" ",t.getCurrentApprovalStage(e)," "),d(2),p("ngIf",t.canEditChequeNo(e)),d(),p("ngIf",!t.canEditChequeNo(e)),d(2),p("ngClass",t.getTypeBadgeClass(e)),d(),A(" ",t.getTypeDisplay(e)," ")}}function ir(l,f){if(l&1){let e=I();r(0,"div",42)(1,"table",43)(2,"thead",44)(3,"tr")(4,"th",45)(5,"input",46),b("
284change",function(t){x(e);let a=g();return S(a.toggleSelectAll(t))}),n()(),r(6,"th",45),o(7,"#"),n(),r(8,"th",47),o(9,"Supplier Name"),n(),r(10,"th",48),o(11,"Bill No."),n(),r(12,"th",49),o(13,"Date"),n(),r(14,"th",50),o(15,"Particulars"),n(),r(16,"th",51),o(17,"Bill Value"),n(),r(18,"th",51),o(19,"Bill Value Before GST"),n(),r(20,"th",52),o(21,"TDS"),n(),r(22,"th",53),o(23,"TDS Amt"),n(),r(24,"th",53),o(25,"Amount"),n(),r(26,"th",53),o(27,"Advance"),n(),r(28,"th",53),o(29,"Cheque Amt"),n(),r(30,"th",54),o(31,"Approval Stage"),n(),r(32,"th",55),o(33,"Cheque No"),n(),r(34,"th",54),o(35,"TYPE"),n()()(),r(36,"tbody"),_(37,tr,44,41,"tr",56),n()(),r(38,"div",57)(39,"button",58),b("click",function(){x(e);let t=g();return S(t.publishedPrevPage())}),o(40,"\xAB Prev"),n(),r(41,"span"),o(42),n(),r(43,"button",59),b("click",function(){x(e);let t=g();return S(t.publishedNextPage())}),o(44,"Next \xBB"),n()()()}if(l&2){let e=g();d(5),p("checked",e.allSelected)("indeterminate",e.getSelectedFormsCount()>0&&e.getSelectedFormsCount()<e.publishedForms.length),d(32),p("ngForOf",e.publishedForms),d(2),p("disabled",e.isPublishedPrevDisabled()),d(3),A("Page ",e.publishedPageNumber,""),d(),p("disabled",e.isPublishedNextDisabled())}}function nr(l,f){if(l&1&&(r(0,"div",74),o(1," No published forms available. "),r(2,"small",75),o(3),n()()),l&2){let e=g();d(3),st("(Loading: ",e.publishedLoading,", Count: ",(e.publishedForms==null?null:e.publishedForms.length)||0,")")}}function rr(l,f){l&1&&c(0,"span",83)}function ar(l,f){l&1&&c(0,"i",37)}function or(l,f){if(l&1){let e=I();r(0,"div",76)(1,"div",77)(2,"div",16)(3,"div",78)(4,"h5",79),o(5,"Confirm Delete"),n(),r(6,"button",80),b("click",function(){x(e);let t=g();return S(t.closeDeleteConfirmModal())}),n()(),r(7,"div",20)(8,"p"),o(9," Are you sure you want to delete "),r(10,"strong"),o(11),n(),o(12," selected pending supplier form(s)? "),n(),r(13,"p",81)(14,"small"),o(15,"This action cannot be undone."),n()()(),r(16,"div",28)(17,"button",29),b("click",function(){x(e);let t=g();return S(t.closeDeleteConfirmModal())}),o(18," Cancel "),n(),r(19,"button",82),b("click",function(){x(e);let t=g();return S(t.confirmDeleteSelected())}),_(20,rr,1,0,"span",31)(21,ar,1,0,"i",8),o(22," Delete "),n()()()()()}if(l&2){let e=g();p("ngStyle",Ze(7,hi,e.showDeleteConfirmModal?"block":"none",e.showDeleteConfirmModal?"rgba(0,0,0,0.5)":"none")),d(6),p("disabled",e.deleting),d(5),w((e.deleteTargets==null?null:e.deleteTargets.length)||0),d(6),p("disabled",e.deleting),d(2),p("disabled",e.deleting),d(),p("ngIf",e.deleting),d(),p("ngIf",!e.deleting)}}function lr(l,f){l&1&&c(0,"span",83)}function sr(l,f){l&1&&c(0,"i",84)}function dr(l,f){l&1&&c(0,"div",85)}function pr(l,f){if(l&1){let e=I();r(0,"div",86)(1,"div",87)(2,"div",16)(3,"div",78)(4,"h5",79),o(5,"Particulars"),n(),r(6,"button",19),b("click",function(){x(e);let t=g();return S(t.closeParticularsModal())}),n()(),r(7,"div",20)(8,"p"),o(9),n()(),r(10,"div",28)(11,"button",88),b("click",function(){x(e);let t=g();return S(t.closeParticularsModal())}),o(12,"Close"),n()()()()()}if(l&2){let e=g();p("ngStyle",Ze(2,hi,e.viewParticularsText?"block":"none",e.viewParticularsText?"rgba(0,0,0,0.5)":"none")),d(9),w(e.viewParticularsText)}}var gi=(()=>{class l{supplierFormService;requestFormService;toastr;fileUploadService;cdr;publishedForms=[];publishedLoading=!1;publishedError="";publishedPageNumber=1;publishedPageSize=100;filterSupplierName="";viewParticularsText=null;selectedForms=new Set;allSelected=!1;signatureLoadingStates={dean:!1,registrar:!1,president:!1};signatureCache=new Map;deleting=!1;showDeleteConfirmModal=!1;deleteTargets=[];constructor(e,i,t,a,s){this.supplierFormService=e,this.requestFormService=i,this.toastr=t,this.fileUploadService=a,this.cdr=s}ngOnInit(){this.fetchPublishedForms()}formatTdsDisplay(e){if(e==null||e==="")return"0";let i=parseFloat(e);return isNaN(i)?"0":Number.isInteger(i)?String(i):i.toFixed(2).replace(/\.?0+$/,"")}fetchPublishedForms(){this.publishedLoading=!0,this.publishedError="";let e=(this.publishedPageNumber-1)*this.publishedPageSize;this.supplierFormService.getPendingRequestForms().then(i=>{console.log("=== PUBLISH VIEW DEBUG START ==="),console.log("Raw API response:",i),console.log("Response type:",typeof i),console.log("Is array?",Array.isArray(i));let t=Array.isArray(i)?i:[];console.log("Parsed data array length:",t.length),t.length===0&&
284console.warn("No data in response array!");let a=[];t.forEach((s,m)=>{let u=s._id||s.id;if(console.log(`
285--- Processing requestForm ${m} ---`),console.log("Full requestForm object:",s),console.log("Keys in requestForm:",Object.keys(s)),console.log("_id:",s._id),console.log("id:",s.id),console.log("requestFormId (resolved):",u),console.log("requestType:",s.requestType),console.log("submissionStatus:",s.submissionStatus),console.log("hasFormData:",!!s.formData),console.log("formData value:",s.formData),console.log("formData type:",typeof s.formData),console.log("hasViews:",!!s.views),console.log("views value:",s.views),!u){console.warn(`\u274C RequestForm ${m} missing both _id and id, skipping. Full object:`,s);return}if(s.requestType!=="SUPPLIER"){console.log(`\u274C Skipping non-SUPPLIER request type: ${s.requestType}`);return}let h=s.formData;if(!h){console.warn(`\u274C RequestForm ${u} has no formData!`),console.warn("Available fields:",Object.keys(s));return}console.log("\u2705 Processing supplierForm from formData..."),Array.isArray(h)?(console.log(`  \u2192 formData is array with ${h.length} items`),h.forEach((v,E)=>{console.log(`  \u2192 Processing array item ${E}:`,v),a.push(N(T({},v),{requestFormId:u,submissionStatus:s.submissionStatus,approvalType:s.approvalType,approvalLevels:s.approvalLevels,supplierName:s.views?.supplierName||v.supplierName||"N/A"}))})):(console.log("  \u2192 formData is single object:",h),a.push(N(T({},h),{requestFormId:u,submissionStatus:s.submissionStatus,approvalType:s.approvalType,approvalLevels:s.approvalLevels,supplierName:s.views?.supplierName||h.supplierName||"N/A"}))),console.log(`  \u2705 Added to pendingSupplierForms. Total now: ${a.length}`)}),this.filterSupplierName&&(a=a.filter(s=>s.supplierName&&s.supplierName.toLowerCase().includes(this.filterSupplierName.toLowerCase()))),console.log(`
286=== BEFORE ASSIGNING TO publishedForms ===`),console.log("pendingSupplierForms length:",a.length),console.log("pendingSupplierForms:",a),this.publishedForms=a.map((s,m)=>N(T({},s),{uniqueId:`${s._id||s.id||s.requestFormId}_${m}`})),this.selectedForms.clear(),this.allSelected=!1,console.log(`
287=== FINAL SUMMARY ===`),console.log("Total request forms from API:",t.length),console.log("Forms with supplierForm extracted:",a.length),console.log("Final published forms count:",this.publishedForms.length),console.log("publishedForms array:",this.publishedForms),console.log("publishedLoading will be set to:",!1),this.cdr.detectChanges(),console.log("Change detection triggered"),console.log(`=== PUBLISH VIEW DEBUG END ===
288`)}).catch(i=>{console.error("\u274C ERROR fetching published forms:",i),this.publishedError="Failed to load published supplier forms.",this.publishedLoading=!1}).finally(()=>{console.log("\u2705 Finally block: Setting publishedLoading to false"),this.publishedLoading=!1,console.log("\u2705 publishedLoading is now:",this.publishedLoading),console.log("\u2705 publishedForms.length is now:",this.publishedForms.length)})}onFilterChange(){this.publishedPageNumber=1,this.fetchPublishedForms()}publishedNextPage(){this.publishedForms.length===this.publishedPageSize&&(this.publishedPageNumber++,this.fetchPublishedForms())}publishedPrevPage(){this.publishedPageNumber>1&&(this.publishedPageNumber--,this.fetchPublishedForms())}isPublishedPrevDisabled(){return this.publishedPageNumber<=1}isPublishedNextDisabled(){return this.publishedForms.length<this.publishedPageSize}getTypeDisplay(e){return e.approvalType==="NONE"?"Normal form":e.approvalType==="PRE_APPROVED"?"Pre_approval form":e.approvalType==="WITHOUT_CHEQUE"?"Without cheque":"Unknown"}getTypeBadgeClass(e){return e.approvalType==="NONE"?"bg-info":e.approvalType==="PRE_APPROVED"?"bg-warning":(e.approvalType==="WITHOUT_CHEQUE","bg-secondary")}isFinalStageOnly(e){return e?.approvalType==="PRE_APPROVED"||e?.approvalType==="WITHOUT_CHEQUE"}requiresCheque(e){return e?.approvalType!=="WITHOUT_CHEQUE"}isStage1Complete(e){return!e.approvalLevels||e.approvalLevels.length===0||this.isFinalStageOnly(e)?!1:e.approvalLevels.every(i=>{let t=i.eSignature?.preApprovedSignature;return t&&(t.url||t.fileKey&&t.versionId)})}getCurrentApprovalStage(e){if(!e.approvalLevels||e.approvalLevels.length===0)return"N/A";if(e.approvalType==="WITHOUT_CHEQUE")return e.approvalLevels.every(s=>{let m=s.eSignature?.finalApprovalSignature;
288return m&&(m.url||m.fileKey&&m.versionId)})?"Approved (no cheque)":"Final approval (no cheque)";let i=this.isStage1Complete(e),t=e.chequeNo&&e.chequeNo.trim().length>0;return i&&t?"Stage 2: Cheque Approved":i?"Stage 1 Complete - Add Cheque No":"Stage 1: Amount Estimate Approved"}getStageBadgeClass(e){let i=this.getCurrentApprovalStage(e);return i.includes("Stage 2")?"bg-success":i.includes("Stage 1 Complete")?"bg-warning":i.includes("Stage 1")?"bg-primary":"bg-secondary"}canEditChequeNo(e){return e.approvalType==="WITHOUT_CHEQUE"?!1:e.approvalType==="PRE_APPROVED"?!0:this.isStage1Complete(e)}showEditChequeNoModal=!1;selectedFormForChequeNo=null;chequeNoInput="";editingChequeNo=!1;openEditChequeNoModal(e){this.selectedFormForChequeNo=e,this.chequeNoInput=e.chequeNo||"",this.showEditChequeNoModal=!0}closeEditChequeNoModal(){this.showEditChequeNoModal=!1,this.selectedFormForChequeNo=null,this.chequeNoInput=""}saveChequeNo(){if(!this.selectedFormForChequeNo||!this.chequeNoInput||this.chequeNoInput.trim().length===0){this.toastr.warning("Please enter a valid Cheque No.");return}let e=this.selectedFormForChequeNo,i=e.requestFormId;if(!i){console.error("RequestFormId is missing:",e),this.toastr.error("Unable to update: Request Form ID is missing. Please refresh the page and try again.");return}this.editingChequeNo=!0;let y=e,{submissionStatus:t,approvalType:a,approvalLevels:s,supplierName:m,uniqueId:u}=y,h=tt(y,["submissionStatus","approvalType","approvalLevels","supplierName","uniqueId"]);h.chequeNo=this.chequeNoInput.trim();let v={supplierForm:h,formData:h},E=e.approvalType==="PRE_APPROVED";console.log("Updating cheque no:",{requestFormId:i,updatePayload:v,isPreApproved:E}),this.requestFormService.updateRequestForm(i,v).then(()=>{e.chequeNo=this.chequeNoInput.trim(),this.toastr.success("Cheque No updated successfully!"),E?this.toastr.info("Form is now ready for final approval. Please go to Form Approval page to e-sign.","Pre-Approval Ready"):this.toastr.info("Form is now ready for Stage 2 (Final Approval). Please go to Form Approval page - Cheque tab to e-sign.","Stage 2 Ready"),this.closeEditChequeNoModal(),this.fetchPublishedForms()}).catch(F=>{console.error("Error updating cheque no:",F),this.toastr.error("Failed to update Cheque No. Please try again.")}).finally(()=>{this.editingChequeNo=!1})}openParticularsModal(e){this.viewParticularsText=e}closeParticularsModal(){this.viewParticularsText=null}toggleSelectAll(e){e.target.checked?(this.selectedForms=new Set(this.publishedForms.map(i=>i.uniqueId)),this.allSelected=!0):(this.selectedForms.clear(),this.allSelected=!1)}toggleFormSelection(e,i){let t=e.uniqueId;console.log("Toggling form selection:",{formId:t,supplierName:e.supplierName,billNo:e.billNo,checked:i.target.checked,currentSelection:Array.from(this.selectedForms)}),i.target.checked?this.selectedForms.add(t):this.selectedForms.delete(t),this.allSelected=this.selectedForms.size===this.publishedForms.length,console.log("After toggle:",{selectedCount:this.selectedForms.size,totalForms:this.publishedForms.length,allSelected:this.allSelected,currentSelection:Array.from(this.selectedForms)})}isFormSelected(e){let i=e.uniqueId;return this.selectedForms.has(i)}getSelectedFormsCount(){return this.selectedForms.size}deleteSelected(){let e=this.publishedForms.filter(i=>this.selectedForms.has(i.uniqueId));e.length!==0&&(this.deleteTargets=e,this.showDeleteConfirmModal=!0)}closeDeleteConfirmModal(){this.deleting||(this.showDeleteConfirmModal=!1,this.deleteTargets=[])}confirmDeleteSelected(){if(!this.deleteTargets||this.deleteTargets.length===0){this.showDeleteConfirmModal=!1;return}this.deleting=!0;let i=this.deleteTargets.map(t=>t.requestFormId).filter(t=>!!t).map(t=>this.requestFormService.deleteRequestForm(t));Promise.allSettled(i).then(t=>{let a=t.filter(m=>m.status==="fulfilled").length,s=t.length-a;a>0&&this.toastr.success(`${a} form(s) deleted.`,"Deleted"),s>0&&this.toastr.error(`${s} form(s) failed to delete.`,"Error"),this.fetchPublishedForms(),this.selectedForms.clear(),this.allSelected=!1}).finally(()=>{this.deleting=!1,this.showDeleteConfirmModal=!1,this.deleteTargets=[]})}printSelectedForApproval(){return M(this,null,function*(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to print.","No Selection");return}let e=this.publishedForms.filter(u=>this.selectedForms.has(u.uniqueId));this.toastr.info("Preparing document and loading signatures...","Generating Print Document");let t=e[0]?.approvalLevels||[],a=yield this.loadAllSignaturesInParallel(t),s=window.open("","_blank");if(!s){this.toastr.error("Please allow popups to print the document.","Error");return}let m=this.generateApprovalPrintContent(e,a);s.document.write(`
289      <!DOCTYPE html>
290      <html>
291        <head>
292          <title>Supplier Forms - Approval Evidence</title>
293          <style>
294            body {
295              font-family: Arial, sans-serif;
296              margin: 15px;
297              padding: 0;
298              font-size: 12px;
299              color: #000;
300            }
301            .header { 
302              text-align: center; 
303            }
304            .logo-container {
305
306            }
307            .logo {
308               max-width: 300px;
309               height: 120px;
310               margin: 0 auto;
311               display: block;
312               object-fit: contain;
313             }
314            .document-title {
315              font-size: 20px;
316              font-weight: bold;
317              text-align: center;
318              color: #000;
319              margin-bottom: 20px;
320            }
321            table {
322              width: 100%;
323              border-collapse: collapse;
324              margin-top: 20px;
325              border: 1px solid #000;
326              table-layout: fixed;
327            }
328            th, td {
329              border: 1px solid #000;
330              padding: 8px 6px;
331              text-align: left;
332              vertical-align: middle;
333              font-size: 12px;
334              word-break: keep-all;
335              overflow-wrap: break-word;
336              white-space: normal;
337              overflow: hidden;
338              text-overflow: ellipsis;
339            }
340            th { 
341              background-color: #f2f2f2; 
342              font-weight: bold;
343              text-align: center;
344              color: #000;
345              font-size: 12px;
346            }
347            td {
348              font-size: 14px;
349            }
350            /* Numeric values - ensure readable font size */
351            td.text-right,
352            td.amount {
353              font-size: 14px;
354            }
355            /* Ensure total row cells respect text-right class */
356            .total-row td.text-right {
357              text-align: right !important;
358            }
359            /* APPROVAL-PRINT: Sl.No(1)=3%, Supplier(2)=12%, Bill(3)=8%, Date(4)=8%, Particulars(5)=18%, BillVal(6)=8%, BillGST(7)=8%, TDS(8)=6%, TDSAmt(9)=8%, ChequeNo(10)=8%, ChequeAmt(11)=8%, ApprovedDate(12)=7% [Total=100%] */
360            table.approval-print th:nth-child(1),
361            table.approval-print td:nth-child(1) {
362              width: 3%;
363              text-align: center;
364              white-space: nowrap;
365              overflow: hidden;
366              padding: 6px 3px;
367            }
368            table.approval-print th:nth-child(2),
369            table.approval-print td:nth-child(2) {
370              width: 12%;
371              text-align: left;
372              word-break: keep-all;
373              overflow-wrap: break-word;
374              padding: 6px 4px;
375            }
376            table.approval-print th:nth-child(3),
377            table.approval-print td:nth-child(3) {
378              width: 8%;
379              text-align: left;
380              white-space: nowrap;
381              overflow: hidden;
382              padding: 6px 3px;
383            }
384            table.approval-print th:nth-child(4),
385            table.approval-print td:nth-child(4) {
386              width: 8%;
387              text-align: center;
388              white-space: nowrap;
389              overflow: hidden;
390              padding: 6px 3px;
391            }
392            table.approval-print th:nth-child(5),
393            table.approval-print td:nth-child(5) {
394              width: 18%;
395              word-break: keep-all;
396              overflow-wrap: break-word;
397              padding: 6px 4px;
398            }
399            table.approval-print th:nth-child(5) {
400              text-align: center;
401            }
402            table.approval-print td:nth-child(5) {
403              text-align: left;
404            }
405            table.approval-print th:nth-child(6),
406            table.approval-print td:nth-child(6) {
407              width: 8%;
408              text-align: right;
409              white-space: nowrap;
410              overflow: hidden;
411              padding: 6px 4px;
412            }
413            table.approval-print th:nth-child(7),
414            table.approval-print td:nth-child(7) {
415              width: 8%;
416              text-align: right;
417              white-space: nowrap;
418              overflow: hidden;
419              padding: 6px 4px;
420            }
421            table.approval-print th:nth-child(8),
422            table.approval-print td:nth-child(8) {
423              width: 6%;
424              text-align: center;
425              white-space: nowrap;
426              overflow: hidden;
427              padding: 6px 3px;
428            }
429            table.approval-print th:nth-child(9),
430            table.approval-print td:nth-child(9) {
431              width: 8%;
432              text-align: right;
433              white-space: nowrap;
434              overflow: hidden;
435              padding: 6px 4px;
436            }
437            table.approval-print th:nth-child(10),
438            table.approval-print td:nth-child(10) {
439              width: 8%;
440              text-align: center;
441              white-space: nowrap;
442              overflow: hidden;
443              padding: 6px 3px;
444            }
445            table.approval-print th:nth-child(11),
446            table.approval-print td:nth-child(11) {
447              width: 8%;
448              text-align: right;
449              white-space: nowrap;
450              overflow: hidden;
451              padding: 6px 4px;
452            }
453            table.approval-print th:nth-child(12),
454            table.approval-print td:nth-child(12) {
455              width: 7%;
456              text-align: center;
457              white-space: nowrap;
458              overflow: hidden;
459              padding: 6px 3px;
460            }
461            .text-center { text-align: center; }
462            .text-right { text-align: right !important; }
463            .amount { font-weight: bold; }
464            .total-row {
465              background-color: #fff;
466              font-weight: bold;
467            }
468            .total-row td {
469              font-size: 14px;
470            }
471            .amount-in-words {
472              margin-top: 20px;
473              padding: 10px;
474              background-color: #f9f9f9;
475              border: 1px solid #ccc;
476              text-align: center;
477              font-weight: bold;
478              color: #000;
479              font-size: 14px;
480            }
481            .signature-section {
482              margin-top: 40px;
483              display: flex;
484              justify-content: space-between;
485            }
486            .signature-box {
487              text-align: center;
488              width: 200px;
489              border: none;
490              padding: 10px;
491              margin: 5px;
492            }
493            .signature-title {
494              font-weight: bold;
495              margin-bottom: 10px;
496              font-size: 12px;
497              border-bottom: 1px solid #000;
498              padding-bottom: 5px;
499              color: #000;
500            }
501            .signature-image {
502              margin: 0;
503              padding: 0;
504              display: flex;
505              align-items: center;
506              justify-content: center;
507              width: 180px;
508              height: 80px;
509            }
510            .e-signature {
511              width: 180px;
512              height: 80px;
513              object-fit: cover;
514              border: none;
515              background: transparent;
516              padding: 0;
517              margin: 0;
518            }
519            .signature-placeholder {
520              margin: 10px 0;
521              min-height: 90px;
522              display: flex;
523              align-items: center;
524              justify-content: center;
525            }
526            .signature-line {
527              width: 150px;
528              height: 1px;
529              border-bottom: 1px solid #333;
530              margin: 0 auto;
531            }
532            .print-button {
533              position: fixed;
534              top: 20px;
535              right: 20px;
536              background-color: #007bff;
537              color: white;
538              border: none;
539              padding: 10px 20px;
540              border-radius: 5px;
541              cursor: pointer;
542              font-size: 14px;
543              font-weight: bold;
544              box-shadow: 0 2px 5px rgba(0,0,0,0.2);
545              z-index: 1000;
546            }
547            .print-button:hover {
548              background-color: #0056b3;
549            }
550            .generated-on {
551              position: fixed;
552              top: 60px;
553              right: 20px;
554              color: #555;
555              font-size: 12px;
556              background: rgba(255,255,255,0.9);
557              padding: 4px 8px;
558              border: 1px solid #ddd;
559              border-radius: 4px;
560              z-index: 999;
561            }
562            /* Page number styling */
563            .page-number {
564              position: fixed;
565              top: 10px;
566              right: 20px;
567              font-size: 12px;
568              font-weight: bold;
569              color: #333;
570              z-index: 1000;
571              background: rgba(255, 255, 255, 0.9);
572              padding: 4px 8px;
573              border-radius: 4px;
574            }
575            @media print {
576              body {
577                margin: 0;
578                padding: 10mm;
579                font-size: 13px;
580              }
581              .no-print { display: none; }
582              .print-button { display: none; }
583              .generated-on { display: none; }
584              .page-number { display: none; }
585              .logo {
586                max-width: 250px !important;
587                height: 90px !important;
588              }
589              table {
590                width: 100% !important;
591                table-layout: fixed !important;
592                font-size: 13px;
593                margin-top: 15px;
594              }
595              th, td {
596                font-size: 13px;
597                padding: 5px 3px !important;
598                word-break: keep-all !important;
599                overflow-wrap: break-word !important;
600                white-space: normal !important;
601                overflow: hidden !important;
602                text-overflow: ellipsis !important;
603              }
604              tbody tr {
605                page-break-inside: avoid;
606              }
607              .total-row {
608                page-break-inside: avoid;
609              }
610              @page {
611                size: landscape;
612                margin: 10mm;
613              }
614            }
615          </style>
616        </head>
617        <body>
618          <button class="print-button" onclick="window.print()">\u{1F5A8}\uFE0F Print Document</button>
619          <div class="page-number no-print">Page 1</div>
620          ${m}
621        </body>
622      </html>
623    `),s.document.close(),s.focus()})}generateApprovalPrintContent(e,i=null){let t=e.some(E=>{let y=this.getApprovalInfo(E.approvalLevels||[],"PRESIDENT")||this.getApprovalInfo(E.approvalLevels||[],"PRESIDENTADMIN");return!!E.approvedDate||y&&y.status==="APPROVED"&&!!y.actionDate}),a=0,s=0,m=0,u=0,h="";e.forEach((E,y)=>{let F=E.billValue||0,k=E.billValueGst||0,V=E.tdsAmount||0,Y=E.chequeAmount||0,O=E.date?new Date(E.date).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}).replace(/\//g,"-"):"N/A",C=this.getApprovalInfo(E.approvalLevels||[],"PRESIDENT")||this.getApprovalInfo(E.approvalLevels||[],"PRESIDENTADMIN"),ae=null;E.approvedDate?ae=E.approvedDate:C&&C.status==="APPROVED"&&C.actionDate&&(
623ae=C.actionDate);let ke="";if(ae)try{let Ae=new Date(ae);isNaN(Ae.getTime())||(ke=Ae.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}).replace(/\//g,"-"))}catch(Ae){console.error("Error parsing date:",Ae)}a+=F,s+=k,m+=V,u+=Y,h+=`
624        <tr>
625          <td class="text-center">${y+1}</td>
626          <td>${E.supplierName||"N/A"}</td>
627          <td>${E.billNo||"N/A"}</td>
628          <td class="text-center" style="white-space: nowrap;">${O}</td>
629          <td>${E.particulars||"N/A"}</td>
630          <td class="text-right amount">${F}</td>
631          <td class="text-right">${k}</td>
632          <td class="text-right">${this.formatTdsDisplay(E.tds)}</td>
633          <td class="text-right">${V}</td>
634          <td class="text-center">${E.chequeNo||"N/A"}</td>
635          <td class="text-right amount">${Y}</td>
636          ${t?`<td class="text-center" style="white-space: nowrap;">${ke}</td>`:""}
637        </tr>
638      `});let v=this.numberToWords(u);return i=i||{dean:null,registrar:null,president:null},`
639      <div class="header">
640        <div class="logo-container">
641          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
642        </div>
643      </div>
644      
645      <div class="document-title">
646        Submitted to the Approval of the President
647      </div>
648      
649      <table class="approval-print">
650        <thead>
651          <tr>
652            <th class="text-center">Sl.No.</th>
653            <th class="text-center">Name of the<br>Company/Supplier</th>
654            <th class="text-center">Inv./<br>Bill No.</th>
655            <th class="text-center">Date</th>
656            <th class="text-center">Particulars</th>
657            <th class="text-right">Total Bill<br>Value \u20B9</th>
658            <th class="text-right">Bill Value<br>before GST \u20B9</th>
659            <th class="text-center">TDS @</th>
660            <th class="text-right">TDS<br>Amount \u20B9</th>
661            <th class="text-center">Cheque<br>No</th>
662            <th class="text-right">Cheque<br>Amount \u20B9</th>
663            ${t?'<th class="text-center">Approved<br>Date</th>':""}
664          </tr>
665        </thead>
666        <tbody>
667          ${h}
668          <tr class="total-row">
669            <td colspan="5" class="text-center"><strong>Total \u20B9</strong></td>
670            <td class="text-right" style="text-align: right !important;"><strong>${a}</strong></td>
671            <td class="text-right" style="text-align: right !important;"><strong>${s}</strong></td>
672            <td></td>
673            <td class="text-right" style="text-align: right !important;"><strong>${m}</strong></td>
674            <td></td>
675            <td class="text-right" style="text-align: right !important;"><strong>${u}</strong></td>
676             ${t?"<td></td>":""}
677          </tr>
678        </tbody>
679      </table>
680      
681      <div class="amount-in-words">
682        (Rupees ${v} only)
683      </div>
684      
685      ${t?`
686      <div class="signature-section">
687        <div class="signature-box">
688          ${this.getSignatureHtmlFromUrl(i.dean,"Dean Signature")}
689          <div class="signature-title">DEAN-STUDENT AFFAIRS</div>
690        </div>
691        <div class="signature-box">
692          ${this.getSignatureHtmlFromUrl(i.registrar,"Registrar Signature")}
693          <div class="signature-title">REGISTRAR</div>
694        </div>
695        <div class="signature-box">
696          ${this.getSignatureHtmlFromUrl(i.president,"President Signature")}
697          <div class="signature-title">PRESIDENT</div>
698        </div>
699      </div>`:""}
700
701    `}getApprovalInfo(e,i){if(!e||e.length===0)return null;let t=i.toUpperCase().trim(),a=e.find(s=>{if(!s)return!1;let m=(s.role||"").toString().toUpperCase().trim(),u=(s.roles||"").toString().toUpperCase().trim(),h=(s.label||"").toString().toUpperCase().trim();return m===t||u===t||h===t||m.includes(t)||t.includes(m)||t.includes("PRESIDENT")&&(m.includes("PRESIDENT")||h.includes("PRESIDENT"))||t.includes("DEAN")&&(m.includes("DEAN")||h.includes("DEAN"))||t.includes("REGISTRAR")&&(m.includes("REGISTRAR")||h.includes("REGISTRAR"))});return a?{status:a.status||"PENDING",actionDate:a.actionDate||a.approvedDate||a.date||"",approvedByName:a.approvedByName||a.name||a.approverName||i,remarks:a.remarks||"",eSignature:a.eSignature||null}:null}numberToWords(e){let i=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"],t=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"],a=["Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"];if(e===0)return"Zero";let s=u=>u===0?"":u<10?i[u]:u<20?a[u-10]:u<100?t[Math.floor(u/10)]+(u%10!==0?" "+i[u%10]:""):u<1e3?i[Math.floor(u/100)]+" Hundred"+(u%100!==0?" and "+s(u%100):""):"";return(u=>{if(u===0)return"Zero";let h=Math.floor(u/1e7),v=Math.floor(u%1e7/1e5),E=Math.floor(u%1e5/1e3),y=u%1e3,F="";return h>0&&(F+=s(h)+" Crore "),v>0&&(F+=s(v)+" Lakh "),E>0&&(F+=s(E)+" Thousand "),y>0&&(F+=s(y)),F.trim()})(Math.floor(e))}loadAllSignaturesInParallel(e){return M(this,null,function*(){console.log("\u{1F50D} Loading signatures in parallel. Approval levels:",e);let i=this.findAnySignature(e);console.log("\u{1F50D} Base signature found:",i);let t=this.createRoleSpecificSignature(i,"DEAN"),a=this.createRoleSpecificSignature(i,"REGISTRAR"),s=this.createRoleSpecificSignature(i,"PRESIDENT"),m=this.extractApproverSignatureData(e,"DEAN")||this.extractApproverSignatureData(e,"DEANADMIN"),u=this.extractApproverSignatureData(e,"REGISTRAR")||this.extractApproverSignatureData(e,"REGISTRARADMIN"),h=this.extractApproverSignatureData(e,"PRESIDENT")||this.extractApproverSignatureData(e,"PRESIDENTADMIN");try{console.log("\u{1F680} Starting parallel signature loading...");let[v,E,y]=yield Promise.all([this.makeIndividualApiCallWithDbData(m,"DEAN"),this.makeIndividualApiCallWithDbData(u,"REGISTRAR"),this.makeIndividualApiCallWithDbData(h,"PRESIDENT")]);return console.log("\u2705 Signature loading completed:",{deanUrl:v,registrarUrl:E,presidentUrl:y}),{dean:v,registrar:E,president:y}}catch(v){return console.error("\u274C Error loading signatures:",v),{dean:null,registrar:null,president:null}}finally{}})}extractApproverSignatureData(e,i){if(!e||e.length===0)return null;let t=i.toUpperCase().trim(),a=e.find(s=>
701{if(!s)return!1;let m=(s.role||"").toString().toUpperCase().trim(),u=(s.roles||"").toString().toUpperCase().trim(),h=(s.label||"").toString().toUpperCase().trim();return m===t||u===t||h===t||m.includes(t)||t.includes(m)||t.includes("PRESIDENT")&&(m.includes("PRESIDENT")||h.includes("PRESIDENT"))||t.includes("DEAN")&&(m.includes("DEAN")||h.includes("DEAN"))||t.includes("REGISTRAR")&&(m.includes("REGISTRAR")||h.includes("REGISTRAR"))});if(a&&a.eSignature){if(a.eSignature.preApprovedSignature){let s=a.eSignature.preApprovedSignature;if(s.url||s.versionId&&s.fileKey)return s}return a.eSignature.finalApprovalSignature?a.eSignature.finalApprovalSignature:a.eSignature}return null}makeIndividualApiCallWithDbData(e,i){return M(this,null,function*(){if(!e)return null;try{if(typeof e=="string")return e.startsWith("http")?e:null;if(e.url&&e.url.startsWith("http"))return e.url;let t,a;if(e.versionId&&e.fileKey)t=e.versionId,a=e.fileKey;else return null;let s=yield this.fileUploadService.getPreSignedUrl(t,a);return s&&s.startsWith("http")?s:null}catch(t){return console.error(`\u274C ${i}: Error getting signature URL:`,t),null}})}findAnySignature(e){for(let i of e)if(i.eSignature)return i.eSignature;return null}createRoleSpecificSignature(e,i){return e?N(T({},e),{role:i,fileKey:this.getRoleSpecificFileKey(e.fileKey,i),versionId:e.versionId+`_${i.toLowerCase()}`}):null}getRoleSpecificFileKey(e,i){if(!e)return`${i.toLowerCase()}_signature.png`;if(e==="signature.png"||e==="signature")return`${i.toLowerCase()}_signature.png`;if(e.includes(i.toLowerCase()))return e;let t=e.split(".").pop();return`${e.replace(`.${t}`,"")}_${i.toLowerCase()}.${t}`}createSignatureCacheKey(e){return typeof e=="string"?`string_${e}`:e.versionId&&e.fileKey?`file_${e.versionId}_${e.fileKey}`:e.url?`url_${e.url}`:`other_${JSON.stringify(e)}`}getSignatureHtmlFromUrl(e,i){return e?`<div class="signature-image">
702        <img src="${e}" alt="${i}" class="e-signature">
703      </div>`:`<div class="signature-placeholder">
704      <div class="signature-line"></div>
705    </div>`}constructSignatureUrl(e){return M(this,null,function*(){if(!e.versionId||!e.fileKey)return null;try{let i=yield this.fileUploadService.getPreSignedUrl(e.versionId,e.fileKey);return i&&i.startsWith("http")?i:null}catch(i){return console.error("\u274C Error in constructSignatureUrl:",i),null}})}static \u0275fac=function(i){return new(i||l)(D(Be),D(bt),D(K),D(qe),D(Yt))};static \u0275cmp=q({type:l,selectors:[["app-publish-view"]],decls:44,vars:24,consts:[[1,"mb-3","d-flex","flex-column","flex-md-row","justify-content-between","align-items-center","gap-2"],["type","text","placeholder","Filter by Supplier Name",1,"form-control","w-100","w-md-50",3,"ngModelChange","ngModel"],[1,"d-flex","align-items-center","gap-2","flex-wrap"],["class","badge bg-primary me-2",4,"ngIf"],[1,"btn","btn-info","btn-sm",3,"click","disabled"],[1,"fa","fa-print","me-1"],[1,"btn","btn-danger","btn-sm",3,"click","disabled"],["class","spinner-border spinner-border-sm me-1",4,"ngIf"],["class","fa fa-trash me-1",4,"ngIf"],["class","text-center my-3",4,"ngIf"],["class","alert alert-danger animate__animated animate__fadeIn",4,"ngIf"],["class","table-responsive animate__animated animate__fadeIn",4,"ngIf"],["class","alert alert-info animate__animated animate__fadeIn",4,"ngIf"],["class","modal fade show","tabindex","-1","role","dialog",3,"ngStyle",4,"ngIf"],["tabindex","-1","role","dialog",1,"modal","fade"],["role","document",1,"modal-dialog","modal
705-md","modal-dialog-centered"],[1,"modal-content"],[1,"modal-header","align-items-center"],[1,"modal-title","fw-bold"],["type","button",1,"btn-close",3,"click"],[1,"modal-body"],[1,"alert","alert-info"],[1,"fa","fa-info-circle","me-2"],[1,"mb-3"],[1,"form-label","fw-bold"],[1,"text-danger"],["type","text","placeholder","Enter Cheque Number",1,"form-control",3,"ngModelChange","keyup.enter","ngModel","disabled"],[1,"text-muted"],[1,"modal-footer"],["type","button",1,"btn","btn-secondary",3,"click","disabled"],["type","button",1,"btn","btn-primary",3,"click","disabled"],["class","spinner-border spinner-border-sm me-2",4,"ngIf"],["class","fa fa-save me-1",4,"ngIf"],["class","modal-backdrop fade show",4,"ngIf"],["class","modal fade show","tabindex","-1",3,"ngStyle",4,"ngIf"],[1,"badge","bg-primary","me-2"],[1,"spinner-border","spinner-border-sm","me-1"],[1,"fa","fa-trash","me-1"],[1,"text-center","my-3"],["role","status",1,"spinner-border","text-primary","spinner-border-lg","animate__animated","animate__fadeIn"],[1,"visually-hidden"],[1,"alert","alert-danger","animate__animated","animate__fadeIn"],[1,"table-responsive","animate__animated","animate__fadeIn"],[1,"table","table-sm","table-striped","table-hover","align-middle",2,"min-width","900px"],[1,"table-primary","sticky-top",2,"z-index","2"],[1,"text-center",2,"width","40px"],["type","checkbox",1,"form-check-input",3,"change","checked","indeterminate"],[2,"width","120px"],[1,"text-nowrap",2,"width","80px"],[1,"text-nowrap",2,"width","100px"],[1,"text-center",2,"width","60px"],[1,"text-end",2,"width","80px"],[1,"text-end",2,"width","60px"],[1,"text-end",2,"width","90px"],[1,"text-center",2,"width","120px"],[1,"text-center",2,"width","100px"],[3,"table-primary",4,"ngFor","ngForOf"],[1,"d-flex","justify-content-end","align-items-center","mt-2"],[1,"btn","btn-primary","me-2",3,"click","disabled"],[1,"btn","btn-secondary","ms-2",3,"click","disabled"],[1,"text-center"],["type","checkbox",1,"form-check-input",3,"change","checked"],[1,"text-nowrap"],["title","View Particulars",1,"btn","btn-link","p-0",3,"click"],[1,"fa","fa-eye"],[1,"text-end"],["title","Current Approval Stage",1,"badge",3,"ngClass"],["class","d-flex align-items-center justify-content-center gap-1",4,"ngIf"],["class","text-muted",4,"ngIf"],[1,"badge",3,"ngClass"],[1,"d-flex","align-items-center","justify-content-center","gap-1"],["class","text-nowrap",4,"ngIf"],["title","Edit Cheque No",1,"btn","btn-sm","btn-outline-primary","p-1",3,"click","disabled"],[1,"fa","fa-edit"],[1,"alert","alert-info","animate__animated","animate__fadeIn"],[1,"d-block","mt-1"],["tabindex","-1","role","dialog",1,"modal","fade","show",3,"ngStyle"],["role","document",1,"modal-dialog","modal
705-dialog-centered"],[1,"modal-header"],[1,"modal-title"],["type","button",1,"btn-close",3,"click","disabled"],[1,"mb-0","text-danger"],["type","button",1,"btn","btn-danger",3,"click","disabled"],[1,"spinner-border","spinner-border-sm","me-2"],[1,"fa","fa-save","me-1"],[1,"modal-backdrop","fade","show"],["tabindex","-1",1,"modal","fade","show",3,"ngStyle"],[1,"modal-dialog"],["type","button",1,"btn","btn-secondary",3,"click"]],template:function(i,t){i&1&&(r(0,"div",0)(1,"input",1),ee("ngModelChange",function(s){return J(t.filterSupplierName,s)||(t.filterSupplierName=s),s}),b("ngModelChange",function(){return t.onFilterChange()}),n(),r(2,"div",2),_(3,jn,2,1,"span",3),r(4,"button",4),b("click",function(){return t.printSelectedForApproval()}),c(5,"i",5),o(6,"Print Selected for Approval "),n(),r(7,"button",6),b("click",function(){return t.deleteSelected()}),_(8,Hn,1,0,"span",7)(9,Zn,1,0,"i",8),o(10,"Delete Selected "),n()()(),_(11,Qn,4,0,"div",9)(12,Kn,2,1,"div",10)(13,ir,45,6,"div",11)(14,nr,4,2,"div",12)(15,or,23,10,"div",13),r(16,"div",14)(17,"div",15)(18,"div",16)(19,"div",17)(20,"h5",18),o(21,"Edit Cheque No"),n(),r(22,"button",19),b("click",function(){return t.closeEditChequeNoModal()}),n()(),r(23,"div",20)(24,"div",21),c(25,"i",22),o(26," Stage 1 (Amount Estimate Approved) is complete. You can now add or edit the Cheque No to proceed to Stage 2 approval. "),n(),r(27,"div",23)(28,"label",24),o(29,"Cheque No "),r(30,"span",25),o(31,"*"),n()(),r(32,"input",26),ee("ngModelChange",function(s){return J(t.chequeNoInput,s)||(t.chequeNoInput=s),s}),b("keyup.enter",function(){return t.saveChequeNo()}),n(),r(33,"small",27),o(34,"This is required before Stage 2 approval can begin."),n()()(),r(35,"div",28)(36,"button",29),b("click",function(){return t.closeEditChequeNoModal()}),o(37," Cancel "),n(),r(38,"button",30),b("click",function(){return t.saveChequeNo()}),_(39,lr,1,0,"span",31)(40,sr,1,0,"i",32),o(41),n()()()()(),_(42,dr,1,0,"div",33)(43,pr,13,5,"div",34)),i&2&&(d(),X("ngModel",t.filterSupplierName),d(2),p("ngIf",t.getSelectedFormsCount()>0),d(),p("disabled",t.getSelectedFormsCount()===0),d(3),p("disabled",t.getSelectedFormsCount()===0||t.deleting),d(),p("ngIf",t.deleting),d(),p("ngIf",!t.deleting),d(2),p("ngIf",t.publishedLoading),d(),p("ngIf",t.publishedError),d(),p("ngIf",!t.publishedLoading&&t.publishedForms&&t.publishedForms.length>0),d(),p("ngIf",!t.publishedLoading&&(!t.publishedForms||t.publishedForms.length===0)),d(),p("ngIf",t.showDeleteConfirmModal),d(),at("display",t.showEditChequeNoModal?"block":"none"),re("show",t.showEditChequeNoModal),d(16),X("ngModel",t.chequeNoInput),p("disabled",t.editingChequeNo),d(4),p("disabled",t.editingChequeNo),d(2),p("disabled",t.editingChequeNo||!t.chequeNoInput||t.chequeNoInput.trim().length===0),d(),p("ngIf",t.editingChequeNo),d(),p("ngIf",!t.editingChequeNo),d(),A(" ",t.editingChequeNo?"Saving...":"Save Cheque No"," "),d(),p("ngIf",t.showEditChequeNoModal),d(),p("ngIf",t.viewParticularsText))},dependencies:[te,ie,W,mt,j,H,ue,se,Q]})}return l})();var Pt=Ye(Ge());var cr=["dateRangePicker"],bi=l=>({disabled:l});function mr(l,f){l&1&&(r(0,"span"),c(1,"i",21),o(2,"Print Selected"),n())}function ur(l,f){l&1&&(r(0,"span"),c(1,"span",22),o(2,"Printing..."),n())}function fr(l,f){if(l&1&&(r(0,"span",15),o(1),n()),l&2){let e=g(2);d(),A(" Supplier: ",e.filterSupplierName," ")}}function hr(l,f){if(l&1&&(r(0,"span",15),o(1),n()),l&2){let e=g(2);d(),A(" Date Range (approved): ",e.getDateRangeDisplay()," ")}}function gr(l,f){if(l&1){let e=I();r(0,"div",1)(1,"div",23)(2,"div",24),c(3,"i",25),r(4,"strong"),o(5,"Active Filters:"),n(),_(6,fr,2,1,"span",26)(7,hr,2,1,"span",26),r(8,"button",27),b("click",function(){x(e);let t=g();return S(t.clearFilters())}),c(9,"i",28),o(10,"Clear Filters "),n()()()()}if(l&2){let e=g();d(6),p("ngIf",e.filterSupplierName),d(),p("ngIf",e.filterFromDate||e.filterToDate)}}function br(l,f){l&1&&(r(0,"div",29)(1,"div",30)(2,"span",31),o(3,"Loading..."),n()(),r(4,"p",32),o(5,"Loading approved forms..."),n()())}function vr(l,f){if(l&1&&(r(0,"div",33),c(1,"i",34),o(2),n()),l&2){let e=g();d(2),A("",e.error,`
706`)}}function xr(l,f){l&1&&(r(0,"div",29),c(1,"i",35),r(2,"p",36),o(3,"No approved forms found."),n()())}function Sr(l,f){if(l&1){let e=I();r(0,"tr")(1,"td",47)(2,"input",48),b("change",function(t){let a=x(e).$implicit,s=g(2);return S(s.toggleFormSelection(a,t))}),n()(),r(3,"td"),o(4),n(),r(5,"td")(6,"strong"),o(7),n()(),r(8,"td"),o(9),n(),r(10,"td",49),o(11),L(12,"date"),n(),r(13,"td",43),o(14),L(15,"number"),n(),r(16,"td")(17,"span",50),o(18),n()(),r(19,"td")(20,"span",50),o(21),n()()()}if(l&2){let e=f.$implicit,i=f.index,t=g(2);re("table-primary",t.isFormSelected(e)),d(2),p("checked",t.isFormSelected(e)),d(2),w(i+1),d(3),w(e.supplierName||"N/A"),d(2),w(e.billNo||"N/A"),d(2),w(e.date?B(12,12,e.date,"dd-MM-yyyy"):"N/A"),d(3),A(" ",pt(15,15,e.chequeAmount||0)," "),d(3),p("ngClass",t.getStatusBadgeClass(e)),d(),A(" ",t.getStatusDisplay(e)," "),d(2),p("ngClass",t.getApprovalTypeBadgeClass(e)),d(),A(" ",t.getApprovalTypeDisplay(e)," ")}}function _r(l,f){if(l&1&&(r(0,"span"),o(1),n()),l&2){let e=g(2);d(),A("Showing all ",e.totalCount," approved forms in selected date range")}}function wr(l,f){if(l&1&&(r(0,"span"),o(1),n()),l&2){let e=g(2);d(),dt("Showing ",e.getShowingFrom()," to ",e.getShowingTo()," of ",e.totalCount," approved forms")}}function Cr(l,f){if(l&1){let e=I();r(0,"nav")(1,"ul",51)(2,"li",52)(3,"button",53),b("click",function(){x(e);let t=g(2);return S(t.prevPage())}),c(4,"i",54),o(5," Previous "),n()(),r(6,"li",55)(7,"span",56),o(8),n()(),r(9,"li",52)(10,"button",53),b("click",function(){x(e);let t=g(2);return S(t.nextPage())}),o(11," Next "),c(12,"i",57),n()()()()}if(l&2){let e=g(2);d(2),p("ngClass",$(5,bi,e.isPrevDisabled())),d(),p("disabled",e.isPrevDisabled()),d(5),w(e.pageNumber),d(),p("ngClass",$(7,bi,e.isNextDisabled())),d(),p("disabled",e.isNextDisabled())}}function Er(l,f){if(l&1){let e=I();
706r(0,"div")(1,"div",37)(2,"table",38)(3,"thead",39)(4,"tr")(5,"th",40)(6,"input",41),b("change",function(t){x(e);let a=g();return S(a.toggleSelectAll(t))}),n()(),r(7,"th",42),o(8,"S.No"),n(),r(9,"th"),o(10,"Supplier Name"),n(),r(11,"th"),o(12,"Bill No"),n(),r(13,"th"),o(14,"Date"),n(),r(15,"th",43),o(16,"Cheque Amount"),n(),r(17,"th"),o(18,"Status"),n(),r(19,"th"),o(20,"Approval Type"),n()()(),r(21,"tbody"),_(22,Sr,22,17,"tr",44),n()()(),r(23,"div",45)(24,"div",46),_(25,_r,2,1,"span",17)(26,wr,2,3,"span",17),n(),_(27,Cr,13,9,"nav",17),n()()}if(l&2){let e=g();d(6),p("checked",e.allSelected)("indeterminate",e.getSelectedFormsCount()>0&&e.getSelectedFormsCount()<e.approvedForms.length),d(16),p("ngForOf",e.approvedForms),d(3),p("ngIf",e.isDateFilterActive()),d(),p("ngIf",!e.isDateFilterActive()),d(),p("ngIf",!e.isDateFilterActive())}}var we=Pt.default??Pt,At=(()=>{class l{supplierFormService;fileUploadService;toastr;router;bsLocaleService;dateRangePicker;approvedForms=[];totalCount=0;loading=!1;error="";pageNumber=1;pageSize=100;filterSupplierName="";filterFromDate="";filterToDate="";bsConfig={ranges:[],dateInputFormat:"DD/MM/YYYY",displayMonths:2};ranges=[{value:[new Date(new Date().setDate(new Date().getDate())),new Date],label:"Today"},{value:[new Date(new Date().setDate(new Date().getDate()-1)),new Date(new Date().setDate(new Date().getDate()-1))],label:"Yesterday"},{value:[new Date(new Date().setDate(new Date().getDate()-7)),new Date],label:"Last 7 Days"},{value:[new Date(new Date().setDate(new Date().getDate()-30)),new Date],label:"Last 30 Days"},{value:[new Date(new Date().setMonth(new Date().getMonth()-1)),new Date],label:"Last Month"}];startDate=new Date;endDate=new Date;fromDate;toDate;dateRangeValue;selectedForms=new Set;allSelected=!1;printSelectedSubmitting=!1;nameFilterTimer=null;signatureLoadingStates={dean:!1,registrar:!1,president:!1};signatureCache=new Map;constructor(e,i,t,a,s){this.supplierFormService=e,this.fileUploadService=i,this.toastr=t,this.router=a,this.bsLocaleService=s}ngOnInit(){we.locale("en-GB"),ve("en-gb",xe),this.bsLocaleService.use("en-gb"),this.bsConfig.ranges=this.ranges,this.fetchApprovedForms()}formatTdsDisplay(e){if(e==null||e==="")return"0";let i=parseFloat(e);return isNaN(i)?"0":Number.isInteger(i)?String(i):i.toFixed(2).replace(/\.?0+$/,"")}clearSignatureCache(){this.signatureCache.clear(),this.toastr.info("Signature cache cleared. Signatures will be reloaded on next print.","Cache Cleared")}forceReloadAllSignatures(){return M(this,null,function*(){if(this.approvedForms.length===0){this.toastr.warning("No approved forms available to test signature loading.","No Data");return}this.signatureCache.clear();let i=this.approvedForms[0]?.approvalLevels||[];this.toastr.info("Force reloading all signatures...","Testing Signature Loading");try{let t=yield this.loadAllSignaturesInParallel(i);this.toastr.success(`Signatures loaded: Dean: ${t.dean?"\u2705":"\u274C"}, Registrar: ${t.registrar?"\u2705":"\u274C"}, President: ${t.president?"\u2705":"\u274C"}`,"Signature Loading Results")}catch{this.toastr.error("Error during signature loading test.","Test Failed")}})}fetchApprovedForms(){this.loading=!0,this.error="";let e=this.router.url.includes("/cheque"),t=!!(this.filterFromDate||this.filterToDate)?0:(this.pageNumber-1)*this.pageSize,a=this.filterFromDate?we(this.filterFromDate).startOf("day").valueOf():void 0,s=this.filterToDate?we(this.filterToDate).endOf("day").valueOf():void 0;this.supplierFormService.getApprovedRequestForms(t,this.pageSize,{from:a,to:s,chequeOnly:e,nameSearch:this.filterSupplierName||void 0}).then(m=>{let u=Array.isArray(m?.data)?m.data:[];this.totalCount=typeof m?.total=="number"?m.total:u.length;let h=[];u.forEach(v=>{let E=v.formData||v.supplierForm;if(!E)return;let y=F=>{let k=v.approvalLevels||[],V=this.getApprovalInfo(k,"PRESIDENT")||this.getApprovalInfo(k,"PRESIDENTADMIN");h.push(N(T({},F),{requestFormId:v._id||v.id,approvalType:v.approvalType,submissionStatus:v.submissionStatus,supplierName:v.views?.supplierName||F.supplierName||"N/A",approvalLevels:k,approvedDate:V?.actionDate||null,createdOn:v.createdOn,modifiedOn:v.modifiedOn}))};
706Array.isArray(E)?E.forEach(y):y(E)}),this.approvedForms=h,this.selectedForms.clear(),this.updateAllSelectedState()}).catch(m=>{console.error("Error fetching approved forms:",m),this.error="Failed to load approved supplier forms.",this.toastr.error("Failed to load approved forms.","Error")}).finally(()=>{this.loading=!1})}toggleSelectAll(e){e.target.checked?(this.selectedForms=new Set(this.approvedForms.map(i=>`${i.supplierName}_${i.billNo}_${i.date}`)),this.allSelected=!0):(this.selectedForms.clear(),this.allSelected=!1)}toggleFormSelection(e,i){let t=`${e.supplierName}_${e.billNo}_${e.date}`;i.target.checked?this.selectedForms.add(t):this.selectedForms.delete(t),this.updateAllSelectedState()}updateAllSelectedState(){let e=this.approvedForms.map(i=>`${i.supplierName}_${i.billNo}_${i.date}`);this.allSelected=e.length>0&&e.every(i=>this.selectedForms.has(i))}isFormSelected(e){let i=`${e.supplierName}_${e.billNo}_${e.date}`;return this.selectedForms.has(i)}getSelectedFormsCount(){return this.selectedForms.size}printSelectedForms(){return M(this,null,function*(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to print.","No Selection");return}this.printSelectedSubmitting=!0;let e=this.router.url.includes("/cheque");e?this.toastr.info("Preparing cheque payment document...","Generating Print Document"):this.toastr.info("Preparing document and loading signatures...","Generating Print Document");let i=this.approvedForms.filter(u=>this.selectedForms.has(`${u.supplierName}_${u.billNo}_${u.date}`)),t=window.open("","_blank");if(!t){this.toastr.error("Please allow popups to print the document.","Error"),this.printSelectedSubmitting=!1;return}let a=e?yield this.generateChequePrintContent(i):yield this.generateSelectedPrintContent(i),s=this.getTodayDateString(),m=e?"Cheque Payment Forms":"Selected Approved Supplier Forms";t.document.write(`
707      <!DOCTYPE html>
708      <html>
709        <head>
710          <title>${m}</title>
711          <style>
712            body {
713              font-family: Arial, sans-serif;
714              margin: 15px;
715              padding: 0;
716              font-size: 12px;
717            }
718            .header { 
719              text-align: center; 
720            }
721            .logo-container {
722
723            }
724            .logo {
725               max-width: 300px;
726               height: 120px;
727               margin: 0 auto;
728               display: block;
729               object-fit: contain;
730             }
731            .document-title {
732              font-size: 20px;
733              font-weight: bold;
734              text-align: center;
735              color: #333;
736            }
737            table {
738              width: 100%;
739              border-collapse: collapse;
740              margin-top: 20px;
741              table-layout: fixed;
742              border: 2px solid #000;
743            }
744            th, td {
745              border: 1px solid #000;
746              padding: 8px 6px;
747              text-align: left;
748              font-size: 12px;
749              word-break: keep-all;
750              overflow-wrap: break-word;
751              white-space: normal;
752              overflow: hidden;
753              text-overflow: ellipsis;
754            }
755            th { 
756              background-color: #f2f2f2; 
757              font-weight: bold;
758              border: 1px solid #000;
759              font-size: 12px;
760            }
761            td {
762              font-size: 14px;
763            }
764            /* Numeric values - ensure readable font size */
765            td.text-right,
766            td.amount {
767              font-size: 14px;
768            }
769            tbody tr td {
770              border: 1px solid #000;
771            }
772            thead tr th {
773              border: 1px solid #000;
774            }
775            /* CHEQUE-PRINT: S.No(1)=4%, Supplier(2)=18%, Bill(3)=10%, Date(4)=10%, Particulars(5)=28%, Amount(6)=10%, ChequeNo(7)=10%, ApprovedDate(8)=10% [Total=100%] */
776            table.cheque-print th:nth-child(1),
777            table.cheque-print td:nth-child(1) {
778              width: 4%;
779              text-align: center;
780              white-space: nowrap;
781              overflow: hidden;
782              padding: 6px 3px;
783            }
784            table.cheque-print th:nth-child(2),
785            table.cheque-print td:nth-child(2) {
786              width: 18%;
787              word-break: keep-all;
788              overflow-wrap: break-word;
789              padding: 6px 4px;
790            }
791            table.cheque-print th:nth-child(3),
792            table.cheque-print td:nth-child(3) {
793              width: 10%;
794              text-align: center;
795              white-space: nowrap;
796              overflow: hidden;
797              padding: 6px 3px;
798            }
799            table.cheque-print th:nth-child(4),
800            table.cheque-print td:nth-child(4) {
801              width: 10%;
802              text-align: center;
803              white-space: nowrap;
804              overflow: hidden;
805              padding: 6px 3px;
806            }
807            table.cheque-print th:nth-child(5),
808            table.cheque-print td:nth-child(5) {
809              width: 28%;
810              word-break: keep-all;
811              overflow-wrap: break-word;
812              padding: 6px 4px;
813            }
814            table.cheque-print th:nth-child(5) {
815              text-align: center;
816            }
817            table.cheque-print td:nth-child(5) {
818              text-align: left;
819            }
820            table.cheque-print th:nth-child(6),
821            table.cheque-print td:nth-child(6) {
822              width: 10%;
823              text-align: right;
824              white-space: nowrap;
825              overflow: hidden;
826              padding: 6px 4px;
827            }
828            table.cheque-print th:nth-child(7),
829            table.cheque-print td:nth-child(7) {
830              width: 10%;
831              text-align: center;
832              white-space: nowrap;
833              overflow: hidden;
834              padding: 6px 3px;
835            }
836            table.cheque-print th:nth-child(8),
837            table.cheque-print td:nth-child(8) {
838              width: 10%;
839              text-align: center;
840              white-space: nowrap;
841              overflow: hidden;
842              padding: 6px 3px;
843            }
844            /* APPROVAL-PRINT: S.No(1)=3%, Supplier(2)=14%, Bill(3)=8%, Date(4)=8%, Particulars(5)=22%, BillVal(6)=8%, BillGST(7)=8%, TDS(8)=6%, TDSAmt(9)=8%, ChequeAmt(10)=8%, ApprovedDate(11)=9% [Total=100%] */
845            table.approval-print th:nth-child(1),
846            table.approval-print td:nth-child(1) {
847              width: 3%;
848              text-align: center;
849              white-space: nowrap;
850              overflow: hidden;
851              padding: 6px 3px;
852            }
853            table.approval-print th:nth-child(2),
854            table.approval-print td:nth-child(2) {
855              width: 14%;
856              word-break: keep-all;
857              overflow-wrap: break-word;
858              padding: 6px 4px;
859            }
860            table.approval-print th:nth-child(3),
861            table.approval-print td:nth-child(3) {
862              width: 8%;
863              text-align: center;
864              white-space: nowrap;
865              overflow: hidden;
866              padding: 6px 3px;
867            }
868            table.approval-print th:nth-child(4),
869            table.approval-print td:nth-child(4) {
870              width: 8%;
871              text-align: center;
872              white-space: nowrap;
873              overflow: hidden;
874              padding: 6px 3px;
875            }
876            table.approval-print th:nth-child(5),
877            table.approval-print td:nth-child(5) {
878              width: 22%;
879              word-break: keep-all;
880              overflow-wrap: break-word;
881              padding: 6px 4px;
882            }
883            table.approval-print th:nth-child(5) {
884              text-align: center;
885            }
886            table.approval-print td:nth-child(5) {
887              text-align: left;
888            }
889            table.approval-print th:nth-child(6),
890            table.approval-print td:nth-child(6) {
891              width: 8%;
892              text-align: right;
893              white-space: nowrap;
894              overflow: hidden;
895              padding: 6px 4px;
896            }
897            table.approval-print th:nth-child(7),
898            table.approval-print td:nth-child(7) {
899              width: 8%;
900              text-align: right;
901              white-space: nowrap;
902              overflow: hidden;
903              padding: 6px 4px;
904            }
905            table.approval-print th:nth-child(8),
906            table.approval-print td:nth-child(8) {
907              width: 6%;
908              text-align: center;
909              white-space: nowrap;
910              overflow: hidden;
911              padding: 6px 3px;
912            }
913            table.approval-print th:nth-child(9),
914            table.approval-print td:nth-child(9) {
915              width: 8%;
916              text-align: right;
917              white-space: nowrap;
918              overflow: hidden;
919              padding: 6px 4px;
920            }
921            table.approval-print th:nth-child(10),
922            table.approval-print td:nth-child(10) {
923              width: 8%;
924              text-align: right;
925              white-space: nowrap;
926              overflow: hidden;
927              padding: 6px 4px;
928            }
929            table.approval-print th:nth-child(11),
930            table.approval-print td:nth-child(11) {
931              width: 9%;
932              text-align: center;
933              white-space: nowrap;
934              overflow: hidden;
935              padding: 6px 3px;
936            }
937            .text-center { text-align: center; }
938            .text-right { text-align: right !important; }
939            .amount { font-weight: bold; }
940            .total-row {
941              background-color: #f8f9fa;
942              font-weight: bold;
943            }
944            .total-row td {
945              font-size: 14px;
946            }
947            /* Ensure total row cells respect text-right class */
948            .total-row td.text-right {
949              text-align: right !important;
950            }
951            .amount-in-words {
952              margin-top: 20px;
953              padding: 10px;
954              background-color: #f8f9fa;
955              border: 1px solid #ddd;
956              text-align: center;
957              font-weight: bold;
958              font-size: 14px;
959            }
960            .signature-section {
961              margin-top: 40px;
962              display: flex;
963              justify-content: space-between;
964            }
965            .signature-box {
966              text-align: center;
967              width: 200px;
968              border: none;
969              padding: 10px;
970              margin: 5px;
971            }
972            .signature-title {
973              font-weight: bold;
974              margin-bottom: 10px;
975              font-size: 12px;
976              border-bottom: 1px solid #ddd;
977              padding-bottom: 5px;
978            }
979            .signature-image {
980              margin: 0;
981              padding: 0;
982              display: flex;
983              align-items: center;
984              justify-content: center;
985              width: 180px;
986              height: 80px;
987            }
988            .e-signature {
989              width: 180px;
990              height: 80px;
991              object-fit: cover;
992              border: none;
993              background: transparent;
994              padding: 0;
995              margin: 0;
996            }
997            .signature-placeholder {
998              margin: 10px 0;
999              min-height: 90px;
1000              display: flex;
1001              align-items: center;
1002              justify-content: center;
1003            }
1004            .signature-line {
1005              width: 150px;
1006              height: 1px;
1007              border-bottom: 1px solid #333;
1008              margin: 0 auto;
1009            }
1010            .approval-status {
1011              margin-top: 8px;
1012              font-size: 10px;
1013            }
1014            .status-label {
1015              font-weight: bold;
1016              color: #333;
1017            }
1018            .status-value.approved {
1019              color: #28a745;
1020              font-weight: bold;
1021            }
1022            .status-value.pending {
1023              color: #ffc107;
1024              font-weight: bold;
1025            }
1026            .approval-time {
1027              margin-top: 5px;
1028              font-size: 10px;
1029            }
1030            .time-label {
1031              font-weight: bold;
1032              color: #333;
1033            }
1034            .time-value {
1035              color: #666;
1036            }
1037            .approver-name {
1038              margin-top: 5px;
1039              font-size: 10px;
1040            }
1041            .name-label {
1042              font-weight: bold;
1043              color: #333;
1044            }
1045            .name-value {
1046              color: #666;
1047            }
1048            .print-button {
1049              position: fixed;
1050              top: 20px;
1051              right: 20px;
1052              background-color: #007bff;
1053              color: white;
1054              border: none;
1055              padding: 10px 20px;
1056              border-radius: 5px;
1057              cursor: pointer;
1058              font-size: 14px;
1059              font-weight: bold;
1060              box-shadow: 0 2px 5px rgba(0,0,0,0.2);
1061              z-index: 1000;
1062            }
1063            .print-button:hover {
1064              background-color: #0056b3;
1065            }
1066            .generated-on {
1067              position: fixed;
1068              top: 60px;
1069              right: 20px;
1070              color: #555;
1071              font-size: 12px;
1072              background: rgba(255,255,255,0.9);
1073              padding: 4px 8px;
1074              border: 1px solid #ddd;
1075              border-radius: 4px;
1076              z-index: 999;
1077            }
1078            /* Page number styling */
1079            .page-number {
1080              position: fixed;
1081              top: 10px;
1082              right: 20px;
1083              font-size: 12px;
1084              font-weight: bold;
1085              color: #333;
1086              z-index: 1000;
1087              background: rgba(255, 255, 255, 0.9);
1088              padding: 4px 8px;
1089              border-radius: 4px;
1090            }
1091            @media print {
1092              body {
1093                margin: 0;
1094                padding: 10mm;
1095                font-size: 13px;
1096              }
1097              .no-print { display: none; }
1098              .print-button { display: none; }
1099              .generated-on { display: none; }
1100              .page-number { display: none; }
1101              .logo {
1102                max-width: 250px !important;
1103                height: 90px !important;
1104              }
1105              table {
1106                width: 100% !important;
1107                table-layout: fixed !important;
1108                font-size: 13px;
1109                margin-top: 15px;
1110              }
1111              th, td {
1112                font-size: 13px;
1113                padding: 5px 3px !important;
1114                word-break: keep-all !important;
1115                overflow-wrap: break-word !important;
1116                white-space: normal !important;
1117                overflow: hidden !important;
1118                text-overflow: ellipsis !important;
1119              }
1120              tbody tr {
1121                page-break-inside: avoid;
1122              }
1123              .total-row {
1124                page-break-inside: avoid;
1125              }
1126              @page {
1127                size: landscape;
1128                margin: 10mm;
1129              }
1130            }
1131          </style>
1132        </head>
1133        <body>
1134          <button class="print-button" onclick="window.print()">\u{1F5A8}\uFE0F Print Document</button>
1135          <div class="page-number no-print">Page 1</div>
1136          ${a}
1137        </body>
1138      </html>
1139    `),t.document.close(),t.focus(),this.printSelectedSubmitting=!1})}getApprovalInfo(e,i){if(!e||e.length===0)return{status:"PENDING",actionDate:"",approvedByName:i,remarks:"",eSignature:null};let t=i.toUpperCase().trim(),a=e.find(s=>
1139{if(!s)return!1;let m=(s.role||"").toString().toUpperCase().trim(),u=(s.roles||"").toString().toUpperCase().trim(),h=(s.label||"").toString().toUpperCase().trim();return m===t||u===t||h===t||m.includes(t)||t.includes(m)||t.includes("PRESIDENT")&&(m.includes("PRESIDENT")||h.includes("PRESIDENT"))||t.includes("DEAN")&&(m.includes("DEAN")||h.includes("DEAN"))||t.includes("REGISTRAR")&&(m.includes("REGISTRAR")||h.includes("REGISTRAR"))});return a?{status:a.status||"APPROVED",actionDate:a.actionDate||a.approvedDate||a.date||"",approvedByName:a.approvedByName||a.name||a.approverName||i,remarks:a.remarks||"",eSignature:a.eSignature||null}:{status:"PENDING",actionDate:"",approvedByName:i,remarks:"",eSignature:null}}formatDate(e){if(!e)return"N/A";try{return new Date(e).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}catch{return e}}getTodayDateString(){let e=new Date,i=String(e.getDate()).padStart(2,"0"),t=String(e.getMonth()+1).padStart(2,"0"),a=e.getFullYear();return`${i}-${t}-${a}`}generateSelectedPrintContent(e){return M(this,null,function*(){let i=new Date().toLocaleDateString(),t=new Date().toLocaleTimeString(),a=0,s=0,m=0,u=0,h="";e.forEach((O,C)=>{let ae=O.billValue||0,ke=O.billValueGst||0,Ae=O.tdsAmount||0,et=O.chequeAmount||0,Ot=new Q("en-US"),Ai=O.date?Ot.transform(O.date,"dd-MM-yyyy"):"N/A";a+=ae,s+=ke,m+=Ae,u+=et;let Ii=this.getApprovalInfo(O.approvalLevels||[],"PRESIDENT")||this.getApprovalInfo(O.approvalLevels||[],"PRESIDENTADMIN"),Rt=O.approvedDate||Ii?.actionDate,ki=Rt?Ot.transform(Rt,"dd-MM-yyyy"):"N/A";h+=`
1140        <tr>
1141          <td class="text-center">${C+1}</td>
1142          <td>${O.supplierName||"N/A"}</td>
1143          <td>${O.billNo||"N/A"}</td>
1144          <td class="text-center">${Ai}</td>
1145          <td>${O.particulars||"N/A"}</td>
1146          <td class="text-right amount">${ae}</td>
1147          <td class="text-right">${ke}</td>
1148          <td class="text-center">${this.formatTdsDisplay(O.tds)}</td>
1149          <td class="text-right">${Ae}</td>
1150          <td class="text-right amount">${et}</td>
1151          <td class="text-center">${ki}</td>
1152        </tr>
1153      `});let v=this.numberToWords(u),E=e[0],y=E?.approvalLevels||[];if(y.length===0){let O=this.findAlternativeApprovalData(E);if(O.length>0){let C=yield this.loadAllSignaturesInParallel(O);return this.generatePrintContentWithSignatures(h,a,s,m,u,v,C)}else{let C=yield this.createIndividualApproverSignatures([]);return this.generatePrintContentWithSignatures(h,a,s,m,u,v,C)}}let F=yield this.createIndividualApproverSignatures(y),k=this.getApprovalInfo(y,"DEAN")||this.getApprovalInfo(y,"DEANADMIN"),V=this.getApprovalInfo(y,"REGISTRAR")||this.getApprovalInfo(y,"REGISTRARADMIN"),Y=this.getApprovalInfo(y,"PRESIDENT")||this.getApprovalInfo(y,"PRESIDENTADMIN");return`
1154      <div class="header">
1155        <div class="logo-container">
1156          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
1157        </div>
1158      </div>
1159      
1160      <div class="document-title">
1161        Submitted to the Approval of the President
1162      </div>
1163
1164      <table class="approval-print">
1165        <thead>
1166          <tr>
1167            <th class="text-center">S.No.</th>
1168            <th class="text-center">Name of the<br>Company/Supplier</th>
1169            <th class="text-center">Inv./<br>Bill No.</th>
1170            <th class="text-center">Date</th>
1171            <th class="text-center">Particulars</th>
1172            <th class="text-right">Total Bill<br>Value \u20B9</th>
1173            <th class="text-right">Bill Value<br>before GST \u20B9</th>
1174            <th class="text-center">TDS @</th>
1175            <th class="text-right">TDS<br>Amount \u20B9</th>
1176            <th class="text-right">Cheque<br>Amount \u20B9</th>
1177            <th class="text-center">Approved<br>Date</th>
1178          </tr>
1179        </thead>
1180        <tbody>
1181          ${h}
1182          <tr class="total-row">
1183            <td colspan="5" class="text-center"><strong>Total \u20B9</strong></td>
1184            <td class="text-right" style="text-align: right !important;"><strong>${a}</strong></td>
1185            <td class="text-right" style="text-align: right !important;"><strong>${s}</strong></td>
1186            <td></td>
1187            <td class="text-right" style="text-align: right !important;"><strong>${m}</strong></td>
1188            <td class="text-right" style="text-align: right !important;"><strong>${u}</strong></td>
1189            <td></td>
1190          </tr>
1191        </tbody>
1192      </table>
1193      
1194      <div class="amount-in-words">
1195        (Rupees ${v} only)
1196      </div>
1197      
1198      <div class="signature-section">
1199        <div class="signature-box">
1200          ${this.getSignatureHtmlFromUrl(F.dean,"Dean Signature")}
1201          <div class="signature-title">DEAN-STUDENT AFFAIRS</div>
1202        </div>
1203        <div class="signature-box">
1204          ${this.getSignatureHtmlFromUrl(F.registrar,"Registrar Signature")}
1205          <div class="signature-title">REGISTRAR</div>
1206        </div>
1207        <div class="signature-box">
1208          ${this.getSignatureHtmlFromUrl(F.president,"President Signature")}
1209          <div class="signature-title">PRESIDENT</div>
1210        </div>
1211      </div>
1212    `})}generateChequePrintContent(e){return M(this,null,function*(){let i=new Q("en-US"),t=0,a="";e.forEach((v,E)=>{let y=v.chequeAmount||0;t+=y;let F=v.date?i.transform(v.date,"dd/MM/yyyy"):"N/A",k=this.getApprovalInfo(v.approvalLevels||[],"PRESIDENT")||this.getApprovalInfo(v.approvalLevels||[],"PRESIDENTADMIN"),V=v.approvedDate||k?.actionDate,Y=V?i.transform(V,"dd/MM/yyyy"):"N/A";a+=`
1213        <tr>
1214          <td class="text-center">${E+1}</td>
1215          <td>${v.supplierName||"N/A"}</td>
1216          <td>${v.billNo||"N/A"}</td>
1217          <td style="white-space: nowrap;">${F}</td>
1218          <td>${v.particulars||"N/A"}</td>
1219          <td class="text-right amount">${y}</td>
1220          <td class="text-center">${v.chequeNo||"N/A"}</td>
1221          <td style="white-space: nowrap;">${Y}</td>
1222        </tr>
1223      `});let s=this.numberToWords(t),m=e[0],u=m?.approvalLevels||[],h;if(u.length===0){let v=this.findAlternativeApprovalData(m);v.length>0?h=yield this.loadAllSignaturesInParallel(v):h=yield this.createIndividualApproverSignatures([])}else h=yield this.createIndividualApproverSignatures(u);return`
1224      <div class="header">
1225        <div class="logo-container">
1226          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
1227        </div>
1228      </div>
1229      
1230      <div class="document-title">
1231        CHEQUE PAYMENT
1232      </div>
1233      
1234      <table class="cheque-print">
1235        <thead>
1236          <tr>
1237            <th class="text-center">S.No.</th>
1238            <th class="text-center">Name of the<br>Company/Supplier</th>
1239            <th class="text-center">Inv./<br>Bill No.</th>
1240            <th class="text-center">Date</th>
1241            <th class="text-center">Particulars</th>
1242            <th class="text-right">Cheque<br>Amount</th>
1243            <th class="text-center">Cheque<br>No</th>
1244            <th class="text-center">Approved<br>Date</th>
1245          </tr>
1246        </thead>
1247        <tbody>
1248          ${a}
1249          <tr class="total-row">
1250            <td colspan="5" class="text-center"><strong>Total \u20B9</strong></td>
1251            <td class="text-right" style="text-align: right !important;"><strong>\u20B9${t}</strong></td>
1252            <td></td>
1253            <td></td>
1254          </tr>
1255        </tbody>
1256      </table>
1257      
1258      <div class="amount-in-words">
1259        (Rupees ${s} only)
1260      </div>
1261      
1262      <div class="signature-section">
1263        <div class="signature-box">
1264          ${this.getSignatureHtmlFromUrl(h.dean,"Dean Signature")}
1265          <div class="signature-title">DEAN-STUDENT AFFAIRS</div>
1266        </div>
1267        <div class="signature-box">
1268          ${this.getSignatureHtmlFromUrl(h.registrar,"Registrar Signature")}
1269          <div class="signature-title">REGISTRAR</div>
1270        </div>
1271        <div class="signature-box">
1272          ${this.getSignatureHtmlFromUrl(h.president,"President Signature")}
1273          <div class="signature-title">PRESIDENT</div>
1274        </div>
1275      </div>
1276    `})}numberToWords(e){let i=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"],t=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"],a=["Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"];if(e===0)return"Zero";let s=u=>u===0?"":u<10?i[u]:u<20?a[u-10]:u<100?t[Math.floor(u/10)]+(u%10!==0?" "+i[u%10]:""):u<1e3?i[Math.floor(u/100)]+" Hundred"+(u%100!==0?" and "+s(u%100):""):"";return(u=>{if(u===0)return"Zero";let h=Math.floor(u/1e7),v=Math.floor(u%1e7/1e5),E=Math.floor(u%1e5/1e3),y=u%1e3,F="";return h>0&&(F+=s(h)+" Crore "),v>0&&(F+=s(v)+" Lakh "),E>0&&(F+=s(E)+" Thousand "),y>0&&(F+=s(y)),F.trim()})(Math.floor(e))}onFilterChange(){this.nameFilterTimer&&clearTimeout(this.nameFilterTimer),this.nameFilterTimer=setTimeout(()=>{this.pageNumber=1,this.fetchApprovedForms()},400)}clearFilters(){this.filterSupplierName="",this.filterFromDate="",this.filterToDate="",this.dateRangeValue=null,this.dateRangePicker&&(this.dateRangePicker.bsValue=null),this.pageNumber=1,this.fetchApprovedForms()}getDateRangeDisplay(){if(this.filterFromDate&&this.filterToDate){let e=we(this.filterFromDate).format("DD/MM/YYYY"),i=we(this.filterToDate).format("DD/MM/YYYY");return`${e} - ${i}`}else{if(this.filterFromDate)return`From ${we(this.filterFromDate).format("DD/MM/YYYY")}`;if(this.filterToDate)return`Until ${we(this.filterToDate).format("DD/MM/YYYY")}`}return""}onDateRangeChange(e){e&&e.length===2?(this.dateRangeValue=e,this.startDate=e[0],this.endDate=e[1],this.fromDate=we(e[0]).format("DD/MM/YYYY"),this.toDate=we(e[1]).format("DD/MM/YYYY"),this.filterFromDate=we(e[0]).format("YYYY-MM-DD"),this.filterToDate=we(e[1]).format("YYYY-MM-DD")):(this.filterFromDate="",this.filterToDate=""),this.pageNumber=1,this.fetchApprovedForms()}isDateFilterActive(){return!!(this.filterFromDate||this.filterToDate)}getShowingFrom(){return this.totalCount>0?(this.pageNumber-1)*this.pageSize+1:0}getShowingTo(){return Math.min(this.pageNumber*this.pageSize,this.totalCount)}loadAllSignaturesInParallel(e){return M(this,null,function*(){console.log("\u{1F50D} Loading signatures in parallel. Approval levels:",e);let i=this.findAnySignature(e);console.log("\u{1F50D} Base signature found:",i);let t=this.createRoleSpecificSignature(i,"DEAN"),a=this.createRoleSpecificSignature(i,"REGISTRAR"),s=this.createRoleSpecificSignature(i,"PRESIDENT");console.log("\u{1F4CB} Dean Signature Object:",t),console.log("\u{1F4CB} Registrar Signature Object:",a),console.log("\u{1F4CB} President Signature Object:",s),this.signatureLoadingStates={dean:!0,registrar:!0,president:!0};try{console.log("\u{1F680} Starting parallel signature loading...");
1276let[m,u,h]=yield Promise.all([this.getSignatureUrlFromObject(t,"DEAN"),this.getSignatureUrlFromObject(a,"REGISTRAR"),this.getSignatureUrlFromObject(s,"PRESIDENT")]);return console.log("\u2705 Signature loading completed:"),console.log("  - Dean signature:",m?"\u2705 Loaded":"\u274C Not found"),console.log("  - Registrar signature:",u?"\u2705 Loaded":"\u274C Not found"),console.log("  - President signature:",h?"\u2705 Loaded":"\u274C Not found"),{dean:m,registrar:u,president:h}}catch(m){return console.error("\u274C Error loading signatures:",m),this.toastr.warning("Some signatures could not be loaded. Proceeding with available signatures.","Signature Loading Warning"),{dean:null,registrar:null,president:null}}finally{this.signatureLoadingStates={dean:!1,registrar:!1,president:!1}}})}findAlternativeApprovalData(e){let i=[e.approvalLevels,e.approvals,e.approvalData,e.approval,e.signatures,e.signatureData,e.eSignatures,e.approvalHistory,e.workflowData];for(let a of i)if(a&&Array.isArray(a)&&a.length>0)return a;let t=[e.requestForm?.approvalLevels,e.parentForm?.approvalLevels,e.metadata?.approvalLevels,e.formData?.approvalLevels];for(let a of t)if(a&&Array.isArray(a)&&a.length>0)return a;return[]}generatePrintContentWithSignatures(e,i,t,a,s,m,u){return`
1277      <div class="header">
1278        <div class="logo-container">
1279          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
1280        </div>
1281      </div>
1282      
1283      <div class="document-title">
1284        Submitted to the Approval of the President
1285      </div>
1286
1287      <table class="approval-print">
1288        <thead>
1289          <tr>
1290            <th class="text-center">S.No.</th>
1291            <th class="text-center">Name of the<br>Company/Supplier</th>
1292            <th class="text-center">Inv./<br>Bill No.</th>
1293            <th class="text-center">Date</th>
1294            <th class="text-center">Particulars</th>
1295            <th class="text-right">Total Bill<br>Value \u20B9</th>
1296            <th class="text-right">Bill Value<br>before GST \u20B9</th>
1297            <th class="text-center">TDS @</th>
1298            <th class="text-right">TDS<br>Amount \u20B9</th>
1299            <th class="text-right">Cheque<br>Amount \u20B9</th>
1300            <th class="text-center">Approved<br>Date</th>
1301          </tr>
1302        </thead>
1303        <tbody>
1304          ${e}
1305          <tr class="total-row">
1306            <td colspan="5" class="text-center"><strong>Total \u20B9</strong></td>
1307            <td class="text-right" style="text-align: right !important;"><strong>${i.toLocaleString()}</strong></td>
1308            <td class="text-right" style="text-align: right !important;"><strong>${t.toLocaleString()}</strong></td>
1309            <td></td>
1310            <td class="text-right" style="text-align: right !important;"><strong>${a.toLocaleString()}</strong></td>
1311            <td class="text-right" style="text-align: right !important;"><strong>${s.toLocaleString()}</strong></td>
1312            <td></td>
1313          </tr>
1314        </tbody>
1315      </table>
1316      
1317      <div class="amount-in-words">
1318        (Rupees ${m} only)
1319      </div>
1320      
1321      <div class="signature-section">
1322        <div class="signature-box">
1323          ${this.getSignatureHtmlFromUrl(u.dean,"Dean Signature")}
1324          <div class="signature-title">DEAN-STUDENT AFFAIRS</div>
1325        </div>
1326        <div class="signature-box">
1327          ${this.getSignatureHtmlFromUrl(u.registrar,"Registrar Signature")}
1328          <div class="signature-title">REGISTRAR</div>
1329        </div>
1330        <div class="signature-box">
1331          ${this.getSignatureHtmlFromUrl(u.president,"President Signature")}
1332          <div class="signature-title">PRESIDENT</div>
1333        </div>
1334      </div>
1335    `}createIndividualApproverSignatures(e){return M(this,null,function*(){let i=this.extractApproverSignatureData(e,"DEAN")||this.extractApproverSignatureData(e,"DEANADMIN"),t=this.extractApproverSignatureData(e,"REGISTRAR")||this.extractApproverSignatureData(e,"REGISTRARADMIN"),a=this.extractApproverSignatureData(e,"PRESIDENT")||this.extractApproverSignatureData(e,"PRESIDENTADMIN");try{let[s,m,u]=yield Promise.all([this.makeIndividualApiCallWithDbData(i,"DEAN"),this.makeIndividualApiCallWithDbData(t,"REGISTRAR"),this.makeIndividualApiCallWithDbData(a,"PRESIDENT")]);return{dean:s,registrar:m,president:u}}catch{return{dean:null,registrar:null,president:null}}})}extractApproverSignatureData(e,i){if(!e||e.length===0)return null;let t=i.toUpperCase().trim(),a=e.find(s=>
1335{if(!s)return!1;let m=(s.role||"").toString().toUpperCase().trim(),u=(s.roles||"").toString().toUpperCase().trim(),h=(s.label||"").toString().toUpperCase().trim();return m===t||u===t||h===t||m.includes(t)||t.includes(m)||t.includes("PRESIDENT")&&(m.includes("PRESIDENT")||h.includes("PRESIDENT"))||t.includes("DEAN")&&(m.includes("DEAN")||h.includes("DEAN"))||t.includes("REGISTRAR")&&(m.includes("REGISTRAR")||h.includes("REGISTRAR"))});if(a?.eSignature){let s=a.eSignature,m=s.finalApprovalSignature;if(m?.url||m?.versionId&&m?.fileKey)return m;let u=s.preApprovedSignature;if(u?.url||u?.versionId&&u?.fileKey)return u;if(s.url||s.fileKey&&s.versionId)return s}return null}makeIndividualApiCallWithDbData(e,i){return M(this,null,function*(){if(!e)return console.log(`\u274C ${i}: No signature data provided`),null;try{if(typeof e=="string")return this.normalizePreSignedUrl(e);if(e.versionId&&e.fileKey){console.log(`\u{1F310} ${i}: Making API call for pre-signed URL with versionId: ${e.versionId}, fileKey: ${e.fileKey}`);let t=this.normalizePreSignedUrl(yield this.fileUploadService.getPreSignedUrl(e.versionId,e.fileKey));if(t)return console.log(`\u2705 ${i}: Got pre-signed URL successfully`),t}if(e.url){let t=this.normalizePreSignedUrl(e.url);if(t)return console.log(`\u2705 ${i}: Using signatureData.url`),t}return console.log(`\u274C ${i}: Missing versionId or fileKey in signature data`),null}catch(t){return console.error(`\u274C ${i}: Error getting signature URL:`,t),null}})}normalizePreSignedUrl(e){if(e==null)return null;let i=String(e).trim().replace(/^"|"$/g,"");return i.startsWith("http")?i:null}makeIndividualApiCall(e,i){return M(this,null,function*(){try{let t=yield this.fileUploadService.getPreSignedUrl(e.versionId,e.fileKey);return t&&t.startsWith("http")?t:null}catch{return null}})}findAnySignature(e){for(let i of e)if(i.eSignature)return i.eSignature;return null}createRoleSpecificSignature(e,i){return e?N(T({},e),{role:i,fileKey:this.getRoleSpecificFileKey(e.fileKey,i),roleSpecific:!0,originalSignature:e,versionId:e.versionId+`_${i.toLowerCase()}`}):null}getRoleSpecificFileKey(e,i){if(!e)return`${i.toLowerCase()}_signature.png`;if(e==="signature.png"||e==="signature")return`${i.toLowerCase()}_signature.png`;if(e.includes(i.toLowerCase()))return e;let t=e.split(".").pop();return`${e.replace(`.${t}`,"")}_${i.toLowerCase()}.${t}`}getSignatureUrlFromObject(e,i){return M(this,null,function*(){if(console.log(`\u{1F50D} Getting signature URL for ${i} from object:`,e),!e)return console.log(`\u274C ${i}: No signature object provided`),null;let t=this.createSignatureCacheKey(e);if(this.signatureCache.has(t))return console.log(`\u{1F4BE} ${i}: Using cached signature URL`),this.signatureCache.get(t);try{let a=null;return typeof e=="string"?(a=e,console.log(`\u{1F517} ${i}: Using string signature URL`)):e.url?(a=e.url,console.log(`\u{1F517} ${i}: Using signatureObject.url`)):e.data?(a=e.data,console.log(`\u{1F517} ${i}: Using signatureObject.data`)):e.image?(a=e.image,console.log(`\u{1F517} ${i}: Using signatureObject.image`)):e.src?(a=e.src,console.log(`\u{1F517} ${i}: Using signatureObject.src`)):e.versionId&&e.fileKey?(console.log(`\u{1F310} ${i}: Making API call for pre-signed URL with versionId: ${e.versionId}, fileKey: ${e.fileKey}`),a=yield this.constructSignatureUrl(e),console.log(`\u{1F310} ${i}: API call completed, got URL:`,a)):console.log(`\u274C ${i}: No valid signature structure found in:`,e),a&&(this.signatureCache.set(t,a),console.log(`\u{1F4BE} ${i}: Cached signature URL`)),a}catch(a){return console.error(`\u274C ${i}: Error getting signature URL:`,a),null}})}getSignatureUrl(e,i="UNKNOWN"){return M(this,null,function*(){if(console.log(`\u{1F50D} Getting signature URL for ${i}:`,e),!e||e.status!=="APPROVED"||!e.eSignature)return console.log(`\u274C ${i}: No approval or eSignature found`),null;console.log(`\u{1F4DD} ${i}: eSignature data:`,e.eSignature);let t=this.createSignatureCacheKey(e.eSignature);if(this.signatureCache.has(t))return console.log(`\u{1F4BE} ${i}: Using cached signature URL`),this.signatureCache.get(t);try{let a=null;return typeof e.eSignature=="string"?(a=e.eSignature,console.log(`\u{1F517} ${i}
1335: Using string signature URL`)):e.eSignature.url?(a=e.eSignature.url,console.log(`\u{1F517} ${i}: Using eSignature.url`)):e.eSignature.data?(a=e.eSignature.data,console.log(`\u{1F517} ${i}: Using eSignature.data`)):e.eSignature.image?(a=e.eSignature.image,console.log(`\u{1F517} ${i}: Using eSignature.image`)):e.eSignature.src?(a=e.eSignature.src,console.log(`\u{1F517} ${i}: Using eSignature.src`)):e.eSignature.versionId&&e.eSignature.fileKey?(console.log(`\u{1F310} ${i}: Making API call for pre-signed URL with versionId: ${e.eSignature.versionId}, fileKey: ${e.eSignature.fileKey}`),a=yield this.constructSignatureUrl(e.eSignature),console.log(`\u{1F310} ${i}: API call completed, got URL:`,a)):console.log(`\u274C ${i}: No valid signature structure found`),a&&(this.signatureCache.set(t,a),console.log(`\u{1F4BE} ${i}: Cached signature URL`)),a}catch(a){return console.error(`\u274C ${i}: Error getting signature URL:`,a),null}})}createSignatureCacheKey(e){return typeof e=="string"?`string_${e}`:e.versionId&&e.fileKey?`file_${e.versionId}_${e.fileKey}`:e.url?`url_${e.url}`:`other_${JSON.stringify(e)}`}getSignatureHtmlFromUrl(e,i){let t=this.normalizePreSignedUrl(e);return t?`<div class="signature-image">
1336        <img src="${t.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}" alt="${i}" class="e-signature">
1337      </div>`:`<div class="signature-placeholder">
1338      <div class="signature-line"></div>
1339    </div>`}getSignatureHtml(e,i){return M(this,null,function*(){if(e&&e.status==="APPROVED"&&e.eSignature){let t=null;if(typeof e.eSignature=="string"?t=e.eSignature:e.eSignature.url?t=e.eSignature.url:e.eSignature.data?t=e.eSignature.data:e.eSignature.image?t=e.eSignature.image:e.eSignature.src?t=e.eSignature.src:e.eSignature.versionId&&e.eSignature.fileKey&&(t=yield this.constructSignatureUrl(e.eSignature)),t)return`<div class="signature-image">
1340          <img src="${t}" alt="${i}" class="e-signature">
1341        </div>`}return`<div class="signature-placeholder">
1342      <div class="signature-line"></div>
1343    </div>`})}constructSignatureUrl(e){return M(this,null,function*(){if(console.log("\u{1F527} Constructing signature URL with:",e),!e.versionId||!e.fileKey)return console.log("\u274C Missing versionId or fileKey"),null;try{console.log(`\u{1F310} Making API call: getPreSignedUrl(${e.versionId}, ${e.fileKey})`);let i=yield this.fileUploadService.getPreSignedUrl(e.versionId,e.fileKey);return console.log("\u{1F310} API response:",i),i&&i.startsWith("http")?(console.log("\u2705 Valid pre-signed URL received"),i):(console.log("\u274C Invalid pre-signed URL received"),null)}catch(i){return console.error("\u274C Error in constructSignatureUrl:",i),null}})}nextPage(){this.isNextDisabled()||(this.pageNumber++,this.fetchApprovedForms())}prevPage(){this.pageNumber>1&&(this.pageNumber--,this.fetchApprovedForms())}isPrevDisabled(){return this.pageNumber<=1}isNextDisabled(){return this.isDateFilterActive()||this.pageNumber*this.pageSize>=this.totalCount}getStatusDisplay(e){let i=e.submissionStatus||e.status;if(!i)return e.approvalType==="PRE_APPROVED"?"Pre-Approved":"Approved";switch(i.toUpperCase()){case"PENDING":return"Pending";case"APPROVED":return"Approved";case"REJECTED":return"Rejected";case"WAITING":return"Waiting";default:return i}}getStatusBadgeClass(e){let i=e.submissionStatus||e.status;if(!i)return e.approvalType==="PRE_APPROVED"?"bg-warning":"bg-success";switch(i.toUpperCase()){case"PENDING":return"bg-warning";case"APPROVED":return"bg-success";case"REJECTED":return"bg-danger";case"WAITING":return"bg-info";default:return"bg-secondary"}}getApprovalTypeDisplay(e){return e.approvalType==="PRE_APPROVED"?"PRE_APPROVED":e.approvalType==="WITHOUT_CHEQUE"?"WITHOUT_CHEQUE":e.approvalType==="NONE"?"NONE":"N/A"}getApprovalTypeBadgeClass(e){return e.approvalType==="PRE_APPROVED"?"bg-warning":e.approvalType==="WITHOUT_CHEQUE"?"bg-secondary":e.approvalType==="NONE"?"bg-info":"bg-secondary"}static \u0275fac=function(i){return new(i||l)(D(Be),D(qe),D(K),D(ne),D(Se))};static \u0275cmp=q({type:l,selectors:[["app-approved-list"]],viewQuery:function(i,t){if(i&1&&Ee(cr,5),i&2){let a;ye(a=Fe())&&(t.dateRangePicker=a.first)}},decls:27,vars:12,consts:[["dateRangePicker",""],[1,"row","mb-2","no-print"],[1,"col-md-6"],[1,"d-flex","gap-2"],[1,"input-group"],[1,"input-group-text"],[1,"fa","fa-calendar"],["type","text","placeholder","Filter by approval date range","bsDaterangepicker","",1,"form-control",3,"bsValueChange","bsConfig","bsValue"],["title","Clear all filters",1,"btn","btn-outline-secondary",3,"click"],[1,"fa","fa-times"],[1,"fa","fa-search"],["type","text","placeholder","Filter by supplier name...",1,"form-control",3,"ngModelChange","input","ngModel"],[1,"col-md-6","d-flex","justify-content-end","align-items-center"],[1,"d-flex","flex-wrap","gap-2","align-items-center","bulk-actions"],[1,"d-flex","align-items-center","me-3"],[1,"badge","bg-primary","me-2"],[1,"btn","btn-success","btn-sm",3,"click","disabled"],[4,"ngIf"],["class","row mb-2 no-print",4,"ngIf"],["class","text-center py-2",4,"ngIf"],["class","alert alert-danger",4,"ngIf"],[1,"fa","fa-print","me-1"],[1,"spinner-border","spinner-border-sm","me-1"],[1,"col-12"],[1,"alert","alert-info","py-1","mb-0"],[1,"fa","fa-filter","me-2"],["class","badge bg-primary me-2",4,"ngIf"],[1,"btn","btn-sm","btn-outline-primary","ms-2",3,"click"],[1,"fa","fa-times","me-1"],[1,"text-center","py-2"],["role","status",1,"spinner-border","text-primary"],[1,"visually-hidden"],[1,"mt-2"],[1,"alert","alert-danger"],[1,"fa","fa-exclamation-triangle","me-2"],[1,"fa","fa-inbox","text-muted",2,"font-size","3rem"],[1,"text-muted","mt-2"],[1,"table-responsive"],[1,"table","table-striped","table-hover"],[1,"table-dark"],[1,"text-center",2,"width","50px"],["type","checkbox",1,"form-check-input",3,"change","checked","indeterminate"],[2,"width","50px"],[1,"text-end"],[3,"table-primary",4,"ngFor","ngForOf"],[1,"d-flex","justify-content-between","align-items-center","mt-2","no-print"],[1,"text-muted"],[1,"text-center"],["type","checkbox",1,"form-check-input",3,"change","checked"],[2,"white-space","nowrap"],[1,"badge",3,"ngClass"],[1,"pagination","pagination-sm","mb-0"],[1,"page-item",3,"ngClass"],[1,"page-link",3,"click","disabled"],[1,"fa","fa-chevron-left"],[1,"page-item"],[1,"page-link"],[1,"fa","fa-chevron-right"]],template:function(i,t){if(i&1){let a=I();r(0,"div",1)(1,"div",2)(2,"div",3)(3,"div",4)(4,"span",5),c(5,"i",6),n(),r(6,"input",7,0),ee("bsValueChange",function(m){return x(a),J(t.dateRangeValue,m)||(t.dateRangeValue=m),S(m)}),b("bsValueChange",function(m){return x(a),S(t.onDateRangeChange(m))}),n()(),r(8,"button",8),b("click",function(){return x(a),S(t.clearFilters())}),c(9,"i",9),n(),r(10,"div",4)(11,"span",5),c(12,"i",10),n(),r(13,"input",11),ee("ngModelChange",function(m){return x(a),J(t.filterSupplierName,m)||(t.filterSupplierName=m),S(m)}),b("input",function(){return x(a),S(t.onFilterChange())}),n()()()(),r(14,"div",12)(15,"div",13)(16,"div",14)(17,"span",15),o(18),n()(),r(19,"button",16),b("click",function(){return x(a),S(t.printSelectedForms())}),_(20,mr,3,0,"span",17)(21,ur,3,0,"span",17),n()()()(),_(22,gr,11,2,"div",18)(23,br,6,0,"div",19)(24,vr,3,1,"div",20)(25,xr,4,0,"div",19)(26,Er,28,6,"div",17)}i&2&&(d(6),p("bsConfig",t.bsConfig),X("bsValue",t.dateRangeValue),d(7),X("ngModel",t.filterSupplierName),d(5),A("",t.getSelectedFormsCount()," selected"),d(),p("disabled",t.getSelectedFormsCount()===0||t.printSelectedSubmitting),d(),p("ngIf",!t.printSelectedSubmitting),d(),p("ngIf",t.printSelectedSubmitting),d(),p("ngIf",(t.filterSupplierName||t.filterFromDate||t.filterToDate)&&!t.loading),d(),p("ngIf",t.loading),d(),p("ngIf",t.error&&!t.loading),d(),p("ngIf",!t.loading&&!t.error&&t.approvedForms.length===0),d(),p("ngIf",!t.loading&&!t.error&&t.approvedForms.length>0))},dependencies:[te,ie,W,j,H,ue,ft,ht,se,Q],styles:[".btn-print[_ngcontent-%COMP%]{transition:all .3s ease}.btn-print[_ngcontent-%COMP%]:hover{transform:translateY(-1px);box-shadow:0 2px 4px #0000001a}.btn-print[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.btn-sm.btn-outline-primary[_ngcontent-%COMP%]{transition:all .2s ease;border-radius:4px}.btn-sm.btn-outline-primary[_ngcontent-%COMP%]:hover{transform:scale(1.05);box-shadow:0 2px 4px #00000026}.btn-sm.btn-outline-primary[_ngcontent-%COMP%]:active{transform:scale(.95)}.form-check-input[_ngcontent-%COMP%]{cursor:pointer}.form-check-input[_ngcontent-%COMP%]:checked{background-color:#0d6efd;border-color:#0d6efd}.table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   tr.table-primary[_ngcontent-%COMP%]{background-color:#0d6efd1a!important}.table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   tr.table-primary[_ngcontent-%COMP%]:hover{background-color:#0d6efd33!important}.bulk-actions[_ngcontent-%COMP%]{transition:all .3s ease}.bulk-actions[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]{transition:all .2s ease}.bulk-actions[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]:hover{transform:translateY(-1px);box-shadow:0 2px 4px #0000001a}.badge[_ngcontent-%COMP%]{font-size:.875rem;padding:.5rem .75rem}.table[_ngcontent-%COMP%]   thead[_ngcontent-%COMP%]   th[_ngcontent-%COMP%]   .form-check-input[_ngcontent-%COMP%], .table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]   .form-check-input[_ngcontent-%COMP%]{margin:0}@media (max-width: 768px){.bulk-actions[_ngcontent-%COMP%]{flex-direction:column;align-items:stretch!important}.bulk-actions[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]{margin-bottom:.5rem}.table-responsive[_ngcontent-%COMP%]{font-size:.875rem}}@media print{.no-print[_ngcontent-%COMP%]{display:none!important}.container-fluid[_ngcontent-%COMP%]{margin:0!important;padding:0!important}.card[_ngcontent-%COMP%]{border:none!important;box-shadow:none!important}.card-body[_ngcontent-%COMP%]{padding:0!important}}"]})}return l})();var vi=(()=>{class l{router;route;constructor(e,i){this.router=e,this.route=i}ngOnInit(){this.route.firstChild===null&&this.router.navigate(["supplier"],{relativeTo:this.route})}static \u0275fac=function(i){return new(i||l)(D(ne),D(ut))};static \u0275cmp=q({type:l,selectors:[["app-create-form-selection"]],decls:3,vars:0,consts:[[1,"container-fluid","flex-grow"],[1,"form-container"]],template:function(i,t){i&1&&(r(0,"div",0)(1,"div",1),c(2,"router-outlet"),n()())},dependencies:[ce],styles:[".form-container[_ngcontent-%COMP%]{width:100%;min-height:500px;margin:0;border-radius:0}.active-btn[_ngcontent-%COMP%]{background-color:#0d6efd!important;color:#fff!important;border-color:#0d6efd!important}"]})}return l})();var It=Ye(Ge());var rl={headers:new de({"Content-Type":"application/json"})},xi=(()=>{class l{http;constructor(e){this.http=e}createStaffExpenseForm(e){return this.http.post(R.URI+"/api/staffExpenseForm/create",e)}getStaffExpenseForms(e=0,i=100,t){let a=R.URI+`/api/staffExpenseForm/get?start=${e}&count=${i}`;return t!==void 0&&(a+=`&draft=${t}`),this.http.get(a)}getStaffExpenseFormsByStatus(e=0,i=100){return this.http.get(R.URI+`/api/staffExpenseForm/get?status=PUBLISHED&start=${e}&count=${i}`)}getStaffExpenseFormById(e){return this.http.get(R.URI+"/api/staffExpenseForm/"+e)}updateStaffExpenseForm(e,i){return this.http.put(R.URI+"/api/staffExpenseForm/update/"+e,i)}deleteStaffExpenseForm(e){return this.http.delete(R.URI+"/api/staffExpenseForm/delete/"+e)}publishStaffExpenseForms(e){return this.http.post(R.URI+"/api/staffExpenseForm/publish",e)}createRequestFormForApproval(e){return this.http.post(R.URI+"/api/requestform/create",e)}submitForApproval(e,i={}){return this.http.post(R.URI+"/api/staffExpenseForm/submitForApproval?id="+e,i)}getRequestForms(e){let i=R.URI+"/api/requestform/get?requestType=STAFFEXPENSE&order=des";return e&&(i+="&status="+e),this.http.get(i)}getPendingRequestForms(){return this.http.get(R.URI+"/api/requestform/get?requestType=STAFFEXPENSE&status=PENDING&order=des")}getApprovedRequestForms(e=0,i=100,t){let a=R.URI+"/api/requestform/approvedPaymentForms?requestType=STAFFEXPENSE&start="+e+"&count="+i;return t?.from!=null&&(a+="&from="+t.from),t?.to!=null&&(a+="&to="+t.to),t?.chequeOnly&&(a+="&chequeOnly=true"),t?.nameSearch&&t.n
1343ameSearch.trim()&&(a+="&nameSearch="+encodeURIComponent(t.nameSearch.trim())),this.http.get(a)}getPreApprovedRequestForms(){return this.http.get(R.URI+"/api/requestform/get?requestType=STAFFEXPENSE&approvalType=PRE_APPROVED&order=des")}static \u0275fac=function(i){return new(i||l)(Z(pe))};static \u0275prov=oe({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var ol={headers:new de({"Content-Type":"application/json"})},Ue=(()=>{class l{http;cookieService;staffExpenseFormProvider;constructor(e,i,t){this.http=e,this.cookieService=i,this.staffExpenseFormProvider=t}createStaffExpenseForm(e){return new Promise((i,t)=>{this.staffExpenseFormProvider.createStaffExpenseForm(e).subscribe(a=>{i(a)},a=>{console.error("Error creating staff expense form:",a),t(a)})})}getStaffExpenseForms(e=0,i=100,t){return new Promise((a,s)=>{this.staffExpenseFormProvider.getStaffExpenseForms(e,i,t).subscribe(m=>{a(m)},m=>{console.error("Error fetching staff expense forms:",m),s(m)})})}getStaffExpenseFormsByStatus(e=0,i=100){return new Promise((t,a)=>{this.staffExpenseFormProvider.getStaffExpenseFormsByStatus(e,i).subscribe(s=>{t(s)},s=>{console.error("Error fetching staff expense forms by status:",s),a(s)})})}getStaffExpenseFormById(e){return new Promise((i,t)=>{this.staffExpenseFormProvider.getStaffExpenseFormById(e).subscribe(a=>{i(a)},a=>{console.error("Error fetching staff expense form by ID:",a),t(a)})})}updateStaffExpenseForm(e,i){return new Promise((t,a)=>{this.staffExpenseFormProvider.updateStaffExpenseForm(e,i).subscribe(s=>{t(s)},s=>{console.error("Error updating staff expense form:",s),a(s)})})}deleteStaffExpenseForm(e){return new Promise((i,t)=>{this.staffExpenseFormProvider.deleteStaffExpenseForm(e).subscribe(a=>{i(a)},a=>{console.error("Error deleting staff expense form:",a),t(a)})})}publishStaffExpenseForms(e){return new Promise((i,t)=>{this.staffExpenseFormProvider.publishStaffExpenseForms(e).subscribe(a=>{i(a)},a=>{console.error("Error publishing staff expense forms:",a),t(a)})})}createRequestFormForApproval(e){return new Promise((i,t)=>{this.staffExpenseFormProvider.createRequestFormForApproval(e).subscribe(a=>{i(a)},a=>{console.error("Error creating request form for approval:",a),t(a)})})}submitForApproval(e,i={}){return new Promise((t,a)=>{this.staffExpenseFormProvider.submitForApproval(e,i).subscribe(s=>{t(s)},s=>{console.error("Error submitting staff expense form for approval:",s),a(s)})})}getRequestForms(e){return new Promise((i,t)=>{this.staffExpenseFormProvider.getRequestForms(e).subscribe(a=>{i(a)},a=>{console.error("Error fetching request forms:",a),t(a)})})}getPendingRequestForms(){return new Promise((e,i)=>{this.staffExpenseFormProvider.getPendingRequestForms().subscribe(t=>{e(t)},t=>{console.error("Error fetching pending request forms:",t),i(t)})})}getApprovedRequestForms(e=0,i=100,t){return new Promise((a,s)=>{this.staffExpenseFormProvider.getApprovedRequestForms(e,i,t).subscribe(m=>{a(m)},m=>{console.error("Error fetching approved request forms:",m),s(m)})})}getPreApprovedRequestForms(){return new Promise((e,i)=>{this.staffExpenseFormProvider.getPreApprovedRequestForms().subscribe(t=>{e(t)},t=>{console.error("Error fetching pre-approved request forms:",t),i(t)})})}checkClaimExists(e,i,t){return new Promise((a,s)=>{this.getStaffExpenseForms(0,1e3).then(m=>{let u=m.some(h=>h.nameOfStaff&&h.nameOfStaff.toString().trim().toLowerCase()===e.toString().trim().toLowerCase()&&h.date&&h.date.toString().trim()===i.toString().trim()&&h.typeOfClaim&&h.typeOfClaim.toString().trim().toLowerCase()===t.toString().trim().toLowerCase());a(u)}).catch(m=>{s(m)})})}static \u0275fac=function(i){return new(i||l)(Z(pe),Z(Qe),Z(xi))};static \u0275prov=oe({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var ze=l=>({"is-invalid":l});function Fr(l,f){l&1&&(r(0,"div",86),o(1," Staff Name is required. "),n())}function Dr(l,f){l&1&&(r(0,"div",86),o(1," Department is required. "),n())}function Pr(l,f){l&1&&(r(0,"div",86),o(1," Designation is required. "),n())}function Ar(l,f){l&1&&(r(0,"div",86),o(1," Type of Claim is required. "),n())}function Ir(l,f){l&1&&(r(0,"div",86),o(1," Date is required. "),n())}function kr(l,f){l&1&&(r(0,"div",86),o(1," Venue is required. "),n())}function Tr(l,f){l&1&&(r(0,"div",86),o(1," Total Amount is required and must be positive. "),n())}function Nr(l,f){l&1&&(r(0,"div",86),o(1," Particulars are required and must be at least 5 characters. "),n())}function Mr(l,f){if(l&1&&(r(0,"div",87),c(1,"i",88),o(2),n()),l&2){let e=g(2);d(2),w(e.submitError)}}function Vr(l,f){if(l&1){let e=I();r(0,"form",59),b("ngSubmit",function(){x(e);let t=g();return S(t.onSubmit())}),r(1,"div",60)(2,"div",61)(3,"label",62),o(4,"Name of Staff"),n(),r(5,"div",48),c(6,"input",63,0),r(8,"button",64),b("click",function(){x(e);let t=g();return S(t.openStaffPicker())}),c(9,"i",50),n()(),_(10,Fr,2,0,"div",65),n(),r(11,"div",61)(12,"label",66),o(13,"ID No"),n(),c(14,"input",67),n()(),r(15,"div",60)(16,"div",61)(17,"label",68),o(18,"Department"),n(),c(19,"input",69),_(20,Dr,2,0,"div",65),n(),r(21,"div",61)(22,"label",70),o(23,"Designation"),n(),c(24,"input",71),_(25,Pr,2,0,"div",65),n()(),r(26,"div",60)(27,"div",61)(28,"label",72),o(29,"Type of Claim"),n(),c(30,"input",73,1),_(32,Ar,2,0,"div",65),n(),r(33,"div",61)(34,"label",74),o(35,"Date"),n(),c(36,"input",75,2),_(38,Ir,2,0,"div",65),n()(),r(39,"div",60)(40,"div",61)(41,"label",76),o(42,"Venue"),n(),c(43,"input",77),_(44,kr,2,0,"div",65),n(),r(45,"div",61)(46,"label",78),o(47,"Total Amount (\u20B9)"),n(),c(48,"input",79),_(49,Tr,2,0,"div",65),n()(),r(50,"div",60)(51,"div",47)(52,"label",80),o(53,"Particulars"),n(),c(54,"textarea",81),_(55,Nr,2,0,"div",65),n()(),r(56,"div",82)(57,"button",83),
1343c(58,"i",84),o(59,"Continue "),n(),_(60,Mr,3,1,"div",85),n()()}if(l&2){let e,i,t,a,s,m,u,h,v,E,y,F,k,V,Y,O,C=g();p("formGroup",C.staffExpenseForm),d(6),p("ngClass",$(20,ze,((e=C.staffExpenseForm.get("nameOfStaff"))==null?null:e.invalid)&&((e=C.staffExpenseForm.get("nameOfStaff"))==null?null:e.touched))),d(4),p("ngIf",((i=C.staffExpenseForm.get("nameOfStaff"))==null?null:i.invalid)&&((i=C.staffExpenseForm.get("nameOfStaff"))==null?null:i.touched)),d(9),p("ngClass",$(22,ze,((t=C.staffExpenseForm.get("dept"))==null?null:t.invalid)&&((t=C.staffExpenseForm.get("dept"))==null?null:t.touched))),d(),p("ngIf",((a=C.staffExpenseForm.get("dept"))==null?null:a.invalid)&&((a=C.staffExpenseForm.get("dept"))==null?null:a.touched)),d(4),p("ngClass",$(24,ze,((s=C.staffExpenseForm.get("designation"))==null?null:s.invalid)&&((s=C.staffExpenseForm.get("designation"))==null?null:s.touched))),d(),p("ngIf",((m=C.staffExpenseForm.get("designation"))==null?null:m.invalid)&&((m=C.staffExpenseForm.get("designation"))==null?null:m.touched)),d(5),p("ngClass",$(26,ze,((u=C.staffExpenseForm.get("typeOfClaim"))==null?null:u.invalid)&&((u=C.staffExpenseForm.get("typeOfClaim"))==null?null:u.touched))),d(2),p("ngIf",((h=C.staffExpenseForm.get("typeOfClaim"))==null?null:h.invalid)&&((h=C.staffExpenseForm.get("typeOfClaim"))==null?null:h.touched)),d(4),p("bsConfig",C.bsConfig)("ngClass",$(28,ze,((v=C.staffExpenseForm.get("date"))==null?null:v.invalid)&&((v=C.staffExpenseForm.get("date"))==null?null:v.touched))),d(2),p("ngIf",((E=C.staffExpenseForm.get("date"))==null?null:E.invalid)&&((E=C.staffExpenseForm.get("date"))==null?null:E.touched)),d(5),p("ngClass",$(30,ze,((y=C.staffExpenseForm.get("venue"))==null?null:y.invalid)&&((y=C.staffExpenseForm.get("venue"))==null?null:y.touched))),d(),p("ngIf",((F=C.staffExpenseForm.get("venue"))==null?null:F.invalid)&&((F=C.staffExpenseForm.get("venue"))==null?null:F.touched)),d(4),p("ngClass",$(32,ze,((k=C.staffExpenseForm.get("total"))==null?null:k.invalid)&&((k=C.staffExpenseForm.get("total"))==null?null:k.touched))),d(),p("ngIf",((V=C.staffExpenseForm.get("total"))==null?null:V.invalid)&&((V=C.staffExpenseForm.get("total"))==null?null:V.touched)),d(5),p("ngClass",$(34,ze,((Y=C.staffExpenseForm.get("particulars"))==null?null:Y.invalid)&&((Y=C.staffExpenseForm.get("particulars"))==null?null:Y.touched))),d(),p("ngIf",((O=C.staffExpenseForm.get("particulars"))==null?null:O.invalid)&&((O=C.staffExpenseForm.get("particulars"))==null?null:O.touched)),d(2),p("disabled",C.staffExpenseForm.invali
1343d||C.submitting),d(3),p("ngIf",C.submitError)}}function Or(l,f){l&1&&c(0,"span",108)}function Rr(l,f){l&1&&c(0,"span",108)}function qr(l,f){l&1&&c(0,"span",108)}function Lr(l,f){l&1&&c(0,"span",108)}function Br(l,f){if(l&1){let e=I();r(0,"div",89)(1,"div",90),c(2,"i",91),r(3,"strong"),o(4,"Form validated successfully!"),n(),o(5," Please choose what you would like to do next: "),n(),r(6,"div",92)(7,"div",93)(8,"div",94)(9,"div",95),c(10,"i",96),r(11,"h5",97),o(12,"Save as Draft"),n(),r(13,"p",98),o(14,"Save this form as a draft for later editing and review."),n(),r(15,"button",99),b("click",function(){x(e);let t=g();return S(t.saveAsDraft())}),_(16,Or,1,0,"span",20),c(17,"i",21),o(18,"Save as Draft "),n()()()(),r(19,"div",93)(20,"div",100)(21,"div",95),c(22,"i",101),r(23,"h5",97),o(24,"Send to Approval"),n(),r(25,"p",98),o(26,"Submit this form for approval workflow. It will be sent to approvers."),n(),r(27,"button",102),b("click",function(){x(e);let t=g();return S(t.sendToApproval())}),_(28,Rr,1,0,"span",20),c(29,"i",29),o(30,"Send to Approval "),n()()()(),r(31,"div",93)(32,"div",103)(33,"div",95),c(34,"i",39),r(35,"h5",97),o(36,"Pre-Approved"),n(),r(37,"p",98),o(38,"Paper verified; final e-sign and cheque in system."),n(),r(39,"button",104),b("click",function(){x(e);let t=g();return S(t.sendToPreApproval())}),_(40,qr,1,0,"span",20),c(41,"i",40),o(42,"Pre-Approved "),n()()()(),r(43,"div",93)(44,"div",105)(45,"div",95),c(46,"i",34),r(47,"h5",97),o(48,"Without Cheque"),n(),r(49,"p",98),o(50,"Cash, transfer, or adjustment \u2014 final e-sign only."),n(),r(51,"button",106),b("click",function(){x(e);let t=g();return S(t.sendToWithoutCheque())}),_(52,Lr,1,0,"span",20),c(53,"i",107),o(54,"Without Cheque "),n()()()()()()}if(l&2){let e=g();d(15),p("disabled",e.draftSubmitting),d(),p("ngIf",e.draftSubmitting),d(11),p("disabled",e.approvalSubmitting),d(),p("ngIf",e.approvalSubmitting),d(11),p("disabled",e.preApprovalSubmitting),d(),p("ngIf",e.preApprovalSubmitting),d(11),p("disabled",e.withoutChequeSubmitting),d(),p("ngIf",e.withoutChequeSubmitting)}}function $r(l,f){l&1&&c(0,"span",108)}function Ur(l,f){l&1&&c(0,"span",108)}function zr(l,f){l&1&&c(0,"span",108)}function Yr(l,f){l&1&&c(0,"span",108)}function Gr(l,f){l&1&&(r(0,"div",109),c(1,"div",110),r(2,"p",111),o(3,"Loading staff..."),n()())}function Wr(l,f){l&1&&(r(0,"div",112),c(1,"i",91),o(2,"No staff found. "),n())}function jr(l,f){if(l&1){let e=I();r(0,"tr")(1,"td"),o(2),n(),r(3,"td"),o(4),n(),r(5,"td"),o(6),n(),r(7,"td",120)(8,"button",121),b("click",function(){let t=x(e).$implicit,a=g(2);return S(a.addStaffToForm(t))}),c(9,"i",122),o(10,"Add "),n()()()}if(l&2){let e=f.$implicit;d(2),w((e==null?null:e.name)||(e==null?null:e.employeeName)||(e==null?null:e.empName)||(e==null?null:e.fullName)||(e==null?null:e.userName)||(e==null||e.emerAddressline==null?null:e.emerAddressline.emerName)||(e==null||e.emerAddressLine==null?null:e.emerAddressLine.emerName)||"-"),d(2),w((e==null?null:e.designation)||(e==null?null:e.role)||(e==null?null:e.title)||"-"),d(2),w((e==null?null:e.department)||(e==null?null:e.departmentname)||(e==null?null:e.departmentName)||(e==null?null:e.dept)||"-")}}function Hr(l,f){if(l&1&&(r(0,"div",113)(1,"table",114)(2,"thead",115)(3,"tr")(4,"th",116),o(5,"Name"),n(),r(6,"th",117),o(7,"Designation"),n(),r(8,"th",117),o(9,"Department"),n(),r(10,"th",118),o(11,"Action"),n()()(),r(12,"tbody"),_(13,jr,11,3,"tr",119),n()()()),l&2){let e=g();d(13),p("ngForOf",e.filteredStaff)}}function Zr(l,f){l&1&&(r(0,"div",123),c(1,"div",124),r(2,"span",125),o(3,"Loading more..."),n()())}function Qr(l,f){if(l&1&&(r(0,"small",126),o(1),n()),l&2){let e=g();d(),A(" Showing ",e.filteredStaff.length," staff members ")}}var Je=It.default??It,Si=(()=>{class l{fb;staffExpenseFormService;router;toastr;userService;bsLocaleService;staffExpenseForm;submitting=!1;draftSubmitting=!1;approvalSubmitting=!1;preApprovalSubmitting=!1;submitSuccess=!1;submitError="";showOptions=!1;formData=null;confirmSaveDraftModal;confirmApprovalModal;confirmPreApprovalModal;withoutChequeSubmitting=!1;staffDetails=[];isStaffLoading;staffPickerModal;filteredStaff=[];staffSearchTerm="";ncount;pageSize;isProgressiveLoading=!1;currentBatch=0;totalBatches=0;loadedBatches=0;hasMoreStaff=!0;loadedStaffIds=new Set;bsConfig={dateInputFormat:"DD/MM/YYYY",containerClass:"theme-default",showWeekNumbers:!1};constructor(e,i,t,a,s,m){this.fb=e,this.staffExpenseFormService=i,this.router=t,this.toastr=a,this.userService=s,this.bsLocaleService=m,this.staffExpenseForm=this.fb.group({nameOfStaff:["",P.required],designation:["",P.required],dept:["",P.required],idNo:[""],typeOfClaim:["",P.required],particulars:["",[P.required,P.minLength(5)]],date:["",P.required],venue:["",P.required],total:["",[P.required,P.min(0)]]})}ngOnInit(){Je.locale("en-GB"),ve("en-gb",xe),this.bsLocaleService.use("en-gb"),this.getAllStaffs()}getAllStaffs(){return M(this,null,function*(){this.isStaffLoading=!0,this.staffDetails=[],this.isProgressiveLoading=!1,this.currentBatch=0,this.loadedBatches=0,this.hasMoreStaff=!0;try{let e=yield this.userService.getAllUserStaffs(),i=Array.isArray(e)?e:e?.content||e?.items||e?.details||[];console.log(`Fetched all staff, size=${i.length}`),i&&i.length>0&&this.staffDetails.push(...i),this.filteredStaff=[...this.staffDetails],this.isStaffLoading=!1,console.log("Total staff fetched:",this.staffDetails.length)}catch(e){console.error("Error loading staff:",e),this.isStaffLoading=!1}})}loadStaffProgressive(){return M(this,null,function*(){this.isProgressiveLoading=!0,this.staffDetails=[],this.filteredStaff=[],this.currentBatch=0,this.loadedBatches=0,this.hasMoreStaff=!0,this.loadedStaffIds.clear(),yield this.loadNextStaffBatch()})}loadNextStaffBatch(){return M(this,null,function*(){if(!(!this.hasMoreStaff||this.isStaffLoading)){this.isStaffLoading=!0;try{if(this.currentBatch>0){this.hasMoreStaff=!1,this.isProgressiveLoading=!1,this.isStaffLoading=!1;return}let e=yield this.userService.getAllUserStaffs(),i=Array.isArray(e)?e:e?.content||e?.items||e?.details||[];if(console.log(`Progressive: Fetched all staff, size=${i.length}`),!i||i.length===0){this.hasMoreStaff=!1,this.isStaffLoading=!1,this.isProgressiveLoading=!1;return}let t=this.filterDuplicates(i);console.log(`After duplicate filtering: ${t.length} unique records from ${i.length} total`),this.staffDetails.push(...t),this.loadedBatches++,this.currentBatch++,this.updateFilteredStaff(),this.hasMoreStaff=!1,this.isProgressiveLoading=!1,this.isStaffLoading=!1}catch(e){console.error("Error loading staff batch:",e),this.hasMoreStaff=!1,this.isProgressiveLoading=!1,this.isStaffLoading=!1}}})}filterDuplicates(e){let i=[];for(let t of e){let a=this.getStaffUniqueId(t);if(a&&!this.loadedStaffIds.has(a))this.loadedStaffIds.add(a),i.push(t);else if(!a){let s=this.getStaffName(t),m=this.getStaffPhone(t),u=`${s}_${m}`;this.loadedStaffIds.has(u)||(this.loadedStaffIds.add(u),i.push(t))}}return i}getStaffUniqueId(e){return e?.id||e?._id||e?.staffId||e?.employeeId||e?.empId||e?.userId||e?.user?.id||e?.user?._id||""}updateFilteredStaff(){!this.staffSearchTerm||this.staffSearchTerm.trim()===""?this.filteredStaff=[...this.staffDetails]:this.onStaffSearchChange(this.staffSearchTerm)}getStaffName(e){return e?.name||e?.employeeName||e?.empName||e?.fullName||e?.userName||e?.emerAddressline?.emerName||e?.emerAddressLine?.emerName||""}getStaffPhone(e){return e?.phone||e?.mobile||e?.contactNo||e?.altContactNo||e?.attContactNo||e?.emerAddressline?.emerMobile||e?.emerAddressLine?.emerMobile||""}getStaffDepartment(e){return e?.department||e?.departmentname||e?.departmentName||e?.dept||""}getStaffDesignation(e){return e?.designation||e?.role||e?.title||""}openStaffPicker(){this.staffSearchTerm="",this.filteredStaff=[...this.staffDetails];let e=document.getElementById("staffExpenseSelectStaffModal");e&&(this.staffPickerModal=new window.bootstrap.Modal(e),this.staffPickerModal.show(),this.staffDetails.length===0&&this.loadStaffProgressive())}onStaffSearchChange(e){this.staffSearchTerm=e||"";let i=this.staffSearchTerm.trim().toLowerCase();if(!i){this.filteredStaff=[...this.staffDetails];return}this.filteredStaff=this.staffDetails.filter(t=>{let a=this.getStaffName(t).toLowerCase(),s=this.getStaffPhone(t).toLowerCase(),m=this.getStaffDepartment(t).toLowerCase(),u=this.getStaffDesignation(t).toLowerCase();return a.includes(i)||s.includes(i)||m.includes(i)||u.includes(i)})}addStaffToForm(e){let i=this.getStaffName(e),t=this.getStaffDesignation(e),a=this.getStaffDepartment(e);this.staffExpenseForm.patchValue({nameOfStaff:i,designation:t,dept:a}),this.staffPickerModal&&this.staffPickerModal.hide()}resetStaffData(){this.staffDetails=[],this.filteredStaff=[],this.staffSearchTerm="",this.isProgressiveLoading=!1,this.currentBatch=0,this.loadedBatches=0,this.hasMoreStaff=!0,this.loadedStaffIds.clear()}
1343resetLoadingStates(){this.submitting=!1,this.draftSubmitting=!1,this.approvalSubmitting=!1,this.preApprovalSubmitting=!1}closeModal(e){let i=document.getElementById(e);if(!i)return;let t=window.bootstrap,s=t?.Modal?.getInstance?.(i)||new t.Modal(i);try{s.hide(),s.dispose?.()}catch{}document.querySelectorAll(".modal-backdrop").forEach(u=>u.remove()),document.body.classList.remove("modal-open"),document.body.style.paddingRight="",document.body.style.overflow="",document.body.style.position="",document.body.style.top=""}cleanupAfterNavigation(){document.querySelectorAll(".modal-backdrop").forEach(i=>i.remove()),document.body.classList.remove("modal-open"),document.body.style.paddingRight="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",window.scrollTo(0,0),document.documentElement.style.overflow="",document.body.style.overflow=""}onSubmit(){if(this.staffExpenseForm.invalid){this.staffExpenseForm.markAllAsTouched();return}let e=this.staffExpenseForm.get("nameOfStaff")?.value,i=this.staffExpenseForm.get("date")?.value;if(i instanceof Date)i=Je(i).format("YYYY-MM-DD");else if(i&&typeof i=="string"){let a=Je(i,"DD/MM/YYYY");a.isValid()&&(i=a.format("YYYY-MM-DD"))}let t=this.staffExpenseForm.get("typeOfClaim")?.value;this.staffExpenseFormService.checkClaimExists(e,i,t).then(a=>{if(a){this.toastr.warning("A claim for this staff member on this date with this claim type already exists. Please check your details.","Duplicate Claim",{timeOut:3e3,progressBar:!0});return}let s=this.staffExpenseForm.getRawValue(),m=s.date;if(s.date instanceof Date)m=Je(s.date).format("YYYY-MM-DD");else if(s.date&&typeof s.date=="string"){let u=Je(s.date,"DD/MM/YYYY");u.isValid()&&(m=u.format("YYYY-MM-DD"))}this.formData=N(T({},s),{date:m,total:parseInt(s.total)||0}),this.submitError="",this.resetLoadingStates(),this.showOptions=!0,this.toastr.success("Form validated successfully!","Success",{timeOut:2e3,progressBar:!0}),setTimeout(()=>{let u=document.querySelector(".options-section");u&&u.scrollIntoView({behavior:"smooth",block:"start"})},300)})}saveAsDraft(){if(!this.formData){this.toastr.error("No form data available.","Error",{timeOut:4e3,progressBar:!0});return}let e=new window.bootstrap.Modal(document.getElementById("staffExpenseConfirmSaveDraftModal"));e.show(),this.confirmSaveDraftModal=e}confirmSaveAsDraft(){this.draftSubmitting=!0;let e=N(T({},this.formData),{draft:!0});this.staffExpenseFormService.createStaffExpenseForm(e).then(i=>{this.closeModal("staffExpenseConfirmSaveDraftModal"),this.toastr.success("Form saved as draft successfully!","Success",{timeOut:1500,progressBar:!0}),setTimeout(()=>{this.showOptions=!1,this.staffExpenseForm.reset(),this.formData=null,this.router.navigate(["supplier/drafts/staff"]),this.cleanupAfterNavigation()},800)}).catch(i=>{this.toastr.error("Failed to save as draft.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.draftSubmitting=!1})}sendToApproval(){if(!this.formData){this.toastr.error("No form data available.","Error",{timeOut:4e3,progressBar:!0});return}let e=new window.bootstrap.Modal(document.getElementById("staffExpenseConfirmApprovalModal"));e.show(),this.confirmApprovalModal=e}confirmSendToApproval(){this.approvalSubmitting=!0;let e=N(T({},this.formData),{draft:!1,approvalType:"NONE"});this.staffExpenseFormService.createStaffExpenseForm(e).then(i=>{let t=i._id||i.id||"";return console.log("Created Staff Expense Form ID:",t),this.staffExpenseFormService.submitForApproval(t)}).then(()=>{this.closeModal("staffExpenseConfirmApprovalModal"),this.toastr.success("Form sent for approval successfully!","Success",{timeOut:1500,progressBar:!0}),setTimeout(()=>{this.showOptions=!1,this.staffExpenseForm.reset(),this.formData=null,this.router.navigate(["supplier/publish/staff"]),this.cleanupAfterNavigation()},800)}).catch(i=>{this.toastr.error("Failed to send for approval.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.approvalSubmitting=!1})}sendToPreApproval(){if(!this.formData){this.toastr.error("No form data available.","Error",{timeOut:4e3,progressBar:!0});return}let e=new window.bootstrap.Modal(document.getElementById("staffExpenseConfirmPreApprovalModal"));e.show(),this.confirmPreApprovalModal=e}confirmSendToPreApproval(){this.preApprovalSubmitting=!0;let e=N(T({},this.formData),{draft:!1,approvalType:"PRE_APPROVED"});this.staffExpenseFormService.createStaffExpenseForm(e).then(i=>{let t=i._id||i.id||"";return console.log("Created Staff Expense Form ID:",t),this.staffExpenseFormService.submitForApproval(t)}).then(()=>{this.closeModal("staffExpenseConfirmPreApprovalModal"),this.toastr.success("Form pre-approved and published successfully!","Success",{timeOut:1500,progressBar:!0}),setTimeout(()=>{this.showOptions=!1,this.staffExpenseForm.reset(),this.formData=null,this.router.navigate(["supplier/publish/staff"]),this.cleanupAfterNavigation()},800)}).catch(i=>{this.toastr.error("Failed to pre-approve form.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.preApprovalSubmitting=!1})}sendToWithoutCheque(){if(!this.formData){this.toastr.error("No form data available.","Error",{timeOut:4e3,progressBar:!0});return}new window.bootstrap.Modal(document.getElementById("staffExpenseConfirmWithoutChequeModal")).show()}confirmSendToWithoutCheque(){this.withoutChequeSubmitting=!0;let e=N(T({},this.formData),{draft:!1,approvalType:"WITHOUT_CHEQUE"});delete e.chequeNo,this.staffExpenseFormService.createStaffExpenseForm(e).then(i=>{let t=i._id||i.id||"",a={approvalType:"WITHOUT_CHEQUE",draft:!1};return this.staffExpenseFormService.submitForApproval(t,a)}).then(()=>{this.closeModal("staffExpenseConfirmWithoutChequeModal"),this.toastr.success("Form submitted for approval (without cheque).","Success",{timeOut:1500,progressBar:!0}),setTimeout(()=>{this.showOptions=!1,this.staffExpenseForm.reset(),this.formData=null,this.router.navigate(["supplier/publish/staff"]),this.cleanupAfterNavigation()},800)}).catch(()=>{this.toastr.error("Failed to submit without-cheque form.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.withoutChequeSubmitting=!1})}static \u0275fac=function(i){return new(i||l)(D(be),D(Ue),D(ne),D(K),D(Qt),D(Se))};static \u0275cmp=q({type:l,selectors:[["app-staff-expense-form"]],decls:112,vars:16,consts:[["nameOfStaffInput",""],["typeOfClaim",""],["dateInput",""],[3,"formGroup","ngSubmit",4,"ngIf"],["class","options-section animate__animated animate__fadeIn mt-4",4,"ngIf"],["id","staffExpenseConfirmSaveDraftModal","tabindex","-1","aria-labelledby","staffExpenseConfirmSaveDraftModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-dialog","modal
1343-dialog-centered"],[1,"modal-content"],[1,"modal-header","bg-success","text-white"],["id","staffExpenseConfirmSaveDraftModalLabel",1,"modal-title"],[1,"fa","fa-file-text","me-2"],["type","button","data-bs-dismiss","modal","aria-label","Close",1,"btn-close","btn-close-white"],[1,"modal-body","text-center"],[1,"fa","fa-check-circle","text-success",2,"font-size","3rem"],[1,"mt-3"],[1,"text-muted","mb-0"],[1,"modal-footer"],["type","button","data-bs-dismiss","modal",1,"btn","btn-secondary"],[1,"fa","fa-x-circle","me-1"],["type","button",1,"btn","btn-success",3,"click","disabled"],["class","spinner-border spinner-border-sm me-2",4,"ngIf"],[1,"fa","fa-save","me-1"],["id","staffExpenseConfirmApprovalModal","tabindex","-1","aria-labelledby","staffExpenseConfirmApprovalModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-warning","text-dark"],["id","staffExpenseConfirmApprovalModalLabel",1,"modal-title"],[1,"fa","fa-exclamation-triangle","me-2"],["type","button","data-bs-dismiss","modal","aria-label","Close",1,"btn-close"],[1,"fa","fa-send-check","text-warning",2,"font-size","3rem"],["type","button",1,"btn","btn-warning",3,"click","disabled"],[1,"fa","fa-send","me-1"],["id","staffExpenseConfirmWithoutChequeModal","tabindex","-1","aria-labelledby","staffExpenseConfirmWithoutChequeModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-secondary","text-white"],["id","staffExpenseConfirmWithoutChequeModalLabel",1,"modal-title"],[1,"fa","fa-ban","me-2"],[1,"fa","fa-money","text-secondary",2,"font-size","3rem"],["type","button",1,"btn","btn-secondary",3,"click","disabled"],["id","staffExpenseConfirmPreApprovalModal","tabindex","-1","aria-labelledby","staffExpenseConfirmPreApprovalModalLabel","aria-hidden","true",1,"modal","fade"],["id","staffExpenseConfirmPreApprovalModalLabel",1,"modal-title"],[1,"fa","fa-check-circle","me-2"],[1,"fa","fa-check-circle","text-warning",2,"font-size","3rem"],[1,"fa","fa-check","me-1"],["id","staffExpenseSelectStaffModal","tabindex","-1","aria-labelledby","staffExpenseSelectStaffModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-dialog","modal
1343-lg","modal-dialog-centered"],["id","staffExpenseSelectStaffModalLabel",1,"modal-title"],[1,"fa","fa-users","me-2"],[1,"modal-body"],[1,"row","g-3","mb-3"],[1,"col-12"],[1,"input-group"],[1,"input-group-text"],[1,"fa","fa-search"],["type","text","placeholder","Search by name, phone, department, designation",1,"form-control",3,"input","value"],["class","text-center py-4",4,"ngIf"],["class","alert alert-light border",4,"ngIf"],["class","table-responsive","style","max-height: 50vh; overflow:auto;",4,"ngIf"],["class","text-center mt-3",4,"ngIf"],[1,"d-flex","justify-content-between","align-items-center","w-100"],["class","text-muted",4,"ngIf"],["type","button","data-bs-dismiss","modal",1,"btn","btn-secondary",3,"click"],[3,"ngSubmit","formGroup"],[1,"row"],[1,"col-md-6"],["for","nameOfStaff",1,"form-label"],["id","nameOfStaff","type","text","formControlName","nameOfStaff","placeholder","Select or type Staff Name","required","",1,"form-control",3,"ngClass"],["type","button",1,"btn","btn-outline-secondary",3,"click"],["class","invalid-feedback",4,"ngIf"],["for","idNo",1,"form-label"],["id","idNo","type","text","formControlName","idNo","placeholder","Enter ID Number",1,"form-control"],["for","dept",1,"form-label"],["id","dept","type","text","formControlName","dept","placeholder","Enter Department","required","",1,"form-control",3,"ngClass"],["for","designation",1,"form-label"],["id","designation","type","text","formControlName","designation","placeholder","Enter Designation","required","",1,"form-control",3,"ngClass"],["for","typeOfClaim",1,"form-label"],["id","typeOfClaim","type","text","formControlName","typeOfClaim","placeholder","Enter claim type (e.g., Travel, Medical)","required","",1,"form-control",3,"ngClass"],["for","date",1,"form-label"],["id","date","type","text","formControlName","date","bsDatepicker","","placeholder","DD/MM/YYYY","required","",1,"form-control",3,"bsConfig","ngClass"],["for","venue",1,"form-label"],["id","venue","type","text","formControlName","venue","placeholder","Enter Venue","required","",1,"form-control",3,"ngClass"],["for","total",1,"form-label"],["id","total","type","number","formControlName","total","min","0","step","1","placeholder","Enter Total Amount","required","",1,"form-control",3,"ngClass"],["for","particulars",1,"form-label"],["id","particulars","formControlName","particulars","rows","3","placeholder","Enter detailed particulars of the expense claim","required","",1,"form-control",3,"ngClass"],[1,"mt-4","d-flex","align-items-center","gap-3"],["type","submit",1,"btn","btn-primary","px-4",3,"disabled"],[1,"fa","fa-check-circle","me-1"],["class","alert alert-danger mb-0 py-1 px-3 animate__animated animate__fadeIn",4,"ngIf"],[1,"invalid-feedback"],[1,"alert","alert-danger","mb-0","py-1","px-3","animate__animated","animate__fadeIn"],[1,"fa","fa-exclamation-triangle-o","me-1"],[1,"options-section","animate__animated","animate__fadeIn","mt-4"],[1,"alert","alert-info","mb-4"],[1,"fa","fa-info-circle","me-2"],[1,"row","g-4"],[1,"col-md-3"],[1,"card","h-100","border-success"],[1,"card-body","text-center"],[1,"fa","fa-file-text-o","text-success",2,"font-size","3rem"],[1,"card-title","mt-3"],[1,"card-text"],[1,"btn","btn-outline-success",3,"click","disabled"],[1,"card","h-100","border-primary"],[1,"fa","fa-paper-plane","text-primary",2,"font-size","3rem"],[1,"btn","btn-outline-primary",3,"click","disabled"],[1,"card","h-100","border-warning"],[1,"btn","btn-outline-warning",3,"click","disabled"],[1,"card","h-100","border-secondary"],[1,"btn","btn-outline-secondary",3,"click","disabled"],[1,"fa","fa-ban","me-1"],[1,"spinner-border","spinner-border-sm","me-2"],[1,"text-center","py-4"],["role","status",1,"spinner-border","text-primary"],[1,"mt-2","mb-0"],[1,"alert","alert-light","border"],[1,"table-responsive",2,"max-height","50vh","overflow","auto"],[1,"table","table-sm","align-middle"],[1,"table-light","sticky-top"],[2,"width","35%"],[2,"width","25%"],[1,"text-end",2,"width","15%"],[4,"ngFor","ngForOf"],[1,"text-end"],["type","button",1,"btn","btn-sm","btn-primary",3,"click"],[1,"fa","fa-plus-circle","me-1"],[1,"text-center","mt-3"],["role","status",1,"spinner-border","spinner-border-sm","text-primary"],[1,"ms-2"],[1,"text-muted"]],template:function(i,t){i&1&&(_(0,Vr,61,36,"form",3)(1,Br,55,8,"div",4),r(2,"div",5)(3,"div",6)(4,"div",7)(5,"div",8)(6,"h5",9),
1343c(7,"i",10),o(8,"Save as Draft "),n(),c(9,"button",11),n(),r(10,"div",12),c(11,"i",13),r(12,"h6",14),o(13,"Save this form as draft?"),n(),r(14,"p",15),o(15,"You can edit and delete it later from the Drafts tab."),n()(),r(16,"div",16)(17,"button",17),c(18,"i",18),o(19,"Cancel "),n(),r(20,"button",19),b("click",function(){return t.confirmSaveAsDraft()}),_(21,$r,1,0,"span",20),c(22,"i",21),o(23,"Save Draft "),n()()()()(),r(24,"div",22)(25,"div",6)(26,"div",7)(27,"div",23)(28,"h5",24),c(29,"i",25),o(30,"Send for Approval "),n(),c(31,"button",26),n(),r(32,"div",12),c(33,"i",27),r(34,"h6",14),o(35,"Send this form for approval?"),n(),r(36,"p",15),o(37,"Once approved, you cannot edit or delete it."),n()(),r(38,"div",16)(39,"button",17),c(40,"i",18),o(41,"Cancel "),n(),r(42,"button",28),b("click",function(){return t.confirmSendToApproval()}),_(43,Ur,1,0,"span",20),c(44,"i",29),o(45,"Send for Approval "),n()()()()(),r(46,"div",30)(47,"div",6)(48,"div",7)(49,"div",31)(50,"h5",32),c(51,"i",33),o(52,"Without Cheque "),n(),c(53,"button",11),n(),r(54,"div",12),c(55,"i",34),r(56,"h6",14),o(57,"Submit without cheque?"),n(),r(58,"p",15),o(59,"No cheque will be issued. Approvers complete final e-sign only."),n()(),r(60,"div",16)(61,"button",17),o(62,"Cancel"),n(),r(63,"button",35),b("click",function(){return t.confirmSendToWithoutCheque()}),_(64,zr,1,0,"span",20),o(65," Submit "),n()()()()(),r(66,"div",36)(67,"div",6)(68,"div",7)(69,"div",23)(70,"h5",37),c(71,"i",38),o(72,"Pre-Approval "),n(),c(73,"button",26),n(),r(74,"div",12),c(75,"i",39),r(76,"h6",14),o(77,"Pre-approve and publish this form?"),n(),r(78,"p",15),o(79,"This will bypass the approval workflow and mark as pre-approved."),n()(),r(80,"div",16)(81,"button",17),c(82,"i",18),o(83,"Cancel "),n(),r(84,"button",28),b("click",function(){return t.confirmSendToPreApproval()}),_(85,Yr,1,0,"span",20),c(86,"i",40),o(87,"Pre-Approval "),n()()()()(),r(88,"div",41)(89,"div",42)(90,"div",7)(91,"div",31)(92,"h5",43),c(93,"i",44),o(94,"Select Staff"),n(),c(95,"button",11),n(),r(96,"div",45)(97,"div",46)(98,"div",47)(99,"div",48)(100,"span",49),c(101,"i",50),n(),r(102,"input",51),b("input",function(s){return t.onStaffSearchChange(s.target.value)}),n()()()(),_(103,Gr,4,0,"div",52)(104,Wr,3,0,"div",53)(105,Hr,14,1,"div",54)(106,Zr,4,0,"div",55),n(),r(107,"div",16)(108,"div",56),_(109,Qr,2,1,"small",57),r(110,"button",58),b("click",function(){return t.resetStaffData()}),o(111,"Close"),n()()()()()()),i&2&&(p("ngIf",!t.showOptions),d(),p("ngIf",t.showOptions),d(19),p("disabled",t.draftSubmitting),d(),p("ngIf",t.draftSubmitting),d(21),p("disabled",t.approvalSubmitting),d(),p("ngIf",t.approvalSubmitting),d(20),p("disabled",t.withoutChequeSubmitting),d(),p("ngIf",t.withoutChequeSubmitting),d(20),p("disabled",t.preApprovalSubmitting),d(),p("ngIf",t.preApprovalSubmitting),d(17),p("value",t.staffSearchTerm),d(),p("ngIf",t.isStaffLoading&&t.filteredStaff.length===0),d(),p("ngIf",!t.isStaffLoading&&!t.isProgressiveLoading&&(!t.filteredStaff||t.filteredStaff.length===0)),d(),p("ngIf",t.filteredStaff&&t.filteredStaff.length>0),d(),p("ngIf",t.isStaffLoading&&t.filteredStaff.length>0),d(3),p("ngIf",t.filteredStaff.length>0))},dependencies:[te,ie,W,fe,j,Ne,H,me,Ve,Me,he,ge,Oe,Re],styles:[`.container-fluid[_ngcontent-%COMP%]{padding:20px}.card[_ngcontent-%COMP%]{border:none;border-radius:10px;box-shadow:0 4px 6px #0000001a}.card-header[_ngcontent-%COMP%]{border-radius:10px 10px 0 0!important;border-bottom:none}.card-body[_ngcontent-%COMP%]{padding:2rem}.form-label[_ngcontent-%COMP%]{font-weight:600;color:#2c2f32;margin-bottom:.5rem}.form-control[_ngcontent-%COMP%], .form-select[_ngcontent-%COMP%]{border-radius:8px;border:2px solid #e9ecef;padding:.75rem 1rem;transition:all .3s ease}.form-control[_ngcontent-%COMP%]:focus, .form-select[_ngcontent-%COMP%]:focus{border-color:#007bff;box-shadow:0 0 0 .2rem #007bff40}.form-control.is-invalid[_ngcontent-%COMP%], .form-select.is-invalid[_ngcontent-%COMP%]{border-color:#dc3545}.invalid-feedback[_ngcontent-%COMP%]{font-size:.875rem;color:#dc3545;margin-top:.25rem}.btn[_ngcontent-%COMP%]{border-radius:8px;padding:.75rem 1.5rem;font-weight:600;transition:all .3s ease}.btn-primary[_ngcontent-%COMP%]{background-color:#007bff;border-color:#007bff}.btn-primary[_ngcontent-%COMP%]:hover{background-color:#0056b3;border-color:#0056b3;transform:translateY(-1px)}.btn-outline-success[_ngcontent-%COMP%]{border-color:#28a745;color:#28a745}.btn-outline-success[_ngcontent-%COMP%]:hover{background-color:#28a745;border-color:#28a745;transform:translateY(-1px)}.btn-outline-primary[_ngcontent-%COMP%]{border-color:#007bff;color:#007bff}.btn-outline-primary[_ngcontent-%COMP%]:hover{background-color:#007bff;border-color:#007bff;transform:translateY(-1px)}.alert[_ngcontent-%COMP%]{border-radius:8px;border:none}.alert-info[_ngcontent-%COMP%]{background-color:#d1ecf1;color:#0c5460}.alert-danger[_ngcontent-%COMP%]{background-color:#f8d7da;color:#721c24}.modal-content[_ngcontent-%COMP%]{border-radius:10px;border:none;box-shadow:0 10px 30px #0000004d}.modal-header[_ngcontent-%COMP%]{border-radius:10px 10px 0 0;border-bottom:none}.modal-footer[_ngcontent-%COMP%]{border-radius:0 0 10px 10px;border-top:none}.animate__animated[_ngcontent-%COMP%]{animation-duration:.5s}.animate__fadeIn[_ngcontent-%COMP%]{animation-name:_ngcontent-%COMP%_fadeIn}@keyframes _ngcontent-%COMP%_fadeIn{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@media (max-width: 768px){.card-body[_ngcontent-%COMP%]{padding:1.5rem}.btn[_ngcontent-%COMP%]{width:100%;margin-bottom:.5rem}.d-flex.align-items-center.gap-3[_ngcontent-%COMP%]{flex-direction:column;align-items:stretch!important}}.spinner-border-sm[_ngcontent-%COMP%]{width:1rem;height:1rem}.form-control.is-valid[_ngcontent-%COMP%]{border-color:#28a745;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right calc(.375em + .1875rem) center;background-size:calc(.75em + .375rem) calc(.75em + .375rem)}.card.h-100[_ngcontent-%COMP%]{transition:all .3s ease}.card.h-100[_ngcontent-%COMP%]:hover{transform:translateY(-5px);box-shadow:0 8px 25px #00000026}.fa[_ngcontent-%COMP%]{font-size:1.1em}textarea.form-control[_ngcontent-%COMP%]{resize:vertical;min-height:100px}.form-select[_ngcontent-%COMP%]{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 6 7 7 7-7'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right .75rem center;background-size:16px 12px}`]})}return l})();var kt=Ye(Ge());var Kr=["editNameOfStaffInput"],Xr=["editDateInput"];function Jr(l,f){l&1&&(r(0,"span"),c(1,"i",94),o(2,"Print Selected"),n())}function ea(l,f){l&1&&(r(0,"span"),c(1,"span",95),o(2,"Printing..."),n())}function ta(l,f){l&1&&(r(0,"span"),c(1,"i",96),o(2,"Delete Selected"),n())}function ia(l,f){l&1&&(r(0,"span"),c(1,"span",95),o(2,"Deleting..."),n())}function na(l,f){l&1&&(r(0,"span"),c(1,"i",97),o(2,"Send for Approval"),n())}function ra(l,f){l&1&&(r(0,"span"),c(1,"span",95),o(2,"Sending..."),n())}function aa(l,f){l&1&&(r(0,"span"),c(1,"i",98),o(2,"Mark as Pre-Approved"),n())}function oa(l,f){l&1&&(r(0,"span"),c(1,"span",95),o(2,"Processing..."),n())}function la(l,f){l&1&&(r(0,"span"),c(1,"i",99),o(2,"Without Cheque"),n())}function sa(l,f){l&1&&(r(0,"span"),c(1,"span",95),o(2,"Processing..."),n())}function da(l,f){if(l&1){let e=I();
1343r(0,"div",86)(1,"div",87)(2,"span",88),o(3),n()(),r(4,"button",89),b("click",function(){x(e);let t=g();return S(t.printSelectedForms())}),_(5,Jr,3,0,"span",68)(6,ea,3,0,"span",68),n(),r(7,"button",90),b("click",function(){x(e);let t=g();return S(t.onBulkDelete())}),_(8,ta,3,0,"span",68)(9,ia,3,0,"span",68),n(),r(10,"button",91),b("click",function(){x(e);let t=g();return S(t.onBulkApproval())}),_(11,na,3,0,"span",68)(12,ra,3,0,"span",68),n(),r(13,"button",92),b("click",function(){x(e);let t=g();return S(t.onBulkPreApproval())}),_(14,aa,3,0,"span",68)(15,oa,3,0,"span",68),n(),r(16,"button",93),b("click",function(){x(e);let t=g();return S(t.onBulkWithoutCheque())}),_(17,la,3,0,"span",68)(18,sa,3,0,"span",68),n()()}if(l&2){let e=g();d(3),A("",e.getSelectedFormsCount()," selected"),d(),p("disabled",e.getSelectedFormsCount()===0||e.printSelectedSubmitting),d(),p("ngIf",!e.printSelectedSubmitting),d(),p("ngIf",e.printSelectedSubmitting),d(),p("disabled",e.getSelectedFormsCount()===0||e.bulkDeleteSubmitting),d(),p("ngIf",!e.bulkDeleteSubmitting),d(),p("ngIf",e.bulkDeleteSubmitting),d(),p("disabled",e.getSelectedFormsCount()===0||e.bulkApprovalSubmitting),d(),p("ngIf",!e.bulkApprovalSubmitting),d(),p("ngIf",e.bulkApprovalSubmitting),d(),p("disabled",e.getSelectedFormsCount()===0||e.bulkPreApprovalSubmitting),d(),p("ngIf",!e.bulkPreApprovalSubmitting),d(),p("ngIf",e.bulkPreApprovalSubmitting),d(),p("disabled",e.getSelectedFormsCount()===0||e.bulkWithoutChequeSubmitting),d(),p("ngIf",!e.bulkWithoutChequeSubmitting),d(),p("ngIf",e.bulkWithoutChequeSubmitting)}}function pa(l,f){l&1&&(r(0,"div",100)(1,"div",101)(2,"span",102),o(3,"Loading..."),n()()())}function ca(l,f){if(l&1&&(r(0,"div",103),o(1),n()),l&2){let e=g();d(),w(e.error)}}function ma(l,f){if(l&1){let e=I();r(0,"button",129),b("click",function(){x(e);let t=g().$implicit,a=g(2);return S(a.onEdit(t))}),c(1,"i",130),n()}}function ua(l,f){l&1&&(r(0,"span",131),o(1,"-"),n())}function fa(l,f){if(l&1){let e=I();r(0,"tr")(1,"td",120)(2,"input",121),b("change",function(t){let a=x(e).$implicit,s=g(2);return S(s.toggleFormSelection(a,t))}),n()(),r(3,"td",120),o(4),n(),r(5,"td"),o(6),n(),r(7,"td"),o(8),n(),r(9,"td"),o(10),n(),r(11,"td"),o(12),n(),r(13,"td"),o(14),n(),r(15,"td",122),o(16),L(17,"date"),n(),r(18,"td"),o(19),n(),r(20,"td",120)(21,"button",123),b("click",function(){let t=x(e).$implicit,a=g(2);return S(a.openParticularsModal(t.particulars))}),c(22,"i",124),n()(),r(23,"td",125),o(24),L(25,"number"),n(),r(26,"td",120)(27,"span",126),o(28),n()(),r(29,"td",120),_(30,ma,2,0,"button",127)(31,ua,2,0,"span",128),n()()}if(l&2){let e=f.$implicit,i=f.index,t=g(2);re("table-primary",t.isFormSelected(e)),d(2),p("checked",t.isFormSelected(e)),d(2),w(i+1),d(2),w(e.nameOfStaff||"N/A"),d(2),w(e.idNo||"N/A"),d(2),w(e.designation||"N/A"),d(2),w(e.dept||"N/A"),d(2),w(e.typeOfClaim||"N/A"),d(2),w(B(17,16,e.date,"dd-MM-yyyy")),d(3),w(e.venue||"N/A"),d(5),w(B(25,19,e.total,"1.0-0")),d(3),p("ngClass",t.getStatusBadgeClass(e)),d(),A(" ",t.getStatusDisplay(e)," "),d(2),p("ngIf",t.canEdit(e)),d(),p("ngIf",!t.canEdit(e))}}function ha(l,f){if(l&1){let e=I();r(0,"div",104)(1,"table",105)(2,"thead",106)(3,"tr")(4,"th",107)(5,"input",108),b("change",function(t){x(e);let a=g();return S(a.toggleSelectAll(t))}),n()(),r(6,"th",107),o(7,"#"),n(),r(8,"th",109),o(9,"Staff Name"),n(),r(10,"th",110),o(11,"ID No"),n(),r(12,"th",110),o(13,"Designation"),n(),r(14,"th",110),o(15,"Department"),n(),r(16,"th",110),o(17,"Type of Claim"),n(),r(18,"th",111),o(19,"Date"),n(),r(20,"th",110),o(21,"Venue"),n(),r(22,"th",112),o(23,"Particulars"),n(),r(24,"th",113),o(25,"Total Amount"),n(),r(26,"th",114),o(27,"Status"),n(),r(28,"th",115),o(29,"Actions"),n()()(),r(30,"tbody"),_(31,fa,32,22,"tr",116),n()(),r(32,"div",117)(33,"button",118),b("click",function(){x(e);let t=g();return S(t.prevPage())}),o(34,"\xAB Prev"),n(),r(35,"span"),o(36),n(),r(37,"button",119),b("click",function(){x(e);let t=g();return S(t.nextPage())}),o(38,"Next \xBB"),n()()()}if(l&2){let e=g();d(5),p("checked",e.allSelected)("indeterminate",e.getSelectedFormsCount()>0&&e.getSelectedFormsCount()<e.staffExpenseForms.length),d(26),p("ngForOf",e.staffExpenseForms),d(2),p("disabled",e.isPrevDisabled()),d(3),A("Page ",e.pageNumber,""),d(),p("disabled",e.isNextDisabled())}}function ga(l,f){l&1&&(r(0,"div",132),o(1,"No forms available."),n())}function ba(l,f){l&1&&c(0,"span",133)}
1343function va(l,f){l&1&&c(0,"span",133)}function xa(l,f){l&1&&c(0,"span",133)}function Sa(l,f){l&1&&(r(0,"span"),c(1,"i",96),o(2,"Delete All"),n())}function _a(l,f){l&1&&(r(0,"span"),c(1,"span",95),o(2,"Deleting..."),n())}function wa(l,f){l&1&&(r(0,"span"),c(1,"i",97),o(2,"Send for Approval"),n())}function Ca(l,f){l&1&&(r(0,"span"),c(1,"span",95),o(2,"Sending..."),n())}function Ea(l,f){l&1&&(r(0,"span"),c(1,"i",98),o(2,"Mark as Pre-Approved"),n())}function ya(l,f){l&1&&(r(0,"span"),c(1,"span",95),o(2,"Processing..."),n())}function Fa(l,f){l&1&&(r(0,"span"),c(1,"i",99),o(2,"Without Cheque"),n())}function Da(l,f){l&1&&(r(0,"span"),c(1,"span",95),o(2,"Processing..."),n())}var je=kt.default??kt,_i=(()=>{class l{staffExpenseFormService;router;fb;toastr;bsLocaleService;staffExpenseForms=[];loading=!1;error="";pageNumber=1;pageSize=1e3;filterStaffName="";editModalOpen=!1;editForm;editSubmitting=!1;editId=null;formToEdit=null;originalDraftStatus=!0;staffFormEditAccessConfirmModal;claimConfirmed=!1;nameOfStaffBlurred=!1;dateBlurred=!1;typeOfClaimBlurred=!1;formToDelete=null;deleteSubmitting=!1;staffFormDeleteModal;formToApprove=null;approvalSubmitting=!1;preApprovalSubmitting=!1;staffFormSendToapprovalModal;selectedForms=new Set;allSelected=!1;bulkDeleteSubmitting=!1;bulkApprovalSubmitting=!1;bulkPreApprovalSubmitting=!1;bulkWithoutChequeSubmitting=!1;staffFormbulkDeleteModal;staffFormbulkApprovalModal;staffFormbulkPreApprovalModal;staffFormbulkWithoutChequeModal;printSelectedSubmitting=!1;viewParticularsText=null;openParticularsModal(e){this.viewParticularsText=e,this.staffFormparticularsModal.show()}closeParticularsModal(){this.viewParticularsText=null}editNameOfStaffInput;editDateInput;staffFormEditModal;staffFormparticularsModal;bsConfig={dateInputFormat:"DD/MM/YYYY",containerClass:"theme-default",showWeekNumbers:!1};constructor(e,i,t,a,s){this.staffExpenseFormService=e,this.router=i,this.fb=t,this.toastr=a,this.bsLocaleService=s,this.editForm=this.fb.group({nameOfStaff:["",P.required],designation:["",P.required],dept:["",P.required],idNo:[""],typeOfClaim:["",P.required],particulars:["",[P.required,P.minLength(5)]],date:["",P.required],venue:["",P.required],total:[0,[P.required,P.min(0)]]})}ngOnInit(){je.locale("en-GB"),ve("en-gb",xe),this.bsLocaleService.use("en-gb"),this.fetchStaffExpenseForms()}fetchStaffExpenseForms(){this.loading=!0,this.error="";let e=(this.pageNumber-1)*this.pageSize;this.staffExpenseFormService.getStaffExpenseForms(e,this.pageSize,!0).then(i=>{let t=Array.isArray(i)?i:[];this.filterStaffName&&(t=t.filter(a=>a.nameOfStaff&&a.nameOfStaff.toLowerCase().includes(this.filterStaffName.toLowerCase()))),this.staffExpenseForms=t,this.selectedForms.clear(),this.allSelected=!1}).catch(()=>{this.error="Failed to load staff expense forms."}).finally(()=>{this.loading=!1})}toggleSelectAll(e){e.target.checked?(this.selectedForms=new Set(this.staffExpenseForms.map(i=>i._id||i.id)),this.allSelected=!0):(this.selectedForms.clear(),this.allSelected=!1)}toggleFormSelection(e,i){let t=e._id||e.id;i.target.checked?this.selectedForms.add(t):this.selectedForms.delete(t),this.allSelected=this.selectedForms.size===this.staffExpenseForms.length}isFormSelected(e){let i=e._id||e.id;return this.selectedForms.has(i)}getSelectedFormsCount(){return this.selectedForms.size}onBulkDelete(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to delete.","No Selection");return}this.staffFormbulkDeleteModal.show()}confirmBulkDelete(){if(this.selectedForms.size===0)return;this.bulkDeleteSubmitting=!0;let e=Array.from(this.selectedForms),i=e.map(t=>this.staffExpenseFormService.deleteStaffExpenseForm(t));Promise.all(i).then(()=>{this.toastr.success(`${e.length} form(s) deleted successfully`,"Success"),this.staffFormbulkDeleteModal.hide(),this.selectedForms.clear(),this.allSelected=!1,this.fetchStaffExpenseForms()}).catch(t=>{console.error("Error deleting forms:",t),this.toastr.error("Failed to delete some forms. Please try again.","Error")}).finally(()=>{this.bulkDeleteSubmitting=!1})}onBulkApproval(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to send for approval.","No Selection");return}this.staffFormbulkApprovalModal.show()}onBulkPreApproval(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to mark as pre-approved.","No Selection");return}this.staffFormbulkPreApprovalModal.show()}onBulkWithoutCheque(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form for without-cheque approval.","No Selection");return}this.staffFormbulkWithoutChequeModal.show()}buildWithoutChequeUpdateData(e){let i=N(T({},e),{draft:!1,approvalType:"WITHOUT_CHEQUE"});return delete i.chequeNo,i}confirmBulkApproval(){if(this.selectedForms.size===0)return;this.bulkApprovalSubmitting=!0;let e=Array.from(this.selectedForms),t=this.staffExpenseForms.filter(a=>this.selectedForms.has(a._id||a.id)).map(a=>{let s=N(T({},a),{draft:!1,approvalType:"NONE"});return this.staffExpenseFormService.updateStaffExpenseForm(a._id||a.id,s).then(()=>this.staffExpenseFormService.submitForApproval(a._id||a.id,{approvalType:"NONE",draft:!1}))});Promise.all(t).then(()=>{this.toastr.success(`${e.length} form(s) sent for approval successfully! They will appear in the publish tab once approved.`,"Success",{timeOut:3e3,progressBar:!0}),this.staffFormbulkApprovalModal.hide(),this.selectedForms.clear(),this.allSelected=!1,this.fetchStaffExpenseForms(),setTimeout(()=>{this.router.navigate(["supplier/publish/staff"],{replaceUrl:!0})},1500)}).catch(a=>{console.error("Error sending forms for approval:",a),this.toastr.error("Failed to send some forms for approval. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.bulkApprovalSubmitting=!1})}confirmBulkPreApproval(){if(this.selectedForms.size===0)return;this.bulkPreApprovalSubmitting=!0;let e=Array.from(this.selectedForms),t=this.staffExpenseForms.filter(a=>this.selectedForms.has(a._id||a.id)).map(a=>{let s=N(T({},a),{draft:!1,approvalType:"PRE_APPROVED"});return this.staffExpenseFormService.updateStaffExpenseForm(a._id||a.id,s).then(()=>this.staffExpenseFormService.submitForApproval(a._id||a.id,{approvalType:"PRE_APPROVED",draft:!1}))});Promise.all(t).then(()=>{this.toastr.success(`${e.length} form(s) marked as pre-approved successfully! They will appear in the pre-approval tab.`,"Success",{timeOut:3e3,progressBar:!0}),this.staffFormbulkPreApprovalModal.hide(),this.selectedForms.clear(),this.allSelected=!1,this.fetchStaffExpenseForms(),setTimeout(()=>{this.router.navigate(["supplier/pre-approval/staff"],{replaceUrl:!0})},1500)}).catch(a=>{console.error("Error marking forms as pre-approved:",a),this.toastr.error("Failed to mark some forms as pre-approved. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.bulkPreApprovalSubmitting=!1})}confirmBulkWithoutCheque(){if(this.selectedForms.size===0)return;this.bulkWithoutChequeSubmitting=!0;let e=Array.from(this.selectedForms),t=this.staffExpenseForms.filter(a=>this.selectedForms.has(a._id||a.id)).map(a=>{let s=this.buildWithoutChequeUpdateData(a),m=a._id||a.id;return this.staffExpenseFormService.updateStaffExpenseForm(m,s).then(()=>this.staffExpenseFormService.submitForApproval(m,{approvalType:"WITHOUT_CHEQUE",draft:!1}))});Promise.all(t).then(()=>{this.toastr.success(`${e.length} form(s) submitted without cheque successfully!`,"Success",{timeOut:3e3,progressBar:!0}),this.staffFormbulkWithoutChequeModal.hide(),this.selectedForms.clear(),this.allSelected=!1,this.fetchStaffExpenseForms(),setTimeout(()=>{this.router.navigate(["supplier/publish/staff"],{replaceUrl:!0})},1500)}).catch(a=>{console.error("Error submitting without-cheque drafts:",a),this.toastr.error("Failed to submit some forms without cheque. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.bulkWithoutChequeSubmitting=!1})}nextPage(){this.staffExpenseForms.length===this.pageSize&&(this.pageNumber++,this.fetchStaffExpenseForms())}prevPage(){this.pageNumber>1&&(this.pageNumber--,this.fetchStaffExpenseForms())}isPrevDisabled(){return this.pageNumber<=1}isNextDisabled(){return this.staffExpenseForms.length<this.pageSize}onFilterChange(){this.pageNumber=1,this.fetchStaffExpenseForms()}onEdit(e){this.formToEdit=e,this.staffFormEditAccessConfirmModal.show()}confirmEditAccess(e){if(this.staffFormEditAccessConfirmModal.hide(),e&&this.formToEdit){let i=this.formToEdit,t=i._id||i.id;this.editId=t,this.originalDraftStatus=i.draft!==void 0?i.draft:!0;let a="";if(i.date){let m;i.date instanceof Date?a=i.date:typeof i.date=="string"?(m=je(i.date,["YYYY-MM-DD","DD/MM/YYYY","YYYY/MM/DD","YYYY-MM-DDTHH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ssZ"],!0),m.isValid()?a=m.toDate():(m=je(i.date),m.isValid()?a=m.toDate():a=i.date)):a=i.date}let s={nameOfStaff:i.nameOfStaff||"",designation:i.designation||"",dept:i.dept||"",idNo:i.idNo||"",typeOfClaim:i.typeOfClaim||"",particulars:i.particulars||"",date:a,venue:i.venue||"",total:i.total||0};this.editForm.setValue(s),this.staffFormEditModal.show(),setTimeout(()=>{a instanceof Date&&this.editForm.get("date")?.setValue(a,{emitEvent:!1})},200)}this.formToEdit=null}closeEditModal(){this.staffFormEditModal.hide(),this.editId=null,this.editForm.reset(),this.editSubmitting=!1,this.originalDraftStatus=!0}
1343onEditSubmit(){if(this.editForm.invalid||!this.editId){this.editForm.markAllAsTouched();return}this.editSubmitting=!0;let e=this.editForm.getRawValue(),i=e.date;if(e.date instanceof Date)i=je(e.date).format("YYYY-MM-DD");else if(e.date&&typeof e.date=="string"){let a=je(e.date,"DD/MM/YYYY");a.isValid()&&(i=a.format("YYYY-MM-DD"))}let t=N(T({},e),{date:i,total:parseInt(e.total)||0,draft:this.originalDraftStatus});this.staffExpenseFormService.updateStaffExpenseForm(this.editId,t).then(()=>{this.closeEditModal(),this.fetchStaffExpenseForms()}).catch(()=>{this.editSubmitting=!1,alert("Failed to update form.")})}ngAfterViewInit(){this.staffFormDeleteModal=new window.bootstrap.Modal(document.getElementById("staffFormDeleteModal")),this.staffFormSendToapprovalModal=new window.bootstrap.Modal(document.getElementById("staffFormSendToapprovalModal")),this.staffFormEditAccessConfirmModal=new window.bootstrap.Modal(document.getElementById("staffFormEditAccessConfirmModal")),this.staffFormEditModal=new window.bootstrap.Modal(document.getElementById("staffFormEditModal")),this.staffFormparticularsModal=new window.bootstrap.Modal(document.getElementById("staffFormparticularsModal")),this.staffFormbulkDeleteModal=new window.bootstrap.Modal(document.getElementById("staffFormbulkDeleteModal")),this.staffFormbulkApprovalModal=new window.bootstrap.Modal(document.getElementById("staffFormbulkApprovalModal")),this.staffFormbulkPreApprovalModal=new window.bootstrap.Modal(document.getElementById("staffFormbulkPreApprovalModal")),this.staffFormbulkWithoutChequeModal=new window.bootstrap.Modal(document.getElementById("staffFormbulkWithoutChequeModal")),setTimeout(()=>{let e=document.getElementById("editNameOfStaff"),i=document.getElementById("editDate"),t=document.getElementById("editTypeOfClaim");e&&e.addEventListener("blur",()=>{this.nameOfStaffBlurred=!0,this.checkShowEditClaimConfirm()}),i&&i.addEventListener("blur",()=>{this.dateBlurred=!0,this.checkShowEditClaimConfirm()}),t&&t.addEventListener("blur",()=>{this.typeOfClaimBlurred=!0,this.checkShowEditClaimConfirm()})},0)}checkShowEditClaimConfirm(){this.editForm.get("nameOfStaff")?.value&&this.editForm.get("date")?.value&&this.editForm.get("typeOfClaim")?.value&&this.nameOfStaffBlurred&&this.dateBlurred&&this.typeOfClaimBlurred&&!this.claimConfirmed&&new window.bootstrap.Modal(document.getElementById("editClaimConfirmModal")).show()}confirmEditClaim(e){this.claimConfirmed=e,new window.bootstrap.Modal(document.getElementById("editClaimConfirmModal")).hide(),e||(this.nameOfStaffBlurred=!1,this.dateBlurred=!1,this.typeOfClaimBlurred=!1,setTimeout(()=>{this.editNameOfStaffInput?.nativeElement.focus()},0))}onDelete(e){this.formToDelete=e,this.staffFormDeleteModal.show()}confirmDelete(){if(!this.formToDelete)return;let e=this.formToDelete._id||this.formToDelete.id;this.deleteSubmitting=!0,this.staffExpenseFormService.deleteStaffExpenseForm(e).then(()=>{this.toastr.success("Staff expense form deleted successfully","Success"),this.staffFormDeleteModal.hide(),this.formToDelete=null,this.fetchStaffExpenseForms()}).catch(i=>{console.error("Error deleting form:",i),this.toastr.error("Failed to delete staff expense form","Error")}).finally(()=>{this.deleteSubmitting=!1})}sendToApproval(e){this.formToApprove=e,this.staffFormSendToapprovalModal.show()}confirmSendToApproval(){if(!this.formToApprove)return;let e=this.formToApprove._id||this.formToApprove.id;this.approvalSubmitting=!0;let i=N(T({},this.formToApprove),{draft:!1,approvalType:"NONE"});this.staffExpenseFormService.updateStaffExpenseForm(i._id||i.id,i).then(()=>this.staffExpenseFormService.submitForApproval(e)).then(()=>{this.toastr.success("Draft sent for approval successfully! It will appear in the publish tab once approved.","Success",{timeOut:3e3,progressBar:!0}),this.staffFormSendToapprovalModal.hide(),this.formToApprove=null,this.fetchStaffExpenseForms(),setTimeout(()=>{this.router.navigate(["supplier/publish/staff"],{replaceUrl:!0})},1500)}).catch(t=>{console.error("Error sending draft for approval:",t),this.toastr.error("Failed to send draft for approval. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.approvalSubmitting=!1})}getStatusDisplay(e){return e.draft===!0?"Draft":e.submissionStatus==="APPROVED"?"Approved":e.submissionStatus==="PENDING"?"Pending Approval":"Unknown"}getStatusBadgeClass(e){return e.draft===!0?"bg-warning":e.submissionStatus==="APPROVED"?"bg-success":e.submissionStatus==="PENDING"?"bg-info":"bg-secondary"}canEdit(e){return e.draft===!0}canSendForApproval(e){return e.draft===!0}sendToPreApproval(e){if(!e||!e.draft){this.toastr.warning("Only draft forms can be sent for pre-approval.","Invalid Action");return}let i=e._id||e.id;this.preApprovalSubmitting=!0;let t=N(T({},e),{draft:!1,approvalType:"PRE_APPROVED"});this.staffExpenseFormService.updateStaffExpenseForm(i,t).then(()=>this.staffExpenseFormService.submitForApproval(i)).then(()=>{this.toastr.success("Draft sent for pre-approval successfully! It will appear in the publish tab once approved.","Success",{timeOut:3e3,progressBar:!0}),this.fetchStaffExpenseForms(),setTimeout(()=>{this.router.navigate(["supplier/publish/staff"],{replaceUrl:!0})},1500)}).catch(a=>{console.error("Error sending draft for pre-approval:",a),this.toastr.error("Failed to send draft for pre-approval. Please try again.","Error",{timeOut:5e3,progressBar:!0})}).finally(()=>{this.preApprovalSubmitting=!1})}printSelectedForms(){return M(this,null,function*(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to print.","No Selection");return}this.printSelectedSubmitting=!0,this.toastr.info("Preparing draft document...","Generating Print Document");let e=this.staffExpenseForms.filter(s=>this.selectedForms.has(s._id||s.id)),i=window.open("","_blank");if(!i){this.toastr.error("Please allow popups to print the document.","Error"),this.printSelectedSubmitting=!1;return}let t=this.generateDraftPrintContent(e);i.document.write(`
1344      <!DOCTYPE html>
1345      <html>
1346        <head>
1347          <title>Draft Staff Expense Forms</title>
1348          <style>
1349            body { 
1350              font-family: Arial, sans-serif; 
1351              margin: 20px; 
1352              font-size: 12px;
1353            }
1354            .header { 
1355              text-align: center; 
1356            }
1357            .logo-container {
1358            }
1359            .logo {
1360               max-width: 300px;
1361               height: 120px;
1362               margin: 0 auto;
1363               display: block;
1364               object-fit: contain;
1365             }
1366            table { 
1367              width: 100%; 
1368              border-collapse: collapse; 
1369              margin-top: 20px;
1370              table-layout: fixed;
1371              border: 2px solid #000;
1372            }
1373            th, td { 
1374              border: 1px solid #000; 
1375              padding: 8px; 
1376              text-align: left;
1377              word-wrap: break-word;
1378              overflow-wrap: break-word;
1379              white-space: normal;
1380              overflow: visible;
1381            }
1382            th { 
1383              background-color: #f2f2f2; 
1384              font-weight: bold;
1385              border: 1px solid #000;
1386              font-size: 12px;
1387            }
1388            td {
1389              font-size: 14px;
1390            }
1391            /* Numeric values - ensure readable font size */
1392            td.text-right,
1393            td.amount {
1394              font-size: 14px;
1395            }
1396            tbody tr td {
1397              border: 1px solid #000;
1398            }
1399            thead tr th {
1400              border: 1px solid #000;
1401            }
1402            /* DRAFT-PRINT: Sl.No(1), Staff Name(2), ID No(3), Designation(4), Department(5), Type of Claim(6), Date(7), Venue(8), Particulars(9), Total Amount(10) */
1403            table.draft-print th:nth-child(1),
1404            table.draft-print td:nth-child(1) { width: 2%; text-align: center; white-space: nowrap; }
1405            table.draft-print th:nth-child(2),
1406            table.draft-print td:nth-child(2) { width: 10%; }
1407            table.draft-print th:nth-child(3),
1408            table.draft-print td:nth-child(3) { width: 4%; text-align: center; }
1409            table.draft-print th:nth-child(4),
1410            table.draft-print td:nth-child(4) { width: 8%; white-space: nowrap; word-break: keep-all; }
1411            table.draft-print th:nth-child(5),
1412            table.draft-print td:nth-child(5) { width: 7%; word-break: keep-all; }
1413            table.draft-print th:nth-child(6),
1414            table.draft-print td:nth-child(6) { width: 9%; word-break: keep-all; }
1415            table.draft-print th:nth-child(7),
1416            table.draft-print td:nth-child(7) { width: 8%; min-width: 95px; text-align: center; white-space: nowrap; padding: 8px 4px; }
1417            table.draft-print th:nth-child(8),
1418            table.draft-print td:nth-child(8) { width: 7%; text-align: center; white-space: nowrap; word-break: keep-all; }
1419            table.draft-print th:nth-child(9),
1420            table.draft-print td:nth-child(9) { width: 25%; min-width: 200px; }
1421            table.draft-print th:nth-child(9) { text-align: center; }
1422            table.draft-print td:nth-child(9) { text-align: left; }
1423            table.draft-print th:nth-child(10),
1424            table.draft-print td:nth-child(10) { width: 6%; min-width: 85px; text-align: right; white-space: nowrap; }
1425            .text-center { text-align: center; }
1426            .text-right { text-align: right; }
1427            .amount { font-weight: bold; }
1428            .total-row {
1429              background-color: #f8f9fa;
1430              font-weight: bold;
1431            }
1432            .total-row td {
1433              font-size: 14px;
1434            }
1435            .amount-in-words {
1436              margin-top: 20px;
1437              padding: 10px;
1438              background-color: #f8f9fa;
1439              border: 1px solid #ddd;
1440              text-align: center;
1441              font-weight: bold;
1442              font-size: 14px;
1443            }
1444            .print-button {
1445              position: fixed;
1446              top: 20px;
1447              right: 20px;
1448              background-color: #007bff;
1449              color: white;
1450              border: none;
1451              padding: 10px 20px;
1452              border-radius: 5px;
1453              cursor: pointer;
1454              font-size: 14px;
1455              font-weight: bold;
1456              box-shadow: 0 2px 5px rgba(0,0,0,0.2);
1457              z-index: 1000;
1458            }
1459            .print-button:hover {
1460              background-color: #0056b3;
1461            }
1462            .generated-on {
1463              position: fixed;
1464              top: 60px;
1465              right: 20px;
1466              color: #555;
1467              font-size: 12px;
1468              background: rgba(255,255,255,0.9);
1469              padding: 4px 8px;
1470              border: 1px solid #ddd;
1471              border-radius: 4px;
1472              z-index: 999;
1473            }
1474            .page-number {
1475              position: fixed;
1476              top: 10px;
1477              right: 20px;
1478              font-size: 12px;
1479              font-weight: bold;
1480              color: #333;
1481              z-index: 1000;
1482              background: rgba(255, 255, 255, 0.9);
1483              padding: 4px 8px;
1484              border-radius: 4px;
1485            }
1486            @media print {
1487              body { margin: 0; }
1488              .no-print { display: none; }
1489              .print-button { display: none; }
1490              .generated-on { top: 20px; }
1491              .page-number {
1492                display: none;
1493              }
1494              table {
1495                width: 100% !important;
1496                table-layout: fixed !important;
1497              }
1498              th, td {
1499                word-wrap: break-word !important;
1500                overflow-wrap: break-word !important;
1501                white-space: normal !important;
1502                overflow: visible !important;
1503                text-overflow: clip !important;
1504                max-width: 100% !important;
1505              }
1506              table.draft-print th:nth-child(4),
1507              table.draft-print td:nth-child(4) {
1508                width: 9% !important;
1509                min-width: 95px !important;
1510                white-space: nowrap !important;
1511              }
1512              table.draft-print th:nth-child(7),
1513              table.draft-print td:nth-child(7) {
1514                width: 8% !important;
1515                min-width: 95px !important;
1516                white-space: nowrap !important;
1517              }
1518              table.draft-print th:nth-child(9),
1519              table.draft-print td:nth-child(9) {
1520                width: 25% !important;
1521                min-width: 200px !important;
1522              }
1523              table.draft-print th:nth-child(10),
1524              table.draft-print td:nth-child(10) {
1525                white-space: nowrap !important;
1526              }
1527              @page {
1528                size: landscape;
1529                margin: 15mm;
1530                @top-right {
1531                  content: counter(page) " of " counter(pages);
1532                  font-size: 12px;
1533                  font-weight: bold;
1534                  color: #000;
1535                  margin-top: 10mm;
1536                  margin-right: 15mm;
1537                }
1538              }
1539            }
1540          </style>
1541        </head>
1542        <body>
1543          <button class="print-button" onclick="window.print()">\u{1F5A8}\uFE0F Print Document</button>
1544          <div class="page-number no-print">Page 1</div>
1545          ${t}
1546        </body>
1547      </html>
1548    `),i.document.close(),i.focus(),this.printSelectedSubmitting=!1})}generateDraftPrintContent(e){let i=0,t="";e.forEach((s,m)=>{let u=s.total||0;i+=u;let h="N/A";if(s.date){if(s.date instanceof Date)h=je(s.date).format("DD-MM-YYYY");else if(typeof s.date=="string"){let v=je(s.date,["YYYY-MM-DD","DD/MM/YYYY","DD-MM-YYYY"],!0);v.isValid()?h=v.format("DD-MM-YYYY"):h=s.date}}t+=`
1549        <tr>
1550          <td class="text-center">${m+1}</td>
1551          <td>${s.nameOfStaff||"N/A"}</td>
1552          <td class="text-center">${s.idNo||"N/A"}</td>
1553          <td>${s.designation||"N/A"}</td>
1554          <td>${s.dept||"N/A"}</td>
1555          <td>${s.typeOfClaim||"N/A"}</td>
1556          <td class="text-center">${h}</td>
1557          <td>${s.venue||"N/A"}</td>
1558          <td>${s.particulars||"N/A"}</td>
1559          <td class="text-right amount">${u}</td>
1560        </tr>
1561      `});let a=this.numberToWords(i);return`
1562      <div class="header">
1563        <div class="logo-container">
1564          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
1565        </div>
1566      </div>
1567      
1568      <table class="draft-print">
1569        <thead>
1570          <tr>
1571            <th class="text-center">Sl.No.</th>
1572            <th class="text-center">Staff Name</th>
1573            <th class="text-center">ID No</th>
1574            <th class="text-center">Designation</th>
1575            <th class="text-center">Department</th>
1576            <th class="text-center">Type of Claim</th>
1577            <th class="text-center">Date</th>
1578            <th class="text-center">Venue</th>
1579            <th class="text-center">Particulars</th>
1580            <th class="text-right">Total<br>Amount \u20B9</th>
1581          </tr>
1582        </thead>
1583        <tbody>
1584          ${t}
1585          <tr class="total-row">
1586            <td colspan="9" class="text-center"><strong>Total \u20B9</strong></td>
1587            <td class="text-right"><strong>${i}</strong></td>
1588          </tr>
1589        </tbody>
1590      </table>
1591      
1592      <div class="amount-in-words">
1593        (Rupees ${a} only)
1594      </div>
1595    `}numberToWords(e){let i=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"],t=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"],a=["Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"];if(e===0)return"Zero";let s=u=>u===0?"":u<10?i[u]:u<20?a[u-10]:u<100?t[Math.floor(u/10)]+(u%10!==0?" "+i[u%10]:""):u<1e3?i[Math.floor(u/100)]+" Hundred"+(u%100!==0?" and "+s(u%100):""):"";return(u=>{if(u===0)return"Zero";let h=Math.floor(u/1e7),v=Math.floor(u%1e7/1e5),E=Math.floor(u%1e5/1e3),y=u%1e3,F="";return h>0&&(F+=s(h)+" Crore "),v>0&&(F+=s(v)+" Lakh "),E>0&&(F+=s(E)+" Thousand "),y>0&&(F+=s(y)),F.trim()})(Math.floor(e))}static \u0275fac=function(i){return new(i||l)(D(Ue),D(ne),D(be),D(K),D(Se))};static \u0275cmp=q({type
vendor: 3,228 bytes, line 1595
1595:l,selectors:[["app-staff-expense-draft-view"]],viewQuery:function(i,t){if(i&1&&(Ee(Kr,5),Ee(Xr,5)),i&2){let a;ye(a=Fe())&&(t.editNameOfStaffInput=a.first),ye(a=Fe())&&(t.editDateInput=a.first)}},decls:271,vars:36,consts:[["editNameOfStaffInput",""],["editDateInput",""],[1,"mb-3","d-flex","flex-column","flex-md-row","justify-content-between","align-items-center","gap-2"],["type","text","placeholder","Filter by Staff Name",1,"form-control","w-100","w-md-50",3,"ngModelChange","ngModel"],["class","mb-3 d-flex flex-wrap gap-2 align-items-center bulk-actions",4,"ngIf"],["class","text-center my-3",4,"ngIf"],["class","alert alert-danger",4,"ngIf"],["class","table-responsive",4,"ngIf"],["class","alert alert-info",4,"ngIf"],["id","staffFormEditModal","tabindex","-1","aria-labelledby","staffFormEditModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-dialog","modal-lg"],[1,"modal-content"],[1,"modal-header"],["id","staffFormEditModalLabel",1,"modal-title"],["type","button","data-bs-dismiss","modal","aria-label","Close",1,"btn-close"],[3,"ngSubmit","formGroup"],[1,"modal-body"],[1,"row","g-3"],[1,"col-md-6"],[1,"form-label"],["id","editNameOfStaff","type","text","formControlName","nameOfStaff","required","",1,"form-control"],["type","text","formControlName","designation","required","",1,"form-control"],["type","text","formControlName","dept","required","",1,"form-control"],["type","text","formControlName","idNo",1,"form-control"],["type","text","formControlName","typeOfClaim","required","",1,"form-control"],["id","editDate","type","text","formControlName","date","bsDatepicker","","placeholder","DD/MM/YYYY","required","",1,"form-control",3,"bsConfig"],["type","text","formControlName","venue","required","",1,"form-control"],[1,"col-12"],["formControlName","particulars","rows","3","required","",1,"form-control"],["type","number","formControlName","total","min","0","step","1","required","",1,"form-control"],[1,"modal-footer"],["type","button","data-bs-dismiss","modal",1,"btn","btn-secondary"],["type","submit",1,"btn","btn-primary",3,"disabled"],["class","spinner-border spinner-border-sm me-2",4,"ngIf"],["id","staffFormDeleteModal","tabindex","-1","aria-labelledby","staffFormDeleteModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-dialog"],[1,"modal-header","bg-danger","text-white"],["id","staffFormDeleteModalLabel",1,"modal-title"],["type","button","data-bs-dismiss","modal","aria-label","Close",1,"btn-close","btn-close-white"],[1,"mb-0"],["type","button",1,"btn","btn-danger",3,"click","disabled"],["id","staffFormSendToapprovalModal","tabindex","-1","aria-labelledby","staffFormSendToapprovalModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-success","text-white"],["id","staffFormSendToapprovalModalLabel",1,"modal-title"],["type","button",1,"btn","btn-success",3,"click","disabled"],["id","staffFormparticularsModal","tabindex","-1","aria-labelledby","staffFormparticularsModalLabel","aria-hidden","true",1,"modal","fade"],["id","staffFormparticularsModalLabel",1,"modal-title"],["id","staffFormEditAccessConfirmModal","tabindex","-1","aria-labelledby","staffFormEditAccessConfirmModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-dialog","modal
1595-dialog-centered"],[1,"modal-header","bg-info","text-dark"],["id","staffFormEditAccessConfirmModalLabel",1,"modal-title"],[1,"fa","fa-question-circle","me-2"],[1,"modal-body","text-center"],[1,"mb-3"],[1,"mb-1"],[1,"modal-footer","justify-content-center"],["type","button",1,"btn","btn-success","px-4",3,"click"],[1,"fa","fa-check","me-1"],["type","button",1,"btn","btn-danger","px-4",3,"click"],[1,"fa","fa-times","me-1"],["id","editClaimConfirmModal","tabindex","-1","aria-labelledby","editClaimConfirmModalLabel","aria-hidden","true",1,"modal","fade"],["id","editClaimConfirmModalLabel",1,"modal-title"],["id","staffFormbulkDeleteModal","tabindex","-1","aria-labelledby","staffFormbulkDeleteModalLabel","aria-hidden","true",1,"modal","fade"],["id","staffFormbulkDeleteModalLabel",1,"modal-title"],[1,"fa","fa-exclamation-triangle","me-2"],[1,"text-danger","mb-0"],["type","button","data-bs-dismiss","modal",1,"btn","btn-secondary","px-4"],["type","button",1,"btn","btn-danger","px-4",3,"click","disabled"],[4,"ngIf"],["id","staffFormbulkApprovalModal","tabindex","-1","aria-labelledby","staffFormbulkApprovalModalLabel","aria-hidden","true",1,"modal","fade"],["id","staffFormbulkApprovalModalLabel",1,"modal-title"],[1,"fa","fa-paper-plane","me-2"],["type","button",1,"btn","btn-success","px-4",3,"click","disabled"],["id","staffFormbulkPreApprovalModal","tabindex","-1","aria-labelledby","staffFormbulkPreApprovalModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-warning","text-dark"],["id","staffFormbulkPreApprovalModalLabel",1,"modal-title"],[1,"fa","fa-check-circle","me-2"],[1,"text-muted","mb-0"],[1,"mb-0","mt-2","text-start",2,"display","inline-block"],["type","button",1,"btn","btn-warning","px-4",3,"click","disabled"],["id","staffFormbulkWithoutChequeModal","tabindex","-1","aria-labelledby","staffFormbulkWithoutChequeModalLabel","aria-hidden","true",1,"modal","fade"],[1,"modal-header","bg-secondary","text-white"],["id","staffFormbulkWithoutChequeModalLabel",1,"modal-title"],[1,"fa","fa-ban","me-2"],[1,"text-muted","small","mb-0"],["type","button",1,"btn","btn-secondary","px-4",3,"click","disabled"],[1,"mb-3","d-flex","flex-wrap","gap-2","align-items-center","bulk-actions"],[1,"d-flex","align-items-center","me-3"],[1,"badge","bg-primary","me-2"],[1,"btn","btn-info","btn-sm",3,"click","disabled"],[1,"btn","btn-danger","btn-sm",3,"click","disabled"],[1,"btn","btn-success","btn-sm",3,"click","disabled"],[1,"btn","btn-warning","btn-sm",3,"click","disabled"],[1,"btn","btn-secondary","btn-sm",3,"click","disabled"],[1,"fa","fa-print","me-1"],[1,"spinner-border","spinner-border-sm","me-1"],[1,"fa","fa-trash-o","me-1"],[1,"fa","fa-paper-plane","me-1"],[1,"fa","fa-check-circle","me-1"],[1,"fa","fa-ban","me-1"],[1,"text-center","my-3"],["role","status",1,"spinner-border","text-primary","spinner-border-lg"],[1,"visually-hidden"],[1,"alert","alert-danger"],[1,"table-responsive"],[1,"table","table-sm","table-striped","table-hover","align-middle",2,"min-width","900px"],[1,"table-primary","sticky-top",2,"z-index","2"],[1,"text-center",2,"width","40px"],["type","checkbox",1,"form-check-input",3,"change","checked","indeterminate"],[2,"width","120px"],[2,"width","100px"],[1,"text-nowrap",2,"width","100px"],[1,"text-center",2,"width","60px"],[1,"text-end",2,"width","80px"],[1,"text-center",2,"width","80px"],[1,"text-center",2,"width","70px"],[3,"table-primary",4,"ngFor","ngForOf"],[1,"d-flex","justify-content-end","align-items-center","mt-2"],[1,"btn","btn-primary","me-2",3,"click","disabled"],[1,"btn","btn-secondary","ms-2",3,"click","disabled"],[1,"text-center"],["type","checkbox",1,"form-check-input",3,"change","checked"],[1,"text-nowrap"],["title","View Particulars",1,"btn","btn-link","p-0",3,"click"],[1,"fa","fa-eye"],[1,"text-end"],[1,"badge",3,"ngClass"],["class","btn btn-link p-0","data-bs-toggle","tooltip","title","Edit",3,"click",4,"ngIf"],["class","text-muted small",4,"ngIf"],["data-bs-toggle","tooltip","title","Edit",1,"btn","btn-link","p-0",3,"click"],[1,"fa","fa-pencil","text-primary","fs-5"],[1,"text-muted","small"],[1,"alert","alert-info"],[1,"spinner-border","spinner-border-sm","me-2"]],template:function(i,t){if(i&1){let a=I();r(0,"div")(1,"div",2)(2,"input",3),ee("ngModelChange",function(m){return x(a),J(t.filterStaffName,m)||(t.filterStaffName=m),S(m)}),b("ngModelChange",function(){return x(a),S(t.onFilterChange())}),n()(),_(3,da,19,16,"div",4)(4,pa,4,0,"div",5)(5,ca,2,1,"div",6)(6,ha,39,6,"div",7)(7,ga,2,0,"div",8),n(),r(8,"div",9)(9,"div",10)(10,"div",11)(11,"div",12)(12,"h5",13),o(13,"Edit Staff Expense Form"),n(),c(14,"button",14),n(),r(15,"form",15),b("ngSubmit",function(){return x(a),S(t.onEditSubmit())}),r(16,"div",16)(17,"div",17)(18,"div",18)(19,"label",19),o(20,"Staff Name"),n(),c(21,"input",20,0),n(),r(23,"div",18)(24,"label",19),o(25,"Designation"),n(),c(26,"input",21),n(),r(27,"div",18)(28,"label",19),o(29,"Department"),n(),c(30,"input",22),n(),r(31,"div",18)(32,"label",19),o(33,"ID No"),n(),c(34,"input",23),n(),r(35,"div",18)(36,"label",19),o(37,"Type of Claim"),n(),c(38,"input",24),n(),r(39,"div",18)(40,"label",19),o(41,"Date"),n(),c(42,"input",25,1),n(),r(44,"div",18)(45,"label",19),o(46,"Venue"),n(),c(47,"input",26),n(),r(48,"div",27)(49,"label",19),o(50,"Particulars"),n(),c(51,"textarea",28),n(),r(52,"div",18)(53,"label",19),o(54,"Total Amount (\u20B9)"),n(),c(55,"input",29),n()()(),r(56,"div",30)(57,"button",31),o(58,"Cancel"),n(),r(59,"button",32),_(60,ba,1,0,"span",33),o(61," Update "),n()()()()()(),r(62,"div",34)(63,"div",35)(64,"div",11)(65,"div",36)(66,"h5",37),o(67,"Confirm Delete"),n(),c(68,"button",38),n(),r(69,"div",16)(70,"p",39),o(71,"Are you sure you want to delete this staff expense form?"),n()(),r(72,"div",30)(73,"button",31),o(74,"Cancel"),n(),r(75,"button",40),b("
1595click",function(){return x(a),S(t.confirmDelete())}),_(76,va,1,0,"span",33),o(77," Delete "),n()()()()(),r(78,"div",41)(79,"div",35)(80,"div",11)(81,"div",42)(82,"h5",43),o(83,"Send for Approval"),n(),c(84,"button",38),n(),r(85,"div",16)(86,"p",39),o(87,"Are you sure you want to send this staff expense form for approval?"),n()(),r(88,"div",30)(89,"button",31),o(90,"Cancel"),n(),r(91,"button",44),b("click",function(){return x(a),S(t.confirmSendToApproval())}),_(92,xa,1,0,"span",33),o(93," Send for Approval "),n()()()()(),r(94,"div",45)(95,"div",35)(96,"div",11)(97,"div",12)(98,"h5",46),o(99,"Particulars"),n(),c(100,"button",14),n(),r(101,"div",16)(102,"p"),o(103),n()(),r(104,"div",30)(105,"button",31),o(106,"Close"),n()()()()(),r(107,"div",47)(108,"div",48)(109,"div",11)(110,"div",49)(111,"h5",50),c(112,"i",51),o(113,"Edit Draft Confirmation "),n(),c(114,"button",14),n(),r(115,"div",52)(116,"p",53),o(117,"Do you want to edit this draft?"),n(),r(118,"p",54),o(119,"Staff Name: "),r(120,"strong"),o(121),n()(),r(122,"p"),o(123,"Type of Claim: "),r(124,"strong"),o(125),n()()(),r(126,"div",55)(127,"button",56),b("click",function(){return x(a),S(t.confirmEditAccess(!0))}),c(128,"i",57),o(129,"Yes "),n(),r(130,"button",58),b("click",function(){return x(a),S(t.confirmEditAccess(!1))}),c(131,"i",59),o(132,"No "),n()()()()(),r(133,"div",60)(134,"div",48)(135,"div",11)(136,"div",49)(137,"h5",61),c(138,"i",51),o(139,"Confirm Claim Details "),n(),c(140,"button",14),n(),r(141,"div",52)(142,"p",53),o(143,"Are the "),r(144,"strong"),o(145,"Staff Name"),n(),o(146,", "),r(147,"strong"),o(148,"Date"),n(),o(149,", and "),r(150,"strong"),o(151,"Type of Claim"),n(),o(152," entered correct?"),n(),r(153,"p",54),o(154,"Staff Name: "),r(155,"strong"),o(156),n()(),r(157,"p",54),o(158,"Date: "),r(159,"strong"),o(160),n()(),r(161,"p"),o(162,"Type of Claim: "),r(163,"strong"),o(164),n()()(),r(165,"div",55)(166,"button",56),b("click",function(){return x(a),S(t.confirmEditClaim(!0))}),c(167,"i",57),o(168,"Yes "),n(),r(169,"button",58),b("click",function(){return x(a),S(t.confirmEditClaim(!1))}),c(170,"i",59),o(171,"No "),n()()()()(),r(172,"div",62)(173,"div",48)(174,"div",11)(175,"div",36)(176,"h5",63),c(177,"i",64),o(178,"Confirm Bulk Delete "),n(),c(179,"button",38),n(),r(180,"div",52)(181,"p",53),o(182,"Are you sure you want to delete "),r(183,"strong"),o(184),n(),o(185," selected form(s)?"),n(),r(186,"p",65)(187,"strong"),o(188,"This action cannot be undone!"),n()()(),r(189,"div",55)(190,"button",66),c(191,"i",59),o(192,"Cancel "),n(),r(193,"button",67),b("click",function(){return x(a),S(t.confirmBulkDelete())}),_(194,Sa,3,0,"span",68)(195,_a,3,0,"span",68),n()()()()(),r(196,"div",69)(197,"div",48)(198,"div",11)(199,"div",42)(200,"h5",70),c(201,"i",71),o(202,"Send for Bulk Approval "),n(),c(203,"button",38),n(),r(204,"div",52)(205,"p",53),o(206,"Are you sure you want to send "),r(207,"strong"),o(208),n(),o(209," selected form(s) for approval?"),n()(),r(210,"div",55)(211,"button",66),c(212,"i",59),o(213,"Cancel "),n(),r(214,"button",72),b("click",function(){return x(a),S(t.confirmBulkApproval())}),_(215,wa,3,0,"span",68)(216,Ca,3,0,"span",68),n()()()()(),r(217,"div",73)(218,"div",48)(219,"div",11)(220,"div",74)(221,"h5",75),c(222,"i",76),o(223,"Mark as Pre-Approved "),n(),c(224,"button",14),n(),r(225,"div",52)(226,"p",53),o(227,"Are you sure you want to mark "),r(228,"strong"),o(229),n(),o(230," selected form(s) as pre-approved?"),n(),c(231,"hr"),r(232,"p",77),o(233,"This will:"),n(),r(234,"ul",78)(235,"li"),o(236,"Publish the forms immediately"),n(),r(237,"li"),o(238,"Bypass the approval workflow"),n(),r(239,"li"),o(240,"Mark all approval levels as approved"),n()()(),r(241,"div",55)(242,"button",66),c(243,"i",59),o(244,"Cancel "),n(),r(245,"button",79),b("click",function(){return x(a),S(t.confirmBulkPreApproval())}),_(246,Ea,3,0,"span",68)(247,ya,3,0,"span",68),n()()()()(),r(248,"div",80)(249,"div",48)(250,"div",11)(251,"div",81)(252,"h5",82),c(253,"i",83),o(254,"Submit Without Cheque "),n(),c(255,"button",38),n(),r(256,"div",16)(257,"p",53),o(258,"Submit "),r(259,"strong"),o(260),n(),o(261," selected draft(s) for approval without cheque?"),n(),r(262,"p",84),o(263,"Full form details are saved; no cheque number is required. Approvers use the Amount Estimate tab for final e-sign."),n()(),r(264,"div",55)(265,"button",66),c(266,"i",59),o(267,"Cancel "),n(),r(268,"button",85),b("click",function(){return x(a),S(t.confirmBulkWithoutCheque())}),_(269,Fa,3,0,"span",68)(270,Da,3,0,"span",68),n()()()()()}if(i&2){let a,s,m;d(2),X("ngModel",t.filterStaffName),d(),p("ngIf",!t.loading&&t.staffExpenseForms.length>0),d(),p("ngIf",t.loading),d(),p("ngIf",t.error),d(),p("ngIf",!t.loading&&t.staffExpenseForms.length>0),d(),p("ngIf",!t.loading&&t.staffExpenseForms.length===0),d(8),p("formGroup",t.editForm),d(27),p("bsConfig",t.bsConfig),d(17),p("disabled",t.editForm.invali
1595d||t.editSubmitting),d(),p("ngIf",t.editSubmitting),d(15),p("disabled",t.deleteSubmitting),d(),p("ngIf",t.deleteSubmitting),d(15),p("disabled",t.approvalSubmitting),d(),p("ngIf",t.approvalSubmitting),d(11),w(t.viewParticularsText),d(18),w(t.formToEdit==null?null:t.formToEdit.nameOfStaff),d(4),w(t.formToEdit==null?null:t.formToEdit.typeOfClaim),d(31),w((a=t.editForm.get("nameOfStaff"))==null?null:a.value),d(4),w((s=t.editForm.get("date"))==null?null:s.value),d(4),w((m=t.editForm.get("typeOfClaim"))==null?null:m.value),d(20),w(t.getSelectedFormsCount()),d(9),p("disabled",t.bulkDeleteSubmitting),d(),p("ngIf",!t.bulkDeleteSubmitting),d(),p("ngIf",t.bulkDeleteSubmitting),d(13),w(t.getSelectedFormsCount()),d(6),p("disabled",t.bulkApprovalSubmitting),d(),p("ngIf",!t.bulkApprovalSubmitting),d(),p("ngIf",t.bulkApprovalSubmitting),d(13),w(t.getSelectedFormsCount()),d(16),p("disabled",t.bulkPreApprovalSubmitting),d(),p("ngIf",!t.bulkPreApprovalSubmitting),d(),p("ngIf",t.bulkPreApprovalSubmitting),d(13),w(t.getSelectedFormsCount()),d(8),p("disabled",t.bulkWithoutChequeSubmitting),d(),p("ngIf",!t.bulkWithoutChequeSubmitting),d(),p("ngIf",t.bulkWithoutChequeSubmitting)}},dependencies:[te,ie,W,fe,j,Ne,H,me,Ve,Me,ue,he,ge,Oe,Re,se,Q],styles:[".form-check-input[_ngcontent-%COMP%]{cursor:pointer}.form-check-input[_ngcontent-%COMP%]:checked{background-color:#0d6efd;border-color:#0d6efd}.table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   tr.table-primary[_ngcontent-%COMP%]{background-color:#0d6efd1a!important}.table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   tr.table-primary[_ngcontent-%COMP%]:hover{background-color:#0d6efd33!important}.bulk-actions[_ngcontent-%COMP%]{transition:all .3s ease}.bulk-actions[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]{transition:all .2s ease}.bulk-actions[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]:hover{transform:translateY(-1px);box-shadow:0 2px 4px #0000001a}.badge[_ngcontent-%COMP%]{font-size:.875rem;padding:.5rem .75rem}.nav-tabs[_ngcontent-%COMP%]{border-bottom:2px solid #e9ecef;margin-bottom:1.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{border:none;border-radius:8px 8px 0 0;padding:.75rem 1.5rem;font-weight:600;color:#6c757d;background-color:transparent;transition:all .3s ease;margin-right:.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]:hover{color:#007bff;background-color:#f8f9fa;border-color:transparent}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{color:#007bff;background-color:#fff;border-color:#007bff #007bff #fff;border-width:2px 2px 0;box-shadow:0 -2px 4px #007bff1a}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:.5rem;font-size:1.1em}@media (max-width: 768px){.nav-tabs[_ngcontent-%COMP%]{flex-direction:column}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{margin-right:0;margin-bottom:.5rem;border-radius:8px;text-align:center}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{border-width:2px;border-color:#007bff}.bulk-actions[_ngcontent-%COMP%]{flex-direction:column;align-items:stretch!important}.bulk-actions[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]{margin-bottom:.5rem}.table-responsive[_ngcontent-%COMP%]{font-size:.875rem}}.btn[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.modal-header.bg-danger[_ngcontent-%COMP%]{background-color:#dc3545!important}.modal-header.bg-success[_ngcontent-%COMP%]{background-color:#198754!important}.table[_ngcontent-%COMP%]   thead[_ngcontent-%COMP%]   th[_ngcontent-%COMP%]   .form-check-input[_ngcontent-%COMP%], .table[_ngcontent-%COMP%]   tbody[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]   .form-check-input[_ngcontent-%COMP%]{margin:0}"]})}return l})();var Pa=()=>({exact:!0}),wi=(()=>{class l{static \u0275fac=function(i){return new(i||l)};static \u0275cmp=q({type:l,selectors:[["app-drafts-parent-view"]],decls:8,vars:2,consts:[[1,"nav","nav-tabs","mb-2"],["routerLink","supplier","routerLinkActive","active",1,"nav-link",3,"routerLinkActiveOptions"],[1,"fa","fa-building","me-1"],["routerLink","staff","routerLinkActive","active",1,"nav-link"],[1,"fa","fa-user-tie","me-1"]],template:function(i,t){i&1&&(r(0,"nav",0)(1,"a",1),c(2,"i",2),o(3,"Supplier Drafts "),n(),r(4,"a",3),c(5,"i",4),o(6,"Staff Expense Drafts "),n()(),c(7,"router-outlet")),i&2&&(d(),p("routerLinkActiveOptions",He(1,Pa)))},dependencies:[ce,De,Te],styles:[".nav-tabs[_ngcontent-%COMP%]{border-bottom:2px solid #e9ecef;margin-bottom:1.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{border:none;border-radius:8px 8px 0 0;padding:.75rem 1.5rem;font-weight:600;color:#6c757d;background-color:transparent;transition:all .3s ease;margin-right:.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]:hover{color:#007bff;background-color:#f8f9fa;border-color:transparent}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{color:#007bff;background-color:#fff;border-color:#007bff #007bff #fff;border-width:2px 2px 0;box-shadow:0 -2px 4px #007bff1a}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:.5rem;font-size:1.1em}@media (max-width: 768px){.nav-tabs[_ngcontent-%COMP%]{flex-direction:column}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{margin-right:0;margin-bottom:.5rem;border-radius:8px;text-align:center}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{border-width:2px;border-color:#007bff}}"]})}return l})();var Aa=()=>({exact:!0}),Ci=(()=>{class l{static \u0275fac=function(i){return new(i||l)};static \u0275cmp=q({type:l,selectors:[["app-publish-parent-view"]],decls:8,vars:2,consts:[[1,"nav","nav-tabs","mb-2"],["routerLink","supplier","routerLinkActive","active",1,"nav-link",3,"routerLinkActiveOptions"],[1,"fa","fa-building","me-1"],["routerLink","staff","routerLinkActive","active",1,"nav-link"],[1,"fa","fa-user-tie","me-1"]],template:function(i,t){i&1&&(r(0,"nav",0)(1,"a",1),c(2,"i",2),o(3,"Supplier Forms "),n(),r(4,"a",3),c(5,"i",4),o(6,"Staff Expense "),n()(),c(7,"router-outlet")),i&2&&(d(),p("routerLinkActiveOptions",He(1,Aa)))},dependencies:[ce,De,Te],styles:[".nav-tabs[_ngcontent-%COMP%]{border-bottom:2px solid #e9ecef;margin-bottom:1.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{border:none;border-radius:8px 8px 0 0;padding:.75rem 1.5rem;font-weight:600;color:#6c757d;background-color:transparent;transition:all .3s ease;margin-right:.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]:hover{color:#007bff;background-color:#f8f9fa;border-color:transparent}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{color:#007bff;background-color:#fff;border-color:#007bff #007bff #fff;border-width:2px 2px 0;box-shadow:0 -2px 4px #007bff1a}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:.5rem;font-size:1.1em}@media (max-width: 768px){.nav-tabs[_ngcontent-%COMP%]{flex-direction:column}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{margin-right:0;margin-bottom:.5rem;border-radius:8px;text-align:center}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{border-width:2px;border-color:#007bff}}"]})}return l})();var Ei=(l,f)=>({display:l,background:f});function Ia(l,f){if(l&1&&(r(0,"span",35),o(1),n()),l&2){let e=g();d(),A("",e.getSelectedFormsCount()," selected")}}function ka(l,f){l&1&&c(0,"span",36)}function Ta(l,f){l&1&&c(0,"i",37)}function Na(l,f){l&1&&(r(0,"div",38)(1,"div",39)(2,"span",40),o(3,"Loading..."),n()()())}function Ma(l,f){if(l&1&&(r(0,"div",41),o(1),n()),l&2){let e=g();d(),w(e.publishedError)}}function Va(l,f){if(l&1&&(r(0,"span",61),o(1),n()),l&2){let e=g(2).$implicit;d(),w(e.chequeNo)}}function Oa(l,f){if(l&1){let e=I();r(0,"div",69),_(1,Va,2,1,"span",70),r(2,"button",71),b("click",function(){x(e);let t=g().$implicit,a=g(2);return S(a.openEditChequeNoModal(t))}),c(3,"i",72),n()()}if(l&2){let e=g().$implicit,i=g(2);d(),p("ngIf",e.chequeNo),d(),p("disabled",i.editingChequeNo)}}function Ra(l,f){l&1&&(r(0,"span",27),o(1,"-"),n())}function qa(l,f){if(l&1){let e=I();r(0,"tr")(1,"td",59)(2,"input",60),b("change",function(t){let a=x(e).$implicit,s=g(2);return S(s.toggleFormSelection(a,t))}),n()(),r(3,"td",59),o(4),n(),r(5,"td"),o(6),n(),r(7,"td"),o(8),n(),r(9,"td"),o(10),n(),r(11,"td"),o(12),n(),r(13,"td",61),o(14),L(15,"date"),n(),r(16,"td",59)(17,"button",62),b("click",function(){let t=x(e).$implicit,a=g(2);return S(a.openParticularsModal(t.particulars))}),c(18,"i",63),n()(),r(19,"td",64),o(20),L(21,"number"),n(),r(22,"td",59)(23,"span",65),o(24),n()(),r(25,"td",59),_(26,Oa,4,2,"div",66)(27,Ra,2,0,"span",67),n(),r(28,"td",59)(29,"span",68),o(30),n()()()}if(l&2){let e=f.$implicit,i=f.index,t=g(2);re("table-primary",t.isFormSelected(e)),d(2),p("checked",t.isFormSelected(e)),d(2),w(i+1),d(2),w(e.nameOfStaff||"N/A"),d(2),w(e.idNo||"N/A"),d(2),w(e.designation||"N/A"),d(2),w(e.dept||"N/A"),d(2),w(B(15,16,e.date,"dd-MM-yyyy")),d(6),w(e.total?B(21,19,e.total,"1.0-0"):"0"),d(3),p("ngClass",t.getStageBadgeClass(e)),d(),A(" ",t.getCurrentApprovalStage(e)," "),d(2),p("ngIf",t.canEditChequeNo(e)),d(),p("ngIf",!t.canEditChequeNo(e)),d(2),p("ngClass",t.getTypeBadgeClass(e)),d(),A(" ",t.getTypeDisplay(e)," ")}}function La(l,f){if(l&1){let e=I();r(0,"div",42)(1,"table",43)(2,"thead",44)(3,"tr")(4,"th",45)(5,"input",46),b("
1595change",function(t){x(e);let a=g();return S(a.toggleSelectAll(t))}),n()(),r(6,"th",45),o(7,"#"),n(),r(8,"th",47),o(9,"Staff Name"),n(),r(10,"th",48),o(11,"ID No"),n(),r(12,"th",49),o(13,"Designation"),n(),r(14,"th",49),o(15,"Department"),n(),r(16,"th",50),o(17,"Date"),n(),r(18,"th",51),o(19,"Particulars"),n(),r(20,"th",52),o(21,"Total Amount"),n(),r(22,"th",53),o(23,"Approval Stage"),n(),r(24,"th",54),o(25,"Cheque No"),n(),r(26,"th",53),o(27,"TYPE"),n()()(),r(28,"tbody"),_(29,qa,31,22,"tr",55),n()(),r(30,"div",56)(31,"button",57),b("click",function(){x(e);let t=g();return S(t.publishedPrevPage())}),o(32,"\xAB Prev"),n(),r(33,"span"),o(34),n(),r(35,"button",58),b("click",function(){x(e);let t=g();return S(t.publishedNextPage())}),o(36,"Next \xBB"),n()()()}if(l&2){let e=g();d(5),p("checked",e.allSelected)("indeterminate",e.getSelectedFormsCount()>0&&e.getSelectedFormsCount()<e.publishedForms.length),d(24),p("ngForOf",e.publishedForms),d(2),p("disabled",e.isPublishedPrevDisabled()),d(3),A("Page ",e.publishedPageNumber,""),d(),p("disabled",e.isPublishedNextDisabled())}}function Ba(l,f){l&1&&(r(0,"div",73),o(1,"No published forms available."),n())}function $a(l,f){l&1&&c(0,"span",81)}function Ua(l,f){l&1&&c(0,"i",37)}function za(l,f){if(l&1){let e=I();r(0,"div",74)(1,"div",75)(2,"div",16)(3,"div",76)(4,"h5",77),o(5,"Confirm Delete"),n(),r(6,"button",78),b("click",function(){x(e);let t=g();return S(t.closeDeleteConfirmModal())}),n()(),r(7,"div",20)(8,"p"),o(9," Are you sure you want to delete "),r(10,"strong"),o(11),n(),o(12," selected pending staff expense form(s)? "),n(),r(13,"p",79)(14,"small"),o(15,"This action cannot be undone."),n()()(),r(16,"div",28)(17,"button",29),b("click",function(){x(e);let t=g();return S(t.closeDeleteConfirmModal())}),o(18," Cancel "),n(),r(19,"button",80),b("click",function(){x(e);let t=g();return S(t.confirmDeleteSelected())}),_(20,$a,1,0,"span",31)(21,Ua,1,0,"i",8),o(22," Delete "),n()()()()()}if(l&2){let e=g();p("ngStyle",Ze(7,Ei,e.showDeleteConfirmModal?"block":"none",e.showDeleteConfirmModal?"rgba(0,0,0,0.5)":"none")),d(6),p("disabled",e.deleting),d(5),w((e.deleteTargets==null?null:e.deleteTargets.length)||0),d(6),p("disabled",e.deleting),d(2),p("disabled",e.deleting),d(),p("ngIf",e.deleting),d(),p("ngIf",!e.deleting)}}function Ya(l,f){l&1&&c(0,"span",81)}function Ga(l,f){l&1&&c(0,"i",82)}function Wa(l,f){l&1&&c(0,"div",83)}function ja(l,f){if(l&1){let e=I();r(0,"div",84)(1,"div",85)(2,"div",16)(3,"div",76)(4,"h5",77),o(5,"Particulars"),n(),r(6,"button",19),b("click",function(){x(e);let t=g();return S(t.closeParticularsModal())}),n()(),r(7,"div",20)(8,"p"),o(9),n()(),r(10,"div",28)(11,"button",86),b("click",function(){x(e);let t=g();return S(t.closeParticularsModal())}),o(12,"Close"),n()()()()()}if(l&2){let e=g();p("ngStyle",Ze(2,Ei,e.viewParticularsText?"block":"none",e.viewParticularsText?"rgba(0,0,0,0.5)":"none")),d(9),w(e.viewParticularsText)}}var yi=(()=>{class l{staffExpenseFormService;requestFormService;toastr;fileUploadService;publishedForms=[];publishedLoading=!1;publishedError="";publishedPageNumber=1;publishedPageSize=100;filterStaffName="";viewParticularsText=null;selectedForms=new Set;allSelected=!1;deleting=!1;showDeleteConfirmModal=!1;deleteTargets=[];constructor(e,i,t,a){this.staffExpenseFormService=e,this.requestFormService=i,this.toastr=t,this.fileUploadService=a}ngOnInit(){this.fetchPublishedForms()}fetchPublishedForms(){this.publishedLoading=!0,this.publishedError="";let e=(this.publishedPageNumber-1)*this.publishedPageSize;this.staffExpenseFormService.getPendingRequestForms().then(i=>{console.log("Raw API response (Staff Expense):",i);let t=Array.isArray(i)?i:[];console.log("Parsed data array length (Staff Expense):",t.length);let a=[];t.forEach((s,m)=>{let u=s._id||s.id;if(console.log(`Processing requestForm ${m} (Staff Expense):`,{_id:s._id,id:s.id,requestFormId:u,requestType:s.requestType,submissionStatus:s.submissionStatus,hasFormData:!!s.formData,formDataType:Array.isArray(s.formData)?"array":typeof s.formData,allKeys:Object.keys(s)}),!u){console.warn(`\u274C RequestForm ${m} missing both _id and id, skipping. Full object:`,s);return}if(s.requestType!=="STAFFEXPENSE"){console.log(`\u274C Skipping non-STAFFEXPENSE request type: ${s.requestType}`);return}let h=s.formData;if(!h){console.warn(`\u274C RequestForm ${u} has no formData. Full object:`,s);return}console.log(`\u2705 Processing staffExpenseForm from formData for requestForm ${u}...`),Array.isArray(h)?(console.log(`  \u2192 formData is array with ${h.length} items`),h.forEach((v,E)=>{console.log(`  \u2192 Processing array item ${E}:`,v),a.push(N(T({},v),{requestFormId:u,submissionStatus:s.submissionStatus,approvalType:s.approvalType,approvalLevels:s.approvalLevels}))})):(console.log("  \u2192 formData is single object:",h),a.push(N(T({},h),{requestFormId:u,submissionStatus:s.submissionStatus,approvalType:s.approvalType,approvalLevels:s.approvalLevels}))),console.log(`  \u2705 Added to pendingStaffForms. Total now: ${a.length}`)}),this.filterStaffName&&(a=a.filter(s=>s.nameOfStaff&&s.nameOfStaff.toLowerCase().includes(this.filterStaffName.toLowerCase()))),this.publishedForms=a.map((s,m)=>N(T({},s),{uniqueId:`${s._id||s.id||s.requestFormId}_${m}`})),this.selectedForms.clear(),this.allSelected=!1,console.log("Fetched published staff expense forms:",this.publishedForms),console.log("Total forms found (Staff Expense):",this.publishedForms.length),console.log("Summary (Staff Expense):",{totalRequestForms:t.length,formsWithFormData:a.length,finalDisplayCount:this.publishedForms.length})}).catch(i=>{console.error("Error fetching published forms (Staff Expense):",i),this.publishedError="Failed to load published staff expense forms."}).finally(()=>{this.publishedLoading=!1})}onFilterChange(){this.publishedPageNumber=1,this.fetchPublishedForms()}publishedNextPage(){this.publishedForms.length===this.publishedPageSize&&(this.publishedPageNumber++,this.fetchPublishedForms())}publishedPrevPage(){this.publishedPageNumber>1&&(this.publishedPageNumber--,this.fetchPublishedForms())}isPublishedPrevDisabled(){return this.publishedPageNumber<=1}isPublishedNextDisabled(){return this.publishedForms.length<this.publishedPageSize}getTypeDisplay(e){return e.approvalType==="NONE"?"Normal form":e.approvalType==="PRE_APPROVED"?"Pre_approval form":e.approvalType==="WITHOUT_CHEQUE"?"Without cheque":"Unknown"}getTypeBadgeClass(e){return e.approvalType==="NONE"?"bg-info":e.approvalType==="PRE_APPROVED"?"bg-warning":(e.approvalType==="WITHOUT_CHEQUE","bg-secondary")}
1595isFinalStageOnly(e){return e?.approvalType==="PRE_APPROVED"||e?.approvalType==="WITHOUT_CHEQUE"}isStage1Complete(e){return!e.approvalLevels||e.approvalLevels.length===0||this.isFinalStageOnly(e)?!1:e.approvalLevels.every(i=>{let t=i.eSignature?.preApprovedSignature;return t&&(t.url||t.fileKey&&t.versionId)})}getCurrentApprovalStage(e){if(!e.approvalLevels||e.approvalLevels.length===0)return"N/A";if(e.approvalType==="WITHOUT_CHEQUE")return e.approvalLevels.every(s=>{let m=s.eSignature?.finalApprovalSignature;return m&&(m.url||m.fileKey&&m.versionId)})?"Approved (no cheque)":"Final approval (no cheque)";let i=this.isStage1Complete(e),t=e.chequeNo&&e.chequeNo.trim().length>0;return i&&t?"Stage 2: Cheque Approved":i?"Stage 1 Complete - Add Cheque No":"Stage 1: Amount Estimate Approved"}getStageBadgeClass(e){let i=this.getCurrentApprovalStage(e);return i.includes("Stage 2")?"bg-success":i.includes("Stage 1 Complete")?"bg-warning":i.includes("Stage 1")?"bg-primary":"bg-secondary"}canEditChequeNo(e){return e.approvalType==="WITHOUT_CHEQUE"?!1:e.approvalType==="PRE_APPROVED"?!0:this.isStage1Complete(e)}showEditChequeNoModal=!1;selectedFormForChequeNo=null;chequeNoInput="";editingChequeNo=!1;openEditChequeNoModal(e){this.selectedFormForChequeNo=e,this.chequeNoInput=e.chequeNo||"",this.showEditChequeNoModal=!0}closeEditChequeNoModal(){this.showEditChequeNoModal=!1,this.selectedFormForChequeNo=null,this.chequeNoInput=""}saveChequeNo(){if(!this.selectedFormForChequeNo||!this.chequeNoInput||this.chequeNoInput.trim().length===0){this.toastr.warning("Please enter a valid Cheque No.");return}let e=this.selectedFormForChequeNo,i=e.requestFormId;if(!i){console.error("RequestFormId is missing:",e),this.toastr.error("Unable to update: Request Form ID is missing. Please refresh the page and try again.");return}this.editingChequeNo=!0;let E=e,{submissionStatus:t,approvalType:a,approvalLevels:s,uniqueId:m}=E,u=tt(E,["submissionStatus","approvalType","approvalLevels","uniqueId"]);u.chequeNo=this.chequeNoInput.trim();let h={staffExpenseForm:u,formData:u},v=e.approvalType==="PRE_APPROVED";console.log("Updating cheque no:",{requestFormId:i,updatePayload:h,isPreApproved:v}),this.requestFormService.updateRequestForm(i,h).then(()=>{e.chequeNo=this.chequeNoInput.trim(),this.toastr.success("Cheque No updated successfully!"),v?this.toastr.info("Form is now ready for final approval. Please go to Form Approval page to e-sign.","Pre-Approval Ready"):this.toastr.info("Form is now ready for Stage 2 (Final Approval). Please go to Form Approval page - Cheque tab to e-sign.","Stage 2 Ready"),this.closeEditChequeNoModal(),this.fetchPublishedForms()}).catch(y=>{console.error("Error updating cheque no:",y),this.toastr.error("Failed to update Cheque No. Please try again.")}).finally(()=>{this.editingChequeNo=!1})}openParticularsModal(e){this.viewParticularsText=e}closeParticularsModal(){this.viewParticularsText=null}toggleSelectAll(e){e.target.checked?(this.selectedForms=new Set(this.publishedForms.map(i=>i.uniqueId)),this.allSelected=!0):(this.selectedForms.clear(),this.allSelected=!1)}toggleFormSelection(e,i){let t=e.uniqueId;console.log("Toggling staff form selection:",{formId:t,staffName:e.nameOfStaff,typeOfClaim:e.typeOfClaim,checked:i.target.checked,currentSelection:Array.from(this.selectedForms)}),i.target.checked?this.selectedForms.add(t):this.selectedForms.delete(t),this.allSelected=this.selectedForms.size===this.publishedForms.length,console.log("After staff toggle:",{selectedCount:this.selectedForms.size,totalForms:this.publishedForms.length,allSelected:this.allSelected,currentSelection:Array.from(this.selectedForms)})}isFormSelected(e){let i=e.uniqueId;return this.selectedForms.has(i)}getSelectedFormsCount(){return this.selectedForms.size}deleteSelected(){let e=this.publishedForms.filter(i=>this.selectedForms.has(i.uniqueId));e.length!==0&&(this.deleteTargets=e,this.showDeleteConfirmModal=!0)}closeDeleteConfirmModal(){this.deleting||(this.showDeleteConfirmModal=!1,this.deleteTargets=[])}confirmDeleteSelected(){if(!this.deleteTargets||this.deleteTargets.length===0){this.showDeleteConfirmModal=!1;return}this.deleting=!0;let i=this.deleteTargets.map(t=>t.requestFormId).filter(t=>!!t).map(t=>this.requestFormService.deleteRequestForm(t));Promise.allSettled(i).then(t=>{let a=t.filter(m=>m.status==="fulfilled").length,s=t.length-a;a>0&&this.toastr.success(`${a} form(s) deleted.`,"Deleted"),s>0&&this.toastr.error(`${s} form(s) failed to delete.`,"Error"),this.fetchPublishedForms(),this.selectedForms.clear(),this.allSelected=!1}).finally(()=>{this.deleting=!1,this.showDeleteConfirmModal=!1,this.deleteTargets=[]})}printSelectedForApproval(){return M(this,null,function*(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to print.","No Selection");return}let e=this.publishedForms.filter(u=>this.selectedForms.has(u.uniqueId));this.toastr.info("Preparing document and loading signatures...","Generating Print Document");let t=e[0]?.approvalLevels||[],a=yield this.loadAllSignaturesInParallel(t),s=window.open("","_blank");if(!s){this.toastr.error("Please allow popups to print the document.","Error");return}let m=this.generateApprovalPrintContent(e,a);s.document.write(`
1596      <!DOCTYPE html>
1597      <html>
1598        <head>
1599          <title>Staff Expense Forms - Approval Evidence</title>
1600          <style>
1601            body {
1602              font-family: Arial, sans-serif;
1603              margin: 15px;
1604              padding: 0;
1605              font-size: 12px;
1606              color: #000;
1607            }
1608            .header { 
1609              text-align: center; 
1610            }
1611            .logo-container {
1612
1613            }
1614            .logo {
1615               max-width: 300px;
1616               height: 120px;
1617               margin: 0 auto;
1618               display: block;
1619               object-fit: contain;
1620             }
1621            .document-title {
1622              font-size: 20px;
1623              font-weight: bold;
1624              text-align: center;
1625              color: #000;
1626              margin-bottom: 20px;
1627            }
1628            table { 
1629              width: 100%; 
1630              border-collapse: collapse; 
1631              margin-top: 20px;
1632              border: 1px solid #000;
1633              table-layout: fixed; /* Fixed layout for better width control */
1634            }
1635            th, td {
1636              border: 1px solid #000;
1637              padding: 8px 6px;
1638              text-align: left;
1639              vertical-align: middle;
1640              font-size: 12px;
1641              word-break: keep-all;
1642              overflow-wrap: break-word;
1643              white-space: normal;
1644              overflow: hidden;
1645              text-overflow: ellipsis;
1646            }
1647            th { 
1648              background-color: #f2f2f2; 
1649              font-weight: bold;
1650              text-align: center;
1651              color: #000;
1652              font-size: 12px;
1653            }
1654            td {
1655              font-size: 14px;
1656            }
1657            /* Numeric values - ensure readable font size */
1658            td.text-right,
1659            td.amount {
1660              font-size: 14px;
1661            }
1662            /* APPROVAL-PRINT: Sl.No(1)=2%, Staff(2)=11%, ID(3)=4%, Desig(4)=9%, Dept(5)=7%, Claim(6)=9%, Date(7)=8%, Venue(8)=7%, Particulars(9)=22%, ChequeNo(10)=6%, TotalAmt(11)=7%, ApprovedDate(12)=8% [Total=100%] */
1663            table.approval-print th:nth-child(1),
1664            table.approval-print td:nth-child(1) {
1665              width: 2%;
1666              text-align: center;
1667              white-space: nowrap;
1668              overflow: hidden;
1669              padding: 6px 3px;
1670            }
1671            table.approval-print th:nth-child(2),
1672            table.approval-print td:nth-child(2) {
1673              width: 11%;
1674              word-break: keep-all;
1675              overflow-wrap: break-word;
1676              padding: 6px 4px;
1677            }
1678            table.approval-print th:nth-child(3),
1679            table.approval-print td:nth-child(3) {
1680              width: 4%;
1681              text-align: center;
1682              white-space: nowrap;
1683              overflow: hidden;
1684              padding: 6px 3px;
1685            }
1686            table.approval-print th:nth-child(4),
1687            table.approval-print td:nth-child(4) {
1688              width: 9%;
1689              word-break: keep-all;
1690              overflow-wrap: break-word;
1691              white-space: normal;
1692              overflow: hidden;
1693              padding: 6px 4px;
1694            }
1695            table.approval-print th:nth-child(5),
1696            table.approval-print td:nth-child(5) {
1697              width: 7%;
1698              word-break: keep-all;
1699              overflow-wrap: break-word;
1700              padding: 6px 4px;
1701            }
1702            table.approval-print th:nth-child(6),
1703            table.approval-print td:nth-child(6) {
1704              width: 9%;
1705              word-break: keep-all;
1706              overflow-wrap: break-word;
1707              padding: 6px 4px;
1708            }
1709            table.approval-print th:nth-child(7),
1710            table.approval-print td:nth-child(7) {
1711              width: 8%;
1712              text-align: center;
1713              white-space: nowrap;
1714              overflow: hidden;
1715              padding: 6px 3px;
1716            }
1717            table.approval-print th:nth-child(8),
1718            table.approval-print td:nth-child(8) {
1719              width: 7%;
1720              text-align: center;
1721              white-space: nowrap;
1722              overflow: hidden;
1723              padding: 6px 3px;
1724            }
1725            table.approval-print th:nth-child(9),
1726            table.approval-print td:nth-child(9) {
1727              width: 22%;
1728              word-break: keep-all;
1729              overflow-wrap: break-word;
1730              padding: 6px 4px;
1731            }
1732            table.approval-print th:nth-child(9) {
1733              text-align: center;
1734            }
1735            table.approval-print td:nth-child(9) {
1736              text-align: left;
1737            }
1738            table.approval-print th:nth-child(10),
1739            table.approval-print td:nth-child(10) {
1740              width: 6%;
1741              text-align: center;
1742              white-space: nowrap;
1743              overflow: hidden;
1744              padding: 6px 3px;
1745            }
1746            table.approval-print th:nth-child(11),
1747            table.approval-print td:nth-child(11) {
1748              width: 7%;
1749              text-align: right;
1750              white-space: nowrap;
1751              overflow: hidden;
1752              padding: 6px 4px;
1753            }
1754            table.approval-print th:nth-child(12),
1755            table.approval-print td:nth-child(12) {
1756              width: 8%;
1757              text-align: center;
1758              white-space: nowrap;
1759              overflow: hidden;
1760              padding: 6px 3px;
1761            }
1762            .text-center { text-align: center; }
1763            .text-right { text-align: right; }
1764            .amount { font-weight: bold; }
1765            .total-row {
1766              background-color: #fff;
1767              font-weight: bold;
1768            }
1769            .total-row td {
1770              font-size: 14px;
1771            }
1772            .amount-in-words {
1773              margin-top: 20px;
1774              padding: 10px;
1775              background-color: #f9f9f9;
1776              border: 1px solid #ccc;
1777              text-align: center;
1778              font-weight: bold;
1779              color: #000;
1780              font-size: 14px;
1781            }
1782            .signature-section {
1783              margin-top: 40px;
1784              display: flex;
1785              justify-content: space-between;
1786            }
1787            .signature-box {
1788              text-align: center;
1789              width: 200px;
1790              border: none;
1791              padding: 10px;
1792              margin: 5px;
1793            }
1794            .signature-title {
1795              font-weight: bold;
1796              margin-bottom: 10px;
1797              font-size: 12px;
1798              border-bottom: 1px solid #000;
1799              padding-bottom: 5px;
1800              color: #000;
1801            }
1802            .signature-image {
1803              margin: 0;
1804              padding: 0;
1805              display: flex;
1806              align-items: center;
1807              justify-content: center;
1808              width: 180px;
1809              height: 80px;
1810            }
1811            .e-signature {
1812              width: 180px;
1813              height: 80px;
1814              object-fit: cover;
1815              border: none;
1816              background: transparent;
1817              padding: 0;
1818              margin: 0;
1819            }
1820            .signature-placeholder {
1821              margin: 10px 0;
1822              min-height: 90px;
1823              display: flex;
1824              align-items: center;
1825              justify-content: center;
1826            }
1827            .signature-line {
1828              width: 150px;
1829              height: 1px;
1830              border-bottom: 1px solid #333;
1831              margin: 0 auto;
1832            }
1833            .print-button {
1834              position: fixed;
1835              top: 20px;
1836              right: 20px;
1837              background-color: #007bff;
1838              color: white;
1839              border: none;
1840              padding: 10px 20px;
1841              border-radius: 5px;
1842              cursor: pointer;
1843              font-size: 14px;
1844              font-weight: bold;
1845              box-shadow: 0 2px 5px rgba(0,0,0,0.2);
1846              z-index: 1000;
1847            }
1848            .print-button:hover {
1849              background-color: #0056b3;
1850            }
1851            .generated-on {
1852              position: fixed;
1853              top: 60px;
1854              right: 20px;
1855              color: #555;
1856              font-size: 12px;
1857              background: rgba(255,255,255,0.9);
1858              padding: 4px 8px;
1859              border: 1px solid #ddd;
1860              border-radius: 4px;
1861              z-index: 999;
1862            }
1863            /* Page number styling */
1864            .page-number {
1865              position: fixed;
1866              top: 10px;
1867              right: 20px;
1868              font-size: 12px;
1869              font-weight: bold;
1870              color: #333;
1871              z-index: 1000;
1872              background: rgba(255, 255, 255, 0.9);
1873              padding: 4px 8px;
1874              border-radius: 4px;
1875            }
1876            @media print {
1877              body {
1878                margin: 0;
1879                padding: 10mm;
1880                font-size: 13px;
1881              }
1882              .no-print { display: none; }
1883              .print-button { display: none; }
1884              .generated-on { display: none; }
1885              .page-number { display: none; }
1886              .logo {
1887                max-width: 250px !important;
1888                height: 90px !important;
1889              }
1890              table {
1891                width: 100% !important;
1892                table-layout: fixed !important;
1893                font-size: 13px;
1894                margin-top: 15px;
1895              }
1896              th, td {
1897                font-size: 13px;
1898                padding: 5px 3px !important;
1899                word-break: keep-all !important;
1900                overflow-wrap: break-word !important;
1901                white-space: normal !important;
1902                overflow: hidden !important;
1903                text-overflow: ellipsis !important;
1904              }
1905              tbody tr {
1906                page-break-inside: avoid;
1907              }
1908              .total-row {
1909                page-break-inside: avoid;
1910              }
1911              @page {
1912                size: landscape;
1913                margin: 10mm;
1914              }
1915            }
1916          </style>
1917        </head>
1918        <body>
1919          <button class="print-button" onclick="window.print()">\u{1F5A8}\uFE0F Print Document</button>
1920           <div class="page-number no-print">Page 1</div>
1921          ${m}
1922        </body>
1923      </html>
1924    `),s.document.close(),s.focus()})}generateApprovalPrintContent(e,i=null){let t=e.some(u=>{let h=this.getApprovalInfo(u.approvalLevels||[],"PRESIDENT")||this.getApprovalInfo(u.approvalLevels||[],"PRESIDENTADMIN");return!!u.approvedDate||h&&h.status==="APPROVED"&&!!h.actionDate}),a=0,s="";e.forEach((u,h)=>{let v=u.total||0,E=u.date?new Date(u.date).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}).replace(/\//g,"-"):"N/A",y=this.getApprovalInfo(u.approvalLevels||[],"PRESIDENT")||this.getApprovalInfo(u.approvalLevels||[],"PRESIDENTADMIN"),F=null;u.app
1924rovedDate?F=u.approvedDate:y&&y.status==="APPROVED"&&y.actionDate&&(F=y.actionDate);let k="";if(F)try{let V=new Date(F);isNaN(V.getTime())||(k=V.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}).replace(/\//g,"-"))}catch(V){console.error("Error parsing date:",V)}a+=v,s+=`
1925        <tr>
1926          <td class="text-center">${h+1}</td>
1927          <td>${u.nameOfStaff||"N/A"}</td>
1928          <td>${u.idNo||"N/A"}</td>
1929          <td>${u.designation||"N/A"}</td>
1930          <td>${u.dept||"N/A"}</td>
1931          <td>${u.typeOfClaim||"N/A"}</td>
1932          <td class="text-center" style="white-space: nowrap;">${E}</td>
1933          <td>${u.venue||"N/A"}</td>
1934          <td>${u.particulars||"N/A"}</td>
1935          <td class="text-center">${u.chequeNo||"N/A"}</td>
1936          <td class="text-right amount">${v}</td>
1937          ${t?`<td class="text-center" style="white-space: nowrap;">${k}</td>`:""}
1938        </tr>
1939      `});let m=this.numberToWords(a);return i=i||{dean:null,registrar:null,president:null},`
1940      <div class="header">
1941        <div class="logo-container">
1942          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
1943        </div>
1944      </div>
1945      
1946      <div class="document-title">
1947        Submitted to the Approval of the President
1948      </div>
1949      
1950      <table class="approval-print">
1951        <thead>
1952          <tr>
1953            <th class="text-center">Sl.No.</th>
1954            <th class="text-center">Staff<br>Name</th>
1955            <th class="text-center">ID<br>No</th>
1956            <th class="text-center">Designation</th>
1957            <th class="text-center">Department</th>
1958            <th class="text-center">Type of<br>Claim</th>
1959            <th class="text-center">Date</th>
1960            <th class="text-center">Venue</th>
1961            <th class="text-center">Particulars</th>
1962            <th class="text-center">Cheque<br>No</th>
1963            <th class="text-right">Total<br>Amount \u20B9</th>
1964            ${t?'<th class="text-center">Approved<br>Date</th>':""}
1965          </tr>
1966        </thead>
1967        <tbody>
1968          ${s}
1969          <tr class="total-row">
1970            <td colspan="10" class="text-center"><strong>Total \u20B9</strong></td>
1971            <td class="text-right"><strong>${a}</strong></td>
1972            ${t?"<td></td>":""}
1973          </tr>
1974        </tbody>
1975      </table>
1976      
1977      <div class="amount-in-words">
1978        (Rupees ${m} only)
1979      </div>
1980      
1981      ${t?`
1982      <div class="signature-section">
1983        <div class="signature-box">
1984          ${this.getSignatureHtmlFromUrl(i.dean,"Dean Signature")}
1985          <div class="signature-title">DEAN-STUDENT AFFAIRS</div>
1986        </div>
1987        <div class="signature-box">
1988          ${this.getSignatureHtmlFromUrl(i.registrar,"Registrar Signature")}
1989          <div class="signature-title">REGISTRAR</div>
1990        </div>
1991        <div class="signature-box">
1992          ${this.getSignatureHtmlFromUrl(i.president,"President Signature")}
1993          <div class="signature-title">PRESIDENT</div>
1994        </div>
1995      </div>`:""}
1996
1997    `}getApprovalInfo(e,i){if(!e||e.length===0)return null;let t=i.toUpperCase().trim(),a=e.find(s=>{if(!s)return!1;let m=(s.role||"").toString().toUpperCase().trim(),u=(s.roles||"").toString().toUpperCase().trim(),h=(s.label||"").toString().toUpperCase().trim();return m===t||u===t||h===t||m.includes(t)||t.includes(m)||t.includes("PRESIDENT")&&(m.includes("PRESIDENT")||h.includes("PRESIDENT"))||t.includes("DEAN")&&(m.includes("DEAN")||h.includes("DEAN"))||t.includes("REGISTRAR")&&(m.includes("REGISTRAR")||h.includes("REGISTRAR"))});return a?{status:a.status||"PENDING",actionDate:a.actionDate||a.approvedDate||a.date||"",approvedByName:a.approvedByName||a.name||a.approverName||i,remarks:a.remarks||"",eSignature:a.eSignature||null}:null}loadAllSignaturesInParallel(e){return M(this,null,function*(){console.log("\u{1F50D} Loading signatures in parallel. Approval levels:",e);let i=this.findAnySignature(e);console.log("\u{1F50D} Base signature found:",i);let t=this.createRoleSpecificSignature(i,"DEAN"),a=this.createRoleSpecificSignature(i,"REGISTRAR"),s=this.createRoleSpecificSignature(i,"PRESIDENT"),m=this.extractApproverSignatureData(e,"DEAN")||this.extractApproverSignatureData(e,"DEANADMIN"),u=this.extractApproverSignatureData(e,"REGISTRAR")||this.extractApproverSignatureData(e,"REGISTRARADMIN"),h=this.extractApproverSignatureData(e,"PRESIDENT")||this.extractApproverSignatureData(e,"PRESIDENTADMIN");try{console.log("\u{1F680} Starting parallel signature loading...");let[v,E,y]=yield Promise.all([this.makeIndividualApiCallWithDbData(m,"DEAN"),this.makeIndividualApiCallWithDbData(u,"REGISTRAR"),this.makeIndividualApiCallWithDbData(h,"PRESIDENT")]);return console.log("\u2705 Signature loading completed:",{deanUrl:v,registrarUrl:E,presidentUrl:y}),{dean:v,registrar:E,president:y}}catch(v){return console.error("\u274C Error loading signatures:",v),{dean:null,registrar:null,president:null}}})}extractApproverSignatureData(e,i){if(!e||e.length===0)return null;let t=i.toUpperCase().trim(),a=e.find(s=>
1997{if(!s)return!1;let m=(s.role||"").toString().toUpperCase().trim(),u=(s.roles||"").toString().toUpperCase().trim(),h=(s.label||"").toString().toUpperCase().trim();return m===t||u===t||h===t||m.includes(t)||t.includes(m)||t.includes("PRESIDENT")&&(m.includes("PRESIDENT")||h.includes("PRESIDENT"))||t.includes("DEAN")&&(m.includes("DEAN")||h.includes("DEAN"))||t.includes("REGISTRAR")&&(m.includes("REGISTRAR")||h.includes("REGISTRAR"))});if(a&&a.eSignature){if(a.eSignature.preApprovedSignature){let s=a.eSignature.preApprovedSignature;if(s.url||s.versionId&&s.fileKey)return s}return a.eSignature.finalApprovalSignature?a.eSignature.finalApprovalSignature:a.eSignature}return null}makeIndividualApiCallWithDbData(e,i){return M(this,null,function*(){if(!e)return null;try{if(typeof e=="string")return e.startsWith("http")?e:null;if(e.url&&e.url.startsWith("http"))return e.url;let t,a;if(e.versionId&&e.fileKey)t=e.versionId,a=e.fileKey;else return null;let s=yield this.fileUploadService.getPreSignedUrl(t,a);return s&&s.startsWith("http")?s:null}catch(t){return console.error(`\u274C ${i}: Error getting signature URL:`,t),null}})}findAnySignature(e){for(let i of e)if(i.eSignature)return i.eSignature;return null}createRoleSpecificSignature(e,i){return e?N(T({},e),{role:i,fileKey:this.getRoleSpecificFileKey(e.fileKey,i),versionId:e.versionId+`_${i.toLowerCase()}`}):null}getRoleSpecificFileKey(e,i){if(!e)return`${i.toLowerCase()}_signature.png`;if(e==="signature.png"||e==="signature")return`${i.toLowerCase()}_signature.png`;if(e.includes(i.toLowerCase()))return e;let t=e.split(".").pop();return`${e.substring(0,e.lastIndexOf("."))}_${i.toLowerCase()}.${t}`}getSignatureHtmlFromUrl(e,i){return e?`
1998        <div class="signature-image">
1999          <img src="${e}" alt="${i}" class="e-signature" onerror="this.style.display='none'; this.nextElementSibling.style.display='flex'">
2000          <div class="signature-placeholder" style="display:none">
2001            <div class="signature-line"></div>
2002          </div>
2003        </div>
2004      `:`
2005        <div class="signature-placeholder">
2006          <div class="signature-line"></div>
2007        </div>
2008      `}numberToWords(e){let i=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"],t=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"],a=["Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"];if(e===0)return"Zero";let s=u=>u===0?"":u<10?i[u]:u<20?a[u-10]:u<100?t[Math.floor(u/10)]+(u%10!==0?" "+i[u%10]:""):u<1e3?i[Math.floor(u/100)]+" Hundred"+(u%100!==0?" and "+s(u%100):""):"";return(u=>{if(u===0)return"Zero";let h=Math.floor(u/1e7),v=Math.floor(u%1e7/1e5),E=Math.floor(u%1e5/1e3),y=u%1e3,F="";return h>0&&(F+=s(h)+" Crore "),v>0&&(F+=s(v)+" Lakh "),E>0&&(F+=s(E)+" Thousand "),y>0&&(F+=s(y)),F.trim()})(Math.floor(e))}static \u0275fac=function(i){return new(i||l)(D(Ue),D(bt),D(K),D(qe))};static \u0275cmp=q({type:l,selectors:[["app-staff-expense-publish-view"]],decls:44,vars:24,consts:[[1,"mb-3","d-flex","flex-column","flex-md-row","justify-content-between","align-items-center","gap-2"],["type","text","placeholder","Filter by Staff Name",1,"form-control","w-100","w-md-50",3,"ngModelChange","ngModel"],[1,"d-flex","align-items-center","gap-2","flex-wrap"],["class","badge bg-primary me-2",4,"ngIf"],[1,"btn","btn-info","btn-sm",3,"click","disabled"],[1,"fa","fa-print","me-1"],[1,"btn","btn-danger","btn-sm",3,"click","disabled"],["class","spinner-border spinner-border-sm me-1",4,"ngIf"],["class","fa fa-trash me-1",4,"ngIf"],["class","text-center my-3",4,"ngIf"],["class","alert alert-danger animate__animated animate__fadeIn",4,"ngIf"],["class","table-responsive animate__animated animate__fadeIn",4,"ngIf"],["class","alert alert-info animate__animated animate__fadeIn",4,"ngIf"],["class","modal fade show","tabindex","-1","role","dialog",3,"ngStyle",4,"ngIf"],["tabindex","-1","role","dialog",1,"modal","fade"],["role","document",1,"modal-dialog","modal
2008-md","modal-dialog-centered"],[1,"modal-content"],[1,"modal-header","align-items-center"],[1,"modal-title","fw-bold"],["type","button",1,"btn-close",3,"click"],[1,"modal-body"],[1,"alert","alert-info"],[1,"fa","fa-info-circle","me-2"],[1,"mb-3"],[1,"form-label","fw-bold"],[1,"text-danger"],["type","text","placeholder","Enter Cheque Number",1,"form-control",3,"ngModelChange","keyup.enter","ngModel","disabled"],[1,"text-muted"],[1,"modal-footer"],["type","button",1,"btn","btn-secondary",3,"click","disabled"],["type","button",1,"btn","btn-primary",3,"click","disabled"],["class","spinner-border spinner-border-sm me-2",4,"ngIf"],["class","fa fa-save me-1",4,"ngIf"],["class","modal-backdrop fade show",4,"ngIf"],["class","modal fade show","tabindex","-1",3,"ngStyle",4,"ngIf"],[1,"badge","bg-primary","me-2"],[1,"spinner-border","spinner-border-sm","me-1"],[1,"fa","fa-trash","me-1"],[1,"text-center","my-3"],["role","status",1,"spinner-border","text-primary","spinner-border-lg","animate__animated","animate__fadeIn"],[1,"visually-hidden"],[1,"alert","alert-danger","animate__animated","animate__fadeIn"],[1,"table-responsive","animate__animated","animate__fadeIn"],[1,"table","table-sm","table-striped","table-hover","align-middle",2,"min-width","900px"],[1,"table-primary","sticky-top",2,"z-index","2"],[1,"text-center",2,"width","40px"],["type","checkbox",1,"form-check-input",3,"change","checked","indeterminate"],[2,"width","140px"],[2,"width","100px"],[2,"width","120px"],[1,"text-nowrap",2,"width","100px"],[1,"text-center",2,"width","60px"],[1,"text-end",2,"width","100px"],[1,"text-center",2,"width","120px"],[1,"text-center",2,"width","100px"],[3,"table-primary",4,"ngFor","ngForOf"],[1,"d-flex","justify-content-end","align-items-center","mt-2"],[1,"btn","btn-primary","me-2",3,"click","disabled"],[1,"btn","btn-secondary","ms-2",3,"click","disabled"],[1,"text-center"],["type","checkbox",1,"form-check-input",3,"change","checked"],[1,"text-nowrap"],["title","View Particulars",1,"btn","btn-link","p-0",3,"click"],[1,"fa","fa-eye"],[1,"text-end"],["title","Current Approval Stage",1,"badge",3,"ngClass"],["class","d-flex align-items-center justify-content-center gap-1",4,"ngIf"],["class","text-muted",4,"ngIf"],[1,"badge",3,"ngClass"],[1,"d-flex","align-items-center","justify-content-center","gap-1"],["class","text-nowrap",4,"ngIf"],["title","Edit Cheque No",1,"btn","btn-sm","btn-outline-primary","p-1",3,"click","disabled"],[1,"fa","fa-edit"],[1,"alert","alert-info","animate__animated","animate__fadeIn"],["tabindex","-1","role","dialog",1,"modal","fade","show",3,"ngStyle"],["role","document",1,"modal-dialog","modal
2008-dialog-centered"],[1,"modal-header"],[1,"modal-title"],["type","button",1,"btn-close",3,"click","disabled"],[1,"mb-0","text-danger"],["type","button",1,"btn","btn-danger",3,"click","disabled"],[1,"spinner-border","spinner-border-sm","me-2"],[1,"fa","fa-save","me-1"],[1,"modal-backdrop","fade","show"],["tabindex","-1",1,"modal","fade","show",3,"ngStyle"],[1,"modal-dialog"],["type","button",1,"btn","btn-secondary",3,"click"]],template:function(i,t){i&1&&(r(0,"div",0)(1,"input",1),ee("ngModelChange",function(s){return J(t.filterStaffName,s)||(t.filterStaffName=s),s}),b("ngModelChange",function(){return t.onFilterChange()}),n(),r(2,"div",2),_(3,Ia,2,1,"span",3),r(4,"button",4),b("click",function(){return t.printSelectedForApproval()}),c(5,"i",5),o(6,"Print Selected for Approval "),n(),r(7,"button",6),b("click",function(){return t.deleteSelected()}),_(8,ka,1,0,"span",7)(9,Ta,1,0,"i",8),o(10,"Delete Selected "),n()()(),_(11,Na,4,0,"div",9)(12,Ma,2,1,"div",10)(13,La,37,6,"div",11)(14,Ba,2,0,"div",12)(15,za,23,10,"div",13),r(16,"div",14)(17,"div",15)(18,"div",16)(19,"div",17)(20,"h5",18),o(21,"Edit Cheque No"),n(),r(22,"button",19),b("click",function(){return t.closeEditChequeNoModal()}),n()(),r(23,"div",20)(24,"div",21),c(25,"i",22),o(26," Stage 1 (Amount Estimate Approved) is complete. You can now add or edit the Cheque No to proceed to Stage 2 approval. "),n(),r(27,"div",23)(28,"label",24),o(29,"Cheque No "),r(30,"span",25),o(31,"*"),n()(),r(32,"input",26),ee("ngModelChange",function(s){return J(t.chequeNoInput,s)||(t.chequeNoInput=s),s}),b("keyup.enter",function(){return t.saveChequeNo()}),n(),r(33,"small",27),o(34,"This is required before Stage 2 approval can begin."),n()()(),r(35,"div",28)(36,"button",29),b("click",function(){return t.closeEditChequeNoModal()}),o(37," Cancel "),n(),r(38,"button",30),b("click",function(){return t.saveChequeNo()}),_(39,Ya,1,0,"span",31)(40,Ga,1,0,"i",32),o(41),n()()()()(),_(42,Wa,1,0,"div",33)(43,ja,13,5,"div",34)),i&2&&(d(),X("ngModel",t.filterStaffName),d(2),p("ngIf",t.getSelectedFormsCount()>0),d(),p("disabled",t.getSelectedFormsCount()===0),d(3),p("disabled",t.getSelectedFormsCount()===0||t.deleting),d(),p("ngIf",t.deleting),d(),p("ngIf",!t.deleting),d(2),p("ngIf",t.publishedLoading),d(),p("ngIf",t.publishedError),d(),p("ngIf",!t.publishedLoading&&t.publishedForms.length>0),d(),p("ngIf",!t.publishedLoading&&t.publishedForms.length===0),d(),p("ngIf",t.showDeleteConfirmModal),d(),at("display",t.showEditChequeNoModal?"block":"none"),re("show",t.showEditChequeNoModal),d(16),X("ngModel",t.chequeNoInput),p("disabled",t.editingChequeNo),d(4),p("disabled",t.editingChequeNo),d(2),p("disabled",t.editingChequeNo||!t.chequeNoInput||t.chequeNoInput.trim().length===0),d(),p("ngIf",t.editingChequeNo),d(),p("ngIf",!t.editingChequeNo),d(),A(" ",t.editingChequeNo?"Saving...":"Save Cheque No"," "),d(),p("ngIf",t.showEditChequeNoModal),d(),p("ngIf",t.viewParticularsText))},dependencies:[te,ie,W,mt,j,H,ue,se,Q]})}return l})();var Ha=()=>({exact:!0}),Tt=(()=>{class l{static \u0275fac=function(i){return new(i||l)};static \u0275cmp=q({type:l,selectors:[["app-approved-list-parent-view"]],decls:8,vars:2,consts:[[1,"nav","nav-tabs","mb-2"],["routerLink","supplier","routerLinkActive","active",1,"nav-link",3,"routerLinkActiveOptions"],[1,"fa","fa-building","me-1"],["routerLink","staff","routerLinkActive","active",1,"nav-link"],[1,"fa","fa-user-tie","me-1"]],template:function(i,t){i&1&&(r(0,"nav",0)(1,"a",1),c(2,"i",2),o(3,"Supplier Forms "),n(),r(4,"a",3),c(5,"i",4),o(6,"Staff Expense Forms "),n()(),c(7,"router-outlet")),i&2&&(d(),p("routerLinkActiveOptions",He(1,Ha)))},dependencies:[ce,De,Te],styles:[".nav-tabs[_ngcontent-%COMP%]{border-bottom:2px solid #e9ecef;margin-bottom:1.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{border:none;border-radius:8px 8px 0 0;padding:.75rem 1.5rem;font-weight:600;color:#6c757d;background-color:transparent;transition:all .3s ease;margin-right:.5rem}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]:hover{color:#007bff;background-color:#f8f9fa;border-color:transparent}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{color:#007bff;background-color:#fff;border-color:#007bff #007bff #fff;border-width:2px 2px 0;box-shadow:0 -2px 4px #007bff1a}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:.5rem;font-size:1.1em}@media (max-width: 768px){.nav-tabs[_ngcontent-%COMP%]{flex-direction:column}.nav-tabs[_ngcontent-%COMP%]   .nav-link[_ngcontent-%COMP%]{margin-right:0;margin-bottom:.5rem;border-radius:8px;text-align:center}.nav-tabs[_ngcontent-%COMP%]   .nav-link.active[_ngcontent-%COMP%]{border-width:2px;border-color:#007bff}}"]})}return l})();var Nt=Ye(Ge());var Za=["dateRangePicker"],Fi=l=>({disabled:l});function Qa(l,f){l&1&&(r(0,"span"),c(1,"i",21),o(2,"Print Selected"),n())}function Ka(l,f){l&1&&(r(0,"span"),c(1,"span",22),o(2,"Printing..."),n())}function Xa(l,f){if(l&1&&(r(0,"span",15),o(1),n()),l&2){let e=g(2);d(),A(" Staff: ",e.filterStaffName," ")}}function Ja(l,f){if(l&1&&(r(0,"span",15),o(1),n()),l&2){let e=g(2);d(),A(" Date Range (approved): ",e.getDateRangeDisplay()," ")}}function eo(l,f){if(l&1){let e=I();r(0,"div",1)(1,"div",23)(2,"div",24),c(3,"i",25),r(4,"strong"),o(5,"Active Filters:"),n(),_(6,Xa,2,1,"span",26)(7,Ja,2,1,"span",26),r(8,"button",27),b("click",function(){x(e);let t=g();return S(t.clearFilters())}),c(9,"i",28),o(10,"Clear Filters "),n()()()()}if(l&2){let e=g();d(6),p("ngIf",e.filterStaffName),d(),p("ngIf",e.filterFromDate||e.filterToDate)}}function to(l,f){l&1&&(r(0,"div",29)(1,"div",30)(2,"span",31),o(3,"Loading..."),n()(),r(4,"p",32),o(5,"Loading approved forms..."),n()())}function io(l,f){if(l&1&&(r(0,"div",33),c(1,"i",34),o(2),n()),l&2){let e=g();d(2),A("",e.error,`
2009`)}}function no(l,f){l&1&&(r(0,"div",29),c(1,"i",35),r(2,"p",36),o(3,"No approved forms found."),n()())}function ro(l,f){if(l&1){let e=I();r(0,"tr")(1,"td",47)(2,"input",48),b("change",function(t){let a=x(e).$implicit,s=g(2);return S(s.toggleFormSelection(a,t))}),n()(),r(3,"td"),o(4),n(),r(5,"td")(6,"strong"),o(7),n()(),r(8,"td"),o(9),n(),r(10,"td"),o(11),n(),r(12,"td"),o(13),n(),r(14,"td",49),o(15),L(16,"date"),n(),r(17,"td",43),o(18),L(19,"number"),n(),r(20,"td")(21,"span",50),o(22),n()(),r(23,"td")(24,"span",50),o(25),n()()()}if(l&2){let e=f.$implicit,i=f.index,t=g(2);re("table-primary",t.isFormSelected(e)),d(2),p("checked",t.isFormSelected(e)),d(2),w(i+1),d(3),w(e.nameOfStaff||"N/A"),d(2),w(e.idNo||"N/A"),d(2),w(e.designation||"N/A"),d(2),w(e.dept||"N/A"),d(2),w(e.date?B(16,14,e.date,"dd-MM-yyyy"):"N/A"),d(3),A(" ",pt(19,17,e.total||0)," "),d(3),p("ngClass",t.getStatusBadgeClass(e)),d(),w(t.getStatusDisplay(e)),d(2),p("ngClass",t.getApprovalTypeBadgeClass(e)),d(),A(" ",t.getApprovalTypeDisplay(e)," ")}}function ao(l,f){if(l&1&&(r(0,"span"),o(1),n()),l&2){let e=g(2);d(),A("Showing all ",e.totalCount," approved forms in selected date range")}}function oo(l,f){if(l&1&&(r(0,"span"),o(1),n()),l&2){let e=g(2);d(),dt("Showing ",e.getShowingFrom()," to ",e.getShowingTo()," of ",e.totalCount," approved forms")}}function lo(l,f){if(l&1){let e=I();r(0,"nav")(1,"ul",51)(2,"li",52)(3,"button",53),b("click",function(){x(e);let t=g(2);return S(t.prevPage())}),c(4,"i",54),o(5," Previous "),n()(),r(6,"li",55)(7,"span",56),o(8),n()(),r(9,"li",52)(10,"button",53),b("click",function(){x(e);let t=g(2);return S(t.nextPage())}),o(11," Next "),c(12,"i",57),n()()()()}if(l&2){let e=g(2);d(2),p("ngClass",$(5,Fi,e.isPrevDisabled())),d(),p("disabled",e.isPrevDisabled()),d(5),w(e.pageNumber),d(),p("ngClass",$(7,Fi,e.isNextDisabled())),d(),p("disabled",e.isNextDisabled())}}function so(l,f){if(l&1){let e=I();
2009r(0,"div")(1,"div",37)(2,"table",38)(3,"thead",39)(4,"tr")(5,"th",40)(6,"input",41),b("change",function(t){x(e);let a=g();return S(a.toggleSelectAll(t))}),n()(),r(7,"th",42),o(8,"S.No"),n(),r(9,"th"),o(10,"Staff Name"),n(),r(11,"th"),o(12,"ID No"),n(),r(13,"th"),o(14,"Designation"),n(),r(15,"th"),o(16,"Department"),n(),r(17,"th"),o(18,"Date"),n(),r(19,"th",43),o(20,"Amount"),n(),r(21,"th"),o(22,"Status"),n(),r(23,"th"),o(24,"Approval Type"),n()()(),r(25,"tbody"),_(26,ro,26,19,"tr",44),n()()(),r(27,"div",45)(28,"div",46),_(29,ao,2,1,"span",17)(30,oo,2,3,"span",17),n(),_(31,lo,13,9,"nav",17),n()()}if(l&2){let e=g();d(6),p("checked",e.allSelected)("indeterminate",e.getSelectedFormsCount()>0&&e.getSelectedFormsCount()<e.approvedForms.length),d(20),p("ngForOf",e.approvedForms),d(3),p("ngIf",e.isDateFilterActive()),d(),p("ngIf",!e.isDateFilterActive()),d(),p("ngIf",!e.isDateFilterActive())}}var Ce=Nt.default??Nt,Mt=(()=>{class l{staffExpenseFormService;fileUploadService;toastr;router;bsLocaleService;dateRangePicker;approvedForms=[];totalCount=0;loading=!1;error="";pageNumber=1;pageSize=100;filterStaffName="";filterFromDate="";filterToDate="";bsConfig={ranges:[],dateInputFormat:"DD/MM/YYYY",displayMonths:2};ranges=[{value:[new Date(new Date().setDate(new Date().getDate())),new Date],label:"Today"},{value:[new Date(new Date().setDate(new Date().getDate()-1)),new Date(new Date().setDate(new Date().getDate()-1))],label:"Yesterday"},{value:[new Date(new Date().setDate(new Date().getDate()-7)),new Date],label:"Last 7 Days"},{value:[new Date(new Date().setDate(new Date().getDate()-30)),new Date],label:"Last 30 Days"},{value:[new Date(new Date().setMonth(new Date().getMonth()-1)),new Date],label:"Last Month"}];startDate=new Date;endDate=new Date;fromDate;toDate;dateRangeValue;selectedForms=new Set;allSelected=!1;printSelectedSubmitting=!1;nameFilterTimer=null;signatureLoadingStates={dean:!1,registrar:!1,president:!1};signatureCache=new Map;constructor(e,i,t,a,s){this.staffExpenseFormService=e,this.fileUploadService=i,this.toastr=t,this.router=a,this.bsLocaleService=s}ngOnInit(){Ce.locale("en-GB"),ve("en-gb",xe),this.bsLocaleService.use("en-gb"),this.bsConfig.ranges=this.ranges,this.fetchApprovedForms()}clearSignatureCache(){this.signatureCache.clear(),this.toastr.info("Signature cache cleared. Signatures will be reloaded on next print.","Cache Cleared")}fetchApprovedForms(){this.loading=!0,this.error="";let e=this.router.url.includes("/cheque"),t=!!(this.filterFromDate||this.filterToDate)?0:(this.pageNumber-1)*this.pageSize,a=this.filterFromDate?Ce(this.filterFromDate).startOf("day").valueOf():void 0,s=this.filterToDate?Ce(this.filterToDate).endOf("day").valueOf():void 0;this.staffExpenseFormService.getApprovedRequestForms(t,this.pageSize,{from:a,to:s,chequeOnly:e,nameSearch:this.filterStaffName||void 0}).then(m=>{let u=Array.isArray(m?.data)?m.data:[];this.totalCount=typeof m?.total=="number"?m.total:u.length;let h=[];u.forEach(v=>{let E=v.formData||v.staffExpenseForm;if(!E)return;let y=F=>{let k=v.approvalLevels||[],V=this.getApprovalInfo(k,"PRESIDENT")||this.getApprovalInfo(k,"PRESIDENTADMIN");h.push(N(T({},F),{requestFormId:v._id||v.id,approvalType:v.approvalType,submissionStatus:v.submissionStatus,approvalLevels:k,approvedDate:V?.actionDate||null,createdOn:v.createdOn,modifiedOn:v.modifiedOn}))};Array.isArray(E)?E.forEach(y):y(E)}),this.approvedForms=h,this.selectedForms.clear(),this.updateAllSelectedState()}).catch(()=>{this.error="Failed to load approved Staff Expense forms.",this.toastr.error("Failed to load approved forms.","Error")}).finally(()=>{this.loading=!1})}toggleSelectAll(e){e.target.checked?(this.selectedForms=new Set(this.approvedForms.map(i=>`${i.nameOfStaff}_${i.designation}_${i.date}`)),this.allSelected=!0):(this.selectedForms.clear(),this.allSelected=!1)}toggleFormSelection(e,i){let t=`${e.nameOfStaff}_${e.designation}_${e.date}`;i.target.checked?this.selectedForms.add(t):this.selectedForms.delete(t),this.updateAllSelectedState()}updateAllSelectedState(){let e=this.approvedForms.map(i=>`${i.nameOfStaff}_${i.designation}_${i.date}`);this.allSelected=e.length>0&&e.every(i=>this.selectedForms.has(i))}isFormSelected(e){let i=`${e.nameOfStaff}_${e.designation}_${e.date}`;return this.selectedForms.has(i)}getSelectedFormsCount(){return this.selectedForms.size}printSelectedForms(){return M(this,null,function*(){if(this.selectedForms.size===0){this.toastr.warning("Please select at least one form to print.","No Selection");return}this.printSelectedSubmitting=!0;let e=this.router.url.includes("/cheque");e?this.toastr.info("Preparing cheque payment document...","Generating Print Document"):this.toastr.info("Preparing document and loading signatures...","Generating Print Document");let i=this.approvedForms.filter(u=>this.selectedForms.has(`${u.nameOfStaff}_${u.designation}_${u.date}`)),t=window.open("","_blank");if(!t){this.toastr.error("Please allow popups to print the document.","Error"),this.printSelectedSubmitting=!1;return}let a=e?yield this.generateChequePrintContent(i):yield this.generateSelectedPrintContent(i),s=this.getTodayDateString(),m=e?"Cheque Payment Forms - Staff":"Approved Staff Expense Forms";t.document.write(`
2010      <!DOCTYPE html>
2011      <html>
2012        <head>
2013          <title>${m}</title>
2014          <style>
2015            body {
2016              font-family: Arial, sans-serif;
2017              margin: 0;
2018              padding: 15px;
2019              font-size: 12px;
2020            }
2021            .header { 
2022              text-align: center; 
2023            }
2024            .logo-container {
2025
2026            }
2027            .logo {
2028               max-width: 300px;
2029               height: 120px;
2030               margin: 0 auto;
2031               display: block;
2032               object-fit: contain;
2033             }
2034            .document-title {
2035              font-size: 20px;
2036              font-weight: bold;
2037              text-align: center;
2038              color: #333;
2039            }
2040            table { 
2041              width: 100%; 
2042              border-collapse: collapse; 
2043              margin-top: 20px;
2044              table-layout: fixed;
2045              border: 2px solid #000;
2046            }
2047            th, td {
2048              border: 1px solid #000;
2049              padding: 6px 8px;
2050              text-align: left;
2051              word-break: keep-all;
2052              overflow-wrap: break-word;
2053              white-space: normal;
2054              overflow: hidden;
2055              line-height: 1.3;
2056              hyphens: none;
2057              vertical-align: top;
2058            }
2059            th { 
2060              background-color: #f2f2f2; 
2061              font-weight: bold;
2062              border: 1px solid #000;
2063              font-size: 12px;
2064            }
2065            td {
2066              font-size: 12px;
2067            }
2068            td.text-right,
2069            td.amount {
2070              font-size: 12px;
2071            }
2072            tbody tr td {
2073              border: 1px solid #000;
2074            }
2075            thead tr th {
2076              border: 1px solid #000;
2077            }
2078            /* CHEQUE-PRINT: S.No(1)=6%, Staff(2)=10%, Dept(3)=9%, Designation(4)=9%, ID No(5)=7%, Particulars(6)=27%, Amount(7)=10%, Cheque No(8)=9%, Date(9)=13% [Total=100%] */
2079            /* Column 1: S.No - NO wrapping, contained in cell, no overlap */
2080            table.cheque-print th:nth-child(1),
2081            table.cheque-print td:nth-child(1) { width: 6%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 6px 3px; }
2082            /* Column 2: Staff Name - Allow multi-line wrap */
2083            table.cheque-print th:nth-child(2),
2084            table.cheque-print td:nth-child(2) { width: 10%; word-break: keep-all; overflow-wrap: break-word; }
2085            /* Column 3: Dept - Allow multi-line wrap */
2086            table.cheque-print th:nth-child(3),
2087            table.cheque-print td:nth-child(3) { width: 9%; word-break: keep-all; overflow-wrap: break-word; }
2088            /* Column 4: Designation - Allow multi-line wrap */
2089            table.cheque-print th:nth-child(4),
2090            table.cheque-print td:nth-child(4) { width: 9%; word-break: keep-all; overflow-wrap: break-word; }
2091            /* Column 5: ID No - NO wrapping, contained in cell */
2092            table.cheque-print th:nth-child(5),
2093            table.cheque-print td:nth-child(5) { width: 7%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 6px 3px; }
2094            /* Column 6: Particulars - Allow multi-line wrapping with full text */
2095            table.cheque-print th:nth-child(6),
2096            table.cheque-print td:nth-child(6) { width: 27%; word-break: keep-all; overflow-wrap: break-word; }
2097            table.cheque-print th:nth-child(6) { text-align: center; }
2098            table.cheque-print td:nth-child(6) { text-align: left; }
2099            /* Column 7: Amount - NO wrapping, contained in cell */
2100            table.cheque-print th:nth-child(7),
2101            table.cheque-print td:nth-child(7) { width: 10%; text-align: right; white-space: nowrap; overflow: hidden; padding: 6px 4px; }
2102            /* Column 8: Cheque No - NO wrapping, contained in cell */
2103            table.cheque-print th:nth-child(8),
2104            table.cheque-print td:nth-child(8) { width: 9%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
2105            /* Column 9: Approved Date - NO wrapping, contained in cell */
2106            table.cheque-print th:nth-child(9),
2107            table.cheque-print td:nth-child(9) { width: 13%; text-align: center; white-space: nowrap; overflow: hidden; }
2108            /* APPROVAL-PRINT: Sl.No(1)=4%, Name(2)=8%, ID No(3)=6%, Designation(4)=9%, Dept(5)=7%, Type(6)=9%, Particulars(7)=24%, Date(8)=8%, Venue(9)=7%, Amount(10)=6%, Approved Date(11)=12% [Total=100%] */
2109            /* Column 1: Sl.No - NO wrapping, contained in cell */
2110            table.approval-print th:nth-child(1),
2111            table.approval-print td:nth-child(1) { width: 4%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 6px 3px; }
2112            /* Column 2: Name - Allow multi-line wrap */
2113            table.approval-print th:nth-child(2),
2114            table.approval-print td:nth-child(2) { width: 8%; word-break: keep-all; overflow-wrap: break-word; }
2115            /* Column 3: ID No - NO wrapping, contained in cell */
2116            table.approval-print th:nth-child(3),
2117            table.approval-print td:nth-child(3) { width: 6%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 6px 3px; }
2118            /* Column 4: Designation - Allow multi-line wrap */
2119            table.approval-print th:nth-child(4),
2120            table.approval-print td:nth-child(4) { width: 9%; word-break: keep-all; overflow-wrap: break-word; }
2121            /* Column 5: Dept - Allow multi-line wrap */
2122            table.approval-print th:nth-child(5),
2123            table.approval-print td:nth-child(5) { width: 7%; word-break: keep-all; overflow-wrap: break-word; }
2124            /* Column 6: Type of Claim - Allow multi-line wrap */
2125            table.approval-print th:nth-child(6),
2126            table.approval-print td:nth-child(6) { width: 9%; word-break: keep-all; overflow-wrap: break-word; }
2127            /* Column 7: Particulars - Allow multi-line wrapping with full text */
2128            table.approval-print th:nth-child(7),
2129            table.approval-print td:nth-child(7) { width: 24%; word-break: keep-all; overflow-wrap: break-word; }
2130            table.approval-print th:nth-child(7) { text-align: center; }
2131            table.approval-print td:nth-child(7) { text-align: left; }
2132            /* Column 8: Date - NO wrapping, contained in cell */
2133            table.approval-print th:nth-child(8),
2134            table.approval-print td:nth-child(8) { width: 8%; text-align: center; white-space: nowrap; overflow: hidden; padding: 6px 4px; }
2135            /* Column 9: Venue - Allow multi-line wrap */
2136            table.approval-print th:nth-child(9),
2137            table.approval-print td:nth-child(9) { width: 7%; text-align: center; word-break: keep-all; overflow-wrap: break-word; }
2138            /* Column 10: Amount - NO wrapping, contained in cell */
2139            table.approval-print th:nth-child(10),
2140            table.approval-print td:nth-child(10) { width: 6%; text-align: right; white-space: nowrap; overflow: hidden; padding: 8px 3px; }
2141            /* Column 11: Approved Date - NO wrapping, contained in cell */
2142            table.approval-print th:nth-child(11),
2143            table.approval-print td:nth-child(11) { width: 12%; text-align: center; white-space: nowrap; overflow: hidden; }
2144            .text-center { text-align: center; }
2145            .text-right { text-align: right !important; }
2146            .amount { font-weight: bold; }
2147            .total-row {
2148              background-color: #f8f9fa;
2149              font-weight: bold;
2150            }
2151            .total-row td {
2152              font-size: 12px;
2153              word-break: keep-all;
2154              hyphens: none;
2155            }
2156            /* Ensure total row cells respect text-right class */
2157            .total-row td.text-right {
2158              text-align: right !important;
2159            }
2160            .amount-in-words {
2161              margin-top: 20px;
2162              padding: 10px;
2163              background-color: #f8f9fa;
2164              border: 1px solid #ddd;
2165              text-align: center;
2166              font-weight: bold;
2167              font-size: 12px;
2168              word-break: keep-all;
2169              hyphens: none;
2170              overflow-wrap: break-word;
2171            }
2172            .signature-section {
2173              margin-top: 40px;
2174              display: flex;
2175              justify-content: space-between;
2176            }
2177            .signature-box {
2178              text-align: center;
2179              width: 200px;
2180              border: none;
2181              padding: 10px;
2182              margin: 5px;
2183            }
2184            .signature-title {
2185              font-weight: bold;
2186              margin-bottom: 10px;
2187              font-size: 12px;
2188              border-bottom: 1px solid #ddd;
2189              padding-bottom: 5px;
2190            }
2191            .signature-image {
2192              margin: 0;
2193              padding: 0;
2194              display: flex;
2195              align-items: center;
2196              justify-content: center;
2197              width: 180px;
2198              height: 80px;
2199            }
2200            .e-signature {
2201              width: 180px;
2202              height: 80px;
2203              object-fit: cover;
2204              border: none;
2205              background: transparent;
2206              padding: 0;
2207              margin: 0;
2208            }
2209            .signature-placeholder {
2210              margin: 10px 0;
2211              min-height: 90px;
2212              display: flex;
2213              align-items: center;
2214              justify-content: center;
2215            }
2216            .signature-line {
2217              width: 150px;
2218              height: 1px;
2219              border-bottom: 1px solid #333;
2220              margin: 0 auto;
2221            }
2222            .approval-status {
2223              margin-top: 8px;
2224              font-size: 10px;
2225            }
2226            .status-label {
2227              font-weight: bold;
2228              color: #333;
2229            }
2230                         .status-value.approved {
2231               color: #28a745;
2232               font-weight: bold;
2233             }
2234             .status-value.pending {
2235               color: #ffc107;
2236               font-weight: bold;
2237             }
2238             .approval-time {
2239               margin-top: 5px;
2240               font-size: 10px;
2241             }
2242             .time-label {
2243               font-weight: bold;
2244               color: #333;
2245             }
2246             .time-value {
2247               color: #666;
2248             }
2249             .approver-name {
2250               margin-top: 5px;
2251               font-size: 10px;
2252             }
2253             .name-label {
2254               font-weight: bold;
2255               color: #333;
2256             }
2257             .name-value {
2258               color: #666;
2259             }
2260            .print-button {
2261              position: fixed;
2262              top: 20px;
2263              right: 20px;
2264              background-color: #007bff;
2265              color: white;
2266              border: none;
2267              padding: 10px 20px;
2268              border-radius: 5
2268px;
2269              cursor: pointer;
2270              font-size: 14px;
2271              font-weight: bold;
2272              box-shadow: 0 2px 5px rgba(0,0,0,0.2);
2273              z-index: 1000;
2274            }
2275            .print-button:hover {
2276              background-color: #0056b3;
2277            }
2278            .generated-on {
2279              position: fixed;
2280              top: 60px;
2281              right: 20px;
2282              color: #555;
2283              font-size: 12px;
2284              background: rgba(255,255,255,0.9);
2285              padding: 4px 8px;
2286              border: 1px solid #ddd;
2287              border-radius: 4px;
2288              z-index: 999;
2289            }
2290            /* Page number styling */
2291            .page-number {
2292              position: fixed;
2293              top: 10px;
2294              right: 20px;
2295              font-size: 12px;
2296              font-weight: bold;
2297              color: #333;
2298              z-index: 1000;
2299              background: rgba(255, 255, 255, 0.9);
2300              padding: 4px 8px;
2301              border-radius: 4px;
2302            }
2303            @media print {
2304              body {
2305                margin: 0;
2306                padding: 10mm;
2307                font-size: 13px;
2308              }
2309
2310              .header {
2311                margin-bottom: 5mm;
2312              }
2313
2314              .logo {
2315                max-width: 250px;
2316                height: 90px;
2317              }
2318
2319              .document-title {
2320                font-size: 18px;
2321                margin-bottom: 10px;
2322              }
2323
2324              .no-print { display: none; }
2325              .print-button { display: none; }
2326              .generated-on { display: none; }
2327              .page-number { display: none; }
2328
2329              table {
2330                width: 100% !important;
2331                table-layout: fixed !important;
2332                page-break-after: auto;
2333                margin-top: 10px !important;
2334              }
2335
2336              th {
2337                font-size: 13px !important;
2338                padding: 5px 6px !important;
2339              }
2340
2341              td {
2342                font-size: 13px !important;
2343                padding: 5px 6px !important;
2344              }
2345
2346              tbody tr {
2347                page-break-inside: avoid;
2348              }
2349
2350              th, td {
2351                word-break: keep-all !important;
2352                overflow-wrap: break-word !important;
2353                white-space: normal !important;
2354                overflow: visible !important;
2355                text-overflow: clip !important;
2356                max-width: 100% !important;
2357                line-height: 1.2 !important;
2358                hyphens: none !important;
2359                vertical-align: top !important;
2360              }
2361
2362              /* Cheque-print particulars: Allow wrapping */
2363              table.cheque-print th:nth-child(6),
2364              table.cheque-print td:nth-child(6) {
2365                width: 28% !important;
2366                word-break: keep-all !important;
2367                overflow-wrap: break-word !important;
2368                hyphens: none !important;
2369                white-space: normal !important;
2370              }
2371
2372              /* Cheque-print: Non-wrapping columns - CONTAINED IN CELLS */
2373              table.cheque-print th:nth-child(1),
2374              table.cheque-print td:nth-child(1),
2375              table.cheque-print th:nth-child(5),
2376              table.cheque-print td:nth-child(5),
2377              table.cheque-print th:nth-child(7),
2378              table.cheque-print td:nth-child(7),
2379              table.cheque-print th:nth-child(8),
2380              table.cheque-print td:nth-child(8),
2381              table.cheque-print th:nth-child(9),
2382              table.cheque-print td:nth-child(9) {
2383                white-space: nowrap !important;
2384                overflow: hidden !important;
2385              }
2386
2387              /* Cheque-print updated widths */
2388              table.cheque-print th:nth-child(1),
2389              table.cheque-print td:nth-child(1) { width: 6% !important; }
2390              table.cheque-print th:nth-child(5),
2391              table.cheque-print td:nth-child(5) { width: 7% !important; }
2392              table.cheque-print th:nth-child(6),
2393              table.cheque-print td:nth-child(6) { width: 27% !important; }
2394              table.cheque-print th:nth-child(7),
2395              table.cheque-print td:nth-child(7) { width: 10% !important; }
2396              table.cheque-print th:nth-child(8),
2397              table.cheque-print td:nth-child(8) { width: 9% !important; }
2398              table.cheque-print th:nth-child(9),
2399              table.cheque-print td:nth-child(9) { width: 13% !important; }
2400
2401              /* Approval-print particulars: Allow wrapping */
2402              table.approval-print th:nth-child(7),
2403              table.approval-print td:nth-child(7) {
2404                width: 24% !important;
2405                word-break: keep-all !important;
2406                overflow-wrap: break-word !important;
2407                hyphens: none !important;
2408                white-space: normal !important;
2409              }
2410
2411              /* Approval-print: Non-wrapping columns - CONTAINED IN CELLS */
2412              table.approval-print th:nth-child(1),
2413              table.approval-print td:nth-child(1),
2414              table.approval-print th:nth-child(3),
2415              table.approval-print td:nth-child(3),
2416              table.approval-print th:nth-child(8),
2417              table.approval-print td:nth-child(8),
2418              table.approval-print th:nth-child(10),
2419              table.approval-print td:nth-child(10),
2420              table.approval-print th:nth-child(11),
2421              table.approval-print td:nth-child(11) {
2422                white-space: nowrap !important;
2423                overflow: hidden !important;
2424              }
2425
2426              /* Approval-print updated widths */
2427              table.approval-print th:nth-child(1),
2428              table.approval-print td:nth-child(1) { width: 4% !important; }
2429              table.approval-print th:nth-child(3),
2430              table.approval-print td:nth-child(3) { width: 6% !important; }
2431              table.approval-print th:nth-child(10),
2432              table.approval-print td:nth-child(10) { width: 6% !important; }
2433              table.approval-print th:nth-child(11),
2434              table.approval-print td:nth-child(11) { width: 12% !important; }
2435
2436              .amount-in-words {
2437                font-size: 13px !important;
2438                margin-top: 10px !important;
2439                padding: 8px !important;
2440              }
2441
2442              .total-row td {
2443                font-size: 13px !important;
2444              }
2445
2446              .signature-section {
2447                margin-top: 30px;
2448              }
2449
2450              .signature-box {
2451                width: 150px;
2452              }
2453
2454              .signature-image {
2455                width: 140px;
2456                height: 60px;
2457              }
2458
2459              .e-signature {
2460                width: 140px;
2461                height: 60px;
2462              }
2463
2464              .signature-title {
2465                font-size: 11px;
2466              }
2467
2468              @page {
2469                size: landscape;
2470                margin: 10mm;
2471                @top-right {
2472                  content: counter(page) " of " counter(pages);
2473                  font-size: 12px;
2474                  font-weight: bold;
2475                  color: #000;
2476                  margin-top: 5mm;
2477                  margin-right: 10mm;
2478                }
2479              }
2480            }
2481          </style>
2482        </head>
2483        <body>
2484          <button class="print-button no-print" onclick="window.print()">\u{1F5A8}\uFE0F Print Document</button>
2485          <div class="page-number no-print">Page 1</div>
2486          ${a}
2487        </body>
2488      </html>
2489    `),t.document.close(),t.focus(),this.printSelectedSubmitting=!1})}getApprovalInfo(e,i){if(!e||e.length===0)return{status:"PENDING",actionDate:"",approvedByName:i,remarks:"",eSignature:null};let t=i.toUpperCase().trim(),a=e.find(s=>
2489{if(!s)return!1;let m=(s.role||"").toString().toUpperCase().trim(),u=(s.roles||"").toString().toUpperCase().trim(),h=(s.label||"").toString().toUpperCase().trim();return m===t||u===t||h===t||m.includes(t)||t.includes(m)||t.includes("PRESIDENT")&&(m.includes("PRESIDENT")||h.includes("PRESIDENT"))||t.includes("DEAN")&&(m.includes("DEAN")||h.includes("DEAN"))||t.includes("REGISTRAR")&&(m.includes("REGISTRAR")||h.includes("REGISTRAR"))});return a?{status:a.status||"APPROVED",actionDate:a.actionDate||a.approvedDate||a.date||"",approvedByName:a.approvedByName||a.name||a.approverName||i,remarks:a.remarks||"",eSignature:a.eSignature||null}:{status:"PENDING",actionDate:"",approvedByName:i,remarks:"",eSignature:null}}getSignatureHtml(e,i){return M(this,null,function*(){if(e&&e.status==="APPROVED"&&e.eSignature){let t=null;if(typeof e.eSignature=="string"?t=e.eSignature:e.eSignature.url?t=e.eSignature.url:e.eSignature.data?t=e.eSignature.data:e.eSignature.image?t=e.eSignature.image:e.eSignature.src?t=e.eSignature.src:e.eSignature.versionId&&e.eSignature.fileKey&&(t=yield this.constructSignatureUrl(e.eSignature)),t)return`<div class="signature-image">
2490          <img src="${t}" alt="${i}" class="e-signature">
2491        </div>`}return`<div class="signature-placeholder">
2492      <div class="signature-line"></div>
2493    </div>`})}constructSignatureUrl(e){return M(this,null,function*(){if(!e.versionId||!e.fileKey)return null;try{let i=yield this.fileUploadService.getPreSignedUrl(e.versionId,e.fileKey);return i&&i.startsWith("http")?i:null}catch(i){return console.error("Error getting pre-signed URL:",i),null}})}formatDate(e){if(!e)return"N/A";try{return new Date(e).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}catch{return e}}getTodayDateString(){let e=new Date,i=String(e.getDate()).padStart(2,"0"),t=String(e.getMonth()+1).padStart(2,"0"),a=e.getFullYear();return`${i}-${t}-${a}`}generateChequePrintContent(e){return M(this,null,function*(){let i=new Q("en-US"),t=0,a="";e.forEach((v,E)=>{let y=v.total||0;t+=y;let F=v.idNo||"N/A",k=this.getApprovalInfo(v.approvalLevels||[],"PRESIDENT")||this.getApprovalInfo(v.approvalLevels||[],"PRESIDENTADMIN"),V=v.approvedDate||k?.actionDate,Y=V?i.transform(V,"dd/MM/yyyy"):"N/A";a+=`
2494        <tr>
2495          <td class="text-center">${E+1}</td>
2496          <td>${v.nameOfStaff||"N/A"}</td>
2497          <td>${v.dept||"N/A"}</td>
2498          <td>${v.designation||"N/A"}</td>
2499          <td class="text-center">${F}</td>
2500          <td>${v.particulars||"N/A"}</td>
2501          <td class="text-right amount">${y}</td>
2502          <td class="text-center">${v.chequeNo||"N/A"}</td>
2503          <td style="white-space: nowrap;">${Y}</td>
2504        </tr>
2505      `});let s=this.numberToWords(t),m=e[0],u=m?.approvalLevels||[],h;if(u.length===0){let v=this.findAlternativeApprovalData(m);v.length>0?h=yield this.createIndividualApproverSignatures(v):h=yield this.createIndividualApproverSignatures([])}else h=yield this.createIndividualApproverSignatures(u);return`
2506      <div class="header">
2507        <div class="logo-container">
2508          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
2509        </div>
2510      </div>
2511      
2512      <div class="document-title">
2513        CHEQUE PAYMENT
2514      </div>
2515      
2516      <table class="cheque-print">
2517        <thead>
2518          <tr>
2519            <th class="text-center">S.No.</th>
2520            <th class="text-center">Staff Name</th>
2521            <th class="text-center">Dept</th>
2522            <th class="text-center">Designation</th>
2523            <th class="text-center">ID<br>No</th>
2524            <th class="text-center">Particulars</th>
2525            <th class="text-right">Cheque<br>Amount</th>
2526            <th class="text-center">Cheque<br>No</th>
2527            <th class="text-center">Approved<br>Date</th>
2528          </tr>
2529        </thead>
2530        <tbody>
2531          ${a}
2532          <tr class="total-row">
2533            <td colspan="5" class="text-center"><strong>Total \u20B9</strong></td>
2534            <td></td>
2535            <td class="text-right" style="text-align: right !important;"><strong>\u20B9${t}</strong></td>
2536            <td></td>
2537            <td></td>
2538          </tr>
2539        </tbody>
2540      </table>
2541      
2542      <div class="amount-in-words">
2543        (Rupees ${s} only)
2544      </div>
2545      
2546      <div class="signature-section">
2547        <div class="signature-box">
2548          ${this.getSignatureHtmlFromUrl(h.dean,"Dean Signature")}
2549          <div class="signature-title">DEAN-STUDENT AFFAIRS</div>
2550        </div>
2551        <div class="signature-box">
2552          ${this.getSignatureHtmlFromUrl(h.registrar,"Registrar Signature")}
2553          <div class="signature-title">REGISTRAR</div>
2554        </div>
2555        <div class="signature-box">
2556          ${this.getSignatureHtmlFromUrl(h.president,"President Signature")}
2557          <div class="signature-title">PRESIDENT</div>
2558        </div>
2559      </div>
2560    `})}generateSelectedPrintContent(e){return M(this,null,function*(){let i=new Date().toLocaleDateString(),t=new Date().toLocaleTimeString(),a=0,s="";e.forEach((k,V)=>{let Y=k.total||0,O=new Q("en-US"),C=k.date?O.transform(k.date,"dd-MM-yyyy"):"N/A";a+=Y;let ae=this.getApprovalInfo(k.approvalLevels||[],"PRESIDENT")||this.getApprovalInfo(k.approvalLevels||[],"PRESIDENTADMIN"),ke=k.approvedDate||ae?.actionDate,Ae=ke?O.transform(ke,"dd-MM-yyyy"):"N/A",et=k.idNo||"N/A";s+=`
2561        <tr>
2562          <td class="text-center">${V+1}</td>
2563          <td>${k.nameOfStaff||"N/A"}</td>
2564          <td class="text-center">${et}</td>
2565          <td>${k.designation||"N/A"}</td>
2566          <td>${k.dept||"N/A"}</td>
2567          <td>${k.typeOfClaim||"N/A"}</td>
2568          <td>${k.particulars||"N/A"}</td>
2569          <td style="white-space: nowrap;">${C}</td>
2570          <td>${k.venue||"N/A"}</td>
2571          <td class="text-right amount">${Y}</td>
2572          <td style="white-space: nowrap;">${Ae}</td>
2573        </tr>
2574      `});let m=this.numberToWords(a),u=e[0],h=u?.approvalLevels||[];if(h.length===0){let k=this.findAlternativeApprovalData(u);if(k.length>0){let V=yield this.createIndividualApproverSignatures(k);return this.generatePrintContentWithSignatures(s,a,m,V)}else{let V=yield this.createIndividualApproverSignatures([]);return this.generatePrintContentWithSignatures(s,a,m,V)}}let v=yield this.createIndividualApproverSignatures(h),E=this.getApprovalInfo(h,"DEAN")||this.getApprovalInfo(h,"DEANADMIN"),y=this.getApprovalInfo(h,"REGISTRAR")||this.getApprovalInfo(h,"REGISTRARADMIN"),F=this.getApprovalInfo(h,"PRESIDENT")||this.getApprovalInfo(h,"PRESIDENTADMIN");return`
2575      <div class="header">
2576        <div class="logo-container">
2577          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
2578        </div>
2579      </div>
2580      
2581      <div class="document-title">
2582        Submitted to the Approval of the President
2583      </div>
2584      
2585      <table class="approval-print">
2586        <thead>
2587          <tr>
2588            <th class="text-center">S.No.</th>
2589            <th class="text-center">Staff Name</th>
2590            <th class="text-center">ID<br>No</th>
2591            <th class="text-center">Designation</th>
2592            <th class="text-center">Dept</th>
2593            <th class="text-center">Type Of Claim</th>
2594            <th class="text-center">Particulars</th>
2595            <th class="text-center">Date</th>
2596            <th class="text-center">Venue</th>
2597            <th class="text-center">Total<br>Amount</th>
2598            <th class="text-center">Approved<br>Date</th>
2599          </tr>
2600        </thead>
2601        <tbody>
2602          ${s}
2603          <tr class="total-row">
2604            <td colspan="9" class="text-center"><strong>Total \u20B9</strong></td>
2605            <td class="text-right" style="text-align: right !important;"><strong>${a}</strong></td>
2606            <td></td>
2607          </tr>
2608        </tbody>
2609      </table>
2610      
2611      <div class="amount-in-words">
2612        (Rupees ${m} only)
2613      </div>
2614      
2615      <div class="signature-section">
2616        <div class="signature-box">
2617          ${this.getSignatureHtmlFromUrl(v.dean,"Dean Signature")}
2618          <div class="signature-title">DEAN-STUDENT AFFAIRS</div>
2619        </div>
2620        <div class="signature-box">
2621          ${this.getSignatureHtmlFromUrl(v.registrar,"Registrar Signature")}
2622          <div class="signature-title">REGISTRAR</div>
2623        </div>
2624        <div class="signature-box">
2625          ${this.getSignatureHtmlFromUrl(v.president,"President Signature")}
2626          <div class="signature-title">PRESIDENT</div>
2627        </div>
2628      </div>
2629    `})}numberToWords(e){let i=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"],t=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"],a=["Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"];if(e===0)return"Zero";let s=u=>u===0?"":u<10?i[u]:u<20?a[u-10]:u<100?t[Math.floor(u/10)]+(u%10!==0?" "+i[u%10]:""):u<1e3?i[Math.floor(u/100)]+" Hundred"+(u%100!==0?" and "+s(u%100):""):"";return(u=>{if(u===0)return"Zero";let h=Math.floor(u/1e7),v=Math.floor(u%1e7/1e5),E=Math.floor(u%1e5/1e3),y=u%1e3,F="";return h>0&&(F+=s(h)+" Crore "),v>0&&(F+=s(v)+" Lakh "),E>0&&(F+=s(E)+" Thousand "),y>0&&(F+=s(y)),F.trim()})(Math.floor(e))}onFilterChange(){this.nameFilterTimer&&clearTimeout(this.nameFilterTimer),this.nameFilterTimer=setTimeout(()=>{this.pageNumber=1,this.fetchApprovedForms()},400)}clearFilters(){this.filterStaffName="",this.filterFromDate="",this.filterToDate="",this.dateRangeValue=null,this.dateRangePicker&&(this.dateRangePicker.bsValue=null),this.pageNumber=1,this.fetchApprovedForms()}getDateRangeDisplay(){if(this.filterFromDate&&this.filterToDate){let e=Ce(this.filterFromDate).format("DD/MM/YYYY"),i=Ce(this.filterToDate).format("DD/MM/YYYY");return`${e} - ${i}`}else{if(this.filterFromDate)return`From ${Ce(this.filterFromDate).format("DD/MM/YYYY")}`;if(this.filterToDate)return`Until ${Ce(this.filterToDate).format("DD/MM/YYYY")}`}return""}onDateRangeChange(e){e&&e.length===2?(this.dateRangeValue=e,this.startDate=e[0],this.endDate=e[1],this.fromDate=Ce(e[0]).format("DD/MM/YYYY"),this.toDate=Ce(e[1]).format("DD/MM/YYYY"),this.filterFromDate=Ce(e[0]).format("YYYY-MM-DD"),this.filterToDate=Ce(e[1]).format("YYYY-MM-DD")):(this.filterFromDate="",this.filterToDate=""),this.pageNumber=1,this.fetchApprovedForms()}isDateFilterActive(){return!!(this.filterFromDate||this.filterToDate)}getShowingFrom(){return this.totalCount>0?(this.pageNumber-1)*this.pageSize+1:0}getShowingTo(){return Math.min(this.pageNumber*this.pageSize,this.totalCount)}nextPage(){this.isNextDisabled()||(this.pageNumber++,this.fetchApprovedForms())}prevPage(){this.pageNumber>1&&(this.pageNumber--,this.fetchApprovedForms())}isPrevDisabled(){return this.pageNumber<=1}isNextDisabled(){return this.isDateFilterActive()||this.pageNumber*this.pageSize>=this.totalCount}getStatusDisplay(e){let i=e.submissionStatus||e.status;if(!i)return e.approvalType==="PRE_APPROVED"?"Pre-Approved":"Approved";switch(i.toUpperCase()){case"PENDING":return"Pending";case"APPROVED":return"Approved";case"REJECTED":return"Rejected";case"WAITING":return"Waiting";default:return i}}getStatusBadgeClass(e){let i=e.submissionStatus||e.status;if(!i)return e.approvalType==="PRE_APPROVED"?"bg-warning":"bg-success";switch(i.toUpperCase()){case"PENDING":return"bg-warning";case"APPROVED":return"bg-success";case"REJECTED":return"bg-danger";case"WAITING":return"bg-info";default:return"bg-secondary"}}getApprovalTypeDisplay(e){return e.approvalType==="PRE_APPROVED"?"PRE_APPROVED":e.approvalType==="WITHOUT_CHEQUE"?"WITHOUT_CHEQUE":e.approvalType==="NONE"?"NONE":"N/A"}getApprovalTypeBadgeClass(e){return e.approvalType==="PRE_APPROVED"?"bg-warning":e.approvalType==="WITHOUT_CHEQUE"?"bg-secondary":e.approvalType==="NONE"?"bg-info":"bg-secondary"}findAlternativeApprovalData(e){let i=[e.approvalLevels,e.approvals,e.approvalData,e.approval,e.signatures,e.signatureData,e.eSignatures,e.approvalHistory,e.workflowData];for(let a of i)if(a&&Array.isArray(a)&&a.length>0)return a;let t=[e.requestForm?.approvalLevels,e.parentForm?.approvalLevels,e.metadata?.approvalLevels,e.formData?.approvalLevels];for(let a of t)if(a&&Array.isArray(a)&&a.length>0)return a;return[]}generatePrintContentWithSignatures(e,i,t,a){return`
2630      <div class="header">
2631        <div class="logo-container">
2632          <img src="https://ims.drmgrdu.ac.in/client/assets/images/mgrLogo.png" alt="MGR Logo" class="logo">
2633        </div>
2634      </div>
2635      
2636      <div class="document-title">
2637        S.B.A/C.No.304777555990 - RBL Bank
2638      </div>
2639      
2640      <table class="approval-print">
2641        <thead>
2642          <tr>
2643            <th class="text-center">S.No.</th>
2644            <th class="text-center">Name of the Staff</th>
2645            <th class="text-center">ID<br>No</th>
2646            <th class="text-center">Designation</th>
2647            <th class="text-center">Dept</th>
2648            <th class="text-center">Type Of Claim</th>
2649            <th class="text-center">Particulars</th>
2650            <th class="text-center">Date</th>
2651            <th class="text-center">Venue</th>
2652            <th class="text-center">Total<br>Amount \u20B9</th>
2653            <th class="text-center">Approved<br>Date</th>
2654          </tr>
2655        </thead>
2656        <tbody>
2657          ${e}
2658          <tr class="total-row">
2659            <td colspan="9" class="text-center"><strong>Total \u20B9</strong></td>
2660            <td class="text-right" style="text-align: right !important;"><strong>
2660\u20B9${i.toLocaleString()}</strong></td>
2661            <td></td>
2662          </tr>
2663        </tbody>
2664      </table>
2665      
2666      <div class="amount-in-words">
2667        (Rupees ${t} only)
2668      </div>
2669      
2670      <div class="signature-section">
2671        <div class="signature-box">
2672          ${this.getSignatureHtmlFromUrl(a.dean,"Dean Signature")}
2673          <div class="signature-title">DEAN-STUDENT AFFAIRS</div>
2674        </div>
2675        <div class="signature-box">
2676          ${this.getSignatureHtmlFromUrl(a.registrar,"Registrar Signature")}
2677          <div class="signature-title">REGISTRAR</div>
2678        </div>
2679        <div class="signature-box">
2680          ${this.getSignatureHtmlFromUrl(a.president,"President Signature")}
2681          <div class="signature-title">PRESIDENT</div>
2682        </div>
2683      </div>
2684    `}createIndividualApproverSignatures(e){return M(this,null,function*(){let i=this.extractApproverSignatureData(e,"DEAN")||this.extractApproverSignatureData(e,"DEANADMIN"),t=this.extractApproverSignatureData(e,"REGISTRAR")||this.extractApproverSignatureData(e,"REGISTRARADMIN"),a=this.extractApproverSignatureData(e,"PRESIDENT")||this.extractApproverSignatureData(e,"PRESIDENTADMIN");try{let[s,m,u]=yield Promise.all([this.makeIndividualApiCallWithDbData(i,"DEAN"),this.makeIndividualApiCallWithDbData(t,"REGISTRAR"),this.makeIndividualApiCallWithDbData(a,"PRESIDENT")]);return{dean:s,registrar:m,president:u}}catch{return{dean:null,registrar:null,president:null}}})}extractApproverSignatureData(e,i){if(!e||e.length===0)return null;let t=i.toUpperCase().trim(),a=e.find(s=>{if(!s)return!1;let m=(s.role||"").toString().toUpperCase().trim(),u=(s.roles||"").toString().toUpperCase().trim(),h=(s.label||"").toString().toUpperCase().trim();return m===t||u===t||h===t||m.includes(t)||t.includes(m)||t.includes("PRESIDENT")&&(m.includes("PRESIDENT")||h.includes("PRESIDENT"))||t.includes("DEAN")&&(m.includes("DEAN")||h.includes("DEAN"))||t.includes("REGISTRAR")&&(m.includes("REGISTRAR")||h.includes("REGISTRAR"))});if(a?.eSignature){let s=a.eSignature,m=s.finalApprovalSignature;if(m?.url||m?.versionId&&m?.fileKey)return m;let u=s.preApprovedSignature;if(u?.url||u?.versionId&&u?.fileKey)return u;if(s.url||s.fileKey&&s.versionId)return s}return null}makeIndividualApiCallWithDbData(e,i){return M(this,null,function*(){if(!e)return console.log(`\u274C ${i}: No signature data provided`),null;try{if(typeof e=="string")return this.normalizePreSignedUrl(e);if(e.versionId&&e.fileKey){console.log(`\u{1F310} ${i}: Making API call for pre-signed URL with versionId: ${e.versionId}, fileKey: ${e.fileKey}`);let t=this.normalizePreSignedUrl(yield this.fileUploadService.getPreSignedUrl(e.versionId,e.fileKey));if(t)return console.log(`\u2705 ${i}: Got pre-signed URL successfully`),t}if(e.url){let t=this.normalizePreSignedUrl(e.url);if(t)return console.log(`\u2705 ${i}: Using signatureData.url`),t}return console.log(`\u274C ${i}: Missing versionId or fileKey in signature data`),null}catch(t){return console.error(`\u274C ${i}: Error getting signature URL:`,t),null}})}normalizePreSignedUrl(e){if(e==null)return null;let i=String(e).trim().replace(/^"|"$/g,"");return i.startsWith("http")?i:null}getSignatureHtmlFromUrl(e,i){let t=this.normalizePreSignedUrl(e);return t?`<div class="signature-image">
2685        <img src="${t.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}" alt="${i}" class="e-signature">
2686      </div>`:`<div class="signature-placeholder">
2687      <div class="signature-line"></div>
2688    </div>`}static \u0275fac=function(i){return new(i||l)(D(Ue),D(qe),D(K),D(ne),D(Se))};static \u0275cmp=q({type:l,selectors:[["app-staff-expense-approved-list"]],viewQuery:function(i,t){if(i&1&&Ee(Za,5),i&2){let a;ye(a=Fe())&&(t.dateRangePicker=a.first)}},decls:27,vars:12,consts:[["dateRangePicker",""],[1,"row","mb-2","no-print"],[1,"col-md-6"],[1,"d-flex","gap-2"],[1,"input-group"],[1,"input-group-text"],[1,"fa","fa-calendar"],["type","text","placeholder","Filter by approval date range","bsDaterangepicker","",1,"form-control",3,"bsValueChange","bsConfig","bsValue"],["title","Clear all filters",1,"btn","btn-outline-secondary",3,"click"],[1,"fa","fa-times"],[1,"fa","fa-search"],["type","text","placeholder","Filter by staff name...",1,"form-control",3,"ngModelChange","input","ngModel"],[1,"col-md-6","d-flex","justify-content-end","align-items-center"],[1,"d-flex","flex-wrap","gap-2","align-items-center","bulk-actions"],[1,"d-flex","align-items-center","me-3"],[1,"badge","bg-primary","me-2"],[1,"btn","btn-success","btn-sm",3,"click","disabled"],[4,"ngIf"],["class","row mb-2 no-print",4,"ngIf"],["class","text-center py-2",4,"ngIf"],["class","alert alert-danger",4,"ngIf"],[1,"fa","fa-print","me-1"],[1,"spinner-border","spinner-border-sm","me-1"],[1,"col-12"],[1,"alert","alert-info","py-1","mb-0"],[1,"fa","fa-filter","me-2"],["class","badge bg-primary me-2",4,"ngIf"],[1,"btn","btn-sm","btn-outline-primary","ms-2",3,"click"],[1,"fa","fa-times","me-1"],[1,"text-center","py-2"],["role","status",1,"spinner-border","text-primary"],[1,"visually-hidden"],[1,"mt-2"],[1,"alert","alert-danger"],[1,"fa","fa-exclamation-triangle","me-2"],[1,"fa","fa-inbox","text-muted",2,"font-size","3rem"],[1,"text-muted","mt-2"],[1,"table-responsive"],[1,"table","table-striped","table-hover"],[1,"table-dark"],[1,"text-center",2,"width","50px"],["type","checkbox",1,"form-check-input",3,"change","checked","indeterminate"],[2,"width","50px"],[1,"text-end"],[3,"table-primary",4,"ngFor","ngForOf"],[1,"d-flex","justify-content-between","align-items-center","mt-2","no-print"],[1,"text-muted"],[1,"text-center"],["type","checkbox",1,"form-check-input",3,"change","checked"],[2,"white-space","nowrap"],[1,"badge",3,"ngClass"],[1,"pagination","pagination-sm","mb-0"],[1,"page-item",3,"ngClass"],[1,"page-link",3,"click","disabled"],[1,"fa","fa-chevron-left"],[1,"page-item"],[1,"page-link"],[1,"fa","fa-chevron-right"]],template:function(i,t){if(i&1){let a=I();r(0,"div",1)(1,"div",2)(2,"div",3)(3,"div",4)(4,"span",5),c(5,"i",6),n(),r(6,"input",7,0),ee("bsValueChange",function(m){return x(a),J(t.dateRangeValue,m)||(t.dateRangeValue=m),S(m)}),b("bsValueChange",function(m){return x(a),S(t.onDateRangeChange(m))}),n()(),r(8,"button",8),b("click",function(){return x(a),S(t.clearFilters())}),c(9,"i",9),n(),r(10,"div",4)(11,"span",5),c(12,"i",10),n(),r(13,"input",11),ee("ngModelChange",function(m){return x(a),J(t.filterStaffName,m)||(t.filterStaffName=m),S(m)}),b("input",function(){return x(a),S(t.onFilterChange())}),n()()()(),r(14,"div",12)(15,"div",13)(16,"div",14)(17,"span",15),o(18),n()(),r(19,"button",16),b("click",function(){return x(a),S(t.printSelectedForms())}),_(20,Qa,3,0,"span",17)(21,Ka,3,0,"span",17),n()()()(),_(22,eo,11,2,"div",18)(23,to,6,0,"div",19)(24,io,3,1,"div",20)(25,no,4,0,"div",19)(26,so,32,6,"div",17)}i&2&&(d(6),p("bsConfig",t.bsConfig),X("bsValue",t.dateRangeValue),d(7),X("ngModel",t.filterStaffName),d(5),A("",t.getSelectedFormsCount()," selected"),d(),p("disabled",t.getSelectedFormsCount()===0||t.printSelectedSubmitting),d(),p("ngIf",!t.printSelectedSubmitting),d(),p("ngIf",t.printSelectedSubmitting),d(),p("ngIf",(t.filterStaffName||t.filterFromDate||t.filterToDate)&&!t.loading),d(),p("ngIf",t.loading),d(),p("ngIf",t.error&&!t.loading),d(),p("ngIf",!t.loading&&!t.error&&t.approvedForms.length===0),d(),p("ngIf",!t.loading&&!t.error&&t.approvedForms.length>0))},dependencies:[te,ie,W,j,H,ue,ft,ht,se,Q]})}return l})();var po=[{path:"",component:fi,children:[{path:"",redirectTo:"drafts",pathMatch:"full"},{path:"edit/:id",component:yt},{path:"drafts",component:wi,children:[{path:"",redirectTo:"supplier",pathMatch:"full"},{path:"supplier",component:ui},{path:"staff",component:_i}]},{path:"publish",component:Ci,children:[{path:"",redirectTo:"supplier",pathMatch:"full"},{path:"supplier",component:gi},{path:"staff",component:yi}]},{path:"create",component:vi,children:[{path:"",redirectTo:"supplier",pathMatch:"full"},{path:"supplier",component:yt},{path:"staff",component:Si}]},{path:"cheque",component:Tt,children:[{path:"",redirectTo:"supplier",pathMatch:"full"},{path:"supplier",component:At},{path:"staff",component:Mt}]},{path:"all-approved",component:Tt,children:[{path:"",redirectTo:"supplier",pathMatch:"full"},{path:"supplier",component:At},{path:"staff",component:Mt}]},{path:"config",component:di}
2688]}],Di=(()=>{class l{static \u0275fac=function(i){return new(i||l)};static \u0275mod=rt({type:l});static \u0275inj=nt({imports:[wt.forChild(po),wt]})}return l})();function co(l,f){l&1&&(r(0,"pre"),o(1,"ng generate component xyz"),n())}function mo(l,f){l&1&&(r(0,"pre"),o(1,"ng add @angular/material"),n())}function uo(l,f){l&1&&(r(0,"pre"),o(1,"ng add @angular/pwa"),n())}function fo(l,f){l&1&&(r(0,"pre"),o(1,"ng add _____"),n())}function ho(l,f){l&1&&(r(0,"pre"),o(1,"ng test"),n())}function go(l,f){l&1&&(r(0,"pre"),o(1,"ng build --prod"),n())}var Pi=(()=>{class l{title="Supplier";static \u0275fac=function(i){return new(i||l)};static \u0275cmp=q({type:l,selectors:[["app-root"]],decls:155,vars:7,consts:[["selection",""],["role","banner",1,"toolbar"],["width","40","alt","Angular Logo","src","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="],[1,"spacer"],["aria-label","Angular on twitter","target","_blank","rel","noopener","href","https://twitter.com/angular","title","Twitter"],["id","twitter-logo","height","24","data-name","Logo","xmlns","http://www.w3.org/2000/svg","viewBox","0 0 400 400"],["width","400","height","400","fill","none"],["d","M153.62,301.59c94.34,0,145.94-78.16,145.94-145.94,0-2.22,0-4.43-.15-6.63A104.36,104.36,0,0,0,325,122.47a102.38,102.38,0,0,1-29.46,8.07,51.47,51.47,0,0,0,22.55-28.37,102.79,102.79,0,0,1-32.57,12.45,51.34,51.34,0,0,0-87.41,46.78A145.62,145.62,0,0,1,92.4,107.81a51.33,51.33,0,0,0,15.88,68.47A50.91,50.91,0,0,1,85,169.86c0,.21,0,.43,0,.65a51.31,51.31,0,0,0,41.15,50.28,51.21,51.21,0,0,1-23.16.88,51.35,51.35,0,0,0,47.92,35.62,102.92,102.92,0,0,1-63.7,22A104.41,104.41,0,0,1,75,278.55a145.21,145.21,0,0,0,78.62,23","fill","#fff"],["role","main",1,"content"],[1,"card","highlight-card","card-small"],["id","rocket","alt","Rocket Ship","xmlns","http://www.w3.org/2000/svg","width","101.678","height","101.678","viewBox","0 0 101.678 101.678"],["id","Group_83","data-name","Group 83","transform","translate(-141 -696)"],["id","Ellipse_8","data-name","Ellipse 8","cx","50.839","cy","50.839","r","50.839","transform","translate(141 696)","fill","#dd0031"],["id","Group_47","data-name","Group 47","transform","translate(165.185 720.185)"],["id","Path_33","data-name","Path 33","d","M3.4,42.615a3.084,3.084,0,0,0,3.553,3.553,21.419,21.419,0,0,0,12.215-6.107L9.511,30.4A21.419,21.419,0,0,0,3.4,42.615Z","transform","translate(0.371 3.363)","fill","#fff"],["id","Path_34","data-name","Path 34","d","M53.3,3.221A3.09,3.09,0,0,0,50.081,0,48.227,48.227,0,0,0,18.322,13.437c-6-1.666-14.991-1.221-18.322,7.218A33.892,33.892,0,0,1,9.439,25.1l-.333.666a3.013,3.013,0,0,0,.555,3.553L23.985,43.641a2.9,2.9,0,0,0,3.553.555l.666-.333A33.892,33.892,0,0,1,32.647,53.3c8.55-3.664,8.884-12.326,7.218-18.322A48.227,48.227,0,0,0,53.3,3.221ZM34.424,9.772a6.439,6.439,0,1,1,9.106,9.106,6.368,6.368,0,0,1-9.106,0A6.467,6.467,0,0,1,34.424,9.772Z","transform","translate(0 0.005)","fill","#fff"],["id","rocket-smoke","alt","Rocket Ship Smoke","xmlns","http://www.w3.org/2000/svg","width","516.119","height","1083.632","viewBox","0 0 516.119 1083.632"],["id","Path_40","data-name","Path 40","d","M644.6,141S143.02,215.537,147.049,870.207s342.774,201.755,342.774,201.755S404.659,847.213,388.815,762.2c-27.116-145.51-11.551-384.124,271.9-609.1C671.15,139.365,644.6,141,644.6,141Z","transform","translate(-147.025 -140.939)","fill","#f5f5f5"],[1,"card-container"],["target","_blank","rel","noopener","href","https://angular.io/tutorial",1,"card"],["xmlns","http://www.w3.org/2000/svg","width","24","height","24","viewBox","0 0 24 24",1,"material-icons"],["d","M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82zM12 3L1 9l11 6 9-4.91V17h2V9L12 3z"],["d","M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"],["target","_blank","rel","noopener","href","https://angular.io/cli",1,"card"],["d","M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"],["target","_blank","rel","noopener","href","https://blog.angular.io/",1,"card"],["d","M13.5.67s.74 2.65.74 4.8c0 2.06-1.35 3.73-3.41 3.73-2.07 0-3.63-1.67-3.63-3.73l.03-.36C5.21 7.51 4 10.62 4 14c0 4.42 3.58 8 8 8s8-3.58 8-8C20 8.61 17.41 3.8 13.5.67zM11.71 19c-1.78 0-3.22-1.4-3.22-3.14 0-1.62 1.05-2.76 2.81-3.12 1.77-.36 3.6-1.21 4.62-2.58.39 1.29.59 2.65.59 4.04 0 2.65-2.15 4.8-4.8 4.8z"],["type","hidden"],["tabindex","0",1,"card","card-small",3,"click"],["d","M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"],[1,"terminal",3,"ngSwitch"],[4,"ngSwitchDefault"],[4,"ngSwitchCase"],["t
2688itle","Animations","href","https://angular.io/guide/animations","target","_blank","rel","noopener",1,"circle-link"],["id","Group_20","data-name","Group 20","xmlns","http://www.w3.org/2000/svg","width","21.813","height","23.453","viewBox","0 0 21.813 23.453"],["id","Path_15","data-name","Path 15","d","M4099.584,972.736h0l-10.882,3.9,1.637,14.4,9.245,5.153,9.245-5.153,1.686-14.4Z","transform","translate(-4088.702 -972.736)","fill","#ffa726"],["id","Path_16","data-name","Path 16","d","M4181.516,972.736v23.453l9.245-5.153,1.686-14.4Z","transform","translate(-4170.633 -972.736)","fill","#fb8c00"],["id","Path_17","data-name","Path 17","d","M4137.529,1076.127l-7.7-3.723,4.417-2.721,7.753,3.723Z","transform","translate(-4125.003 -1058.315)","fill","#ffe0b2"],["id","Path_18","data-name","Path 18","d","M4137.529,1051.705l-7.7-3.723,4.417-2.721,7.753,3.723Z","transform","translate(-4125.003 -1036.757)","fill","#fff3e0"],["id","Path_19","data-name","Path 19","d","M4137.529,1027.283l-7.7-3.723,4.417-2.721,7.753,3.723Z","transform","translate(-4125.003 -1015.199)","fill","#fff"],["title","CLI","href","https://cli.angular.io/","target","_blank","rel","noopener",1,"circle-link"],["alt","Angular CLI Logo","xmlns","http://www.w3.org/2000/svg","width","21.762","height","23.447","viewBox","0 0 21.762 23.447"],["id","Group_21","data-name","Group 21","transform","translate(0)"],["id","Path_20","data-name","Path 20","d","M2660.313,313.618h0l-10.833,3.9,1.637,14.4,9.2,5.152,9.244-5.152,1.685-14.4Z","transform","translate(-2649.48 -313.618)","fill","#37474f"],["id","Path_21","data-name","Path 21","d","M2741.883,313.618v23.447l9.244-5.152,1.685-14.4Z","transform","translate(-2731.05 -313.618)","fill","#263238"],["id","Path_22","data-name","Path 22","d","M2692.293,379.169h11.724V368.618h-11.724Zm11.159-.6h-10.608v-9.345h10.621v9.345Z","transform","translate(-2687.274 -362.17)","fill","#fff"],["id","Path_23","data-name","Path 23","d","M2709.331,393.688l.4.416,2.265-2.28-2.294-2.294-.4.4,1.893,1.893Z","transform","translate(-2702.289 -380.631)","fill","#fff"],["id","Rectangle_12","data-name","Rectangle 12","width","3.517","height","0.469","transform","translate(9.709 13.744)","fill","#fff"],["title","Augury","href","https://augury.rangle.io/","target","_blank","rel","noopener",1,"circle-link"],["alt","Angular Augury Logo","xmlns","http://www.w3.org/2000/svg",0,"xmlns","xlink","http://www.w3.org/1999/xlink","width","21.81","height","23.447","viewBox","0 0 21.81 23.447"],["id","clip-path"],["id","Rectangle_13","data-name","Rectangle 13","width","10.338","height","10.27","fill","none"],["id","Group_25","data-name","Group 25","transform","translate(0)"],["id","Path_24","data-name","Path 24","d","M3780.155,311.417h0l-10.881,3.9,1.637,14.4,9.244,5.152,9.244-5.152,1.685-14.4Z","transform","translate(-3769.274 -311.417)","fill","#4a3493"],["id","Path_25","data-name","Path 25","d","M3862.088,311.417v23.447l9.244-5.152,1.685-14.4Z","transform","translate(-3851.207 -311.417)","fill","#311b92"],["id","Group_24","data-name","Group 24","transform","translate(6.194 6.73)","opacity","0.5"],["id","Group_23","data-name","Group 23","transform","translate(0 0)"],["id","Group_22","data-name","Group 22","clip-path","url(#clip-path)"],["id","Path_26","data-name","Path 26","d","M3832.4,373.252a5.168,5.168,0,1,1-5.828-4.383,5.216,5.216,0,0,1,2.574.3,3.017,3.017,0,1,0,3.252,4.086Z","transform","translate(-3822.107 -368.821)","fill","#fff"],["id","Path_27","data-name","Path 27","d","M3830.582,370.848a5.162,5.162,0,1,1-3.254-4.086,3.017,3.017,0,1,0,3.252,4.086Z","transform","translate(-3814.311 -359.969)","fill","#fff"],["title","Protractor","href","https://www.protractortest.org/","target","_blank","rel","noopener",1,"circle-link"],["alt","Angular Protractor Logo","xmlns","http://www.w3.org/2000/svg","width","21.81","height","23.447","viewBox","0 0 21.81 23.447"],["id","Group_26","data-name","Group 26","transform","translate(0)"],["id","Path_28","data-name","Path 28","d","M4620.155,311.417h0l-10.881,3.9,1.637,14.4,9.244,5.152,9.244-5.152,1.685-14.4Z","transform","translate(-4609.274 -311.417)","fill","#e13439"],["id","Path_29","data-name","Path 29","d","M4702.088,311.417v23.447l9.244-5.152,1.685-14.4Z","transform","translate(-4691.207 -311.417)","fill","#b52f32"],["id","Path_30","data-name","Path 30","d","M4651.044,369.58v-.421h1.483a7.6,7.6,0,0,0-2.106-5.052l-1.123,1.123-.3-.3,1.122-1.121a7.588,7.588,0,0,0-4.946-2.055v1.482h-.421v-1.485a7.589,7.589,0,0,0-5.051,2.058l1.122,1.121-.3.3-1.123-1.
2688123a7.591,7.591,0,0,0-2.106,5.052h1.482v.421h-1.489v1.734h15.241V369.58Zm-10.966-.263a4.835,4.835,0,0,1,9.67,0Z","transform","translate(-4634.008 -355.852)","fill","#fff"],["title","Find a Local Meetup","href","https://www.meetup.com/find/?keywords=angular","target","_blank","rel","noopener",1,"circle-link"],["alt","Meetup Logo","xmlns","http://www.w3.org/2000/svg","width","24.607","height","23.447","viewBox","0 0 24.607 23.447"],["id","logo--mSwarm","d","M21.221,14.95A4.393,4.393,0,0,1,17.6,19.281a4.452,4.452,0,0,1-.8.069c-.09,0-.125.035-.154.117a2.939,2.939,0,0,1-2.506,2.091,2.868,2.868,0,0,1-2.248-.624.168.168,0,0,0-.245-.005,3.926,3.926,0,0,1-2.589.741,4.015,4.015,0,0,1-3.7-3.347,2.7,2.7,0,0,1-.043-.38c0-.106-.042-.146-.143-.166a3.524,3.524,0,0,1-1.516-.69A3.623,3.623,0,0,1,2.23,14.557a3.66,3.66,0,0,1,1.077-3.085.138.138,0,0,0,.026-.2,3.348,3.348,0,0,1-.451-1.821,3.46,3.46,0,0,1,2.749-3.28.44.44,0,0,0,.355-.281,5.072,5.072,0,0,1,3.863-3,5.028,5.028,0,0,1,3.555.666.31.31,0,0,0,.271.03A4.5,4.5,0,0,1,18.3,4.7a4.4,4.4,0,0,1,1.334,2.751,3.658,3.658,0,0,1,.022.706.131.131,0,0,0,.1.157,2.432,2.432,0,0,1,1.574,1.645,2.464,2.464,0,0,1-.7,2.616c-.065.064-.051.1-.014.166A4.321,4.321,0,0,1,21.221,14.95ZM13.4,14.607a2.09,2.09,0,0,0,1.409,1.982,4.7,4.7,0,0,0,1.275.221,1.807,1.807,0,0,0,.9-.151.542.542,0,0,0,.321-.545.558.558,0,0,0-.359-.534,1.2,1.2,0,0,0-.254-.078c-.262-.047-.526-.086-.787-.138a.674.674,0,0,1-.617-.75,3.394,3.394,0,0,1,.218-1.109c.217-.658.509-1.286.79-1.918a15.609,15.609,0,0,0,.745-1.86,1.95,1.95,0,0,0,.06-1.073,1.286,1.286,0,0,0-1.051-1.033,1.977,1.977,0,0,0-1.521.2.339.339,0,0,1-.446-.042c-.1-.092-.2-.189-.307-.284a1.214,1.214,0,0,0-1.643-.061,7.563,7.563,0,0,1-.614.512A.588.588,0,0,1,10.883,8c-.215-.115-.437-.215-.659-.316a2.153,2.153,0,0,0-.695-.248A2.091,2.091,0,0,0,7.541,8.562a9.915,9.915,0,0,0-.405.986c-.559,1.545-1.015,3.123-1.487,4.7a1.528,1.528,0,0,0,.634,1.777,1.755,1.755,0,0,0,1.5.211,1.35,1.35,0,0,0,.824-.858c.543-1.281,1.032-2.584,1.55-3.875.142-.355.28-.712.432-1.064a.548.548,0,0,1,.851-.24.622.622,0,0,1,.185.539,2.161,2.161,0,0,1-.181.621c-.337.852-.68,1.7-1.018,2.552a2.564,2.564,0,0,0-.173.528.624.624,0,0,0,.333.71,1.073,1.073,0,0,0,.814.034,1.22,1.22,0,0,0,.657-.655q.758-1.488,1.511-2.978.35-.687.709-1.37a1.073,1.073,0,0,1,.357-.434.43.43,0,0,1,.463-.016.373.373,0,0,1,.153.387.7.7,0,0,1-.057.236c-.065.157-.127.316-.2.469-.42.883-.846,1.763-1.262,2.648A2.463,2.463,0,0,0,13.4,14.607Zm5.888,6.508a1.09,1.09,0,0,0-2.179.006,1.09,1.09,0,0,0,2.179-.006ZM1.028,12.139a1.038,1.038,0,1,0,.01-2.075,1.038,1.038,0,0,0-.01,2.075ZM13.782.528a1.027,1.027,0,1,0-.011,2.055A1.027,1.027,0,0,0,13.782.528ZM22.21,6.95a.882.882,0,0,0-1.763.011A.882.882,0,0,0,22.21,6.95ZM4.153,4.439a.785.785,0,1,0,.787-.78A.766.766,0,0,0,4.153,4.439Zm8.221,18.22a.676.676,0,1,0-.677.666A.671.671,0,0,0,12.374,22.658ZM22.872,12.2a.674.674,0,0,0-.665.665.656.656,0,0,0,.655.643.634.634,0,0,0,.655-.644A.654.654,0,0,0,22.872,12.2ZM7.171-.123A.546.546,0,0,0,6.613.43a.553.553,0,1,0,1.106,0A.539.539,0,0,0,7.171-.123ZM24.119,9.234a.507.507,0,0,0-.493.488.494.494,0,0,0,.494.494.48.48,0,0,0,.487-.483A.491.491,0,0,0,24.119,9.234Zm-19.454,9.7a.5.5,0,0,0-.488-.488.491.491,0,0,0-.487.5.483.483,0,0,0,.491.479A.49.49,0,0,0,4.665,18.936Z","transform","translate(0 0.123)","fill","#f64060"],["title","Join the Conversation on Gitter","href","https://gitter.im/angular/angular","target","_blank","rel","noopener",1,"circle-link"],["alt","Gitter Logo","xmlns","http://www.w3.org/2000/svg","width","19.447","height","19.447","viewBox","0 0 19.447 19.447"],["id","Group_40","data-name","Group 40","transform","translate(-1612 -405)"],["id","Rectangle_19","data-name","Rectangle 19","width","19.447","height","19.447","transform","translate(1612 405)","fill","#e60257"],["id","gitter","transform","translate(1617.795 408.636)"],["id","Group_33","data-name","Group 33","transform","translate(0 0)"],["id","Rectangle_15","data-name","Rectangle 15","width","1.04","height","9.601","transform","translate(2.304 2.324)","fill","#fff"],["id","Rectangle_16","data-name","Rectangle 16","width","1.04","height","9.601","transform","translate(4.607 2.324)","fill","#fff"],["id","Rectangle_17","data-name","Rectangle 17","width","1.04","height","4.648","transform","translate(6.91 2.324)","fill","#fff"],["id","Rectangle_18","data-name","Rectangle 18","width","1.04","height","6.971","transform","translate(0 0)","fill","#fff"],["href","https://github.com/angular/angular","target","_blank","rel","noopener"],[1,"github-star-badge"],["d","M0 0h24v24H0z","fill","none"],["d","M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"],["d","M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z","fill","#1976d2"],["id","clouds","alt","Gray Clouds Backgroun
2688d","xmlns","http://www.w3.org/2000/svg","width","2611.084","height","485.677","viewBox","0 0 2611.084 485.677"],["id","Path_39","data-name","Path 39","d","M2379.709,863.793c10-93-77-171-168-149-52-114-225-105-264,15-75,3-140,59-152,133-30,2.83-66.725,9.829-93.5,26.25-26.771-16.421-63.5-23.42-93.5-26.25-12-74-77-130-152-133-39-120-212-129-264-15-54.084-13.075-106.753,9.173-138.488,48.9-31.734-39.726-84.4-61.974-138.487-48.9-52-114-225-105-264,15a162.027,162.027,0,0,0-103.147,43.044c-30.633-45.365-87.1-72.091-145.206-58.044-52-114-225-105-264,15-75,3-140,59-152,133-53,5-127,23-130,83-2,42,35,72,70,86,49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33,61.112,8.015,113.854-5.72,150.492-29.764a165.62,165.62,0,0,0,110.861-3.236c47,94,178,113,251,33,31.385,4.116,60.563,2.495,86.487-3.311,25.924,5.806,55.1,7.427,86.488,3.311,73,80,204,61,251-33a165.625,165.625,0,0,0,120,0c51,13,108,15,157-5a147.188,147.188,0,0,0,33.5-18.694,147.217,147.217,0,0,0,33.5,18.694c49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33C2446.709,1093.793,2554.709,922.793,2379.709,863.793Z","transform","translate(142.69 -634.312)","fill","#eee"]],template:function(i,t){if(i&1){let a=I();r(0,"div",1),c(1,"img",2),r(2,"span"),o(3,"Welcome"),n(),c(4,"div",3),r(5,"a",4),U(),r(6,"svg",5),c(7,"rect",6)(8,"path",7),n()()(),z(),r(9,"div",8)(10,"div",9),U(),r(11,"svg",10)(12,"g",11),c(13,"circle",12),r(14,"g",13),c(15,"path",14)(16,"path",15),n()()(),z(),r(17,"span"),o(18),n(),U(),r(19,"svg",16),c(20,"path",17),n()(),z(),r(21,"h2"),o(22,"Resources"),n(),r(23,"p"),o(24,"Here are some links to help you get started:"),n(),r(25,"div",18)(26,"a",19),U(),r(27,"svg",20),c(28,"path",21),n(),z(),r(29,"span"),o(30,"Learn Angular"),n(),U(),r(31,"svg",20),c(32,"path",22),n()(),z(),r(33,"a",23),U(),r(34,"svg",20),c(35,"path",24),n(),z(),r(36,"span"),o(37,"CLI Documentation"),n(),U(),r(38,"svg",20),c(39,"path",22),n()(),z(),r(40,"a",25),U(),r(41,"svg",20),c(42,"path",26),n(),z(),r(43,"span"),o(44,"Angular Blog"),n(),U(),r(45,"svg",20),c(46,"path",22),n()()(),z(),r(47,"h2"),o(48,"Next Steps"),n(),r(49,"p"),o(50,"What do you want to do next with your app?"),n(),c(51,"input",27,0),r(53,"div",18)(54,"div",28),b("click",function(){x(a);let m=le(52);return S(m.value="component")}),U(),r(55,"svg",20),c(56,"path",29),n(),z(),r(57,"span"),o(58,"New Component"),n()(),r(59,"div",28),b("click",function(){x(a);let m=le(52);return S(m.value="material")}),U(),r(60,"svg",20),c(61,"path",29),n(),z(),r(62,"span"),o(63,"Angular Material"),n()(),r(64,"div",28),b("click",function(){x(a);let m=le(52);return S(m.value="pwa")}),U(),r(65,"svg",20),c(66,"path",29),n(),z(),r(67,"span"),o(68,"Add PWA Support"),n()(),r(69,"div",28),b("click",function(){x(a);let m=le(52);return S(m.value="dependency")}),U(),r(70,"svg",20),c(71,"path",29),n(),z(),r(72,"span"),o(73,"Add Dependency"),n()(),r(74,"div",28),b("click",function(){x(a);let m=le(52);return S(m.value="test")}),U(),r(75,"svg",20),c(76,"path",29),n(),z(),r(77,"span"),o(78,"Run and Watch Tests"),n()(),r(79,"div",28),b("click",function(){x(a);let m=le(52);return S(m.value="build")}),U(),r(80,"svg",20),c(81,"path",29),n(),z(),r(82,"span"),o(83,"Build for Production"),n()()(),r(84,"div",30),_(85,co,2,0,"pre",31)(86,mo,2,0,"pre",32)(87,uo,2,0,"pre",32)(88,fo,2,0,"pre",32)(89,ho,2,0,"pre",32)(90,go,2,0,"pre",32),n(),r(91,"div",18)(92,"a",33),U(),r(93,"svg",34),c(94,"path",35)(95,"path",36)(96,"path",37)(97,"path",38)(98,"path",39),n()(),z(),r(99,"a",40),U(),r(100,"svg",41)(101,"g",42),c(102,"path",43)(103,"path",44)(104,"path",45)(105,"path",46)(106,"rect",47),n()()(),z(),r(107,"a",48),U(),r(108,"svg",49)(109,"defs")(110,"clipPath",50),c(111,"rect",51),n()(),r(112,"g",52),c(113,"path",53)(114,"path",54),r(115,"g",55)(116,"g",56)(117,"g",57),c(118,"path",58),n()()(),c(119,"path",59),n()()(),z(),r(120,"a",60),U(),r(121,"svg",61)(122,"g",62),c(123,"path",63)(124,"path",64)(125,"path",65),n()()(),z(),r(126,"a",66),U(),r(127,"svg",67),c(128,"path",68),n()(),z(),r(129,"a",69),U(),r(130,"svg",70)(131,"g",71),c(132,"rect",72),r(133,"g",73)(134,"g",74),c(135,"rect",75)(136,"rect",76)(137,"rect",77)(138,"rect",78),n()()()()()(),z(),r(139,"footer"),o(140," Love Angular?\xA0 "),r(141,"a",79),o(142," Give our repo a star. "),r(143,"div",80),U(),r(144,"svg",20),c(145,"path",81)(146,"path",82),n(),o(147," Star "),n()(),z(),r(148,"a",79),U(),r(149,"svg",20),c(150,"path",83)(151,"path",81),n()()(),r(152,"svg",84),c(153,"path",85),n()(),z(),c(154,"router-outlet")}if(i&2){let a=le(52);d(18),A("",t.title," app is running!"),d(66),p("ngSwitch",a.value),d(2),p("ngSwitchCase","material"),d(),p("ngSwitchCase","pwa"),d(),p("ngSwitchCase","dependency"),d(),p("ngSwitchCase","test"),d(),p("ngSwitchCase","build")}},dependencies:[Gt,Wt,jt,ce],styles:[`[_nghost-%COMP%] {
2689    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
2690    font-size: 14px;
2691    color: #333;
2692    box-sizing: border-box;
2693    -webkit-font-smoothing: antialiased;
2694    -moz-osx-font-smoothing: grayscale;
2695  }
2696
2697  h1[_ngcontent-%COMP%], 
2698   h2[_ngcontent-%COMP%], 
2699   h3[_ngcontent-%COMP%], 
2700   h4[_ngcontent-%COMP%], 
2701   h5[_ngcontent-%COMP%], 
2702   h6[_ngcontent-%COMP%] {
2703    margin: 8px 0;
2704  }
2705
2706  p[_ngcontent-%COMP%] {
2707    margin: 0;
2708  }
2709
2710  .spacer[_ngcontent-%COMP%] {
2711    flex: 1;
2712  }
2713
2714  .toolbar[_ngcontent-%COMP%] {
2715    position: absolute;
2716    top: 0;
2717    left: 0;
2718    right: 0;
2719    height: 60px;
2720    display: flex;
2721    align-items: center;
2722    background-color: #1976d2;
2723    color: white;
2724    font-weight: 600;
2725  }
2726
2727  .toolbar[_ngcontent-%COMP%]   img[_ngcontent-%COMP%] {
2728    margin: 0 16px;
2729  }
2730
2731  .toolbar[_ngcontent-%COMP%]   #twitter-logo[_ngcontent-%COMP%] {
2732    height: 40px;
2733    margin: 0 16px;
2734  }
2735
2736  .toolbar[_ngcontent-%COMP%]   #twitter-logo[_ngcontent-%COMP%]:hover {
2737    opacity: 0.8;
2738  }
2739
2740  .content[_ngcontent-%COMP%] {
2741    display: flex;
2742    margin: 82px auto 32px;
2743    padding: 0 16px;
2744    max-width: 960px;
2745    flex-direction: column;
2746    align-items: center;
2747  }
2748
2749  svg.material-icons[_ngcontent-%COMP%] {
2750    height: 24px;
2751    width: auto;
2752  }
2753
2754  svg.material-icons[_ngcontent-%COMP%]:not(:last-child) {
2755    margin-right: 8px;
2756  }
2757
2758  .card[_ngcontent-%COMP%]   svg.material-icons[_ngcontent-%COMP%]   path[_ngcontent-%COMP%] {
2759    fill: #888;
2760  }
2761
2762  .card-container[_ngcontent-%COMP%] {
2763    display: flex;
2764    flex-wrap: wrap;
2765    justify-content: center;
2766    margin-top: 16px;
2767  }
2768
2769  .card[_ngcontent-%COMP%] {
2770    border-radius: 4px;
2771    border: 1px solid #eee;
2772    background-color: #fafafa;
2773    height: 40px;
2774    width: 200px;
2775    margin: 0 8px 16px;
2776    padding: 16px;
2777    display: flex;
2778    flex-direction: row;
2779    justify-content: center;
2780    align-items: center;
2781    transition: all 0.2s ease-in-out;
2782    line-height: 24px;
2783  }
2784
2785  .card-container[_ngcontent-%COMP%]   .card[_ngcontent-%COMP%]:not(:last-child) {
2786    margin-right: 0;
2787  }
2788
2789  .card.card-small[_ngcontent-%COMP%] {
2790    height: 16px;
2791    width: 168px;
2792  }
2793
2794  .card-container[_ngcontent-%COMP%]   .card[_ngcontent-%COMP%]:not(.highlight-card) {
2795    cursor: pointer;
2796  }
2797
2798  .card-container[_ngcontent-%COMP%]   .card[_ngcontent-%COMP%]:not(.highlight-card):hover {
2799    transform: translateY(-3px);
2800    box-shadow: 0 4px 17px rgba(0, 0, 0, 0.35);
2801  }
2802
2803  .card-container[_ngcontent-%COMP%]   .card[_ngcontent-%COMP%]:not(.highlight-card):hover   .material-icons[_ngcontent-%COMP%]   path[_ngcontent-%COMP%] {
2804    fill: rgb(105, 103, 103);
2805  }
2806
2807  .card.highlight-card[_ngcontent-%COMP%] {
2808    background-color: #1976d2;
2809    color: white;
2810    font-weight: 600;
2811    border: none;
2812    width: auto;
2813    min-width: 30%;
2814    position: relative;
2815  }
2816
2817  .card.card.highlight-card[_ngcontent-%COMP%]   span[_ngcontent-%COMP%] {
2818    margin-left: 60px;
2819  }
2820
2821  svg#rocket[_ngcontent-%COMP%] {
2822    width: 80px;
2823    position: absolute;
2824    left: -10px;
2825    top: -24px;
2826  }
2827
2828  svg#rocket-smoke[_ngcontent-%COMP%] {
2829    height: calc(100vh - 95px);
2830    position: absolute;
2831    top: 10px;
2832    right: 180px;
2833    z-index: -10;
2834  }
2835
2836  a[_ngcontent-%COMP%], 
2837   a[_ngcontent-%COMP%]:visited, 
2838   a[_ngcontent-%COMP%]:hover {
2839    color: #1976d2;
2840    text-decoration: none;
2841  }
2842
2843  a[_ngcontent-%COMP%]:hover {
2844    color: #125699;
2845  }
2846
2847  .terminal[_ngcontent-%COMP%] {
2848    position: relative;
2849    width: 80%;
2850    max-width: 600px;
2851    border-radius: 6px;
2852    padding-top: 45px;
2853    margin-top: 8px;
2854    overflow: hidden;
2855    background-color: rgb(15, 15, 16);
2856  }
2857
2858  .terminal[_ngcontent-%COMP%]::before {
2859    content: "\\2022 \\2022 \\2022";
2860    position: absolute;
2861    top: 0;
2862    left: 0;
2863    height: 4px;
2864    background: rgb(58, 58, 58);
2865    color: #c2c3c4;
2866    width: 100%;
2867    font-size: 2rem;
2868    line-height: 0;
2869    padding: 14px 0;
2870    text-indent: 4px;
2871  }
2872
2873  .terminal[_ngcontent-%COMP%]   pre[_ngcontent-%COMP%] {
2874    font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
2875    color: white;
2876    padding: 0 1rem 1rem;
2877    margin: 0;
2878  }
2879
2880  .circle-link[_ngcontent-%COMP%] {
2881    height: 40px;
2882    width: 40px;
2883    border-radius: 40px;
2884    margin: 8px;
2885    background-color: white;
2886    border: 1px solid #eeeeee;
2887    display: flex;
2888    justify-content: center;
2889    align-items: center;
2890    cursor: pointer;
2891    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
2892    transition: 1s ease-out;
2893  }
2894
2895  .circle-link[_ngcontent-%COMP%]:hover {
2896    transform: translateY(-0.25rem);
2897    box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
2898  }
2899
2900  footer[_ngcontent-%COMP%] {
2901    margin-top: 8px;
2902    display: flex;
2903    align-items: center;
2904    line-height: 20px;
2905  }
2906
2907  footer[_ngcontent-%COMP%]   a[_ngcontent-%COMP%] {
2908    display: flex;
2909    align-items: center;
2910  }
2911
2912  .github-star-badge[_ngcontent-%COMP%] {
2913    color: #24292e;
2914    display: flex;
2915    align-items: center;
2916    font-size: 12px;
2917    padding: 3px 10px;
2918    border: 1px solid rgba(27,31,35,.2);
2919    border-radius: 3px;
2920    background-image: linear-gradient(-180deg,#fafbfc,#eff3f6 90%);
2921    margin-left: 4px;
2922    font-weight: 600;
2923    font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
2924  }
2925
2926  .github-star-badge[_ngcontent-%COMP%]:hover {
2927    background-image: linear-gradient(-180deg,#f0f3f6,#e6ebf1 90%);
2928    border-color: rgba(27,31,35,.35);
2929    background-position: -.5em;
2930  }
2931
2932  .github-star-badge[_ngcontent-%COMP%]   .material-icons[_ngcontent-%COMP%] {
2933    height: 16px;
2934    width: 16px;
2935    margin-right: 4px;
2936  }
2937
2938  svg#clouds[_ngcontent-%COMP%] {
2939    position: fixed;
2940    bottom: -160px;
2941    left: -230px;
2942    z-index: -10;
2943    width: 1920px;
2944  }
2945
2946
2947  
2948
2949  @media screen and (max-width: 767px) {
2950
2951    .card-container[_ngcontent-%COMP%]    > *[_ngcontent-%COMP%]:not(.circle-link), 
2952   .terminal[_ngcontent-%COMP%] {
2953      width: 100%;
2954    }
2955
2956    .card[_ngcontent-%COMP%]:not(.highlight-card) {
2957      height: 16px;
2958      margin: 8px 0;
2959    }
2960
2961    .card.highlight-card[_ngcontent-%COMP%]   span[_ngcontent-%COMP%] {
2962      margin-left: 72px;
2963    }
2964
2965    svg#rocket-smoke[_ngcontent-%COMP%] {
2966      right: 120px;
2967      transform: rotate(-5deg);
2968    }
2969  }
2970
2971  @media screen and (max-width: 575px) {
2972    svg#rocket-smoke[_ngcontent-%COMP%] {
2973      display: none;
2974      visibility: hidden;
2975    }
2976  }`]})}return l})();var Vt=Ye(Ge());var bo=Vt.default??Vt,Fs=(()=>{class l{constructor(){bo.locale("en-GB")}static \u0275fac=function(i){return new(i||l)};static \u0275mod=rt({type:l,bootstrap:[Pi]});static \u0275inj=nt({imports:[Ht,Di,ii,ni,oi.forRoot(),ai]})}return l})();export{Fs as supplierModule};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.