Overview
Comment:Suppression de références à date_cotisation, qui n'est plus utilisé du coup
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 484bd293809efa4ce8e8dfc0f78396b04be974c4
User & Date: bohwaz on 2014-01-30 02:14:20
Other Links: manifest | tags
Context
2014-01-30
15:36
Affichage transactions sur fiche membre + sous-menu sur les pages liées à un membre check-in: 5f46283cb0 user: bohwaz tags: trunk
02:14
Suppression de références à date_cotisation, qui n'est plus utilisé du coup check-in: 484bd29380 user: bohwaz tags: trunk
2014-01-29
20:24
design par défaut adapté aux tablettes/mobiles et affichage des sous-articles aussi check-in: 1ca7edd636 user: bohwaz tags: trunk
Changes

Modified src/include/class.champs_membres.php from [ca2a050e2f] to [ae35bd1abf].

353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381

    	// Champs à créer
    	$create = array(
    		'id INTEGER PRIMARY KEY, -- Numéro attribué automatiquement',
    		'id_categorie INTEGER NOT NULL, -- Numéro de catégorie',
            'date_connexion TEXT NULL, -- Date de dernière connexion',
            'date_inscription TEXT NOT NULL DEFAULT CURRENT_DATE, -- Date d\'inscription',
            'date_cotisation TEXT NULL, -- Date de cotisation',
            //'exemption_transaction INTEGER NOT NULL DEFAULT 0, -- Exempté de transaction obligatoire',
    	);

        $create_keys = array(
            'FOREIGN KEY (id_categorie) REFERENCES membres_categories (id)'
        );

    	// Champs à recopier
    	$copy = array(
    		'id',
    		'id_categorie',
            'date_connexion',
            'date_inscription',
            'date_cotisation',
            //'exemption_transaction',
    	);

        $anciens_champs = $config->get('champs_membres');
    	$anciens_champs = is_null($anciens_champs) ? $this->champs : $anciens_champs->getAll();

    	foreach ($this->champs as $key=>$cfg)







<













<







353
354
355
356
357
358
359

360
361
362
363
364
365
366
367
368
369
370
371
372

373
374
375
376
377
378
379

    	// Champs à créer
    	$create = array(
    		'id INTEGER PRIMARY KEY, -- Numéro attribué automatiquement',
    		'id_categorie INTEGER NOT NULL, -- Numéro de catégorie',
            'date_connexion TEXT NULL, -- Date de dernière connexion',
            'date_inscription TEXT NOT NULL DEFAULT CURRENT_DATE, -- Date d\'inscription',

            //'exemption_transaction INTEGER NOT NULL DEFAULT 0, -- Exempté de transaction obligatoire',
    	);

        $create_keys = array(
            'FOREIGN KEY (id_categorie) REFERENCES membres_categories (id)'
        );

    	// Champs à recopier
    	$copy = array(
    		'id',
    		'id_categorie',
            'date_connexion',
            'date_inscription',

            //'exemption_transaction',
    	);

        $anciens_champs = $config->get('champs_membres');
    	$anciens_champs = is_null($anciens_champs) ? $this->champs : $anciens_champs->getAll();

    	foreach ($this->champs as $key=>$cfg)

Modified src/include/class.membres.php from [1342d9ac1b] to [78366218cf].

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

    public function login($email, $passe)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
            return false;

        $db = DB::getInstance();
        $r = $db->simpleQuerySingle('SELECT *, strftime(\'%s\', date_cotisation) AS date_cotisation FROM membres WHERE email = ? LIMIT 1;', true, trim($email));

        if (empty($r))
            return false;

        if (!$this->_checkPassword(trim($passe), $r['passe']))
            return false;








|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

    public function login($email, $passe)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
            return false;

        $db = DB::getInstance();
        $r = $db->simpleQuerySingle('SELECT * FROM membres WHERE email = ? LIMIT 1;', true, trim($email));

        if (empty($r))
            return false;

        if (!$this->_checkPassword(trim($passe), $r['passe']))
            return false;

411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
        $db->simpleUpdate('membres', $data, 'id = '.(int)$id);
    }

    public function get($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT *,
            strftime(\'%s\', date_cotisation) AS date_cotisation,
            strftime(\'%s\', date_inscription) AS date_inscription,
            strftime(\'%s\', date_connexion) AS date_connexion
            FROM membres WHERE id = ? LIMIT 1;', true, (int)$id);
    }

    public function delete($ids)
    {







<







411
412
413
414
415
416
417

418
419
420
421
422
423
424
        $db->simpleUpdate('membres', $data, 'id = '.(int)$id);
    }

    public function get($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT *,

            strftime(\'%s\', date_inscription) AS date_inscription,
            strftime(\'%s\', date_connexion) AS date_connexion
            FROM membres WHERE id = ? LIMIT 1;', true, (int)$id);
    }

    public function delete($ids)
    {
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
        if (!in_array($field, $fields))
        {
            $fields[] = $field;
        }

        return $db->simpleStatementFetch(
            'SELECT id, id_categorie, ' . implode(', ', $fields) . ',
                strftime(\'%s\', date_cotisation) AS date_cotisation,
                strftime(\'%s\', date_inscription) AS date_inscription
                FROM membres ' . $where . ($order ? ' ORDER BY ' . $order : '') . '
                LIMIT 1000;',
            SQLITE3_ASSOC
        );
    }








<







514
515
516
517
518
519
520

521
522
523
524
525
526
527
        if (!in_array($field, $fields))
        {
            $fields[] = $field;
        }

        return $db->simpleStatementFetch(
            'SELECT id, id_categorie, ' . implode(', ', $fields) . ',

                strftime(\'%s\', date_inscription) AS date_inscription
                FROM membres ' . $where . ($order ? ' ORDER BY ' . $order : '') . '
                LIMIT 1000;',
            SQLITE3_ASSOC
        );
    }

559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
            $fields []= 'email';
        }

        $fields = implode(', ', $fields);

        return $db->simpleStatementFetch(
            'SELECT id, id_categorie, '.$fields.',
                strftime(\'%s\', date_cotisation) AS date_cotisation,
                strftime(\'%s\', date_inscription) AS date_inscription
                FROM membres '.$where.'
                ORDER BY '.$order.' LIMIT ?, ?;',
            SQLITE3_ASSOC,
            $begin,
            self::ITEMS_PER_PAGE
        );







<







557
558
559
560
561
562
563

564
565
566
567
568
569
570
            $fields []= 'email';
        }

        $fields = implode(', ', $fields);

        return $db->simpleStatementFetch(
            'SELECT id, id_categorie, '.$fields.',

                strftime(\'%s\', date_inscription) AS date_inscription
                FROM membres '.$where.'
                ORDER BY '.$order.' LIMIT ?, ?;',
            SQLITE3_ASSOC,
            $begin,
            self::ITEMS_PER_PAGE
        );
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636

    public function countAllButHidden()
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT COUNT(*) FROM membres WHERE id_categorie NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);');
    }

    static public function checkCotisation($date_membre, $duree_cotisation, $date_verif = null)
    {
        if (is_null($date_verif))
            $date_verif = time();

        if (!$date_membre)
            return false;

        $echeance = new \DateTime('@' . $date_membre);
        $echeance->setTime(0, 0);
        $echeance->modify('+'.$duree_cotisation.' months');

        if ($echeance->getTimestamp() < $date_verif)
            return round(($date_verif - $echeance->getTimestamp()) / 3600 / 24);

        return true;
    }

    static public function updateCotisation($id, $date)
    {
        if (preg_match('!^\d{2}/\d{2}/\d{4}$!', $date))
            $date = \DateTime::createFromFormat('d/m/Y', $date, new \DateTimeZone('UTC'));
        elseif (preg_match('!^\d{4}-\d{2}-\d{2}$!', $date))
            $date = \DateTime::createFromFormat('Y-m-d', $date, new \DateTimeZone('UTC'));
        else
            throw new UserException('Format de date invalide : '.$date);

        $db = DB::getInstance();
        return $db->simpleUpdate('membres',
            array('date_cotisation' => $date->format('Y-m-d H:i:s')),
            'id = '.(int)$id
        );
    }

    static public function changeCategorie($id_cat, $membres)
    {
        foreach ($membres as &$id)
        {
            $id = (int) $id;
        }








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







586
587
588
589
590
591
592


































593
594
595
596
597
598
599

    public function countAllButHidden()
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT COUNT(*) FROM membres WHERE id_categorie NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);');
    }



































    static public function changeCategorie($id_cat, $membres)
    {
        foreach ($membres as &$id)
        {
            $id = (int) $id;
        }

Modified src/include/data/0.6.0.sql from [7cbd1842b4] to [3888c76900].

1
2
3
4
5
6
7
8
9
PRAGMA foreign_keys = OFF;

-- nouveau moyen de paiement
INSERT INTO compta_moyens_paiement (code, nom) VALUES ('AU', 'Autre');

CREATE TABLE transactions
-- Paiements possibles
(
    id INTEGER PRIMARY KEY,
<
<









1
2
3
4
5
6
7


-- nouveau moyen de paiement
INSERT INTO compta_moyens_paiement (code, nom) VALUES ('AU', 'Autre');

CREATE TABLE transactions
-- Paiements possibles
(
    id INTEGER PRIMARY KEY,
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    PRIMARY KEY(id_membre, id_rappel, date)
);

CREATE TABLE membres_transactions
-- Paiements enregistrés
(
    id INTEGER PRIMARY KEY,
    
    id_membre INTEGER NOT NULL,
    id_transaction INTEGER NULL, -- NULL si n'est pas relié à une transaction prévue

    libelle TEXT NULL,

    date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    montant REAL NOT NULL,







|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    PRIMARY KEY(id_membre, id_rappel, date)
);

CREATE TABLE membres_transactions
-- Paiements enregistrés
(
    id INTEGER PRIMARY KEY,

    id_membre INTEGER NOT NULL,
    id_transaction INTEGER NULL, -- NULL si n'est pas relié à une transaction prévue

    libelle TEXT NULL,

    date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
    montant REAL NOT NULL,
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
    FOREIGN KEY (id_transaction_obligatoire) REFERENCES transactions (id)
);

-- Remise des anciennes infos
INSERT INTO membres_categories_tmp SELECT id, nom, description, droit_wiki, droit_membres, 
    droit_compta, droit_inscription, droit_connexion, droit_config, cacher, NULL FROM membres_categories;

-- Conversion des cotisations de catégories en transactions
INSERT INTO transactions (id_categorie_compta, intitule, montant, duree, description) 
    SELECT 
        (SELECT id FROM compta_categories WHERE compte = 756 LIMIT 1), -- Numéro de catégorie comptable
        nom, montant_cotisation, round(duree_cotisation * 30.44), "Importé depuis les catégories de membres (version 0.5.x)"
    FROM membres_categories;

-- Suppression de l'ancienne table et renommage de la nouvelle
DROP TABLE membres_categories;
ALTER TABLE membres_categories_tmp RENAME TO membres_categories;

-- Ajout id transaction aux écritures comptables
ALTER TABLE compta_journal ADD COLUMN id_transaction INTEGER NULL REFERENCES transactions (id);

-- Ajout désactivation compte
ALTER TABLE compta_comptes ADD COLUMN desactive INTEGER NOT NULL DEFAULT 0;

PRAGMA foreign_keys = ON;







<
<
<
<
<
<
<











95
96
97
98
99
100
101







102
103
104
105
106
107
108
109
110
111
112
    FOREIGN KEY (id_transaction_obligatoire) REFERENCES transactions (id)
);

-- Remise des anciennes infos
INSERT INTO membres_categories_tmp SELECT id, nom, description, droit_wiki, droit_membres, 
    droit_compta, droit_inscription, droit_connexion, droit_config, cacher, NULL FROM membres_categories;








-- Suppression de l'ancienne table et renommage de la nouvelle
DROP TABLE membres_categories;
ALTER TABLE membres_categories_tmp RENAME TO membres_categories;

-- Ajout id transaction aux écritures comptables
ALTER TABLE compta_journal ADD COLUMN id_transaction INTEGER NULL REFERENCES transactions (id);

-- Ajout désactivation compte
ALTER TABLE compta_comptes ADD COLUMN desactive INTEGER NOT NULL DEFAULT 0;

PRAGMA foreign_keys = ON;

Modified src/templates/admin/index.tpl from [eaecc4ec22] to [854a31f352].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
        Web : <a href="{$config.site_asso|escape}">{$config.site_asso|escape}</a>
    </p>
    {/if}
</div>

<ul class="actions">
    <li><a href="{$admin_url}mes_infos.php">Modifier mes informations personnelles</a></li>
    <li>Cotisation : 
        {if empty($user.date_cotisation)}<b class="error">jamais réglée</b>
        {elseif $verif_cotisation === true}<b class="confirm">À jour :-)</b>
        {else}<b class="alert">En retard !</b>{/if}
    </li>
</ul>

<div class="wikiContent">
    {$page.contenu.contenu|format_wiki|liens_wiki:'wiki/?'}
</div>

{include file="admin/_foot.tpl"}







<
<
<
<
<







17
18
19
20
21
22
23





24
25
26
27
28
29
30
        Web : <a href="{$config.site_asso|escape}">{$config.site_asso|escape}</a>
    </p>
    {/if}
</div>

<ul class="actions">
    <li><a href="{$admin_url}mes_infos.php">Modifier mes informations personnelles</a></li>





</ul>

<div class="wikiContent">
    {$page.contenu.contenu|format_wiki|liens_wiki:'wiki/?'}
</div>

{include file="admin/_foot.tpl"}

Modified src/templates/admin/membres/fiche.tpl from [b6cf6cdebc] to [21b7212934].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{include file="admin/_head.tpl" title="`$membre.nom` (`$categorie.nom`)" current="membres"}

{if $user.droits.membres >= Garradin\Membres::DROIT_ECRITURE}
<ul class="actions">
    <li><a href="{$www_url}admin/membres/modifier.php?id={$membre.id|escape}">Modifier</a></li>
    {if $user.droits.membres >= Garradin\Membres::DROIT_ADMIN}
        <li><a href="{$www_url}admin/membres/supprimer.php?id={$membre.id|escape}">Supprimer</a></li>
    {/if}
</ul>
{/if}

{if $error}
    <p class="error">
        {$error|escape}
    </p>
{/if}

<dl class="describe">
    <dt>Numéro d'adhérent</dt>
    <dd>{$membre.id|escape}</dd>
    {foreach from=$champs key="c" item="config"}
    <dt>{$config.title|escape}</dt>
    <dd>
        {if $config.type == 'checkbox'}











<
<
<
<
<
<







1
2
3
4
5
6
7
8
9
10
11






12
13
14
15
16
17
18
{include file="admin/_head.tpl" title="`$membre.nom` (`$categorie.nom`)" current="membres"}

{if $user.droits.membres >= Garradin\Membres::DROIT_ECRITURE}
<ul class="actions">
    <li><a href="{$www_url}admin/membres/modifier.php?id={$membre.id|escape}">Modifier</a></li>
    {if $user.droits.membres >= Garradin\Membres::DROIT_ADMIN}
        <li><a href="{$www_url}admin/membres/supprimer.php?id={$membre.id|escape}">Supprimer</a></li>
    {/if}
</ul>
{/if}







<dl class="describe">
    <dt>Numéro d'adhérent</dt>
    <dd>{$membre.id|escape}</dd>
    {foreach from=$champs key="c" item="config"}
    <dt>{$config.title|escape}</dt>
    <dd>
        {if $config.type == 'checkbox'}
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
    {/foreach}
    <dt>Catégorie</dt>
    <dd>{$categorie.nom|escape} <span class="droits">{format_droits droits=$categorie}</span></dd>
    <dt>Inscription</dt>
    <dd>{$membre.date_inscription|date_fr:'d/m/Y'}</dd>
    <dt>Dernière connexion</dt>
    <dd>{if empty($membre.date_connexion)}Jamais{else}{$membre.date_connexion|date_fr:'d/m/Y à H:i'}{/if}</dd>
    <dt>Cotisation</dt>
    <dd>
    {if empty($membre.date_cotisation)}
        <span class="error">Jamais réglée</span>
    {elseif $verif_cotisation === true}
        <span class="confirm">Réglée le {$membre.date_cotisation|date_fr:'d/m/Y'}</span>
    {else}
        <span class="alert">En retard de {$verif_cotisation|escape} jours</span>
    {/if}
        <br />
        <form method="post" action="{$self_url}">
            <fieldset>
                <legend>Mettre à jour la cotisation</legend>
                <dl>
                    <dt><label for="f_date">L'adhésion commence le...</label></dt>
                    <dd>
                        <input type="date" name="date" value="{form_field name=date default=$date_cotisation_defaut}" id="f_date" />
                        {csrf_field key="cotisation_"|cat:$membre.id}
                        <input type="submit" name="cotisation" value="Enregistrer &rarr;" />
                    </dd>
                </dl>
            </fieldset>
        </form>
    </dd>
</dl>

{include file="admin/_foot.tpl"}







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<


51
52
53
54
55
56
57




















58




59
60
    {/foreach}
    <dt>Catégorie</dt>
    <dd>{$categorie.nom|escape} <span class="droits">{format_droits droits=$categorie}</span></dd>
    <dt>Inscription</dt>
    <dd>{$membre.date_inscription|date_fr:'d/m/Y'}</dd>
    <dt>Dernière connexion</dt>
    <dd>{if empty($membre.date_connexion)}Jamais{else}{$membre.date_connexion|date_fr:'d/m/Y à H:i'}{/if}</dd>




















</dl>





{include file="admin/_foot.tpl"}

Modified src/templates/admin/membres/index.tpl from [c3ca8b3111] to [7ad382f117].

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    <table class="list">
        <thead>
            {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" value="Tout cocher / décocher" onclick="checkUncheck();" /></td>{/if}
            <td class="{if $order == 'id'} cur {if $desc}desc{else}asc{/if}{/if}" title="Numéro unique"><a href="?o=id&amp;a">&darr;</a><a href="?o=id&amp;d">&uarr;</a></td>
            {foreach from=$champs key="c" item="champ"}
                <td class="{if $order == $c} cur {if $desc}desc{else}asc{/if}{/if}">{$champ.title|escape} <a href="?o={$c|escape}&amp;a">&darr;</a><a href="?o={$c|escape}&amp;d">&uarr;</a></td>
            {/foreach}
            <td>Cotisation</td>
            <td></td>
        </thead>
        <tbody>
            {foreach from=$liste item="membre"}
                <tr>
                    {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" name="selected[]" value="{$membre.id|escape}" /></td>{/if}
                    <td class="num"><a href="{$admin_url}membres/fiche.php?id={$membre.id|escape}">{$membre.id|escape}</a></th>
                    {foreach from=$champs key="c" item="cfg"}
                        <td>{$membre[$c]|escape|display_champ_membre:$cfg}</td>
                    {/foreach}
                    {if empty($membre.date_cotisation)}
                        <td class="error">jamais réglée</td>
                    {elseif $membre.date_cotisation > strtotime('12 months ago')} {* FIXME durée de cotisation variable *}
                        <td class="confirm">à jour</td>
                    {else}
                        <td class="alert">en retard</td>
                    {/if}
                    <td class="actions">
                        {if !empty($membre.email)}<a class="icn" href="{$www_url}admin/membres/message.php?id={$membre.id|escape}" title="Envoyer un message">✉</a> {/if}
                        <a class="icn" href="modifier.php?id={$membre.id|escape}">✎</a>
                    </td>
                </tr>
            {/foreach}
        </tbody>







<










<
<
<
<
<
<
<







48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63
64







65
66
67
68
69
70
71
    <table class="list">
        <thead>
            {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" value="Tout cocher / décocher" onclick="checkUncheck();" /></td>{/if}
            <td class="{if $order == 'id'} cur {if $desc}desc{else}asc{/if}{/if}" title="Numéro unique"><a href="?o=id&amp;a">&darr;</a><a href="?o=id&amp;d">&uarr;</a></td>
            {foreach from=$champs key="c" item="champ"}
                <td class="{if $order == $c} cur {if $desc}desc{else}asc{/if}{/if}">{$champ.title|escape} <a href="?o={$c|escape}&amp;a">&darr;</a><a href="?o={$c|escape}&amp;d">&uarr;</a></td>
            {/foreach}

            <td></td>
        </thead>
        <tbody>
            {foreach from=$liste item="membre"}
                <tr>
                    {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" name="selected[]" value="{$membre.id|escape}" /></td>{/if}
                    <td class="num"><a href="{$admin_url}membres/fiche.php?id={$membre.id|escape}">{$membre.id|escape}</a></th>
                    {foreach from=$champs key="c" item="cfg"}
                        <td>{$membre[$c]|escape|display_champ_membre:$cfg}</td>
                    {/foreach}







                    <td class="actions">
                        {if !empty($membre.email)}<a class="icn" href="{$www_url}admin/membres/message.php?id={$membre.id|escape}" title="Envoyer un message">✉</a> {/if}
                        <a class="icn" href="modifier.php?id={$membre.id|escape}">✎</a>
                    </td>
                </tr>
            {/foreach}
        </tbody>

Modified src/templates/admin/membres/recherche.tpl from [8369632438] to [9124bbb0c6].

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
            {foreach from=$champs_entete key="c" item="cfg"}
                {if $champ == $c}
                    <th><strong>{$cfg.title|escape}</strong></th>
                {else}
                    <td>{$cfg.title|escape}</td>
                {/if}
            {/foreach}
            <td>Cotisation</td>
            <td></td>
        </thead>
        <tbody>
            {foreach from=$liste item="membre"}
                <tr>
                    {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" name="selected[]" value="{$membre.id|escape}" /></td>{/if}
                    <td class="num"><a href="{$admin_url}membres/fiche.php?id={$membre.id|escape}">{$membre.id|escape}</a></th>
                    {foreach from=$champs_entete key="c" item="cfg"}
                        {if $champ == $c}
                            <th><strong>{$membre[$c]|escape|display_champ_membre:$cfg}</strong></th>
                        {else}
                            <td>{$membre[$c]|escape|display_champ_membre:$cfg}</td>
                        {/if}
                    {/foreach}
                    {if empty($membre.date_cotisation)}
                        <td class="error">jamais réglée</td>
                    {elseif $membre.date_cotisation > strtotime('12 months ago')}
                        <td class="confirm">à jour</td>
                    {else}
                        <td class="alert">en retard</td>
                    {/if}
                    <td class="actions">
                        {if !empty($membre.email)}<a class="icn" href="{$www_url}admin/membres/message.php?id={$membre.id|escape}" title="Envoyer un message">✉</a> {/if}
                        <a class="icn" href="modifier.php?id={$membre.id|escape}">✎</a>
                    </td>
                </tr>
            {/foreach}
        </tbody>







<














<
<
<
<
<
<
<







68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
84
85
86
87
88







89
90
91
92
93
94
95
            {foreach from=$champs_entete key="c" item="cfg"}
                {if $champ == $c}
                    <th><strong>{$cfg.title|escape}</strong></th>
                {else}
                    <td>{$cfg.title|escape}</td>
                {/if}
            {/foreach}

            <td></td>
        </thead>
        <tbody>
            {foreach from=$liste item="membre"}
                <tr>
                    {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<td class="check"><input type="checkbox" name="selected[]" value="{$membre.id|escape}" /></td>{/if}
                    <td class="num"><a href="{$admin_url}membres/fiche.php?id={$membre.id|escape}">{$membre.id|escape}</a></th>
                    {foreach from=$champs_entete key="c" item="cfg"}
                        {if $champ == $c}
                            <th><strong>{$membre[$c]|escape|display_champ_membre:$cfg}</strong></th>
                        {else}
                            <td>{$membre[$c]|escape|display_champ_membre:$cfg}</td>
                        {/if}
                    {/foreach}







                    <td class="actions">
                        {if !empty($membre.email)}<a class="icn" href="{$www_url}admin/membres/message.php?id={$membre.id|escape}" title="Envoyer un message">✉</a> {/if}
                        <a class="icn" href="modifier.php?id={$membre.id|escape}">✎</a>
                    </td>
                </tr>
            {/foreach}
        </tbody>

Modified src/www/admin/index.php from [1e2f6cd837] to [5254328335].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

$cats = new Membres_Categories;
$categorie = $cats->get($user['id_categorie']);

$tpl->assign('categorie', $categorie);
$tpl->assign('verif_cotisation', Membres::checkCotisation($user['date_cotisation'], $categorie['duree_cotisation']));

$wiki = new Wiki;
$page = $wiki->getByURI($config->get('accueil_connexion'));
$tpl->assign('page', $page);

$tpl->display('admin/index.tpl');










<







1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

$cats = new Membres_Categories;
$categorie = $cats->get($user['id_categorie']);

$tpl->assign('categorie', $categorie);


$wiki = new Wiki;
$page = $wiki->getByURI($config->get('accueil_connexion'));
$tpl->assign('page', $page);

$tpl->display('admin/index.tpl');

Modified src/www/admin/install.php from [2f10ed0fdf] to [7eae80316c].

130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
                $config->setVersion(garradin_version());

                $champs = Champs_Membres::importInstall();
                $champs->save(false); // Pas de copie car pas de table membres existante

                // Création catégories
                $cats = new Membres_Categories;
                $id = $cats->add(array(
                    'nom' => 'Membres actifs',
                    'montant_cotisation' => 10));
                $config->set('categorie_membres', $id);

                $id = $cats->add(array(
                    'nom' => 'Anciens membres',
                    'montant_cotisation' => 0,
                    'droit_inscription' => Membres::DROIT_AUCUN,
                    'droit_wiki' => Membres::DROIT_AUCUN,
                    'droit_membres' => Membres::DROIT_AUCUN,
                    'droit_compta' => Membres::DROIT_AUCUN,
                    'droit_config' => Membres::DROIT_AUCUN,
                    'droit_connexion' => Membres::DROIT_AUCUN,
                    'cacher' => 1,
                    ));

                $id = $cats->add(array(
                    'nom' => ucfirst(utils::post('cat_membre')),
                    'montant_cotisation' => 0,
                    'droit_inscription' => Membres::DROIT_AUCUN,
                    'droit_wiki' => Membres::DROIT_ADMIN,
                    'droit_membres' => Membres::DROIT_ADMIN,
                    'droit_compta' => Membres::DROIT_ADMIN,
                    'droit_config' => Membres::DROIT_ADMIN,
                    ));








|

|




<











<







130
131
132
133
134
135
136
137
138
139
140
141
142
143

144
145
146
147
148
149
150
151
152
153
154

155
156
157
158
159
160
161
                $config->setVersion(garradin_version());

                $champs = Champs_Membres::importInstall();
                $champs->save(false); // Pas de copie car pas de table membres existante

                // Création catégories
                $cats = new Membres_Categories;
                $id = $cats->add([
                    'nom' => 'Membres actifs',
                ]);
                $config->set('categorie_membres', $id);

                $id = $cats->add(array(
                    'nom' => 'Anciens membres',

                    'droit_inscription' => Membres::DROIT_AUCUN,
                    'droit_wiki' => Membres::DROIT_AUCUN,
                    'droit_membres' => Membres::DROIT_AUCUN,
                    'droit_compta' => Membres::DROIT_AUCUN,
                    'droit_config' => Membres::DROIT_AUCUN,
                    'droit_connexion' => Membres::DROIT_AUCUN,
                    'cacher' => 1,
                    ));

                $id = $cats->add(array(
                    'nom' => ucfirst(utils::post('cat_membre')),

                    'droit_inscription' => Membres::DROIT_AUCUN,
                    'droit_wiki' => Membres::DROIT_ADMIN,
                    'droit_membres' => Membres::DROIT_ADMIN,
                    'droit_compta' => Membres::DROIT_ADMIN,
                    'droit_config' => Membres::DROIT_ADMIN,
                    ));

Modified src/www/admin/membres/fiche.php from [9afcee1910] to [3211b6ac5b].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

if (!$membre)
{
    throw new UserException("Ce membre n'existe pas.");
}

$champs = $config->get('champs_membres');
$error = false;

if (!empty($_POST['cotisation']))
{
    if (!utils::CSRF_check('cotisation_'.$id))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try {
            $membres->updateCotisation($id, utils::post('date'));

            if ($id == $user['id'])
            {
                $membres->updateSessionData();
            }

            utils::redirect('/admin/membres/fiche.php?id='.$id);
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

$cats = new Membres_Categories;
$categorie = $cats->get($membre['id_categorie']);

$tpl->assign('categorie', $categorie);
$tpl->assign('membre', $membre);
$tpl->assign('verif_cotisation', Membres::checkCotisation($membre['date_cotisation'], $categorie['duree_cotisation']));

if (!empty($membre['date_cotisation']))
{
    $prochaine_cotisation = new \DateTime('@'.$membre['date_cotisation']);
    $prochaine_cotisation->modify('+1 year');
    $prochaine_cotisation = $prochaine_cotisation->getTimestamp();
}
else
{
    $prochaine_cotisation = time();
}
$tpl->assign('date_cotisation_defaut', date('Y-m-d', $prochaine_cotisation));

$tpl->assign('champs', $champs->getAll());

$tpl->assign('error', $error);
$tpl->assign('custom_js', array('datepickr.js'));

$tpl->display('admin/membres/fiche.tpl');

?>







<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






<
<
<
<
<
<
<
<
<
<
<
<
<



<





19
20
21
22
23
24
25

26
























27
28
29
30
31
32













33
34
35

36
37
38
39
40

if (!$membre)
{
    throw new UserException("Ce membre n'existe pas.");
}

$champs = $config->get('champs_membres');



























$cats = new Membres_Categories;
$categorie = $cats->get($membre['id_categorie']);

$tpl->assign('categorie', $categorie);
$tpl->assign('membre', $membre);














$tpl->assign('champs', $champs->getAll());


$tpl->assign('custom_js', array('datepickr.js'));

$tpl->display('admin/membres/fiche.tpl');

?>

Modified src/www/admin/upgrade.php from [5b0e97e5bf] to [d846aee0f2].

112
113
114
115
116
117
118





119
120






























121
122
123
124
125
126
127


128
129
130
131
132
133
134
135
136
137


138



139
140
141
142
143
144
145

    // Suppression de l'ancienne config
    $db->exec('DELETE FROM config WHERE cle IN ("champs_obligatoires", "champs_modifiables_membre");');
}

if (version_compare($v, '0.6.0', '<'))
{





    // Mise à jour base de données
    $db->exec(file_get_contents(GARRADIN_ROOT . '/include/data/0.6.0.sql'));































    // Déplacement des squelettes dans le répertoire public
    if (!file_exists(GARRADIN_ROOT . '/www/squelettes'))
    {
        mkdir(GARRADIN_ROOT . '/www/squelettes');
    }



    $dir = dir(GARRADIN_ROOT . '/squelettes');

    while ($file = $dir->read())
    {
        if ($file == '.' || $file == '..')
            continue;

        rename(GARRADIN_ROOT . '/squelettes/' . $file, GARRADIN_ROOT . '/www/squelettes/' . $file);
    }



    @rmdir(GARRADIN_ROOT . '/squelettes');



}

utils::clearCaches();

$config->setVersion(garradin_version());

echo '<h4>Mise à jour terminée.</h4>







>
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







>
>
|

|
|
|
|

|
|

>
>
|
>
>
>







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

    // Suppression de l'ancienne config
    $db->exec('DELETE FROM config WHERE cle IN ("champs_obligatoires", "champs_modifiables_membre");');
}

if (version_compare($v, '0.6.0', '<'))
{
    $categories = new Membres_Categories;
    $list = $categories->listComplete();

    $db->exec('PRAGMA foreign_keys = OFF; BEGIN;');

    // Mise à jour base de données
    $db->exec(file_get_contents(GARRADIN_ROOT . '/include/data/0.6.0.sql'));

    $id_cat_cotisation = $db->querySingle('SELECT id FROM compta_categories WHERE compte = 756 LIMIT 1;');

    // Conversion des cotisations de catégories en transactions
    foreach ($list as $cat)
    {
        $db->simpleInsert('transactions', [
            'id_categorie_compta'   =>  null,
            'intitule'              =>  $cat['nom'],
            'montant'               =>  (float) $cat['montant_cotisation'],
            // Convertir un nombre de mois en nombre de jours
            'duree'                 =>  round($cat['duree_cotisation'] * 30.44),
            'description'           =>  'Créé automatiquement depuis les catégories de membres (version 0.5.x)',
        ]);

        $args = [
            'id_transaction'=>  (int)$db->lastInsertRowId(),
            'montant'       =>  (float) $cat['montant_cotisation'],
            'id_categorie'  =>  (int)$cat['id'],
        ];

        // import des dates de cotisation existantes comme paiements
        $db->simpleExec('INSERT INTO membres_transactions 
            (id_membre, id_transaction, libelle, date, montant)
            SELECT id, :id_transaction, "Créé automatiquement depuis la date de cotisation enregistrée (version 0.5.x)",
            date_cotisation, :montant FROM membres WHERE id_categorie = :id_categorie;',
            $args);

        // Mais on ne crée pas d'écriture comptable, car elles existent probablement déjà
    }

    // Déplacement des squelettes dans le répertoire public
    if (!file_exists(GARRADIN_ROOT . '/www/squelettes'))
    {
        mkdir(GARRADIN_ROOT . '/www/squelettes');
    }

    if (file_exists(GARRADIN_ROOT . '/squelettes'))
    {
        $dir = dir(GARRADIN_ROOT . '/squelettes');

        while ($file = $dir->read())
        {
            if ($file == '.' || $file == '..')
                continue;

            rename(GARRADIN_ROOT . '/squelettes/' . $file, GARRADIN_ROOT . '/www/squelettes/' . $file);
        }

        $dir->close();

        @rmdir(GARRADIN_ROOT . '/squelettes');
    }

    $db->exec('END; PRAGMA foreign_keys = ON;');
}

utils::clearCaches();

$config->setVersion(garradin_version());

echo '<h4>Mise à jour terminée.</h4>