import{_ as I}from"./RapportDynamique-BvCuWpYR.js";import{_ as M}from"./FavorisSwitch-DD6nTfzi.js";import{f as N,o as d,c as V,b as c,a as s,z as j,av as z,i as b,q as L,d as w,F as T,r as i,e as O}from"./vendor-0kGcmQpG.js";import{u as U,a as x,s as n,S as h}from"./index-Bn9WoKhP.js";import{_ as W}from"./DataGrid-tb6QVwpZ.js";import"./useAgGridConfig-DjXMc6wb.js";const H={class:"w-full mb-6 flex flex-col sm:flex-row items-center align-baseline gap-3"},J={class:"flex items-center gap-3 lg:w-1/4 lg:justify-end whitespace-nowrap"},K={style:{height:"calc(100vh - 220px)"}},te={__name:"SituationFinanciereGlobale",props:["masquerFermer"],setup(y){const{showError:p,showWarn:m,showInfo:f}=U(),S=y,u=i(),v=i(),C=i([]),g=i(),o=i([]),r=i(!1),k=O(()=>["debit","credit"]),$=({event:t,ndoc:e})=>{},A=({selectedRows:t})=>{C.value=t},F=t=>{v.value=t.api};N(async()=>{await G(),_()});const G=async()=>{try{const e=(await x.post(`${n.lienApi}/verifierDroit/${n.state.dbCommun6}`,{id_utilisateur:n.userId,id_page:803,mail:n.state.userCloud.mail})).data;e&&Object.keys(e).length>0&&(e.lecture||(m("Vous n'avez pas le droit, veuillez consulter l'administrateur"),h("SituationFinanciereGlobale")))}catch(t){p(`Une erreur s'est produite lors de la vérification des droits.
 ${t}`)}},_=async()=>{n.state.afficher_in_progress=!0;const t=`${n.lienApi}/SituationFinanciereGlobale/${n.db}/${n.state.enreg_societe.Capital}`;try{const e=await x.post(t);o.value=e.data}catch(e){const a=e.response?.data?.message||e.message;p("Une erreur est survenue : "+a)}finally{n.state.afficher_in_progress=!1}},R=()=>{if(!o.value||o.value.length===0){m("Aucune donnée à imprimer");return}r.value=!0},q=()=>{if(!u.value){f("Grille non initialisée");return}if(o.value.length===0){f("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");u.value.exportToExcel(`Situation Financiere Globale_${n.state.enreg_societe.Nom}_${e}.xlsx`)};return(t,e)=>{const a=j,B=z,D=M,E=I;return d(),V(T,null,[c("div",H,[s(a,{icon:"pi pi-refresh",label:"Afficher",text:"",onClick:e[0]||(e[0]=l=>_())}),s(a,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=l=>g.value.toggle(l))}),s(B,{ref_key:"actionsMenu",ref:g,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>q()},{label:"Imprimer",icon:"pi pi-print",command:()=>R()}],popup:!0},null,8,["model"]),S.masquerFermer?w("",!0):(d(),b(a,{key:0,icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=l=>L(h)("SituationFinanciereGlobale"))})),e[4]||(e[4]=c("div",{class:"w-full lg:w-2/4 flex justify-center px-4"},null,-1)),c("div",J,[s(D,{fen:"SituationFinanciereGlobale",text:"Situation financière Global"})])]),c("div",K,[s(W,{ref_key:"dataGrid",ref:u,"excel-file-name":"Situation financiere globale","excel-sheet-name":"Situation financiere globale","row-data":o.value,"document-number-fields":["ndoc"],"excluded-columns":["ndoc"],"column-widths":{debit:120,credit:120,element:350},"enable-totals":!0,"numeric-columns":k.value,"totals-columns":["debit","credit"],onRowClicked:$,onSelectionChanged:A,onGridReady:F},null,8,["row-data","numeric-columns"])]),r.value?(d(),b(E,{key:0,show:r.value,dataList:o.value,titre:"Situation fiancière globale",gridApi:v.value,onClose:e[3]||(e[3]=l=>r.value=!1)},null,8,["show","dataList","gridApi"])):w("",!0)],64)}}};export{te as default};
