]> git.agnieray.net Git - galette.git/blob - galette/templates/default/pages/members_list.html.twig
2417f40317e8cce92d8b490d63284d84fdc5aebc
[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 {% endif %}
404
405 {# If value has not been set, take the generic value #}
406 {% if not value %}
407 {% set propvalue = attribute(member, propname) %}
408 {% if propvalue %}
409 {% set value = propvalue|e('html') %}
410 {% else %}
411 {% set value = propvalue %}
412 {% endif %}
413 {% elseif escaped is not defined %}
414 {% set value = value|e('html') %}
415 {% endif %}
416
417 <td data-col-label="{{ column.label }}">
418 {# Display column.
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.
421 #}
422 {% if value %}
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() }}
431 {% else %}
432 {{ value|raw }}
433 {% endif %}
434 {% endif %}
435 </td>
436 {% endif %}
437 {% endfor %}
438 {{ _self.draw_actions(member, login) }}
439 </tr>
440 {% else %}
441 <tr><td colspan="{{ galette_list|length + 1 }}" class="emptylist">{{ _T('No member has been found') }}</td></tr>
442 {% endfor %}
443 {% endblock %}
444
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()) %}
446 {% set batch = {
447 'route': {
448 'name': 'batch-memberslist'
449 },
450 'modal': {
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.")
453 }
454 } %}
455 {% set batch_actions = callstatic('\\Galette\\Core\\Galette', 'getBatchActions') %}
456 {% endif %}
457
458 {% block batch_selection %}
459 else if (value == 'sendmail') {
460 {% if existing_mailing == true %}
461 _sendmail(true);
462 {% else %}
463 _sendmail();
464 {% endif %}
465 }
466 else if (value == 'attendance_sheet') {
467 _attendance_sheet_details();
468 }
469
470 else if (value == 'masscontributions') {
471 _masscontributions();
472 }
473
474 else if (value == 'masschange') {
475 _masschange();
476 }
477 {% endblock %}
478
479 {% block javascripts %}
480 {% set batch_selection = ['masschange', 'masscontributions', 'sendmail', 'attendance_sheet_details'] %}
481 {{ parent() }}
482 <script type="text/javascript">
483 {# Use of Javascript to draw specific elements that are not relevant is JS is inactive #}
484 $(function(){
485 $('#savesearch').on('click', function(e) {
486 e.preventDefault();
487
488 $('body').modal({
489 title: '{{ _T("Search title")|e('js') }}',
490 class: 'tiny',
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();
496 $.ajax({
497 url: '{{ url_for('saveSearch') }}',
498 type: "POST",
499 data: _data,
500 datatype: 'json',
501 {% include "elements/js/loader.js.twig" with {
502 loader: "action",
503 selector: ".loader_selector"
504 } %},
505 success: function(res) {
506 $.ajax({
507 url: '{{ url_for('ajaxMessages') }}',
508 method: "GET",
509 success: function (values) {
510 for (var type in values) {
511 var dtime = 0;
512 if (type == 'success') {
513 dtime = 'auto';
514 }
515 $('body')
516 .toast({
517 displayTime: dtime,
518 minDisplayTime: 5000,
519 wordsPerMinute: 80,
520 showProgress: 'bottom',
521 closeIcon: true,
522 position: 'top attached',
523 title: values[type]['title'],
524 message: values[type]['messages'].join('<br/>'),
525 showIcon: values[type]['icon'],
526 class: type
527 })
528 ;
529 }
530 }
531 });
532 }
533 });
534 },
535 actions: [{
536 text : '{{ _T("Save")|e('js') }}',
537 icon : 'save',
538 class : 'icon labeled primary approve'
539 }, {
540 text : '{{ _T("Cancel")|e('js') }}',
541 icon : 'times',
542 class : 'icon labeled cancel'
543 }]
544 }).modal('show');
545 });
546
547 });
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') }}';
555
556 if (existing) {
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"),
560 modal_class: "tiny",
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"),
567 icon: "edit",
568 class: "blue",
569 click: "function() { location.href = _redirect; }"
570 }
571 } %}
572 } else {
573 _form.submit();
574 }
575 }
576 var _attendance_sheet_details = function(){
577 $.ajax({
578 url: '{{ url_for('attendance_sheet_details') }}',
579 type: "POST",
580 data: {
581 ajax: true,
582 selection: $('#listform input[type=\"checkbox\"]:checked').map(function(){
583 return $(this).val();
584 }).get()
585 },
586 dataType: 'html',
587 {% include "elements/js/loader.js.twig" with {
588 loader: "action",
589 selector: ".loader_selector"
590 } %},
591 success: function(res){
592 var _res = $(res);
593
594 $('body').append(_res);
595
596 {% include "elements/js/modal.js.twig" with {
597 modal_selector: "#attendance_sheet_details",
598 modal_without_title: true,
599 modal_class: "tiny",
600 modal_onshow: "_batchAjaxMapper();",
601 modal_onapprove: "$('#attendance_sheet_details form').submit();"
602 } %}
603 },
604 error: function() {
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,
608 modal_class: "mini",
609 modal_deny_only: true,
610 modal_cancel_text: _T("Close")|e("js"),
611 modal_classname: "redalert",
612 } %}
613 }
614 });
615 }
616 var _masscontributions = function(){
617 $.ajax({
618 url: '{{ url_for('batch-memberslist') }}',
619 type: "POST",
620 data: {
621 ajax: true,
622 masscontributions: true,
623 entries_sel: $('#listform input[type=\"checkbox\"]:checked').map(function(){
624 return $(this).val();
625 }).get()
626 },
627 datatype: 'html',
628 {% include "elements/js/loader.js.twig" with {
629 loader: "action",
630 selector: ".loader_selector"
631 } %},
632 success: function(res){
633 var _res = $(res);
634
635 $('body').append(_res);
636
637 _res.find('form').on('submit', function(e) {
638 e.preventDefault();
639 var _form = $(this);
640 var _data = _form.serialize();
641
642 $.ajax({
643 url: _form.attr('action'),
644 type: "POST",
645 data: _data,
646 datatype: 'json',
647 {% include "elements/js/loader.js.twig" with {
648 loader: "action",
649 selector: ".loader_selector"
650 } %},
651 success: function(data, status, xhr) {
652 var _res = $(data);
653
654 $('#mass_contributions').remove();
655 $('body').append(_res);
656
657 _res.find('form').on('submit', function(e) {
658 e.preventDefault();
659 var _form = $(this);
660 var _data = _form.serialize();
661 $.ajax({
662 url: _form.attr('action'),
663 type: "POST",
664 data: _data,
665 datatype: 'json',
666 {% include "elements/js/loader.js.twig" with {
667 loader: "action",
668 selector: ".loader_selector"
669 } %},
670 success: function(res) {
671 window.location.href = _form.find('input[name=redirect_uri]').val();
672 },
673 error: function() {
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,
678 modal_class: "mini",
679 modal_deny_only: true,
680 modal_cancel_text: _T("Close")|e("js"),
681 modal_classname: "redalert",
682 } %}
683 }
684 });
685 });
686
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;}"
693 } %}
694 },
695 error: function() {
696 {% include "elements/js/modal.js.twig" with {
697 modal_title_twig: _T("An error occurred :(")|e("js"),
698 modal_without_content: true,
699 modal_class: "mini",
700 modal_deny_only: true,
701 modal_cancel_text: _T("Close")|e("js"),
702 modal_classname: "redalert",
703 } %}
704 }
705 });
706 });
707
708 {% include "elements/js/modal.js.twig" with {
709 modal_selector: "#mass_contributions",
710 modal_without_title: true,
711 modal_class: "mini",
712 modal_onshow: "_batchAjaxMapper();",
713 modal_onapprove: "$('#mass_contributions form').submit();"
714 } %}
715 },
716 error: function() {
717 {% include "elements/js/modal.js.twig" with {
718 modal_title_twig: _T("An error occurred :(")|e("js"),
719 modal_without_content: true,
720 modal_class: "mini",
721 modal_deny_only: true,
722 modal_cancel_text: _T("Close")|e("js"),
723 modal_classname: "redalert",
724 } %}
725 }
726 });
727 }
728 var _masschange = function(){
729 $.ajax({
730 url: '{{ url_for('batch-memberslist') }}',
731 type: "POST",
732 data: {
733 ajax: true,
734 masschange: true,
735 entries_sel: $('#listform input[type=\"checkbox\"]:checked').map(function(){
736 return $(this).val();
737 }).get()
738 },
739 datatype: 'json',
740 {% include "elements/js/loader.js.twig" with {
741 loader: "action",
742 selector: ".loader_selector"
743 } %},
744 success: function(res){
745 var _res = $(res);
746
747 $('body').append(_res);
748
749 _res.find('form').on('submit', function(e) {
750 e.preventDefault();
751 var _form = $(this);
752 var _data = _form.serialize();
753 $.ajax({
754 url: _form.attr('action'),
755 type: "POST",
756 data: _data,
757 datatype: 'json',
758 {% include "elements/js/loader.js.twig" with {
759 loader: "action",
760 selector: ".loader_selector"
761 } %},
762 success: function(data, status, xhr) {
763 var _res = $(data);
764
765 $('#mass_change').remove();
766 $('body').append(_res);
767
768 _res.find('form').on('submit', function(e) {
769 e.preventDefault();
770 var _form = $(this);
771 var _data = _form.serialize();
772 $.ajax({
773 url: _form.attr('action'),
774 type: "POST",
775 data: _data,
776 datatype: 'json',
777 {% include "elements/js/loader.js.twig" with {
778 loader: "action",
779 selector: ".loader_selector"
780 } %},
781 success: function(res) {
782 window.location.href = _form.find('input[name=redirect_uri]').val();
783 },
784 error: function() {
785 {% include "elements/js/modal.js.twig" with {
786 modal_title_twig: _T("An error occurred :(")|e("js"),
787 modal_without_content: true,
788 modal_class: "mini",
789 modal_deny_only: true,
790 modal_cancel_text: _T("Close")|e("js"),
791 modal_classname: "redalert",
792 } %}
793 }
794 });
795 });
796
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();"
801 } %}
802 },
803 error: function() {
804 {% include "elements/js/modal.js.twig" with {
805 modal_title_twig: _T("An error occurred :(")|e("js"),
806 modal_without_content: true,
807 modal_class: "mini",
808 modal_deny_only: true,
809 modal_cancel_text: _T("Close")|e("js"),
810 modal_classname: "redalert",
811 } %}
812 }
813 });
814 });
815
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();"
822 } %}
823 },
824 error: function() {
825 {% include "elements/js/modal.js.twig" with {
826 modal_title_twig: _T("An error occurred :(")|e("js"),
827 modal_without_content: true,
828 modal_class: "mini",
829 modal_deny_only: true,
830 modal_cancel_text: _T("Close")|e("js"),
831 modal_classname: "redalert",
832 } %}
833 }
834 });
835 }
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',
841 inline: false,
842 addTouchEvents: false,
843 });
844 {% include 'elements/js/calendar.js.twig' with {
845 selector: ".modal-form [id$='rangestart'], .modal-form [id$='rangeend']"
846 } %}
847 }
848 var _formValidationInModal = function(modal){
849 $(modal +' form').form({
850 inline: true,
851 autoCheckRequired: true,
852 prompt: {
853 empty: '{{ _T("Required field!")|e("js") }}'
854 }
855 })
856 }
857 var _formSubmitInModal = function(modal){
858 var validated = $(modal +' form').form('is valid');
859 if(validated) {
860 $(modal +' form').submit();
861 $(modal).modal('hide dimmer').remove();
862 } else {
863 $(modal +' form').form('validate form');
864 return false;
865 }
866 }
867 {% endif %}
868 </script>
869 {% endblock %}