import{_ as M}from"./Imprimer-Bot4QNbk.js";import{r as a,f as S,o as b,c as B,b as t,a as s,q as v,z as G,j as N,av as U,aw as j,i as z,d as P,F as L}from"./vendor-BDR7yMJi.js";import{_ as q}from"./ComboDynamique-DbhbUtR4.js";import{u as O,s as l,S as W,g as H,a as J}from"./index-BSaHX2oa.js";import{_ as K}from"./FavorisSwitch-DFHH_fud.js";import{_ as Q}from"./DataGrid-DbeHIyBR.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./useAgGridConfig-DxO2r97K.js";const X={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},Y={class:"btns flex items-center gap-2"},Z={class:"flex items-center p-2"},ee={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-4"},te={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4 mb-4"},oe={class:"flex items-center gap-2"},ae={style:{height:"calc(100vh - 180px)",width:"100%"}},fe={__name:"Transport",setup(se){const{showInfo:g,showError:w,showWarn:T}=O(),h=a(null),_=a(),i=a(!1),u=a(),k=a(),p=a(l.state.dossier.dated),m=a(l.state.dossier.datef),d=a(!1),c=a(""),r=a([]),D=({event:n,data:e})=>{h.value=e},V=n=>{k.value=n.api};S(()=>{});const y=async()=>{l.state.afficher_in_progress=!0;try{const n=await J.post(`${l.lienApi}/DonneesTransport/${l.db}`,{DateDebut:p.value,DateFin:m.value,IDTransporteur:c.value,ModePointage:d.value?1:0},{headers:{"Content-Type":"application/json"}});r.value=n.data}catch(n){w(`Une erreur est survenue lors de l'affichage ${n}`)}finally{l.state.afficher_in_progress=!1}},$=()=>{if(!r.value||r.value.length===0){T("Aucune donnée à imprimer. Veuillez d'abord afficher les données.");return}i.value=!0},C=()=>{if(!u.value){g("Grille non initialisée");return}if(!r.value||r.value.length===0){g("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");u.value.exportToExcel(`Transport_${l.state.enreg_societe.Nom}_${e}.xlsx`)};return(n,e)=>{const f=G,F=K,I=U,x=H,R=q,E=j,A=M;return b(),B(L,null,[t("div",X,[t("div",Y,[s(f,{icon:"pi pi-search",label:"Rechercher",onClick:y,text:"",loading:v(l).state.afficher_in_progress},null,8,["loading"]),s(f,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=o=>_.value?.toggle(o))}),s(I,{ref_key:"actionsMenu",ref:_,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>C()},{label:"Imprimer",icon:"pi pi-print",command:()=>$()},{label:"Favoris",icon:"pi pi-star",template:"favorisTemplate"}],popup:!0},{favorisTemplate:N(()=>[t("div",Z,[s(F,{fen:"Transport",text:"Transport"}),e[7]||(e[7]=t("span",{class:"font-semibold ml-2 text-primary"},"Favoris",-1))])]),_:1},8,["model"]),s(f,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=o=>v(W)("Transport"))})])]),t("div",null,[t("div",ee,[t("div",null,[e[8]||(e[8]=t("label",{class:"block text-sm"},"Date du",-1)),s(x,{size:"small",modelValue:p.value,"onUpdate:modelValue":e[2]||(e[2]=o=>p.value=o),placeholder:"Date du","input-class":"w-full"},null,8,["modelValue"])]),t("div",null,[e[9]||(e[9]=t("label",{class:"block text-sm"},"Date au",-1)),s(x,{size:"small",modelValue:m.value,"onUpdate:modelValue":e[3]||(e[3]=o=>m.value=o),placeholder:"Date au","input-class":"w-full"},null,8,["modelValue"])]),t("div",null,[e[10]||(e[10]=t("label",{class:"block text-sm"},"Transporteur",-1)),s(R,{placeholder:"Sélectionner un transporteur",modelValue:c.value,"onUpdate:modelValue":e[4]||(e[4]=o=>c.value=o),table:"Transporteur",class:"w-full"},null,8,["modelValue"])])]),t("div",te,[t("div",oe,[s(E,{modelValue:d.value,"onUpdate:modelValue":e[5]||(e[5]=o=>d.value=o),inputId:"pointage",binary:""},null,8,["modelValue"]),e[11]||(e[11]=t("label",{for:"pointage",class:"text-sm font-medium text-gray-700"},"À partir du pointage",-1))])])]),e[12]||(e[12]=t("div",{class:"h-2"},null,-1)),t("div",ae,[s(Q,{ref_key:"dataGrid",ref:u,"excel-file-name":"Transport","excel-sheet-name":"Transport","row-data":r.value,"numeric-columns":["nombre","montant"],"totals-columns":["nombre","montant"],"column-widths":{jours:120,Transporteur:250,nombre:220,montant:150},"excluded-columns":["IDTransporteur"],onRowClicked:D,onGridReady:V},null,8,["row-data"])]),i.value?(b(),z(A,{key:0,show:i.value,onClose:e[6]||(e[6]=o=>i.value=!1),data:r.value,modeList:!0,RapportName:"/transport/EtatTransport",nomFichier:`EtatTransport_${v(l).state.annee_fiscale}`},null,8,["show","data","nomFichier"])):P("",!0)],64)}}};export{fe as default};
