]> git.agnieray.net Git - galette.git/blob - galette/templates/default/member.tpl
ed5e07883564f817f251b8c5bdf99c61bbfe87fd
[galette.git] / galette / templates / default / member.tpl
1 {extends file="$parent_tpl"}
2
3 {block name="content"}
4 {if isset($navigate) and $navigate|@count != 0}
5 <nav>
6 <a href="{if isset($navigate.prev)}{path_for name="editMember" data=["id" => $navigate.prev]}{else}#{/if}" class="button{if !isset($navigate.prev)} selected{/if}">
7 <i class="fas fa-step-backward"></i>
8 {_T string="Previous"}
9 </a>
10 {$navigate.pos}/{$navigate.count}
11 <a href="{if isset($navigate.next)}{path_for name="editMember" data=["id" => $navigate.next]}{else}#{/if}" class="button{if !isset($navigate.next)} selected{/if}">
12 {_T string="Next"}
13 <i class="fas fa-step-forward"></i>
14 </a>
15 </nav>
16 {/if}
17 <form action="{if $self_adh}{path_for name="storeselfmembers"}{elseif !$member->id}{path_for name="doAddMember"}{else}{path_for name="doEditMember" data=["id" => $member->id]}{/if}" method="post" enctype="multipart/form-data" id="form">
18 <div class="bigtable">
19 <p>{_T string="NB : The mandatory fields are in"} <span class="required">{_T string="red"}</span></p>
20 {if !$self_adh}
21 <div>
22 {if $member->hasParent() && !$member->isDuplicate()}
23 <strong>{_T string="Attached to:"}
24 <a href="{path_for name="member" data=["id" => $member->parent->id]}">{$member->parent->sfullname}</a></strong>
25 {if !$member->id}
26 <input type="hidden" name="parent_id" value="{$member->parent->id}"/>
27 {/if}
28 {if $login->isAdmin() or $login->isStaff() && (!isset($addchild) || !$addchild)}
29 <br/><label for="detach_parent">{_T string="Detach?"}</label>
30 <input type="checkbox" name="detach_parent" id="detach_parent" value="1"/>
31 {/if}
32 {else if ($login->isAdmin() or $login->isStaff()) and !$member->hasChildren() and isset($members.list)}
33 <input type="checkbox" name="attach" id="attach" value="1"{if $member->isDuplicate()} checked="checked"{/if}/>
34 <label for="attach"><i class="fas fa-link"></i> {_T string="Attach member"}</label>
35 <span id="parent_id_elt" class="sr-only">
36 <select name="parent_id" id="parent_id" class="nochosen">
37 <option value="">{_T string="-- select a name --"}</option>
38 {foreach $members.list as $k=>$v}
39 <option value="{$k}"{if $member->isDuplicate() && isset($member->parent) && $member->parent->id eq $k} selected="selected"{/if}>{$v}</option>
40 {/foreach}
41 </select>
42 </span>
43 {if $member->isDuplicate()}
44 <input type="hidden" name="duplicate" value="1" />
45 {/if}
46 {else if $member->hasChildren()}
47 <strong>{_T string="Parent of:"}</strong>
48 {foreach from=$member->children item=child}
49 <a href="{path_for name="member" data=["id" => $child->id]}">{$child->sfullname}</a>{if not $child@last}, {/if}
50 {/foreach}
51 {/if}
52 {/if}
53
54 {* Main form entries*}
55 {include file="forms_types.tpl"}
56 {* Dynamic entries *}
57 {include file="edit_dynamic_fields.tpl" object=$member}
58
59 {include file="edit_socials.tpl" socials=$member->socials social_fieldset_class="galette_form" social_fieldset_legend_class="ui-state-active ui-corner-top"}
60
61 <p>
62 {if !$member->id && !$self_adh}
63 {if ($login->isAdmin() or $login->isStaff())}
64 <label for="redirect_on_create">{_T string="After member creation:"}</label>
65 <select name="redirect_on_create" id="redirect_on_create">
66 <option value="{constant('Galette\Entity\Adherent::AFTER_ADD_DEFAULT')}"{if $preferences->pref_redirect_on_create == constant('Galette\Entity\Adherent::AFTER_ADD_DEFAULT')} selected="selected"{/if}>{_T string="create a new contribution (default action)"}</option>
67 <option value="{constant('Galette\Entity\Adherent::AFTER_ADD_TRANS')}"{if $preferences->pref_redirect_on_create == constant('Galette\Entity\Adherent::AFTER_ADD_TRANS')} selected="selected"{/if}>{_T string="create a new transaction"}</option>
68 <option value="{constant('Galette\Entity\Adherent::AFTER_ADD_NEW')}"{if $preferences->pref_redirect_on_create == constant('Galette\Entity\Adherent::AFTER_ADD_NEW')} selected="selected"{/if}>{_T string="create another new member"}</option>
69 <option value="{constant('Galette\Entity\Adherent::AFTER_ADD_SHOW')}"{if $preferences->pref_redirect_on_create == constant('Galette\Entity\Adherent::AFTER_ADD_SHOW')} selected="selected"{/if}>{_T string="show member"}</option>
70 <option value="{constant('Galette\Entity\Adherent::AFTER_ADD_LIST')}"{if $preferences->pref_redirect_on_create == constant('Galette\Entity\Adherent::AFTER_ADD_LIST')} selected="selected"{/if}>{_T string="go to members list"}</option>
71 <option value="{constant('Galette\Entity\Adherent::AFTER_ADD_HOME')}"{if $preferences->pref_redirect_on_create == constant('Galette\Entity\Adherent::AFTER_ADD_HOME')} selected="selected"{/if}>{_T string="go to main page"}</option>
72 </select>
73 <br/>
74 {else}
75 <input type="hidden" name="redirect_on_create" value="{constant('Galette\Entity\Adherent::AFTER_ADD_SHOW')}"/>
76 {/if}
77 {if isset($addchild) && $addchild}
78 <input type="hidden" name="addchild" value="true"/>
79 {/if}
80 {/if}
81
82 {if $pref_mail_method neq constant('Galette\Core\GaletteMail::METHOD_DISABLED') and (!$self_adh and ($login->isAdmin() or $login->isStaff()))}
83 <br/><label for="mail_confirm">
84 {if $member->id}
85 {_T string="Notify member his account has been modified"}
86 {else}
87 {_T string="Notify member his account has been created"}
88 {/if}
89 </label>
90 <input type="checkbox" name="mail_confirm" id="mail_confirm" value="1" {if $preferences->pref_bool_mailowner || isset($smarty.post.mail_confirm) and $smarty.post.mail_confirm != ""}checked="checked"{/if}/>
91 <br/><span class="exemple">
92 {if $member->id}
93 {_T string="Member will be notified by email his account has been modified."}
94 {else}
95 {_T string="Member will receive his username and password by email, if he has an address."}
96 {/if}
97 </span>
98 {/if}
99 </p>
100 </div>
101 <div class="button-container">
102 <button type="submit" name="valid" class="action">
103 <i class="fas fa-save fa-fw"></i> {_T string="Save"}
104 </button>
105
106
107 {foreach item=entry from=$hidden_elements}
108 {if $entry->field_id neq 'mdp_adh'}
109 {assign var="title" value=null}
110 {assign var="tip" value=null}
111 {assign var="size" value=null}
112 {assign var="propname" value=$entry->propname}
113 {if $entry->field_id eq 'activite_adh'}
114 {assign var="value" value=$member->isActive()}
115 {else}
116 {assign var="value" value=$member->$propname}
117 {/if}
118 {assign var="checked" value=null}
119 {assign var="example" value=null}
120
121 {if $value neq '' and $entry->field_id neq 'parent_id'}
122 {include
123 file="forms_types/hidden.tpl"
124 name=$entry->field_id
125 id=$entry->field_id
126 value=$value
127 }
128 {/if}
129 {/if}
130 {/foreach}
131
132 <a href="#" id="back2top">{_T string="Back to top"}</a>
133 </div>
134 </form>
135 {/block}
136
137 {block name="javascripts"}
138 <script type="text/javascript">
139 {include file="js_chosen_adh.tpl" js_chosen_id="#parent_id"}
140 $(function() {
141 $('#is_company').change(function(){
142 $('#company_field').toggleClass('hidden');
143 $('#company_field').backgroundFade(
144 {
145 sColor:'#ffffff',
146 eColor:'#DDDDFF',
147 steps:10
148 },
149 function() {
150 $(this).backgroundFade(
151 {
152 sColor:'#DDDDFF',
153 eColor:'#ffffff'
154 }
155 );
156 });
157 });
158
159 _collapsibleFieldsets();
160
161 $('#ddn_adh').datepicker({
162 changeMonth: true,
163 changeYear: true,
164 showOn: 'button',
165 maxDate: '-0d',
166 yearRange: '-200:+0',
167 buttonText: '<i class="far fa-calendar-alt"></i> <span class="sr-only">{_T string="Select a date" escape="js"}</span>'
168 });
169 $('#date_crea_adh').datepicker({
170 changeMonth: true,
171 changeYear: true,
172 showOn: 'button',
173 maxDate: '-0d',
174 yearRange: 'c-10:c+0',
175 buttonText: '<i class="far fa-calendar-alt"></i> <span class="sr-only">{_T string="Select a date" escape="js"}</span>'
176 });
177
178 {if !$self_adh}
179 {* Groups popup *}
180 $('#btngroups, #btnmanagedgroups').click(function(){
181 var _managed = false;
182 if ( $(this).attr('id') == 'btnmanagedgroups' ) {
183 _managed = true;
184 }
185 var _groups = [];
186 var _form = (_managed) ? 'managed' : 'user';
187 $('#' + _form + 'groups_form input').each(function(){
188 _group = $(this).val().split('|');
189 _groups[_groups.length] = {
190 id: _group[0],
191 name: _group[1]
192 };
193 });
194 $.ajax({
195 url: '{path_for name="ajax_groups"}',
196 type: "POST",
197 data: {
198 ajax: true,
199 groups: _groups,
200 managed: _managed
201 },
202 {include file="js_loader.tpl"},
203 success: function(res){
204 _groups_dialog(res, _groups, _managed);
205 },
206 error: function() {
207 alert("{_T string="An error occurred displaying groups interface :(" escape="js"}");
208 }
209 });
210 return false;
211 });
212
213 var _groups_dialog = function(res, _groups, _managed){
214 var _title = '{_T string="Groups selection" escape="js"}';
215 if ( _managed ) {
216 _title = '{_T string="Managed groups selection" escape="js"}';
217 }
218 var _el = $('<div id="ajax_groups_list" title="' + _title + '"> </div>');
219 _el.appendTo('body').dialog({
220 modal: true,
221 hide: 'fold',
222 width: '80%',
223 height: 500,
224 close: function(event, ui){
225 _el.remove();
226 },
227 create: function (event, ui) {
228 if ($(window ).width() < 767) {
229 $(this).dialog('option', {
230 'width': '95%',
231 'draggable': false
232 });
233 }
234 }
235 });
236 _groups_ajax_mapper(res, _groups, _managed);
237 }
238
239 var _groups_ajax_mapper = function(res, _groups, _managed){
240 $('#ajax_groups_list').append(res);
241 $('#btnvalid').button().click(function(){
242 //remove actual groups
243 var _form = (_managed) ? 'managed' : 'user';
244 $('#' + _form + 'groups_form').empty();
245 var _groups = new Array();
246 var _groups_str = '<br/><strong>';
247 if ( _managed ) {
248 _groups_str += '{_T string="Manager for:" escape="js"}';
249 } else {
250 _groups_str += '{_T string="Member of:" escape="js"}';
251 }
252 _groups_str += '</strong> ';
253
254 $('li[id^="group_"]').each(function(){
255 //get group values
256 _gid = this.id.substring(6, this.id.length);
257 _gname = $(this).text();
258 _groups[_groups.length] = this.id.substring(6, this.id.length);
259 var _iname = (_managed) ? 'groups_managed_adh' : 'groups_adh';
260 $('#' + _form + 'groups_form').append(
261 '<input type="hidden" value="' +
262 _gid + '|' + _gname + '|' +
263 '" name="' + _iname + '[]">'
264 );
265 if ( _groups.length > 1 ) {
266 _groups_str += ', ';
267 }
268 _groups_str += _gname;
269 });
270 $('#' + _form + 'groups').html(_groups_str);
271 $('#ajax_groups_list').dialog("close");
272 });
273 //Remap links
274 var _none = $('#none_selected').clone();
275 $('li input[type=checkbox]').click(function(e){
276 e.stopPropagation();
277 });
278 $('li[id^="group_"]').click(function(){
279 $(this).remove();
280 if ( $('#selected_groups ul li').length == 0 ) {
281 $('#selected_groups ul').append(_none);
282 }
283 });
284 $('#listing a').click(function(e){
285 e.preventDefault();
286 var _gid = this.href.match(/.*\/(\d+)$/)[1];
287 var _gname = $(this).text();
288 $('#none_selected').remove()
289 if ( $('#group_' + _gid).length == 0 ) {
290 var _li = '<li id="group_' + _gid + '"><i class="fas fa-user-minus"></i> ' + _gname + '</li>';
291 $('#selected_groups ul').append(_li);
292 $('#group_' + _gid).click(function(){
293 $(this).remove();
294 if ( $('#selected_groups ul li').length == 0 ) {
295 $('#selected_groups ul').append(_none);
296 }
297 });
298 }
299 return false;
300 });
301
302 }
303
304 {if !$self_adh and !$member->hasChildren()}
305 {* Parent selection *}
306 $('#parent_id_elt').removeClass('sr-only');
307 {if !$member->isDuplicate()}
308 $('#parent_id_elt').hide();
309 {/if}
310 $('#attach').on('click', function() {
311 var _checked = $(this).is(':checked');
312 $('#parent_id_elt').toggle();
313 });
314 {/if}
315
316 {if !$self_adh}
317 {if $parent_fields|@count gt 0}
318 $('#detach_parent').on('change', function(){
319 var _checked = $(this).is(':checked');
320 var _changes = '';
321 {foreach item=req from=$parent_fields}
322 _changes += '#{$req}';
323 {if !$req@last}
324 _changes += ',';
325 {/if}
326 {/foreach}
327 if (_checked) {
328 $(_changes).attr('required', 'required');
329 } else {
330 $(_changes).removeAttr('required');
331 }
332 });
333
334 $('#parent_id').on('change', function(){
335 var _hasParent = $(this).attr('value') != '';
336 var _changes = '';
337 {foreach item=req from=$parent_fields}
338 _changes += '#{$req}';
339 {if !$req@last}
340 _changes += ',';
341 {/if}
342 {/foreach}
343 if (_hasParent) {
344 $(_changes).removeAttr('required');
345 } else {
346 $(_changes).attr('required', 'required');
347 }
348 });
349 {/if}
350 {/if}
351 {include file="photo_dnd.tpl"}
352
353 $('#ddn_adh').on('blur', function() {
354 var _bdate = $(this).val();
355 if ('{_T string="Y-m-d"}' === 'Y-m-d') {
356 _bdate = new Date(_bdate);
357 } else {
358 //try for dd/mm/yyyy
359 var _dparts = _bdate.split("/");
360 _bdate = new Date(_dparts[2], _dparts[1] - 1, _dparts[0]);
361 }
362
363 if (! isNaN(_bdate.getTime())) {
364 var _today = new Date();
365 var _age = Math.floor((_today-_bdate) / (365.25 * 24 * 60 * 60 * 1000));
366 $('#member_age').html('{_T string=" (%age years old)"}'.replace(/%age/, _age))
367 } else {
368 $('#member_age').html('');
369 }
370 });
371 {/if}
372 });
373 </script>
374 {/block}