diff --git a/snippets/user_details.html b/snippets/user_details.html index 6d364be..bb1bfcf 100644 --- a/snippets/user_details.html +++ b/snippets/user_details.html @@ -19,131 +19,143 @@ {{/foreach}} {{/foreach}} -{{#select - eqpmt.key as eqpmt_key, - json_extract(eqpmt.document, '$.name') as eqpmt_name, - mvt.key AS mvt_key, - json_extract(mvt.document, '$.direction') as direction, - json_extract(mvt.document, '$.operation') as operation, - json_extract(mvt.document, '$.date') as date, - json_extract(mvt.document, '$.amount') as amount - FROM module_data_equipment AS mvt - INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id - INNER JOIN module_data_equipment AS eqpmt - ON json_extract(mvt.document, '$.equipment') = eqpmt.key - WHERE users.id = :user - AND (json_extract(mvt.document, '$.operation') IN !output_types - OR json_extract(mvt.document, '$.operation') IN !input_types) - ORDER BY date - ; - :user = $user.id - !output_types=$output_types.temporaire - !input_types=$input_types.retour - assign="temp_mat." -}} -{{/select}} +{{* + vérifier l'existence de la table du module + eh oui, il se peut qu'elle ne soit pas encore créée si aucune donnée n'a été ajoutée dedans +*}} +{{#load limit="1"}} + {{:assign table_presente=true}} +{{else}} + {{:assign table_presente=false}} +{{/load}} -{{if $temp_mat|count != 0}} -

Matériels attribués temporairement

- - - - - - - - - - - - - {{#foreach from=$temp_mat}} - {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$operation}} - {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} - {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} - {{if $total == null}} - {{:assign total=0}} - {{/if}} - {{if $direction == 'input' && $type_mvt == 'retour'}} - {{:assign var="reste.%s"|args:$eqpmt_key value="%d-%d"|math:$total:$amount}} - {{elseif $direction == 'output' && $type_mvt == 'temporaire'}} - {{:assign var="reste.%s"|args:$eqpmt_key value="%d+%d"|math:$total:$amount}} - {{/if}} - {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} +{{if $table_presente}} + {{#select + eqpmt.key as eqpmt_key, + json_extract(eqpmt.document, '$.name') as eqpmt_name, + mvt.key AS mvt_key, + json_extract(mvt.document, '$.direction') as direction, + json_extract(mvt.document, '$.operation') as operation, + json_extract(mvt.document, '$.date') as date, + json_extract(mvt.document, '$.amount') as amount + FROM module_data_equipment AS mvt + INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id + INNER JOIN module_data_equipment AS eqpmt + ON json_extract(mvt.document, '$.equipment') = eqpmt.key + WHERE users.id = :user + AND (json_extract(mvt.document, '$.operation') IN !output_types + OR json_extract(mvt.document, '$.operation') IN !input_types) + ORDER BY date + ; + :user = $user.id + !output_types=$output_types.temporaire + !input_types=$input_types.retour + assign="temp_mat." + }} + {{/select}} + + {{if $temp_mat|count != 0}} +

Matériels attribués temporairement

+
DateOpérationMatérielQuantitéTotal
+ - - - - - - + + + + + + - {{/foreach}} - -
{{$date|date_short}}{{$op_label}}{{$eqpmt_name}}{{$amount}}{{$total}} - {{if $direction == "output" && $type_mvt == "temporaire"}} - {{:linkbutton - label="Retour" - href="%smovements/output_return.html?key=%s&prop=0&user=%s"|args:$module.url:$mvt_key:$user.id - shape="history" - target="_dialog"}} - {{/if}} - DateOpérationMatérielQuantitéTotal
-{{/if}} + + + {{#foreach from=$temp_mat}} + {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$operation}} + {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} + {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} + {{if $total == null}} + {{:assign total=0}} + {{/if}} + {{if $direction == 'input' && $type_mvt == 'retour'}} + {{:assign var="reste.%s"|args:$eqpmt_key value="%d-%d"|math:$total:$amount}} + {{elseif $direction == 'output' && $type_mvt == 'temporaire'}} + {{:assign var="reste.%s"|args:$eqpmt_key value="%d+%d"|math:$total:$amount}} + {{/if}} + {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} + + {{$date|date_short}} + {{$op_label}} + {{$eqpmt_name}} + {{$amount}} + {{$total}} + + {{if $direction == "output" && $type_mvt == "temporaire"}} + {{:linkbutton + label="Retour" + href="%smovements/output_return.html?key=%s&prop=0&user=%s"|args:$module.url:$mvt_key:$user.id + shape="history" + target="_dialog"}} + {{/if}} + + + {{/foreach}} + + + {{/if}} -{{#select - eqpmt.key as eqpmt_key, - json_extract(eqpmt.document, '$.name') as eqpmt_name, - json_extract(mvt.document, '$.direction') as direction, - json_extract(mvt.document, '$.operation') as operation, - json_extract(mvt.document, '$.date') as date, - json_extract(mvt.document, '$.amount') as amount - FROM module_data_equipment AS mvt - INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id - INNER JOIN module_data_equipment AS eqpmt - ON json_extract(mvt.document, '$.equipment') = eqpmt.key - WHERE users.id = :user - AND json_extract(mvt.document, '$.operation') IN !output_types - ORDER BY date DESC - ; - :user = $user.id - !output_types=$output_types.définitif - assign="def_mat." -}} -{{/select}} + {{#select + eqpmt.key as eqpmt_key, + json_extract(eqpmt.document, '$.name') as eqpmt_name, + json_extract(mvt.document, '$.direction') as direction, + json_extract(mvt.document, '$.operation') as operation, + json_extract(mvt.document, '$.date') as date, + json_extract(mvt.document, '$.amount') as amount + FROM module_data_equipment AS mvt + INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id + INNER JOIN module_data_equipment AS eqpmt + ON json_extract(mvt.document, '$.equipment') = eqpmt.key + WHERE users.id = :user + AND json_extract(mvt.document, '$.operation') IN !output_types + ORDER BY date DESC + ; + :user = $user.id + !output_types=$output_types.définitif + assign="def_mat." + }} + {{/select}} -{{if $def_mat|count != 0}} -

Matériels attribués définitivement

- - - - - - - - - - - - {{#foreach from=$def_mat}} - {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$operation}} - {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} - {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} - {{if $total == null}} - {{:assign total=0}} - {{/if}} - {{if $direction == 'output' && $type_mvt == 'définitif'}} - {{:assign var="reste.%s"|args:$eqpmt_key value="%d+%d"|math:$total:$amount}} - {{/if}} - {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} + {{if $def_mat|count != 0}} +

Matériels attribués définitivement

+
DateOpérationMatérielQuantitéTotal
+ - - - - - + + + + + - {{/foreach}} - -
{{$date|date_short}}{{$op_label}}{{$eqpmt_name}}{{$amount}}{{$total}}DateOpérationMatérielQuantitéTotal
+ + + {{#foreach from=$def_mat}} + {{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$operation}} + {{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}} + {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} + {{if $total == null}} + {{:assign total=0}} + {{/if}} + {{if $direction == 'output' && $type_mvt == 'définitif'}} + {{:assign var="reste.%s"|args:$eqpmt_key value="%d+%d"|math:$total:$amount}} + {{/if}} + {{:assign var="total" from="reste.%s"|args:$eqpmt_key}} + + {{$date|date_short}} + {{$op_label}} + {{$eqpmt_name}} + {{$amount}} + {{$total}} + + {{/foreach}} + + + {{/if}} {{/if}}