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