Overview
Comment: | Implement: add / copy chart |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
e7d84b2f9e3320f1e7eb89aa13630269 |
User & Date: | bohwaz on 2020-10-14 19:13:31 |
Other Links: | branch diff | manifest | tags |
Context
2020-10-14
| ||
19:40 | Implement: chart edition, restrict changes of archived charts check-in: 77f341a314 user: bohwaz tags: dev | |
19:13 | Implement: add / copy chart check-in: e7d84b2f9e user: bohwaz tags: dev | |
18:54 | Implement: account delete, limiting account changes if it's used in closed years check-in: 38f005c1b7 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Accounting/Accounts.php from [da4f7ed4c6] to [ce5c62a562].
︙ | ︙ | |||
114 115 116 117 118 119 120 | $code = $code . $letter; } unset($code); return $codes; } | | > > > > > > > | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | $code = $code . $letter; } unset($code); return $codes; } public function copyFrom(int $id) { $db = DB::getInstance(); return $db->exec(sprintf('INSERT INTO %s (id_chart, code, label, description, position, type, user) SELECT %d, code, label, description, position, type, user FROM %1$s WHERE id_chart = %d;', Account::TABLE, $this->chart_id, $id)); } } |
Modified src/include/lib/Garradin/Entities/Accounting/Chart.php from [fadff02d39] to [0953241c8f].
1 2 3 4 5 6 7 8 9 | <?php namespace Garradin\Entities\Accounting; use Garradin\Entity; use Garradin\Accounting\Accounts; class Chart extends Entity { | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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\Entities\Accounting; use Garradin\Entity; use Garradin\Utils; use Garradin\Accounting\Accounts; class Chart extends Entity { const TABLE = 'acc_charts'; protected $id; protected $label; protected $country; protected $code; protected $archived = 0; protected $_types = [ 'id' => 'int', 'label' => 'string', 'country' => 'string', 'code' => '?string', 'archived' => 'int', ]; protected $_form_rules = [ 'label' => 'required|string|max:200', 'country' => 'required|string|size:2', 'code' => 'string', ]; public function selfCheck(): void { parent::selfCheck(); $this->assert(Utils::getCountryName($this->country), 'Le code pays doit être un code ISO valide'); $this->assert($this->archived === 0 || $this->archived === 1); } public function accounts() { return new Accounts($this->id()); } } |
Modified src/templates/acc/charts/index.tpl from [7b4022390e] to [8e19ab31c8].
︙ | ︙ | |||
26 27 28 29 30 31 32 | <td></td> </thead> <tbody> {foreach from=$list item="item"} <tr> <td>{$item.country|get_country_name}</td> <th><a href="{$admin_url}acc/charts/accounts/?id={$item.id}">{$item.label}</a> <em>{if $item.code}(officiel){else}(copie){/if}</em></th> | | | < < < | > | | 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 | <td></td> </thead> <tbody> {foreach from=$list item="item"} <tr> <td>{$item.country|get_country_name}</td> <th><a href="{$admin_url}acc/charts/accounts/?id={$item.id}">{$item.label}</a> <em>{if $item.code}(officiel){else}(copie){/if}</em></th> <td> {linkbutton shape="star" label="Comptes favoris" href="acc/charts/accounts/?id=%d"|args:$item.id} {linkbutton shape="menu" label="Tous les comptes" href="acc/charts/accounts/all.php?id=%d"|args:$item.id} {if $session->canAccess('compta', Membres::DROIT_ADMIN)} {linkbutton shape="edit" label="Modifier" href="acc/charts/edit.php?id=%d"|args:$item.id} {linkbutton shape="export" label="Exporter en CSV" href="acc/charts/export.php?id=%d"|args:$item.id} {if empty($item.code)} {linkbutton shape="delete" label="Supprimer" href="acc/charts/delete.php?id=%d"|args:$item.id} {/if} {/if} </td> </tr> {/foreach} </tbody> </table> {/if} {if $session->canAccess('compta', Membres::DROIT_ADMIN)} <form method="post" action="{$self_url_no_qs}"> <fieldset> <legend>Créer un nouveau plan comptable</legend> <dl> {input type="select_groups" name="copy" options=$charts_groupped label="Recopier depuis" required=1 default=$from} {input type="text" name="label" label="Libellé" required=1} {input type="select" name="country" label="Pays" required=1 options=$country_list default=$config.pays} </dl> <p class="submit"> {csrf_field key="acc_charts_new"} <input type="submit" name="new" value="Créer →" /> </p> </fieldset> </form> {/if} {include file="admin/_foot.tpl"} |
Modified src/templates/acc/years/new.tpl from [16b237797f] to [cb76d08b57].
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 | {include file="admin/_head.tpl" title="Commencer un exercice" current="acc/years" js=1} {form_errors} <form method="post" action="{$self_url}"> <fieldset> <legend>Commencer un nouvel exercice</legend> <dl> {input type="select_groups" options=$charts name="id_chart" label="Plan comptable" required=true} <dd class="help">{linkbutton shape="settings" label="Gestion des plans comptables" href="acc/charts/"}</dd> {input type="text" name="label" label="Libellé" required=true} {input type="date" label="Début de l'exercice" name="start_date" required=true default=$start_date} {input type="date" label="Fin de l'exercice" name="end_date" required=true default=$end_date} </dl> </fieldset> <p class="submit"> {csrf_field key="acc_years_new"} <input type="submit" name="new" value="Créer ce nouvel exercice →" /> </p> </form> {include file="admin/_foot.tpl"} | > > > > > | 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 | {include file="admin/_head.tpl" title="Commencer un exercice" current="acc/years" js=1} {form_errors} <form method="post" action="{$self_url}"> <fieldset> <legend>Commencer un nouvel exercice</legend> <dl> {input type="select_groups" options=$charts name="id_chart" label="Plan comptable" required=true} <dd class="help">Attention, il ne sera pas possible de modifier ou supprimer un compte si celui-ci est utilisé dans un exercice clôturé.<br /> Si vous souhaitez modifier le plan comptable pour ce nouvel exercice, il est recommandé de créer un nouveau plan comptable, recopié à partir de l'ancien plan comptable. Ainsi tous les comptes seront modifiables et supprimables.</dd> <dd class="help">{linkbutton shape="settings" label="Gestion des plans comptables" href="acc/charts/"}</dd> {input type="text" name="label" label="Libellé" required=true} {input type="date" label="Début de l'exercice" name="start_date" required=true default=$start_date} {input type="date" label="Fin de l'exercice" name="end_date" required=true default=$end_date} </dl> </fieldset> <p class="help"> Note : <p class="submit"> {csrf_field key="acc_years_new"} <input type="submit" name="new" value="Créer ce nouvel exercice →" /> </p> </form> {include file="admin/_foot.tpl"} |
Modified src/www/admin/acc/charts/index.php from [7c503aac7a] to [78edbd5354].
1 2 3 4 5 6 7 8 9 10 11 | <?php namespace Garradin; use Garradin\Accounting\Charts; require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ACCES); if ($session->canAccess('compta', Membres::DROIT_ADMIN)) { $tpl->assign('from', (int)qg('from')); | > > > > > > > > > > > > > > > > > > > > < | 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 | <?php namespace Garradin; use Garradin\Entities\Accounting\Chart; use Garradin\Accounting\Charts; require_once __DIR__ . '/../_inc.php'; $session->requireAccess('compta', Membres::DROIT_ACCES); $tpl->assign('list', Charts::list()); if ($session->canAccess('compta', Membres::DROIT_ADMIN)) { if (f('new') && $form->check('acc_charts_new')) { try { $chart = new Chart; $chart->importForm(); $chart->save(); if (f('copy')) { $chart->accounts()->copyFrom((int) f('copy')); } Utils::redirect(Utils::getSelfURI(false)); } catch (UserException $e) { $form->addError($e->getMessage()); } } $tpl->assign('from', (int)qg('from')); $tpl->assign('charts_groupped', Charts::listByCountry()); $tpl->assign('country_list', Utils::getCountryList()); } $tpl->display('acc/charts/index.tpl'); |