add proportional stockThreshold

This commit is contained in:
isUnknown 2024-09-04 17:02:37 +02:00
parent 3ee87a6f04
commit 9391a37a1e
10 changed files with 47 additions and 21 deletions

View file

@ -50,7 +50,7 @@
}
.sessions--detailed .session {
grid-template-columns: 1.5fr 2fr 1fr 1fr 1.5fr !important;
grid-template-columns: 1.5fr 2fr 1fr 1fr 2.5fr !important;
}
.collapsable__content .production p:not(:last-child) {

View file

@ -137,7 +137,7 @@
.session__event-link {
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-template-columns: 1fr 1fr 1fr 1fr 1.5fr;
padding: var(--padding-vertical) var(--space-m);
}

View file

@ -5,6 +5,25 @@ tabs:
label: Contenu
icon: false
columns:
- width: 1/1
fields:
totalStock:
label: Nombre total de places
type: number
disabled: true
when:
isMapadoEvent: true
width: 1/4
category:
label: Catégorie
type: select
width: 1/4
options:
type: query
query: page.parent.parent.categories.split
color:
extends: fields/color
width: 2/4
- width: 1/2
fields:
mapadoKeyInfos:
@ -12,7 +31,7 @@ tabs:
type: info
width: 1/2
text: |
[Gérer l'événement Mapado](https://desk.mapado.com/mass-action/ticketing/{{page.mapadoId}}).
Les données verrouillées proviennent de [l'événement Mapado](https://desk.mapado.com/mass-action/ticketing/{{page.mapadoId}}).
**Infos erronées ?**
Enregistrez (touches ⌘ / ctrl + s) et rechargez la page.
@ -164,16 +183,6 @@ tabs:
label: Réglages
icon: cog
fields:
category:
label: Catégorie
type: select
width: 1/4
options:
type: query
query: page.parent.parent.categories.split
color:
extends: fields/color
width: 3/4
mapadoLine:
type: line
isMapadoEvent:

View file

@ -46,5 +46,4 @@ return [
],
'locale' => 'fr_FR.UTF-8',
'ticketingUrl' => 'https://cdn-besancon.mapado.com/',
'stockThreshold' => 15,
];

View file

@ -87,7 +87,8 @@ return [
"place" => $event->place()->value(),
"eventUrl" => $event->url(),
"ticketingUrl" => $ticketingUrl,
"bookableStock" => $bookableStock
"bookableStock" => $bookableStock,
"totalStock" => (int) $event->totalStock()->value(),
]);
}
}

View file

@ -37,6 +37,7 @@ function createArraySession($event, $session) {
$arraySession['duration'] = $isMapadoEvent ? $event->remoteDuration() : $event->duration();
$arraySession['ticketingUrl'] = $isMapadoEvent ? $session->ticketingUrl() : false;
$arraySession['bookableStock'] = $isMapadoEvent ? $session->bookableStock()->value() : 'free';
$arraySession['totalStock'] = $isMapadoEvent ? (int) $event->totalStock()->value() : 'free';
$arraySession['color'] = $event->color();
$arraySession['category'] = $event->category();

View file

@ -102,7 +102,8 @@ function createMapadoEventRequest($page) {
"subfields" => [
["name" => "startDate"],
["name" => "endDate"],
["name" => "notInStockContingentBookableStock"]
["name" => "notInStockContingentBookableStock"],
["name" => "totalStock"]
]
],
]
@ -116,6 +117,7 @@ function saveMapadoEvent($mapadoEvent, $page) {
$kirby->impersonate('kirby');
$duration = '';
$totalStock = null;
$sessionsToSave = [];
if ($mapadoEvent->{"@type"} === 'hydra:Error') {
@ -132,6 +134,9 @@ function saveMapadoEvent($mapadoEvent, $page) {
foreach ($mapadoEvent->eventDateList as $session) {
if (!$totalStock) {
$totalStock = $session->totalStock;
}
$sessionMonth = substr($session->startDate, 0, 7);
@ -158,7 +163,8 @@ function saveMapadoEvent($mapadoEvent, $page) {
"mapadoSlug" => $mapadoEvent->slug,
"remoteDuration" => $duration,
"remoteSessions" => $sessionsToSave,
"eventDateId" => $eventDateId
"eventDateId" => $eventDateId,
"totalStock" => $totalStock
];
$page->update($dataToSave);

View file

@ -9,7 +9,6 @@
targetSessions: [],
open: false,
today: dayjs().format('DD-MM-YYYY'),
stockThreshold: <?= option('stockThreshold') ?>,
get monthName() {
return dayjs().month(this.monthNumb).format('MMMM');
@ -65,7 +64,13 @@
<div class="calendar-strip__date" :class="open ? 'open' : ''">
<ul class="sessions sessions--detailed">
<template x-for="session in targetSessions">
<li class="session" :style="'--color: ' + session.color">
<li
x-data="{
stockThreshold: (session.totalStock / 100) * 25
}"
:style="'--color: ' + session.color"
class="session"
>
<a class="session__event-link" :href="session.eventUrl" title="En savoir plus">
<div class="session__info">
<p x-html="`${session.day} ${monthName}`"></p>

View file

@ -79,7 +79,12 @@
"
>
<template x-for="session in sessions">
<div class="collapsable__item--padding session grid">
<div
x-data="{
stockThreshold: (<?= $page->totalStock() ?> / 100) * 25
}"
class="collapsable__item--padding session grid"
>
<p x-text="dateToFrench(session.date)"></p>
<p x-text="session.time"></p>
<p><?= $page->place() ?></p>

View file

@ -114,7 +114,7 @@
<a class="ticket-link" title="Entrée libre" disabled><?php snippet('ticket') ?>Entrée libre</a>
<?php elseif ($session['bookableStock'] == 0): ?>
<a class="ticket-link" title="Séance complète" disabled><?php snippet('ticket') ?>Complet</a>
<?php elseif ($session['bookableStock'] < option('stockThreshold')): ?>
<?php elseif ($session['bookableStock'] < (($session['totalStock'] / 100) * 25)): ?>
<a class="ticket-link" title="Plateforme de réservation" href="<?= $session['ticketingUrl'] ?>" target="_blank"><?php snippet('ticket') ?>Plus que quelques places !</a>
<?php else: ?>
<a class="ticket-link" title="Plateforme de réservation" href="<?= $session['ticketingUrl'] ?>" target="_blank"><?php snippet('ticket') ?>Billetterie</a>