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 %}
403 {% elseif propname == 'contribstatus' %}
404 {% if member.isSponsor() %}
405 {% set value = '<i class="donate green icon tooltip" title="' ~ _T("Is a sponsor") ~ '"></i>' %}
407 {% set value = '<i class="ui icon" aria-hidden="true"></i>' %}
409 {% set value = value ~ member.contribstatus %}
410 {% set escaped = true %}
413 {# If value has not been set, take the generic value #}
415 {% set propvalue = attribute(member, propname) %}
417 {% set value = propvalue|e('html') %}
419 {% set value = propvalue %}
421 {% elseif escaped is not defined %}
422 {% set value = value|e('html') %}
425 <td data-col-label="{{ column.label }}">
427 A check is done here to adapt display, this is may not the best way to go
428 but for now, that works as expected.
431 {% if column.field_id == 'email_adh' %}
432 <a href="mailto:{{ value }}">{{ value }}</a>
433 {% elseif column.field_id == 'tel_adh' or column.field_id == 'gsm_adh' %}
434 <a href="tel:{{ value }}">{{ value }}</a>
435 {% elseif column.field_id == 'parent_id' %}
436 <a href="{{ url_for("member", {"id": member.parent}) }}">{{ memberName({"id": member.parent}) }}</a>
437 {% elseif column.field_id == 'ddn_adh' %}
438 {{ value }} {{ member.getAge() }}
446 {{ _self.draw_actions(member, login) }}
449 <tr><td colspan="{{ galette_list|length + 1 }}" class="emptylist">{{ _T('No member') }}</td></tr>
453 {% 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()) %}
456 'name': 'batch-memberslist'
459 'title': _T("No member selected"),
460 'content': _T("Please make sure to select at least one member from the list to perform this action.")
463 {% set batch_actions = callstatic('\\Galette\\Core\\Galette', 'getBatchActions') %}
466 {% block batch_selection %}
467 else if (value == 'sendmail') {
468 {% if existing_mailing == true %}
474 else if (value == 'attendance_sheet') {
475 _attendance_sheet_details();
478 else if (value == 'masscontributions') {
479 _masscontributions();
482 else if (value == 'masschange') {
487 {% block javascripts %}
488 {% set batch_selection = ['masschange', 'masscontributions', 'sendmail', 'attendance_sheet_details'] %}
490 <script type="text/javascript">
491 {# Use of Javascript to draw specific elements that are not relevant is JS is inactive #}
493 $('#savesearch').on('click', function(e) {
497 title: '{{ _T("Search title")|e('js') }}',
499 content: '<div class="ui input"><input type="text" name="search_title" id="search_title"/></div>',
500 onApprove: function() {
501 var _form = $('#members_list_search_filter');
502 var _data = _form.serialize();
503 _data = _data + "&search_title=" + $('#search_title').val();
505 url: '{{ url_for('saveSearch') }}',
509 {% include "elements/js/loader.js.twig" with {
511 selector: ".loader_selector"
513 success: function(res) {
515 url: '{{ url_for('ajaxMessages') }}',
517 success: function (values) {
518 for (var type in values) {
520 if (type == 'success') {
526 minDisplayTime: 5000,
528 showProgress: 'bottom',
530 position: 'top attached',
531 title: values[type]['title'],
532 message: values[type]['messages'].join('<br/>'),
533 showIcon: values[type]['icon'],
544 text : '{{ _T("Save")|e('js') }}',
546 class : 'icon labeled primary approve'
548 text : '{{ _T("Cancel")|e('js') }}',
550 class : 'icon labeled cancel'
556 {% if nb_members != 0 %}
557 var _sendmail = function(existing){
558 var _form = $('#listform');
559 _form.append($('<input type="hidden" name="sendmail" value="true"/>'));
560 _form.append($('<input type="hidden" name="mailing_new" value="true"/>'));
561 _form.append($('<input type="hidden" name="mailing" value="true"/>'));
562 var _redirect = '{{ url_for('mailing') }}';
565 {% include "elements/js/modal.js.twig" with {
566 modal_title_twig: _T("Existing mailing")|e("js"),
567 modal_content_twig: _T("A mailing already exists. Do you want to create a new one or resume the existing?")|e("js"),
569 modal_onapprove: "_form.submit();",
570 modal_approve_text: _T("New")|e("js"),
571 modal_approve_icon: "plus",
572 modal_approve_color: "green",
573 modal_additional_button: {
574 text: _T("Resume")|e("js"),
577 click: "function() { location.href = _redirect; }"
584 var _attendance_sheet_details = function(){
586 url: '{{ url_for('attendance_sheet_details') }}',
590 selection: $('#listform input[type=\"checkbox\"]:checked').map(function(){
591 return $(this).val();
595 {% include "elements/js/loader.js.twig" with {
597 selector: ".loader_selector"
599 success: function(res){
602 $('body').append(_res);
604 {% include "elements/js/modal.js.twig" with {
605 modal_selector: "#attendance_sheet_details",
606 modal_without_title: true,
608 modal_onshow: "_batchAjaxMapper();",
609 modal_onapprove: "$('#attendance_sheet_details form').submit();"
613 {% include "elements/js/modal.js.twig" with {
614 modal_title_twig: _T("An error occurred displaying attendance sheet details interface :(")|e("js"),
615 modal_without_content: true,
617 modal_deny_only: true,
618 modal_cancel_text: _T("Close")|e("js"),
619 modal_classname: "redalert",
624 var _masscontributions = function(){
626 url: '{{ url_for('batch-memberslist') }}',
630 masscontributions: true,
631 entries_sel: $('#listform input[type=\"checkbox\"]:checked').map(function(){
632 return $(this).val();
636 {% include "elements/js/loader.js.twig" with {
638 selector: ".loader_selector"
640 success: function(res){
643 $('body').append(_res);
645 _res.find('form').on('submit', function(e) {
648 var _data = _form.serialize();
651 url: _form.attr('action'),
655 {% include "elements/js/loader.js.twig" with {
657 selector: ".loader_selector"
659 success: function(data, status, xhr) {
662 $('#mass_contributions').remove();
663 $('body').append(_res);
665 _res.find('form').on('submit', function(e) {
668 var _data = _form.serialize();
670 url: _form.attr('action'),
674 {% include "elements/js/loader.js.twig" with {
676 selector: ".loader_selector"
678 success: function(res) {
679 window.location.href = _form.find('input[name=redirect_uri]').val();
682 $('#mass_contributions').modal('hide dimmer').remove();
683 {% include "elements/js/modal.js.twig" with {
684 modal_title_twig: _T("An error occurred :(")|e("js"),
685 modal_without_content: true,
687 modal_deny_only: true,
688 modal_cancel_text: _T("Close")|e("js"),
689 modal_classname: "redalert",
695 {% include "elements/js/modal.js.twig" with {
696 modal_selector: "#mass_contributions",
697 modal_without_title: true,
698 modal_content_class: "scrolling",
699 modal_onshow: "_batchAjaxMapper();_formValidationInModal('#mass_contributions');",
700 modal_onapprove: "var submitted = _formSubmitInModal('#mass_contributions');if (!submitted){return false;}"
704 {% include "elements/js/modal.js.twig" with {
705 modal_title_twig: _T("An error occurred :(")|e("js"),
706 modal_without_content: true,
708 modal_deny_only: true,
709 modal_cancel_text: _T("Close")|e("js"),
710 modal_classname: "redalert",
716 {% include "elements/js/modal.js.twig" with {
717 modal_selector: "#mass_contributions",
718 modal_without_title: true,
720 modal_onshow: "_batchAjaxMapper();",
721 modal_onapprove: "$('#mass_contributions form').submit();"
725 {% include "elements/js/modal.js.twig" with {
726 modal_title_twig: _T("An error occurred :(")|e("js"),
727 modal_without_content: true,
729 modal_deny_only: true,
730 modal_cancel_text: _T("Close")|e("js"),
731 modal_classname: "redalert",
736 var _masschange = function(){
738 url: '{{ url_for('batch-memberslist') }}',
743 entries_sel: $('#listform input[type=\"checkbox\"]:checked').map(function(){
744 return $(this).val();
748 {% include "elements/js/loader.js.twig" with {
750 selector: ".loader_selector"
752 success: function(res){
755 $('body').append(_res);
757 _res.find('form').on('submit', function(e) {
760 var _data = _form.serialize();
762 url: _form.attr('action'),
766 {% include "elements/js/loader.js.twig" with {
768 selector: ".loader_selector"
770 success: function(data, status, xhr) {
773 $('#mass_change').remove();
774 $('body').append(_res);
776 _res.find('form').on('submit', function(e) {
779 var _data = _form.serialize();
781 url: _form.attr('action'),
785 {% include "elements/js/loader.js.twig" with {
787 selector: ".loader_selector"
789 success: function(res) {
790 window.location.href = _form.find('input[name=redirect_uri]').val();
793 {% include "elements/js/modal.js.twig" with {
794 modal_title_twig: _T("An error occurred :(")|e("js"),
795 modal_without_content: true,
797 modal_deny_only: true,
798 modal_cancel_text: _T("Close")|e("js"),
799 modal_classname: "redalert",
805 {% include "elements/js/modal.js.twig" with {
806 modal_selector: "#mass_change",
807 modal_without_title: true,
808 modal_onapprove: "$('#mass_change form').submit();"
812 {% include "elements/js/modal.js.twig" with {
813 modal_title_twig: _T("An error occurred :(")|e("js"),
814 modal_without_content: true,
816 modal_deny_only: true,
817 modal_cancel_text: _T("Close")|e("js"),
818 modal_classname: "redalert",
824 {% include "elements/js/modal.js.twig" with {
825 modal_selector: "#mass_change",
826 modal_without_title: true,
827 modal_content_class: "scrolling",
828 modal_onshow: "_massCheckboxes('#mass_change');_batchAjaxMapper();",
829 modal_onapprove: "$('#mass_change form').submit();"
833 {% include "elements/js/modal.js.twig" with {
834 modal_title_twig: _T("An error occurred :(")|e("js"),
835 modal_without_content: true,
837 modal_deny_only: true,
838 modal_cancel_text: _T("Close")|e("js"),
839 modal_classname: "redalert",
844 var _batchAjaxMapper = function(){
845 $('.modal-form .ui.dropdown, .modal-form select:not(.nochosen)').dropdown();
846 $('.modal-form .ui.checkbox, .modal-form .ui.radio.checkbox').checkbox();
847 $('.modal-form a[title], .modal-form .tooltip').popup({
848 variation: 'inverted',
850 addTouchEvents: false,
852 {% include 'elements/js/calendar.js.twig' with {
853 selector: ".modal-form [id$='rangestart'], .modal-form [id$='rangeend']"
856 var _formValidationInModal = function(modal){
857 $(modal +' form').form({
859 autoCheckRequired: true,
861 empty: '{{ _T("Required field!")|e("js") }}'
865 var _formSubmitInModal = function(modal){
866 var validated = $(modal +' form').form('is valid');
868 $(modal +' form').submit();
869 $(modal).modal('hide dimmer').remove();
871 $(modal +' form').form('validate form');