2023-10-24 18:11:28 +02:00
|
|
|
{{#restrict section="config" level="admin" block=true}}{{/restrict}}
|
|
|
|
{{:admin_header title="Configuration" current="module_equipment"}}
|
|
|
|
|
|
|
|
{{* barre de navigation *}}
|
2023-12-05 10:07:01 +01:00
|
|
|
{{:include file="_nav.html" current="config"}}
|
2023-10-24 18:11:28 +02:00
|
|
|
|
|
|
|
{{if $_GET.ok}}
|
2023-12-06 09:59:11 +01:00
|
|
|
<p class="block confirm">Configuration enregistrée.</p>
|
2023-10-24 18:11:28 +02:00
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{* Traiter l'envoi du formulaire *}}
|
|
|
|
{{#form on="save"}}
|
|
|
|
|
2023-12-06 09:59:11 +01:00
|
|
|
{{:save key="config"
|
|
|
|
validate_schema="./config.schema.json"
|
|
|
|
input_nature=$_POST.input_fields|array_transpose
|
|
|
|
output_nature=$_POST.output_fields|array_transpose
|
|
|
|
}}
|
|
|
|
{{:redirect to="./config.html?ok=1"}}
|
2023-10-24 18:11:28 +02:00
|
|
|
{{/form}}
|
|
|
|
|
2023-11-29 20:14:31 +01:00
|
|
|
{{* config par défaut *}}
|
2023-12-05 10:07:01 +01:00
|
|
|
{{:read file="./defaut.json" assign="config_defaut"}}
|
2023-11-29 20:14:31 +01:00
|
|
|
{{:assign config_defaut=$config_defaut|json_decode}}
|
2023-10-24 18:11:28 +02:00
|
|
|
|
2023-11-29 20:14:31 +01:00
|
|
|
{{* types d'entrées *}}
|
2023-12-05 19:17:08 +01:00
|
|
|
{{#foreach from=$config_defaut.inputs item="elem"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{#foreach from=$elem key=label item=value}}
|
|
|
|
{{:assign var='input_types.%s'|args:$value value=$value}}
|
|
|
|
{{/foreach}}
|
2023-11-29 20:14:31 +01:00
|
|
|
{{/foreach}}
|
2023-11-15 14:49:34 +01:00
|
|
|
|
|
|
|
{{* types de sorties *}}
|
2023-12-05 19:17:08 +01:00
|
|
|
{{#foreach from=$config_defaut.outputs item="elem"}}
|
2023-12-06 09:59:11 +01:00
|
|
|
{{#foreach from=$elem key=label item=value}}
|
|
|
|
{{:assign var='output_typess.%s'|args:$value value=$value}}
|
|
|
|
{{/foreach}}
|
2023-11-29 20:14:31 +01:00
|
|
|
{{/foreach}}
|
2023-10-24 18:11:28 +02:00
|
|
|
|
|
|
|
<form method="post" action="">
|
2023-12-06 09:59:11 +01:00
|
|
|
<fieldset>
|
|
|
|
<legend>Entrées</legend>
|
|
|
|
<table class="list input_fields">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Nature de l'entrée</th>
|
|
|
|
<th>Type</th>
|
|
|
|
<th>Action</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="input_body">
|
|
|
|
{{#foreach from=$module.config.input_nature item="input_field"}}
|
|
|
|
|
|
|
|
{{* Vérifier si la suppression de ce type d'entrée est possible *}}
|
|
|
|
{{:assign suppr=true}}
|
|
|
|
{{#load type="movement" where="$$.input_nature = :libelle" :libelle=$input_field.label}}
|
|
|
|
{{:assign suppr=false}}
|
|
|
|
{{/load}}
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>{{:input type="text" name="input_fields[label][]" default=$input_field.label}}</td>
|
|
|
|
<td>{{:input type="select"
|
|
|
|
name="input_fields[type][]"
|
|
|
|
options=$input_types
|
|
|
|
default=$input_field.type
|
|
|
|
required=true
|
|
|
|
default_empty="— Choisir un type —"}}
|
|
|
|
</td>
|
|
|
|
<td class="action">
|
|
|
|
{{if $suppr}}
|
|
|
|
{{:button label="Supprimer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
|
|
|
|
{{else}}
|
|
|
|
{{:button label="Supprimer" shape="minus" disabled=true}}
|
|
|
|
{{/if}}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{{else}}
|
|
|
|
{{* pas de config enregistrée : utiliser les valeurs par défaut *}}
|
|
|
|
{{#foreach from=$config_defaut.inputs item="elem"}}
|
|
|
|
{{#foreach from=$elem key=label item=value}}
|
|
|
|
|
|
|
|
{{* Vérifier si la suppression de ce type d'entrée est possible *}}
|
|
|
|
{{:assign suppr=true}}
|
|
|
|
{{#load type="movement" where="$$.input_nature = :libelle" :libelle=$label}}
|
|
|
|
{{:assign suppr=false}}
|
|
|
|
{{/load}}
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>{{:input type="text" name="input_fields[label][]" default=$label}}</td>
|
|
|
|
<td>{{:input
|
|
|
|
type="select"
|
|
|
|
name="input_fields[type][]"
|
|
|
|
options=$input_types
|
|
|
|
required=true
|
|
|
|
default=$value
|
|
|
|
default_empty="— Choisir un type —"}}
|
|
|
|
</td>
|
|
|
|
<td class="action">
|
|
|
|
{{if $suppr}}
|
|
|
|
{{:button label="Supprimer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
|
|
|
|
{{else}}
|
|
|
|
{{:button label="Supprimer" shape="minus" disabled=true}}
|
|
|
|
{{/if}}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{{/foreach}}
|
|
|
|
{{/foreach}}
|
|
|
|
{{/foreach}}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<p class="actions">
|
|
|
|
{{:button shape="plus" label="Ajouter un champ" onclick="addLine('#input_body')"}}
|
|
|
|
</p>
|
|
|
|
<div class="help block">
|
|
|
|
<h3>Signification du type d'entrée</h3>
|
|
|
|
<ul>
|
|
|
|
<li><b>définitif</b> : l'asso devient propriétaire du matériel (ex : achat, don)</li>
|
|
|
|
<li><b>temporaire</b> : l'asso ne devient <strong>pas</strong> propriétaire du matériel (ex : location, emprunt)</li>
|
|
|
|
<li><b>retour</b> : matériel qui revient après une sortie temporaire (ex : retour de location ou de prêt)</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
<fieldset>
|
|
|
|
<legend>Sorties</legend>
|
|
|
|
<table class="list output_fields">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Nature de la sortie</th>
|
|
|
|
<th>Type</th>
|
|
|
|
<th>Action</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="output_body">
|
|
|
|
{{#foreach from=$module.config.output_nature item="output_field"}}
|
|
|
|
|
|
|
|
{{* Vérifier si la suppression de ce type de sortie est possible *}}
|
|
|
|
{{:assign suppr=true}}
|
|
|
|
{{#load type="movement" where="$$.output_nature = :libelle" :libelle=$output_field.label}}
|
|
|
|
{{:assign suppr=false}}
|
|
|
|
{{/load}}
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>{{:input type="text" name="output_fields[label][]" default=$output_field.label}}</td>
|
|
|
|
<td>{{:input
|
|
|
|
type="select"
|
|
|
|
name="output_fields[type][]"
|
|
|
|
options=$output_typess
|
|
|
|
default=$output_field.type
|
|
|
|
required=true
|
|
|
|
default_empty="— Choisir un type —"}}
|
|
|
|
</td>
|
|
|
|
<td class="action">
|
|
|
|
{{if $suppr}}
|
|
|
|
{{:button label="Supprimer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
|
|
|
|
{{else}}
|
|
|
|
{{:button label="Supprimer" shape="minus" disabled=true}}
|
|
|
|
{{/if}}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{{else}}
|
|
|
|
{{* pas de config enregistrée : utiliser les valeurs par défaut *}}
|
|
|
|
{{#foreach from=$config_defaut.outputs item="elem"}}
|
|
|
|
{{#foreach from=$elem key=label item=value}}
|
|
|
|
|
|
|
|
{{* Vérifier si la suppression de ce type de sortie est possible *}}
|
|
|
|
{{:assign suppr=true}}
|
|
|
|
{{#load type="movement" where="$$.input_nature = :libelle" :libelle=$label}}
|
|
|
|
{{:assign suppr=false}}
|
|
|
|
{{/load}}
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>{{:input type="text" name="output_fields[label][]" default=$label}}</td>
|
|
|
|
<td>{{:input
|
|
|
|
type="select"
|
|
|
|
name="output_fields[type][]"
|
|
|
|
options=$output_typess
|
|
|
|
required=true
|
|
|
|
default=$value
|
|
|
|
default_empty="— Choisir un type —"}}
|
|
|
|
</td>
|
|
|
|
<td class="action">
|
|
|
|
{{if $suppr}}
|
|
|
|
{{:button label="Supprimer" shape="minus" onclick="this.parentNode.parentNode.remove();"}}
|
|
|
|
{{else}}
|
|
|
|
{{:button label="Supprimer" shape="minus" disabled=true}}
|
|
|
|
{{/if}}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{{/foreach}}
|
|
|
|
{{/foreach}}
|
|
|
|
{{/foreach}}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<p class="actions">
|
|
|
|
{{:button shape="plus"
|
|
|
|
label="Ajouter un champ"
|
|
|
|
onclick="addLine('#output_body')"}}
|
|
|
|
</p>
|
|
|
|
<div class="help block">
|
|
|
|
<h3>Signification du type de sortie</h3>
|
|
|
|
<ul>
|
|
|
|
<li><b>définitif</b> : le matériel n'appartient plus à l'asso (ex : vente, casse, perte, vol, ...)</li>
|
|
|
|
<li><b>temporaire</b> : le matériel sort temporairement de l'asso qui en reste propriétaire (ex : location, prêt)</li>
|
|
|
|
<li><b>retour</b> : le matériel <strong>non propriété de l'asso</strong> est rendu à son propriétaire (ex : retour de location ou d'emprunt)</li>
|
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
<p class="submit">
|
|
|
|
{{:button
|
|
|
|
type="submit"
|
|
|
|
name="save"
|
|
|
|
label="Enregistrer"
|
|
|
|
shape="right"
|
|
|
|
class="main"
|
|
|
|
}}
|
|
|
|
</p>
|
2023-10-24 18:11:28 +02:00
|
|
|
</form>
|
|
|
|
|
2023-10-25 12:14:05 +02:00
|
|
|
<script type="text/javascript">
|
2023-12-06 09:59:11 +01:00
|
|
|
// dupliquer la dernière ligne d'une table
|
|
|
|
function addLine(id_body) {
|
|
|
|
var ligne = document.querySelector(id_body).lastElementChild;
|
|
|
|
var nelle = ligne.cloneNode(true);
|
|
|
|
let text = nelle.querySelector('input[type="text"]');
|
|
|
|
text.value = null;
|
|
|
|
let menu = nelle.querySelector('select')
|
|
|
|
if (menu != null) {
|
|
|
|
menu[0].selected = 'selected';
|
|
|
|
}
|
|
|
|
ligne.parentNode.appendChild(nelle);
|
|
|
|
text.focus();
|
|
|
|
}
|
2023-10-25 12:14:05 +02:00
|
|
|
</script>
|
2023-10-24 18:11:28 +02:00
|
|
|
{{:admin_footer}}
|