1import{r as u,j as e,y as S,a as I}from"./app-mTfod8_p.js";import{C as O}from"./ContableLayout-G2jYJxnt.js";import{m as L}from"./Alertas-D8qI7uOX.js";import{m as T,u as B,$ as U}from"./index-1WwU9Ijs.js";import{k as _}from"./index-M5txmUst.js";import{f as z,E as J}from"./filtrosDeTabla-sRv8HwAb.js";import{P as R}from"./Pagination-DpTvShJQ.js";/* empty css */import"./Dropdown-CGchWa5F.js";import"./transition-Bkjc864C.js";import"./ChangelogBell-6zg2SAXl.js";import"./VersionNotesNavLink-CJHQtYSK.js";import"./ResponsiveNavLink-BWVOaaDA.js";import"./iconBase-DSG2VGHm.js";import"./ButtonBase-CzFeVXPC.js";import"./index-Chjiymov.js";import"./assertThisInitialized-BltG6J5U.js";import"./useControlled-2KXIme5c.js";import"./index-hTO633n6.js";import"./createSimplePaletteValueFilter-bm0fmN_7.js";import"./createSvgIcon-BAE4XVEF.js";function Y({isOpen:N,onClose:i,onDownload:g}){const[o,m]=u.useState(""),[x,j]=u.useState(""),c=[{value:"01",label:"Enero"},{value:"02",label:"Febrero"},{value:"03",label:"Marzo"},{value:"04",label:"Abril"},{value:"05",label:"Mayo"},{value:"06",label:"Junio"},{value:"07",label:"Julio"},{value:"08",label:"Agosto"},{value:"09",label:"Septiembre"},{value:"10",label:"Octubre"},{value:"11",label:"Noviembre"},{value:"12",label:"Diciembre"}],w=new Date().getFullYear(),k=Array.from(new Array(30),(r,d)=>w-d),f=()=>{o&&x?(g({mes:o,anio:x}),i()):L({mensaje:"Por favor, selecciona mes y año",tipo:"warning"})};return N?e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-gray-900 bg-opacity-50",children:e.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-lg w-1/3",children:[e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Seleccionar mes y año"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"mes",className:"block text-sm font-medium text-gray-700",children:"Mes"}),e.jsxs("select",{name:"mes",id:"mes",className:"mt-1 block w-full border-gray-300 rounded-md shadow-sm",value:o,onChange:r=>m(r.target.value),children:[e.jsx("option",{value:"",children:"Selecciona el mes"}),c.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"anio",className:"block text-sm font-medium text-gray-700",children:"Año"}),e.jsxs("select",{name:"anio",id:"anio",className:"mt-1 block w-full border-gray-300 rounded-md shadow-sm",value:x,onChange:r=>j(r.target.value),children:[e.jsx("option",{value:"",children:"Selecciona el año"}),k.map(r=>e.jsx("option",{value:r,children:r},r))]})]}),e.jsxs("div",{className:"flex justify-end",children:[e.jsx("button",{onClick:i,className:"bg-gray-500 text-white font-bold py-2 px-4 rounded mr-2",children:"Cancelar"}),e.jsx("button",{onClick:f,className:"bg-blue-500 text-white font-bold py-2 px-4 rounded",children:"Descargar"})]})]})}):null}const G=[{label:"Id",key:"id"},{label:"Nombre",key:"nombre"},{label:"ID Grupo",key:null},{label:"AMPA",key:"ampa"},{label:"Colegio",key:null},{label:"Monitor",key:null},{label:"Actividad",key:null},{label:"Lugar",key:null},{label:"Alta",key:null},{label:"Baja",key:null}];function pe({auth:N,alumnos:i,searchTerm:g,orden:o="id",direccion:m="asc"}){const[x,j]=u.useState(i.current_page||1),[c,w]=u.useState(g||""),[k,f]=u.useState(!1),[r,d]=u.useState(!1);u.useEffect(()=>{if(!z({busqueda:c},{busqueda:g}))return;const s=setTimeout(()=>{j(1),S.get("/contable/alumnos",{busqueda:c,orden:o,direccion:m,page:1},{preserveState:!0,replace:!0,onStart:()=>d(!0),onFinish:()=>d(!1)})},J);return()=>clearTimeout(s)},[c,g,o,m]);const D=(s,l)=>{j(l),S.get("/contable/alumnos",{page:l,busqueda:c,orden:o,direccion:m},{preserveState:!0,preserveScroll:!0,onStart:()=>d(!0),onFinish:()=>d(!1)})},F=s=>{s&&S.get("/contable/alumnos",{busqueda:c,orden:s,direccion:o===s&&m==="asc"?"desc":"asc",page:x},{preserveState:!0,preserveScroll:!0,replace:!0,onStart:()=>d(!0),onFinish:()=>d(!1)})},v=(s,l)=>{const p=new Set;return s.reduce((y,b)=>{const h=l(b)||"N/A";return p.has(h)||(p.add(h),y.push({key:(b==null?void 0:b.id)??h,label:h})),y},[])},A=s=>{const l=new Date(s);return Number.isNaN(l.getTime())?s:l.toLocaleDateString()},M=({mes:s,anio:l})=>{const p=`/contable/descargar/excel?mes=${s}&anio=${l}`;globalThis.location.assign(p)};return e.jsxs(O,{user:N.user,children:[e.jsx(I,{title:"Contable - Alumnos"}),e.jsxs("div",{className:"container mx-auto px-4 py-10 space-y-8",children:[e.jsxs("div",{className:"flex flex-col gap-4 justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl sm:text-4xl font-extrabold text-gray-800 tracking-tight",children:"Listado de Alumnos"}),e.jsxs("p",{className:"text-sm text-gray-500 mt-2 flex items-center gap-1",children:[e.jsx(T,{className:"text-pink-500 text-xs"}),"Consulta y descarga los registros de los alumnos."]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-center sm:justify-between w-full sm:w-auto",children:[e.jsxs("div",{className:"flex-1 relative w-full sm:w-1/2",children:[e.jsx("label",{htmlFor:"table-search-users",className:"sr-only",children:"Buscar actividad"}),e.jsx(_,{className:"absolute left-3 top-3 text-pink-300 text-lg"}),e.jsx("input",{type:"text",id:"table-search-users",placeholder:"Buscar por nombre, actividad, provincia o colegio",value:c,onChange:s=>w(s.target.value),className:"block w-full md:w-1/2 pl-10 pr-4 py-2 text-sm text-gray-900 border border-pink-300 rounded-md bg-white shadow-sm focus:ring-2 focus:ring-pink-400 focus:border-pink-400 transition"})]}),e.jsxs("button",{className:"inline-flex items-center justify-center gap-2 text-sm font-medium text-white bg-pink-600 hover:bg-pink-700 px-4 py-3 rounded-lg shadow transition",onClick:()=>f(!0),children:[e.jsx(B,{className:"w-4 h-4"}),"Descargar registro"]})]})]}),e.jsxs("div",{className:`overflow-x-auto rounded-lg shadow transition-opacity ${r?"opacity-50":""}`,children:[e.jsxs("table",{className:"min-w-full text-sm text-left bg-white border border-gray-200",children:[e.jsx("thead",{className:"bg-pink-500 text-xs uppercase text-gray-100 sticky top-0 z-0",children:e.jsx("tr",{children:G.map(s=>e.jsxs("th",{className:s.key?"px-6 py-3 cursor-pointer select-none":"px-6 py-3",onClick:()=>
1F(s.key),children:[s.label," ",s.key&&o===s.key?m==="asc"?"â":"â":""]},s.label))})}),e.jsx("tbody",{children:(i.data??[]).map(s=>{var C;const l=s.grupos??[],p=l.map(t=>t.id??"N/A").join(", "),y=s.ampa?"SÃ":"No",b=v(l,t=>{var a,n;return((n=(a=t.actividad)==null?void 0:a.colegio)==null?void 0:n.nombre)||"N/A"}),h=v(l,t=>{var a,n;return((n=(a=t.monitor)==null?void 0:a.user)==null?void 0:n.name)||"N/A"}),$=v(l,t=>{var a;return((a=t.actividad)==null?void 0:a.nombre)||"N/A"}),E=v(l,t=>{var a,n;return((n=(a=t.actividad)==null?void 0:a.colegio)==null?void 0:n.provincia)||"N/A"}),P=l.flatMap(t=>(t.altas??[]).map(a=>{const n=t.id??"N/A";return{key:`${n}-alta-${a}`,label:`(${n}) ${A(a)}`}})),q=l.flatMap(t=>(t.bajas??[]).map(a=>{const n=t.id??"N/A";return{key:`${n}-baja-${a}`,label:`(${n}) ${A(a)}`}}));return e.jsxs("tr",{className:"odd:bg-white even:bg-gray-50 border-b hover:bg-pink-50 transition",children:[e.jsx("td",{className:"px-6 py-4 font-semibold text-gray-900 ",children:e.jsx("span",{className:"bg-pink-200 p-2 rounded-full",children:s.id})}),e.jsx("td",{className:"px-6 py-4 font-bold text-gray-700 tracking-tight text-md",children:((C=s.user)==null?void 0:C.name)||"N/A"}),e.jsx("td",{className:"px-6 py-4 text-gray-700",children:p}),e.jsx("td",{className:"px-6 py-4 text-gray-700",children:y}),e.jsx("td",{className:"px-6 py-4 text-gray-700",children:b.map(({key:t,label:a})=>e.jsx("div",{children:a},t))}),e.jsx("td",{className:"px-6 py-4 text-gray-700",children:h.map(({key:t,label:a})=>e.jsx("div",{children:a},t))}),e.jsx("td",{className:"px-6 py-4 text-gray-700",children:$.map(({key:t,label:a})=>e.jsx("div",{children:a},t))}),e.jsx("td",{className:"px-6 py-4 text-gray-700",children:E.map(({key:t,label:a})=>e.jsx("div",{children:a},t))}),e.jsx("td",{className:"px-6 py-4 text-gray-700",children:P.map(({key:t,label:a})=>e.jsx("div",{children:a},t))}),e.jsx("td",{className:"px-6 py-4 text-gray-700",children:q.map(({key:t,label:a})=>e.jsx("div",{children:a},t))})]},s.id)})})]}),(i.data??[]).length===0&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-16",children:[e.jsx(U,{className:"w-10 h-10 text-slate-300"}),e.jsx("p",{className:"text-base font-semibold text-slate-700",children:"No se encontraron alumnos"}),e.jsx("p",{className:"text-sm text-slate-400",children:"Prueba con otro término de búsqueda."})]})]}),i.last_page>1&&e.jsx("div",{className:"flex justify-center mt-6",children:e.jsx(R,{count:i.last_page,page:x,onChange:D,color:"primary"})})]}),e.jsx(Y,{isOpen:k,onClose:()=>f(!1),onDownload:M})]})}export{pe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.