ajout sortie sur page inventaire
This commit is contained in:
parent
528120d3a0
commit
e7538a11c8
@ -79,10 +79,17 @@
|
||||
<td>{{$exterieur}}</td>
|
||||
<td>{{$dispo}}</td>
|
||||
<td class="actions">
|
||||
{{:linkbutton
|
||||
label="Ajouter entrée"
|
||||
{{if $dispo > 0}}
|
||||
{{:linkbutton
|
||||
label="Sortie"
|
||||
shape="plus"
|
||||
href="mouvements/entrees/repertorie.html?key=%s"|args:$eqpmt_key
|
||||
href="mouvements/sorties/stock_disponible.html?key=%s&prop=1"|args:$eqpmt_key
|
||||
target="_dialog"}}
|
||||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Entrée"
|
||||
shape="plus"
|
||||
href="mouvements/entrees/repertorie.html?key=%s&prop=1"|args:$eqpmt_key
|
||||
target="_dialog"}}
|
||||
{{:linkbutton
|
||||
label="Mouvements"
|
||||
@ -90,7 +97,7 @@
|
||||
shape="table"}}
|
||||
{{:linkbutton
|
||||
label="Modifier"
|
||||
href="%smodifier_materiel.html?key=%s"|args:$module.url:$eqpmt_key
|
||||
href="%smodifier_materiel.html?key=%s&prop=1"|args:$module.url:$eqpmt_key
|
||||
shape="edit"
|
||||
target="_dialog"}}
|
||||
</td>
|
||||
@ -156,19 +163,26 @@
|
||||
<td>{{$eqpmt.designation}}</td>
|
||||
<td>{{$eqpmt.nonproprio}}</td>
|
||||
<td class="actions">
|
||||
{{if $eqpmt.nonproprio > 0}}
|
||||
{{:linkbutton
|
||||
label="Ajouter entrée"
|
||||
label="Retour"
|
||||
href="mouvements/sorties/emprunte.html?key=%s&prop=0"|args:$mvt_key
|
||||
shape="history"
|
||||
target="_dialog"}}
|
||||
{{/if}}
|
||||
{{:linkbutton
|
||||
label="Entrée"
|
||||
shape="plus"
|
||||
href="mouvements/entrees/repertorie.html?key=%s"|args:$eqpmt_key
|
||||
href="mouvements/entrees/repertorie.html?key=%s&prop=0"|args:$eqpmt_key
|
||||
target="_dialog"}}
|
||||
{{:linkbutton
|
||||
label="Mouvements"
|
||||
href="historique.html?key=%s"|args:$eqpmt_key
|
||||
href="historique.html?key=%s&prop=0"|args:$eqpmt_key
|
||||
shape="table"
|
||||
target="_dialog"}}
|
||||
{{:linkbutton
|
||||
label="Modifier"
|
||||
href="modifier_materiel.html?key=%s"|args:$eqpmt_key
|
||||
href="modifier_materiel.html?key=%s&prop=0"|args:$eqpmt_key
|
||||
shape="edit"
|
||||
target="_dialog"}}
|
||||
</td>
|
||||
|
@ -2,8 +2,10 @@
|
||||
|
||||
{{*
|
||||
paramètres :
|
||||
- key : clé du mouvement à modifier
|
||||
- prop : = 1 si matériel propriété
|
||||
- key : clé du matériel à modifier
|
||||
- prop : = 1 si matériel propriété de l'asso
|
||||
|
||||
TODO : simplifier
|
||||
*}}
|
||||
|
||||
{{:admin_header title="Sortie de matériel" current="module_equipment"}}
|
||||
@ -26,9 +28,8 @@
|
||||
{{* 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 type="equipment" key=$_GET.key assign="equipment"}}
|
||||
{{:assign designation=$equipment.designation}}
|
||||
{{:assign var="category_keys." value=$equipment.category}}
|
||||
{{/load}}
|
||||
|
||||
{{:assign stock=0}}
|
||||
@ -37,7 +38,7 @@
|
||||
{{:assign insere=false}}
|
||||
|
||||
{{* lister tous les mouvements du matériel *}}
|
||||
{{#load type="movement" where="$$.equipment = '%s'"|args:$_POST.equipment assign="mvt" order="$$.date ASC"}}
|
||||
{{#load type="movement" where="$$.equipment = '%s'"|args:$_GET.key assign="mvt" order="$$.date ASC"}}
|
||||
|
||||
{{* traiter le nouveau mouvement *}}
|
||||
{{if ! $insere && $mvt.date > $_POST.date|parse_date}}
|
||||
@ -106,75 +107,65 @@
|
||||
date=$_POST.date|parse_date
|
||||
comment=$_POST.remarques|trim
|
||||
}}
|
||||
{{:redirect force="../../historique.html?ok=1&key=%s&prop=%s&msg=sortie"|args:$_POST.equipment:$_GET.prop}}
|
||||
{{:redirect force="../../historique.html?ok=1&key=%s&prop=%s&msg=sortie"|args:$_GET.key:$_GET.prop}}
|
||||
{{else}}
|
||||
{{:form_errors}}
|
||||
{{/form}}
|
||||
|
||||
{{* Extraire et compiler les infos de la base *}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="cumul_mvt"}}
|
||||
{{* TODO simplifier et peut-être mutualiser *}}
|
||||
|
||||
{{if $cumul_mvt !== null}}
|
||||
{{* calculer les disponibilités *}}
|
||||
{{#foreach from=$cumul_mvt key="cat_key" item="cat_elem"}}
|
||||
{{#foreach from=$cat_elem.eqpmt key="eqpmt_key" item="eqpmt"}}
|
||||
{{:assign dispo="%d-%d"|math:$eqpmt.stock:$eqpmt.exterieur}}
|
||||
{{if $dispo != 0}}
|
||||
{{:assign
|
||||
var="disponibilites.%s.%s"|args:$cat_elem.name:$eqpmt_key
|
||||
value="%s (dispo : %d)"|args:$eqpmt.designation:$dispo
|
||||
}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/foreach}}
|
||||
{{:include file="../../_calcul_dispo.html" keep="cumul_mvt,equipments"}}
|
||||
|
||||
{{if $disponibilites != null}}
|
||||
{{* déterminer le matériel concerné par le mouvement *}}
|
||||
{{#load key=$_GET.key}}
|
||||
{{:assign eqpmt_key=$equipment}}
|
||||
{{/load}}
|
||||
{{:assign var=stock from="equipments.%s.stock"|args:$_GET.key}}
|
||||
{{:assign var=exterieur from="equipments.%s.exterieur"|args:$_GET.key}}
|
||||
{{:assign dispo="%d-%d"|math:$stock:$exterieur}}
|
||||
{{:assign var=category_key from="equipments.%s.category"|args:$_GET.key}}
|
||||
{{:assign var=category from="cumul_mvt.%s.name"|args:$category_key}}
|
||||
|
||||
{{* 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>
|
||||
{{if $dispo > 0}}
|
||||
{{* déterminer le matériel concerné par le mouvement *}}
|
||||
{{#load key=$_GET.key assign="equipment"}}
|
||||
{{/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>
|
||||
<dl>
|
||||
{{:input type="select" name="type_operation" label="Type" required=true options=$output_labels}}
|
||||
{{: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>
|
||||
{{:input type="text" name="category" label="Catégorie" required=true disabled=true default=$category.name}}
|
||||
{{:input type="text" name="equipment" label="Matériel" required=true disabled=true default=$equipment.designation}}
|
||||
{{:input type="text" name="dispo" label="Qté disponible" disabled=true default=$dispo}}
|
||||
<p><span class="alert">La quantité indiquée est celle à la date du jour</span></p>
|
||||
<dl>
|
||||
{{:input type="select_groups" name="equipment" label="Matériel" required=true options=$disponibilites default=$eqpmt_key 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}}
|
||||
{{:assign date_err=$now|date:'d/m/Y'}}
|
||||
<p class="block error">Il n'y a aucun matériel disponible à la date du {{$date_err}}</p>
|
||||
{{/if}}
|
||||
{{:input type="number" name="quantite" label="Quantité" required=true default=1 min=1}}
|
||||
{{: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}}
|
||||
<p class="block error">Il n'y a aucun matériel en stock</p>
|
||||
{{:assign date_err=$now|date:'d/m/Y'}}
|
||||
<p class="block error">Il n'y a aucun matériel disponible à la date du {{$date_err}}</p>
|
||||
{{/if}}
|
||||
|
||||
<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]);
|
||||
console.log('idsel=' + idSelect + ', idnum=' + idNumber);
|
||||
let max = document.getElementById(idSelect).value;
|
||||
let val = parseInt(document.getElementById(idNumber).value);
|
||||
document.getElementById(idNumber).setAttribute("max", max);
|
||||
if (val > max) {
|
||||
document.getElementById(idNumber).value = max;
|
||||
}
|
||||
}
|
||||
addEventListener("DOMContentLoaded", (event) => {
|
||||
fixerValeurMax('f_dispo', 'f_quantite');
|
||||
});
|
||||
</script>
|
||||
|
||||
{{:admin_footer}}
|
||||
|
Loading…
Reference in New Issue
Block a user