Simplification détails membre
This commit is contained in:
parent
1d5d54e59e
commit
b6743ad3b3
1 changed files with 63 additions and 113 deletions
|
|
@ -35,117 +35,86 @@
|
||||||
{{if $output_types|has_key:"temporaire" && $input_types|has_key:"retour"}}
|
{{if $output_types|has_key:"temporaire" && $input_types|has_key:"retour"}}
|
||||||
|
|
||||||
{{*
|
{{*
|
||||||
Calculer les quantités de matériel en prêt, retourné et restant
|
Calculer les quantités de matériel en prêt
|
||||||
*}}
|
*}}
|
||||||
{{:assign premier=true}}
|
{{:assign premier=true}}
|
||||||
{{#select
|
{{#select
|
||||||
mvt.key AS mvt_key,
|
json_extract(mvt.document, '$.direction') AS direction,
|
||||||
json_extract(mvt.document, '$.date') AS out_date,
|
json_extract(mvt.document, '$.date') AS date,
|
||||||
|
eqpmt.key as eqpmt_key,
|
||||||
json_extract(eqpmt.document, '$.name') AS eqpmt_name,
|
json_extract(eqpmt.document, '$.name') AS eqpmt_name,
|
||||||
json_extract(mvt.document, '$.amount') AS qte,
|
json_extract(mvt.document, '$.amount') AS qte,
|
||||||
IFNULL(SUM(json_extract(retour.document, '$.amount')), 0) AS return_amount,
|
|
||||||
json_extract(mvt.document, '$.operation') AS operation
|
json_extract(mvt.document, '$.operation') AS operation
|
||||||
FROM module_data_equipment AS mvt
|
FROM {!$module.table} AS mvt
|
||||||
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
||||||
LEFT JOIN module_data_equipment AS links ON mvt.key = json_extract(links.document, '$.temp_key')
|
INNER JOIN {!$module.table} AS eqpmt ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
||||||
LEFT JOIN module_data_equipment AS retour ON retour.key = json_extract(links.document, '$.return')
|
|
||||||
INNER JOIN module_data_equipment AS eqpmt ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
|
||||||
WHERE
|
WHERE
|
||||||
users.id = :user
|
users.id = :user
|
||||||
AND
|
AND
|
||||||
json_extract(mvt.document, '$.type') = 'movement'
|
json_extract(mvt.document, '$.type') = 'movement'
|
||||||
AND
|
AND
|
||||||
json_extract(mvt.document, '$.operation') IN !output_types
|
(json_extract(mvt.document, '$.operation') IN !output_types
|
||||||
GROUP BY mvt.key
|
OR
|
||||||
ORDER BY eqpmt_name, json_extract(mvt.document, '$.date')
|
json_extract(mvt.document, '$.operation') IN !input_types)
|
||||||
|
ORDER BY eqpmt_name, date
|
||||||
;
|
;
|
||||||
:user = $user.id
|
:user = $user.id
|
||||||
!output_types=$output_types.temporaire
|
!output_types=$output_types.temporaire
|
||||||
|
!input_types=$input_types.retour
|
||||||
}}
|
}}
|
||||||
{{:assign reste="%d-%d"|math:$qte:$return_amount}}
|
|
||||||
{{if $reste > 0}}
|
|
||||||
{{:assign class=""}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign class="r0"}}
|
|
||||||
{{/if}}
|
|
||||||
{{:assign var="op_label" from="config.output_nature.%s.label"|args:$operation}}
|
|
||||||
{{:assign total=$qte}}
|
|
||||||
{{if $premier}}
|
{{if $premier}}
|
||||||
{{:assign premier=false}}
|
{{:assign premier=false}}
|
||||||
|
{{:assign total=0}}
|
||||||
|
{{:assign old_eqpmt_key=$eqpmt_key}}
|
||||||
|
{{:assign var="ligne.date" value=$date}}
|
||||||
|
{{:assign var="ligne.materiel" value=$eqpmt_name}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $eqpmt_key != $old_eqpmt_key}}
|
||||||
|
{{if $total > 0}}
|
||||||
|
{{:assign var="ligne.qte" value=$total}}
|
||||||
|
{{:assign var="lignes." value=$ligne}}
|
||||||
|
{{/if}}
|
||||||
|
{{:assign total=0}}
|
||||||
|
{{:assign old_eqpmt_key=$eqpmt_key}}
|
||||||
|
{{:assign var="ligne.date" value=$date}}
|
||||||
|
{{:assign var="ligne.materiel" value=$eqpmt_name}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $direction == "output"}}
|
||||||
|
{{:assign total="%d+%d"|math:$total:$qte}}
|
||||||
|
{{else}}
|
||||||
|
{{:assign total="%d-%d"|math:$total:$qte}}
|
||||||
|
{{/if}}
|
||||||
|
{{/select}}
|
||||||
|
|
||||||
|
{{if $total > 0}}
|
||||||
|
{{:assign var="ligne.qte" value=$total}}
|
||||||
|
{{:assign var="lignes." value=$ligne}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{if $lignes|count > 0}}
|
||||||
<h3 class="ruler">Matériels attribués temporairement</h3>
|
<h3 class="ruler">Matériels attribués temporairement</h3>
|
||||||
<form method="post" action="">
|
|
||||||
<fieldset class="shortFormLeft">
|
|
||||||
{{:input type="checkbox" value=1 name="no_return" label="Masquer les matériels rendus en totalité"}}
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
<table class="list" id="liste_temporaires">
|
<table class="list" id="liste_temporaires">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th>Matériel</th>
|
<th>Matériel</th>
|
||||||
<th>Opération</th>
|
|
||||||
<th>Quantité</th>
|
<th>Quantité</th>
|
||||||
<th>Total</th>
|
|
||||||
<th class="actions"></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{/if}}
|
{{#foreach from=$lignes}}
|
||||||
{{* Sortie temporaire *}}
|
<tr>
|
||||||
<tr class="{{$class}}">
|
<td>{{$date|date_short}}</td>
|
||||||
<td>{{$out_date|date_short}}</td>
|
<td>{{$materiel}}</td>
|
||||||
<td>{{$eqpmt_name}}</td>
|
|
||||||
<td>{{$op_label}}</td>
|
|
||||||
<td>{{$qte}}</td>
|
<td>{{$qte}}</td>
|
||||||
<td>{{$total}}</td>
|
|
||||||
<td class="actions">
|
|
||||||
{{if $reste > 0}}
|
|
||||||
{{if $reste > 1}}
|
|
||||||
{{:assign msg_reste="Reste %s unités"|args:$reste}}
|
|
||||||
{{else}}
|
|
||||||
{{:assign msg_reste="Reste %s unité"|args:$reste}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{:linkbutton
|
|
||||||
label="Retour"
|
|
||||||
href="%smovements/output_return.html?key=%s&prop=0&user=%s"|args:$module.url:$mvt_key:$user.id
|
|
||||||
shape="history"
|
|
||||||
title=$msg_reste
|
|
||||||
target="_dialog"}}
|
|
||||||
{{/if}}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
{{/foreach}}
|
||||||
{{* chercher les retours *}}
|
|
||||||
{{#select
|
|
||||||
json_extract(links.document, '$.return') AS return_key,
|
|
||||||
json_extract(return_mvt.document, '$.amount') AS return_amount,
|
|
||||||
json_extract(return_mvt.document, '$.date') AS return_date,
|
|
||||||
json_extract(return_mvt.document, '$.operation') AS operation
|
|
||||||
FROM module_data_equipment AS links
|
|
||||||
INNER JOIN module_data_equipment AS return_mvt ON return_mvt.key = return_key
|
|
||||||
WHERE json_extract(links.document, '$.temp_key') = :mvt_key
|
|
||||||
ORDER BY return_date
|
|
||||||
;
|
|
||||||
:mvt_key=$mvt_key
|
|
||||||
}}
|
|
||||||
{{:assign var="op_label" from="config.input_nature.%s.label"|args:$operation}}
|
|
||||||
{{:assign total="%d-%d"|math:$total:$return_amount}}
|
|
||||||
|
|
||||||
{{* retour de sortie temporaire *}}
|
|
||||||
<tr class="{{$class}}">
|
|
||||||
<td>{{$return_date|date_short}}</td>
|
|
||||||
<td>{{$eqpmt_name}}</td>
|
|
||||||
<td>{{$op_label}}</td>
|
|
||||||
<td>{{$return_amount}}</td>
|
|
||||||
<td>{{$total}}</td>
|
|
||||||
<td class="actions"></td>
|
|
||||||
</tr>
|
|
||||||
{{/select}}
|
|
||||||
{{/select}}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{* Matériels attribués définitivement *}}
|
{{* Matériels attribués définitivement *}}
|
||||||
{{* vérifier la présence des types de sorties requis *}}
|
{{* vérifier la présence des types de sorties requis *}}
|
||||||
|
|
@ -155,15 +124,16 @@
|
||||||
json_extract(eqpmt.document, '$.name') as eqpmt_name,
|
json_extract(eqpmt.document, '$.name') as eqpmt_name,
|
||||||
json_extract(mvt.document, '$.direction') as direction,
|
json_extract(mvt.document, '$.direction') as direction,
|
||||||
json_extract(mvt.document, '$.operation') as operation,
|
json_extract(mvt.document, '$.operation') as operation,
|
||||||
json_extract(mvt.document, '$.date') as date,
|
MIN(json_extract(mvt.document, '$.date')) as date,
|
||||||
json_extract(mvt.document, '$.amount') as amount
|
SUM(json_extract(mvt.document, '$.amount')) as amount
|
||||||
FROM module_data_equipment AS mvt
|
FROM {!$module.table} AS mvt
|
||||||
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
||||||
INNER JOIN module_data_equipment AS eqpmt
|
INNER JOIN {!$module.table} AS eqpmt
|
||||||
ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
||||||
WHERE users.id = :user
|
WHERE users.id = :user
|
||||||
AND json_extract(mvt.document, '$.operation') IN !output_types
|
AND json_extract(mvt.document, '$.operation') IN !output_types
|
||||||
ORDER BY date DESC
|
GROUP BY eqpmt_key, operation
|
||||||
|
ORDER BY eqpmt_name, date
|
||||||
;
|
;
|
||||||
:user = $user.id
|
:user = $user.id
|
||||||
!output_types=$output_types.définitif
|
!output_types=$output_types.définitif
|
||||||
|
|
@ -208,23 +178,3 @@
|
||||||
</table>
|
</table>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
// afficher/masquer les sorties temporaires entièrement rendues
|
|
||||||
function showhide(cb, liste) {
|
|
||||||
let rows = liste.querySelectorAll("tr[class='r0']");
|
|
||||||
rows.forEach((elem) => {
|
|
||||||
if (cb.checked) {
|
|
||||||
elem.style.display = 'none';
|
|
||||||
} else {
|
|
||||||
elem.style.display = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let cb = $('#f_no_return_1');
|
|
||||||
cb.addEventListener("change", (evt) => {
|
|
||||||
showhide(cb, document.getElementById('liste_temporaires'));
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue