2023-12-05 19:17:08 +01:00
|
|
|
{{:admin_header title="Sortie de matériel" current="module_equipment"}}
|
2023-11-20 14:00:00 +01:00
|
|
|
|
2023-12-05 19:17:08 +01:00
|
|
|
{{if ! $dialog}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* barre de navigation *}}
|
|
|
|
{{:include file="../../_nav.html" current="sorties"}}
|
2023-11-20 14:00:00 +01:00
|
|
|
{{/if}}
|
|
|
|
|
2023-11-30 18:14:46 +01:00
|
|
|
{{* récupérer la config des entrées/sorties *}}
|
2023-12-05 10:07:01 +01:00
|
|
|
{{:include file="../../_get_config.html" keep="config"}}
|
2023-11-30 18:14:46 +01:00
|
|
|
|
2023-11-20 14:00:00 +01:00
|
|
|
{{* types de sorties *}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{#foreach from=$config.output_nature key="label" item="type"}}
|
|
|
|
{{if $type == 'retour'}}
|
|
|
|
{{:assign var='output_labels.' value="%s"|args:$label}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
2023-11-20 14:00:00 +01:00
|
|
|
{{/foreach}}
|
|
|
|
|
|
|
|
{{* Traiter l'envoi du formulaire *}}
|
|
|
|
{{#form on="save"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* récupérer les infos du matériel *}}
|
|
|
|
{{#load type="equipment" key=$_POST.equipment assign="equipment"}}
|
|
|
|
{{:assign designation=$equipment.designation}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{:assign var="category_keys." value=$equipment.category}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/load}}
|
|
|
|
|
|
|
|
{{* Extraire et compiler les infos de la base *}}
|
|
|
|
{{:include
|
|
|
|
file="../../_calcul_dispo.html"
|
2023-12-07 17:33:49 +01:00
|
|
|
keep="cumul_mvt"
|
2023-12-06 09:59:11 +01:00
|
|
|
date=$_POST.date|parse_date
|
|
|
|
}}
|
|
|
|
|
|
|
|
{{* déterminer la quantité présente de ce matériel à la date donnée *}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{:assign var=present from="cumul_mvt.%s.eqpmt.%s.nonproprio"|args:$equipment.category:$_POST.equipment}}
|
2023-12-06 09:59:11 +01:00
|
|
|
|
|
|
|
{{if $_POST.quantite|intval > $present}}
|
|
|
|
{{:error message="Erreur : la quantité indiquée (%s) est supérieure à celle présente (%d) à la date du %s"|args:$_POST.quantite:$present:$_POST.date}}
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{* Enregistrer le mouvement *}}
|
|
|
|
|
|
|
|
{{:assign mvt_key=""|uuid}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{:assign var="operation" from="output_labels.%d|args:$_POST.type_operation}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:save
|
|
|
|
key=$mvt_key
|
|
|
|
validate_schema="../movement.schema.json"
|
|
|
|
type="movement"
|
|
|
|
direction="output"
|
|
|
|
output_nature=$operation
|
|
|
|
amount=$_POST.quantite|intval
|
|
|
|
equipment=$equipment.key
|
|
|
|
date=$_POST.date|parse_date
|
|
|
|
comment=$_POST.remarques|trim
|
|
|
|
}}
|
|
|
|
{{:redirect force="index.html?ok=1&msg=sortie"}}
|
2023-11-20 14:00:00 +01:00
|
|
|
{{else}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:form_errors}}
|
2023-11-20 14:00:00 +01:00
|
|
|
{{/form}}
|
|
|
|
|
|
|
|
{{* Extraire et compiler les infos de la base *}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{:include file="../../_calcul_dispo.html" keep="cumul_mvt"}}
|
2023-11-20 14:00:00 +01:00
|
|
|
|
2023-12-07 17:33:49 +01:00
|
|
|
{{if $cumul_mvt !== null}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{* calculer les quantité de matériels dont l'asso n'est pas propriétaire *}}
|
2023-12-07 17:33:49 +01:00
|
|
|
{{#foreach from=$cumul_mvt key="cat_key" item="cat_elem"}}
|
|
|
|
{{#foreach from=$cat_elem.eqpmt key="eqpmt_key" item="eqpmt"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:assign quantite="%d-%d"|math:$eqpmt.nonproprio:$eqpmt.retour}}
|
|
|
|
{{if $quantite != 0}}
|
|
|
|
{{:assign
|
2023-12-07 17:33:49 +01:00
|
|
|
var="temporaire.%s.%s"|args:$cat_elem.name:$eqpmt_key
|
2023-12-06 09:59:11 +01:00
|
|
|
value="%s (quantité : %d)"|args:$eqpmt.designation:$quantite
|
|
|
|
}}
|
|
|
|
{{/if}}
|
|
|
|
{{/foreach}}
|
|
|
|
{{/foreach}}
|
|
|
|
|
|
|
|
{{if $temporaire != null}}
|
|
|
|
{{* formulaire de sortie de matériel *}}
|
|
|
|
<form method="post" action="">
|
|
|
|
<fieldset class="sortie">
|
|
|
|
<legend>Ajouter une sortie d'un matériel disponible en stock</legend>
|
|
|
|
<dl>
|
2023-12-07 17:33:49 +01:00
|
|
|
{{:input type="select" name="type_operation" label="Type" required=true options=$output_labels}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:input type="date" name="date" label="Date de sortie" required=true default=$now|date_short}}
|
|
|
|
{{:input type="number" name="quantite" label="Quantité" required=true default=1 min=1}}
|
|
|
|
</dl>
|
|
|
|
</fieldset>
|
|
|
|
<fieldset>
|
|
|
|
<legend>Matériel</legend>
|
|
|
|
<p><span class="alert">La quantité disponible est celle à la date du jour</span></p>
|
|
|
|
<dl>
|
|
|
|
{{:input type="select_groups" name="equipment" label="Matériel" required=true options=$temporaire onchange="fixerValeurMax('f_equipment', 'f_quantite')"}}
|
|
|
|
{{:input type="textarea" name="remarques" label="Remarques" cols="40" rows="3" required=false}}
|
|
|
|
</dl>
|
|
|
|
</fieldset>
|
|
|
|
<p class="submit">
|
|
|
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
|
|
|
</p>
|
|
|
|
</form>
|
|
|
|
{{else}}
|
2023-12-07 22:21:04 +01:00
|
|
|
<p class="block error">Il n'y a aucun matériel présent temporairement</p>
|
2023-12-06 09:59:11 +01:00
|
|
|
{{/if}}
|
2023-11-30 18:14:46 +01:00
|
|
|
{{else}}
|
2023-12-07 22:21:04 +01:00
|
|
|
<p class="block error">Il n'y a aucun matériel en stock</p>
|
2023-11-30 18:14:46 +01:00
|
|
|
{{/if}}
|
2023-11-20 14:00:00 +01:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
2023-12-06 09:59:11 +01:00
|
|
|
// fixer la valeur maximale du champ de saisie de la quantité
|
|
|
|
function fixerValeurMax(idSelect, idNumber) {
|
|
|
|
let option = document.getElementById(idSelect).selectedOptions[0];
|
|
|
|
let max = parseInt(option.label.match(/\(quantité : ([0-9]+)\)/)[1]);
|
|
|
|
let val = parseInt(document.getElementById(idNumber).value);
|
|
|
|
document.getElementById(idNumber).setAttribute("max", max);
|
|
|
|
if (val > max) {
|
|
|
|
document.getElementById(idNumber).value = max;
|
|
|
|
}
|
|
|
|
}
|
2023-11-20 14:00:00 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
{{:admin_footer}}
|