import{_ as A}from"./Imprimer-Bot4QNbk.js";import{f as B,o as S,c as D,b as l,a,q as g,z as G,av as j,ax as F,i as P,d as z,F as J,r as o}from"./vendor-BDR7yMJi.js";import{_ as O}from"./FavorisSwitch-DFHH_fud.js";import{_ as U,u as q,s as n,S as W,a as H}from"./index-BSaHX2oa.js";import{_ as K}from"./DataGrid-DbeHIyBR.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./useAgGridConfig-DxO2r97K.js";const Q={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},X={class:"btns flex items-center gap-2 py-2"},Y={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},Z={class:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-4"},ee={style:{height:"calc(100vh - 220px)",width:"100%"}},te={__name:"EtatCNSS",setup(le){const{showWarn:m,showError:I}=q(),f=o(),c=o(!1),x=o(null),b=o({}),w=o(null),u=o(),L=o(),h=new Date().getMonth()+1,d=o([]),C=[{Id:"0",Libelle:"----"},{Id:"1",Libelle:"Affaire"},{Id:"2",Libelle:"Service"},{Id:"3",Libelle:"Site"}],p=o("0"),_=[{Id:"1",Libelle:"Janvier"},{Id:"2",Libelle:"Février"},{Id:"3",Libelle:"Mars"},{Id:"4",Libelle:"Avril"},{Id:"5",Libelle:"Mai"},{Id:"6",Libelle:"Juin"},{Id:"7",Libelle:"Juillet"},{Id:"8",Libelle:"Août"},{Id:"9",Libelle:"Septembre"},{Id:"10",Libelle:"Octobre"},{Id:"11",Libelle:"Novembre"},{Id:"12",Libelle:"Décembre"},{Id:"1,2,3",Libelle:"Trimestre 1"},{Id:"4,5,6",Libelle:"Trimestre 2"},{Id:"7,8,9",Libelle:"Trimestre 3"},{Id:"10,11,12",Libelle:"Trimestre 4"},{Id:"1,2,3,4,5,6,7,8,9,10,11,12",Libelle:"Annuelle"}],i=o(`${h}`),N=({row:t})=>{w.value=t},$=t=>{L.value=t.api},M=t=>t.data&&(t.data.Nom&&t.data.Nom.includes("Sous total")||t.data.Nom&&t.data.Nom.includes("Total General"))?"row-total":"";B(()=>{});const E=async()=>{n.state.afficher_in_progress=!0;try{const t=await H.post(`${n.lienApi}/EtatCNSS/${n.db}`,{Combo_Mois:i.value,annee_fiscale:n.state.annee_fiscale,Combo_Sous_total_par:p.value},{headers:{"Content-Type":"application/json"}});d.value=t.data}catch(t){const e=t.response?.data?.message||t.message;I(`Une erreur est survenue : ${e}`)}finally{n.state.afficher_in_progress=!1}},k=()=>{const t=_.find(r=>r.Id===i.value),e=t?t.Libelle:i.value;b.value={Entete:d.value,Periode:`${e} ${n.state.annee_fiscale}`},c.value=!0},y=()=>{if(!u.value){m("Grille non initialisée");return}if(d.value.length===0){m("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");u.value.exportToExcel(`État de CNSS_${n.state.enreg_societe.Nom}_Mois_${i.value}_${e}.xlsx`)};return(t,e)=>{const r=G,T=j,R=O,v=F,V=A;return S(),D(J,null,[l("div",Q,[l("div",X,[a(r,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=s=>E()),text:"",loading:g(n).state.afficher_in_progress},null,8,["loading"]),a(r,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=s=>f.value.toggle(s))}),a(T,{ref_key:"actionsMenu",ref:f,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>y()},{label:"Imprimer",icon:"pi pi-print",command:()=>k()}],popup:!0},null,8,["model"]),a(r,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=s=>g(W)("EtatCNSS"))})]),l("div",Y,[a(R,{fen:"EtatCNSS",text:"État CNSS"})])]),l("div",Z,[l("div",null,[e[6]||(e[6]=l("label",{class:"block text-sm"},"Mois / Trimestre",-1)),a(v,{size:"small",modelValue:i.value,"onUpdate:modelValue":e[3]||(e[3]=s=>i.value=s),options:_,optionLabel:"Libelle",optionValue:"Id",placeholder:"Mois / Trimestre",class:"w-full"},null,8,["modelValue"])]),l("div",null,[e[7]||(e[7]=l("label",{class:"block text-sm"},"Sous total par",-1)),a(v,{size:"small",modelValue:p.value,"onUpdate:modelValue":e[4]||(e[4]=s=>p.value=s),options:C,optionLabel:"Libelle",optionValue:"Id",placeholder:"Sous total par",class:"w-full"},null,8,["modelValue"])])]),e[8]||(e[8]=l("div",{class:"h-2"},null,-1)),l("div",ee,[a(K,{ref_key:"dataGrid",ref:u,"excel-file-name":"Etat CNSS","excel-sheet-name":"Etat CNSS","row-data":d.value,"excluded-columns":["GID"],"column-widths":{Matricule:120,Nom:200,cnss:140,jours:100,SBI:180,brut_plafond:120,cnss_sal:130,cnss_pat:130},"numeric-columns":["jours","SBI","brut_plafond","cnss_sal","cnss_pat"],"enable-totals":!0,"totals-columns":["jours","SBI","brut_plafond","cnss_sal","cnss_pat"],"get-row-class":M,onRowClicked:N,onGridReady:$,"grid-style":"height: calc(100vh - 220px); width: 100%","show-checkbox":!1},null,8,["row-data"])]),c.value?(S(),P(V,{key:0,show:c.value,onClose:e[5]||(e[5]=s=>c.value=!1),Response:x.value,data:b.value,RapportName:"/classique/paie/EtatDeCNSS",nomFichier:"EtatCNSS"},null,8,["show","Response","data"])):z("",!0)],64)}}},pe=U(te,[["__scopeId","data-v-bc7370f2"]]);export{pe as default};
