import{_ as E}from"./Imprimer-CqTc6qE9.js";import{f as F,an as M,ap as V,o as g,c as j,b as i,a as s,q as d,z as D,j as T,av as G,ax as J,i as z,d as L,ar as O,r as n}from"./vendor-0kGcmQpG.js";import{_ as U}from"./FavorisSwitch-DD6nTfzi.js";import{u as H,s as t,S as h,a as x}from"./index-Bn9WoKhP.js";import{_ as q}from"./DataGrid-tb6QVwpZ.js";import"./ReportViewer-1Jmo7TFF.js";import"./useAgGridConfig-DjXMc6wb.js";const P={class:"flex min-w-full flex-col"},W={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},K={class:"btns flex items-center gap-2"},Q={class:"flex items-center p-2"},X={class:"p-4"},Y={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Z={style:{height:"calc(100vh - 220px)",width:"100%"}},re={__name:"RepartitionAffaireSite",setup(ee){const{showInfo:f,showError:v,showWarn:_}=H(),o=O({lecture:!1,ajout:!1,modif:!1,supp:!1,devalidation:!1,validation:!1}),b=n(),c=n(!1),p=n(1),l=n([]),S=[{label:"Janvier",value:1},{label:"Février",value:2},{label:"Mars",value:3},{label:"Avril",value:4},{label:"Mai",value:5},{label:"Juin",value:6},{label:"Juillet",value:7},{label:"Août",value:8},{label:"Septembre",value:9},{label:"Octobre",value:10},{label:"Novembre",value:11},{label:"Décembre",value:12}],u=n(),w=n(),A=a=>{w.value=a.api},y=async()=>{try{const e=(await x.post(`${t.lienApi}/verifierDroit/${t.state.dbCommun6}`,{id_utilisateur:t.userId,id_page:1405,mail:t.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;e&&Object.keys(e).length>0&&(o.lecture=e.lecture,o.ajout=e.ajout,o.modif=e.modif,o.supp=e.supp,o.devalidation=e.devalidation,o.validation=e.validation),o.lecture||(_("Vous n'avez pas le droit, veuillez consulter l'administrateur"),h("RepartitionAffaireSite"))}catch(a){v("Une erreur est survenue : "+(a.response?.data?.message||a.message))}finally{t.state.afficher_in_progress=!1}};F(async()=>{await y()});const C=async()=>{t.state.afficher_in_progress=!0;try{const a=await x.post(`${t.lienApi}/repartitionAffaireSite/${t.db}`,{Annee:t.state.annee_fiscale,Mois:p.value},{headers:{"Content-Type":"application/json"}});l.value=a.data}catch(a){v(`Une erreur est survenue lors du chargement des données: ${a.message}`)}finally{t.state.afficher_in_progress=!1}},R=()=>{if(!l.value||l.value.length===0){_("Aucune donnée à imprimer. Veuillez d'abord afficher les données.");return}c.value=!0},$=()=>{if(!u.value){f("Grille non initialisée");return}if(l.value.length===0){f("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");u.value.exportToExcel(`Repartition_Affaire_Site_${t.state.enreg_societe.Nom}_${e}.xlsx`)};return(a,e)=>{const m=D,k=U,I=G,N=J,B=E;return M((g(),j("div",P,[i("div",W,[i("div",K,[s(m,{icon:"pi pi-search",label:"Rechercher",onClick:C,text:"",loading:d(t).state.afficher_in_progress},null,8,["loading"]),s(m,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=r=>b.value?.toggle(r))}),s(I,{ref_key:"actionsMenu",ref:b,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>$()},{label:"Imprimer",icon:"pi pi-print",command:()=>R()},{label:"Favoris",icon:"pi pi-star",template:"favorisTemplate"}],popup:!0},{favorisTemplate:T(()=>[i("div",Q,[s(k,{fen:"RepartitionAffaireSite",text:"Répartition Affaire/Site"}),e[4]||(e[4]=i("span",{class:"font-semibold ml-2 text-primary"},"Favoris",-1))])]),_:1},8,["model"]),s(m,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=r=>d(h)("RepartitionAffaireSite"))})])]),i("div",X,[i("div",Y,[i("div",null,[e[5]||(e[5]=i("label",{class:"block text-sm font-medium text-gray-700 mb-1"},"Mois",-1)),s(N,{modelValue:p.value,"onUpdate:modelValue":e[2]||(e[2]=r=>p.value=r),options:S,optionLabel:"label",optionValue:"value",placeholder:"Sélectionner un mois",class:"w-full"},null,8,["modelValue"])])])]),e[6]||(e[6]=i("div",{class:"h-2"},null,-1)),i("div",Z,[s(q,{ref_key:"dataGrid",ref:u,"excel-file-name":"Repartition affaire site","excel-sheet-name":"Repartition affaire site","row-data":l.value,"numeric-columns":["Effectif","SalaireBrutImposable","Net","SalaireDeBase","JoursFerie","HeuresSupp","Ancienneté","Éléments Imposable","Éléments Non Imposable","StcEtConge"],"totals-columns":["Effectif","SalaireBrutImposable","Net","SalaireDeBase","JoursFerie","HeuresSupp","Ancienneté","Éléments Imposable","Éléments Non Imposable","StcEtConge"],"grid-style":"height: calc(100vh - 220px); width: 100%",onRowClicked:a.handleRowClick,onSelectionChanged:a.handleSelectionChanged,onGridReady:A},null,8,["row-data","onRowClicked","onSelectionChanged"])]),c.value?(g(),z(B,{key:0,show:c.value,onClose:e[3]||(e[3]=r=>c.value=!1),data:l.value,modeList:!0,RapportName:"/rh/RepartitionAffaireSite",nomFichier:`RepartitionAffaireSite_${p.value.value}_${d(t).state.annee_fiscale}`},null,8,["show","data","nomFichier"])):L("",!0)],512)),[[V,o.lecture]])}}};export{re as default};
