]> git.agnieray.net Git - galette.git/blob - galette/templates/default/pages/members_list.html.twig
Identify donators in list
[galette.git] / galette / templates / default / pages / members_list.html.twig
1 {#
2 /**
3 * Copyright © 2003-2024 The Galette Team
4 *
5 * This file is part of Galette (https://galette.eu).
6 *
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.
11 *
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.
16 *
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/>.
19 */
20 #}
21 {% extends 'elements/list.html.twig' %}
22
23 {% import "macros.twig" as macros %}
24
25 {% set basic_table = true %}
26
27 {% set nb = nb_members %}
28
29 {% set form = {
30 'order': {
31 'name': 'members'
32 },
33 'route': {
34 'name': 'batch-memberslist'
35 }
36 } %}
37
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) }}
43 {% endfor %}
44 </td>
45 {% endmacro %}
46
47 {% block infoline %}
48 {% set infoline = {
49 'label': _Tn("%count member", "%count members", nb_members)|replace({'%count': nb_members}),
50 'route': {
51 'name': 'filter-memberslist'
52 }
53 } %}
54 {{ parent() }}
55 {% endblock %}
56
57 {% block infoline_actions %}
58 {% if login.isAdmin() or login.isStaff() or (login.isGroupManager() and preferences.pref_bool_groupsmanagers_create_member) %}
59 <a
60 class="ui tiny labeled icon button"
61 href="{{ url_for("addMember") }}"
62 >
63 <i class="plus circle green icon" aria-hidden="true"></i>
64 {{ _T("Add a member") }}
65 </a>
66 {% endif %}
67 {% endblock %}
68
69 {% block header %}
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([
75 {
76 label: _T('Mbr id'),
77 order: constant("Galette\\Repository\\Members::ORDERBY_ID")
78 }
79 ]) %}
80 {% else %}
81 {% set columns = columns|merge([
82 {label: '#'}
83 ]) %}
84 {% endif %}
85 {% else %}
86 {% set columns = columns|merge([
87 {
88 label: column.label,
89 order: column.field_id
90 }
91 ]) %}
92 {% endif %}
93 {% endfor %}
94
95 {{ parent() }}
96 {% endblock %}
97
98 {% block search %}
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">
103 <div class="field">
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') }}"/>
106 </div>
107 <div class="field">
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>
112 {% endfor %}
113 </select>
114 </div>
115 <div class="field">
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>
120 {% endfor %}
121 </select>
122 </div>
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>
128 {% endfor %}
129 </select>
130 </div>
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>
137 {% endfor %}
138 </select>
139 </div>
140 </div>
141 <div class="two fields">
142 <div class="field">
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>
149 </div>
150 </div>
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>
155 </div>
156 </div>
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>
161 </div>
162 </div>
163 </div>
164 </div>
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>
168 {{ _T('Filter') }}
169 </button>
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>
172 {{ _T('Save') }}
173 </button>
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') }}
177 </button>
178 </div>
179 </div>
180 {% else %}
181 <div class="field">
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>
185 {{ _T('Save') }}
186 </button>
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') }}
190 </button>
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') }}
195 </button>
196 <div class="ui basic fluid accordion">
197 <div class="title">
198 <i class="dropdown icon" aria-hidden="true"></i>
199 {{ _T('Show/hide query') }}
200 </div>
201 <div class="content">
202 <div id="sql_qry" class="ui grey inverted segment">{{ filters.query }}</div>
203 </div>
204 </div>
205 </div>
206 {% endif %}
207 {% include "components/forms/csrf.html.twig" %}
208 </div>
209 </form>
210 {% endblock %}
211
212 {% block legend %}
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">
218 <thead>
219 <tr>
220 <th class="" colspan="4">{{ _T('Reading the list') }}</th>
221 </tr>
222 <thead>
223 <tbody>
224 <tr>
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>
229 </tr>
230 <tr>
231 <th class="cotis-ok color-sample">&nbsp;</th>
232 <td class="back">{{ _T('Membership in order') }}</td>
233 <th class="cotis-soon color-sample">&nbsp;</th>
234 <td class="back">{{ _T('Membership will expire soon (&lt;30d)') }}</td>
235 </tr>
236 <tr>
237 <th class="cotis-never color-sample">&nbsp;</th>
238 <td class="back">{{ _T('Never contributed') }}</td>
239 <th class="cotis-late color-sample">&nbsp;</th>
240 <td class="back">{{ _T('Lateness in fee') }}</td>
241 </tr>
242 </tbody>
243 </table>
244 <table class="ui stripped table">
245 <thead>
246 <tr>
247 <th class="" colspan="4">{{ _T('Actions') }}</th>
248 </tr>
249 <thead>
250 <tbody>
251 <tr>
252 <th class="action">
253 <i class="ui user edit blue icon" aria-hidden="true"></i>
254 </th>
255 <td class="back">{{ _T('Modification') }}</td>
256 <th>
257 <i class="ui receipt green icon" aria-hidden="true"></i>
258 </th>
259 <td class="back">{{ _T('Contributions') }}</td>
260 </tr>
261 <tr>
262 <th class="delete">
263 <i class="ui user times red icon" aria-hidden="true"></i>
264 </th>
265 <td class="back">{{ _T('Deletion') }}</td>
266 </tr>
267 </tbody>
268 </table>
269 <table class="ui stripped table">
270 <thead>
271 <tr>
272 <th colspan="4">{{ _T('User status/interactions') }}</th>
273 </tr>
274 <thead>
275 <tbody>
276 <tr>
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>
281 </tr>
282
283 <tr>
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>
288 </tr>
289 <tr>
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>
294 </tr>
295 <tr>
296 <th><i class="ui users cog orange icon" aria-hidden="true"></i></th>
297 <td class="back">{{ _T('Group manager') }}</td>
298
299 </tr>
300 </tbody>
301 </table>
302 </div>
303 <div class="actions"><div class="ui labeled icon deny button"><i class="times icon" aria-hidden="true"></i> {{ _T('Close') }}</div></div>
304 </div>
305 {% endif %}
306 {% endblock %}
307
308 {% block body %}
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 %}
315 {{ member.id }}
316 {% else %}
317 {{ ordre + 1 + (filters.current_page - 1) * numrows }}
318 {% endif %}
319 </td>
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() %}
324 <span>
325 <i class="ui building outline icon tooltip" aria-hidden="true"></i>
326 <span class="ui special popup">{{ _T('Is a company') }}</span>
327 </span>
328 {% elseif member.isMan() %}
329 <span>
330 <i class="ui male icon tooltip" aria-hidden="true"></i>
331 <span class="ui special popup">{{ _T('Is a man') }}</span>
332 </span>
333 {% elseif member.isWoman() %}
334 <span>
335 <i class="ui female icon tooltip" aria-hidden="true"></i>
336 <span class="ui special popup">{{ _T('Is a woman') }}</span>
337 </span>
338 {% else %}
339 <i class="ui icon" aria-hidden="true"></i>
340 {% endif %}
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>
345 </a>
346
347 {% else %}
348 <i class="ui icon" aria-hidden="true"></i>
349 {% endif %}
350 {% if member.isAdmin() %}
351 <span>
352 <i class="ui user shield red icon tooltip" aria-hidden="true"></i>
353 <span class="ui special popup">{{ _T('Admin') }}</span>
354 </span>
355 {% elseif member.isStaff() %}
356 <span>
357 <i class="ui user tie orange icon tooltip" aria-hidden="true"></i>
358 <span class="ui special popup">{{ _T('Staff member') }}</span>
359 </span>
360 {% elseif member.getManagedGroups() %}
361 <span>
362 <i class="ui users cog orange icon tooltip" aria-hidden="true"></i>
363 <span class="ui special popup">{{ _T('Group manager') }}</span>
364 </span>
365 {% else %}
366 <i class="ui icon" aria-hidden="true"></i>
367 {% endif %}
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>
370 </td>
371 {% else %}
372 {% set propname = column.propname %}
373 {% set value = null %}
374
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 %}
385 {% endif %}
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>' %}
406 {% else %}
407 {% set value = '<i class="ui icon" aria-hidden="true"></i>' %}
408 {% endif %}
409 {% set value = value ~ member.contribstatus %}
410 {% set escaped = true %}
411 {% endif %}
412
413 {# If value has not been set, take the generic value #}
414 {% if not value %}
415 {% set propvalue = attribute(member, propname) %}
416 {% if propvalue %}
417 {% set value = propvalue|e('html') %}
418 {% else %}
419 {% set value = propvalue %}
420 {% endif %}
421 {% elseif escaped is not defined %}
422 {% set value = value|e('html') %}
423 {% endif %}
424
425 <td data-col-label="{{ column.label }}">
426 {# Display column.
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.
429 #}
430 {% if value %}
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() }}
439 {% else %}
440 {{ value|raw }}
441 {% endif %}
442 {% endif %}
443 </td>
444 {% endif %}
445 {% endfor %}
446 {{ _self.draw_actions(member, login) }}
447 </tr>
448 {% else %}
449 <tr><td colspan="{{ galette_list|length + 1 }}" class="emptylist">{{ _T('No member') }}</td></tr>
450 {% endfor %}
451 {% endblock %}
452
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()) %}
454 {% set batch = {
455 'route': {
456 'name': 'batch-memberslist'
457 },
458 'modal': {
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.")
461 }
462 } %}
463 {% set batch_actions = callstatic('\\Galette\\Core\\Galette', 'getBatchActions') %}
464 {% endif %}
465
466 {% block batch_selection %}
467 else if (value == 'sendmail') {
468 {% if existing_mailing == true %}
469 _sendmail(true);
470 {% else %}
471 _sendmail();
472 {% endif %}
473 }
474 else if (value == 'attendance_sheet') {
475 _attendance_sheet_details();
476 }
477
478 else if (value == 'masscontributions') {
479 _masscontributions();
480 }
481
482 else if (value == 'masschange') {
483 _masschange();
484 }
485 {% endblock %}
486
487 {% block javascripts %}
488 {% set batch_selection = ['masschange', 'masscontributions', 'sendmail', 'attendance_sheet_details'] %}
489 {{ parent() }}
490 <script type="text/javascript">
491 {# Use of Javascript to draw specific elements that are not relevant is JS is inactive #}
492 $(function(){
493 $('#savesearch').on('click', function(e) {
494 e.preventDefault();
495
496 $('body').modal({
497 title: '{{ _T("Search title")|e('js') }}',
498 class: 'tiny',
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();
504 $.ajax({
505 url: '{{ url_for('saveSearch') }}',
506 type: "POST",
507 data: _data,
508 datatype: 'json',
509 {% include "elements/js/loader.js.twig" with {
510 loader: "action",
511 selector: ".loader_selector"
512 } %},
513 success: function(res) {
514 $.ajax({
515 url: '{{ url_for('ajaxMessages') }}',
516 method: "GET",
517 success: function (values) {
518 for (var type in values) {
519 var dtime = 0;
520 if (type == 'success') {
521 dtime = 'auto';
522 }
523 $('body')
524 .toast({
525 displayTime: dtime,
526 minDisplayTime: 5000,
527 wordsPerMinute: 80,
528 showProgress: 'bottom',
529 closeIcon: true,
530 position: 'top attached',
531 title: values[type]['title'],
532 message: values[type]['messages'].join('<br/>'),
533 showIcon: values[type]['icon'],
534 class: type
535 })
536 ;
537 }
538 }
539 });
540 }
541 });
542 },
543 actions: [{
544 text : '{{ _T("Save")|e('js') }}',
545 icon : 'save',
546 class : 'icon labeled primary approve'
547 }, {
548 text : '{{ _T("Cancel")|e('js') }}',
549 icon : 'times',
550 class : 'icon labeled cancel'
551 }]
552 }).modal('show');
553 });
554
555 });
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') }}';
563
564 if (existing) {
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"),
568 modal_class: "tiny",
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"),
575 icon: "edit",
576 class: "blue",
577 click: "function() { location.href = _redirect; }"
578 }
579 } %}
580 } else {
581 _form.submit();
582 }
583 }
584 var _attendance_sheet_details = function(){
585 $.ajax({
586 url: '{{ url_for('attendance_sheet_details') }}',
587 type: "POST",
588 data: {
589 ajax: true,
590 selection: $('#listform input[type=\"checkbox\"]:checked').map(function(){
591 return $(this).val();
592 }).get()
593 },
594 dataType: 'html',
595 {% include "elements/js/loader.js.twig" with {
596 loader: "action",
597 selector: ".loader_selector"
598 } %},
599 success: function(res){
600 var _res = $(res);
601
602 $('body').append(_res);
603
604 {% include "elements/js/modal.js.twig" with {
605 modal_selector: "#attendance_sheet_details",
606 modal_without_title: true,
607 modal_class: "tiny",
608 modal_onshow: "_batchAjaxMapper();",
609 modal_onapprove: "$('#attendance_sheet_details form').submit();"
610 } %}
611 },
612 error: function() {
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,
616 modal_class: "mini",
617 modal_deny_only: true,
618 modal_cancel_text: _T("Close")|e("js"),
619 modal_classname: "redalert",
620 } %}
621 }
622 });
623 }
624 var _masscontributions = function(){
625 $.ajax({
626 url: '{{ url_for('batch-memberslist') }}',
627 type: "POST",
628 data: {
629 ajax: true,
630 masscontributions: true,
631 entries_sel: $('#listform input[type=\"checkbox\"]:checked').map(function(){
632 return $(this).val();
633 }).get()
634 },
635 datatype: 'html',
636 {% include "elements/js/loader.js.twig" with {
637 loader: "action",
638 selector: ".loader_selector"
639 } %},
640 success: function(res){
641 var _res = $(res);
642
643 $('body').append(_res);
644
645 _res.find('form').on('submit', function(e) {
646 e.preventDefault();
647 var _form = $(this);
648 var _data = _form.serialize();
649
650 $.ajax({
651 url: _form.attr('action'),
652 type: "POST",
653 data: _data,
654 datatype: 'json',
655 {% include "elements/js/loader.js.twig" with {
656 loader: "action",
657 selector: ".loader_selector"
658 } %},
659 success: function(data, status, xhr) {
660 var _res = $(data);
661
662 $('#mass_contributions').remove();
663 $('body').append(_res);
664
665 _res.find('form').on('submit', function(e) {
666 e.preventDefault();
667 var _form = $(this);
668 var _data = _form.serialize();
669 $.ajax({
670 url: _form.attr('action'),
671 type: "POST",
672 data: _data,
673 datatype: 'json',
674 {% include "elements/js/loader.js.twig" with {
675 loader: "action",
676 selector: ".loader_selector"
677 } %},
678 success: function(res) {
679 window.location.href = _form.find('input[name=redirect_uri]').val();
680 },
681 error: function() {
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,
686 modal_class: "mini",
687 modal_deny_only: true,
688 modal_cancel_text: _T("Close")|e("js"),
689 modal_classname: "redalert",
690 } %}
691 }
692 });
693 });
694
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;}"
701 } %}
702 },
703 error: function() {
704 {% include "elements/js/modal.js.twig" with {
705 modal_title_twig: _T("An error occurred :(")|e("js"),
706 modal_without_content: true,
707 modal_class: "mini",
708 modal_deny_only: true,
709 modal_cancel_text: _T("Close")|e("js"),
710 modal_classname: "redalert",
711 } %}
712 }
713 });
714 });
715
716 {% include "elements/js/modal.js.twig" with {
717 modal_selector: "#mass_contributions",
718 modal_without_title: true,
719 modal_class: "mini",
720 modal_onshow: "_batchAjaxMapper();",
721 modal_onapprove: "$('#mass_contributions form').submit();"
722 } %}
723 },
724 error: function() {
725 {% include "elements/js/modal.js.twig" with {
726 modal_title_twig: _T("An error occurred :(")|e("js"),
727 modal_without_content: true,
728 modal_class: "mini",
729 modal_deny_only: true,
730 modal_cancel_text: _T("Close")|e("js"),
731 modal_classname: "redalert",
732 } %}
733 }
734 });
735 }
736 var _masschange = function(){
737 $.ajax({
738 url: '{{ url_for('batch-memberslist') }}',
739 type: "POST",
740 data: {
741 ajax: true,
742 masschange: true,
743 entries_sel: $('#listform input[type=\"checkbox\"]:checked').map(function(){
744 return $(this).val();
745 }).get()
746 },
747 datatype: 'json',
748 {% include "elements/js/loader.js.twig" with {
749 loader: "action",
750 selector: ".loader_selector"
751 } %},
752 success: function(res){
753 var _res = $(res);
754
755 $('body').append(_res);
756
757 _res.find('form').on('submit', function(e) {
758 e.preventDefault();
759 var _form = $(this);
760 var _data = _form.serialize();
761 $.ajax({
762 url: _form.attr('action'),
763 type: "POST",
764 data: _data,
765 datatype: 'json',
766 {% include "elements/js/loader.js.twig" with {
767 loader: "action",
768 selector: ".loader_selector"
769 } %},
770 success: function(data, status, xhr) {
771 var _res = $(data);
772
773 $('#mass_change').remove();
774 $('body').append(_res);
775
776 _res.find('form').on('submit', function(e) {
777 e.preventDefault();
778 var _form = $(this);
779 var _data = _form.serialize();
780 $.ajax({
781 url: _form.attr('action'),
782 type: "POST",
783 data: _data,
784 datatype: 'json',
785 {% include "elements/js/loader.js.twig" with {
786 loader: "action",
787 selector: ".loader_selector"
788 } %},
789 success: function(res) {
790 window.location.href = _form.find('input[name=redirect_uri]').val();
791 },
792 error: function() {
793 {% include "elements/js/modal.js.twig" with {
794 modal_title_twig: _T("An error occurred :(")|e("js"),
795 modal_without_content: true,
796 modal_class: "mini",
797 modal_deny_only: true,
798 modal_cancel_text: _T("Close")|e("js"),
799 modal_classname: "redalert",
800 } %}
801 }
802 });
803 });
804
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();"
809 } %}
810 },
811 error: function() {
812 {% include "elements/js/modal.js.twig" with {
813 modal_title_twig: _T("An error occurred :(")|e("js"),
814 modal_without_content: true,
815 modal_class: "mini",
816 modal_deny_only: true,
817 modal_cancel_text: _T("Close")|e("js"),
818 modal_classname: "redalert",
819 } %}
820 }
821 });
822 });
823
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();"
830 } %}
831 },
832 error: function() {
833 {% include "elements/js/modal.js.twig" with {
834 modal_title_twig: _T("An error occurred :(")|e("js"),
835 modal_without_content: true,
836 modal_class: "mini",
837 modal_deny_only: true,
838 modal_cancel_text: _T("Close")|e("js"),
839 modal_classname: "redalert",
840 } %}
841 }
842 });
843 }
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',
849 inline: false,
850 addTouchEvents: false,
851 });
852 {% include 'elements/js/calendar.js.twig' with {
853 selector: ".modal-form [id$='rangestart'], .modal-form [id$='rangeend']"
854 } %}
855 }
856 var _formValidationInModal = function(modal){
857 $(modal +' form').form({
858 inline: true,
859 autoCheckRequired: true,
860 prompt: {
861 empty: '{{ _T("Required field!")|e("js") }}'
862 }
863 })
864 }
865 var _formSubmitInModal = function(modal){
866 var validated = $(modal +' form').form('is valid');
867 if(validated) {
868 $(modal +' form').submit();
869 $(modal).modal('hide dimmer').remove();
870 } else {
871 $(modal +' form').form('validate form');
872 return false;
873 }
874 }
875 {% endif %}
876 </script>
877 {% endblock %}