diff --git a/_immobilisations.html b/_immobilisations.html index 57ca24e..337fc0b 100644 --- a/_immobilisations.html +++ b/_immobilisations.html @@ -37,8 +37,16 @@ {{/foreach}} {{:assign condition=$condition|cat:"0)"}} {{:assign condition=$condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}} - {{:assign nb_immo=0}} + {{:assign filter_condition=" NOT ("}} + {{#foreach from=$module.config.filters item="filter"}} + {{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}} + {{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}} + {{/foreach}} + {{:assign filter_condition=$filter_condition|cat:"0)"}} + {{:assign condition=$condition|cat:" AND "|cat:$filter_condition}} + + {{:assign nb_immo=0}} {{#select trans.id as trans_id, trans.label as trans_label, diff --git a/_immobilisations_autres.html b/_immobilisations_autres.html index fb1970b..41a547f 100644 --- a/_immobilisations_autres.html +++ b/_immobilisations_autres.html @@ -29,7 +29,7 @@ {{* lister les immobilisations *}} - {{:include file="_get_config.html" keep="module.config.prefixes"}} + {{:include file="_get_config.html" keep="module.config"}} {{:assign condition="("}} {{#foreach from=$module.config.prefixes item="code"}} @@ -38,8 +38,16 @@ {{/foreach}} {{:assign condition=$condition|cat:"0)"}} {{:assign condition=$condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}} - {{:assign nb_immo=0}} + {{:assign filter_condition=" NOT ("}} + {{#foreach from=$module.config.filters item="filter"}} + {{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}} + {{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}} + {{/foreach}} + {{:assign filter_condition=$filter_condition|cat:"0)"}} + {{:assign condition=$condition|cat:" AND "|cat:$filter_condition}} + + {{:assign nb_immo=0}} {{#select trans.id as trans_id, trans.label as trans_label, diff --git a/_nav.html b/_nav.html index 1cc3608..9c56bfb 100644 --- a/_nav.html +++ b/_nav.html @@ -33,4 +33,12 @@
  • Sortie de bilan
  • {{/if}} + + {{if $current == "config"}} + + {{/if}} diff --git a/_unfinished.html b/_unfinished.html index 3565470..ab7e1e0 100644 --- a/_unfinished.html +++ b/_unfinished.html @@ -52,7 +52,7 @@ {{* lister les immobilisations en cours de constitution *}} - {{:include file="_get_config.html" keep="module.config.unfinished"}} + {{:include file="_get_config.html" keep="module.config"}} {{:assign accounts_condition="("}} {{#foreach from=$module.config.unfinished item="elem"}} @@ -61,8 +61,17 @@ {{/foreach}} {{:assign accounts_condition=$accounts_condition|cat:"0)"}} {{:assign condition=$accounts_condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}} - {{:assign nb_immo=0}} + {{:assign filter_condition=" NOT ("}} + {{#foreach from=$module.config.filters item="filter"}} + {{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}} + {{:assign filter_condition=$filter_condition|cat:" trans_label LIKE "|cat:$filter|cat:" OR "}} + {{/foreach}} + {{:assign filter_condition=$filter_condition|cat:"0)"}} + {{:assign condition=$condition|cat:" AND "|cat:$filter_condition}} + {{*:debug condition=$condition*}} + + {{:assign nb_immo=0}} {{#select trans.id as trans_id, trans.label as trans_label, diff --git a/amortization.html b/amortization.html index 1801ea8..9eb9874 100644 --- a/amortization.html +++ b/amortization.html @@ -79,6 +79,14 @@ {{/if}} {{* Autres amortissements non rattachés *}} +{{:include file="_get_config.html" keep="module.config"}} +{{:assign filter_condition=" NOT ("}} +{{#foreach from=$module.config.filters item="filter"}} + {{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}} + {{:assign filter_condition=$filter_condition|cat:" trans.label LIKE "|cat:$filter|cat:" OR "}} +{{/foreach}} +{{:assign filter_condition=$filter_condition|cat:"0)"}} + {{#select line.id as l_id, line.id_transaction as t_id, @@ -94,8 +102,9 @@ INNER JOIN acc_accounts AS account ON account.id = line.id_account INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction INNER JOIN acc_years AS y ON y.id = trans.id_year - WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) + WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition ORDER BY trans.date, trans.label; + !filter_condition=$filter_condition assign=autre_amort }} {{#select diff --git a/config.html b/config.html index 25b2dc3..7695c17 100644 --- a/config.html +++ b/config.html @@ -1,8 +1,5 @@ {{* -*- brindille -*- *}} -{{:admin_header title="Configuration" custom_css="./style.css" current="module_amortissement"}} -{{:include file="_nav.html" current="config"}} - {{if $_GET.ok == 1}}

    Configuration enregistrée.

    {{/if}} @@ -52,6 +49,9 @@ {{:form_errors}} {{/form}} +{{:admin_header title="Configuration" custom_css="./style.css" current="module_amortissement"}} +{{:include file="_nav.html" current="config"}} + {{* 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}} diff --git a/filters.html b/filters.html new file mode 100644 index 0000000..36228af --- /dev/null +++ b/filters.html @@ -0,0 +1,94 @@ +{{* -*- brindille -*- *}} + +{{:admin_header title="Configuration" custom_css="./style.css" current="module_amortissement"}} +{{:include file="_nav.html" current="config" subcurrent="filters"}} + +{{if $_GET.ok == 1}} +

    Configuration enregistrée.

    +{{/if}} + +{{* lecture config *}} +{{:include file="./_get_config.html" keep="module.config"}} + +{{#form on="save"}} + {{* enregistrer les filtres dans la config *}} + {{#foreach from=$_POST.filters item="filter"}} + {{if $filter != ""}} + {{:assign var="filters." value=$filter}} + {{/if}} + {{/foreach}} + {{:save key="config" filters=$filters}} + {{:redirect to="./filters.html"}} +{{/form}} + +
    +

    Liste de libellés à ignorer

    +

    + Les écritures dont le libellé contient un des textes ci-dessous seront ignorées +

    + + + + + + + + + + {{if $module.config.filters == null}} + + + + + {{else}} + {{#foreach from=$module.config.filters item="filter"}} + + + + + {{/foreach}} + {{/if}} + + + + + + + +
    Libellé
    + {{:input type="text" name="filters[]" required=false}} + + {{:button + label="Enlever" + title="Enlever une ligne" + shape="minus" + name="remove_line" + }} +
    + {{:input type="text" name="filters[]" default=$filter required=false}} + + {{:button + label="Enlever" + title="Enlever une ligne" + shape="minus" + name="remove_line" + }} +
    {{:button shape="plus" label="Ajouter" title="Ajouter un libellé"}}
    +

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

    +
    + + + diff --git a/other_amortizations.html b/other_amortizations.html index 84d6eaa..a3758d9 100644 --- a/other_amortizations.html +++ b/other_amortizations.html @@ -23,6 +23,14 @@ {{:error message="Immobilisation %s non trouvée"|args:$_GET.immo_id}} {{/select}} +{{:include file="_get_config.html" keep="module.config"}} +{{:assign filter_condition=" NOT ("}} +{{#foreach from=$module.config.filters item="filter"}} + {{:assign filter="%"|cat:$filter|cat:"%"|quote_sql}} + {{:assign filter_condition=$filter_condition|cat:" trans.label LIKE "|cat:$filter|cat:" OR "}} +{{/foreach}} +{{:assign filter_condition=$filter_condition|cat:"0)"}} + {{#select line.id as l_id, line.id_transaction as t_id, @@ -38,8 +46,9 @@ INNER JOIN acc_accounts AS account ON account.id = line.id_account INNER JOIN acc_transactions AS trans ON trans.id = line.id_transaction INNER JOIN acc_years AS y ON y.id = trans.id_year - WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) + WHERE account.code LIKE "28%" AND credit > 0 AND (NOT trans.status & 16) AND !filter_condition ORDER BY trans.date, trans.label; + !filter_condition=$filter_condition assign=autre_amort }} {{#select diff --git a/scripts.js b/scripts.js index 818d3ed..15369ff 100644 --- a/scripts.js +++ b/scripts.js @@ -149,7 +149,7 @@ function initLine(row) { var min = removeBtn.getAttribute('min'); if (count <= min) { - alert("Il n'est pas possible d'avoir moins de " + min + " compte(s)."); + alert("Il n'est pas possible d'avoir moins de " + min + " ligne(s)."); return false; } @@ -235,3 +235,18 @@ function computeTotal(id_total, id_url) { let new_href = url.href.replace(/trans=.*/, 'trans=' + Object.values(transactions)); url.href = new_href; } + +// dupliquer la dernière ligne d'une table +function copyLine(button) { + button.onclick = () => { + let lines = button.closest("table").querySelectorAll('tbody tr'); + let line = lines[lines.length - 1]; + let newNode = line.cloneNode(true); + let libelle = newNode.querySelector('input'); + libelle.value = ''; + + // ajouter la nouvelle ligne + line.parentNode.appendChild(newNode); + initLine(newNode); + }; +}