Overview
Comment:Correction ajout cotisation membre
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA1: 7e98e7c8eed3198521ad924b24788e47edefa70a
User & Date: bohwaz on 2019-01-26 12:13:12
Other Links: manifest | tags
Context
2019-01-28
14:11
Version 0.9.2 check-in: c48cf081fa user: bohwaz tags: trunk, stable, 0.9.2
2019-01-26
12:13
Correction ajout cotisation membre check-in: 7e98e7c8ee user: bohwaz tags: trunk, stable
10:40
Ne pas essayer d'envoyer des mails à des adresses vides (signalé par @Nicolas) check-in: 20f13bfbab user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Membres/Cotisations.php from [ac1577bdbf] to [86b67dc8e7].

31
32
33
34
35
36
37






38
39
40
41
42
43
44
		if (empty($data['id_cotisation']) 
			|| !$db->firstColumn('SELECT 1 FROM cotisations WHERE id = ?;', (int) $data['id_cotisation']))
		{
			throw new UserException('Cotisation inconnue.');
		}

		$data['id_cotisation'] = (int) $data['id_cotisation'];







		if (empty($data['id_membre']) 
			|| !$db->firstColumn('SELECT 1 FROM membres WHERE id = ?;', (int) $data['id_membre']))
		{
			throw new UserException('Membre inconnu ou invalide.');
		}








>
>
>
>
>
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
		if (empty($data['id_cotisation']) 
			|| !$db->firstColumn('SELECT 1 FROM cotisations WHERE id = ?;', (int) $data['id_cotisation']))
		{
			throw new UserException('Cotisation inconnue.');
		}

		$data['id_cotisation'] = (int) $data['id_cotisation'];

		if (!empty($data['numero_membre']))
		{
			$data['id_membre'] = (new Membres)->getIDWithNumero($data['numero_membre']);
			unset($data['numero_membre']);
		}

		if (empty($data['id_membre']) 
			|| !$db->firstColumn('SELECT 1 FROM membres WHERE id = ?;', (int) $data['id_membre']))
		{
			throw new UserException('Membre inconnu ou invalide.');
		}

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
			}
		}

		$db->commit();

		Plugin::fireSignal('cotisation.ajout', array_merge(['id' => $id], $data));

		return $id;
	}

	/**
	 * Supprimer un événement de cotisation
	 * @param  integer $id ID de l'événement à supprimer
	 * @return integer true en cas de succès
	 */







|







105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
			}
		}

		$db->commit();

		Plugin::fireSignal('cotisation.ajout', array_merge(['id' => $id], $data));

		return $data['id_membre'];
	}

	/**
	 * Supprimer un événement de cotisation
	 * @param  integer $id ID de l'événement à supprimer
	 * @return integer true en cas de succès
	 */

Modified src/www/admin/membres/cotisations/ajout.php from [f27f81d535] to [b2cc2cef01].

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
80
81
82

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

$cats = new Compta\Categories;
$banques = new Compta\Comptes_Bancaires;

if (f('add'))
{
    $form->check('add_cotisation', [
        'date'          => 'date_format:Y-m-d|required',
        'id_cotisation' => 'numeric|required|in_table:cotisations,id',
        'numero_membre' => 'numeric|required|in_table:membres,numero',
    ]);

    if (!$form->hasErrors())
    {
        try {
            $id_membre = f('id_membre');

            if (!$id_membre && f('numero_membre'))
            {
                $id_membre = (new Membres)->getIDWithNumero(f('numero_membre'));
            }

            $data = [
                'date'          =>  f('date'),
                'id_cotisation' =>  f('id_cotisation'),
                'id_membre'     =>  $id_membre,

                'id_auteur'     =>  $user->id,
            ];

            $compta = [
                'montant'        =>  f('montant'),
                'moyen_paiement' =>  f('moyen_paiement'),
                'numero_cheque'  =>  f('numero_cheque'),
                'banque'         =>  f('banque'),
                'numero_piece'   =>  f('numero_piece'),
                'remarques'      =>  f('remarques'),
                'a_encaisser'    =>  f('a_encaisser'),
            ];

            $m_cotisations->add($data, $compta);

            Utils::redirect(ADMIN_URL . 'membres/cotisations.php?id=' . $id_membre);
        }
        catch (UserException $e)
        {
            $form->addError($e->getMessage());
        }
    }
}

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

$tpl->assign('cotisations', $cotisations->listCurrent());








<
<
|
<
<
<
<
|
<
<
|
<
<
<
<
<
<
<
|
|
|
|
>
|
|

|
|
|
|
|
|
|
|
|

|

|
|
|
|
|
<







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

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

$cats = new Compta\Categories;
$banques = new Compta\Comptes_Bancaires;



if (f('add') && $form->check('add_cotisation'))




{


    try {







        $data = [
            'date'          =>  f('date'),
            'id_cotisation' =>  f('id_cotisation'),
            'id_membre'     =>  f('id_membre'),
            'numero_membre' =>  f('numero_membre'),
            'id_auteur'     =>  $user->id,
        ];

        $compta = [
            'montant'        =>  f('montant'),
            'moyen_paiement' =>  f('moyen_paiement'),
            'numero_cheque'  =>  f('numero_cheque'),
            'banque'         =>  f('banque'),
            'numero_piece'   =>  f('numero_piece'),
            'remarques'      =>  f('remarques'),
            'a_encaisser'    =>  f('a_encaisser'),
        ];

        $id_membre = $m_cotisations->add($data, $compta);

        Utils::redirect(ADMIN_URL . 'membres/cotisations.php?id=' . $id_membre);
    }
    catch (UserException $e)
    {
        $form->addError($e->getMessage());

    }
}

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

$tpl->assign('cotisations', $cotisations->listCurrent());