203 lines
6.2 KiB
HTML
203 lines
6.2 KiB
HTML
{{* -*- brindille -*- *}}
|
|
|
|
{{* Liste des immobilisations en cours de constitution *}}
|
|
|
|
<section class="immobilisation">
|
|
|
|
<p class="help">
|
|
Cette page liste les immobilisations en cours de constitution, donc non amortissables
|
|
</p>
|
|
|
|
<form method="post" action="">
|
|
<fieldset class="shortFormLeft">
|
|
<legend>Transférer une ou plusieurs lignes vers une immobilisation amortissable</legend>
|
|
<p class="help">
|
|
Cocher les lignes concernées ; les montants seront additionnés par numéro de compte
|
|
</p>
|
|
<div class="shortFormRight informations" id="total_amount">
|
|
<legend>Montants sélectionnés</legend>
|
|
<ul>
|
|
<li> </li>
|
|
</ul>
|
|
</div>
|
|
<div>
|
|
<p class="submit">
|
|
{{:linkbutton
|
|
label="Transférer"
|
|
href="transfer.html?trans="
|
|
shape="right"
|
|
id="transfer"
|
|
}}
|
|
</p>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset>
|
|
{{:input type="checkbox" value=1 name="unhide" label="Afficher les écritures marquées ignorées" }}
|
|
</fieldset>
|
|
</form>
|
|
|
|
<table class="list">
|
|
<thead>
|
|
<tr>
|
|
<th class="check">{{*:input type="checkbox" name="all" value="all"*}}</th>
|
|
<th class="num">N°</th>
|
|
<th>Date</th>
|
|
<th>Libellé</th>
|
|
<th class="nombre">Montant</th>
|
|
<th>N° compte</th>
|
|
<th>Compte</th>
|
|
<th class="actions"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
{{* lister les immobilisations en cours de constitution *}}
|
|
{{:include file="_get_config.html" keep="module.config"}}
|
|
|
|
{{:assign accounts_condition="("}}
|
|
{{#foreach from=$module.config.unfinished item="elem"}}
|
|
{{:assign code=$elem.code|cat:"%"|quote_sql}}
|
|
{{:assign accounts_condition=$accounts_condition|cat:" account.code LIKE "|cat:$code|cat:" OR "}}
|
|
{{/foreach}}
|
|
{{:assign accounts_condition=$accounts_condition|cat:"0)"}}
|
|
{{:assign condition=$accounts_condition|cat:" AND debit > 0 AND NOT (trans.status & 16)"}}
|
|
|
|
{{: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}}
|
|
{{:assign total_immo = 0}}
|
|
{{#select
|
|
trans.id as trans_id,
|
|
trans.label as trans_label,
|
|
trans.date as trans_date,
|
|
line.id as immo_id,
|
|
account.id as account_id,
|
|
account.code as account_code,
|
|
account.label as account_label,
|
|
sum(line.debit) AS debit,
|
|
trans.id_year as trans_id_year
|
|
FROM acc_transactions AS trans
|
|
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
|
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
|
INNER JOIN acc_years AS years ON trans.id_year = years.id
|
|
WHERE !condition
|
|
GROUP BY trans.id
|
|
ORDER BY trans.date DESC;
|
|
!condition=$condition
|
|
}}
|
|
{{* voir si l'écriture a été marquée ignorée *}}
|
|
{{:assign ignore=false}}
|
|
{{#load type="immo" assign="info_immo" where="$$.line = :line_id AND $$.status = 'ignored'" :line_id=$immo_id|intval}}
|
|
{{:assign ignore=true}}
|
|
{{/load}}
|
|
{{if $ignore && $_POST.unhide == null}}
|
|
{{:continue}}
|
|
{{/if}}
|
|
|
|
{{* voir s'il existe une écriture qui solde l'immobilisation *}}
|
|
{{#select
|
|
count(*) AS count
|
|
FROM acc_transactions AS trans
|
|
INNER JOIN acc_transactions_lines AS line ON line.id_transaction = trans.id
|
|
INNER JOIN acc_accounts AS account ON line.id_account = account.id
|
|
WHERE line.credit = :amount AND code = :account_code
|
|
;
|
|
:amount = $debit
|
|
:account_code = $account_code
|
|
}}
|
|
{{:assign count=$count}}
|
|
{{/select}}
|
|
|
|
{{* S'il y a plus d'une écriture de même montant on ne peut pas décider *}}
|
|
{{if $count == 1}}
|
|
{{:continue}}
|
|
{{/if}}
|
|
|
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$trans_id}}
|
|
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$account_id:$trans_id_year}}
|
|
{{:assign nb_immo="%d+1"|math:$nb_immo}}
|
|
{{:assign total_immo="%d+%d"|math:$total_immo:$debit}}
|
|
{{:assign var="montant" from="sommes_immo.%s"|args:$account_code}}
|
|
{{:assign var="sommes_immo.%s"|args:$account_code value="%d+%d"|math:$montant:$debit}}
|
|
|
|
<tr>
|
|
<td class="check">{{:input type="checkbox" name="selected[]" value=$trans_id}}</td>
|
|
<td class="num"><a href={{$trans_url}}>#{{$trans_id}}</a></td>
|
|
<td>{{$trans_date|date_short}}</td>
|
|
<td>{{$trans_label}}</td>
|
|
<td class="money">{{"%f"|math:$debit|money:false}}</td>
|
|
<td class="account_code"><a href={{$compte_url}}>{{$account_code}}</a></td>
|
|
<td>{{$account_label}}</td>
|
|
<td class="actions">
|
|
{{:linkbutton
|
|
label="Modifier"
|
|
href="ignore.html?immo_id=%s"|args:$immo_id
|
|
shape="edit"
|
|
target="_dialog"
|
|
}}
|
|
</td>
|
|
</tr>
|
|
{{/select}}
|
|
</tbody>
|
|
<tfoot>
|
|
{{if $total_immo != 0}}
|
|
{{#foreach from=$sommes_immo|ksort key="code" item="value"}}
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Total du compte {{$code}}</td>
|
|
<td class="money">{{$value|money}}</td>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="actions"></td>
|
|
</tr>
|
|
{{/foreach}}
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>Total des immobilisations</td>
|
|
<td class="money"><span class="strong">{{$total_immo|money}}</span></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="actions"></td>
|
|
</tr>
|
|
{{/if}}
|
|
</tfoot>
|
|
</table>
|
|
{{if $nb_immo == 0}}
|
|
<p class="block alert">Aucune immobilisation</p>
|
|
{{/if}}
|
|
</section>
|
|
|
|
<script type="text/javascript" src="scripts.js"></script>
|
|
<script type="text/javascript" async="async">
|
|
|
|
let lines = document.querySelectorAll('.list tbody tr');
|
|
for (const line of lines) {
|
|
let button = line.querySelector('input[type=checkbox]');
|
|
|
|
button.onchange = () => {
|
|
computeTotal('total_amount', 'transfer');
|
|
};
|
|
|
|
}
|
|
|
|
function changeVisibility(evt, idcheck = 'f_unhide_1') {
|
|
this.form.dispatchEvent(new Event('submit'));
|
|
this.form.submit();
|
|
}
|
|
|
|
(function () {
|
|
document.getElementById('f_unhide_1').onclick = changeVisibility;
|
|
})();
|
|
|
|
</script>
|