Overview
Comment:Possibilité de choisir le montant de la cotisation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 25897d90e89fefcc496bbcbd26f0e546ef93389e
User & Date: bohwaz on 2014-04-15 05:13:05
Other Links: manifest | tags
Context
2014-04-16
19:25
Gestion correcte des valeurs _POST des champs de type multiple check-in: 473eb527cf user: bohwaz tags: trunk
2014-04-15
05:13
Possibilité de choisir le montant de la cotisation check-in: 25897d90e8 user: bohwaz tags: trunk
05:12
Afficher les erreurs utilisateurs en mode texte check-in: 492a8b9e8b user: bohwaz tags: trunk
Changes

Modified src/include/class.cotisations_membres.php from [1e76b69c3c] to [577baba209].

52
53
54
55
56
57
58





59
60
61
62
63
64
65

	            if (!$db->simpleQuerySingle('SELECT 1 FROM compta_comptes_bancaires WHERE id = ?;',
	            	false, $data['banque']))
	            {
	                throw new UserException('Le compte bancaire choisi n\'existe pas.');
	            }
	        }





	    }
	}

	/**
	 * Enregistrer un événement de cotisation
	 * @param array $data Tableau des champs à insérer
	 * @return integer ID de l'événement créé







>
>
>
>
>







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

	            if (!$db->simpleQuerySingle('SELECT 1 FROM compta_comptes_bancaires WHERE id = ?;',
	            	false, $data['banque']))
	            {
	                throw new UserException('Le compte bancaire choisi n\'existe pas.');
	            }
	        }

	        if (empty($data['montant']) || !is_numeric($data['montant']))
	        {
	        	throw new UserException('Le montant indiqué n\'est pas un nombre valide.');
	        }
	    }
	}

	/**
	 * Enregistrer un événement de cotisation
	 * @param array $data Tableau des champs à insérer
	 * @return integer ID de l'événement créé
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
			false, (int)$data['id_cotisation'], (int)$data['id_membre'], $data['date']);

		if ($check)
		{
			throw new UserException('Cette cotisation a déjà été enregistrée pour ce jour-ci et ce membre-ci.');
		}

		$db->exec('BEGIN;');

		$db->simpleInsert('cotisations_membres', [
			'date'				=>	$data['date'],
			'id_cotisation'		=>	$data['id_cotisation'],
			'id_membre'			=>	$data['id_membre'],
			]);

		$id = $db->lastInsertRowId();

		if ($co['id_categorie_compta'] && $co['montant'] > 0)
		{
			try {
		        $id_operation = $this->addOperationCompta($id, [
		        	'id_categorie'	=>	$co['id_categorie_compta'],
		            'libelle'       =>  'Cotisation (automatique)',
		            'montant'       =>  $co['montant'],
		            'date'          =>  $data['date'],
		            'moyen_paiement'=>  $data['moyen_paiement'],
		            'numero_cheque' =>  isset($data['numero_cheque']) ? $data['numero_cheque'] : null,
		            'id_auteur'     =>  $data['id_auteur'],
		            'banque'		=>	isset($data['banque']) ? $data['banque'] : null,
		            'id_membre'		=>	$data['id_membre'],
		        ]);
	        }
	        catch (\Exception $e)
	        {
	        	$db->exec('ROLLBACK;');
	        	throw $e;
	        }
		}

		$db->exec('END;');

		return $id;
	}

	/**
	 * Supprimer un événement de cotisation
	 * @param  integer $id ID de l'événement à supprimer







|















|










|




|







83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
122
123
124
125
126
127
128
129
			false, (int)$data['id_cotisation'], (int)$data['id_membre'], $data['date']);

		if ($check)
		{
			throw new UserException('Cette cotisation a déjà été enregistrée pour ce jour-ci et ce membre-ci.');
		}

		$db->begin();

		$db->simpleInsert('cotisations_membres', [
			'date'				=>	$data['date'],
			'id_cotisation'		=>	$data['id_cotisation'],
			'id_membre'			=>	$data['id_membre'],
			]);

		$id = $db->lastInsertRowId();

		if ($co['id_categorie_compta'] && $co['montant'] > 0)
		{
			try {
		        $id_operation = $this->addOperationCompta($id, [
		        	'id_categorie'	=>	$co['id_categorie_compta'],
		            'libelle'       =>  'Cotisation (automatique)',
		            'montant'       =>  $data['montant'],
		            'date'          =>  $data['date'],
		            'moyen_paiement'=>  $data['moyen_paiement'],
		            'numero_cheque' =>  isset($data['numero_cheque']) ? $data['numero_cheque'] : null,
		            'id_auteur'     =>  $data['id_auteur'],
		            'banque'		=>	isset($data['banque']) ? $data['banque'] : null,
		            'id_membre'		=>	$data['id_membre'],
		        ]);
	        }
	        catch (\Exception $e)
	        {
	        	$db->rollback();
	        	throw $e;
	        }
		}

		$db->commit();

		return $id;
	}

	/**
	 * Supprimer un événement de cotisation
	 * @param  integer $id ID de l'événement à supprimer

Modified src/templates/admin/membres/cotisations/ajout.tpl from [ef40dcb0a6] to [5ac4794ae6].

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
    <fieldset>
        <legend>Enregistrer une cotisation</legend>
        <dl>
            <dt><label for="f_id_cotisation">Cotisation</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select id="f_id_cotisation" required="required" name="id_cotisation">
                    {foreach from=$cotisations item="co"}
                    <option value="{$co.id|escape}" {form_field name="id_cotisation" selected=$co.id default=$default_co} data-compta="{$co.id_categorie_compta|escape}">
                        {$co.intitule|escape}
                        — {$co.montant|html_money} {$config.monnaie|escape}
                        — {if $co.duree}pour {$co.duree|escape} jours
                        {elseif $co.debut}
                            du {$co.debut|format_sqlite_date_to_french} au {$co.fin|format_sqlite_date_to_french}
                        {else}
                            ponctuelle
                        {/if}
                    </option>
                    {/foreach}
                </select>
            </dd>


            <dt class="f_compta"><label for="f_moyen_paiement">Moyen de paiement</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd class="f_compta">
                <select name="moyen_paiement" id="f_moyen_paiement">
                {foreach from=$moyens_paiement item="moyen"}
                    <option value="{$moyen.code|escape}"{if $moyen.code == $moyen_paiement} selected="selected"{/if}>{$moyen.nom|escape}</option>
                {/foreach}
                </select>







|












>
>







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
    <fieldset>
        <legend>Enregistrer une cotisation</legend>
        <dl>
            <dt><label for="f_id_cotisation">Cotisation</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select id="f_id_cotisation" required="required" name="id_cotisation">
                    {foreach from=$cotisations item="co"}
                    <option value="{$co.id|escape}" {form_field name="id_cotisation" selected=$co.id default=$default_co} data-compta="{$co.id_categorie_compta|escape}" data-amount="{$co.montant|escape}">
                        {$co.intitule|escape}
                        — {$co.montant|html_money} {$config.monnaie|escape}
                        — {if $co.duree}pour {$co.duree|escape} jours
                        {elseif $co.debut}
                            du {$co.debut|format_sqlite_date_to_french} au {$co.fin|format_sqlite_date_to_french}
                        {else}
                            ponctuelle
                        {/if}
                    </option>
                    {/foreach}
                </select>
            </dd>
            <dt class="f_compta"><label for="f_montant">Montant</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd class="f_compta"><input type="number" name="montant" step="0.01" min="0.01" id="f_montant" value="{form_field name=montant default=$default_amount}" required="required" /></dd>
            <dt class="f_compta"><label for="f_moyen_paiement">Moyen de paiement</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd class="f_compta">
                <select name="moyen_paiement" id="f_moyen_paiement">
                {foreach from=$moyens_paiement item="moyen"}
                    <option value="{$moyen.code|escape}"{if $moyen.code == $moyen_paiement} selected="selected"{/if}>{$moyen.nom|escape}</option>
                {/foreach}
                </select>
98
99
100
101
102
103
104

105
106
107
108
109
110
111
    changeMoyenPaiement();

    $('#f_moyen_paiement').onchange = changeMoyenPaiement;

    $('#f_id_cotisation').onchange = function () {
        if (this.options[this.selectedIndex].getAttribute('data-compta'))
        {

            toggleElementVisibility('.f_compta', true);
            changeMoyenPaiement();
        }
        else
        {
            toggleElementVisibility('.f_compta', false);
            changeMoyenPaiement();







>







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    changeMoyenPaiement();

    $('#f_moyen_paiement').onchange = changeMoyenPaiement;

    $('#f_id_cotisation').onchange = function () {
        if (this.options[this.selectedIndex].getAttribute('data-compta'))
        {
            $('#f_montant').value = this.options[this.selectedIndex].getAttribute('data-amount'); 
            toggleElementVisibility('.f_compta', true);
            changeMoyenPaiement();
        }
        else
        {
            toggleElementVisibility('.f_compta', false);
            changeMoyenPaiement();

Modified src/templates/admin/membres/cotisations/index.tpl from [e71ccf919c] to [72cf9ec3c7].

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    <fieldset>
        <legend>Ajouter une cotisation</legend>
        <dl>
            <dt><label for="f_intitule">Intitulé</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="intitule" id="f_intitule" value="{form_field name=intitule}" required="required" /></dd>
            <dt><label for="f_description">Description</label></dt>
            <dd><textarea name="description" id="f_description" cols="50" rows="3">{form_field name=description}</textarea></dd>
            <dt><label for="f_montant">Montant</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="number" name="montant" step="0.01" min="0.00" id="f_montant" value="{form_field name=montant default=0.00}" required="required" /></dd>

            <dt><label for="f_periodicite_jours">Période de validité</label></dt>
            <dd><input type="radio" name="periodicite" id="f_periodicite_ponctuel" value="ponctuel" {form_field checked="ponctuel" name=periodicite default="ponctuel"} /> <label for="f_periodicite_ponctuel">Pas de période (cotisation ponctuelle)</label></dd>

            <dd><input type="radio" name="periodicite" id="f_periodicite_jours" value="jours" {form_field checked="jours" name=periodicite} /> <label for="f_periodicite_jours">En nombre de jours</label>
                <dl class="periode_jours">







|







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    <fieldset>
        <legend>Ajouter une cotisation</legend>
        <dl>
            <dt><label for="f_intitule">Intitulé</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="intitule" id="f_intitule" value="{form_field name=intitule}" required="required" /></dd>
            <dt><label for="f_description">Description</label></dt>
            <dd><textarea name="description" id="f_description" cols="50" rows="3">{form_field name=description}</textarea></dd>
            <dt><label for="f_montant">Montant minimal</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="number" name="montant" step="0.01" min="0.00" id="f_montant" value="{form_field name=montant default=0.00}" required="required" /></dd>

            <dt><label for="f_periodicite_jours">Période de validité</label></dt>
            <dd><input type="radio" name="periodicite" id="f_periodicite_ponctuel" value="ponctuel" {form_field checked="ponctuel" name=periodicite default="ponctuel"} /> <label for="f_periodicite_ponctuel">Pas de période (cotisation ponctuelle)</label></dd>

            <dd><input type="radio" name="periodicite" id="f_periodicite_jours" value="jours" {form_field checked="jours" name=periodicite} /> <label for="f_periodicite_jours">En nombre de jours</label>
                <dl class="periode_jours">

Modified src/www/admin/membres/cotisations/ajout.php from [a67846c779] to [ce2a28bfdf].

45
46
47
48
49
50
51

52
53
54
55
56
57
58
    {
        try {
            $data = [
                'date'              =>  utils::post('date'),
                'id_cotisation'     =>  utils::post('id_cotisation'),
                'id_membre'         =>  utils::post('id_membre'),
                'id_auteur'         =>  $user['id'],

                'moyen_paiement'    =>  utils::post('moyen_paiement'),
                'numero_cheque'     =>  utils::post('numero_cheque'),
                'banque'            =>  utils::post('banque'),
            ];

            $m_cotisations->add($data);








>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    {
        try {
            $data = [
                'date'              =>  utils::post('date'),
                'id_cotisation'     =>  utils::post('id_cotisation'),
                'id_membre'         =>  utils::post('id_membre'),
                'id_auteur'         =>  $user['id'],
                'montant'           =>  utils::post('montant'),
                'moyen_paiement'    =>  utils::post('moyen_paiement'),
                'numero_cheque'     =>  utils::post('numero_cheque'),
                'banque'            =>  utils::post('banque'),
            ];

            $m_cotisations->add($data);