Correction erreur si table du module pas encore créée
This commit is contained in:
parent
86d27e67d5
commit
b50778f572
1 changed files with 132 additions and 120 deletions
|
@ -19,131 +19,143 @@
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
||||||
{{#select
|
{{*
|
||||||
eqpmt.key as eqpmt_key,
|
vérifier l'existence de la table du module
|
||||||
json_extract(eqpmt.document, '$.name') as eqpmt_name,
|
eh oui, il se peut qu'elle ne soit pas encore créée si aucune donnée n'a été ajoutée dedans
|
||||||
mvt.key AS mvt_key,
|
*}}
|
||||||
json_extract(mvt.document, '$.direction') as direction,
|
{{#load limit="1"}}
|
||||||
json_extract(mvt.document, '$.operation') as operation,
|
{{:assign table_presente=true}}
|
||||||
json_extract(mvt.document, '$.date') as date,
|
{{else}}
|
||||||
json_extract(mvt.document, '$.amount') as amount
|
{{:assign table_presente=false}}
|
||||||
FROM module_data_equipment AS mvt
|
{{/load}}
|
||||||
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}}
|
{{if $table_presente}}
|
||||||
<h3 class="ruler">Matériels attribués temporairement</h3>
|
{{#select
|
||||||
<table class="list">
|
eqpmt.key as eqpmt_key,
|
||||||
<thead>
|
json_extract(eqpmt.document, '$.name') as eqpmt_name,
|
||||||
<tr>
|
mvt.key AS mvt_key,
|
||||||
<td>Date</td>
|
json_extract(mvt.document, '$.direction') as direction,
|
||||||
<td>Opération</td>
|
json_extract(mvt.document, '$.operation') as operation,
|
||||||
<td>Matériel</td>
|
json_extract(mvt.document, '$.date') as date,
|
||||||
<td>Quantité</td>
|
json_extract(mvt.document, '$.amount') as amount
|
||||||
<td>Total</td>
|
FROM module_data_equipment AS mvt
|
||||||
<td class="actions"></td>
|
INNER JOIN users ON json_extract(mvt.document, '$.user') = users.id
|
||||||
</tr>
|
INNER JOIN module_data_equipment AS eqpmt
|
||||||
</thead>
|
ON json_extract(mvt.document, '$.equipment') = eqpmt.key
|
||||||
<tbody>
|
WHERE users.id = :user
|
||||||
{{#foreach from=$temp_mat}}
|
AND (json_extract(mvt.document, '$.operation') IN !output_types
|
||||||
{{:assign var="type_mvt" from="config.%s_nature.%s.type"|args:$direction:$operation}}
|
OR json_extract(mvt.document, '$.operation') IN !input_types)
|
||||||
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
|
ORDER BY date
|
||||||
{{:assign var="total" from="reste.%s"|args:$eqpmt_key}}
|
;
|
||||||
{{if $total == null}}
|
:user = $user.id
|
||||||
{{:assign total=0}}
|
!output_types=$output_types.temporaire
|
||||||
{{/if}}
|
!input_types=$input_types.retour
|
||||||
{{if $direction == 'input' && $type_mvt == 'retour'}}
|
assign="temp_mat."
|
||||||
{{:assign var="reste.%s"|args:$eqpmt_key value="%d-%d"|math:$total:$amount}}
|
}}
|
||||||
{{elseif $direction == 'output' && $type_mvt == 'temporaire'}}
|
{{/select}}
|
||||||
{{:assign var="reste.%s"|args:$eqpmt_key value="%d+%d"|math:$total:$amount}}
|
|
||||||
{{/if}}
|
{{if $temp_mat|count != 0}}
|
||||||
{{:assign var="total" from="reste.%s"|args:$eqpmt_key}}
|
<h3 class="ruler">Matériels attribués temporairement</h3>
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{$date|date_short}}</td>
|
<td>Date</td>
|
||||||
<td>{{$op_label}}</td>
|
<td>Opération</td>
|
||||||
<td>{{$eqpmt_name}}</td>
|
<td>Matériel</td>
|
||||||
<td>{{$amount}}</td>
|
<td>Quantité</td>
|
||||||
<td>{{$total}}</td>
|
<td>Total</td>
|
||||||
<td class="actions">
|
<td class="actions"></td>
|
||||||
{{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}}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{{/foreach}}
|
</thead>
|
||||||
</tbody>
|
<tbody>
|
||||||
</table>
|
{{#foreach from=$temp_mat}}
|
||||||
{{/if}}
|
{{: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}}
|
||||||
|
<tr>
|
||||||
|
<td>{{$date|date_short}}</td>
|
||||||
|
<td>{{$op_label}}</td>
|
||||||
|
<td>{{$eqpmt_name}}</td>
|
||||||
|
<td>{{$amount}}</td>
|
||||||
|
<td>{{$total}}</td>
|
||||||
|
<td class="actions">
|
||||||
|
{{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}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/foreach}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#select
|
{{#select
|
||||||
eqpmt.key as eqpmt_key,
|
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, '$.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,
|
json_extract(mvt.document, '$.date') as date,
|
||||||
json_extract(mvt.document, '$.amount') as amount
|
json_extract(mvt.document, '$.amount') as amount
|
||||||
FROM module_data_equipment AS mvt
|
FROM module_data_equipment 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_data_equipment 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
|
ORDER BY date DESC
|
||||||
;
|
;
|
||||||
:user = $user.id
|
:user = $user.id
|
||||||
!output_types=$output_types.définitif
|
!output_types=$output_types.définitif
|
||||||
assign="def_mat."
|
assign="def_mat."
|
||||||
}}
|
}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
|
|
||||||
{{if $def_mat|count != 0}}
|
{{if $def_mat|count != 0}}
|
||||||
<h3 class="ruler">Matériels attribués définitivement</h3>
|
<h3 class="ruler">Matériels attribués définitivement</h3>
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
|
||||||
<td>Date</td>
|
|
||||||
<td>Opération</td>
|
|
||||||
<td>Matériel</td>
|
|
||||||
<td>Quantité</td>
|
|
||||||
<td>Total</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{{#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}}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{$date|date_short}}</td>
|
<td>Date</td>
|
||||||
<td>{{$op_label}}</td>
|
<td>Opération</td>
|
||||||
<td>{{$eqpmt_name}}</td>
|
<td>Matériel</td>
|
||||||
<td>{{$amount}}</td>
|
<td>Quantité</td>
|
||||||
<td>{{$total}}</td>
|
<td>Total</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/foreach}}
|
</thead>
|
||||||
</tbody>
|
<tbody>
|
||||||
</table>
|
{{#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}}
|
||||||
|
<tr>
|
||||||
|
<td>{{$date|date_short}}</td>
|
||||||
|
<td>{{$op_label}}</td>
|
||||||
|
<td>{{$eqpmt_name}}</td>
|
||||||
|
<td>{{$amount}}</td>
|
||||||
|
<td>{{$total}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/foreach}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue