import{_ as D}from"./Imprimer-CqTc6qE9.js";import{_ as E}from"./ComboDynamique-CzrtYPe1.js";import{_ as N}from"./FavorisSwitch-DD6nTfzi.js";import{f as T,o as h,c as j,b as a,a as n,q as _,z as I,av as J,i as B,d as G,F as q,r as t}from"./vendor-0kGcmQpG.js";import{_ as U,u as z,s,S as L,a as O}from"./index-Bn9WoKhP.js";import{_ as W}from"./DataGrid-tb6QVwpZ.js";import"./ReportViewer-1Jmo7TFF.js";import"./useAgGridConfig-DjXMc6wb.js";const H={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 gap-3 whitespace-nowrap ml-auto"},X={class:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-4"},Y={style:{height:"calc(100vh - 220px)",width:"100%"}},Z={__name:"FicheAnnuellePaie",setup(ee){const{showError:x,showWarn:c}=z(),g=t(),w=t(null),A=t(null),r=t(!1),i=t([]),b=t({}),u=t(),F=t(),y=({row:l})=>{w.value=l},k=l=>{F.value=l.api},V=l=>{const e=[];return l.colDef.type==="numericColumn"&&e.push("ag-right-aligned-cell"),l.colDef.field==="Total"&&e.push("bold-cell"),e.join(" ")},m=t(""),p=t(""),d=t("");T(()=>{});const $=async()=>{s.state.afficher_in_progress=!0;try{const l=await O.post(`${s.lienApi}/FicheAnnuellePaie/${s.db}`,{employe:m.value||"",annee_fiscale:s.state.annee_fiscale,affaire:p.value||"",site:d.value||""},{headers:{"Content-Type":"application/json"}});i.value=l.data}catch(l){const e=l.response?.data?.message||l.message;x(`Une erreur est survenue : ${e}`)}finally{s.state.afficher_in_progress=!1}},C=()=>{if(!i.value||i.value.length===0){c("Aucune donnée à imprimer. Veuillez d'abord afficher les données.");return}b.value={Entete:i.value,Annee:s.state.annee_fiscale.toString()},r.value=!0},P=()=>{if(!u.value){c("Grille non initialisée");return}if(i.value.length===0){c("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");u.value.exportToExcel(`FicheAnnuellePaie_${s.state.enreg_societe.Nom}_${e}.xlsx`)};return(l,e)=>{const f=I,R=J,S=N,v=E,M=D;return h(),j(q,null,[a("div",H,[a("div",K,[n(f,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=o=>$()),text:"",loading:_(s).state.afficher_in_progress},null,8,["loading"]),n(f,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=o=>g.value.toggle(o))}),n(R,{ref_key:"actionsMenu",ref:g,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>P()},{label:"Imprimer",icon:"pi pi-print",command:()=>C()}],popup:!0},null,8,["model"]),n(f,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=o=>_(L)("FicheAnnuellePaie"))})]),a("div",Q,[n(S,{fen:"FicheAnnuellePaie",text:"Fiche Annuelle de Paie"})])]),a("div",X,[a("div",null,[e[7]||(e[7]=a("label",{class:"block text-sm"},"Employé",-1)),n(v,{placeholder:"Employé",table:"employe",modelValue:m.value,"onUpdate:modelValue":e[3]||(e[3]=o=>m.value=o),class:"w-full"},null,8,["modelValue"])]),a("div",null,[e[8]||(e[8]=a("label",{class:"block text-sm"},"Affaire",-1)),n(v,{placeholder:"Affaire",table:"affaire",modelValue:p.value,"onUpdate:modelValue":e[4]||(e[4]=o=>p.value=o),class:"w-full"},null,8,["modelValue"])]),a("div",null,[e[9]||(e[9]=a("label",{class:"block text-sm"},"Site",-1)),n(v,{placeholder:"Site",table:"site",modelValue:d.value,"onUpdate:modelValue":e[5]||(e[5]=o=>d.value=o),class:"w-full"},null,8,["modelValue"])])]),e[10]||(e[10]=a("div",{class:"h-2"},null,-1)),a("div",Y,[n(W,{ref_key:"dataGrid",ref:u,"excel-file-name":"Fiche annuelle paie","excel-sheet-name":"Fiche annuelle paie","row-data":i.value,"column-widths":{Rubrique:100,Description:300,janvier:90,Fevrier:90,Mars:90,Avril:90,Mai:90,Juin:90,Juillet:90,Aout:90,Septembre:90,octobre:90,Novembre:90,Decembre:90,Total:90},"numeric-columns":["janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","octobre","Novembre","Decembre","Total"],"enable-totals":!1,"totals-columns":["janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","octobre","Novembre","Decembre","Total"],"get-cell-class":V,onRowClicked:y,onGridReady:k},null,8,["row-data"])]),r.value?(h(),B(M,{key:0,show:r.value,onClose:e[6]||(e[6]=o=>r.value=!1),Response:A.value,data:b.value,RapportName:"/classique/paie/FicheAnnuellePaie",nomFichier:`FicheAnnuellePaie_${_(s).state.annee_fiscale}`},null,8,["show","Response","data","nomFichier"])):G("",!0)],64)}}},ce=U(Z,[["__scopeId","data-v-5c5d1152"]]);export{ce as default};
