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