Overview
Comment:
  • Saisie avancée fonctionnelle
  • Récup. solde d'un ou plusieurs comptes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9cb04c259120559047e6c602eef0e65abb1d6ac8
User & Date: bohwaz on 2012-07-10 20:45:54
Other Links: manifest | tags
Context
2012-07-13
02:32
Ajout et liste des catégories comptables check-in: fbf0e73204 user: bohwaz tags: trunk
2012-07-10
20:45
  • Saisie avancée fonctionnelle
  • Récup. solde d'un ou plusieurs comptes
check-in: 9cb04c2591 user: bohwaz tags: trunk
19:37
FIX bug où l'ordre n'était pas suivi par la pagination check-in: 957ce0acb9 user: bohwaz tags: trunk
Changes

Modified DB_SCHEMA from [2c3d236bfd] to [4bad1e1c48].

165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
--

CREATE TABLE compta_exercices
-- Exercices
(
    id INTEGER PRIMARY KEY,

    libelle TEXT DEFAULT NOT NULL,

    debut TEXT NOT NULL DEFAULT CURRENT_DATE,
    fin TEXT NULL DEFAULT NULL,

    clos INTEGER NOT NULL DEFAULT 0
);








|







165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
--

CREATE TABLE compta_exercices
-- Exercices
(
    id INTEGER PRIMARY KEY,

    libelle TEXT NOT NULL,

    debut TEXT NOT NULL DEFAULT CURRENT_DATE,
    fin TEXT NULL DEFAULT NULL,

    clos INTEGER NOT NULL DEFAULT 0
);

Modified include/class.compta_journal.php from [316cd4fc78] to [81700df2d3].

24
25
26
27
28
29
30
















31
32
33
34
35
36
37
            WHERE debut >= date(\'now\') AND fin <= date(\'now\') AND clos = 0 LIMIT 1;');

        if ($id)
            return true;

        return false;
    }

















    public function add($data)
    {
        $this->_checkFields($data);

        $db = Garradin_DB::getInstance();








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







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
            WHERE debut >= date(\'now\') AND fin <= date(\'now\') AND clos = 0 LIMIT 1;');

        if ($id)
            return true;

        return false;
    }

    public function getSolde($compte)
    {
        $db = Garradin_DB::getInstance();
        $exercice = $this->_getCurrentExercice();
        $exercice = is_null($exercice) ? 'IS NULL' : '= ' . (int)$exercice;
        $compte = '\'' . $db->escapeString(trim($compte)) . '%\'';

        $query = 'SELECT
            (SELECT SUM(montant) FROM compta_journal
                WHERE compte_credit LIKE '.$compte.' AND id_exercice '.$exercice.')
            - (SELECT SUM(montant) FROM compta_journal
                WHERE compte_debit LIKE '.$compte.' AND id_exercice '.$exercice.');';

        return $db->querySingle($query);
    }

    public function add($data)
    {
        $this->_checkFields($data);

        $db = Garradin_DB::getInstance();

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
        if (empty($data['libelle']) || !trim($data['libelle']))
        {
            throw new UserException('Le libellé ne peut rester vide.');
        }

        $data['libelle'] = trim($data['libelle']);

        if (empty($data['moyen_paiement'])
            || !$db->simpleQuerySingle('SELECT 1 FROM compta_moyens_paiement WHERE code = ?;', false, $data['moyen_paiement']))
        {
            throw new UserException('Moyen de paiement invalide.');
        }








        $data['moyen_paiement'] = strtoupper($data['moyen_paiement']);







        $data['montant'] = (float)$data['montant'];

        if ($data['montant'] <= 0)
        {
            throw new UserException('Le montant ne peut être égal ou inférieur à zéro.');
        }

        foreach (array('remarques', 'numero_piece', 'numero_cheque') as $champ)
        {
            if (empty($data[$champ]) || !trim($data[$champ]))
            {
                $data[$champ] = '';
            }
            else
            {
                $data[$champ] = trim($data[$champ]);
            }
        }

        if ($data['moyen_paiement'] != 'CH')
        {
            $data['numero_cheque'] = NULL;
        }

        if (empty($data['compte_debit']) ||
            !$db->simpleQuerySingle('SELECT 1 FROM compta_comptes WHERE id = ?;', false, $data['compte_debit']))
        {
            throw new UserException('Compte débité inconnu.');
        }

        if (empty($data['compte_credit']) ||







|
|




>
>
>
>
>
>
>
|
>
>
>
>
>
>




















<
<
<
<
<







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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145





146
147
148
149
150
151
152
        if (empty($data['libelle']) || !trim($data['libelle']))
        {
            throw new UserException('Le libellé ne peut rester vide.');
        }

        $data['libelle'] = trim($data['libelle']);

        if (!empty($data['moyen_paiement'])
            && !$db->simpleQuerySingle('SELECT 1 FROM compta_moyens_paiement WHERE code = ?;', false, $data['moyen_paiement']))
        {
            throw new UserException('Moyen de paiement invalide.');
        }

        if (empty($data['moyen_paiement']))
        {
            $data['moyen_paiement'] = null;
            $data['numero_cheque'] = null;
        }
        else
        {
            $data['moyen_paiement'] = strtoupper($data['moyen_paiement']);

            if ($data['moyen_paiement'] != 'CH')
            {
                $data['numero_cheque'] = null;
            }
        }

        $data['montant'] = (float)$data['montant'];

        if ($data['montant'] <= 0)
        {
            throw new UserException('Le montant ne peut être égal ou inférieur à zéro.');
        }

        foreach (array('remarques', 'numero_piece', 'numero_cheque') as $champ)
        {
            if (empty($data[$champ]) || !trim($data[$champ]))
            {
                $data[$champ] = '';
            }
            else
            {
                $data[$champ] = trim($data[$champ]);
            }
        }






        if (empty($data['compte_debit']) ||
            !$db->simpleQuerySingle('SELECT 1 FROM compta_comptes WHERE id = ?;', false, $data['compte_debit']))
        {
            throw new UserException('Compte débité inconnu.');
        }

        if (empty($data['compte_credit']) ||

Modified include/template.php from [fb7e6cb51a] to [7f756091c9].

310
311
312
313
314
315
316

317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335






336
337
338
339
340
341
342
343
    return $out;
}

function tpl_select_compte($params)
{
    $name = $params['name'];
    $comptes = $params['comptes'];


    $out = '<select name="'.$name.'" id="f_'.$name.'" class="large">';

    foreach ($comptes as $compte)
    {
        if (!isset($compte['id'][1]))
        {
            $out.= '<optgroup label="'.htmlspecialchars($compte['libelle'], ENT_QUOTES, 'UTF-8', false).'" class="niveau_1"></optgroup>';
        }
        elseif (!isset($compte['id'][2]))
        {
            if ($compte['id'] > 10)
                $out.= '</optgroup>';

            $out.= '<optgroup label="'.htmlspecialchars($compte['id'] . ' - ' . $compte['libelle'], ENT_QUOTES, 'UTF-8', false).'" class="niveau_2">';
        }
        else
        {
            $out .= '<option value="'.htmlspecialchars($compte['id'], ENT_QUOTES, 'UTF-8', false).'" class="niveau_'.strlen($compte['id']).'">';






            $out .= htmlspecialchars($compte['id'] . ' - ' . $compte['libelle'], ENT_QUOTES, 'UTF-8', false);
            $out .= '</option>';
        }
    }

    $out .= '</optgroup>';
    $out .= '</select>';








>


















|
>
>
>
>
>
>
|







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
    return $out;
}

function tpl_select_compte($params)
{
    $name = $params['name'];
    $comptes = $params['comptes'];
    $selected = utils::post($name);

    $out = '<select name="'.$name.'" id="f_'.$name.'" class="large">';

    foreach ($comptes as $compte)
    {
        if (!isset($compte['id'][1]))
        {
            $out.= '<optgroup label="'.htmlspecialchars($compte['libelle'], ENT_QUOTES, 'UTF-8', false).'" class="niveau_1"></optgroup>';
        }
        elseif (!isset($compte['id'][2]))
        {
            if ($compte['id'] > 10)
                $out.= '</optgroup>';

            $out.= '<optgroup label="'.htmlspecialchars($compte['id'] . ' - ' . $compte['libelle'], ENT_QUOTES, 'UTF-8', false).'" class="niveau_2">';
        }
        else
        {
            $out .= '<option value="'.htmlspecialchars($compte['id'], ENT_QUOTES, 'UTF-8', false).'" class="niveau_'.strlen($compte['id']).'"';

            if ($selected == $compte['id'])
            {
                $out .= ' selected="selected"';
            }

            $out .= '>' . htmlspecialchars($compte['id'] . ' - ' . $compte['libelle'], ENT_QUOTES, 'UTF-8', false);
            $out .= '</option>';
        }
    }

    $out .= '</optgroup>';
    $out .= '</select>';

Modified templates/admin/compta/saisie.tpl from [94a3e6e944] to [fb048d0d96].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{include file="admin/_head.tpl" title="Saisie d'une opération" current="compta/saisie" custom_js="datepickr.js"}

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

<ul class="actions">
    <li><a href="?recettes">Recettes</a></li>
    <li><a href="?depenses">Dépenses</a></li>
    <li><a href="?autres">Autres</a></li>
    <li class="current"><a href="?avancé">Saisie avancée</a></li>
</ul>

<form method="post" action="{$self_url|escape}">

    <fieldset>
        <legend>Informations sur l'opération</legend>
        <dl>












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{include file="admin/_head.tpl" title="Saisie d'une opération" current="compta/saisie" custom_js="datepickr.js"}

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

<ul class="actions">
    <li><a href="?recettes">Recettes</a></li>
    <li><a href="?depenses">Dépenses</a></li>
    <li><a href="?autres">Autres</a></li>
    <li class="current"><a href="?avance">Saisie avancée</a></li>
</ul>

<form method="post" action="{$self_url|escape}">

    <fieldset>
        <legend>Informations sur l'opération</legend>
        <dl>

Modified www/admin/compta/saisie.php from [82827e3cf8] to [7f3551ed41].

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
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try
        {
            $id = $journal->add(array(
                'id_categorie'  =>  $id_categorie,
                'nom'           =>  utils::post('nom'),
                'email'         =>  utils::post('email'),
                'passe'         =>  utils::post('passe'),
                'telephone'     =>  utils::post('telephone'),
                'code_postal'   =>  utils::post('code_postal'),
                'adresse'       =>  utils::post('adresse'),
                'ville'         =>  utils::post('ville'),
                'pays'          =>  utils::post('pays'),
                'date_naissance'=>  utils::post('date_naissance'),
                'notes'         =>  '',
                'lettre_infos'  =>  utils::post('lettre_infos'),
            ));

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







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







20
21
22
23
24
25
26

27
28
29

30
31
32
33

34

35
36
37
38
39
40
41
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try
        {
            $id = $journal->add(array(

                'libelle'       =>  utils::post('libelle'),
                'montant'       =>  utils::post('montant'),
                'date'          =>  utils::post('date'),

                'compte_credit' =>  utils::post('compte_credit'),
                'compte_debit'  =>  utils::post('compte_debit'),
                'numero_piece'  =>  utils::post('numero_piece'),
                'remarques'     =>  utils::post('remarques'),

                'id_auteur'     =>  $user['id'],

            ));

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