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