254 lines
7.4 KiB
HTML
254 lines
7.4 KiB
HTML
{{* -*- brindille -*- *}}
|
|
|
|
{{* lecture config (défaut ou enregistrée) *}}
|
|
{{:include file="../_get_config.html" keep="config, directions"}}
|
|
|
|
{{#foreach from=$directions key="direction"}}
|
|
{{:assign var="nature" from="config.%s_nature"|args:$direction}}
|
|
{{#foreach from=$nature key=key}}
|
|
{{:assign var="types.%s.%s."|args:$direction:$type value=$key|quote_sql}}
|
|
{{/foreach}}
|
|
{{:assign var="io_types" from="types.%s"|args:$direction}}
|
|
{{#foreach from=$io_types key=key}}
|
|
{{:assign var=elem from="io_types.%s"|args:$key}}
|
|
{{:assign elem=$elem|implode:","}}
|
|
{{:assign elem="("|cat:$elem|cat:")"}}
|
|
{{:assign var="%s_types.%s"|args:$direction:$key value=$elem}}
|
|
{{/foreach}}
|
|
{{/foreach}}
|
|
|
|
{{*
|
|
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 $table_presente}}
|
|
{{* Matériels attribués temporairement *}}
|
|
{{* vérifier la présence des types d'entrées et de sorties requis *}}
|
|
{{if $output_types|has_key:"temporaire" && $input_types|has_key:"retour"}}
|
|
|
|
{{*
|
|
Calculer les quantités de matériel en prêt
|
|
*}}
|
|
{{:assign premier=true}}
|
|
{{#select
|
|
mvt.$$.direction AS direction,
|
|
mvt.$$.date AS date,
|
|
eqpmt.key as eqpmt_key,
|
|
eqpmt.$$.name AS eqpmt_name,
|
|
mvt.$$.amount AS qte,
|
|
mvt.$$.return_date AS return_date,
|
|
mvt.$$.operation AS operation
|
|
FROM !table AS mvt
|
|
INNER JOIN users ON mvt.$$.user = users.id
|
|
INNER JOIN !table AS eqpmt ON mvt.$$.equipment = eqpmt.key
|
|
WHERE
|
|
users.id = :user
|
|
AND
|
|
mvt.$$.type = 'movement'
|
|
AND
|
|
(mvt.$$.operation IN !output_types
|
|
OR
|
|
mvt.$$.operation IN !input_types)
|
|
ORDER BY eqpmt_name, date
|
|
;
|
|
!table=$module.table
|
|
:user = $user.id
|
|
!output_types=$output_types.temporaire
|
|
!input_types=$input_types.retour
|
|
}}
|
|
{{if $premier}}
|
|
{{:assign premier=false}}
|
|
{{:assign total=0}}
|
|
{{:assign nb_jours=0}}
|
|
{{:assign old_eqpmt_key=$eqpmt_key}}
|
|
{{:assign var="ligne.date" value=$date}}
|
|
{{:assign var="ligne.eqpmt_key" value=$eqpmt_key}}
|
|
{{:assign var="ligne.materiel" value=$eqpmt_name}}
|
|
{{:assign var="ligne.return_date" value=$return_date}}
|
|
{{:assign var="ligne.retard" value="0"}}
|
|
{{if $return_date != null}}
|
|
{{:assign ts_retour=$return_date|strtotime}}
|
|
{{:assign nb_jours="floor((%d-%d)/(60*60*24))"|math:$now:$ts_retour}}
|
|
{{:assign var="ligne.retard" value=$nb_jours}}
|
|
{{/if}}
|
|
{{/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 nb_jours=0}}
|
|
{{:assign old_eqpmt_key=$eqpmt_key}}
|
|
{{:assign var="ligne.date" value=$date}}
|
|
{{:assign var="ligne.eqpmt_key" value=$eqpmt_key}}
|
|
{{:assign var="ligne.materiel" value=$eqpmt_name}}
|
|
{{:assign var="ligne.return_date" value=$return_date}}
|
|
{{:assign var="ligne.retard" value="0"}}
|
|
{{if $return_date != null}}
|
|
{{:assign ts_retour=$return_date|strtotime}}
|
|
{{:assign nb_jours="floor((%d-%d)/(60*60*24))"|math:$now:$ts_retour}}
|
|
{{:assign var="ligne.retard" value=$nb_jours}}
|
|
{{/if}}
|
|
{{/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>
|
|
<table class="list" id="liste_temporaires">
|
|
<thead>
|
|
<tr>
|
|
<th>Date</th>
|
|
<th>Matériel</th>
|
|
<th>Quantité</th>
|
|
<th>Date de retour</th>
|
|
<th>Remarque</th>
|
|
<th class="actions">
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{#foreach from=$lignes}}
|
|
<tr>
|
|
<td>{{$date|date_short}}</td>
|
|
<td>{{$materiel}}</td>
|
|
<td>{{$qte}}</td>
|
|
<td>{{$return_date|date_short}}</td>
|
|
<td>
|
|
{{if $retard < 0}}
|
|
{{:assign delai="abs(%d)"|math:$retard}}
|
|
{{"Reste %s jours"|args:$delai}}
|
|
{{elseif $retard > 0 }}
|
|
{{:tag color="darkred" label="Retard %s jours"|args:$retard}}
|
|
{{elseif $return_date != null}}
|
|
{{:tag color="darkgreen" label="À rendre aujourdh'ui"}}
|
|
{{/if}}
|
|
</td>
|
|
<td class="actions">
|
|
{{:linkbutton
|
|
label="Historique"
|
|
href="%smember_history.html?key=%s&id=%s"|args:$module.url:$eqpmt_key:$user.id
|
|
shape="table"
|
|
target="_dialog"
|
|
}}
|
|
</td>
|
|
</tr>
|
|
{{/foreach}}
|
|
</tbody>
|
|
</table>
|
|
{{/if}}
|
|
{{/if}}
|
|
|
|
{{* Matériels attribués définitivement *}}
|
|
{{* vérifier la présence des types de sorties requis *}}
|
|
{{if $output_types|has_key:"définitif"}}
|
|
{{#select
|
|
eqpmt.key as eqpmt_key,
|
|
eqpmt.$$.name as eqpmt_name,
|
|
mvt.$$.direction as direction,
|
|
mvt.$$.operation as operation,
|
|
MIN(mvt.$$.date) as date,
|
|
SUM(mvt.$$.amount) as amount
|
|
FROM !table AS mvt
|
|
INNER JOIN users ON mvt.$$.user = users.id
|
|
INNER JOIN !table AS eqpmt
|
|
ON mvt.$$.equipment = eqpmt.key
|
|
WHERE users.id = :user
|
|
AND mvt.$$.operation IN !output_types
|
|
GROUP BY eqpmt_key, operation
|
|
ORDER BY eqpmt_name, date
|
|
;
|
|
!table=$module.table
|
|
:user = $user.id
|
|
!output_types=$output_types.définitif
|
|
assign="def_mat."
|
|
}}
|
|
{{/select}}
|
|
{{/if}}
|
|
|
|
{{if $def_mat|count != 0}}
|
|
<h3 class="ruler">Matériels attribués définitivement</h3>
|
|
<table class="list">
|
|
<thead>
|
|
<tr>
|
|
<th>Date</th>
|
|
<th>Matériel</th>
|
|
<th>Opération</th>
|
|
<th>Quantité</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{#foreach from=$def_mat}}
|
|
{{:assign var="op_label" from="config.%s_nature.%s.label"|args:$direction:$operation}}
|
|
<tr>
|
|
<td>{{$date|date_short}}</td>
|
|
<td>{{$eqpmt_name}}</td>
|
|
<td>{{$op_label}}</td>
|
|
<td>{{$amount}}</td>
|
|
</tr>
|
|
{{/foreach}}
|
|
</tbody>
|
|
</table>
|
|
{{/if}}
|
|
|
|
|
|
{{* Mes réservations de matériel *}}
|
|
{{#load type="reservation" member=$logged_user.id assign="my_reservations."}}{{/load}}
|
|
{{*:debug my_reservations=$my_reservations*}}
|
|
{{if $my_reservations|count != 0}}
|
|
<h3 class="ruler">Mes réservations</h3>
|
|
<table class="list">
|
|
<thead>
|
|
<tr>
|
|
<th>Date</th>
|
|
<th>Matériel</th>
|
|
<th>Date de début</th>
|
|
<th>Date de retour</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{#foreach from=$my_reservations}}
|
|
<tr>
|
|
<td>{{$date|date_short}}</td>
|
|
{{* Charge le matériel *}}
|
|
{{#load key=$equipment assign="equipment"}}{{/load}}
|
|
<td>{{$equipment.name}}</td>
|
|
<td>{{$loan_date|date_short}}</td>
|
|
<td>{{$return_date|date_short}}</td>
|
|
{{if $status == "acceptée"}}
|
|
{{:assign var="_tag_color" value="--tag-color: lightgreen;"}}
|
|
{{elseif $status == "archivée"}}
|
|
{{:assign var="_tag_color" value="--tag-color: lightgrey;"}}
|
|
{{elseif $status == "en attente"}}
|
|
{{:assign var="_tag_color" value="--tag-color: lightblue;"}}
|
|
{{elseif $status == "refusée"}}
|
|
{{:assign var="_tag_color" value="--tag-color: darksalmon;"}}
|
|
{{elseif $status == "refusée"}}
|
|
{{:assign var="_tag_color" value="--tag-color: darkorchid;"}}
|
|
{{/if}}
|
|
<td><span class="tag" style="{{$_tag_color}}">{{$status}}</span></td>
|
|
</tr>
|
|
{{/foreach}}
|
|
</tbody>
|
|
</table>
|
|
{{/if}}
|
|
{{/if}}
|