2023-10-19 14:54:03 +02:00
|
|
|
{{#restrict section="config" level="admin" block=true}}{{/restrict}}
|
|
|
|
{{:admin_header title="Gestion des matériels" current="module_equipment"}}
|
|
|
|
|
2023-11-01 16:53:20 +01:00
|
|
|
{{if $_GET.dialog === null}}
|
|
|
|
{{* barre de navigation *}}
|
|
|
|
{{:include file="/%s/_nav.html"|args:$module.name current="sorties"}}
|
|
|
|
{{else}}
|
|
|
|
<header class="header">
|
|
|
|
<h1>Sortie de matériel</h1>
|
|
|
|
{{/if}}
|
2023-10-19 14:54:03 +02:00
|
|
|
|
|
|
|
{{* types de sorties *}}
|
2023-10-26 10:04:45 +02:00
|
|
|
{{#foreach from=$module.config.outputNature item="elem"}}
|
|
|
|
{{:assign var='types_sorties.' value="%s"|args:$elem.label}}
|
|
|
|
{{/foreach}}
|
2023-10-19 14:54:03 +02:00
|
|
|
|
|
|
|
{{* Traiter l'envoi du formulaire *}}
|
|
|
|
{{#form on="save"}}
|
|
|
|
{{* récupérer les infos du matériel *}}
|
|
|
|
{{#load type="equipment" key=$_POST.equipment assign="equipment"}}
|
|
|
|
{{/load}}
|
|
|
|
|
2023-10-26 19:09:59 +02:00
|
|
|
{{* TODO vérifier si qté sortie <= dispo *}}
|
|
|
|
{{:include file="./_calcul_dispo.html" keep="dispo" }}
|
|
|
|
|
|
|
|
{{* cumuler les entrées et les sorties de ce matériel *}}
|
|
|
|
{{if $_POST.quantite|intval > $dispo}}
|
|
|
|
{{:error message="Erreur : la quantité indiquée (%s) est supérieure à celle disponible (%d)"|args:$_POST.quantite:$dispo}}
|
|
|
|
{{/if}}
|
|
|
|
|
2023-10-19 14:54:03 +02:00
|
|
|
{{* Enregistrer le mouvement *}}
|
|
|
|
{{:assign mvt_key=""|uuid}}
|
|
|
|
{{:assign var="operation" from="types_sorties.%d|args:$_POST.type_operation}}
|
|
|
|
|
|
|
|
{{:save
|
|
|
|
key=$mvt_key
|
|
|
|
validate_schema="/%s/mouvements/movement.schema.json"|args:$module.name
|
|
|
|
type="movement"
|
|
|
|
direction="sortie"
|
|
|
|
outputNature=$operation
|
|
|
|
amount=$_POST.quantite|intval
|
|
|
|
equipment=$equipment.key
|
|
|
|
date=$_POST.date|parse_date
|
|
|
|
comment=$_POST.remarques|trim
|
|
|
|
}}
|
|
|
|
|
2023-10-27 09:23:18 +02:00
|
|
|
{{:redirect force="index.html?ok=1&msg=Sortie de « %s » enregistrée"|args:$equipment.designation}}
|
2023-10-19 14:54:03 +02:00
|
|
|
{{else}}
|
|
|
|
{{:form_errors}}
|
|
|
|
{{/form}}
|
|
|
|
|
|
|
|
{{* lister les catégories et matériels associés *}}
|
|
|
|
{{#load type="category" assign="category" order="$$.name"}}
|
|
|
|
{{:assign nom_cat=$category.name}}
|
2023-10-19 20:30:04 +02:00
|
|
|
|
|
|
|
{{#load type="equipment" where="$$.category = :key" :key=$category.key assign="equipment" order="$$.designation"}}
|
|
|
|
|
|
|
|
{{* cumuler les entrées et les sorties de ce matériel *}}
|
2023-10-26 19:09:59 +02:00
|
|
|
{{:include file="./_calcul_dispo.html" keep="dispo" }}
|
|
|
|
|
|
|
|
{{if $dispo > 0}}
|
|
|
|
{{:assign var="equipments.%s.%s"|args:$nom_cat:$equipment.key value="%s (dispo : %d)"|args:$equipment.designation:$dispo}}
|
|
|
|
{{/if}}
|
2023-10-19 14:54:03 +02:00
|
|
|
{{/load}}
|
|
|
|
{{/load}}
|
|
|
|
|
|
|
|
{{* 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>
|
|
|
|
{{:input type="select" name="type_operation" label="Type" required=true options=$types_sorties}}
|
|
|
|
{{:input type="date" name="date" label="Date de sortie" required=true default=$now|date_short}}
|
2023-10-26 19:09:59 +02:00
|
|
|
{{:input type="number" name="quantite" label="Quantité" required=true default=1 min=1}}
|
2023-10-19 14:54:03 +02:00
|
|
|
|
|
|
|
<fieldset>
|
|
|
|
<legend>Matériel</legend>
|
2023-10-26 19:09:59 +02:00
|
|
|
{{:input type="select_groups" name="equipment" label="Matériel" required=true options=$equipments onchange="fixerValeurMax('f_equipment', 'f_quantite')"}}
|
|
|
|
{{:input type="textarea" name="remarques" label="Remarques" cols="40" rows="3" required=false}}
|
2023-10-19 14:54:03 +02:00
|
|
|
</fieldset>
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
<p class="submit">
|
|
|
|
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
|
2023-10-26 19:09:59 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
// 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(/\(dispo : ([0-9]+)\)/)[1]);
|
|
|
|
let val = parseInt(document.getElementById(idNumber).value);
|
|
|
|
document.getElementById(idNumber).setAttribute("max", max);
|
|
|
|
if (val > max) {
|
|
|
|
document.getElementById(idNumber).value = max;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2023-10-19 14:54:03 +02:00
|
|
|
{{:admin_footer}}
|