Overview
Comment:Liste des écritures liées à une cotisation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9e6dc2ec31fe602ddad1ef086d23172d5121a8ba
User & Date: bohwaz on 2015-03-28 17:06:56
Other Links: manifest | tags
Context
2015-03-28
17:13
Liste des membres liés à une opération check-in: b0edec6de7 user: bohwaz tags: trunk
17:06
Liste des écritures liées à une cotisation check-in: 9e6dc2ec31 user: bohwaz tags: trunk
16:48
éviter les problèmes de foreign key en mettant à NULL id_cotisation dans membres_operations, et prévenir de l'effet check-in: 87b5f2fd4f user: bohwaz tags: trunk
Changes

Modified src/include/lib/Garradin/Membres/Cotisations.php from [ec88714c70] to [7d0abf176b].

283
284
285
286
287
288
289




290
291
292
293
294
295
296
	/**
	 * Liste des événements d'un membre
	 * @param  integer $id Numéro de membre
	 * @return array     Liste des événements de cotisation fait par ce membre
	 */
	public function listForMember($id)
	{




		$db = DB::getInstance();
		return $db->simpleStatementFetch('SELECT cm.*, c.intitule, c.duree, c.debut, c.fin, c.montant,
			(SELECT COUNT(*) FROM membres_operations WHERE id_cotisation = cm.id) AS nb_operations
			FROM cotisations_membres AS cm
				LEFT JOIN cotisations AS c ON c.id = cm.id_cotisation
			WHERE cm.id_membre = ? ORDER BY cm.date DESC;', \SQLITE3_ASSOC, (int)$id);
	}







>
>
>
>







283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
	/**
	 * Liste des événements d'un membre
	 * @param  integer $id Numéro de membre
	 * @return array     Liste des événements de cotisation fait par ce membre
	 */
	public function listForMember($id)
	{
		// TODO: récupérer ici le solde payé pour une cotisation, pour savoir si tout a été payé
		// (pour gérer par exemple les paiements effectués en plusieurs versements)
		// mais pour le moment le fonctionnement de compta_journal est trop compliqué pour arriver
		// à récupérer un solde dans une requête simple, la requête serait trop lourde donc on laisse tomber
		$db = DB::getInstance();
		return $db->simpleStatementFetch('SELECT cm.*, c.intitule, c.duree, c.debut, c.fin, c.montant,
			(SELECT COUNT(*) FROM membres_operations WHERE id_cotisation = cm.id) AS nb_operations
			FROM cotisations_membres AS cm
				LEFT JOIN cotisations AS c ON c.id = cm.id_cotisation
			WHERE cm.id_membre = ? ORDER BY cm.date DESC;', \SQLITE3_ASSOC, (int)$id);
	}

Added src/templates/admin/compta/operations/cotisation.tpl version [195ebb5c04].













































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
{include file="admin/_head.tpl" title="Écritures liées à une cotisation" current="compta/gestion"}

<ul class="actions">
    <li><a href="{$admin_url}membres/fiche.php?id={$membre.id|escape}"><b>{$membre.identite|escape}</b></a></li>
    <li><a href="{$admin_url}membres/modifier.php?id={$membre.id|escape}">Modifier</a></li>
    {if $user.droits.membres >= Garradin\Membres::DROIT_ADMIN}
        <li><a href="{$admin_url}membres/supprimer.php?id={$membre.id|escape}">Supprimer</a></li>
    {/if}
    <li><a href="{$admin_url}membres/cotisations.php?id={$membre.id|escape}">Suivi des cotisations</a></li>
</ul>

{if empty($journal)}
    <p class="alert">Aucune écriture comptable n'est associée à cette cotisation.</p>
{else}
<table class="list">
    <colgroup>
        <col width="3%" />
        <col width="3%" />
        <col width="12%" />
        <col width="10%" />
        <col />
    </colgroup>
    <thead>
        <tr>
            <td></td>
            <td></td>
            <td>Date</td>
            <td>Montant</td>
            <th>Libellé</th>
            <td>Compte débité</td>
            <td>Compte crédité</td>
        </tr>
    </thead>
    <tbody>
    {foreach from=$journal item="ligne"}
        <tr>
            <td><a href="{$admin_url}compta/operations/voir.php?id={$ligne.id|escape}">{$ligne.id|escape}</a></td>
            <td class="actions">
            {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
                <a class="icn" href="{$admin_url}compta/operations/modifier.php?id={$ligne.id|escape}" title="Modifier cette opération">✎</a>
            {/if}
            </td>
            <td>{$ligne.date|format_sqlite_date_to_french|escape}</td>
            <td>{$ligne.montant|html_money}</td>
            <th>{$ligne.libelle|escape}</th>
            <td>{$ligne.compte_debit|escape} — {$ligne.compte_debit|get_nom_compte}</td>
            <td>{$ligne.compte_credit|escape} — {$ligne.compte_credit|get_nom_compte}</td>
        </tr>
    {/foreach}
    </tbody>
</table>
{/if}

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

Modified src/templates/admin/membres/cotisations.tpl from [36e42e832e] to [ebd63024b1].

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
                    {else}
                        ponctuelle
                    {/if}
                    — {$c.montant|html_money} {$config.monnaie|escape}
                </td>
                <td>
                    {if $user.droits.compta >= Garradin\Membres::DROIT_ECRITURE && !empty($c.nb_operations)}
                        {$c.nb_operations} écritures
                    {/if}
                </td>
                <td class="actions">
                    <a class="icn" href="{$admin_url}membres/cotisations/voir.php?id={$c.id_cotisation|escape}" title="Liste des membres inscrits à cette cotisation">👪</a>
                    <a class="icn" href="{$admin_url}membres/cotisations/supprimer.php?id={$c.id|escape}" title="Supprimer cette cotisation pour ce membre">✘</a>
                </td>
            </tr>
        {/foreach}
    </tbody>
</table>
{/if}

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







|













79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
                    {else}
                        ponctuelle
                    {/if}
                    — {$c.montant|html_money} {$config.monnaie|escape}
                </td>
                <td>
                    {if $user.droits.compta >= Garradin\Membres::DROIT_ECRITURE && !empty($c.nb_operations)}
                        <a href="{$admin_url}compta/operations/cotisation.php?id={$c.id|escape}">{$c.nb_operations|escape} écriture{if $c.nb_operations > 1}s{/if}</a>
                    {/if}
                </td>
                <td class="actions">
                    <a class="icn" href="{$admin_url}membres/cotisations/voir.php?id={$c.id_cotisation|escape}" title="Liste des membres inscrits à cette cotisation">👪</a>
                    <a class="icn" href="{$admin_url}membres/cotisations/supprimer.php?id={$c.id|escape}" title="Supprimer cette cotisation pour ce membre">✘</a>
                </td>
            </tr>
        {/foreach}
    </tbody>
</table>
{/if}

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

Added src/www/admin/compta/operations/cotisation.php version [ed97743915].









































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

$journal = new Compta\Journal;

if (empty($_GET['id']) || !is_numeric($_GET['id']))
{
    throw new UserException("Argument du numéro de cotisation manquant.");
}

$id = (int) $_GET['id'];

$m_cotisations = new Membres\Cotisations;
$cotisations = new Cotisations;

$mco = $m_cotisations->get($id);

if (!$mco)
{
	throw new UserException("La cotisation demandée n'existe pas.");
}

$co = $cotisations->get($mco['id_cotisation']);
$membre = $membres->get($mco['id_membre']);

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

$liste_comptes = $comptes->getListAll();

function get_nom_compte($compte)
{
	if (is_null($compte))
		return '';

	global $liste_comptes;
	return $liste_comptes[$compte];
}

$tpl->register_modifier('get_nom_compte', 'Garradin\get_nom_compte');

$tpl->assign('journal', $m_cotisations->listOperationsCompta($mco['id']));

$tpl->assign('cotisation_membre', $mco);
$tpl->assign('cotisation', $co);
$tpl->assign('membre', $membre);

$tpl->display('admin/compta/operations/cotisation.tpl');