Overview
Comment:Rapprochement fonctionnel
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4bf13fe01e84c4435747b9c2e7bf46e31b18acc4
User & Date: bohwaz on 2015-02-19 07:06:56
Other Links: manifest | tags
Context
2015-02-20
06:45
Vérification de la présence des fichiers avant envoi check-in: 0acb6d101e user: bohwaz tags: trunk
2015-02-19
07:06
Rapprochement fonctionnel check-in: 4bf13fe01e user: bohwaz tags: trunk
06:53
formattage rapprochement définitif check-in: 90f06b9e42 user: bohwaz tags: trunk
Changes

Modified src/include/lib/Garradin/Compta/Rapprochement.php from [61b5bbecc5] to [69ffb638fe].

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
        }

        $solde_final = $solde;

        return $result;
    }

    public function record($compte, $operations, $auteur)
    {
        if (!is_array($operations))
        {
            throw new \UnexpectedValueException('$operations doit être un tableau.');





        }

        $db = DB::getInstance();
        $db->exec('BEGIN;');


        $st = $db->prepare('INSERT OR REPLACE INTO compta_rapprochement (operation, auteur) 
            VALUES (:operation, :auteur);');
        $st->bindValue(':auteur', (int)$auteur, \SQLITE3_INTEGER);

        foreach ($operations as $row)
        {



            $st->bindValue(':operation', (int)$row, \SQLITE3_INTEGER);












            $st->execute();
        }

        $db->exec('END;');
        return true;
    }
}







|

|

|
>
>
>
>
>




>
>




|

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







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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
        }

        $solde_final = $solde;

        return $result;
    }

    public function record($compte, $journal, $cases, $auteur)
    {
        if (!is_array($journal))
        {
            throw new \UnexpectedValueException('$journal doit être un tableau.');
        }

        if (!is_array($cases) && empty($cases))
        {
            $cases = [];
        }

        $db = DB::getInstance();
        $db->exec('BEGIN;');

        // Synchro des trucs cochés
        $st = $db->prepare('INSERT OR REPLACE INTO compta_rapprochement (operation, auteur) 
            VALUES (:operation, :auteur);');
        $st->bindValue(':auteur', (int)$auteur, \SQLITE3_INTEGER);

        foreach ($journal as $row)
        {
            if (!array_key_exists($row['id'], $cases))
                continue;

            $st->bindValue(':operation', (int)$row['id'], \SQLITE3_INTEGER);
            $st->execute();
        }

        // Synchro des trucs NON cochés
        $st = $db->prepare('DELETE FROM compta_rapprochement WHERE operation = :id;');

        foreach ($journal as $row)
        {
            if (array_key_exists($row['id'], $cases))
                continue;

            $st->bindValue(':id', (int)$row['id'], \SQLITE3_INTEGER);
            $st->execute();
        }

        $db->exec('END;');
        return true;
    }
}

Modified src/templates/admin/compta/banques/rapprocher.tpl from [8baf0ddb75] to [9929219aa3].

84
85
86
87
88
89
90

91
92
93
94
95
                <td colspan="5"></td>
                <td>{$solde_final|html_money} {$config.monnaie|escape}</td>
                <th>Solde au {$fin|format_sqlite_date_to_french}</th>
            </tr>
        </tfoot>
    </table>
    <p class="submit">

        <input type="submit" name="save" value="Enregistrer" />
    </p>
</form>

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







>





84
85
86
87
88
89
90
91
92
93
94
95
96
                <td colspan="5"></td>
                <td>{$solde_final|html_money} {$config.monnaie|escape}</td>
                <th>Solde au {$fin|format_sqlite_date_to_french}</th>
            </tr>
        </tfoot>
    </table>
    <p class="submit">
        {csrf_field key="compta_rapprocher_`$compte.id`"}
        <input type="submit" name="save" value="Enregistrer" />
    </p>
</form>

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

Modified src/www/admin/compta/banques/rapprocher.php from [c19f0013d0] to [5a59c6abd4].

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
if (!$compte)
{
    throw new UserException("Le compte demandé n'existe pas.");
}

$error = false;

if (Utils::post('save'))
{
    if (!Utils::CSRF_check('compta_rapprocher_' . $compte['id']))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try
        {
            $rapprochement->record($compte['id'], Utils::post('rapprocher'), $user['id']);
            Utils::redirect('/admin/compta/banques/rapprocher.php?id=');
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
	}
}

$debut = Utils::get('debut');
$fin = Utils::get('fin');

if ($debut && $fin)
{
    if (!Utils::checkDate($debut) || !Utils::checkDate($fin))







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







18
19
20
21
22
23
24















25



26
27
28
29
30
31
32
if (!$compte)
{
    throw new UserException("Le compte demandé n'existe pas.");
}

$error = false;
















$solde_initial = $solde_final = 0;




$debut = Utils::get('debut');
$fin = Utils::get('fin');

if ($debut && $fin)
{
    if (!Utils::checkDate($debut) || !Utils::checkDate($fin))
64
65
66
67
68
69
70























71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

if (!$debut || !$fin)
{
    $date = $exercice['fin'];
    $debut = date('Y-m-01', $date);
    $fin = date('Y-m-t', $date);
}
























if (substr($debut, 0, 7) == substr($fin, 0, 7))
{
    $tpl->assign('prev', Utils::modifyDate($debut, '-1 month', true));
    $tpl->assign('next', Utils::modifyDate($fin, '+1 month', true));
}

$solde_initial = $solde_final = 0;

$tpl->assign('compte', $compte);
$tpl->assign('debut', $debut);
$tpl->assign('fin', $fin);

$tpl->assign('journal', $rapprochement->getJournal($compte['id'], $debut, $fin, $solde_initial, $solde_final));

$tpl->assign('solde_initial', $solde_initial);
$tpl->assign('solde_final', $solde_final);

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

$tpl->display('admin/compta/banques/rapprocher.tpl');







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







<
<




|







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


83
84
85
86
87
88
89
90
91
92
93
94

if (!$debut || !$fin)
{
    $date = $exercice['fin'];
    $debut = date('Y-m-01', $date);
    $fin = date('Y-m-t', $date);
}

$journal = $rapprochement->getJournal($compte['id'], $debut, $fin, $solde_initial, $solde_final);

// Enregistrement des cases cochées
if (Utils::post('save'))
{
    if (!Utils::CSRF_check('compta_rapprocher_' . $compte['id']))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try
        {
            $rapprochement->record($compte['id'], $journal, Utils::post('rapprocher'), $user['id']);
            Utils::redirect(Utils::getSelfURL());
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
	}
}

if (substr($debut, 0, 7) == substr($fin, 0, 7))
{
    $tpl->assign('prev', Utils::modifyDate($debut, '-1 month', true));
    $tpl->assign('next', Utils::modifyDate($fin, '+1 month', true));
}



$tpl->assign('compte', $compte);
$tpl->assign('debut', $debut);
$tpl->assign('fin', $fin);

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

$tpl->assign('solde_initial', $solde_initial);
$tpl->assign('solde_final', $solde_final);

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

$tpl->display('admin/compta/banques/rapprocher.tpl');

Modified src/www/admin/static/scripts/global.js from [7ebc6fb98f] to [b670693e89].

168
169
170
171
172
173
174





175
176
177
178
179
180
						}
						
						if (elm.checked)
							parent.className += ' checked';
						else
							parent.className = parent.className.replace(/ checked/, '');
					};





				}
			}
		});
	}

})();







>
>
>
>
>






168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
						}
						
						if (elm.checked)
							parent.className += ' checked';
						else
							parent.className = parent.className.replace(/ checked/, '');
					};

					if (checkBoxes[j].checked)
					{
						checkBoxes[j].onchange({target: checkBoxes[j]});
					}
				}
			}
		});
	}

})();