From 4b504f6eb99f7a099afd1fcc6d44e6dbd39fde9c Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Mon, 3 Nov 2025 13:44:41 +0100 Subject: [PATCH] Configuration : traitement cas particuliers exercices --- add_asset.html | 2 + config.html | 159 ++++++++++++++++++++++++++----------------------- 2 files changed, 87 insertions(+), 74 deletions(-) diff --git a/add_asset.html b/add_asset.html index 31ec3dc..99da03d 100644 --- a/add_asset.html +++ b/add_asset.html @@ -13,6 +13,8 @@ {{if $ts_debut <= $now && $now <= $ts_fin}} {{:assign selected_year=$id}} {{/if}} +{{else}} + {{:error message="Aucun exercice ouvert"}} {{/years}} {{* Traiter l'envoi du formulaire *}} diff --git a/config.html b/config.html index 6506ce9..8170ac1 100644 --- a/config.html +++ b/config.html @@ -3,6 +3,7 @@ {{:admin_header title="Configuration" custom_css="./style.css" current="module_amortissement"}} {{* barre de navigation *}} {{:include file="_nav.html" current="config"}} + {{if $_GET.ok == 1}}

Configuration enregistrée.

{{/if}} @@ -39,97 +40,107 @@ {{:redirect to="./config.html?ok=%d"|args:$ok}} {{/form}} -{{* récupérer l'exercice courant *}} +{{* récupérer l'exercice courant ou sinon le plus récent *}} {{:assign var="selected_year" from="logged_user.preferences.accounting_year}} {{if $selected_year == null}} {{* sélectionner l'exercice le plus probable *}} - {{#years closed=false order="start_date"}} - {{:assign var="open_years.%d"|args:$id value=$label}} + {{#years}} {{if $start_date|strtotime <= $now && $end_date|strtotime >= $now}} {{:assign selected_year=$id}} {{:break}} {{/if}} + {{:assign last_year=$id}} {{/years}} {{/if}} -{{* libellés des comptes d'immobilisation *}} -{{:assign condition="("}} -{{#foreach from=$config.prefixes item="code"}} - {{:assign code=$code|quote_sql}} - {{:assign condition=$condition|cat:" account.code = "|cat:$code|cat:" OR "}} -{{/foreach}} -{{:assign condition=$condition|cat:"0)"}} -{{:assign condition=$condition|cat:" AND year.id = %s"|args:$selected_year}} +{{if $selected_year == null}} + {{if $last_year == null}} +

Aucun exercice

+ {{else}} + {{:assign selected_year=$last_year}} + {{/if}} +{{/if}} -{{#select - account.id as account_id, - account.code, - account.id_chart, - account.label, - year.label as year_label, - chart.label as chart_label - FROM acc_accounts AS account - INNER JOIN acc_charts AS chart ON chart.id = account.id_chart - INNER JOIN acc_years AS year ON year.id_chart = chart.id - WHERE !condition - ; - !condition=$condition - }} - {{:assign var="accounts.%s"|args:$code label=$label id=$account_id}} -{{/select}} +{{if $selected_year != null}} -

Comptes d'immobilisation

-
+ {{* libellés des comptes d'immobilisation *}} + {{:assign condition="("}} + {{#foreach from=$config.prefixes item="code"}} + {{:assign code=$code|quote_sql}} + {{:assign condition=$condition|cat:" account.code = "|cat:$code|cat:" OR "}} + {{/foreach}} + {{:assign condition=$condition|cat:"0)"}} + {{:assign condition=$condition|cat:" AND year.id = %s"|args:$selected_year}} -

- Les immobilisations sont cherchées dans les comptes sélectionnées et leurs sous-comptes. -

+ {{#select + account.id as account_id, + account.code, + account.id_chart, + account.label, + year.label as year_label, + chart.label as chart_label + FROM acc_accounts AS account + INNER JOIN acc_charts AS chart ON chart.id = account.id_chart + INNER JOIN acc_years AS year ON year.id_chart = chart.id + WHERE !condition + ; + !condition=$condition + }} + {{:assign var="accounts.%s"|args:$code label=$label id=$account_id}} + {{/select}} - - - - - - - - - {{#foreach from=$accounts key=code item=elem}} +

Comptes d'immobilisation

+ + +

+ Les immobilisations sont cherchées dans les comptes sélectionnées et leurs sous-comptes. +

+ +
Compte
+ - - + + - {{/foreach}} - - - - - - - -
- {{:assign var="immo_account.%s.%s"|args:$code:$code value="%s — "|args:$code|cat:$elem.label}} - {{:assign var="current_account" from="immo_account.%s"|args:$code}} - {{*:debug immo_account=$immo_account current_account=$current_account*}} - {{:input - type="list" - name="immo_accounts[]" - target="!acc/charts/accounts/selector.php?codes=%s&id_year=%d"|args:$code::$selected_year - default=$current_account - }} - - {{:button - label="Enlever" - title="Enlever une ligne" - shape="minus" - min="1" - name="remove_line" - }} - Compte
{{:button shape="plus" label="Ajouter" title="Ajouter un compte"}}
+ + + {{#foreach from=$accounts key=code item=elem}} + + + {{:assign var="immo_account.%s.%s"|args:$code:$code value="%s — "|args:$code|cat:$elem.label}} + {{:assign var="current_account" from="immo_account.%s"|args:$code}} + {{:input + type="list" + name="immo_accounts[]" + target="!acc/charts/accounts/selector.php?codes=%s&id_year=%d"|args:$code::$selected_year + default=$current_account + }} + + + {{:button + label="Enlever" + title="Enlever une ligne" + shape="minus" + min="1" + name="remove_line" + }} + + + {{/foreach}} + + + + + {{:button shape="plus" label="Ajouter" title="Ajouter un compte"}} + + + -

- {{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}} -

-
+

+ {{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}} +

+ +{{/if}}