import{r as n,f as U,o as _,c as j,i as z,d as R,an as h,ap as N,b as l,a as i,z as T,q as O,ax as q,aw as W,F as G,e as E,ar as H}from"./vendor-BDR7yMJi.js";import{_ as J}from"./ComboDynamique-DbhbUtR4.js";import{u as K,S as M,a as y,s}from"./index-BSaHX2oa.js";import{R as Q}from"./ReportViewer-Cmd4kpyP.js";const X={class:"w-full flex flex-row items-center gap-3 mb-4"},Y={class:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-4"},Z={class:"flex flex-col gap-1"},ee={class:"flex items-center gap-2"},le="Bulletins de paie",ie={__name:"BulletinsPaie",setup(ae){const{showError:$,showWarn:v}=K(),m=n(new Date().getMonth()+1),f=n(null),b=n(null),u=n(null),d=n([]),g=n(!1),V=n(null),B=n(!1),p=n(!1),w=n(!1),k=n({Entete:[],Lignes:[]}),x=n("matricule"),I=[{label:"Par Matricule",value:"matricule"},{label:"Par N° CNSS",value:"cnss"}],r=H({lecture:!1,ajout:!1,modif:!1,supp:!1,devalidation:!1,validation:!1}),A=E(()=>u.value?`${s.lienApi}/${u.value}`:""),D=E(()=>`Bulletins_${`${m.value}_${s.state.annee_fiscale}`}`),F=async()=>{try{const e=(await y.post(`${s.lienApi}/verifierDroit/${s.state.dbCommun6}`,{id_utilisateur:s.userId,id_page:1601,mail:s.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;e&&Object.keys(e).length>0&&(r.lecture=e.lecture,r.ajout=e.ajout,r.modif=e.modif,r.supp=e.supp,r.devalidation=e.devalidation,r.validation=e.validation),r.lecture||(v("Vous n'avez pas le droit, veuillez consulter l'administrateur"),M("BulletinsPaie"))}catch(t){$("Une erreur est survenue : "+(t.response?.data?.message||t.message))}finally{s.state.afficher_in_progress=!1}},L=async()=>{try{const t=await y.post(`${s.lienApi}/affichierRapportsPourImprimer/${s.db}`,{IdClient:s.cloudId,document:le,id_societe:s.id_societe},{headers:{"Content-Type":"application/json"}});d.value=t.data.map(o=>({value:o.chemin,text:o.name.replace(".mrt","")}));const e=d.value.find(o=>o.value.includes("default_"));u.value=e?e.value:d.value.length>0?d.value[0].value:null}catch{}};U(async()=>{await F(),await L()});const P=async()=>{if(!u.value){v("Veuillez sélectionner un modèle d'impression");return}w.value=!0,s.state.afficher_in_progress=!0;try{const t={annee_fiscale:s.state.annee_fiscale,mois:m.value||0,id_departement:f.value||0,id_site:V.value||0,matricules:b.value||"",ordre:x.value||"matricule"},e=await y.post(`${s.lienApi}/imprimerBulletinsLignes/${s.db}`,t,{headers:{"Content-Type":"application/json"}});if(!e.data||e.data.length===0){v("Aucun bulletin trouvé avec les critères sélectionnés");return}let o=e.data;g.value&&(o=[...o,...o]),k.value={Entete:[],Lignes:o},p.value=!0}catch(t){$("Erreur lors de la récupération des bulletins : "+(t.response?.data?.message||t.message))}finally{w.value=!1,s.state.afficher_in_progress=!1}};return(t,e)=>{const o=T,c=J,C=q,S=W;return _(),j(G,null,[p.value?(_(),z(Q,{key:0,show:p.value,onClose:e[0]||(e[0]=a=>p.value=!1),data:k.value,isModeList:!0,urlFichier:A.value,nomFichier:D.value},null,8,["show","data","urlFichier","nomFichier"])):R("",!0),h(l("div",null,[l("div",X,[i(o,{icon:"pi pi-print",label:"Aperçu",text:"",onClick:e[1]||(e[1]=a=>P()),loading:w.value},null,8,["loading"]),i(o,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=a=>O(M)("BulletinsPaie"))})]),l("div",Y,[l("div",null,[e[10]||(e[10]=l("label",{class:"block text-sm"},"Mois",-1)),i(c,{id:"mois",modelValue:m.value,"onUpdate:modelValue":e[3]||(e[3]=a=>m.value=a),table:"MoisEnLettres",class:"w-full"},null,8,["modelValue"])]),l("div",null,[e[11]||(e[11]=l("label",{class:"block text-sm"},"Affaire",-1)),i(c,{id:"affaire",table:"affaire",modelValue:f.value,"onUpdate:modelValue":e[4]||(e[4]=a=>f.value=a),class:"w-full"},null,8,["modelValue"])]),l("div",null,[e[12]||(e[12]=l("label",{class:"block text-sm"},"Site",-1)),i(c,{id:"site",table:"site",modelValue:V.value,"onUpdate:modelValue":e[5]||(e[5]=a=>V.value=a),class:"w-full"},null,8,["modelValue"])]),l("div",null,[e[13]||(e[13]=l("label",{class:"block text-sm"},"Employé",-1)),i(c,{placeholder:"Employé",table:"employe",modelValue:b.value,"onUpdate:modelValue":e[6]||(e[6]=a=>b.value=a),class:"w-full"},null,8,["modelValue"])]),l("div",null,[e[14]||(e[14]=l("label",{class:"block text-sm"},"Modèle",-1)),i(C,{size:"small",id:"modeleImpression",modelValue:u.value,"onUpdate:modelValue":e[7]||(e[7]=a=>u.value=a),options:d.value,optionLabel:"text",optionValue:"value",class:"w-full",placeholder:"Modèle"},null,8,["modelValue","options"])]),l("div",Z,[l("div",null,[e[15]||(e[15]=l("label",{class:"block text-sm"},"Ordre",-1)),i(C,{size:"small",modelValue:x.value,"onUpdate:modelValue":e[8]||(e[8]=a=>x.value=a),options:I,optionLabel:"label",optionValue:"value",class:"w-full"},null,8,["modelValue"])]),l("div",ee,[i(S,{modelValue:g.value,"onUpdate:modelValue":e[9]||(e[9]=a=>g.value=a),inputId:"enDouble",binary:""},null,8,["modelValue"]),e[16]||(e[16]=l("label",{for:"enDouble",class:"text-sm"},"En double",-1))])])])],512),[[N,!B.value]])],64)}}};export{ie as default};
