3 * Copyright © 2003-2024 The Galette Team
5 * This file is part of Galette (https://galette.eu).
7 * Galette is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * Galette is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
21 {% extends 'elements/list.html.twig' %}
23 {% import "macros.twig" as macros %}
25 {% set basic_table = true %}
27 {% set nb = nb_members %}
34 'name': 'batch-memberslist'
38 {% macro draw_actions(member, login) %}
39 <td class="center actions_row">
40 {% set actions = callstatic('\\Galette\\Core\\Galette', 'getListActions', member) %}
41 {% for action in actions %}
42 {{ macros.drawListAction(action.label, action.route, action.icon, action.extra_class ?? null) }}
49 'label': _Tn("%count member", "%count members", nb_members)|replace({'%count': nb_members}),
51 'name': 'filter-memberslist'
57 {% block infoline_actions %}
58 {% if login.isAdmin() or login.isStaff() or (login.isGroupManager() and preferences.pref_bool_groupsmanagers_create_member) %}
60 class="ui tiny labeled icon button"
61 href="{{ url_for("addMember") }}"
63 <i class="plus circle green icon" aria-hidden="true"></i>
64 {{ _T("Add a member") }}
70 {% set columns = [] %}
71 {% for column in galette_list %}
72 {% if column.field_id == 'id_adh' %}
73 {% if preferences.pref_show_id %}
74 {% set columns = columns|merge([
77 order: constant("Galette\\Repository\\Members::ORDERBY_ID")
81 {% set columns = columns|merge([
86 {% set columns = columns|merge([
89 order: column.field_id
99 <form action="{{ url_for('filter-memberslist') }}" method="post" id="members_list_search_filter" class="ui form filters">
100 <div class="ui secondary yellow segment">
101 {% if adv_filters is not defined or not adv_filters %}
102 <div class="five fields">
104 <label for="filter_str">{{ _T('Search:') }}</label>
105 <input type="text" name="filter_str" id="filter_str" value="{{ filters.filter_str }}" type="search" placeholder="{{ _T('Enter a value') }}"/>
108 <label for="field_filter">{{ _T('in:') }}</label>
109 <select name="field_filter" id="field_filter" class="ui search dropdown">
110 {% for key, value in field_filter_options %}
111 <option value="{{ key }}"{% if key == filters.field_filter %} selected="selected"{% endif %}>{{ value }}</option>
116 <label for="filter_str">{{ _T('among:') }}</label>
117 <select name="membership_filter" class="ui search dropdown">
118 {% for key, value in membership_filter_options %}
119 <option value="{{ key }}"{% if key == filters.membership_filter %} selected="selected"{% endif %}>{{ value }}</option>
123 <div class="flexend field">
124 <label for="filter_account" class="visually-hidden">{{ _T('among:') }}</label>
125 <select name="filter_account" class="ui search dropdown">
126 {% for key, value in filter_accounts_options %}
127 <option value="{{ key }}"{% if key == filters.filter_account %} selected="selected"{% endif %}>{{ value }}</option>
131 <div class="flexend field">
132 <label for="group_filter" class="visually-hidden">{{ _T('among:') }}</label>
133 <select name="group_filter" class="ui search dropdown">
134 <option value="0">{{ _T('Select a group') }}</option>
135 {% for group in filter_groups_options %}
136 <option value="{{ group.getId() }}"{% if filters.group_filter == group.getId() %} selected="selected"{% endif %}>{{ group.getIndentName()|raw }}</option>
141 <div class="two fields">
143 <div class="inline fields">
144 <label for="email_filter">{{ _T('Members that have an email address:') }}</label>
145 <div class="field inline">
146 <div class="ui radio checkbox">
147 <input type="radio" name="email_filter" id="filter_dc_email" value="{{ constant('Galette\\Repository\\Members::FILTER_DC_EMAIL') }}"{% if filters.email_filter == constant('Galette\\Repository\\Members::FILTER_DC_EMAIL') %} checked="checked"{% endif %}>
148 <label for="filter_dc_email">{{ _T("Don't care") }}</label>
151 <div class="field inline">
152 <div class="ui radio checkbox">
153 <input type="radio" name="email_filter" id="filter_with_email" value="{{ constant('Galette\\Repository\\Members::FILTER_W_EMAIL') }}"{% if filters.email_filter == constant('Galette\\Repository\\Members::FILTER_W_EMAIL') %} checked="checked"{% endif %}>
154 <label for="filter_with_email">{{ _T('With') }}</label>
157 <div class="field inline">
158 <div class="ui radio checkbox">
159 <input type="radio" name="email_filter" id="filter_without_email" value="{{ constant('Galette\\Repository\\Members::FILTER_WO_EMAIL') }}"{% if filters.email_filter == constant('Galette\\Repository\\Members::FILTER_WO_EMAIL') %} checked="checked"{% endif %}>
160 <label for="filter_without_email">{{ _T('Without') }}</label>
165 <div class="ui right aligned basic fitted segment field">
166 <button type="submit" class="tooltip action ui labeled icon primary button" title="{{ _T('Apply filters') }}" name="filter">
167 <i class="search icon" aria-hidden="true"></i>
170 <button type="submit" class="tooltip action ui labeled icon button" title="{{ _T('Save selected criteria') }}" name="savesearch" id="savesearch">
171 <i class="save blue icon" aria-hidden="true"></i>
174 <button type="submit" name="clear_filter" class="tooltip ui labeled icon button" title="{{ _T('Reset all filters to defaults') }}">
175 <i class="trash alt red icon" aria-hidden="true"></i>
176 {{ _T('Clear filter') }}
182 <span class="ui primary ribbon label">{{ _T('Advanced search mode') }}</span>
183 <button type="submit" class="tooltip action ui labeled icon primary button" title="{{ _T('Save current advanced search criteria') }}" name="savesearch" id="savesearch">
184 <i class="save icon" aria-hidden="true"></i>
187 <button type="submit" class="tooltip action ui labeled icon button" title="{{ _T('Change search criteria') }}" name="adv_criteria">
188 <i class="edit blue icon" aria-hidden="true"></i>
189 {{ _T('Change criteria') }}
191 <input type="hidden" name="advanced_search" value="1" class="ui button"/>
192 <button type="submit" name="clear_filter" class="tooltip ui labeled icon button" title="{{ _T('Reset all filters to defaults') }}">
193 <i class="trash alt red icon" aria-hidden="true"></i>
194 {{ _T('Clear filter') }}
196 <div class="ui basic fluid accordion">
198 <i class="dropdown icon" aria-hidden="true"></i>
199 {{ _T('Show/hide query') }}
201 <div class="content">
202 <div id="sql_qry" class="ui grey inverted segment">{{ filters.query }}</div>
207 {% include "components/forms/csrf.html.twig" %}
213 {% if nb_members != 0 %}
214 <div id="legende" title="{{ _T('Legend') }}" class="ui modal">
215 <div class="header">{{ _T('Legend') }}</div>
216 <div class="content">
217 <table class="ui stripped table">
220 <th class="" colspan="4">{{ _T('Reading the list') }}</th>
225 <th class="back">{{ _T('Name') }}</th>
226 <td class="back">{{ _T('Active account') }}</td>
227 <th class="inactive-account back">{{ _T('Name') }}</th>
228 <td class="back">{{ _T('Inactive account') }}</td>
231 <th class="cotis-ok color-sample"> </th>
232 <td class="back">{{ _T('Membership in order') }}</td>
233 <th class="cotis-soon color-sample"> </th>
234 <td class="back">{{ _T('Membership will expire soon (<30d)') }}</td>
237 <th class="cotis-never color-sample"> </th>
238 <td class="back">{{ _T('Never contributed') }}</td>
239 <th class="cotis-late color-sample"> </th>
240 <td class="back">{{ _T('Lateness in fee') }}</td>
244 <table class="ui stripped table">
247 <th class="" colspan="4">{{ _T('Actions') }}</th>
253 <i class="ui user edit blue icon" aria-hidden="true"></i>
255 <td class="back">{{ _T('Modification') }}</td>
257 <i class="ui receipt green icon" aria-hidden="true"></i>
259 <td class="back">{{ _T('Contributions') }}</td>
263 <i class="ui user times red icon" aria-hidden="true"></i>
265 <td class="back">{{ _T('Deletion') }}</td>
269 <table class="ui stripped table">
272 <th colspan="4">{{ _T('User status/interactions') }}</th>
277 <th><i class="ui envelope outline teal icon" aria-hidden="true"></i></th>
278 <td class="back">{{ _T('Send an email') }}</td>
279 <th><i class="ui building icon" aria-hidden="true"></i></th>
280 <td class="back">{{ _T('Is a company') }}</td>
284 <th><i class="ui male icon" aria-hidden="true"></i></th>
285 <td class="back">{{ _T('Is a man') }}</td>
286 <th><i class="ui female icon" aria-hidden="true"></i></th>
287 <td class="back">{{ _T('Is a woman') }}</td>
290 <th><i class="ui user shield red icon" aria-hidden="true"></i></th>
291 <td class="back">{{ _T('Admin') }}</td>
292 <th><i class="ui user tie orange icon" aria-hidden="true"></i></th>
293 <td class="back">{{ _T('Staff member') }}</td>
296 <th><i class="ui users cog orange icon" aria-hidden="true"></i></th>
297 <td class="back">{{ _T('Group manager') }}</td>
303 <div class="actions"><div class="ui labeled icon deny button"><i class="times icon" aria-hidden="true"></i> {{ _T('Close') }}</div></div>
309 {% for ordre, member in members %}
310 <tr class="{{ member.getRowClass() }}">
311 {% for column in galette_list %}
312 {% if column.field_id == 'id_adh' %}
313 <td class="right" data-scope="id">
314 {% if preferences.pref_show_id %}
317 {{ ordre + 1 + (filters.current_page - 1) * numrows }}
320 {% elseif column.field_id == 'list_adh_name' %}
321 <td class="username_row" data-scope="row">
322 <input type="checkbox" name="entries_sel[]" value="{{ member.__get('id') }}"/>
323 {% if member.isCompany() %}
325 <i class="ui building outline icon tooltip" aria-hidden="true"></i>
326 <span class="ui special popup">{{ _T('Is a company') }}</span>
328 {% elseif member.isMan() %}
330 <i class="ui male icon tooltip" aria-hidden="true"></i>
331 <span class="ui special popup">{{ _T('Is a man') }}</span>
333 {% elseif member.isWoman() %}
335 <i class="ui female icon tooltip" aria-hidden="true"></i>
336 <span class="ui special popup">{{ _T('Is a woman') }}</span>
339 <i class="ui icon" aria-hidden="true"></i>
341 {% if member.email != '' %}
342 <a href="mailto:{{ member.email }}">
343 <i class="ui envelope outline teal icon tooltip" aria-hidden="true"></i>
344 <span class="ui special popup">{{ _T('Mail') }}</span>
348 <i class="ui icon" aria-hidden="true"></i>
350 {% if member.isAdmin() %}
352 <i class="ui user shield red icon tooltip" aria-hidden="true"></i>
353 <span class="ui special popup">{{ _T('Admin') }}</span>
355 {% elseif member.isStaff() %}
357 <i class="ui user tie orange icon tooltip" aria-hidden="true"></i>
358 <span class="ui special popup">{{ _T('Staff member') }}</span>
360 {% elseif member.getManagedGroups() %}
362 <i class="ui users cog orange icon tooltip" aria-hidden="true"></i>
363 <span class="ui special popup">{{ _T('Group manager') }}</span>
366 <i class="ui icon" aria-hidden="true"></i>
368 {% set mid = member.id %}
369 <a href="{{ url_for("member", {"id": member.id}) }}">{{ member.sname }}{% if member.company_name %} ({{ member.company_name }}){% endif %}</a>
372 {% set propname = column.propname %}
373 {% set value = null %}
375 {% if column.field_id == 'nom_adh' %}
376 {% set value = member.sfullname %}
377 {% elseif column.field_id == 'pseudo_adh' %}
378 {% set value = attribute(member, propname) %}
379 {% elseif column.field_id == 'tel_adh' or column.field_id == 'gsm_adh' %}
380 {% elseif column.field_id == 'id_statut' %}
381 {% set value = member.sstatus %}
382 {% elseif column.field_id == 'titre_adh' %}
383 {% if member.title is not null %}
384 {% set value = member.title.long %}
386 {% elseif column.field_id == 'pref_lang' %}
387 {% set value = i18n.getNameFromId(member.language) %}
388 {% elseif column.field_id == 'adresse_adh' %}
389 {% set value = member.saddress|e('html')|nl2br %}
390 {% set escaped = true %}
391 {% elseif column.field_id == 'bool_display_info' %}
392 {% set value = member.sappears_in_list %}
393 {% elseif column.field_id == 'activite_adh' %}
394 {% set value = member.sactive %}
395 {% elseif column.field_id == 'id_statut' %}
396 {% set value = member.sstatus %}
397 {% elseif column.field_id == 'bool_admin_adh' %}
398 {% set value = member.sadmin %}
399 {% elseif column.field_id == 'bool_exempt_adh' %}
400 {% set value = member.sdue_free %}
401 {% elseif column.field_id == 'sexe_adh' %}
402 {% set value = member.sgender %}
405 {# If value has not been set, take the generic value #}
407 {% set propvalue = attribute(member, propname) %}
409 {% set value = propvalue|e('html') %}
411 {% set value = propvalue %}
413 {% elseif escaped is not defined %}
414 {% set value = value|e('html') %}
417 <td data-col-label="{{ column.label }}">
419 A check is done here to adapt display, this is may not the best way to go
420 but for now, that works as expected.
423 {% if column.field_id == 'email_adh' %}
424 <a href="mailto:{{ value }}">{{ value }}</a>
425 {% elseif column.field_id == 'tel_adh' or column.field_id == 'gsm_adh' %}
426 <a href="tel:{{ value }}">{{ value }}</a>
427 {% elseif column.field_id == 'parent_id' %}
428 <a href="{{ url_for("member", {"id": member.parent}) }}">{{ memberName({"id": member.parent}) }}</a>
429 {% elseif column.field_id == 'ddn_adh' %}
430 {{ value }} {{ member.getAge() }}
438 {{ _self.draw_actions(member, login) }}
441 <tr><td colspan="{{ galette_list|length + 1 }}" class="emptylist">{{ _T('No member has been found') }}</td></tr>
445 {% if nb_members != 0 and (login.isGroupManager() and (preferences.pref_bool_groupsmanagers_exports or preferences.pref_bool_groupsmanagers_mailings) or login.isAdmin() or login.isStaff()) %}
448 'name': 'batch-memberslist'
451 'title': _T("No member selected"),
452 'content': _T("Please make sure to select at least one member from the list to perform this action.")
455 {% set batch_actions = callstatic('\\Galette\\Core\\Galette', 'getBatchActions') %}
458 {% block batch_selection %}
459 else if (value == 'sendmail') {
460 {% if existing_mailing == true %}
466 else if (value == 'attendance_sheet') {
467 _attendance_sheet_details();
470 else if (value == 'masscontributions') {
471 _masscontributions();
474 else if (value == 'masschange') {
479 {% block javascripts %}
480 {% set batch_selection = ['masschange', 'masscontributions', 'sendmail', 'attendance_sheet_details'] %}
482 <script type="text/javascript">
483 {# Use of Javascript to draw specific elements that are not relevant is JS is inactive #}
485 $('#savesearch').on('click', function(e) {
489 title: '{{ _T("Search title")|e('js') }}',
491 content: '<div class="ui input"><input type="text" name="search_title" id="search_title"/></div>',
492 onApprove: function() {
493 var _form = $('#members_list_search_filter');
494 var _data = _form.serialize();
495 _data = _data + "&search_title=" + $('#search_title').val();
497 url: '{{ url_for('saveSearch') }}',
501 {% include "elements/js/loader.js.twig" with {
503 selector: ".loader_selector"
505 success: function(res) {
507 url: '{{ url_for('ajaxMessages') }}',
509 success: function (values) {
510 for (var type in values) {
512 if (type == 'success') {
518 minDisplayTime: 5000,
520 showProgress: 'bottom',
522 position: 'top attached',
523 title: values[type]['title'],
524 message: values[type]['messages'].join('<br/>'),
525 showIcon: values[type]['icon'],
536 text : '{{ _T("Save")|e('js') }}',
538 class : 'icon labeled primary approve'
540 text : '{{ _T("Cancel")|e('js') }}',
542 class : 'icon labeled cancel'
548 {% if nb_members != 0 %}
549 var _sendmail = function(existing){
550 var _form = $('#listform');
551 _form.append($('<input type="hidden" name="sendmail" value="true"/>'));
552 _form.append($('<input type="hidden" name="mailing_new" value="true"/>'));
553 _form.append($('<input type="hidden" name="mailing" value="true"/>'));
554 var _redirect = '{{ url_for('mailing') }}';
557 {% include "elements/js/modal.js.twig" with {
558 modal_title_twig: _T("Existing mailing")|e("js"),
559 modal_content_twig: _T("A mailing already exists. Do you want to create a new one or resume the existing?")|e("js"),
561 modal_onapprove: "_form.submit();",
562 modal_approve_text: _T("New")|e("js"),
563 modal_approve_icon: "plus",
564 modal_approve_color: "green",
565 modal_additional_button: {
566 text: _T("Resume")|e("js"),
569 click: "function() { location.href = _redirect; }"
576 var _attendance_sheet_details = function(){
578 url: '{{ url_for('attendance_sheet_details') }}',
582 selection: $('#listform input[type=\"checkbox\"]:checked').map(function(){
583 return $(this).val();
587 {% include "elements/js/loader.js.twig" with {
589 selector: ".loader_selector"
591 success: function(res){
594 $('body').append(_res);
596 {% include "elements/js/modal.js.twig" with {
597 modal_selector: "#attendance_sheet_details",
598 modal_without_title: true,
600 modal_onshow: "_batchAjaxMapper();",
601 modal_onapprove: "$('#attendance_sheet_details form').submit();"
605 {% include "elements/js/modal.js.twig" with {
606 modal_title_twig: _T("An error occurred displaying attendance sheet details interface :(")|e("js"),
607 modal_without_content: true,
609 modal_deny_only: true,
610 modal_cancel_text: _T("Close")|e("js"),
611 modal_classname: "redalert",
616 var _masscontributions = function(){
618 url: '{{ url_for('batch-memberslist') }}',
622 masscontributions: true,
623 entries_sel: $('#listform input[type=\"checkbox\"]:checked').map(function(){
624 return $(this).val();
628 {% include "elements/js/loader.js.twig" with {
630 selector: ".loader_selector"
632 success: function(res){
635 $('body').append(_res);
637 _res.find('form').on('submit', function(e) {
640 var _data = _form.serialize();
643 url: _form.attr('action'),
647 {% include "elements/js/loader.js.twig" with {
649 selector: ".loader_selector"
651 success: function(data, status, xhr) {
654 $('#mass_contributions').remove();
655 $('body').append(_res);
657 _res.find('form').on('submit', function(e) {
660 var _data = _form.serialize();
662 url: _form.attr('action'),
666 {% include "elements/js/loader.js.twig" with {
668 selector: ".loader_selector"
670 success: function(res) {
671 window.location.href = _form.find('input[name=redirect_uri]').val();
674 $('#mass_contributions').modal('hide dimmer').remove();
675 {% include "elements/js/modal.js.twig" with {
676 modal_title_twig: _T("An error occurred :(")|e("js"),
677 modal_without_content: true,
679 modal_deny_only: true,
680 modal_cancel_text: _T("Close")|e("js"),
681 modal_classname: "redalert",
687 {% include "elements/js/modal.js.twig" with {
688 modal_selector: "#mass_contributions",
689 modal_without_title: true,
690 modal_content_class: "scrolling",
691 modal_onshow: "_batchAjaxMapper();_formValidationInModal('#mass_contributions');",
692 modal_onapprove: "var submitted = _formSubmitInModal('#mass_contributions');if (!submitted){return false;}"
696 {% include "elements/js/modal.js.twig" with {
697 modal_title_twig: _T("An error occurred :(")|e("js"),
698 modal_without_content: true,
700 modal_deny_only: true,
701 modal_cancel_text: _T("Close")|e("js"),
702 modal_classname: "redalert",
708 {% include "elements/js/modal.js.twig" with {
709 modal_selector: "#mass_contributions",
710 modal_without_title: true,
712 modal_onshow: "_batchAjaxMapper();",
713 modal_onapprove: "$('#mass_contributions form').submit();"
717 {% include "elements/js/modal.js.twig" with {
718 modal_title_twig: _T("An error occurred :(")|e("js"),
719 modal_without_content: true,
721 modal_deny_only: true,
722 modal_cancel_text: _T("Close")|e("js"),
723 modal_classname: "redalert",
728 var _masschange = function(){
730 url: '{{ url_for('batch-memberslist') }}',
735 entries_sel: $('#listform input[type=\"checkbox\"]:checked').map(function(){
736 return $(this).val();
740 {% include "elements/js/loader.js.twig" with {
742 selector: ".loader_selector"
744 success: function(res){
747 $('body').append(_res);
749 _res.find('form').on('submit', function(e) {
752 var _data = _form.serialize();
754 url: _form.attr('action'),
758 {% include "elements/js/loader.js.twig" with {
760 selector: ".loader_selector"
762 success: function(data, status, xhr) {
765 $('#mass_change').remove();
766 $('body').append(_res);
768 _res.find('form').on('submit', function(e) {
771 var _data = _form.serialize();
773 url: _form.attr('action'),
777 {% include "elements/js/loader.js.twig" with {
779 selector: ".loader_selector"
781 success: function(res) {
782 window.location.href = _form.find('input[name=redirect_uri]').val();
785 {% include "elements/js/modal.js.twig" with {
786 modal_title_twig: _T("An error occurred :(")|e("js"),
787 modal_without_content: true,
789 modal_deny_only: true,
790 modal_cancel_text: _T("Close")|e("js"),
791 modal_classname: "redalert",
797 {% include "elements/js/modal.js.twig" with {
798 modal_selector: "#mass_change",
799 modal_without_title: true,
800 modal_onapprove: "$('#mass_change form').submit();"
804 {% include "elements/js/modal.js.twig" with {
805 modal_title_twig: _T("An error occurred :(")|e("js"),
806 modal_without_content: true,
808 modal_deny_only: true,
809 modal_cancel_text: _T("Close")|e("js"),
810 modal_classname: "redalert",
816 {% include "elements/js/modal.js.twig" with {
817 modal_selector: "#mass_change",
818 modal_without_title: true,
819 modal_content_class: "scrolling",
820 modal_onshow: "_massCheckboxes('#mass_change');_batchAjaxMapper();",
821 modal_onapprove: "$('#mass_change form').submit();"
825 {% include "elements/js/modal.js.twig" with {
826 modal_title_twig: _T("An error occurred :(")|e("js"),
827 modal_without_content: true,
829 modal_deny_only: true,
830 modal_cancel_text: _T("Close")|e("js"),
831 modal_classname: "redalert",
836 var _batchAjaxMapper = function(){
837 $('.modal-form .ui.dropdown, .modal-form select:not(.nochosen)').dropdown();
838 $('.modal-form .ui.checkbox, .modal-form .ui.radio.checkbox').checkbox();
839 $('.modal-form a[title], .modal-form .tooltip').popup({
840 variation: 'inverted',
842 addTouchEvents: false,
844 {% include 'elements/js/calendar.js.twig' with {
845 selector: ".modal-form [id$='rangestart'], .modal-form [id$='rangeend']"
848 var _formValidationInModal = function(modal){
849 $(modal +' form').form({
851 autoCheckRequired: true,
853 empty: '{{ _T("Required field!")|e("js") }}'
857 var _formSubmitInModal = function(modal){
858 var validated = $(modal +' form').form('is valid');
860 $(modal +' form').submit();
861 $(modal).modal('hide dimmer').remove();
863 $(modal +' form').form('validate form');