1 {% extends parent_tpl %}
4 <form action="{% if self_adh %}{{ url_for("storeselfmembers") }}{% elseif not member.id %}{{ url_for("doAddMember") }}{% else %}{{ url_for("doEditMember", {"id": member.id}) }}{% endif %}" method="post" enctype="multipart/form-data" id="form" class="ui form{% if member.id %} edit-member{% endif %}">
5 {% if member.id or not self_adh and members.list is defined and members.list|length > 0 %}
6 <div class="ui stackable grid">
8 <div class="sixteen wide tablet six wide computer five wide widescreen column order-2">
9 <div class="position-sticky">
11 <div class="ui basic clearing horizontally fitted segment">
13 <div class="ui left floated basic fitted segment">
14 {% include "elements/navigate.html.twig" with {"mpath": "editMember"} %}
17 <div class="ui right floated basic fitted segment">
18 <div class="ui small spaced buttons">
20 <button type="submit" name="valid" class="action ui labeled icon primary button">
21 <i class="save icon"></i> {{ _T("Save") }}
25 href="{{ url_for("member", {"id": member.id}) }}"
26 class="ui basic labeled icon button"
28 <i class="eye outline icon"></i>
34 {% include "elements/member_card.html.twig" %}
38 {% if not self_adh and members.list is defined and members.list|length > 0 %}
39 <div class="ui basic horizontally fitted segment">
40 <div class="ui segment">
41 {% if member.hasParent() and not member.isDuplicate() %}
43 <div class="ui label">
44 <i class="linkify icon"></i>
45 {{ _T("Attached to:") }}
47 <div class="ui celled list">
48 <a href="{{ url_for("member", {"id": member.parent.id}) }}" class="item">{{ member.parent.sfullname }}</a>
50 {% if not member.id %}
51 <input type="hidden" name="parent_id" value="{{ member.parent.id }}"/>
54 {% if login.isAdmin() or login.isStaff() and (addchild is not defined or not addchild) %}
56 <div class="ui toggle checkbox">
57 <input type="checkbox" name="detach_parent" id="detach_parent" value="1"/>
58 <label for="detach_parent">{{ _T("Detach?") }}</label>
62 {% elseif (login.isAdmin() or login.isStaff()) and not member.hasChildren() %}
64 <div id="attach-checkbox" class="ui{% if member.isDuplicate() %} checked{% endif %} toggle checkbox">
65 <input type="checkbox" name="attach" id="attach" value="1"{% if member.isDuplicate() %} checked="checked"{% endif %}/>
66 <label for="attach"><i class="linkify icon"></i> {{ _T("Attach member") }}</label>
69 <span id="parent_id_elt" class="">
70 <div id="parent_id" class="jsonly search-dropdown ui input nochosen paginated">
71 <input id="parent_id_input" type="text" name="parent_id" value="{{ member.isDuplicate() and member.parent is defined and member.parent is not null ? member.parent.id }}" placeholder="{{ _T("Member ID") }}">
72 <i class="jsonly displaynone dropdown icon"></i>
73 <span class="ui mini compact icon disabled button prev-results"><i class="jsonly displaynone chevron circle left icon disabled button tooltip" title="{{ _T("Load previous members...") }}"></i></span>
74 <span class="ui mini compact icon disabled button next-results"><i class="jsonly displaynone chevron circle right icon disabled button tooltip" title="{{ _T("Load following members...") }}"></i></span>
75 <div class="jsonly displaynone default text">{{ _T("Search for name or ID and pick member") }}</div>
76 <div class="jsonly displaynone menu">
77 {% for k, v in members.list %}
78 <div class="item" data-value="{{ k }}">{{ v }}</div>
83 {% if member.isDuplicate() %}
84 <input type="hidden" name="duplicate" value="1" />
86 {% elseif member.hasChildren() %}
88 <div class="ui label">
89 <i class="linkify icon"></i>
90 {{ _T("Parent of:") }}
92 <div class="ui celled list">
93 {% for child in member.children %}
94 <a href="{{ url_for("member", {"id": child.id}) }}" class="item">{{ child.sfullname }}</a>
103 {% if member.id or not self_adh and members.list is defined and members.list|length > 0 %}
106 <div class="sixteen wide tablet ten wide computer eleven wide widescreen column">
108 {# Main form entries #}
109 {% include "components/form.html.twig" %}
111 {# Dynamic entries #}
112 {% include "components/dynamic_fields.html.twig" with {object: member} %}
114 {% if not member.id and not self_adh %}
115 {% if login.isAdmin() or login.isStaff() %}
116 <div class="ui center aligned yellow segment">
117 <div class="inline field">
118 <label for="redirect_on_create">{{ _T("After member creation:") }}</label>
119 <select name="redirect_on_create" id="redirect_on_create"i class="ui search dropdown nochosen">
120 <option value="{{ constant('Galette\\Entity\\Adherent::AFTER_ADD_DEFAULT') }}"{% if preferences.pref_redirect_on_create == constant('Galette\\Entity\\Adherent::AFTER_ADD_DEFAULT') %} selected="selected"{% endif %}>{{ _T("create a new contribution (default action)") }}</option>
121 <option value="{{ constant('Galette\\Entity\\Adherent::AFTER_ADD_TRANS') }}"{% if preferences.pref_redirect_on_create == constant('Galette\\Entity\\Adherent::AFTER_ADD_TRANS') %} selected="selected"{% endif %}>{{ _T("create a new transaction") }}</option>
122 <option value="{{ constant('Galette\\Entity\\Adherent::AFTER_ADD_NEW') }}"{% if preferences.pref_redirect_on_create == constant('Galette\\Entity\\Adherent::AFTER_ADD_NEW') %} selected="selected"{% endif %}>{{ _T("create another new member") }}</option>
123 <option value="{{ constant('Galette\\Entity\\Adherent::AFTER_ADD_SHOW') }}"{% if preferences.pref_redirect_on_create == constant('Galette\\Entity\\Adherent::AFTER_ADD_SHOW') %} selected="selected"{% endif %}>{{ _T("show member") }}</option>
124 <option value="{{ constant('Galette\\Entity\\Adherent::AFTER_ADD_LIST') }}"{% if preferences.pref_redirect_on_create == constant('Galette\\Entity\\Adherent::AFTER_ADD_LIST') %} selected="selected"{% endif %}>{{ _T("go to members list") }}</option>
125 <option value="{{ constant('Galette\\Entity\\Adherent::AFTER_ADD_HOME') }}"{% if preferences.pref_redirect_on_create == constant('Galette\\Entity\\Adherent::AFTER_ADD_HOME') %} selected="selected"{% endif %}>{{ _T("go to main page") }}</option>
130 <input type="hidden" name="redirect_on_create" value="{{ constant('Galette\\Entity\\Adherent::AFTER_ADD_SHOW') }}"/>
132 {% if addchild is defined and addchild %}
133 <input type="hidden" name="addchild" value="true"/>
136 {% if preferences.pref_mail_method != constant('Galette\\Core\\GaletteMail::METHOD_DISABLED') and (not self_adh and (login.isAdmin() or login.isStaff())) %}
137 <div class="ui center aligned yellow segment">
138 <div class="inline field">
139 <div class="ui toggle checkbox">
140 <input type="checkbox" name="mail_confirm" id="mail_confirm" value="1"{% if member.sendEMail() %} checked="checked"{% endif %}/>
141 <label for="mail_confirm">
143 {{ _T("Notify member his account has been modified") }}
145 {{ _T("Notify member his account has been created") }}
149 <span class="exemple">
151 {{ _T("Member will be notified by email his account has been modified.") }}
153 {{ _T("Member will receive his username and password by email, if he has an address.") }}
160 <div class="ui basic center aligned fitted segment">
161 <button type="submit" name="valid" class="action ui labeled icon primary button">
162 <i class="save icon"></i> {{ _T("Save") }}
164 {% for entry in hidden_elements %}
165 {% if entry.field_id != 'mdp_adh' %}
166 {% set title = null %}
168 {% set size = null %}
169 {% set propname = entry.propname %}
170 {% if entry.field_id == 'activite_adh' %}
171 {% set value = member.isActive() %}
173 {% set value = attribute(member, propname) %}
175 {% set checked = null %}
176 {% set example = null %}
178 {% if value != '' and entry.field_id != 'parent_id' %}
179 {% include "components/forms/hidden.html.twig" with {
180 name: entry.field_id,
187 {% include "components/forms/csrf.html.twig" %}
190 {% if member.id or not self_adh and members.list is defined and members.list|length > 0 %}
198 {% block javascripts %}
199 <script type="text/javascript">
200 {% include "elements/js/choose_adh.js.twig" with {"js_chosen_id": "#parent_id"} %}
203 $('#company_field.nocompany').addClass('displaynone');
204 $('#is_company').change(function(){
205 $('#company_field').toggleClass('displaynone');
206 $('#company_field').backgroundFade(
213 $(this).backgroundFade(
222 {% if not self_adh %}
224 $('#btngroups, #btnmanagedgroups').click(function(){
225 var _managed = false;
226 if ( $(this).attr('id') == 'btnmanagedgroups' ) {
230 var _form = (_managed) ? 'managed' : 'user';
231 $('#' + _form + 'groups_form input').each(function(){
232 _group = $(this).val().split('|');
233 _groups[_groups.length] = {
239 url: '{{ url_for("ajax_groups") }}',
246 {% include "elements/js/loader.js.twig" with {
247 selector: '#groups_field'
249 success: function(res){
250 _groups_dialog(res, _groups, _managed);
253 {% include "elements/js/modal.js.twig" with {
254 modal_title_twig: _T("An error occurred displaying groups interface :(")|e("js"),
255 modal_without_content: true,
257 modal_deny_only: true,
258 modal_cancel_text: _T("Close")|e("js"),
259 modal_classname: "redalert",
266 var _groups_dialog = function(res, _groups, _managed){
267 var _title = '{{ _T("Groups selection")|e('js') }}';
269 _title = '{{ _T("Managed groups selection")|e('js') }}';
271 {% include "elements/js/modal.js.twig" with {
272 modal_title: "_title",
273 modal_content: "res",
274 modal_class: "groups-selection fullscreen",
275 modal_content_class: "scrolling",
276 modal_deny_only: true,
277 modal_cancel_text: _T("Close")|e("js")
279 _groups_ajax_mapper(res, _groups, _managed);
282 var _groups_ajax_mapper = function(res, _groups, _managed){
283 $('#btnvalid').click(function(){
284 //remove actual groups
285 var _form = (_managed) ? 'managed' : 'user';
286 $('#' + _form + 'groups_form').empty();
287 var _groups = new Array();
288 var _groups_str = '<br/><strong>';
290 _groups_str += '{{ _T("Manager for:")|e('js') }}';
292 _groups_str += '{{ _T("Member of:")|e('js') }}';
294 _groups_str += '</strong> ';
296 $('li[id^="group_"]').each(function(){
298 _gid = this.id.substring(6, this.id.length);
299 _gname = $(this).text();
300 _groups[_groups.length] = this.id.substring(6, this.id.length);
301 var _iname = (_managed) ? 'groups_managed_adh' : 'groups_adh';
302 $('#' + _form + 'groups_form').append(
303 '<input type="hidden" value="' +
304 _gid + '|' + _gname + '|' +
305 '" name="' + _iname + '[]">'
307 if ( _groups.length > 1 ) {
310 _groups_str += _gname;
312 $('#' + _form + 'groups').html(_groups_str);
313 $('.groups-selection').modal('hide');
317 var _none = $('#none_selected').clone();
318 $('li input[type=checkbox]').click(function(e){
321 $('li[id^="group_"]').click(function(){
323 if ( $('#selected_groups ul li').length == 0 ) {
324 $('#selected_groups ul').append(_none);
329 $('#listing tbody tr').click(function(event){
330 event.preventDefault();
331 var _glink = $(this).find('.username_row a');
332 var _gid = _glink[0].href.match(/.*\/(\d+)$/)[1];
333 var _gname = _glink.text();
334 $('#none_selected').remove()
335 if ( $('#group_' + _gid).length == 0 ) {
336 var _li = '<li id="group_' + _gid + '" class="item">'
337 + '<i class="icons"><i class="users icon"><i class="top right corner minus icon"></i></i></i>'
338 + '<span class="ui content">' + _gname + '</span></li>';
339 $('#selected_groups ul').append(_li);
340 $('#group_' + _gid).click(function(){
342 if ( $('#selected_groups ul li').length == 0 ) {
343 $('#selected_groups ul').append(_none);
348 }).css('cursor', 'pointer').attr('title', '{{ _T("Click on a contribution row to attach it to the current transaction")|e('js') }}');
351 {% if not self_adh and not member.hasChildren() %}
352 {# Parent selection #}
353 {% if not member.isDuplicate() %}
354 $('#parent_id_elt').addClass('displaynone');
356 $('#attach-checkbox').checkbox({
357 onChecked: function() {
358 $('#parent_id_elt').removeClass('displaynone');
360 onUnchecked: function() {
361 $('#parent_id_elt').addClass('displaynone');
366 {% if not self_adh %}
367 {% if parent_fields|length > 0 %}
368 $('#detach_parent').on('change', function(){
369 var _checked = $(this).is(':checked');
371 {% for req in parent_fields %}
372 _changes += '#{{ req }}';
373 {% if not loop.last %}
378 $(_changes).attr('required', 'required');
380 $(_changes).removeAttr('required');
384 $('#parent_id').on('change', function(){
385 var _hasParent = $(this).attr('value') != '';
387 {% for req in parent_fields %}
388 _changes += '#{{ req }}';
389 {% if not loop.last %}
394 $(_changes).removeAttr('required');
396 $(_changes).attr('required', 'required');
401 {% include "elements/js/photo_dnd.js.twig" %}
403 $('#ddn_adh').on('blur', function() {
404 var _bdate = $(this).val();
405 if ('{{ _T("Y-m-d") }}' === 'Y-m-d') {
406 _bdate = new Date(_bdate);
409 var _dparts = _bdate.split("/");
410 _bdate = new Date(_dparts[2], _dparts[1] - 1, _dparts[0]);
413 if (! isNaN(_bdate.getTime())) {
414 var _today = new Date();
415 var _age = Math.floor((_today-_bdate) / (365.25 * 24 * 60 * 60 * 1000));
416 $('#member_age').html('{{ _T(" (%age years old)") }}'.replace(/%age/, _age))
418 $('#member_age').html('');