@@ -104,88 +104,82 @@
-
+
{{ _T("Activities", "events") }}
-
-
{% set availables = event.availableActivities() %}
{% set activities = event.getActivities() %}
-
{% if availables|length or activities|length %}
{% if availables|length %}
-
-
+
+ {% include "components/forms/select.html.twig" with {
+ id: 'attach_activity',
+ value: '',
+ values: attach_values,
+ label: _T("Add selected activity to event", "events"),
+ component_class: 'twelve wide field'
+ } %}
+
+
+
+
{% endif %}
{% if activities|length %}
-
-
- {% endif %}
-
- {% if activities|length %}
+
+ {% include "components/forms/select.html.twig" with {
+ id: 'detach_activity',
+ value: '',
+ values: detach_values,
+ label: _T("Remove selected activity from event", "events"),
+ component_class: 'twelve wide field'
+ } %}
+
+
+
+
+
+ {% set status_values = {
+ (constant('GaletteEvents\\Activity::YES')): _T("Yes"),
+ (constant('GaletteEvents\\Activity::NO')): _T("No"),
+ (constant('GaletteEvents\\Activity::REQUIRED')): _T("Required", "events")
+ } %}
{% for item in activities %}
- {% set activity = item.activity %}
-
-
-
-
-
+
+ {% include "components/forms/select.html.twig" with {
+ id: 'activities_status_' ~ item.activity.getId(),
+ name: 'activities_status[]',
+ value: item.status,
+ values: status_values,
+ label: item.activity.getName()
+ } %}
{% endfor %}
{% endif %}
{% else %}
-
{{ _T("No activity available in the database.", "events") }}
+
{{ _T("No activity available in the database.", "events") }}
{% endif %}
-
{% endblock %}
-
-{% block javascripts %}
-
-{% endblock %}
diff --git a/templates/default/events.html.twig b/templates/default/events.html.twig
index 60f6dd1b..f74174ce 100644
--- a/templates/default/events.html.twig
+++ b/templates/default/events.html.twig
@@ -78,7 +78,7 @@
{{ event.getTown() }} |
{{ event.getGroupName() }} |
-
+
{% if event.isOpen() %}
{{ _T("Event is open", "events") }}
diff --git a/templates/default/scripts.html.twig b/templates/default/scripts.html.twig
new file mode 100644
index 00000000..60cae56b
--- /dev/null
+++ b/templates/default/scripts.html.twig
@@ -0,0 +1,10 @@
+{#
+ # This file is part of Galette Events plugin (https://galette.eu).
+ # SPDX-FileCopyrightText: Copyright © 2018-2026 The Galette Team
+ # SPDX-License-Identifier: GPL-3.0-or-later
+ #}
+
+{# plugin pages only #}
+{% if cur_route starts with 'events_' %}
+
+{% endif %}
diff --git a/tests/GaletteEvents/Controllers/Crud/tests/units/BookingsController.php b/tests/GaletteEvents/Controllers/Crud/tests/units/BookingsController.php
index 18d93115..40b5bcc1 100644
--- a/tests/GaletteEvents/Controllers/Crud/tests/units/BookingsController.php
+++ b/tests/GaletteEvents/Controllers/Crud/tests/units/BookingsController.php
@@ -660,4 +660,21 @@ public function testFilterOnEvent(): void
$this->assertNull($this->session->plugin_events_bookings_filter->event_filter);
$this->expectNoLogEntry();
}
+
+ /**
+ * Bookings list shows the total amount of listed bookings
+ */
+ public function testListTotal(): void
+ {
+ $member_one = $this->getMemberOne();
+ $member_two = $this->getMemberTwo();
+ $event = $this->insertEvent('Event');
+ $this->insertBooking($event, $member_one->id, ['payment_amount' => 12.5]);
+ $this->insertBooking($event, $member_two->id, ['payment_amount' => 7]);
+ $this->logSuperAdmin();
+
+ $body = (string)$this->app->handle($this->createRequest('events_bookings', ['event' => (string)$event]))->getBody();
+ $this->assertStringContainsString('Found bookings total 19.5', $body);
+ $this->expectNoLogEntry();
+ }
}
diff --git a/tests/GaletteEvents/Controllers/Crud/tests/units/EventsController.php b/tests/GaletteEvents/Controllers/Crud/tests/units/EventsController.php
index 9e510ed6..c8c370c2 100644
--- a/tests/GaletteEvents/Controllers/Crud/tests/units/EventsController.php
+++ b/tests/GaletteEvents/Controllers/Crud/tests/units/EventsController.php
@@ -318,6 +318,20 @@ public function testCalendarCanEdit(): void
$can_edit = array_column($events, 'can_edit', 'name');
ksort($can_edit);
$this->assertSame(['Managed event' => true, 'Public event' => false], $can_edit);
+
+ //links of the event modal come with the event
+ $by_name = array_column($events, null, 'name');
+ $managed_id = (string)$by_name['Managed event']['id_event'];
+ $public_id = (string)$by_name['Public event']['id_event'];
+ $this->assertSame(
+ $this->routeparser->urlFor('events_event_edit', ['id' => $managed_id]),
+ $by_name['Managed event']['edit_url']
+ );
+ $this->assertArrayNotHasKey('edit_url', $by_name['Public event']);
+ $this->assertSame(
+ $this->routeparser->urlFor('events_booking_add') . '?event=' . $public_id,
+ $by_name['Public event']['booking_url']
+ );
}
/**
@@ -445,6 +459,46 @@ public function testCalendarPage(): void
$body = (string)$test_response->getBody();
$this->assertStringContainsString('', $body);
$this->assertStringContainsString('js/calendar.bundle.js', $body);
- $this->assertStringContainsString($this->routeparser->urlFor('ajax-events_calendar'), $body);
+ $this->assertStringContainsString(' ', $body);
+
+ //options are given as JSON, that cannot close the script element
+ $this->assertSame(1, preg_match('##s', $body, $matches));
+ $options = json_decode($matches[1], true);
+ $this->assertSame($this->routeparser->urlFor('ajax-events_calendar'), $options['dataurl']);
+ $this->assertSame('Daily list', $options['buttons']['listDay']['text']);
+ $this->assertSame('en-US', $options['locale']);
+ }
+
+ /**
+ * Plugin pages load their script from a file, other pages do not
+ */
+ public function testScriptFile(): void
+ {
+ $this->logSuperAdmin();
+ $this->linkActivity($this->insertEvent('Event'), $this->insertActivity('Dinner'));
+
+ $body = (string)$this->app->handle($this->createRequest('events_event_add'))->getBody();
+ $this->assertStringContainsString('events.js', $body);
+ $this->assertStringNotContainsString('alert(', $body);
+ $this->assertStringContainsString('aria-controls="attach_activity"', $body);
+
+ //linked activities status are labelled
+ $event = $this->insertEvent('Linked');
+ $dinner = $this->insertActivity('Supper');
+ $this->linkActivity($event, $dinner, \GaletteEvents\Activity::REQUIRED);
+ $body = (string)$this->app->handle($this->createRequest('events_event_edit', ['id' => (string)$event]))->getBody();
+ $this->assertMatchesRegularExpression('##', $body);
+ $this->assertMatchesRegularExpression(
+ '# |