]> git.agnieray.net Git - galette.git/commitdiff
Continue migration
authorJohan Cwiklinski <johan@x-tnd.be>
Sat, 29 Jan 2022 06:36:36 +0000 (07:36 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Wed, 8 Jun 2022 05:51:21 +0000 (07:51 +0200)
22 files changed:
galette/includes/dependencies.php
galette/lib/Galette/Controllers/Crud/ContributionsController.php
galette/lib/Galette/Controllers/Crud/MailingsController.php
galette/lib/Galette/Controllers/Crud/MembersController.php
galette/lib/Galette/Controllers/Crud/SavedSearchesController.php
galette/lib/Galette/Controllers/HistoryController.php
galette/lib/Galette/Middleware/MembersNavigate.php
galette/templates/default/member.tpl [deleted file]
galette/templates/default/photo_dnd.tpl [deleted file]
galette/templates/default/ui_elements/member_card.tpl [deleted file]
galette/templates/default/ui_elements/navigate.tpl [deleted file]
galette/templates/default/voir_adherent.tpl
galette/templates/gtwig/components/forms/address.html.twig
galette/templates/gtwig/components/forms/company.html.twig
galette/templates/gtwig/components/forms/groups.html.twig
galette/templates/gtwig/components/forms/password.html.twig
galette/templates/gtwig/components/forms/payment_types.html.twig
galette/templates/gtwig/components/forms/textarea.html.twig
galette/templates/gtwig/elements/js/photo_dnd.js.twig [new file with mode: 0644]
galette/templates/gtwig/elements/member_card.html.twig [new file with mode: 0644]
galette/templates/gtwig/elements/navigate.html.twig [new file with mode: 0644]
galette/templates/gtwig/pages/member_form.html.twig [new file with mode: 0644]

index 0982c683797cbf835968f95db9c6e96131ef70ae..24ad53d5adef9e320539098176ad9a9f6ddda61c 100644 (file)
@@ -142,6 +142,20 @@ $container->set('Slim\Views\Twig', function (ContainerInterface $c) {
         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
index bb4aa5e07c231feba8792bdc6b535dda23c022f3..1712981366db4e2f5b7ad987e4e574074fe92b61 100644 (file)
@@ -7,7 +7,7 @@
  *
  * 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).
  *
@@ -28,7 +28,7 @@
  * @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
@@ -56,7 +56,7 @@ use Galette\Repository\PaymentTypes;
  * @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
@@ -498,7 +498,7 @@ class ContributionsController extends CrudController
         }
 
         //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' ?
index afef248ff43be08a233fc60b51384f15b3c6d1df..45a0878618dd1cb049f3e1c88dda6e9da3929971 100644 (file)
@@ -498,10 +498,10 @@ class MailingsController extends CrudController
         $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(
index f8d5087ffc775b60e5346aaabb51a4eaeebe04ec..89351608cf56db74cc872d9afc2e9b1defb5a62e 100644 (file)
@@ -160,10 +160,10 @@ class MembersController extends CrudController
         // 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,
@@ -359,7 +359,7 @@ class MembersController extends CrudController
         $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(
@@ -876,7 +876,7 @@ class MembersController extends CrudController
         }
 
         //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;
 
@@ -1173,9 +1173,9 @@ class MembersController extends CrudController
         // 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,
index 071565bcae208d7a4abf025dc086ffc94dc0fa2c..5da09fe1c05533b2295eb1493b97f2668470e4a0 100644 (file)
@@ -191,7 +191,7 @@ class SavedSearchesController extends CrudController
         $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;
 
index ad9587ac86b3ad4d50a284e99c6d4e126fc07ca9..2ffb253822edefdeb7e83dafb3572b857861a96d 100644 (file)
@@ -101,7 +101,7 @@ class HistoryController extends AbstractController
         $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(
index f6907fe05b73bebc1c263f9867661dc8bc3a315c..60b85aaa338dc10fe54df653b5eab409efc73fec 100644 (file)
@@ -137,7 +137,7 @@ class MembersNavigate
                 }
             }
         }
-        $this->view->getSmarty()->assign('navigate', $navigate);
+        $this->view->getEnvironment()->addGlobal('navigate', $navigate);
 
         return $next($request, $response);
     }
diff --git a/galette/templates/default/member.tpl b/galette/templates/default/member.tpl
deleted file mode 100644 (file)
index fdfe1c5..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-{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}
diff --git a/galette/templates/default/photo_dnd.tpl b/galette/templates/default/photo_dnd.tpl
deleted file mode 100644 (file)
index 2f0d42b..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-    {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}
diff --git a/galette/templates/default/ui_elements/member_card.tpl b/galette/templates/default/ui_elements/member_card.tpl
deleted file mode 100644 (file)
index 48a6953..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<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>
diff --git a/galette/templates/default/ui_elements/navigate.tpl b/galette/templates/default/ui_elements/navigate.tpl
deleted file mode 100644 (file)
index 65390e8..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{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}
index 4046f33fcf46ee117b50ace3e21bbe139fa45c74..cb5bf98da069ae6fb5f06588694c56311a75ba60 100644 (file)
@@ -96,7 +96,7 @@
             </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()}
index bc22cd3fe2fc835dd8461ca66bf5ff27172b92f8..48a36e8e7602be701af5d86a2c726391652648cf 100644 (file)
@@ -1,14 +1,15 @@
 <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>
index d28b253efcf7b8b754589934b948f1bc02b35d5a..e94e31163b45a00293fae67e5abf214b268a0795 100644 (file)
@@ -1,26 +1,26 @@
 <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>
index 95a55ed3d3337635cff1ba2708f6dd9305054d80..cda6bc3731fffe98e329df5742a66fbac5014d94 100644 (file)
@@ -1,59 +1,59 @@
 <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>
index 61d7c6e56e13b6e5f66dc9145b1abbc28a42b32c..6f7f65b2f2d160f1ab0d605810245c5b2b6409ea 100644 (file)
@@ -1,28 +1,28 @@
-{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 } %}
index 812d4aee946781dbbf1e7a73c6595e83e2b42ca0..6bda255e29f77c6bf4b10e6e4b960bda8e4bfb2c 100644 (file)
@@ -1,16 +1,16 @@
-{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>
index a73a9193f404e895a06e49069a7d79f3c33909c1..fb60c3eaacabb5d5a5bd98b47cff7f2162c64348 100644 (file)
@@ -23,5 +23,5 @@
         {% 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 %}
diff --git a/galette/templates/gtwig/elements/js/photo_dnd.js.twig b/galette/templates/gtwig/elements/js/photo_dnd.js.twig
new file mode 100644 (file)
index 0000000..cdccb59
--- /dev/null
@@ -0,0 +1,66 @@
+    {% 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 %}
diff --git a/galette/templates/gtwig/elements/member_card.html.twig b/galette/templates/gtwig/elements/member_card.html.twig
new file mode 100644 (file)
index 0000000..ebe6bb9
--- /dev/null
@@ -0,0 +1,55 @@
+<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>
diff --git a/galette/templates/gtwig/elements/navigate.html.twig b/galette/templates/gtwig/elements/navigate.html.twig
new file mode 100644 (file)
index 0000000..1002d22
--- /dev/null
@@ -0,0 +1,25 @@
+{% 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 %}
diff --git a/galette/templates/gtwig/pages/member_form.html.twig b/galette/templates/gtwig/pages/member_form.html.twig
new file mode 100644 (file)
index 0000000..82d43a5
--- /dev/null
@@ -0,0 +1,372 @@
+{% 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 %}