Plugin Directory

Changeset 3814533


Ignore:
Timestamp:
11/20/2026 09:40:08 PM (14 hours ago)
Author:
pabloaronnabookingfacil
Message:

Release 2.1.1: active-first reservations view, check-in date filters and pagination

Location:
bookingfacil-reservas/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • bookingfacil-reservas/trunk/assets/css/admin/admin-common.css

    r3741551 r3814533  
    49274927    font-weight: 600;
    49284928}
     4929
     4930/* ==========================================================================
     4931   FILTROS DE FECHA Y PAGINACIÓN DE RESERVAS
     4932   ========================================================================== */
     4933.wp-booking-date-filter-wrap {
     4934    display: inline-flex;
     4935    align-items: center;
     4936    gap: 6px;
     4937}
     4938
     4939.wp-booking-date-filter-label {
     4940    font-size: 12px;
     4941    font-weight: 600;
     4942    color: #a1a1aa;
     4943    white-space: nowrap;
     4944}
     4945
     4946.wp-booking-date-filter-input {
     4947    height: 35px !important;
     4948    line-height: 33px !important;
     4949    background-color: rgba(255, 255, 255, 0.03) !important;
     4950    color: #fff !important;
     4951    border: 1px solid rgba(255, 255, 255, 0.08) !important;
     4952    border-radius: 6px !important;
     4953    padding: 0 10px !important;
     4954    box-sizing: border-box !important;
     4955    color-scheme: dark;
     4956}
     4957
     4958.wp-booking-date-filter-input:focus {
     4959    border-color: #00b4b9 !important;
     4960    outline: none !important;
     4961}
     4962
     4963.wp-booking-reservations-pagination {
     4964    display: flex;
     4965    align-items: center;
     4966    justify-content: space-between;
     4967    gap: 12px;
     4968    flex-wrap: wrap;
     4969    margin-top: 14px;
     4970    padding: 10px 4px 2px;
     4971}
     4972
     4973.wp-booking-res-pager-info {
     4974    font-size: 12.5px;
     4975    font-weight: 600;
     4976    color: #a1a1aa;
     4977}
     4978
     4979.wp-booking-res-pager-controls {
     4980    display: flex;
     4981    align-items: center;
     4982    gap: 6px;
     4983    flex-wrap: wrap;
     4984}
     4985
     4986.wp-booking-res-page-btn {
     4987    background: rgba(255, 255, 255, 0.05) !important;
     4988    border: 1px solid rgba(255, 255, 255, 0.12) !important;
     4989    color: #d4d4d8 !important;
     4990    border-radius: 6px !important;
     4991    min-width: 34px;
     4992    height: 32px !important;
     4993    line-height: 30px !important;
     4994    padding: 0 10px !important;
     4995    font-size: 12.5px !important;
     4996    font-weight: 600 !important;
     4997    cursor: pointer;
     4998}
     4999
     5000.wp-booking-res-page-btn:hover:not(:disabled) {
     5001    background: rgba(255, 255, 255, 0.12) !important;
     5002    border-color: #00b4b9 !important;
     5003    color: #ffffff !important;
     5004}
     5005
     5006.wp-booking-res-page-btn.active {
     5007    background: #00b4b9 !important;
     5008    border-color: #00b4b9 !important;
     5009    color: #04191c !important;
     5010    font-weight: 700 !important;
     5011}
     5012
     5013.wp-booking-res-page-btn:disabled {
     5014    opacity: 0.4 !important;
     5015    cursor: not-allowed !important;
     5016}
     5017
     5018.wp-booking-res-pager-dots {
     5019    color: #71717a;
     5020    padding: 0 4px;
     5021    font-weight: 700;
     5022}
  • bookingfacil-reservas/trunk/assets/js/admin/admin-reservations.js

    r3789780 r3814533  
    2020  const filterStatusSelect = document.getElementById('wp-booking-filter-status-select');
    2121  const filterUnitSelect = document.getElementById('wp-booking-filter-unit-select');
     22  const filterDateFromInput = document.getElementById('wp-booking-filter-date-from');
     23  const filterDateToInput = document.getElementById('wp-booking-filter-date-to');
    2224  const viewSelect = document.getElementById('wp-booking-view-select');
    2325  const clearFiltersBtn = document.getElementById('wp-booking-clear-filters-btn');
     26  const paginationContainer = document.getElementById('wp-booking-reservations-pagination');
    2427  const calPrevBtn = document.getElementById('wp-booking-cal-prev-btn');
    2528  const calNextBtn = document.getElementById('wp-booking-cal-next-btn');
    … …  
    100103  let currentMonth = new Date().getMonth();
    101104  let currentKpiFilter = 'all';
    102   let currentViewFilter = 'all';
     105  let currentViewFilter = 'important';
     106  let currentPage = 1;
     107  const BOOKINGS_PAGE_SIZE = 12;
    103108
    104109  // Variable global local del módulo para el folio actual
    … …  
    173178    if (activeCard) activeCard.classList.add('active-kpi-card');
    174179    currentKpiFilter = filterName;
    175     filterBookings();
     180    filterBookings(true);
    176181  }
    177182  function setViewFilter(viewName) {
    … …  
    183188  }
    184189  if (kpiAll) kpiAll.addEventListener('click', function () {
    185     if (viewSelect) viewSelect.value = 'all';
    186     setViewFilter('all');
     190    if (filterDateFromInput) filterDateFromInput.value = '';
     191    if (filterDateToInput) filterDateToInput.value = '';
     192    if (viewSelect) viewSelect.value = 'important';
     193    setViewFilter('important');
    187194  });
    188195  if (kpiUnassigned) kpiUnassigned.addEventListener('click', function () {
    … …  
    207214    setViewFilter(viewSelect.value);
    208215  });
    209   if (searchInput) searchInput.addEventListener('input', filterBookings);
    210   if (filterStatusSelect) filterStatusSelect.addEventListener('change', filterBookings);
    211   if (filterUnitSelect) filterUnitSelect.addEventListener('change', filterBookings);
     216  if (searchInput) searchInput.addEventListener('input', () => filterBookings(true));
     217  if (filterStatusSelect) filterStatusSelect.addEventListener('change', () => filterBookings(true));
     218  if (filterUnitSelect) filterUnitSelect.addEventListener('change', () => filterBookings(true));
     219  if (filterDateFromInput) filterDateFromInput.addEventListener('change', () => filterBookings(true));
     220  if (filterDateToInput) filterDateToInput.addEventListener('change', () => filterBookings(true));
    212221  if (clearFiltersBtn) {
    213222    clearFiltersBtn.addEventListener('click', function () {
    … …  
    215224      if (filterStatusSelect) filterStatusSelect.value = '';
    216225      if (filterUnitSelect) filterUnitSelect.value = '';
     226      if (filterDateFromInput) filterDateFromInput.value = '';
     227      if (filterDateToInput) filterDateToInput.value = '';
    217228      if (viewSelect) viewSelect.value = 'important';
    218229      setViewFilter('important');
    … …  
    13561367    const statusFilter = filterStatusSelect ? filterStatusSelect.value : '';
    13571368    const unitFilter = filterUnitSelect ? filterUnitSelect.value : '';
     1369    const dateFrom = filterDateFromInput ? filterDateFromInput.value : '';
     1370    const dateTo = filterDateToInput ? filterDateToInput.value : '';
     1371    const hasExplicitBypass = Boolean(query) || Boolean(dateFrom) || Boolean(dateTo) || statusFilter === 'cancelled' || statusFilter === 'blocked' || currentKpiFilter === 'blocked';
     1372
    13581373    const filtered = allBookings.filter(b => {
    13591374      const matchesQuery = !query || (
    … …  
    13641379      );
    13651380
     1381      const cleanCheckin = b.checkin ? String(b.checkin).substring(0, 10) : '';
     1382      if (dateFrom && (!cleanCheckin || cleanCheckin < dateFrom)) return false;
     1383      if (dateTo && (!cleanCheckin || cleanCheckin > dateTo)) return false;
     1384
    13661385      // Si el operador selecciona un estado en el desplegable (ej. 'cancelled' o 'confirmed'), se respeta.
    1367       // Si el operador realiza una búsqueda por texto (ej. busca a un huésped cancelado), se incluye.
     1386      // Si el operador realiza una búsqueda por texto o fechas, se incluye el histórico/canceladas según corresponda.
    13681387      // Por defecto en cualquier vista normal, las canceladas se excluyen automáticamente para evitar ruido operativo.
    13691388      let matchesStatus = true;
    13701389      if (statusFilter) {
    13711390        matchesStatus = b.status === statusFilter;
    1372       } else if (!query) {
     1391      } else if (!query && !dateFrom && !dateTo) {
    13731392        matchesStatus = b.status !== 'cancelled';
    13741393      }
    … …  
    13851404      let matchesView = true;
    13861405      if (currentViewFilter === 'important') {
    1387         matchesView = b.needs_attention;
     1406        matchesView = hasExplicitBypass ? true : b.needs_attention;
    13881407      } else if (currentViewFilter === 'future') {
    13891408        matchesView = b.time_category === 'future';
    … …  
    14721491    return filtered;
    14731492  }
    1474   function filterBookings() {
     1493  function filterBookings(resetPage = true) {
     1494    if (resetPage === true) {
     1495      currentPage = 1;
     1496    }
    14751497    renderBookingsTable(getFilteredBookings());
    14761498    if (calendarView && calendarView.style.display === 'block') {
    … …  
    14821504  function printBookingsList() {
    14831505    const statusFilter = filterStatusSelect ? filterStatusSelect.value : '';
     1506    const dateFrom = filterDateFromInput ? filterDateFromInput.value : '';
     1507    const dateTo = filterDateToInput ? filterDateToInput.value : '';
    14841508    const showBlocks = statusFilter === 'blocked' || currentKpiFilter === 'blocked';
    14851509    // Los bloqueos (manuales y de mantenimiento) no forman parte del parte impreso salvo que se filtren explícitamente
    … …  
    14941518
    14951519    const filtersDesc = [
    1496       `Vista: ${selText(viewSelect) || 'Todas'}`,
     1520      `Vista: ${selText(viewSelect) || 'Activas'}`,
    14971521      `Estado: ${selText(filterStatusSelect) || 'Todos los Estados'}`,
    14981522      `Unidad: ${selText(filterUnitSelect) || 'Todas las Unidades'}`,
     1523      dateFrom ? `Ingreso desde: ${bookingFacilFormatDate(dateFrom)}` : '',
     1524      dateTo ? `Ingreso hasta: ${bookingFacilFormatDate(dateTo)}` : '',
    14991525      currentKpiFilter && currentKpiFilter !== 'all' ? `Indicador: ${kpiLabels[currentKpiFilter] || currentKpiFilter}` : '',
    15001526      searchInput && searchInput.value.trim() ? `Búsqueda: "${searchInput.value.trim()}"` : ''
    … …  
    15841610  const printListBtn = document.getElementById('wp-booking-print-list-btn');
    15851611  if (printListBtn) printListBtn.addEventListener('click', printBookingsList);
     1612  if (paginationContainer) {
     1613    paginationContainer.addEventListener('click', function (e) {
     1614      const btn = e.target.closest('.wp-booking-res-page-btn');
     1615      if (!btn || btn.disabled || !btn.dataset.page) return;
     1616      currentPage = Number(btn.dataset.page) || 1;
     1617      filterBookings(false);
     1618    });
     1619  }
     1620
     1621  function renderBookingsPagination(total, totalPages, fromRow, toRow) {
     1622    if (!paginationContainer) return;
     1623    if (total === 0) {
     1624      paginationContainer.innerHTML = '';
     1625      return;
     1626    }
     1627    const infoHtml = `<span class="wp-booking-res-pager-info">Mostrando ${fromRow}–${toRow} de ${total} reserva${total !== 1 ? 's' : ''}</span>`;
     1628    if (totalPages <= 1) {
     1629      paginationContainer.innerHTML = infoHtml;
     1630      return;
     1631    }
     1632    const pages = [];
     1633    if (totalPages <= 7) {
     1634      for (let i = 1; i <= totalPages; i++) pages.push(i);
     1635    } else {
     1636      pages.push(1);
     1637      if (currentPage > 3) pages.push('dots');
     1638      for (let p = Math.max(2, currentPage - 1); p <= Math.min(totalPages - 1, currentPage + 1); p++) pages.push(p);
     1639      if (currentPage < totalPages - 2) pages.push('dots');
     1640      pages.push(totalPages);
     1641    }
     1642    let btnsHtml = `<button type="button" class="button wp-booking-res-page-btn" data-page="${currentPage - 1}" ${currentPage <= 1 ? 'disabled' : ''}>« Anterior</button>`;
     1643    pages.forEach(item => {
     1644      if (item === 'dots') {
     1645        btnsHtml += `<span class="wp-booking-res-pager-dots">…</span>`;
     1646      } else {
     1647        btnsHtml += `<button type="button" class="button wp-booking-res-page-btn${item === currentPage ? ' active' : ''}" data-page="${item}">${item}</button>`;
     1648      }
     1649    });
     1650    btnsHtml += `<button type="button" class="button wp-booking-res-page-btn" data-page="${currentPage + 1}" ${currentPage >= totalPages ? 'disabled' : ''}>Siguiente »</button>`;
     1651    paginationContainer.innerHTML = `${infoHtml}<div class="wp-booking-res-pager-controls">${btnsHtml}</div>`;
     1652  }
     1653
    15861654  function renderBookingsTable(bookings) {
    15871655    const container = document.getElementById('wp-booking-bookings-list');
    … …  
    15891657    if (bookings.length === 0) {
    15901658      container.innerHTML = '<tr><td colspan="7">No se encontraron reservas con los filtros aplicados.</td></tr>';
     1659      renderBookingsPagination(0, 1, 0, 0);
    15911660      return;
    15921661    }
     1662    const total = bookings.length;
     1663    const totalPages = Math.max(1, Math.ceil(total / BOOKINGS_PAGE_SIZE));
     1664    if (currentPage > totalPages) currentPage = totalPages;
     1665    if (currentPage < 1) currentPage = 1;
     1666    const startIdx = (currentPage - 1) * BOOKINGS_PAGE_SIZE;
     1667    const endIdx = Math.min(startIdx + BOOKINGS_PAGE_SIZE, total);
     1668    const pageRows = bookings.slice(startIdx, endIdx);
     1669
    15931670    container.innerHTML = '';
    1594     bookings.forEach(b => {
     1671    pageRows.forEach(b => {
    15951672      let badgeClass = 'pending_payment';
    15961673      let statusLabel = 'Pendiente Seña';
    … …  
    16681745    });
    16691746    registerBookingActions();
     1747    renderBookingsPagination(total, totalPages, startIdx + 1, endIdx);
    16701748  }
    16711749  function registerBookingActions() {
  • bookingfacil-reservas/trunk/booking-facil.php

    r3814213 r3814533  
    33 * Plugin Name: BookingFacil Reservations for Accommodations
    44 * Description: Accept online reservations for accommodations, campsites, and events. Manage rates, parcel occupancy, event tickets with QR check-in, payments, and confirmations from WordPress.
    5  * Version:     2.1.0
     5 * Version:     2.1.1
    66 * Requires at least: 5.8
    77 * Requires PHP: 7.4
    … …  
    2020
    2121// Definir constantes del plugin
    22 define( 'BOOKING_FACIL_VERSION', '2.1.0' );
     22define( 'BOOKING_FACIL_VERSION', '2.1.1' );
    2323define( 'BOOKING_FACIL_PATH', plugin_dir_path( __FILE__ ) );
    2424define( 'BOOKING_FACIL_URL', plugin_dir_url( __FILE__ ) );
  • bookingfacil-reservas/trunk/includes/admin-pages/reservations.php

    r3789780 r3814533  
    6868                <div>
    6969                    <select id="wp-booking-view-select" class="wbf-style-1f4a39a5">
    70                         <option value="all" selected class="wbf-style-8f8111c7"><?php esc_html_e( 'Todas', 'bookingfacil-reservas' ); ?></option>
    71                         <option value="important" class="wbf-style-8f8111c7"><?php esc_html_e( 'Importantes', 'bookingfacil-reservas' ); ?></option>
     70                        <option value="important" selected class="wbf-style-8f8111c7"><?php esc_html_e( 'Activas (Próximas, en curso o con deuda)', 'bookingfacil-reservas' ); ?></option>
     71                        <option value="all" class="wbf-style-8f8111c7"><?php esc_html_e( 'Todas (incluye histórico)', 'bookingfacil-reservas' ); ?></option>
    7272                        <option value="future" class="wbf-style-8f8111c7"><?php esc_html_e( 'Próximas', 'bookingfacil-reservas' ); ?></option>
    7373                        <option value="current" class="wbf-style-8f8111c7"><?php esc_html_e( 'En curso', 'bookingfacil-reservas' ); ?></option>
    … …  
    8989                        <option value="" class="wbf-style-8f8111c7"><?php esc_html_e( 'Todas las Unidades', 'bookingfacil-reservas' ); ?></option>
    9090                    </select>
     91                </div>
     92                <div class="wp-booking-date-filter-wrap">
     93                    <label for="wp-booking-filter-date-from" class="wp-booking-date-filter-label"><?php esc_html_e( 'Desde:', 'bookingfacil-reservas' ); ?></label>
     94                    <input type="date" id="wp-booking-filter-date-from" class="wp-booking-date-filter-input" title="<?php esc_attr_e( 'Fecha de ingreso desde', 'bookingfacil-reservas' ); ?>" />
     95                </div>
     96                <div class="wp-booking-date-filter-wrap">
     97                    <label for="wp-booking-filter-date-to" class="wp-booking-date-filter-label"><?php esc_html_e( 'Hasta:', 'bookingfacil-reservas' ); ?></label>
     98                    <input type="date" id="wp-booking-filter-date-to" class="wp-booking-date-filter-input" title="<?php esc_attr_e( 'Fecha de ingreso hasta', 'bookingfacil-reservas' ); ?>" />
    9199                </div>
    92100                <button type="button" class="button wbf-style-8fdc7fbe" id="wp-booking-clear-filters-btn"><?php esc_html_e( 'Limpiar', 'bookingfacil-reservas' ); ?></button>
    … …  
    114122                    </tbody>
    115123                </table>
     124                <div id="wp-booking-reservations-pagination" class="wp-booking-reservations-pagination"></div>
    116125            </div>
    117126
  • bookingfacil-reservas/trunk/readme.txt

    r3814213 r3814533  
    55Tested up to: 7.1.3
    66Requires PHP: 7.4
    7 Stable tag: 2.1.0
     7Stable tag: 2.1.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    104104== Changelog ==
    105105
     106= 2.1.1 =
     107* Active-First Reservations View (Hosted Parity): the Reservations & Blocks list now opens on "Activas (Próximas, en curso o con deuda)" — upcoming, in-house and balance-due bookings — hiding paid-out historical and cancelled reservations by default. Typing a search, picking a date range, or filtering by Cancelled/Blocked status automatically includes historical records so nothing is missed; "Todas (incluye histórico)" remains available.
     108* Check-in Date Range Filters: new "Ingreso desde / Ingreso hasta" date pickers filter the list by arrival date, are cleared by "Limpiar filtros", and are reflected in the printed report header.
     109* Pagination: reservation listings now paginate 12 records per page (desktop table and mobile cards) and reset to page 1 whenever a filter, search or KPI changes — keeping the KPI counters and calendar view in sync on the same filtered dataset.
     110* Print-Aware: the printed bookings report now includes the applied date range and prints the full filtered set (not just the visible page).
     111
    106112= 2.1.0 =
    107113* Ticket Order Management & Confirmations (Hosted Parity): the event orders list now mirrors the hosted SaaS experience — 10-per-page pagination with « Anterior / Siguiente » controls and live-refresh of the selected order detail after reloads.
    … …  
    347353== Upgrade Notice ==
    348354
     355= 2.1.1 =
     356* Recommended update: reservations list now defaults to active/upcoming/in-debt bookings, adds check-in date filters and 12-per-page pagination — same view rules as the hosted version.
     357
    349358= 2.1.0 =
    350359* Recommended update: adds pending-order confirmation, order pagination, and explicit safety confirmations for door sales and ticket check-in — same state rules as the hosted version. Requires the updated Booking Fácil backend (events/orders/:id/confirm).
Note: See TracChangeset for help on using the changeset viewer.