import{_ as G}from"./Imprimer-Bot4QNbk.js";import{_ as F}from"./ComboDynamique-DbhbUtR4.js";import{f as N,o as g,c as B,b as t,a as s,q as x,z as U,av as q,ax as z,i as J,d as P,F as j,r as a}from"./vendor-BDR7yMJi.js";import{_ as O}from"./FavorisSwitch-DFHH_fud.js";import{_ as W,u as H,s as n,S as K,a as Q}from"./index-BSaHX2oa.js";import{_ as X}from"./DataGrid-DbeHIyBR.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./useAgGridConfig-DxO2r97K.js";const Y={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},Z={class:"btns flex items-center gap-2"},ee={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},le={class:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-4"},te={style:{height:"calc(100vh - 220px)",width:"100%"}},ae={__name:"EtatResumeCharges",setup(oe){const{showError:w,showWarn:h,showInfo:v}=H(),_=a(),p=a(),R=a(),i=a([]),C=a(null),M=a(null),E=({row:l})=>{C.value=l},k=l=>{R.value=l.api},V=l=>l.data&&(l.data.Libelle&&l.data.Libelle.includes("Sous total")||l.data.Libelle&&l.data.Libelle.includes("Total Général"))?"row-total":"",r=a(""),u=a(""),c=a(""),d=a("1"),m=a(!1),$=[{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"}];N(()=>{});const S=async()=>{n.state.afficher_in_progress=!0;try{r.value="",u.value>0&&(r.value=" and c.Id_Departement="+u.value),c.value>0&&(r.value+=" and c.Id_site="+c.value);const l=await Q.post(`${n.lienApi}/EtatResumeDesCharges/${n.db}`,{annee_fiscale:n.state.annee_fiscale,combo_Mois:d.value,condition1:r.value},{headers:{"Content-Type":"application/json"}});i.value=l.data}catch(l){const e=l.response?.data?.message||l.message;w(`Une erreur est survenue : ${e}`)}finally{n.state.afficher_in_progress=!1}},y=()=>{if(!i.value||i.value.length===0){h("Aucune donnée à imprimer. Veuillez d'abord afficher les données.");return}m.value=!0},A=()=>{if(!p.value){v("Grille non initialisée");return}if(i.value.length===0){v("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");p.value.exportToExcel(`EtatResumeCharges_${n.state.enreg_societe.Nom}_Mois_${d.value}_${e}.xlsx`)};return(l,e)=>{const f=U,D=q,I=O,T=z,b=F,L=G;return g(),B(j,null,[t("div",Y,[t("div",Z,[s(f,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=o=>S()),text:"",loading:x(n).state.afficher_in_progress},null,8,["loading"]),s(f,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=o=>_.value?.toggle(o))}),s(D,{ref_key:"actionsMenu",ref:_,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>A()},{label:"Imprimer",icon:"pi pi-print",command:()=>y()}],popup:!0},null,8,["model"]),s(f,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=o=>x(K)("EtatResumeCharges"))})]),t("div",ee,[s(I,{fen:"EtatResumeCharges",text:"État Résumé des Charges"})])]),t("div",null,[t("div",le,[t("div",null,[e[7]||(e[7]=t("label",{class:"block text-sm"},"Période",-1)),s(T,{size:"small",modelValue:d.value,"onUpdate:modelValue":e[3]||(e[3]=o=>d.value=o),options:$,optionLabel:"libelle",optionValue:"id",placeholder:"Sélectionner une période",class:"w-full"},null,8,["modelValue"])]),t("div",null,[e[8]||(e[8]=t("label",{class:"block text-sm"},"Affaire",-1)),s(b,{placeholder:"Sélectionner une affaire",table:"affaire",modelValue:u.value,"onUpdate:modelValue":e[4]||(e[4]=o=>u.value=o),class:"w-full"},null,8,["modelValue"])]),t("div",null,[e[9]||(e[9]=t("label",{class:"block text-sm"},"Site",-1)),s(b,{placeholder:"Sélectionner un site",table:"site",modelValue:c.value,"onUpdate:modelValue":e[5]||(e[5]=o=>c.value=o),class:"w-full"},null,8,["modelValue"])])])]),e[10]||(e[10]=t("div",{class:"h-2"},null,-1)),t("div",te,[s(X,{ref_key:"dataGrid",ref:p,"excel-file-name":"Etat resume charges","excel-sheet-name":"Etat resume charges","row-data":i.value,"excluded-columns":["GID"],"column-widths":{Code:120,Libelle:200,Montant_salariale:150,Montant_patronale:150,Montant_global:150},"numeric-columns":["Montant_salariale","Montant_patronale","Montant_global"],"enable-totals":!0,"totals-columns":["Montant_salariale","Montant_patronale","Montant_global"],"get-row-class":V,onRowClicked:E,onGridReady:k},null,8,["row-data"])]),m.value?(g(),J(L,{key:0,show:m.value,onClose:e[6]||(e[6]=o=>m.value=!1),Response:M.value,data:i.value,RapportName:"/classique/paie/EtatResumeDesCharges",nomFichier:"EtatResumeDesCharges"},null,8,["show","Response","data"])):P("",!0)],64)}}},fe=W(ae,[["__scopeId","data-v-63a0860e"]]);export{fe as default};
