166 lines
5.4 KiB
HTML
166 lines
5.4 KiB
HTML
{{* -*- brindille -*- *}}
|
|
|
|
{{*
|
|
Lister les écritures d'amortissement indépendantes
|
|
et proposer des les attacher à l'immo sélectionnée
|
|
@param immo_line_id = id de la ligne d'immo
|
|
@param immo_doc_id id du doc d'immo associé
|
|
*}}
|
|
|
|
{{* récupérer les infos de l'immobilisation *}}
|
|
{{#select
|
|
trans.label as label,
|
|
line.label as line_label
|
|
FROM acc_transactions_lines AS line
|
|
INNER JOIN acc_transactions AS trans ON line.id_transaction = trans.id
|
|
WHERE line.id = :line_id;
|
|
:line_id = $_GET.immo_line_id|intval
|
|
assign=ligne_immo
|
|
}}
|
|
{{else}}
|
|
{{:error message="Immobilisation non trouvée"}}
|
|
{{/select}}
|
|
|
|
{{#load id=$_GET.immo_doc_id|intval}}
|
|
{{:assign label_immo=$label|or:$ligne_immo.label}}
|
|
{{else}}
|
|
{{:error message="Informations de l'immobilisation %s (%s) non trouvées"|args:$_GET.immo_line_id:$ligne_immo.label}}
|
|
{{/load}}
|
|
{{if $ligne_immo.line_label != null && $ligne_immo.line_label != $label_immo}}
|
|
{{:assign label_immo=$label_immo|cat:" — "|cat:$ligne_immo.line_label}}
|
|
{{/if}}
|
|
|
|
{{:include file="_get_config.html" keep="module.config"}}
|
|
{{if $_POST.unhide == null}}
|
|
{{: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)"}}
|
|
{{else}}
|
|
{{:assign filter_condition="1"}}
|
|
{{/if}}
|
|
|
|
{{* lister les écritures d'amortissement *}}
|
|
{{#select
|
|
line.id as amort_line_id,
|
|
line.id_transaction as amort_trans_id,
|
|
line.credit as amort_amount,
|
|
line.label as line_label,
|
|
trans.date as trans_date,
|
|
trans.label as trans_label,
|
|
trans.id_year as amort_year,
|
|
account.id as account_id,
|
|
account.code as account_code,
|
|
account.label as account_label
|
|
FROM acc_transactions_lines AS line
|
|
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) AND !filter_condition
|
|
ORDER BY trans.date, trans.label;
|
|
!filter_condition=$filter_condition
|
|
assign="amort"
|
|
}}
|
|
{{* voir s'il existe des lignes d'immo liées à cette ligne d'amortissement *}}
|
|
{{:assign amort_amount=0}}
|
|
{{:assign keep_amort=true}}
|
|
{{#load type="amort_link"
|
|
where="$$.amort_line_id = :amort_line_id"
|
|
:amort_line_id=$amort.amort_line_id|intval
|
|
assign="amort_link"
|
|
}}
|
|
{{if $amort_link.amount == null || $amort_link.amount == 0}}
|
|
{{:assign amort_amount=$amort.amort_amount}}
|
|
{{:assign keep_amort=false}}
|
|
{{else}}
|
|
{{:assign amort_amount="%d+%d"|math:$amort_amount:$amort_link.amount}}
|
|
{{/if}}
|
|
{{else}}
|
|
{{* pas de ligne d'immo liée à cette ligne d'amort => garder cette ligne d'amortissement *}}
|
|
{{/load}}
|
|
{{if $keep_amort && $amort_amount < $amort.amort_amount}}
|
|
{{:assign var="free_amort_lines." value=$amort}}
|
|
{{/if}}
|
|
{{/select}}
|
|
|
|
{{:admin_header title="Amortissements non rattachés" custom_css="./style.css" current="module_amortization"}}
|
|
|
|
{{* barre de navigation *}}
|
|
{{if ! $dialog}}
|
|
{{:include
|
|
file="_nav.html"
|
|
current="index"
|
|
subcurrent="other"
|
|
subsubcurrent="amortization"
|
|
type_immo="other"
|
|
autres_amort=$free_amort_lines
|
|
}}
|
|
{{/if}}
|
|
|
|
{{if $_POST.unhide != null}}
|
|
{{:assign checked="checked"}}
|
|
{{/if}}
|
|
|
|
<form method="post" action="">
|
|
<fieldset>
|
|
{{:input type="checkbox" value=1 name="unhide" checked="%s"|args:$checked label="Afficher les écritures ignorées"}}
|
|
</fieldset>
|
|
</form>
|
|
|
|
{{if $free_amort_lines != null}}
|
|
<section class="amortissement">
|
|
<h3 class="ruler">Immobilisation « {{$label_immo}} »</h3>
|
|
<table class="list">
|
|
<thead>
|
|
<tr>
|
|
<th>N°</th>
|
|
<th>Date</th>
|
|
<th class="nombre">Montant</th>
|
|
<th>Libellé</th>
|
|
<th>N° compte</th>
|
|
<th>Compte</th>
|
|
<th class="actions"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{#foreach from=$free_amort_lines item="line"}}
|
|
{{:assign trans_url="%s/acc/transactions/details.php?id=%s"|args:$admin_url:$line.amort_trans_id}}
|
|
{{:assign compte_url="%s/acc/accounts/journal.php?id=%s&year=%s"|args:$admin_url:$line.account_id:$line.amort_year}}
|
|
<tr>
|
|
<td class="num"><a href="{{$trans_url}}">#{{$line.amort_trans_id}}</a></td>
|
|
<td>{{$line.trans_date|date_short}}</td>
|
|
<td class="money">{{"%f"|math:$line.amort_amount|money_html:false|raw}}</td>
|
|
<td>{{$line.trans_label}}
|
|
{{if $line.line_label != null && $line.line_label != $line.trans_label}} - {{$line.line_label}}{{/if}}
|
|
</td>
|
|
<td><a href="{{$compte_url}}">{{$line.account_code}}</a></td>
|
|
<td>{{$line.account_label}}</td>
|
|
<td>
|
|
{{if $_GET.init == null}}
|
|
{{:linkbutton label="Attacher" href="attach_amort.html?amort_line_id=%d&immo_line_id=%d&immo_doc_id=%s"|args:$line.amort_line_id:$_GET.immo_line_id:$_GET.immo_doc_id shape="plus"}}
|
|
{{elseif $_GET.init}}
|
|
{{:linkbutton label="Attacher" href="attach_amort_init.html?amort_line_id=%d&immo_line_id=%d&immo_doc_id=%s"|args:$line.amort_line_id:$_GET.immo_line_id:$_GET.immo_doc_id shape="plus"}}
|
|
{{/if}}
|
|
</td>
|
|
</tr>
|
|
{{/foreach}}
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
{{/if}}
|
|
{{:form_errors}}
|
|
{{:admin_footer}}
|
|
|
|
<script type="text/javascript">
|
|
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>
|