import{_ as $}from"./FavorisSwitch-DFHH_fud.js";import{f as k,o as D,c as T,b as t,a as s,z as S,q as r,j as u,aN as v,aA as B,aB as g,B as V,aC as z,aO as H,F,r as f,e as E}from"./vendor-BDR7yMJi.js";import{_ as P,S as N,g as _,h as m,s as p,a as I,k as x}from"./index-BSaHX2oa.js";const R={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},j={class:"btns flex items-center gap-2"},M={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},O={class:"p-4"},U={class:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4"},W={class:"p-2 h-full"},q={class:"border rounded p-2 bg-white h-full"},L={class:"font-semibold"},Y={class:"p-2 h-full"},Z={class:"border rounded p-4 bg-white h-full"},G={__name:"CAParTrancheHoraire",setup(J){const i=f(new Date),d=f(new Date),h=f(!1),l=f([]),b=()=>{const a=[];for(let e=0;e<24;e++){const o=e.toString().padStart(2,"0"),c=(e+1).toString().padStart(2,"0");a.push({Tranche:`${o} - ${c}`,heure:e,ca:0})}return a};l.value=b();const w=async()=>{if(!i.value||!d.value){p.commit("showWarn","Veuillez selectionner une periode");return}h.value=!0;try{l.value=b();const a=await I.post(`${p.lienApi}/CAParTrancheHoraire/${p.db}`,{dateDu:x(i.value),dateAu:x(d.value)});a.data&&Array.isArray(a.data)&&a.data.forEach(e=>{const o=l.value.findIndex(c=>c.heure===e.heur);o!==-1&&(l.value[o].ca=e.ca||0)})}catch{p.commit("showError","Erreur lors du chargement des donnees")}finally{h.value=!1}},C=a=>a.ca>0?"bg-blue-50":"",y=E(()=>({labels:l.value.map(a=>a.Tranche),datasets:[{label:"Chiffre d'affaire",data:l.value.map(a=>a.ca),fill:!0,borderColor:"#8b5cf6",backgroundColor:"rgba(139, 92, 246, 0.2)",tension:.4,pointRadius:5,pointHoverRadius:7,pointBackgroundColor:"#8b5cf6",pointBorderColor:"#fff",pointBorderWidth:2}]})),A=f({responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!0,position:"top"},tooltip:{callbacks:{label:function(a){return`CA: ${m(a.parsed.y)}`}}}},scales:{y:{beginAtZero:!0,ticks:{callback:function(a){return m(a)}}},x:{grid:{display:!0}}}});return k(()=>{const a=new Date;i.value=new Date(a.getFullYear(),a.getMonth(),1),d.value=a}),(a,e)=>{const o=S,c=$;return D(),T(F,null,[t("div",R,[t("div",j,[s(o,{icon:"pi pi-search",label:"Afficher",onClick:e[0]||(e[0]=n=>w()),text:"",loading:h.value},null,8,["loading"]),s(o,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=n=>r(N)("CAParTrancheHoraire"))})]),t("div",M,[s(c,{fen:"CAParTrancheHoraire",text:"Chiffre d'affaire par tranche horaire"})])]),t("div",O,[t("div",U,[t("div",null,[e[4]||(e[4]=t("label",{class:"block text-sm mb-1"},"Du",-1)),s(_,{modelValue:i.value,"onUpdate:modelValue":e[2]||(e[2]=n=>i.value=n),"input-class":"w-full"},null,8,["modelValue"])]),t("div",null,[e[5]||(e[5]=t("label",{class:"block text-sm mb-1"},"Au",-1)),s(_,{modelValue:d.value,"onUpdate:modelValue":e[3]||(e[3]=n=>d.value=n),"input-class":"w-full"},null,8,["modelValue"])])])]),s(r(H),{style:{height:"calc(100vh - 200px)"}},{default:u(()=>[s(r(v),{size:35,minSize:20},{default:u(()=>[t("div",W,[t("div",q,[e[6]||(e[6]=t("h3",{class:"text-lg font-semibold mb-3"},"Chiffre d'affaire par tranche horaire",-1)),s(r(B),{value:l.value,scrollable:"",scrollHeight:"flex",size:"small",class:"text-sm",rowClass:C},{default:u(()=>[s(r(g),{field:"Tranche",header:"Tranche",style:{width:"150px"}}),s(r(g),{field:"ca",header:"Chiffre d'affaire",style:{width:"150px"}},{body:u(n=>[t("span",L,V(r(m)(n.data.ca)),1)]),_:1})]),_:1},8,["value"])])])]),_:1}),s(r(v),{size:65,minSize:40},{default:u(()=>[t("div",Y,[t("div",Z,[e[7]||(e[7]=t("h3",{class:"text-lg font-semibold mb-3 text-center"}," Chiffre d'affaire par tranche horaire ",-1)),s(r(z),{type:"line",data:y.value,options:A.value,class:"h-full"},null,8,["data","options"])])])]),_:1})]),_:1})],64)}}},ee=P(G,[["__scopeId","data-v-b5051bf8"]]);export{ee as default};
