Comment: | Modernisation compta / changement aussi de la gestion des forms pour faire de l'objet |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
61ac1e5c2a4cb3829a5311d26efc43cf |
User & Date: | bohwaz on 2017-05-19 07:25:00 |
Other Links: | branch diff | manifest | tags |
2017-05-24
| ||
02:22 | Fichiers : ajout possibilité de stockage à partir d'une chaîne encodée en base64 check-in: ad5540c863 user: bohwaz tags: dev | |
2017-05-19
| ||
07:25 | Modernisation compta / changement aussi de la gestion des forms pour faire de l'objet check-in: 61ac1e5c2a user: bohwaz tags: dev | |
05:46 | Modernisation/remise en fonctionnement des fichiers dans le wiki check-in: 2db443930d user: bohwaz tags: dev | |
Modified src/include/lib/Garradin/Compta/Categories.php from [ae38db4253] to [c234c132b2].
whitespace changes only
Modified src/include/lib/Garradin/Compta/Comptes.php from [5e4270a61a] to [206fe5f03c].
whitespace changes only
Modified src/include/lib/Garradin/Compta/Comptes_Bancaires.php from [981d7813a1] to [c9af4deba8].
whitespace changes only
Modified src/include/lib/Garradin/Compta/Exercices.php from [0831de6860] to [c811ae1bf1].
︙ | ︙ | |||
10 11 12 13 14 15 16 | { public function add($data) { $this->_checkFields($data); $db = DB::getInstance(); | | | | | | | | | | | | | | 10 11 12 13 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 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 | { public function add($data) { $this->_checkFields($data); $db = DB::getInstance(); if ($db->firstColumn('SELECT 1 FROM compta_exercices WHERE (debut <= :debut AND fin >= :debut) OR (debut <= :fin AND fin >= :fin);', ['debut' => $data['debut'], 'fin' => $data['fin']])) { throw new UserException('La date de début ou de fin se recoupe avec un autre exercice.'); } if ($db->firstColumn('SELECT 1 FROM compta_exercices WHERE cloture = 0;')) { throw new UserException('Il n\'est pas possible de créer un nouvel exercice tant qu\'il existe un exercice non-clôturé.'); } $db->insert('compta_exercices', [ 'libelle' => trim($data['libelle']), 'debut' => $data['debut'], 'fin' => $data['fin'], ]); return $db->lastInsertRowId(); } public function edit($id, $data) { $db = DB::getInstance(); $this->_checkFields($data); // Evitons que les exercices se croisent if ($db->firstColumn('SELECT 1 FROM compta_exercices WHERE id != :id AND ((debut <= :debut AND fin >= :debut) OR (debut <= :fin AND fin >= :fin));', ['debut' => $data['debut'], 'fin' => $data['fin'], 'id' => (int) $id])) { throw new UserException('La date de début ou de fin se recoupe avec un autre exercice.'); } // On vérifie qu'on ne va pas mettre des opérations en dehors de tout exercice if ($db->firstColumn('SELECT 1 FROM compta_journal WHERE id_exercice = ? AND date < ? LIMIT 1;', (int)$id, $data['debut'])) { throw new UserException('Des opérations de cet exercice ont une date antérieure à la date de début de l\'exercice.'); } if ($db->firstColumn('SELECT 1 FROM compta_journal WHERE id_exercice = ? AND date > ? LIMIT 1;', (int)$id, $data['fin'])) { throw new UserException('Des opérations de cet exercice ont une date postérieure à la date de fin de l\'exercice.'); } $db->update('compta_exercices', [ 'libelle' => trim($data['libelle']), 'debut' => $data['debut'], 'fin' => $data['fin'], ], 'id = :id', ['id' => (int)$id]); return true; } /** * Clôturer un exercice et en ouvrir un nouveau * Le report à nouveau n'est pas effectué automatiquement par cette fonction, voir doReports pour ça. |
︙ | ︙ | |||
86 87 88 89 90 91 92 | { throw new UserException('Date de fin vide ou invalide.'); } $db->begin(); // Clôture de l'exercice | | | | | > | > | 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 | { throw new UserException('Date de fin vide ou invalide.'); } $db->begin(); // Clôture de l'exercice $db->update('compta_exercices', [ 'cloture' => 1, 'fin' => $end, ], 'id = :id', ['id' => (int)$id]); // Date de début du nouvel exercice : lendemain de la clôture du précédent exercice $new_begin = Utils::modifyDate($end, '+1 day'); // Date de fin du nouvel exercice : un an moins un jour après l'ouverture $new_end = Utils::modifyDate($new_begin, '+1 year -1 day'); // Enfin sauf s'il existe déjà des opérations après cette date, auquel cas la date de fin // est fixée à la date de la dernière opération, ceci pour ne pas avoir d'opération // orpheline d'exercice $last = $db->firstColumn('SELECT date FROM compta_journal WHERE id_exercice = ? AND date >= ? ORDER BY date DESC LIMIT 1;', $id, $new_end); $new_end = $last ?: $new_end; // Création du nouvel exercice $new_id = $this->add([ 'debut' => $new_begin, 'fin' => $new_end, 'libelle' => 'Nouvel exercice' ]); // Ré-attribution des opérations de l'exercice à clôturer qui ne sont pas dans son // intervale au nouvel exercice $db->update('compta_journal', ['id_exercice' => $new_id], 'id_exercice = :id AND date >= :date', [ 'id' => $id, 'date' => $new_begin, ]); $db->commit(); return $new_id; } /** |
︙ | ︙ | |||
152 153 154 155 156 157 158 | } unset($comptes); $this->solderResultat($old_id, $date); // Récupérer chacun des comptes de bilan et leurs soldes (uniquement les classes 1 à 5) | | | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | } unset($comptes); $this->solderResultat($old_id, $date); // Récupérer chacun des comptes de bilan et leurs soldes (uniquement les classes 1 à 5) $statement = $db->query('SELECT compta_comptes.id AS compte, compta_comptes.position AS position, COALESCE((SELECT SUM(montant) FROM compta_journal WHERE compte_debit = compta_comptes.id AND id_exercice = :id), 0) - COALESCE((SELECT SUM(montant) FROM compta_journal WHERE compte_credit = compta_comptes.id AND id_exercice = :id), 0) AS solde FROM compta_comptes INNER JOIN compta_journal ON compta_comptes.id = compta_journal.compte_debit OR compta_comptes.id = compta_journal.compte_credit WHERE id_exercice = :id AND solde != 0 AND CAST(substr(compta_comptes.id, 1, 1) AS INTEGER) <= 5 GROUP BY compta_comptes.id;', ['id' => $old_id]); |
︙ | ︙ | |||
248 249 250 251 252 253 254 | } public function delete($id) { $db = DB::getInstance(); // Ne pas supprimer un compte qui est utilisé ! | | | | | | | | | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | } public function delete($id) { $db = DB::getInstance(); // Ne pas supprimer un compte qui est utilisé ! if ($db->firstColumn('SELECT 1 FROM compta_journal WHERE id_exercice = ? LIMIT 1;', $id)) { throw new UserException('Cet exercice ne peut être supprimé car des opérations comptables y sont liées.'); } $db->delete('compta_exercices', 'id = ?', (int)$id); return true; } public function get($id) { $db = DB::getInstance(); return $db->first('SELECT *, strftime(\'%s\', debut) AS debut, strftime(\'%s\', fin) AS fin FROM compta_exercices WHERE id = ?;', (int)$id); } public function getCurrent() { $db = DB::getInstance(); return $db->first('SELECT *, strftime(\'%s\', debut) AS debut, strftime(\'%s\', fin) AS fin FROM compta_exercices WHERE cloture = 0 LIMIT 1;'); } public function getCurrentId() { $db = DB::getInstance(); return $db->firstColumn('SELECT id FROM compta_exercices WHERE cloture = 0 LIMIT 1;'); } public function getList() { $db = DB::getInstance(); return $db->getAssocKey('SELECT id, *, strftime(\'%s\', debut) AS debut, strftime(\'%s\', fin) AS fin, (SELECT COUNT(*) FROM compta_journal WHERE id_exercice = compta_exercices.id) AS nb_operations FROM compta_exercices ORDER BY fin DESC;'); } protected function _checkFields(&$data) { if (empty($data['libelle']) || !trim($data['libelle'])) { throw new UserException('Le libellé ne peut rester vide.'); |
︙ | ︙ | |||
313 314 315 316 317 318 319 | return true; } public function getJournal($exercice) { $db = DB::getInstance(); | | | < | | | | < | 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 | return true; } public function getJournal($exercice) { $db = DB::getInstance(); return $db->get('SELECT *, strftime(\'%s\', date) AS date FROM compta_journal WHERE id_exercice = ? ORDER BY date, id;', $exercice); } public function getGrandLivre($exercice) { $db = DB::getInstance(); $livre = ['classes' => [], 'debit' => 0.0, 'credit' => 0.0]; $res = $db->query('SELECT compte FROM (SELECT compte_debit AS compte FROM compta_journal WHERE id_exercice = :exercice GROUP BY compte_debit UNION SELECT compte_credit AS compte FROM compta_journal WHERE id_exercice = :exercice GROUP BY compte_credit) ORDER BY compte ASC;', ['exercice' => (int) $exercice]); while ($row = $res->fetchArray(SQLITE3_NUM)) { $compte = $row[0]; if (is_null($compte)) continue; |
︙ | ︙ | |||
357 358 359 360 361 362 363 | 'total' => 0.0, 'comptes' => [], ]; } $livre['classes'][$classe][$parent]['comptes'][$compte] = ['debit' => 0.0, 'credit' => 0.0, 'journal' => []]; | | | | | > > | | | > | | | | | | | | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | 'total' => 0.0, 'comptes' => [], ]; } $livre['classes'][$classe][$parent]['comptes'][$compte] = ['debit' => 0.0, 'credit' => 0.0, 'journal' => []]; $livre['classes'][$classe][$parent]['comptes'][$compte]['journal'] = $db->get( 'SELECT *, strftime(\'%s\', date) AS date FROM ( SELECT * FROM compta_journal WHERE compte_debit = :compte AND id_exercice = :exercice UNION SELECT * FROM compta_journal WHERE compte_credit = :compte AND id_exercice = :exercice ) ORDER BY date, numero_piece, id;', ['compte' => $compte, 'exercice' => (int) $exercice]); $solde = 0.0; foreach ($livre['classes'][$classe][$parent]['comptes'][$compte]['journal'] as &$ligne) { if ($ligne->compte_credit == $compte) { $solde += $ligne->montant; } else { $solde -= $ligne->montant; } $ligne->solde = $solde; } $debit = (float) $db->firstColumn( 'SELECT SUM(montant) FROM compta_journal WHERE compte_debit = ? AND id_exercice = ?;', $compte, (int) $exercice); $credit = (float) $db->firstColumn( 'SELECT SUM(montant) FROM compta_journal WHERE compte_credit = ? AND id_exercice = ?;', $compte, (int) $exercice); $livre['classes'][$classe][$parent]['comptes'][$compte]['debit'] = $debit; $livre['classes'][$classe][$parent]['comptes'][$compte]['credit'] = $credit; $livre['classes'][$classe][$parent]['comptes'][$compte]['solde'] = $credit - $debit; $livre['classes'][$classe][$parent]['total'] += $debit; $livre['classes'][$classe][$parent]['total'] -= $credit; |
︙ | ︙ | |||
411 412 413 414 415 416 417 | { $db = DB::getInstance(); $charges = ['comptes' => [], 'total' => 0.0]; $produits = ['comptes' => [], 'total' => 0.0]; $resultat = 0.0; | | | | | < | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | { $db = DB::getInstance(); $charges = ['comptes' => [], 'total' => 0.0]; $produits = ['comptes' => [], 'total' => 0.0]; $resultat = 0.0; $res = $db->query('SELECT compte, SUM(debit), SUM(credit) FROM (SELECT compte_debit AS compte, SUM(montant) AS debit, 0 AS credit FROM compta_journal WHERE id_exercice = :exercice GROUP BY compte_debit UNION SELECT compte_credit AS compte, 0 AS debit, SUM(montant) AS credit FROM compta_journal WHERE id_exercice = :exercice GROUP BY compte_credit) WHERE compte LIKE \'6%\' OR compte LIKE \'7%\' GROUP BY compte ORDER BY compte ASC;', ['exercice' => (int)$exercice]); while ($row = $res->fetchArray(SQLITE3_NUM)) { list($compte, $debit, $credit) = $row; $classe = substr($compte, 0, 1); $parent = substr($compte, 0, 2); |
︙ | ︙ | |||
510 511 512 513 514 515 516 | ]; $passif['total'] = $resultat['resultat']; } // Y'a sûrement moyen d'améliorer tout ça pour que le maximum de travail // soit fait au niveau du SQL, mais pour le moment ça marche | | | | | < | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | ]; $passif['total'] = $resultat['resultat']; } // Y'a sûrement moyen d'améliorer tout ça pour que le maximum de travail // soit fait au niveau du SQL, mais pour le moment ça marche $res = $db->query('SELECT compte, debit, credit, (SELECT position FROM compta_comptes WHERE id = compte) AS position FROM (SELECT compte_debit AS compte, SUM(montant) AS debit, NULL AS credit FROM compta_journal WHERE id_exercice = :exercice GROUP BY compte_debit UNION SELECT compte_credit AS compte, NULL AS debit, SUM(montant) AS credit FROM compta_journal WHERE id_exercice = :exercice GROUP BY compte_credit) WHERE compte IN (SELECT id FROM compta_comptes WHERE position IN ('.implode(', ', $include).')) ORDER BY compte ASC;', ['exercice' => (int)$exercice]); while ($row = $res->fetchArray(SQLITE3_NUM)) { list($compte, $debit, $credit, $position) = $row; $parent = substr($compte, 0, 2); $classe = $compte[0]; |
︙ | ︙ |
Modified src/include/lib/Garradin/Compta/Rapprochement.php from [b2268513dd] to [f49b02cffe].
whitespace changes only
Modified src/include/lib/Garradin/Compta/Stats.php from [63af68cb36] to [5104b17973].
1 2 3 4 5 6 7 8 9 10 11 12 | <?php namespace Garradin\Compta; use \Garradin\DB; use \Garradin\Utils; use \Garradin\UserException; class Stats { protected function _parRepartitionCategorie($type) { | < | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 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 42 43 44 | <?php namespace Garradin\Compta; use \Garradin\DB; use \Garradin\Utils; use \Garradin\UserException; class Stats { protected function _parRepartitionCategorie($type) { return DB::getInstance()->get('SELECT SUM(montant) AS somme, id_categorie FROM compta_journal WHERE id_categorie IN (SELECT id FROM compta_categories WHERE type = ?) AND id_exercice = (SELECT id FROM compta_exercices WHERE cloture = 0) GROUP BY id_categorie ORDER BY somme DESC;', $type); } public function repartitionRecettes() { return $this->_parRepartitionCategorie(Categories::RECETTES); } public function repartitionDepenses() { return $this->_parRepartitionCategorie(Categories::DEPENSES); } protected function _parType($type) { return $this->getStats('SELECT strftime(\'%Y%m\', date) AS date, SUM(montant) FROM compta_journal WHERE id_categorie IN (SELECT id FROM compta_categories WHERE type = :type) AND id_exercice = (SELECT id FROM compta_exercices WHERE cloture = 0) GROUP BY strftime(\'%Y-%m\', date) ORDER BY date;', ['type' => $type]); } public function recettes() { return $this->_parType(Categories::RECETTES); } |
︙ | ︙ | |||
81 82 83 84 85 86 87 | $c += $v; $stats[$k] = $c; } return $stats; } | | | | | > | | | | 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 | $c += $v; $stats[$k] = $c; } return $stats; } public function getStats($query, Array $args = []) { $db = DB::getInstance(); $data = $db->getAssoc($query, $args); $e = $db->first('SELECT *, strftime(\'%s\', debut) AS debut, strftime(\'%s\', fin) AS fin FROM compta_exercices WHERE cloture = 0 LIMIT 1;'); if (!$e) { return []; } $y = date('Y', $e->debut); $m = date('m', $e->debut); $max = date('Ym', $e->fin); while ($y . $m <= $max) { if (!isset($data[$y . $m])) { $data[$y . $m] = 0; } |
︙ | ︙ |
Modified src/include/lib/Garradin/DB.php from [9faaff99f4] to [3716397b8d].
︙ | ︙ | |||
670 671 672 673 674 675 676 | } /** * @deprecated */ public function queryFetch($query, $mode = null) { | | | | | 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | } /** * @deprecated */ public function queryFetch($query, $mode = null) { return $this->simpleStatementFetch($query, $mode); } /** * @deprecated */ public function queryFetchAssoc($query) { return $this->simpleStatementFetchAssoc($query); } /** * @deprecated */ public function queryFetchAssocKey($query, $mode = null) { return $this->simpleStatementFetchAssocKey($query, $mode); } /** * @deprecated */ public function simpleQuerySingle($query, $all_columns = false) { |
︙ | ︙ |
Added src/include/lib/Garradin/Form.php version [3de82224f0].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 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 42 43 44 | <?php namespace Garradin; class Form { protected $errors = []; public function check($token_action = '') { if (!\KD2\Form::tokenCheck($token_action)) { $this->errors[] = 'Erreur CSRF'; return false; } return true; } public function validate(Array $rules) { return \KD2\Form::validate($rules, $this->errors, $_POST); } public function hasErrors() { return (count($this->errors) > 0); } public function &getErrors() { return $this->errors; } public function getErrorMessages() { return; } public function __invoke($key) { return \KD2\Form::get($key); } } |
Modified src/templates/admin/compta/comptes/modifier.tpl from [55777f2458] to [f906ad5d55].
1 2 | {include file="admin/_head.tpl" title="Modifier un compte" current="compta/categories"} | < < | < < | 1 2 3 4 5 6 7 8 9 10 | {include file="admin/_head.tpl" title="Modifier un compte" current="compta/categories"} {form_errors} <form method="post" action="{$self_url}"> <fieldset> <legend>Modifier un compte</legend> <dl> <dt><label for="f_libelle">Libellé</label> <b title="(Champ obligatoire)">obligatoire</b></dt> |
︙ | ︙ |
Modified src/templates/admin/compta/exercices/ajouter.tpl from [8df71f6c27] to [c84bd45486].
1 2 | {include file="admin/_head.tpl" title="Commencer un exercice" current="compta/exercices" js=1} | < < | < < | 1 2 3 4 5 6 7 8 9 10 | {include file="admin/_head.tpl" title="Commencer un exercice" current="compta/exercices" js=1} {form_errors} <form method="post" action="{$self_url}"> <fieldset> <legend>Commencer un nouvel exercice</legend> <dl> <dt><label for="f_libelle">Libellé</label> <b title="(Champ obligatoire)">obligatoire</b></dt> |
︙ | ︙ |
Modified src/templates/admin/compta/exercices/cloturer.tpl from [f29deb24fb] to [852ff3bdd2].
1 2 | {include file="admin/_head.tpl" title="Clôturer un exercice" current="compta/exercices" js=1} | < < | < < | 1 2 3 4 5 6 7 8 9 10 | {include file="admin/_head.tpl" title="Clôturer un exercice" current="compta/exercices" js=1} {form_errors} <form method="post" action="{$self_url}"> <fieldset> <legend>Clôturer un exercice</legend> <h3 class="warning"> Êtes-vous sûr de vouloir clôturer l'exercice « {$exercice.libelle} » ? |
︙ | ︙ |
Modified src/templates/admin/compta/exercices/modifier.tpl from [8545fe9bda] to [ea0aa3d194].
1 2 | {include file="admin/_head.tpl" title="Modifier un exercice" current="compta/exercices" js=1} | < < | < < | 1 2 3 4 5 6 7 8 9 10 | {include file="admin/_head.tpl" title="Modifier un exercice" current="compta/exercices" js=1} {form_errors} <form method="post" action="{$self_url}"> <fieldset> <legend>Modifier un exercice</legend> <dl> <dt><label for="f_libelle">Libellé</label> <b title="(Champ obligatoire)">obligatoire</b></dt> |
︙ | ︙ |
Modified src/templates/admin/compta/import.tpl from [e027e3b5ff] to [20cc30ed8a].
1 2 | {include file="admin/_head.tpl" title="Import / Export" current="compta"} | < < | | | | 1 2 3 4 5 6 7 8 9 10 11 12 | {include file="admin/_head.tpl" title="Import / Export" current="compta"} {form_errors} {if $ok} <p class="confirm"> L'import s'est bien déroulé. </p> {/if} <ul class="actions"> <li class="current"><a href="{$www_url}admin/compta/import.php">Importer</a></li> |
︙ | ︙ |
Modified src/www/admin/_inc.php from [ee330da3e9] to [a79bfe08b9].
1 2 3 4 5 | <?php namespace Garradin; use Garradin\Membres\Session; | < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?php namespace Garradin; use Garradin\Membres\Session; require_once __DIR__ . '/../../include/init.php'; // Redirection automatique en HTTPS si nécessaire if (PREFER_HTTPS !== true && PREFER_HTTPS >= 2 && empty($_SERVER['HTTPS']) && empty($_POST)) { utils::redirect(str_replace('http://', 'https://', utils::getSelfURL())); exit; } // Query-Validate: valider les éléments passés en GET function qv(Array $rules) { if (Form::validate($rules, $errors, $_GET)) { return true; } |
︙ | ︙ | |||
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | { return isset($_GET[$key]) ? $_GET[$key] : null; } $tpl = Template::getInstance(); $tpl->assign('admin_url', WWW_URL . 'admin/'); $session = Session::get(); if (!defined('Garradin\LOGIN_PROCESS')) { if (!$session) { if (Session::isOTPRequired()) | > > > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | { return isset($_GET[$key]) ? $_GET[$key] : null; } $tpl = Template::getInstance(); $tpl->assign('admin_url', WWW_URL . 'admin/'); $form = new Form; $tpl->assign_by_ref('form_errors', $form->getErrors()); $session = Session::get(); if (!defined('Garradin\LOGIN_PROCESS')) { if (!$session) { if (Session::isOTPRequired()) |
︙ | ︙ |
Modified src/www/admin/compta/_inc.php from [668ded3763] to [d9a9f9120a].
1 2 3 4 5 6 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; | | < < < | 1 2 3 4 5 6 7 8 9 10 11 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ACCES); $comptes = new Compta\Comptes; $tpl->assign('id_caisse', Compta\Comptes::CAISSE); |
Modified src/www/admin/compta/exercices/ajouter.php from [84b6bbaf7d] to [ed57d48ab3].
1 2 3 4 5 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; | | < < < < | < | < > > > | | | | | | | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ADMIN); $e = new Compta\Exercices; if (f('add')) { fc('compta_ajout_exercice', [ 'libelle' => 'required', 'fin' => 'required|date', 'debut' => 'required|date', ], $form_errors); if (count($form_errors) == 0) { try { $id = $e->add([ 'libelle' => f('libelle'), 'debut' => f('debut'), 'fin' => f('fin'), ]); Utils::redirect('/admin/compta/exercices/'); } catch (UserException $e) { $form_errors[] = $e->getMessage(); } } } $tpl->display('admin/compta/exercices/ajouter.tpl'); |
Modified src/www/admin/compta/exercices/bilan.php from [8bd50769bf] to [8a023f5709].
1 2 3 4 5 6 7 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $exercices = new Compta\Exercices; | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $exercices = new Compta\Exercices; $exercice = $exercices->get((int)qg('id')); if (!$exercice) { throw new UserException('Exercice inconnu.'); } $liste_comptes = $comptes->getListAll(); function get_nom_compte($compte) { global $liste_comptes; return $liste_comptes[$compte]; } $tpl->register_modifier('get_nom_compte', 'Garradin\get_nom_compte'); $tpl->assign('bilan', $exercices->getBilan($exercice->id)); $tpl->assign('cloture', $exercice->cloture ? $exercice->fin : time()); $tpl->assign('exercice', $exercice); $tpl->display('admin/compta/exercices/bilan.tpl'); |
Modified src/www/admin/compta/exercices/cloturer.php from [fa758bc632] to [8abfc96cf3].
1 2 3 4 5 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; | | < < < | < | < | < > > | | < > | | | | < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 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 42 43 44 45 46 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ADMIN); $e = new Compta\Exercices; $exercice = $e->get((int)qg('id')); if (!$exercice) { throw new UserException('Exercice inconnu.'); } if (f('close')) { fc('compta_cloturer_exercice_' . $exercice->id, [ 'fin' => 'date|required', 'reports' => 'boolean', ], $form_errors); if (count($form_errors) == 0) { try { $id = $e->close($exercice->id, f('fin')); if ($id && f('reports')) { $e->doReports($exercice->id, Utils::modifyDate(f('fin'), '+1 day')); } Utils::redirect('/admin/compta/exercices/'); } catch (UserException $e) { $form_errors[] = $e->getMessage(); } } } $tpl->assign('exercice', $exercice); $tpl->display('admin/compta/exercices/cloturer.tpl'); |
Modified src/www/admin/compta/exercices/compte_resultat.php from [f77464ad8f] to [a0497a409d].
1 2 3 4 5 6 7 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $exercices = new Compta\Exercices; | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $exercices = new Compta\Exercices; $exercice = $exercices->get((int)qg('id')); if (!$exercice) { throw new UserException('Exercice inconnu.'); } $liste_comptes = $comptes->getListAll(); function get_nom_compte($compte) { global $liste_comptes; return $liste_comptes[$compte]; } $tpl->register_modifier('get_nom_compte', 'Garradin\get_nom_compte'); $tpl->assign('compte_resultat', $exercices->getCompteResultat($exercice->id)); $tpl->assign('cloture', $exercice->cloture ? $exercice->fin : time()); $tpl->assign('exercice', $exercice); $tpl->display('admin/compta/exercices/compte_resultat.tpl'); |
Modified src/www/admin/compta/exercices/grand_livre.php from [6741cade3e] to [30a396ce8e].
1 2 3 4 5 6 7 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $exercices = new Compta\Exercices; | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $exercices = new Compta\Exercices; $exercice = $exercices->get((int)qg('id')); if (!$exercice) { throw new UserException('Exercice inconnu.'); } $liste_comptes = $comptes->getListAll(); function get_nom_compte($compte) { global $liste_comptes; return $liste_comptes[$compte]; } $tpl->register_modifier('get_nom_compte', 'Garradin\get_nom_compte'); $tpl->assign('livre', $exercices->getGrandLivre($exercice->id)); $tpl->assign('cloture', $exercice->cloture ? $exercice->fin : time()); $tpl->assign('exercice', $exercice); $tpl->display('admin/compta/exercices/grand_livre.tpl'); |
Modified src/www/admin/compta/exercices/journal.php from [90f31fb433] to [5f28fca015].
1 2 3 4 5 6 7 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $exercices = new Compta\Exercices; | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $exercices = new Compta\Exercices; $exercice = $exercices->get((int)qg('id')); if (!$exercice) { throw new UserException('Exercice inconnu.'); } $liste_comptes = $comptes->getListAll(); function get_nom_compte($compte) { if (is_null($compte)) return ''; global $liste_comptes; return $liste_comptes[$compte]; } $tpl->register_modifier('get_nom_compte', 'Garradin\get_nom_compte'); $tpl->assign('journal', $exercices->getJournal($exercice->id)); $tpl->assign('cloture', $exercice->cloture ? $exercice->fin : time()); $tpl->assign('exercice', $exercice); $tpl->display('admin/compta/exercices/journal.tpl'); |
Modified src/www/admin/compta/exercices/modifier.php from [24bc6904ad] to [c40172abfa].
1 2 3 4 5 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; | | < < < | | < | < | | > > | > > | < > < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 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 42 43 44 45 46 47 48 49 50 51 52 53 | <?php namespace Garradin; require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ADMIN); $e = new Compta\Exercices; $exercice = $e->get((int)qg('id')); if (!$exercice) { throw new UserException('Exercice inconnu.'); } if ($exercice->cloture) { throw new UserException('Impossible de modifier un exercice clôturé.'); } if ($form('edit')) { $form->check('compta_modif_exercice_' . $exercice->id); $form->validate([ 'libelle' => 'required', 'fin' => 'required|date', 'debut' => 'required|date', ]); if (!$form->hasErrors()) { try { $id = $e->edit($exercice['id'], [ 'libelle' => Utils::post('libelle'), 'debut' => Utils::post('debut'), 'fin' => Utils::post('fin'), ]); Utils::redirect('/admin/compta/exercices/'); } catch (UserException $e) { $error = $e->getMessage(); } } } $tpl->assign('exercice', $exercice); $tpl->display('admin/compta/exercices/modifier.tpl'); |
Modified src/www/admin/compta/graph.php from [80ae2df104] to [30e9fb5def].
1 2 3 4 5 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; | | | < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; qv(['g' => 'required|in:recettes_depenses:banques_caisses']); $graph = qg('g'); if (Static_Cache::expired('graph_' . $graph)) { $stats = new Compta\Stats; $plot = new \KD2\SVGPlot(400, 300); |
︙ | ︙ |
Modified src/www/admin/compta/import.php from [48462d1086] to [029d24a386].
1 2 3 4 5 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; | | < < < > | > | | < < < | < > | | < > | | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; $session->requireAccess('compta', Membres::DROIT_ADMIN); $e = new Compta\Exercices; $import = new Compta\Import; $form_errors = []; if (qg('export') !== null) { header('Content-type: application/csv'); header('Content-Disposition: attachment; filename="Export comptabilité - ' . $config->get('nom_asso') . ' - ' . date('Y-m-d') . '.csv"'); $import->toCSV($e->getCurrentId()); exit; } $error = false; if (f('import')) { fc('compta_import', [ 'upload' => 'file|required', 'type' => 'required|in:citizen,garradin', ], $form_errors); if (count($form_errors) === 0) { try { if (f('type') == 'citizen') { $import->fromCitizen($_FILES['upload']['tmp_name']); } elseif (f('type') == 'garradin') { $import->fromCSV($_FILES['upload']['tmp_name']); } else { throw new UserException('Import inconnu.'); } Utils::redirect('/admin/compta/import.php?ok'); } catch (UserException $e) { $form_errors[] = $e->getMessage(); } } } $tpl->assign('form_errors', $form_errors); $tpl->assign('ok', qg('ok')); $tpl->display('admin/compta/import.tpl'); |
Modified src/www/admin/compta/pie.php from [b09f4a0ec5] to [d1d8e8011c].
1 2 3 4 5 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; | | | < < < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; qv(['g' => 'required|in:recettes:depenses']); $graph = qg('g'); if (Static_Cache::expired('pie_' . $graph)) { $stats = new Compta\Stats; $categories = new Compta\Categories; $pie = new \KD2\SVGPie(400, 250); |
︙ | ︙ |
Modified src/www/admin/wiki/_fichiers.php from [621f8f7b9e] to [78531b30dd].
1 2 3 4 5 6 7 8 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; qv(['page' => 'required|numeric']); $page = $wiki->getById(qg('page')); | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; qv(['page' => 'required|numeric']); $page = $wiki->getById(qg('page')); $csrf_id = 'wiki_files_' . $page->id; if (!$page) { throw new UserException('Page introuvable.'); } // Vérification des hash avant upload if ($hash_check = f('uploadHelper_hashCheck')) { echo json_encode(Fichiers::checkHashList($hash_check)); exit; } elseif (f('delete')) { if (fc($csrf_id, [], $form_errors)) { try { $fichier = new Fichiers(f('delete')); if (!$fichier->checkAccess($user)) { throw new UserException('Vous n\'avez pas accès à ce fichier.'); |
︙ | ︙ | |||
48 49 50 51 52 53 54 | { $validate = [ 'uploadHelper_fileHash' => 'required', 'uploadHelper_fileName' => 'required', ]; } | | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | { $validate = [ 'uploadHelper_fileHash' => 'required', 'uploadHelper_fileName' => 'required', ]; } fc($csrf_id, $validate, $form_errors); if (f('uploadHelper_status') > 0) { $form_errors[] = 'Un seul fichier peut être envoyé en même temps.'; } if (count($form_errors) === 0) |
︙ | ︙ | |||
105 106 107 108 109 110 111 | } } $tpl->assign('fichiers', Fichiers::listLinkedFiles(Fichiers::LIEN_WIKI, $page->id, false)); $tpl->assign('images', Fichiers::listLinkedFiles(Fichiers::LIEN_WIKI, $page->id, true)); $tpl->assign('max_size', Utils::getMaxUploadSize()); | < | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | } } $tpl->assign('fichiers', Fichiers::listLinkedFiles(Fichiers::LIEN_WIKI, $page->id, false)); $tpl->assign('images', Fichiers::listLinkedFiles(Fichiers::LIEN_WIKI, $page->id, true)); $tpl->assign('max_size', Utils::getMaxUploadSize()); $tpl->assign('page', $page); $tpl->assign('sent', (bool)qg('sent')); $tpl->assign('custom_js', ['upload_helper.min.js', 'wiki_fichiers.js']); $tpl->assign('csrf_field_name', Utils::CSRF_field_name($csrf_id)); $tpl->assign('csrf_value', Utils::CSRF_create($csrf_id)); $tpl->display('admin/wiki/_fichiers.tpl'); |
Modified src/www/admin/wiki/creer.php from [842d664ef0] to [f0561e6ff0].
1 2 3 4 5 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; | < | 1 2 3 4 5 6 7 8 9 10 11 12 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; $parent = (int) Utils::get('parent') ?: 0; if (f('create')) { fc('wiki_create', [ 'titre' => 'required', 'parent'=> 'required|integer' |
︙ | ︙ | |||
23 24 25 26 27 28 29 | } catch (UserException $e) { $form_errors[] = $e->getMessage(); } } | < < | 22 23 24 25 26 27 28 29 | } catch (UserException $e) { $form_errors[] = $e->getMessage(); } } $tpl->display('admin/wiki/creer.tpl'); |
Modified src/www/admin/wiki/editer.php from [698ce7fbac] to [2d55183856].
1 2 3 4 5 6 7 8 9 10 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; $session->requireAccess('wiki', Membres::DROIT_ECRITURE); qv(['id' => 'required|numeric']); $page = $wiki->getById(qg('id')); | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <?php namespace Garradin; require_once __DIR__ . '/_inc.php'; $session->requireAccess('wiki', Membres::DROIT_ECRITURE); qv(['id' => 'required|numeric']); $page = $wiki->getById(qg('id')); $date = false; if (!$page) { throw new UserException('Page introuvable.'); } |
︙ | ︙ | |||
71 72 73 74 75 76 77 | } } } $parent = (int) f('parent') ?: (int) $page->parent; $tpl->assign('parent', $parent ? $wiki->getTitle($parent) : 0); | < | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | } } } $parent = (int) f('parent') ?: (int) $page->parent; $tpl->assign('parent', $parent ? $wiki->getTitle($parent) : 0); $tpl->assign('page', $page); $tpl->assign('wiki', $wiki); $tpl->assign('time', time()); $tpl->assign('date', $date ? strtotime($date) : $page->date_creation); $tpl->assign('custom_js', ['wiki_editor.js', 'wiki-encryption.js']); $tpl->display('admin/wiki/editer.tpl'); |
Modified src/www/admin/wiki/supprimer.php from [2f4ab439a2] to [f4dd6d4f24].
︙ | ︙ | |||
10 11 12 13 14 15 16 | $page = $wiki->getByID(qg('id')); if (!$page) { throw new UserException("Cette page n'existe pas."); } | < < < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | $page = $wiki->getByID(qg('id')); if (!$page) { throw new UserException("Cette page n'existe pas."); } if (f('delete')) { if (fc('delete_wiki_'.$page->id, [], $form_errors)) { if ($wiki->delete($page->id)) { Utils::redirect('/admin/wiki/'); } else { $form_errors[] = "D'autres pages utilisent cette page comme rubrique parente."; } } } $tpl->assign('page', $page); $tpl->display('admin/wiki/supprimer.tpl'); |