import{_ as W}from"./Imprimer-CqTc6qE9.js";import{b1 as H,f as K,o as I,c as Q,b as t,a as s,q as S,z as X,av as Y,ax as Z,i as ee,d as le,F as te,r as a,e as oe}from"./vendor-0kGcmQpG.js";import{_ as ae}from"./ComboDynamique-CzrtYPe1.js";import{_ as se}from"./FavorisSwitch-DD6nTfzi.js";import{u as ne,a as h,s as n,S as D,h as ie,m as re,A as ue}from"./index-Bn9WoKhP.js";import{_ as ce}from"./DataGrid-tb6QVwpZ.js";import"./ReportViewer-1Jmo7TFF.js";import"./useAgGridConfig-DjXMc6wb.js";const de={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},me={class:"btns flex items-center gap-2"},pe={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},ve={class:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-4 mb-4"},fe={class:"col-span-2"},be={style:{height:"calc(100vh - 260px)",width:"100%"}},Se={__name:"ReleveClientGlobal",setup(ge){const{showError:C,showInfo:R,showWarn:$}=ne(),u=a(!1),k=a({}),c=a([]),p=a(),d=a(),r=a(""),v=a(0),f=a("Actif"),b=a(0),g=a(0),T=a(0),_=a(2),G=[{Id:0,Libelle:"Tous"},{Id:1,Libelle:"Soldé"},{Id:2,Libelle:"Non Soldé"}],A=[{Id:"",Libelle:"----"},{Id:"Actif",Libelle:"Actif"},{Id:"En sommeil",Libelle:"En sommeil"}],L=a(0),N=oe(()=>["Report","Debit","Credit","Solde"]),z=()=>l=>{if(l.value===null||l.value===void 0||l.value===""||l.value==="null")return"";const e=parseFloat(l.value);if(isNaN(e))return"";const i=ie(e);return l.node.rowPinned?`<span style="font-weight: 600;">${i}</span>`:e>=0?`<span style="color: #16a34a; font-weight: bold;">${i}</span>`:`<span style="color: #dc2626; font-weight: bold;">${i}</span>`},w=a(""),E=({event:l,ndoc:e,rowIndex:i})=>{r.value=e,w.value=e,x.value=i,B()},U=({selectedRows:l})=>{},F=l=>{d.value=l.api},x=a(-1);H(()=>{d.value&&x.value>=0&&setTimeout(()=>{w.value&&d.value.forEachNode(l=>{l.data?.code_client===w.value&&l.setSelected(!0,!1,!0)}),d.value.ensureIndexVisible(x.value,"middle")},50)}),K(async()=>{await P(),await V()});const P=async()=>{try{const e=(await h.post(`${n.lienApi}/verifierDroit/${n.state.dbCommun6}`,{id_utilisateur:n.userId,id_page:410,mail:n.state.userCloud.mail})).data;e&&Object.keys(e).length>0&&(e.lecture||($("Vous n'avez pas le droit, veuillez consulter l'administrateur"),D("ReleveClientGlobal")))}catch(l){C("Une erreur s'est produite lors de la vérification des droits."+l)}},V=async()=>{n.state.afficher_in_progress=!0;try{const{data:l}=await h.post(`${n.lienApi}/ReleveClientGlobal/${n.db}`,{maDate:`${n.state.annee_fiscale}0101`,echu:L.value,isSolde:_.value,code_client:r.value,IDfamille_client:g.value,IDville:v.value,ID_representant:T.value,IDcommercial:b.value,Comercial_par:n.state.enreg_option_comm.Comercial_par,typeClient:f.value},{headers:{"Content-Type":"application/json"}});c.value=l}catch(l){const e=l.response?.data?.message||l.message;C(`Une erreur est survenue : 
 ${e}`)}finally{n.state.afficher_in_progress=!1}},B=async()=>{const l=await re.ReleveClientParDate();ue({id:"ReleveClientParDate",text:`Relevé client par date : ${r.value}`,content:l.default,props:{code_client:r,ParamJusteNonSolde:!0,fermerParRetour:!0}})},M=()=>{u.value=!0},j=()=>{if(!p.value){R("Grille non initialisée");return}if(c.value.length===0){R("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");p.value.exportToExcel(`Releve Client Global_${n.state.enreg_societe.Nom}_${e}.xlsx`)};return(l,e)=>{const i=X,q=Y,O=se,m=ae,y=Z,J=W;return I(),Q(te,null,[t("div",de,[t("div",me,[s(i,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=o=>V()),text:"",loading:S(n).state.afficher_in_progress},null,8,["loading"]),s(i,{label:"Actions",icon:"pi pi-cog",onClick:e[1]||(e[1]=o=>l.$refs.actionsMenu.toggle(o)),text:""}),s(q,{ref:"actionsMenu",model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:j},{label:"Imprimer",icon:"pi pi-print",command:M}],popup:!0},null,8,["model"]),s(i,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=()=>S(D)("ReleveClientGlobal"))})]),t("div",pe,[s(O,{fen:"ReleveClientGlobal",text:"Releve Client Global"})])]),t("div",null,[t("div",ve,[t("div",fe,[e[10]||(e[10]=t("label",{class:"block text-sm"},"Client",-1)),s(m,{modelValue:r.value,"onUpdate:modelValue":e[3]||(e[3]=o=>r.value=o),placeholder:"Tous les clients",table:"client",class:"w-full",size:"small"},null,8,["modelValue"])]),t("div",null,[e[11]||(e[11]=t("label",{class:"block text-sm"},"Situation",-1)),s(y,{size:"small",modelValue:_.value,"onUpdate:modelValue":e[4]||(e[4]=o=>_.value=o),placeholder:"Situation",options:G,optionLabel:"Libelle",optionValue:"Id",class:"w-full"},null,8,["modelValue"])]),t("div",null,[e[12]||(e[12]=t("label",{class:"block text-sm"},"Famille client",-1)),s(m,{modelValue:g.value,"onUpdate:modelValue":e[5]||(e[5]=o=>g.value=o),placeholder:"Toutes",table:"famille_client",class:"w-full",size:"small"},null,8,["modelValue"])]),t("div",null,[e[13]||(e[13]=t("label",{class:"block text-sm"},"Ville",-1)),s(m,{modelValue:v.value,"onUpdate:modelValue":e[6]||(e[6]=o=>v.value=o),placeholder:"Toutes",table:"ville",class:"w-full",size:"small"},null,8,["modelValue"])]),t("div",null,[e[14]||(e[14]=t("label",{class:"block text-sm"},"Commercial",-1)),s(m,{modelValue:b.value,"onUpdate:modelValue":e[7]||(e[7]=o=>b.value=o),placeholder:"Tous",table:"commercial",class:"w-full",size:"small"},null,8,["modelValue"])]),t("div",null,[e[15]||(e[15]=t("label",{class:"block text-sm"},"Type client",-1)),s(y,{size:"small",modelValue:f.value,"onUpdate:modelValue":e[8]||(e[8]=o=>f.value=o),placeholder:"Type",options:A,optionLabel:"Libelle",optionValue:"Id",class:"w-full"},null,8,["modelValue"])])])]),e[16]||(e[16]=t("div",{class:"h-2"},null,-1)),t("div",be,[s(ce,{ref_key:"dataGrid",ref:p,"excel-file-name":"Releve client global","excel-sheet-name":"Releve client global","row-data":c.value,"document-number-fields":["code_client"],"excluded-columns":[],"enable-totals":!0,"numeric-columns":N.value,"totals-columns":["Report","Debit","Credit","Solde"],"column-widths":{nom:350,mail:250},"custom-renderers":{Solde:z()},"column-order":["code_client","nom","Report","Debit","Credit","Solde","tel","gsm","mail","Ville"],"show-checkbox":!1,onRowClicked:E,onSelectionChanged:U,onGridReady:F},null,8,["row-data","numeric-columns","custom-renderers"])]),u.value?(I(),ee(J,{key:0,show:u.value,onClose:e[9]||(e[9]=o=>u.value=!1),Response:k.value,data:c.value,RapportName:"/classique/commercial/ReleveClientGlobal"},null,8,["show","Response","data"])):le("",!0)],64)}}};export{Se as default};
