import{_ as B}from"./Imprimer-Bot4QNbk.js";import{_ as G}from"./ComboDynamique-DbhbUtR4.js";import{f as T,o as w,c as U,b as t,a as n,q as _,z,av as F,aP as L,M as q,i as j,d as K,r as s,e as O}from"./vendor-BDR7yMJi.js";import{_ as Q}from"./FavorisSwitch-DFHH_fud.js";import{u as W,s as o,S as H,a as J}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"},te={class:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-4"},le={style:{height:"calc(100vh - 320px)",width:"100%"}},fe={__name:"EtatAbsences",setup(ae){const{showError:$,showWarn:p}=W(),f=s(),i=s([]),y=s(null),V=["Matricule","Nom","Prenom","Affaire","Site","Qualification"],E={Matricule:120,Nom:150,Prenom:150,Affaire:250,Site:150,Qualification:200},x=s(null),u=s(!1),v=s(""),c=s(""),m=s(null),d=s(null),S=new Date().getMonth()+1,r=s(S),A=O(()=>[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>I()},{label:"Imprimer",icon:"pi pi-print",command:()=>M()}]);T(async()=>{});const h=async()=>{o.state.afficher_in_progress=!0,c.value="",m.value&&(c.value+=` and Employe.Id_departemet= '${m.value}'`),d.value&&(c.value+=` and Employe.Id_site= '${d.value}'`);try{const a=await J.post(`${o.lienApi}/Etatdesabsences/${o.db}`,{condition1:c.value,annee:o.state.annee_fiscale,mois:r.value,rechercheString:v.value},{headers:{"Content-Type":"application/json"}});i.value=a.data}catch(a){const e=a.response?.data?.message||a.message;$(`Une erreur est survenue : ${e}`)}finally{o.state.afficher_in_progress=!1}},M=()=>{if(!i.value||i.value.length===0){p("Aucune donnée à imprimer. Veuillez d'abord afficher les données.");return}u.value=!0},k=()=>{},C=({selectedRows:a})=>{a&&a.length>0&&(y.value=a[0])},I=()=>{if(!f.value){p("Grille non initialisée");return}if(!i.value||i.value.length===0){p("Aucune donnée à exporter. Veuillez d'abord afficher les données.");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");f.value.exportToExcel(`État des absences_${o.state.enreg_societe.Nom}_Mois_${r.value}_${e}.xlsx`)};return(a,e)=>{const g=z,P=F,N=Q,D=q,b=G,R=B;return w(),U("div",null,[t("div",Y,[t("div",Z,[n(g,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=l=>h()),text:"",loading:_(o).state.afficher_in_progress},null,8,["loading"]),n(g,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=l=>x.value.toggle(l))}),n(P,{ref_key:"actionsMenu",ref:x,model:A.value,popup:!0},null,8,["model"]),n(g,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=l=>_(H)("EtatAbsences"))})]),t("div",ee,[n(N,{fen:"EtatAbsences",text:"État des Absences"})])]),t("div",null,[t("div",te,[t("div",null,[e[9]||(e[9]=t("label",{class:"block text-sm"},"Recherche",-1)),n(D,{size:"small",modelValue:v.value,"onUpdate:modelValue":e[3]||(e[3]=l=>v.value=l),placeholder:"Rechercher dans les états d'absences...",class:"w-full",onKeyup:e[4]||(e[4]=L(l=>h(),["enter"]))},null,8,["modelValue"])]),t("div",null,[e[10]||(e[10]=t("label",{class:"block text-sm"},"Mois",-1)),n(b,{modelValue:r.value,"onUpdate:modelValue":e[5]||(e[5]=l=>r.value=l),table:"MoisEnLettres",class:"w-full"},null,8,["modelValue"])]),t("div",null,[e[11]||(e[11]=t("label",{class:"block text-sm"},"Affaire",-1)),n(b,{modelValue:m.value,"onUpdate:modelValue":e[6]||(e[6]=l=>m.value=l),table:"affaire",placeholder:"Sélectionner une affaire",class:"w-full"},null,8,["modelValue"])]),t("div",null,[e[12]||(e[12]=t("label",{class:"block text-sm"},"Site",-1)),n(b,{modelValue:d.value,"onUpdate:modelValue":e[7]||(e[7]=l=>d.value=l),table:"site",placeholder:"Sélectionner un site",class:"w-full"},null,8,["modelValue"])])])]),e[13]||(e[13]=t("div",{class:"h-2"},null,-1)),t("div",le,[n(X,{ref_key:"agGrid",ref:f,"excel-file-name":"Etat absences","excel-sheet-name":"Etat absences","row-data":i.value,"column-widths":E,"column-order":V,"enable-totals":!1,onGridReady:k,onSelectionChanged:C},null,8,["row-data"])]),u.value?(w(),j(R,{key:0,show:u.value,onClose:e[8]||(e[8]=l=>u.value=!1),data:i.value,modeList:!0,RapportName:"/classique/paie/PaieEtatAbsences",nomFichier:`EtatAbsences_${r.value.value}_${_(o).state.annee_fiscale}`},null,8,["show","data","nomFichier"])):K("",!0)])}}};export{fe as default};
