import{_ as C}from"./Imprimer-Bot4QNbk.js";import{o as _,c as I,b as l,a as s,z as D,av as q,q as x,aw as P,i as B,d as F,F as G,r as o}from"./vendor-BDR7yMJi.js";import{_ as T}from"./ComboDynamique-DbhbUtR4.js";import{u as U,S as L,s as i,a as j}from"./index-BSaHX2oa.js";import{_ as z}from"./DataGrid-DbeHIyBR.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./useAgGridConfig-DxO2r97K.js";const O={class:"flex min-w-full flex-col lg:flex-row lg:items-center gap-2 p-1"},W={class:"btns flex items-center gap-2 lg:w-1/4 lg:justify-start lg:ml-0"},H={class:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-4"},J={class:"flex items-center gap-2 pt-5"},K={style:{height:"calc(100vh - 220px)",width:"100%"}},se={__name:"Suividesprets",setup(Q){const{showError:b,showWarn:w,showInfo:d}=U(),f=o(),u=o(null),h=o(null),p=o(""),y=o("0"),m=o("0"),n=o([]),v=o({}),r=o(!1),S=o(null),k=({row:t})=>{},M=t=>{h.value=t.api},V=async()=>{i.state.afficher_in_progress=!0;try{const t=await j.post(`${i.lienApi}/SuiviPrets/${i.db}`,{Matricule:p.value,IdDepartement:y.value,NonSolde:m.value},{headers:{"Content-Type":"application/json"}});n.value=t.data||[]}catch(t){const e=t.response?.data?.message||t.message;b(`Une erreur est survenue : ${e}`)}finally{i.state.afficher_in_progress=!1}},R=()=>{if(!n.value||n.value.length===0){w("Aucune donnée à imprimer. Veuillez d'abord afficher les données.");return}v.value={Entete:n.value},r.value=!0},$=()=>{if(!u.value){d("Grille non initialisée");return}if(n.value.length===0){d("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");u.value.exportToExcel(`Suivi des prêts_${i.state.enreg_societe.Nom}_${e}.xlsx`)};return(t,e)=>{const c=D,E=q,g=T,N=P,A=C;return _(),I(G,null,[l("div",O,[l("div",W,[s(c,{icon:"pi pi-refresh",label:"Afficher",text:"",onClick:V}),s(c,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=a=>f.value.toggle(a))}),s(E,{ref_key:"actionsMenu",ref:f,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>$()},{label:"Imprimer",icon:"pi pi-print",command:()=>R()}],popup:!0},null,8,["model"]),s(c,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=a=>x(L)("Suividesprets"))})])]),l("div",H,[l("div",null,[e[6]||(e[6]=l("label",{class:"block text-sm"},"Employé",-1)),s(g,{placeholder:"Employé",table:"employe",modelValue:p.value,"onUpdate:modelValue":e[2]||(e[2]=a=>p.value=a),class:"w-full"},null,8,["modelValue"])]),l("div",null,[e[7]||(e[7]=l("label",{class:"block text-sm"},"Affaire",-1)),s(g,{placeholder:"Affaire",table:"affaire",modelValue:t.ParamAffaire,"onUpdate:modelValue":e[3]||(e[3]=a=>t.ParamAffaire=a),class:"w-full"},null,8,["modelValue"])]),l("div",J,[s(N,{modelValue:m.value,"onUpdate:modelValue":e[4]||(e[4]=a=>m.value=a),inputId:"NonSolde",binary:""},null,8,["modelValue"]),e[8]||(e[8]=l("label",{for:"NonSolde",class:"text-sm"},"Non soldés",-1))])]),e[9]||(e[9]=l("div",{class:"h-2"},null,-1)),l("div",K,[s(z,{ref_key:"dataGrid",ref:u,"excel-file-name":"Suivi des prets","excel-sheet-name":"Suivi des prets","row-data":n.value,"column-widths":{Matricule:100,Nom:130,Prenom:130,Libelle:180,Date:110,Montant:120,Montant_Ech:130,Reliquat:120},"numeric-columns":["Montant","Montant_Ech","Reliquat"],"date-columns":["Date"],"date-only":["Date"],"enable-totals":!0,"totals-columns":["Montant","Montant_Ech","Reliquat"],onRowClicked:k,onGridReady:M},null,8,["row-data"])]),r.value?(_(),B(A,{key:0,show:r.value,onClose:e[5]||(e[5]=a=>r.value=!1),Response:S.value,data:v.value,RapportName:"/classique/paie/SuiviPrets",nomFichier:`SuiviPrets_${x(i).state.annee_fiscale}`},null,8,["show","Response","data","nomFichier"])):F("",!0)],64)}}};export{se as default};
