|
|
@@ -224,13 +224,14 @@ $ordineCoperti = (string) ($infoOrdine['coperti'] ?? '');
|
|
224
|
224
|
<div class="cassa-sb-products-wrap" id="product-panel">
|
|
225
|
225
|
<div class="cassa-sb-products" id="product-grid">
|
|
226
|
226
|
@foreach($cucine as $cucina)
|
|
227
|
|
- @foreach(($cucina->piatti ?? collect()) as $piatto)
|
|
|
227
|
+ @foreach(\App\Models\Piatto::ordinaCollezioneInCassa($cucina->piatti ?? []) as $piatto)
|
|
228
|
228
|
|
|
229
|
229
|
<article
|
|
230
|
230
|
class="cassa-sb-product"
|
|
231
|
231
|
data-product-item
|
|
232
|
232
|
data-kitchen-id="{{ $cucina->id }}"
|
|
233
|
233
|
data-name="{{ mb_strtolower((string) ($piatto->nome ?? ''), 'UTF-8') }}"
|
|
|
234
|
+ data-ordine-visualizzazione="{{ \App\Models\Piatto::ordineVisualizzazioneImpostato($piatto->ordine_visualizzazione) ? (int) $piatto->ordine_visualizzazione : 0 }}"
|
|
234
|
235
|
data-piatto-id="{{ $piatto->id }}"
|
|
235
|
236
|
data-title="{{ $piatto->nome }}"
|
|
236
|
237
|
data-price="{{ (float) ($piatto->prezzo ?? 0) }}"
|
|
|
@@ -296,8 +297,10 @@ $ordineCoperti = (string) ($infoOrdine['coperti'] ?? '');
|
|
296
|
297
|
<div class="cassa-sb-footer">
|
|
297
|
298
|
<div class="cassa-sb-pay-grid">
|
|
298
|
299
|
<button type="button" class="cassa-sb-main-btn" onclick="checkout()">Paga ora</button>
|
|
|
300
|
+ {{--
|
|
299
|
301
|
<button type="button" class="cassa-sb-cash-btn">Contanti</button>
|
|
300
|
302
|
<button type="button" class="cassa-sb-card-btn">Carta</button>
|
|
|
303
|
+ --}}
|
|
301
|
304
|
<button type="button" class="cassa-sb-clear-btn" id="cart-reset" onclick="azzeraCarrello()">Svuota</button>
|
|
302
|
305
|
</div>
|
|
303
|
306
|
</div>
|
|
|
@@ -451,50 +454,23 @@ $ordineCoperti = (string) ($infoOrdine['coperti'] ?? '');
|
|
451
|
454
|
});
|
|
452
|
455
|
};
|
|
453
|
456
|
|
|
454
|
|
- const getProductInitialLetter = function (name) {
|
|
455
|
|
- const trimmed = (name || '').trim();
|
|
456
|
|
- if (trimmed === '') return '#';
|
|
457
|
|
- const initial = [...trimmed][0]?.toLocaleUpperCase('it') || '#';
|
|
458
|
|
- return /^[A-Z]$/.test(initial.normalize('NFD').replace(/\p{M}/gu, '')) ? initial : '#';
|
|
|
457
|
+ const prodottoHaOrdine = function (item) {
|
|
|
458
|
+ const n = Number.parseInt(item.dataset.ordineVisualizzazione || '0', 10);
|
|
|
459
|
+ return Number.isFinite(n) && n !== 0;
|
|
459
|
460
|
};
|
|
460
|
461
|
|
|
461
|
|
- const createLetterDivider = function (letter) {
|
|
462
|
|
- const divider = document.createElement('div');
|
|
463
|
|
- divider.className = 'cassa-sb-letter-divider js-letter-divider';
|
|
464
|
|
- divider.setAttribute('data-letter', letter);
|
|
465
|
|
- const label = document.createElement('span');
|
|
466
|
|
- label.className = 'cassa-sb-letter-divider-label';
|
|
467
|
|
- label.textContent = letter;
|
|
468
|
|
- divider.appendChild(label);
|
|
469
|
|
- return divider;
|
|
470
|
|
- };
|
|
471
|
|
-
|
|
472
|
|
- const clearLetterDividers = function () {
|
|
473
|
|
- productGrid.querySelectorAll('.js-letter-divider').forEach(function (node) {
|
|
474
|
|
- node.remove();
|
|
475
|
|
- });
|
|
476
|
|
- };
|
|
477
|
|
-
|
|
478
|
|
- const LETTER_DIVIDER_MIN_ITEMS = 10;
|
|
479
|
|
-
|
|
480
|
|
- const buildProductGridSequence = function (items, totalVisibleCount) {
|
|
481
|
|
- const sequence = [];
|
|
482
|
|
- const showLetterDividers = totalVisibleCount > LETTER_DIVIDER_MIN_ITEMS;
|
|
483
|
|
- let lastLetter = null;
|
|
484
|
|
-
|
|
485
|
|
- items.forEach(function (item) {
|
|
486
|
|
- const letter = getProductInitialLetter(item.dataset.title || item.dataset.name || '');
|
|
487
|
|
- if (showLetterDividers && letter !== lastLetter) {
|
|
488
|
|
- sequence.push(createLetterDivider(letter));
|
|
489
|
|
- lastLetter = letter;
|
|
490
|
|
- }
|
|
491
|
|
- if (!showLetterDividers) {
|
|
492
|
|
- lastLetter = letter;
|
|
493
|
|
- }
|
|
494
|
|
- sequence.push(item);
|
|
495
|
|
- });
|
|
496
|
|
-
|
|
497
|
|
- return sequence;
|
|
|
462
|
+ const sortProductsForCassa = function (items) {
|
|
|
463
|
+ if (items.length > 0 && items.every(prodottoHaOrdine)) {
|
|
|
464
|
+ return items.slice().sort(function (a, b) {
|
|
|
465
|
+ const oa = Number.parseInt(a.dataset.ordineVisualizzazione, 10);
|
|
|
466
|
+ const ob = Number.parseInt(b.dataset.ordineVisualizzazione, 10);
|
|
|
467
|
+ if (oa !== ob) return oa - ob;
|
|
|
468
|
+ const nameA = (a.dataset.title || a.dataset.name || '').trim();
|
|
|
469
|
+ const nameB = (b.dataset.title || b.dataset.name || '').trim();
|
|
|
470
|
+ return nameA.localeCompare(nameB, 'it', { sensitivity: 'base' });
|
|
|
471
|
+ });
|
|
|
472
|
+ }
|
|
|
473
|
+ return sortProductsAlphabetically(items);
|
|
498
|
474
|
};
|
|
499
|
475
|
|
|
500
|
476
|
const renderProducts = function () {
|
|
|
@@ -524,7 +500,7 @@ $ordineCoperti = (string) ($infoOrdine['coperti'] ?? '');
|
|
524
|
500
|
}
|
|
525
|
501
|
|
|
526
|
502
|
const term = (productSearch?.value || '').trim().toLowerCase();
|
|
527
|
|
- visibleProducts = sortProductsAlphabetically(productItems.filter(function (item) {
|
|
|
503
|
+ visibleProducts = sortProductsForCassa(productItems.filter(function (item) {
|
|
528
|
504
|
const okKitchen = selectedKitchen === 'all' || item.dataset.kitchenId === selectedKitchen;
|
|
529
|
505
|
const okSearch = term === '' || (item.dataset.name || '').includes(term);
|
|
530
|
506
|
return okKitchen && okSearch;
|
|
|
@@ -537,14 +513,9 @@ $ordineCoperti = (string) ($infoOrdine['coperti'] ?? '');
|
|
537
|
513
|
|
|
538
|
514
|
productItems.forEach(function (item) { item.style.display = 'none'; });
|
|
539
|
515
|
const current = visibleProducts.slice(start, end);
|
|
540
|
|
- clearLetterDividers();
|
|
541
|
|
-
|
|
542
|
|
- const gridSequence = buildProductGridSequence(current, visibleProducts.length);
|
|
543
|
|
- gridSequence.forEach(function (node) {
|
|
544
|
|
- if (node.classList.contains('cassa-sb-product')) {
|
|
545
|
|
- node.style.display = '';
|
|
546
|
|
- }
|
|
547
|
|
- productGrid.appendChild(node);
|
|
|
516
|
+ current.forEach(function (item) {
|
|
|
517
|
+ item.style.display = '';
|
|
|
518
|
+ productGrid.appendChild(item);
|
|
548
|
519
|
});
|
|
549
|
520
|
|
|
550
|
521
|
visibleProducts.forEach(function (item) {
|
|
|
@@ -560,7 +531,7 @@ $ordineCoperti = (string) ($infoOrdine['coperti'] ?? '');
|
|
560
|
531
|
});
|
|
561
|
532
|
|
|
562
|
533
|
productGrid.querySelectorAll('.js-product-placeholder').forEach(function (node) { node.remove(); });
|
|
563
|
|
- applyProductGridLayout(gridSequence.length);
|
|
|
534
|
+ applyProductGridLayout(current.length);
|
|
564
|
535
|
|
|
565
|
536
|
productStatus.textContent = productPage + ' / ' + maxPage;
|
|
566
|
537
|
productPrev.disabled = productPage <= 1;
|