Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix batch actions on bookings list; fixes #1701 #30

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/GaletteEvents/Controllers/Crud/BookingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public function handleBatch(Request $request, Response $response): Response
);
return $response
->withStatus(301)
->withHeader('Location', $this->routeparser->urlFor('mailing') . '?new=new');
->withHeader('Location', $this->routeparser->urlFor('mailing') . '?mailing_new=true');
}

if (isset($post['csv'])) {
Expand Down
123 changes: 86 additions & 37 deletions templates/default/bookings.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -181,49 +181,98 @@
{% endblock %}

{% if nb > 0 %}
{#% set batch = {
'route': {
'name': 'batch-bookinglist'
},
'modal': {
'title': _T("No booking selected", "events"),
'content': _T("Please make sure to select at least one booking from the list to perform this action.", "events")
}
} %#}
{% if login.isAdmin() or login.isStaff() or login.isGroupManager() %}
{% set batch = {
'route': {
'name': 'batch-eventslist'
},
'modal': {
'title': _T("No booking selected", "events"),
'content': _T("Please make sure to select at least one booking from the list to perform this action.", "events")
}
} %}
{% endif %}

{% if login.isAdmin() or login.isStaff() %}
{% if preferences.pref_mail_method != constant('Galette\\Core\\GaletteMail::METHOD_DISABLED') %}
{% set batch_actions = [
{% if login.isAdmin() or login.isStaff() or login.isGroupManager() and (preferences.pref_bool_groupsmanagers_exports or preferences.pref_bool_groupsmanagers_mailings) %}
{% if login.isAdmin() or login.isStaff() or (login.isGroupManager() and preferences.pref_bool_groupsmanagers_mailings) %}
{% if preferences.pref_mail_method != constant('Galette\\Core\\GaletteMail::METHOD_DISABLED') %}
{% set batch_actions = [
{
'name': 'sendmail',
'label': _T("Mail"),
'icon': 'mail bulk'
}
] %}
{% endif %}
{% endif %}

{% if login.isAdmin() or login.isStaff() or login.isGroupManager() and preferences.pref_bool_groupsmanagers_exports %}
{% set batch_actions = (batch_actions ?? [])|merge([
{
'name': 'csv__directdownload',
'label': _T("Members as CSV", "events"),
'title': _T("Export selected reservation members as CSV", "events"),
'icon': 'file excel'
},
{
'name': 'csvbooking__directdownload',
'label': _T("Bookings as CSV", "events"),
'title': _T("Export selected reservations as CSV", "events"),
'icon': 'file excel'
},
{
'name': 'mailing',
'id': 'sendmail',
'label': _T("Mail"),
'icon': 'mail bulk'
'name': 'labels__directdownload',
'label': _T("Generate labels"),
'icon': 'id badge outline'
}
] %}
]) %}
{% endif %}
{% endif %}
{% endif %}

{% set batch_actions = (batch_actions ?? [])|merge([
{
'name': 'csv',
'label': _T("Members as CSV", "events"),
'title': _T("Export selected reservation members as CSV", "events"),
'icon': 'file excel'
},
{
'name': 'csvbooking',
'label': _T("Bookings as CSV", "events"),
'title': _T("Export selected reservations as CSV", "events"),
'icon': 'file excel'
}
]) %}
{% block batch_selection %}
else if (value == 'sendmail') {
{% if existing_mailing == true %}
_sendmail(true);
{% else %}
_sendmail();
{% endif %}
}
{% endblock %}

{% block javascripts %}
{% set batch_selection = ['sendmail'] %}
{{ parent() }}
<script type="text/javascript">
{% if nb > 0 %}
var _sendmail = function(existing){
console.log(existing);
var _form = $('#listform');
_form.append($('<input type="hidden" name="sendmail" value="true"/>'));
_form.append($('<input type="hidden" name="mailing_new" value="true"/>'));
_form.append($('<input type="hidden" name="mailing" value="true"/>'));
var _redirect = '{{ url_for('mailing') }}';

{% set batch_actions = (batch_actions ?? [])|merge([
{
'name': 'labels',
'label': _T("Generate labels"),
'icon': 'id badge outline'
if (existing) {
{% include "elements/js/modal.js.twig" with {
modal_title_twig: _T("Existing mailing")|e("js"),
modal_content_twig: _T("A mailing already exists. Do you want to create a new one or resume the existing?")|e("js"),
modal_class: "tiny",
modal_onapprove: "_form.submit();",
modal_approve_text: _T("New")|e("js"),
modal_approve_icon: "plus",
modal_approve_color: "green",
modal_additional_button: {
text: _T("Resume")|e("js"),
icon: "edit",
class: "blue",
click: "function() { location.href = _redirect; }"
}
} %}
} else {
_form.submit();
}
}
]) %}
{% endif %}
</script>
{% endblock %}