return $statuses_list[$id];
});
$view->getEnvironment()->addFunction($function);
+
+ $view->getEnvironment()->addFunction(
+ new \Twig\TwigFunction('callstatic', function ($class, $method, ...$args) {
+ if (!class_exists($class)) {
+ throw new \Exception("Cannot call static method $method on Class $class: Invalid Class");
+ }
+
+ if (!method_exists($class, $method)) {
+ throw new \Exception("Cannot call static method $method on Class $class: Invalid method");
+ }
+
+ return forward_static_call_array([$class, $method], $args);
+ })
+ );
//End Twig functions
//Twig globals
*
* PHP version 5
*
- * Copyright © 2020-2021 The Galette Team
+ * Copyright © 2020-2022 The Galette Team
*
* This file is part of Galette (http://galette.tuxfamily.org).
*
* @package Galette
*
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020-2021 The Galette Team
+ * @copyright 2020-2022 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.9.4dev - 2020-05-08
* @name ContributionsController
* @package Galette
* @author Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020-2021 The Galette Team
+ * @copyright 2020-2022 The Galette Team
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
* @link http://galette.tuxfamily.org
* @since Available since 0.9.4dev - 2020-05-02
}
//assign pagination variables to the template and add pagination links
- $filters->setSmartyPagination($this->router, $this->view->getSmarty());
+ $filters->setSmartyPagination($this->router, $this->view);
$tpl_vars = [
'page_title' => $raw_type === 'contributions' ?
$this->session->filter_mailings = $filters;
//assign pagination variables to the template and add pagination links
- $mailhist->filters->setSmartyPagination($this->router, $this->view->getSmarty());
+ $mailhist->filters->setSmartyPagination($this->router, $this->view);
$history_list = $mailhist->getHistory();
//assign pagination variables to the template and add pagination links
- $mailhist->filters->setSmartyPagination($this->router, $this->view->getSmarty());
+ $mailhist->filters->setSmartyPagination($this->router, $this->view);
// display page
$this->view->render(
// display page
$this->view->render(
$response,
- 'member.tpl',
+ 'pages/member_form.html.twig',
array(
'page_title' => _T("Subscription"),
- 'parent_tpl' => 'public_page.tpl',
+ 'parent_tpl' => 'public_page.html.twig',
'member' => $member,
'self_adh' => true,
'autocomplete' => true,
$this->session->$varname = $filters;
//assign pagination variables to the template and add pagination links
- $filters->setSmartyPagination($this->router, $this->view->getSmarty(), false);
+ $filters->setSmartyPagination($this->router, $this->view, false);
// display page
$this->view->render(
}
//assign pagination variables to the template and add pagination links
- $filters->setSmartyPagination($this->router, $this->view->getSmarty(), false);
+ $filters->setSmartyPagination($this->router, $this->view, false);
$this->session->ajax_members_filters = $filters;
// display page
$this->view->render(
$response,
- 'member.tpl',
+ 'pages/member_form.html.twig',
array(
- 'parent_tpl' => 'page.tpl',
+ 'parent_tpl' => 'page.html.twig',
'autocomplete' => true,
'page_title' => $title,
'member' => $member,
$list = $searches->getList(true);
//assign pagination variables to the template and add pagination links
- $filters->setSmartyPagination($this->router, $this->view->getSmarty(), false);
+ $filters->setSmartyPagination($this->router, $this->view, false);
$this->session->filter_savedsearch = $filters;
$logs = $this->history->getHistory();
//assign pagination variables to the template and add pagination links
- $this->history->filters->setSmartyPagination($this->router, $this->view->getSmarty());
+ $this->history->filters->setSmartyPagination($this->router, $this->view);
// display page
$this->view->render(
}
}
}
- $this->view->getSmarty()->assign('navigate', $navigate);
+ $this->view->getEnvironment()->addGlobal('navigate', $navigate);
return $next($request, $response);
}
+++ /dev/null
-{extends file="$parent_tpl"}
-
-{block name="content"}
- {if $member->id}
- {include file="ui_elements/navigate.tpl"}
- {include file="ui_elements/member_card.tpl"}
- {/if}
-
- <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" class="ui form">
- {if !$self_adh}
- <div class="ui compact segment">
- {if $member->hasParent() && !$member->isDuplicate()}
- <div class="inline field">
- <span class="ui primary ribbon label">{_T string="Attached to:"}</span>
- <a href="{path_for name="member" data=["id" => $member->parent->id]}" class="ui label">{$member->parent->sfullname}</a>
- {if !$member->id}
- <input type="hidden" name="parent_id" value="{$member->parent->id}"/>
- {/if}
- </div>
- {if $login->isAdmin() or $login->isStaff() && (!isset($addchild) || !$addchild)}
- <div class="inline field">
- <div class="ui toggle checkbox">
- <input type="checkbox" name="detach_parent" id="detach_parent" value="1"/>
- <label for="detach_parent">{_T string="Detach?"}</label>
- </div>
- </div>
- {/if}
- {else if ($login->isAdmin() or $login->isStaff()) and !$member->hasChildren() and isset($members.list)}
- <input type="checkbox" name="attach" id="attach" value="1"{if $member->isDuplicate()} checked="checked"{/if}/>
- <label for="attach"><i class="linkify icon"></i> {_T string="Attach member"}<label>
- <span id="parent_id_elt" class="sr-only">
- <select name="parent_id" id="parent_id" class="nochosen">
- <option value="">{_T string="-- select a name --"}</option>
- {foreach $members.list as $k=>$v}
- <option value="{$k}"{if $member->isDuplicate() && isset($member->parent) && $member->parent->id eq $k} selected="selected"{/if}>{$v}</option>
- {/foreach}
- </select>
- </span>
- {if $member->isDuplicate()}
- <input type="hidden" name="duplicate" value="1" />
- {/if}
- {else if $member->hasChildren()}
- <div class="inline field">
- <span class="ui primary ribbon label">{_T string="Parent of:"}</span>
- {foreach from=$member->children item=child}
- <a href="{path_for name="member" data=["id" => $child->id]}" class="ui label">{$child->sfullname}</a>{if not $child@last}, {/if}
- {/foreach}
- </div>
- {/if}
- </div>
- {/if}
- {* Main form entries*}
- {include file="forms_types.tpl"}
- {* Dynamic entries *}
- {include file="edit_dynamic_fields.tpl" object=$member}
- {include file="edit_socials.tpl" socials=$member->socials social_fieldset_class="galette_form" social_fieldset_legend_class="ui-state-active ui-corner-top"}
-
- {if !$member->id && !$self_adh}
- {if ($login->isAdmin() or $login->isStaff())}
- <div class="ui center aligned segment">
- <div class="inline field">
- <label for="redirect_on_create">{_T string="After member creation:"}</label>
- <select name="redirect_on_create" id="redirect_on_create"i class="ui search dropdown nochosen">
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- </select>
- </div>
- </div>
- {else}
- <input type="hidden" name="redirect_on_create" value="{constant('Galette\Entity\Adherent::AFTER_ADD_SHOW')}"/>
- {/if}
- {if isset($addchild) && $addchild}
- <input type="hidden" name="addchild" value="true"/>
- {/if}
- {/if}
- {if $pref_mail_method neq constant('Galette\Core\GaletteMail::METHOD_DISABLED') and (!$self_adh and ($login->isAdmin() or $login->isStaff()))}
- <div class="ui center aligned segment">
- <div class="inline field">
- <div class="ui toggle checkbox">
- <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}/>
- <label for="mail_confirm">
- {if $member->id}
- {_T string="Notify member his account has been modified"}
- {else}
- {_T string="Notify member his account has been created"}
- {/if}
- </label>
- <br/>
- <span class="exemple">
- {if $member->id}
- {_T string="Member will be notified by email his account has been modified."}
- {else}
- {_T string="Member will receive his username and password by email, if he has an address."}
- {/if}
- </span>
- </div>
- </div>
- </div>
- {/if}
- <div class="ui basic center aligned fitted segment">
- <button type="submit" name="valid" class="action ui labeled icon primary button">
- <i class="save icon"></i> {_T string="Save"}
- </button>
- {foreach item=entry from=$hidden_elements}
- {if $entry->field_id neq 'mdp_adh'}
- {assign var="title" value=null}
- {assign var="tip" value=null}
- {assign var="size" value=null}
- {assign var="propname" value=$entry->propname}
- {if $entry->field_id eq 'activite_adh'}
- {assign var="value" value=$member->isActive()}
- {else}
- {assign var="value" value=$member->$propname}
- {/if}
- {assign var="checked" value=null}
- {assign var="example" value=null}
-
- {if $value neq '' and $entry->field_id neq 'parent_id'}
- {include
- file="forms_types/hidden.tpl"
- name=$entry->field_id
- id=$entry->field_id
- value=$value
- }
- {/if}
- {/if}
- {/foreach}
- {include file="forms_types/csrf.tpl"}
- </div>
- </form>
-{/block}
-
-{block name="javascripts"}
- <script type="text/javascript">
- {include file="js_chosen_adh.tpl" js_chosen_id="#parent_id"}
- $(function() {
- $('#is_company').change(function(){
- $('#company_field').toggleClass('hidden');
- $('#company_field').backgroundFade(
- {
- sColor:'#ffffff',
- eColor:'#DDDDFF',
- steps:10
- },
- function() {
- $(this).backgroundFade(
- {
- sColor:'#DDDDFF',
- eColor:'#ffffff'
- }
- );
- });
- });
-
- /*$('#ddn_adh').datepicker({
- changeMonth: true,
- changeYear: true,
- showOn: 'button',
- maxDate: '-0d',
- yearRange: '-200:+0',
- buttonText: '<i class="ui calendar alt icon"></i> <span class="sr-only">{_T string="Select a date" escape="js"}</span>'
- });
- $('#date_crea_adh').datepicker({
- changeMonth: true,
- changeYear: true,
- showOn: 'button',
- maxDate: '-0d',
- yearRange: 'c-10:c+0',
- buttonText: '<i class="ui calendar alt icon"></i> <span class="sr-only">{_T string="Select a date" escape="js"}</span>'
- });*/
-
-{if !$self_adh}
- {* Groups popup *}
- $('#btngroups, #btnmanagedgroups').click(function(){
- var _managed = false;
- if ( $(this).attr('id') == 'btnmanagedgroups' ) {
- _managed = true;
- }
- var _groups = [];
- var _form = (_managed) ? 'managed' : 'user';
- $('#' + _form + 'groups_form input').each(function(){
- _group = $(this).val().split('|');
- _groups[_groups.length] = {
- id: _group[0],
- name: _group[1]
- };
- });
- $.ajax({
- url: '{path_for name="ajax_groups"}',
- type: "POST",
- data: {
- ajax: true,
- groups: _groups,
- managed: _managed
- },
- {include file="js_loader.tpl"},
- success: function(res){
- _groups_dialog(res, _groups, _managed);
- },
- error: function() {
- alert("{_T string="An error occurred displaying groups interface :(" escape="js"}");
- }
- });
- return false;
- });
-
- var _groups_dialog = function(res, _groups, _managed){
- var _title = '{_T string="Groups selection" escape="js"}';
- if ( _managed ) {
- _title = '{_T string="Managed groups selection" escape="js"}';
- }
- var _el = $('<div id="ajax_groups_list" title="' + _title + '"> </div>');
- _el.appendTo('body').dialog({
- modal: true,
- hide: 'fold',
- width: '80%',
- height: 500,
- close: function(event, ui){
- _el.remove();
- },
- create: function (event, ui) {
- if ($(window ).width() < 767) {
- $(this).dialog('option', {
- 'width': '95%',
- 'draggable': false
- });
- }
- }
- });
- _groups_ajax_mapper(res, _groups, _managed);
- }
-
- var _groups_ajax_mapper = function(res, _groups, _managed){
- $('#ajax_groups_list').append(res);
- $('#btnvalid').button().click(function(){
- //remove actual groups
- var _form = (_managed) ? 'managed' : 'user';
- $('#' + _form + 'groups_form').empty();
- var _groups = new Array();
- var _groups_str = '<br/><strong>';
- if ( _managed ) {
- _groups_str += '{_T string="Manager for:" escape="js"}';
- } else {
- _groups_str += '{_T string="Member of:" escape="js"}';
- }
- _groups_str += '</strong> ';
-
- $('li[id^="group_"]').each(function(){
- //get group values
- _gid = this.id.substring(6, this.id.length);
- _gname = $(this).text();
- _groups[_groups.length] = this.id.substring(6, this.id.length);
- var _iname = (_managed) ? 'groups_managed_adh' : 'groups_adh';
- $('#' + _form + 'groups_form').append(
- '<input type="hidden" value="' +
- _gid + '|' + _gname + '|' +
- '" name="' + _iname + '[]">'
- );
- if ( _groups.length > 1 ) {
- _groups_str += ', ';
- }
- _groups_str += _gname;
- });
- $('#' + _form + 'groups').html(_groups_str);
- $('#ajax_groups_list').dialog("close");
- });
- //Remap links
- var _none = $('#none_selected').clone();
- $('li input[type=checkbox]').click(function(e){
- e.stopPropagation();
- });
- $('li[id^="group_"]').click(function(){
- $(this).remove();
- if ( $('#selected_groups ul li').length == 0 ) {
- $('#selected_groups ul').append(_none);
- }
- });
- $('#listing a').click(function(e){
- e.preventDefault();
- var _gid = this.href.match(/.*\/(\d+)$/)[1];
- var _gname = $(this).text();
- $('#none_selected').remove()
- if ( $('#group_' + _gid).length == 0 ) {
- var _li = '<li id="group_' + _gid + '"><i class="ui user minus icon"></i> ' + _gname + '</li>';
- $('#selected_groups ul').append(_li);
- $('#group_' + _gid).click(function(){
- $(this).remove();
- if ( $('#selected_groups ul li').length == 0 ) {
- $('#selected_groups ul').append(_none);
- }
- });
- }
- return false;
- });
-
- }
-
- {if !$self_adh and !$member->hasChildren()}
- {* Parent selection *}
- $('#parent_id_elt').removeClass('sr-only');
- {if !$member->isDuplicate()}
- $('#parent_id_elt').hide();
- {/if}
- $('#attach').on('click', function() {
- var _checked = $(this).is(':checked');
- $('#parent_id_elt').toggle();
- });
- {/if}
-
- {if !$self_adh}
- {if $parent_fields|@count gt 0}
- $('#detach_parent').on('change', function(){
- var _checked = $(this).is(':checked');
- var _changes = '';
- {foreach item=req from=$parent_fields}
- _changes += '#{$req}';
- {if !$req@last}
- _changes += ',';
- {/if}
- {/foreach}
- if (_checked) {
- $(_changes).attr('required', 'required');
- } else {
- $(_changes).removeAttr('required');
- }
- });
-
- $('#parent_id').on('change', function(){
- var _hasParent = $(this).attr('value') != '';
- var _changes = '';
- {foreach item=req from=$parent_fields}
- _changes += '#{$req}';
- {if !$req@last}
- _changes += ',';
- {/if}
- {/foreach}
- if (_hasParent) {
- $(_changes).removeAttr('required');
- } else {
- $(_changes).attr('required', 'required');
- }
- });
- {/if}
- {/if}
- {include file="photo_dnd.tpl"}
-
- $('#ddn_adh').on('blur', function() {
- var _bdate = $(this).val();
- if ('{_T string="Y-m-d"}' === 'Y-m-d') {
- _bdate = new Date(_bdate);
- } else {
- //try for dd/mm/yyyy
- var _dparts = _bdate.split("/");
- _bdate = new Date(_dparts[2], _dparts[1] - 1, _dparts[0]);
- }
-
- if (! isNaN(_bdate.getTime())) {
- var _today = new Date();
- var _age = Math.floor((_today-_bdate) / (365.25 * 24 * 60 * 60 * 1000));
- $('#member_age').html('{_T string=" (%age years old)"}'.replace(/%age/, _age))
- } else {
- $('#member_age').html('');
- }
- });
-{/if}
- });
- </script>
-{/block}
+++ /dev/null
- {if $member->id}
- //Photo dnd
- // Check if window.FileReader exists to make
- // sure the browser supports file uploads
- if ( typeof(window.FileReader) ) {
- var _dz = $('#photo_adh');
-
- // Add a nice drag effect
- _dz[0].ondragover = function() {
- _dz.addClass('dndhover');
- return false;
- };
-
- // Remove the drag effect when stopping our drag
- _dz[0].ondragend = function() {
- _dz.removeClass('dndhover');
- return false;
- };
-
- // The drop event handles the file sending
- _dz[0].ondrop = function(event) {
- // Stop the browser from opening the file in the window
- event.preventDefault();
- _dz.removeClass('dndhover');
-
- var file = event.dataTransfer.files[0];
- var reader = new FileReader();
- reader.readAsDataURL(file);
-
- reader.onload = function(evt) {
- $.ajax({
- type: 'POST',
- dataType: 'json',
- url : '{path_for name="photoDnd"}',
- data: {
- member_id: {$member->id},
- filename: file.name,
- filesize: file.size,
- file: evt.target.result
- },
- {include file="js_loader.tpl"},
- success: function(res){
- if ( res.result == true ) {
- d = new Date();
- var _photo = $('#photo_adh');
- _photo.removeAttr('width').removeAttr('height');
- _photo.attr('src', $('#photo_adh')[0].src + '?' + d.getTime());
- }
-
- //display message
- $.ajax({
- url: '{path_for name="ajaxMessages"}',
- method: "GET",
- success: function (message) {
- $('#asso_name').after(message);
- }
- });
- },
- error: function() {
- alert("{_T string="An error occurred sending photo :(" escape="js"}");
- }
- });
- }
- }
- }
- {/if}
+++ /dev/null
-<div class="ui horizontal card">
- <div class="image">
- {if $login->isAdmin() or $login->isStaff() or $login->login eq $member->login}
- <a class="ui right corner inverted label">
- <i class="upload icon"></i>
- </a>
- {/if}
- <img
- src="{path_for name="photo" data=["id" => $member->id, "rand" => $time]}"
- width="{$member->picture->getOptimalWidth()}"
- height="{$member->picture->getOptimalHeight()}"
- alt="{_T string="Picture"}"
- {if $login->isAdmin() or $login->isStaff() or $login->login eq $member->login} title="{_T string="You can drop new image here to get photo changed"}" class="tooltip"{/if}
- id="photo_adh"/>
- </div>
- <div class="content">
- <div class="header aligned">
- {$member->sname}
- </div>
- <div class="meta aligned">
- <span>{$member->sstatus}</span>
- <span class="ui {$member->getRowClass()} horizontal icon label tooltip" title="{$member->getDues()|escape}">
- <i class="icon cookie"></i>
- </span>
- </div>
- <div class="description">
- <div class="ui relaxed divided list">
- {if $member->phone || $member->gsm}
- <div class="item">
- <div class="content">
- <span class="header">{_T string="Phone"}</span>
- <div class="description">
- {if $member->phone}
- {$member->phone}
- {/if}
- {if $member->gsm}
- {if $member->phone}, {/if}
- {$member->gsm}
- {/if}
- </div>
- </div>
- </div>
- {/if}
- {if $member->getEmail()}
- <div class="item">
- <div class="content">
- <span class="blue header">{_T string="Email"}</span>
- <div class="description">{$member->getEMail()}</div>
- </div>
- </div>
- {/if}
- </div>
- </div>
- </div>
-</div>
+++ /dev/null
-{if isset($navigate) and $navigate|@count != 0}
- <nav class="ui mini inverted pagination menu right floated">
- {if isset($navigate.prev)}
- <a
- href="{if isset($navigate.prev)}{path_for name="member" data=["id" => $navigate.prev]}{else}#{/if}"
- class="{if !isset($navigate.prev)} disabled{/if} item"
- title="{_T string="Previous"|escape}"
- >
- <i class="step backward icon"></i>
- <span class="sr-only">{_T string="Previous"}</span>
- </a>
- {/if}
- <div class="item">{$navigate.pos} / {$navigate.count}</div>
- {if isset($navigate.next)}
- <a
- href="{if isset($navigate.next)}{path_for name="member" data=["id" => $navigate.next]}{else}#{/if}"
- class="{if !isset($navigate.next)} disabled{/if} item"
- title="{_T string="Next"|escape}"
- >
- <span class="sr-only">{_T string="Next"}</span>
- <i class="step forward icon"></i>
- </a>
- {/if}
- </nav>
-{/if}
</div>
</div>
</div>
- {include file="ui_elements/navigate.tpl"}
+ {% include "elements/navigate.html.twig" with { "mpath": "member" } %}
{include file="ui_elements/member_card.tpl"}
{if $member->hasParent() or $member->hasChildren()}
<div class="grouped fields">
<div class="field required">
-{% include "components/forms/textarea.html.twig"
- name: entry.field_id,
- id: entry.field_id,
- value: member.address|escape,
- required: entry.required,
- disabled: entry.disabled,
- label: entry.label,
- notag: true,
- elt_class: "large",
+{% include "components/forms/textarea.html.twig" with {
+ name: entry.field_id,
+ id: entry.field_id,
+ value: member.address|escape,
+ required: entry.required,
+ disabled: entry.disabled,
+ label: entry.label,
+ notag: true,
+ elt_class: "large"
+ }
%}
</div>
</div>
<div class="grouped fields">
-{include
- file="forms_types/checkbox.tpl"
- name="is_company"
- id="is_company"
- value="1"
- label={_T string="Is company?"}
- title={_T string="Is member a company?"}
- tip={_T string="Do you manage a non profit organization, or a company? If you do so, check the box, and then enter its name in the field that will appear."}
- checked=$member->isCompany()
- component_class="field"
-}
+{% include "components/forms/checkbox.html.twig" with {
+ name: "is_company",
+ id: "is_company",
+ value: "1",
+ label: _T("Is company?"),
+ title: _T("Is member a company?"),
+ tip: _T("Do you manage a non profit organization, or a company? If you do so, check the box, and then enter its name in the field that will appear."),
+ checked: member.isCompany(),
+ component_class: "field"
+ }
+%}
<div class="field">
-{include
- file="forms_types/text.tpl"
- name=$entry->field_id
- id=$entry->field_id
- value=$member->company_name
- required=$entry->required
- disabled=$entry->disabled
- label=$entry->label
- component_id="company_field"
- component_class="{if not $member->isCompany()}hidden{/if}"
-}
+{% include "components/forms/text.html.twig" with {
+ name: entry.field_id,
+ id: entry.field_id,
+ value: member.company_name,
+ required: entry.required,
+ disabled: entry.disabled,
+ label: entry.label,
+ component_id: "company_field",
+ component_class: "{% if not member.isCompany() %}hidden{% endif %}"
+ }
+%}
</div>
</div>
<div class="field">
- <label>{_T string="Groups:"}</label>
- {if $login->isGroupManager()}
+ <label>{{ _T("Groups:") }}</label>
+ {% if login.isGroupManager() %}
<a class="ui icon button" id="btngroups">
<i class="user tag icon" aria-hidden="true"></i>
- {_T string="Manage user's groups"}
+ {{ _T("Manage user's groups") }}
</a>
- {/if}
- {if $login->isAdmin() or $login->isStaff()}
+ {% endif %}
+ {% if login.isAdmin() or login.isStaff() %}
<a class="ui icon button" id="btnmanagedgroups">
<i class="user shield icon" aria-hidden="true"></i>
- {_T string="Manage user's managed groups"}
+ {{ _T("Manage user's managed groups") }}
</a>
- {/if}
+ {% endif %}
<span id="usergroups_form">
- {if $member->id}
- {foreach from=$groups item=group}
- {if $member->isGroupMember($group->getName())}
- <input type="hidden" name="groups_adh[]" value="{$group->getId()}|{$group->getName()}"/>
- {/if}
- {/foreach}
- {/if}
+ {% if member.id %}
+ {% for group in groups %}
+ {% if member.isGroupMember(group.getName()) %}
+ <input type="hidden" name="groups_adh[]" value="{{ group.getId() }}|{{ group.getName() }}"/>
+ {% endif %}
+ {% endfor %}
+ {% endif %}
</span>
- {if $login->isAdmin() or $login->isStaff() or $login->isGroupManager()}
+ {% if login.isAdmin() or login.isStaff() or login.isGroupManager() %}
<span id="managedgroups_form">
- {if $member->id}
- {foreach from=$groups item=group}
- {if $member->isGroupManager($group->getName())}
- <input type="hidden" name="groups_managed_adh[]" value="{$group->getId()}|{$group->getName()}"/>
- {/if}
- {/foreach}
- {/if}
+ {% if member.id %}
+ {% for group in groups %}
+ {% if member.isGroupManager(group.getName()) %}
+ <input type="hidden" name="groups_managed_adh[]" value="{{ group.getId() }}|{{ group.getName() }}"/>
+ {% endif %}
+ {% endfor %}
+ {% endif %}
</span>
- {/if}
- {if $login->isAdmin() or $login->isStaff() or $login->isGroupManager()}<br/>{/if}
+ {% endif %}
+ {% if login.isAdmin() or login.isStaff() or login.isGroupManager() %}<br/>{% endif %}
<span id="usergroups">
- {if $member->id}
- {foreach from=$groups item=group name=groupsiterate}
- {if $member->isGroupMember($group->getName())}
- {if isset($isnotfirst)}, {else}<strong>{_T string="Member of:"}</strong>{/if}
- {assign var=isnotfirst value=true}
- {$group->getName()}
- {/if}
- {/foreach}
- {/if}
+ {% if member.id %}
+ {% for group in groups %}
+ {% if member.isGroupMember(group.getName()) %}
+ {% if isnotfirst is defined %}, {% else %}<strong>{{ _T("Member of:") }}</strong>{% endif %}
+ {% set isnotfirst = true %}
+ {{ group.getName() }}
+ {% endif %}
+ {% endfor %}
+ {% endif %}
</span>
- {if isset($isnotfirst)}<br/>{/if}
+ {% if isnotfirst is defined %}<br/>{% endif %}
<span id="managedgroups">
- {if $member->id}
- {foreach from=$groups item=group name=groupsmiterate}
- {if $member->isGroupManager($group->getName())}
- {if isset($isnotfirstm)}, {else}<strong>{_T string="Manager for:"}</strong>{/if}
- {assign var=isnotfirstm value=true}
- {$group->getName()}
- {/if}
- {/foreach}
- {/if}
+ {% if member.id %}
+ {% for group in groups %}
+ {% if member.isGroupManager(group.getName()) %}
+ {% if isnotfirstm is defined %}, {% else %}<strong>{{ _T("Manager for:") }}</strong>{% endif %}
+ {% set isnotfirstm = true %}
+ {{ group.getName() }}
+ {% endif %}
+ {% endfor %}
+ {% endif %}
</span>
</div>
-{include
- file="forms_types/input.tpl"
- type="password"
- name=$entry->field_id
- id=$entry->field_id
- required=$entry->required
- disabled=$entry->disabled
- label=$entry->label
- autocomplete="off"
- value=null
- component_class="field"
-}
-{include
- file="forms_types/input.tpl"
- type="password"
- name="mdp_adh2"
- id="mdp_adh2"
- required=$entry->required
- disabled=$entry->disabled
- label={_T string="Password confirmation:"}
- autocomplete="off"
- elt_class="labelalign"
- value=null
- component_class="field"
-}
+{% include "components/forms/input.html.twig" with {
+ type: "password",
+ name: entry.field_id,
+ id: entry.field_id,
+ required: entry.required,
+ disabled: entry.disabled,
+ label: entry.label,
+ autocomplete: "off",
+ value: null,
+ component_class: "field"
+ }
+%}
+{% include "components/forms/input.html.twig" with {
+ type: "password",
+ name: "mdp_adh2",
+ id: "mdp_adh2",
+ required: entry.required,
+ disabled: entry.disabled,
+ label: _T("Password confirmation:"),
+ autocomplete: "off",
+ elt_class: "labelalign",
+ value: null,
+ component_class: "field"
+ }
+%}
<script type="text/javascript">
$(function() {
{% include "elements/js/pwdcheck.js.twig" with { selector: '#' ~ entry.field_id } %}
-{if !isset($show_inline)}
+{% if show_inline is not defined %}
<div class="field">
-{else}
+{% else %}
<div class="field inline">
-{/if}
- <label for="{$varname}">{if isset($label)}{$label}{else}{_T string="Payment type:"}{/if}</label>
- <select name="{$varname}" id="{$varname}" class="ui search dropdown nochosen">
-{if isset($empty)}
- <option value="{$empty.value}">{$empty.label}</option>
-{/if}
-{assign var="ptypes" value=\Galette\Repository\PaymentTypes::getAll()}
-{foreach from=$ptypes item=ptype}
- <option value="{$ptype->id}"{if $current eq $ptype->id} selected="selected"{/if}>{$ptype->getName()}</option>
-{/foreach}
+{% endif %}
+ <label for="{{ varname }}">{% if label is edfined %}{{ label }}{% else %}{{ _T("Payment type:") }}{% endif %}</label>
+ <select name="{{ varname }}" id="{{ varname }}" class="ui search dropdown nochosen">
+{% if empty is defined %}
+ <option value="{{ empty.value }}">{{ empty.label }}</option>
+{% endif %}
+{% set ptypes = callstatic('\\Galette\\Repository\\PaymentTypes', 'getAll') %}
+{% for ptype in ptypes %}
+ <option value="{{ ptype.id }}"{% if current == ptype.id %} selected="selected"{% endif %}>{{ ptype.getName() }}</option>
+{% endfor %}
</select>
</div>
{% if elt_class is defined %} class="{{ elt_class }}"{% endif %}
{% if autocomplete is defined %} autocomplete="{{ autocomplete }}"{% endif %}
{% if size is defined %} size="{$size}"{% endif %}
- >{% if value is not sameas(null) %}{{ value }}{% endif %}</textarea><br/>
+ >{% if value is not same as(null) %}{{ value }}{% endif %}</textarea><br/>
{% endblock %}
--- /dev/null
+ {% if member.id %}
+ //Photo dnd
+ // Check if window.FileReader exists to make
+ // sure the browser supports file uploads
+ if ( typeof(window.FileReader) ) {
+ var _dz = $('#photo_adh');
+
+ // Add a nice drag effect
+ _dz[0].ondragover = function() {
+ _dz.addClass('dndhover');
+ return false;
+ };
+
+ // Remove the drag effect when stopping our drag
+ _dz[0].ondragend = function() {
+ _dz.removeClass('dndhover');
+ return false;
+ };
+
+ // The drop event handles the file sending
+ _dz[0].ondrop = function(event) {
+ // Stop the browser from opening the file in the window
+ event.preventDefault();
+ _dz.removeClass('dndhover');
+
+ var file = event.dataTransfer.files[0];
+ var reader = new FileReader();
+ reader.readAsDataURL(file);
+
+ reader.onload = function(evt) {
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url : '{{ path_for("photoDnd") }}',
+ data: {
+ member_id: {{ member.id }},
+ filename: file.name,
+ filesize: file.size,
+ file: evt.target.result
+ },
+ {% include "elements/js/loader.js.twig" %},
+ success: function(res){
+ if ( res.result == true ) {
+ d = new Date();
+ var _photo = $('#photo_adh');
+ _photo.removeAttr('width').removeAttr('height');
+ _photo.attr('src', $('#photo_adh')[0].src + '?' + d.getTime());
+ }
+
+ //display message
+ $.ajax({
+ url: '{{ path_for("ajaxMessages") }}',
+ method: "GET",
+ success: function (message) {
+ $('#asso_name').after(message);
+ }
+ });
+ },
+ error: function() {
+ alert("{{ _T("An error occurred sending photo :(")|e('js') }}");
+ }
+ });
+ }
+ }
+ }
+ {% endif %}
--- /dev/null
+<div class="ui horizontal card">
+ <div class="image">
+ {% if login.isAdmin() or login.isStaff() or login.login == member.login %}
+ <a class="ui right corner inverted label">
+ <i class="upload icon"></i>
+ </a>
+ {% endif %}
+ <img
+ src="{{ path_for("photo", { "id": member.id, "rand": time }) }}"
+ width="{{ member.picture.getOptimalWidth() }}"
+ height="{{ member.picture.getOptimalHeight() }}"
+ alt="{{ _T("Picture") }}"
+ {% if login.isAdmin() or login.isStaff() or login.login == member.login %} title="{{ _T("You can drop new image here to get photo changed") }}" class="tooltip"{% endif %}
+ id="photo_adh"/>
+ </div>
+ <div class="content">
+ <div class="header aligned">
+ {{ member.sname }}
+ </div>
+ <div class="meta aligned">
+ <span>{{ member.sstatus }}</span>
+ <span class="ui {{ member.getRowClass() }} horizontal icon label tooltip" title="{{ member.getDues()|escape }}">
+ <i class="icon cookie"></i>
+ </span>
+ </div>
+ <div class="description">
+ <div class="ui relaxed divided list">
+ {% if member.phone or member.gsm %}
+ <div class="item">
+ <div class="content">
+ <span class="header">{{ _T("Phone") }}</span>
+ <div class="description">
+ {% if member.phone %}
+ {{ member.phone }}
+ {% endif %}
+ {% if member.gsm %}
+ {% if member.phone %}, {% endif %}
+ {{ member.gsm }}
+ {% endif %}
+ </div>
+ </div>
+ </div>
+ {% endif %}
+ {% if member.getEmail() %}
+ <div class="item">
+ <div class="content">
+ <span class="blue header">{{ _T("Email") }}</span>
+ <div class="description">{{ member.getEMail() }}</div>
+ </div>
+ </div>
+ {% endif %}
+ </div>
+ </div>
+ </div>
+</div>
--- /dev/null
+{% if navigate is defined and navigate|length != 0 %}
+ <nav class="ui mini inverted pagination menu right floated">
+ {% if navigate.prev is defined %}
+ <a
+ href="{{ path_for(mpath, {"id": navigate.prev }) }}"
+ class="item"
+ title="{{ _T("Previous")|escape }}"
+ >
+ <i class="step backward icon"></i>
+ <span class="sr-only">{{ _T("Previous") }}</span>
+ </a>
+ {% endif %}
+ <div class="item">{{ navigate.pos }} / {{ navigate.count }}</div>
+ {% if navigate.next is defined %}
+ <a
+ href="{{ path_for(mpath, { "id": navigate.next }) }}"
+ class="item"
+ title="{{ _T("Next")|escape }}"
+ >
+ <span class="sr-only">{{ _T("Next") }}</span>
+ <i class="step forward icon"></i>
+ </a>
+ {% endif %}
+ </nav>
+{% endif %}
--- /dev/null
+{% extends parent_tpl %}
+
+{% block content %}
+ {% if member.id %}
+ {% include "elements/navigate.html.twig" with { "mpath": "editMember" } %}
+ {% include "elements/member_card.html.twig" %}
+ {% endif %}
+
+ <form action="{% if self_adh %}{{ path_for("storeselfmembers") }}{% elseif not member.id %}{{ path_for("doAddMember") }}{% else %}{{ path_for("doEditMember", { "id": member.id }) }}{% endif %}" method="post" enctype="multipart/form-data" id="form" class="ui form">
+ {% if not self_adh %}
+ <div class="ui compact segment">
+ {% if member.hasParent() and not member.isDuplicate() %}
+ <div class="inline field">
+ <span class="ui primary ribbon label">{{ _T("Attached to:") }}</span>
+ <a href="{{ path_for("member", { "id": member.parent.id }) }}" class="ui label">{{ member.parent.sfullname }}</a>
+ {% if not member.id %}
+ <input type="hidden" name="parent_id" value="{{ member.parent.id }}"/>
+ {% endif %}
+ </div>
+ {% if login.isAdmin() or login.isStaff() and (addchild is not defined or not addchild) %}
+ <div class="inline field">
+ <div class="ui toggle checkbox">
+ <input type="checkbox" name="detach_parent" id="detach_parent" value="1"/>
+ <label for="detach_parent">{{ _T("Detach?") }}</label>
+ </div>
+ </div>
+ {% endif %}
+ {% elseif (login.isAdmin() or login.isStaff()) and not member.hasChildren() and members.list is defined %}
+ <input type="checkbox" name="attach" id="attach" value="1"{% if member.isDuplicate() %} checked="checked"{% endif %}/>
+ <label for="attach"><i class="linkify icon"></i> {{ _T("Attach member") }}</label>
+ <span id="parent_id_elt" class="sr-only">
+ <select name="parent_id" id="parent_id" class="nochosen">
+ <option value="">{{ _T("-- select a name --") }}</option>
+ {% for k, v in members.list %}
+ <option value="{{ k }}"{% if member.isDuplicate() and member.parent is defined and member.parent.id == k %} selected="selected"{% endif %}>{{ v }}</option>
+ {% endfor %}
+ </select>
+ </span>
+ {% if member.isDuplicate() %}
+ <input type="hidden" name="duplicate" value="1" />
+ {% endif %}
+ {% elseif member.hasChildren() %}
+ <div class="inline field">
+ <span class="ui primary ribbon label">{{ _T("Parent of:") }}</span>
+ {% for child in member.children %}
+ <a href="{{ path_for("member", { "id": child.id }) }}" class="ui label">{{ child.sfullname }}</a>{% if not loop.last %}, {% endif %}
+ {% endfor %}
+ </div>
+ {% endif %}
+ </div>
+ {% endif %}
+ {# Main form entries #}
+ {% include "components/form.html.twig" %}
+ {# Dynamic entries #}
+ {% include "components/edit_dynamic_fields.html.twig" with { object: member } %}
+ {% include "elements/edit_socials.html.twig" with { socials: member.socials, social_fieldset_class: "galette_form", social_fieldset_legend_class: "ui-state-active ui-corner-top"} %}
+
+ {% if not member.id and not self_adh %}
+ {% if login.isAdmin() or login.isStaff() %}
+ <div class="ui center aligned segment">
+ <div class="inline field">
+ <label for="redirect_on_create">{{ _T("After member creation:") }}</label>
+ <select name="redirect_on_create" id="redirect_on_create"i class="ui search dropdown nochosen">
+ <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>
+ <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>
+ <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>
+ <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>
+ <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>
+ <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>
+ </select>
+ </div>
+ </div>
+ {% else %}
+ <input type="hidden" name="redirect_on_create" value="{constant('Galette\\Entity\\Adherent::AFTER_ADD_SHOW')}"/>
+ {% endif %}
+ {% if addchild is defined and addchild %}
+ <input type="hidden" name="addchild" value="true"/>
+ {% endif %}
+ {% endif %}
+ {% if preferences.pref_mail_method != constant('Galette\\Core\\GaletteMail::METHOD_DISABLED') and (not self_adh and (login.isAdmin() or login.isStaff())) %}
+ <div class="ui center aligned segment">
+ <div class="inline field">
+ <div class="ui toggle checkbox">
+ <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#}/>
+ <label for="mail_confirm">
+ {% if member.id %}
+ {{ _T("Notify member his account has been modified") }}
+ {% else %}
+ {{ _T("Notify member his account has been created") }}
+ {% endif %}
+ </label>
+ <br/>
+ <span class="exemple">
+ {% if member.id %}
+ {{ _T("Member will be notified by email his account has been modified.") }}
+ {% else %}
+ {{ _T("Member will receive his username and password by email, if he has an address.") }}
+ {% endif %}
+ </span>
+ </div>
+ </div>
+ </div>
+ {% endif %}
+ <div class="ui basic center aligned fitted segment">
+ <button type="submit" name="valid" class="action ui labeled icon primary button">
+ <i class="save icon"></i> {{ _T("Save") }}
+ </button>
+ {% for entry in hidden_elements %}
+ {% if entry.field_id != 'mdp_adh' %}
+ {% set title = null %}
+ {% set tip = null %}
+ {% set size = null %}
+ {% set propname = entry.propname %}
+ {% if entry.field_id == 'activite_adh' %}
+ {% set value = member.isActive() %}
+ {% else%}
+ {% set value = attribute(member, propname) %}
+ {% endif %}
+ {% set checked = null %}
+ {% set example = null %}
+
+ {% if value != '' and entry.field_id != 'parent_id' %}
+ {% include "components/forms/hidden.html.twig" with {
+ name: entry.field_id,
+ id: entry.field_id,
+ value: value
+ }
+ %}
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+ {% include "components/forms/csrf.html.twig" %}
+ </div>
+ </form>
+{% endblock %}
+
+{% block javascripts %}
+ <script type="text/javascript">
+ {include file="js_chosen_adh.tpl" js_chosen_id="#parent_id"}
+ $(function() {
+ $('#is_company').change(function(){
+ $('#company_field').toggleClass('hidden');
+ $('#company_field').backgroundFade(
+ {
+ sColor:'#ffffff',
+ eColor:'#DDDDFF',
+ steps:10
+ },
+ function() {
+ $(this).backgroundFade(
+ {
+ sColor:'#DDDDFF',
+ eColor:'#ffffff'
+ }
+ );
+ });
+ });
+
+ /*$('#ddn_adh').datepicker({
+ changeMonth: true,
+ changeYear: true,
+ showOn: 'button',
+ maxDate: '-0d',
+ yearRange: '-200:+0',
+ buttonText: '<i class="ui calendar alt icon"></i> <span class="sr-only">{{ _T("Select a date")|e('js') }}</span>'
+ });
+ $('#date_crea_adh').datepicker({
+ changeMonth: true,
+ changeYear: true,
+ showOn: 'button',
+ maxDate: '-0d',
+ yearRange: 'c-10:c+0',
+ buttonText: '<i class="ui calendar alt icon"></i> <span class="sr-only">{{ _T("Select a date")|e('js') }}</span>'
+ });*/
+
+{% if not self_adh %}
+ {# Groups popup #}
+ $('#btngroups, #btnmanagedgroups').click(function(){
+ var _managed = false;
+ if ( $(this).attr('id') == 'btnmanagedgroups' ) {
+ _managed = true;
+ }
+ var _groups = [];
+ var _form = (_managed) ? 'managed' : 'user';
+ $('#' + _form + 'groups_form input').each(function(){
+ _group = $(this).val().split('|');
+ _groups[_groups.length] = {
+ id: _group[0],
+ name: _group[1]
+ };
+ });
+ $.ajax({
+ url: '{{ path_for("ajax_groups") }}',
+ type: "POST",
+ data: {
+ ajax: true,
+ groups: _groups,
+ managed: _managed
+ },
+ {% include "elements/js/loader.js.twig" %},
+ success: function(res){
+ _groups_dialog(res, _groups, _managed);
+ },
+ error: function() {
+ alert("{{ _T("An error occurred displaying groups interface :(")|e('js') }}");
+ }
+ });
+ return false;
+ });
+
+ var _groups_dialog = function(res, _groups, _managed){
+ var _title = '{{ _T("Groups selection")|e('js') }}';
+ if ( _managed ) {
+ _title = '{{ _T("Managed groups selection")|e('js') }}';
+ }
+ var _el = $('<div id="ajax_groups_list" title="' + _title + '"> </div>');
+ _el.appendTo('body').dialog({
+ modal: true,
+ hide: 'fold',
+ width: '80%',
+ height: 500,
+ close: function(event, ui){
+ _el.remove();
+ },
+ create: function (event, ui) {
+ if ($(window ).width() < 767) {
+ $(this).dialog('option', {
+ 'width': '95%',
+ 'draggable': false
+ });
+ }
+ }
+ });
+ _groups_ajax_mapper(res, _groups, _managed);
+ }
+
+ var _groups_ajax_mapper = function(res, _groups, _managed){
+ $('#ajax_groups_list').append(res);
+ $('#btnvalid').button().click(function(){
+ //remove actual groups
+ var _form = (_managed) ? 'managed' : 'user';
+ $('#' + _form + 'groups_form').empty();
+ var _groups = new Array();
+ var _groups_str = '<br/><strong>';
+ if ( _managed ) {
+ _groups_str += '{{ _T("Manager for:")|e('js') }}';
+ } else {
+ _groups_str += '{{ _T("Member of:")|e('js') }}';
+ }
+ _groups_str += '</strong> ';
+
+ $('li[id^="group_"]').each(function(){
+ //get group values
+ _gid = this.id.substring(6, this.id.length);
+ _gname = $(this).text();
+ _groups[_groups.length] = this.id.substring(6, this.id.length);
+ var _iname = (_managed) ? 'groups_managed_adh' : 'groups_adh';
+ $('#' + _form + 'groups_form').append(
+ '<input type="hidden" value="' +
+ _gid + '|' + _gname + '|' +
+ '" name="' + _iname + '[]">'
+ );
+ if ( _groups.length > 1 ) {
+ _groups_str += ', ';
+ }
+ _groups_str += _gname;
+ });
+ $('#' + _form + 'groups').html(_groups_str);
+ $('#ajax_groups_list').dialog("close");
+ });
+ //Remap links
+ var _none = $('#none_selected').clone();
+ $('li input[type=checkbox]').click(function(e){
+ e.stopPropagation();
+ });
+ $('li[id^="group_"]').click(function(){
+ $(this).remove();
+ if ( $('#selected_groups ul li').length == 0 ) {
+ $('#selected_groups ul').append(_none);
+ }
+ });
+ $('#listing a').click(function(e){
+ e.preventDefault();
+ var _gid = this.href.match(/.*\/(\d+)$/)[1];
+ var _gname = $(this).text();
+ $('#none_selected').remove()
+ if ( $('#group_' + _gid).length == 0 ) {
+ var _li = '<li id="group_' + _gid + '"><i class="ui user minus icon"></i> ' + _gname + '</li>';
+ $('#selected_groups ul').append(_li);
+ $('#group_' + _gid).click(function(){
+ $(this).remove();
+ if ( $('#selected_groups ul li').length == 0 ) {
+ $('#selected_groups ul').append(_none);
+ }
+ });
+ }
+ return false;
+ });
+
+ }
+
+ {% if not self_adh and not member.hasChildren() %}
+ {* Parent selection *}
+ $('#parent_id_elt').removeClass('sr-only');
+ {% if not member.isDuplicate() %}
+ $('#parent_id_elt').hide();
+ {% endif %}
+ $('#attach').on('click', function() {
+ var _checked = $(this).is(':checked');
+ $('#parent_id_elt').toggle();
+ });
+ {% endif %}
+
+ {% if not self_adh %}
+ {% if parent_fields|length > 0 %}
+ $('#detach_parent').on('change', function(){
+ var _checked = $(this).is(':checked');
+ var _changes = '';
+ {% for req in parent_fields %}
+ _changes += '#{{ req }}';
+ {% if not loop.last %}
+ _changes += ',';
+ {% endif %}
+ {% endfor %}
+ if (_checked) {
+ $(_changes).attr('required', 'required');
+ } else {
+ $(_changes).removeAttr('required');
+ }
+ });
+
+ $('#parent_id').on('change', function(){
+ var _hasParent = $(this).attr('value') != '';
+ var _changes = '';
+ {% for req in parent_fields %}
+ _changes += '#{{ req }}';
+ {% if not loop.last %}
+ _changes += ',';
+ {% endif %}
+ {% endfor %}
+ if (_hasParent) {
+ $(_changes).removeAttr('required');
+ } else {
+ $(_changes).attr('required', 'required');
+ }
+ });
+ {% endif %}
+ {% endif %}
+ {% include "elements/js/photo_dnd.js.twig" %}
+
+ $('#ddn_adh').on('blur', function() {
+ var _bdate = $(this).val();
+ if ('{{ _T("Y-m-d") }}' === 'Y-m-d') {
+ _bdate = new Date(_bdate);
+ } else {
+ //try for dd/mm/yyyy
+ var _dparts = _bdate.split("/");
+ _bdate = new Date(_dparts[2], _dparts[1] - 1, _dparts[0]);
+ }
+
+ if (! isNaN(_bdate.getTime())) {
+ var _today = new Date();
+ var _age = Math.floor((_today-_bdate) / (365.25 * 24 * 60 * 60 * 1000));
+ $('#member_age').html('{{ _T(" (%age years old)") }}'.replace(/%age/, _age))
+ } else {
+ $('#member_age').html('');
+ }
+ });
+{% endif %}
+ });
+ </script>
+{% endblock %}