Overview
Comment:Ajout possibilité de visualiser dans la liste des cotisants tous les membres dont c'est la cotisation obligatoire, répond à un besoin basique de plusieurs assos (merci @Dbout)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA1: d56bf48588deb036d4335e20cd7fe09a05978883
User & Date: bohwaz on 2019-03-03 23:21:37
Other Links: manifest | tags
Context
2019-03-13
17:08
Correctif pour la validation des champs de type select check-in: 49d6ec6970 user: bohwaz tags: trunk, stable
2019-03-03
23:21
Ajout possibilité de visualiser dans la liste des cotisants tous les membres dont c'est la cotisation obligatoire, répond à un besoin basique de plusieurs assos (merci @Dbout) check-in: d56bf48588 user: bohwaz tags: trunk, stable
2019-02-22
10:17
Ne pas limiter les requêtes pour l'envoi de mail, et préciser clairement si la requête ne permet pas d'accéder aux colonnes nécessaires check-in: b13b9efbee user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Membres/Cotisations.php from [11e1bece47] to [29206fdf20].

253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
	}

	/**
	 * Liste des membres qui sont inscrits à une cotisation
	 * @param  integer $id Numéro de la cotisation
	 * @return array     Liste des membres
	 */
	public function listMembersForCotisation($id, $page = 1, $order = null, $desc = true)
	{
		$begin = ($page - 1) * self::ITEMS_PER_PAGE;

		$db = DB::getInstance();
		$champ_id = Config::getInstance()->get('champ_identite');

		if (empty($order))







|







253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
	}

	/**
	 * Liste des membres qui sont inscrits à une cotisation
	 * @param  integer $id Numéro de la cotisation
	 * @return array     Liste des membres
	 */
	public function listMembersForCotisation($id, $include_category, $page = 1, $order = null, $desc = true)
	{
		$begin = ($page - 1) * self::ITEMS_PER_PAGE;

		$db = DB::getInstance();
		$champ_id = Config::getInstance()->get('champ_identite');

		if (empty($order))
279
280
281
282
283
284
285




















286
287
288
289
290
291
292
				break;
			default:
				$order = 'cm.id_membre';
				break;
		}

		$desc = $desc ? 'DESC' : 'ASC';





















		return $db->get('SELECT cm.id_membre, cm.date, cm.id, m.numero,
			m.'.$champ_id.' AS nom, c.montant,
			CASE WHEN c.duree IS NOT NULL THEN date(cm.date, \'+\'||c.duree||\' days\') >= date()
			WHEN c.fin IS NOT NULL THEN (cm.date <= c.fin AND cm.date >= c.debut)
			ELSE 1 END AS a_jour
			FROM cotisations_membres AS cm







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







279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
				break;
			default:
				$order = 'cm.id_membre';
				break;
		}

		$desc = $desc ? 'DESC' : 'ASC';

		// Renvoyer la liste avec tous les membres des catégories dont la cotisation obligatoire est celle-ci
		if ($include_category)
		{
			$cats_obligatoires = $db->getAssoc('SELECT id, id FROM membres_categories WHERE id_cotisation_obligatoire = ? AND cacher = 0;', $id);

			return $db->get('SELECT m.id AS id_membre, cm.date, cm.id, m.numero,
				m.'.$champ_id.' AS nom, c.montant,
				CASE WHEN cm.id IS NULL THEN 0
				WHEN c.duree IS NOT NULL THEN date(cm.date, \'+\'||c.duree||\' days\') >= date()
				WHEN c.fin IS NOT NULL THEN (cm.date <= c.fin AND cm.date >= c.debut)
				ELSE 1 END AS a_jour
				FROM membres AS m
					LEFT JOIN cotisations_membres AS cm ON cm.id_membre = m.id AND cm.id_cotisation = ?
					LEFT JOIN cotisations AS c ON c.id = cm.id_cotisation
				WHERE
					'.$db->where('m.id_categorie', $cats_obligatoires) . '
				GROUP BY m.id ORDER BY '.$order.' '.$desc.' LIMIT ?,?;',
				$id, $begin, self::ITEMS_PER_PAGE);
		}

		return $db->get('SELECT cm.id_membre, cm.date, cm.id, m.numero,
			m.'.$champ_id.' AS nom, c.montant,
			CASE WHEN c.duree IS NOT NULL THEN date(cm.date, \'+\'||c.duree||\' days\') >= date()
			WHEN c.fin IS NOT NULL THEN (cm.date <= c.fin AND cm.date >= c.debut)
			ELSE 1 END AS a_jour
			FROM cotisations_membres AS cm

Modified src/templates/admin/membres/cotisations/voir.tpl from [3ab24d7fdd] to [57768b3fa3].

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
        {elseif $cotisation.debut}
            du {$cotisation.debut|format_sqlite_date_to_french} au {$cotisation.fin|format_sqlite_date_to_french}
        {else}
            ponctuelle
        {/if}
        — {$cotisation.montant|escape|html_money} {$config.monnaie}
    </dd>






    <dt>Nombre de membres ayant cotisé</dt>
    <dd>
        {$cotisation.nb_membres}
        <small class="help">(incluant les membres des catégories cachées)</small>
    </dd>
</dl>

{if !empty($liste)}
    <table class="list">
        <thead class="userOrder">
            <tr>
                <td class="{if $order == "id"} cur {if $desc}desc{else}asc{/if}{/if}"><a href="?id={$cotisation.id}&amp;o=id&amp;a" class="icn up">&uarr;</a><a href="?id={$cotisation.id}&amp;o=id&amp;d" class="icn dn">&darr;</a></td>
                <th class="{if $order == "identite"} cur {if $desc}desc{else}asc{/if}{/if}">Membre <a href="?id={$cotisation.id}&amp;o=identite&amp;a" class="icn up">&uarr;</a><a href="?id={$cotisation.id}&amp;o=identite&amp;d" class="icn dn">&darr;</a></th>
                <td class="{if $order == "a_jour"} cur {if $desc}desc{else}asc{/if}{/if}">Statut <a href="?id={$cotisation.id}&amp;o=a_jour&amp;a" class="icn up">&uarr;</a><a href="?id={$cotisation.id}&amp;o=a_jour&amp;d" class="icn dn">&darr;</a></td>
                <td class="{if $order == "date"} cur {if $desc}desc{else}asc{/if}{/if}">Date de cotisation <a href="?id={$cotisation.id}&amp;o=date&amp;a" class="icn up">&uarr;</a><a href="?id={$cotisation.id}&amp;o=date&amp;d" class="icn dn">&darr;</a></td>
                <td></td>
            </tr>
        </thead>
        <tbody>
            {foreach from=$liste item="co"}
                <tr>
                    <td class="num"><a href="{$admin_url}membres/fiche.php?id={$co.id_membre}">{$co.numero}</a></td>







>
>
>
>
>
>
|










|
|
|
|







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
        {elseif $cotisation.debut}
            du {$cotisation.debut|format_sqlite_date_to_french} au {$cotisation.fin|format_sqlite_date_to_french}
        {else}
            ponctuelle
        {/if}
        — {$cotisation.montant|escape|html_money} {$config.monnaie}
    </dd>
    <dd>
        {if !$cats}
            <a href="?id={$cotisation.id}&amp;cats=1">Afficher les membres des catégories pour lesquelles cette cotisation est obligatoire</a>
        {else}
            <a href="?id={$cotisation.id}">Afficher seulement les membres à jour (ou qui ont déjà payé, mais ne sont plus à jour)</a>
        {/if}
    </dd>    <dt>Nombre de membres ayant cotisé</dt>
    <dd>
        {$cotisation.nb_membres}
        <small class="help">(incluant les membres des catégories cachées)</small>
    </dd>
</dl>

{if !empty($liste)}
    <table class="list">
        <thead class="userOrder">
            <tr>
                <td class="{if $order == "id"} cur {if $desc}desc{else}asc{/if}{/if}"><a href="?id={$cotisation.id}&amp;o=id&amp;a&amp;cats={$cats}" class="icn up">&uarr;</a><a href="?id={$cotisation.id}&amp;o=id&amp;d&amp;cats={$cats}" class="icn dn">&darr;</a></td>
                <th class="{if $order == "identite"} cur {if $desc}desc{else}asc{/if}{/if}">Membre <a href="?id={$cotisation.id}&amp;o=identite&amp;a&amp;cats={$cats}" class="icn up">&uarr;</a><a href="?id={$cotisation.id}&amp;o=identite&amp;d&amp;cats={$cats}" class="icn dn">&darr;</a></th>
                <td class="{if $order == "a_jour"} cur {if $desc}desc{else}asc{/if}{/if}">Statut <a href="?id={$cotisation.id}&amp;o=a_jour&amp;a&amp;cats={$cats}" class="icn up">&uarr;</a><a href="?id={$cotisation.id}&amp;o=a_jour&amp;d&amp;cats={$cats}" class="icn dn">&darr;</a></td>
                <td class="{if $order == "date"} cur {if $desc}desc{else}asc{/if}{/if}">Date de cotisation <a href="?id={$cotisation.id}&amp;o=date&amp;a" class="icn up">&uarr;</a><a href="?id={$cotisation.id}&amp;o=date&amp;d&amp;cats={$cats}" class="icn dn">&darr;</a></td>
                <td></td>
            </tr>
        </thead>
        <tbody>
            {foreach from=$liste item="co"}
                <tr>
                    <td class="num"><a href="{$admin_url}membres/fiche.php?id={$co.id_membre}">{$co.numero}</a></td>

Modified src/www/admin/membres/cotisations/voir.php from [db337019a9] to [8935c9e002].

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

if (!$co)
{
    throw new UserException("Cette cotisation n'existe pas.");
}

$page = (int) qg('p') ?: 1;



$tpl->assign('page', $page);
$tpl->assign('bypage', Membres\Cotisations::ITEMS_PER_PAGE);
$tpl->assign('total', $m_cotisations->countMembersForCotisation($co->id));
$tpl->assign('pagination_url', Utils::getSelfUrl([
	'id' => $co->id,
	'o' => qg('o'),
	(qg('a') !== null ? 'a' : 'd') => '',
	'p'  => '[ID]',

]));

$tpl->assign('cotisation', $co);
$tpl->assign('order', qg('o') ?: 'date');
$tpl->assign('desc', !null !== qg('a'));
$tpl->assign('liste', $m_cotisations->listMembersForCotisation(
	$co->id, $page, qg('o'), null !== qg('a') ? false : true));

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







>

>








>




|

|


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

if (!$co)
{
    throw new UserException("Cette cotisation n'existe pas.");
}

$page = (int) qg('p') ?: 1;
$categories = (int) qg('cats');

$tpl->assign('cats', $categories);
$tpl->assign('page', $page);
$tpl->assign('bypage', Membres\Cotisations::ITEMS_PER_PAGE);
$tpl->assign('total', $m_cotisations->countMembersForCotisation($co->id));
$tpl->assign('pagination_url', Utils::getSelfUrl([
	'id' => $co->id,
	'o' => qg('o'),
	(qg('a') !== null ? 'a' : 'd') => '',
	'p'  => '[ID]',
	'cats' => $categories,
]));

$tpl->assign('cotisation', $co);
$tpl->assign('order', qg('o') ?: 'date');
$tpl->assign('desc', null === qg('a'));
$tpl->assign('liste', $m_cotisations->listMembersForCotisation(
	$co->id, $categories, $page, qg('o'), null !== qg('a') ? false : true));

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