Réorganisation saisie/modification tarif
This commit is contained in:
parent
54a42ed5d2
commit
00d1a697e1
3 changed files with 80 additions and 56 deletions
11
config.html
11
config.html
|
|
@ -11,7 +11,7 @@
|
|||
<p class="block confirm">Configuration enregistrée.</p>
|
||||
{{/if}}
|
||||
|
||||
{{* lecture config (défaut ou enregistrée) *}}
|
||||
{{* lecture config *}}
|
||||
{{:include file="./_get_config.html" keep="config_defaut, config, directions"}}
|
||||
|
||||
{{* interdire la modification et la suppression des types de mouvement prédéfinis *}}
|
||||
|
|
@ -41,6 +41,13 @@
|
|||
<tbody>
|
||||
{{:assign var="nature" from="config.%s_nature"|args:$direction}}
|
||||
{{#foreach from=$nature key=key}}
|
||||
{{:assign sortie_temp=false}}
|
||||
{{if $direction == 'output'}}
|
||||
{{:assign var="type" from="nature.%s.type"|args:$key}}
|
||||
{{if $type == 'temporaire'}}
|
||||
{{:assign sortie_temp=true}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
<tr>
|
||||
<td>{{$label}}</td>
|
||||
<td>{{$type}}</td>
|
||||
|
|
@ -48,7 +55,7 @@
|
|||
{{if ! $default_keys|has:$key && ! $locked|has:$key}}
|
||||
{{:linkbutton label="Supprimer" shape="delete" href="config/delete_movement_type.html?dir=%s&op_key=%s"|args:$direction:$key target="_dialog"}}
|
||||
{{/if}}
|
||||
{{if ! $default_keys|has:$key}}
|
||||
{{if ! $default_keys|has:$key || $sortie_temp}}
|
||||
{{:linkbutton label="Modifier" shape="edit" href="config/modify_movement_type.html?dir=%s&op_key=%s"|args:$direction:$key target="_dialog"}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -2,57 +2,35 @@
|
|||
|
||||
{{#restrict block=true section="accounting" level="write"}}{{/restrict}}
|
||||
|
||||
{{* lecture config (défaut ou enregistrée) *}}
|
||||
{{:include file="../_get_config.html" keep="loan_duration"}}
|
||||
|
||||
{{#form on="save"}}
|
||||
{{* vérifier si les boutons ont été cochés *}}
|
||||
{{#foreach from=$module.config.output_nature item="elem"}}
|
||||
{{if $elem.type == 'temporaire'}}
|
||||
{{if $_POST|has_key:$elem.key}}
|
||||
{{:assign var="fee" from="_POST.%s"|args:$elem.key}}
|
||||
{{:assign var="elem" key=$elem.key label=$elem.label type=$elem.type fee=$fee}}
|
||||
{{else}}
|
||||
{{:error message="Vous n'avez pas fait de choix pour la sortie « %s »"|args:$elem.label}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{:assign var="output_nature." value=$elem}}
|
||||
{{/foreach}}
|
||||
{{* vérifier la valisité de la durée saisie *}}
|
||||
{{if $_POST.loan_duration <= 0}}
|
||||
{{:error message="Durée (%s) erronée ; doit être > 0"|args:$_POST.loan_duration}}
|
||||
{{/if}}
|
||||
|
||||
{{:save
|
||||
key="config"
|
||||
output_nature=$output_nature
|
||||
loan_duration=$_POST.loan_duration
|
||||
}}
|
||||
|
||||
{{/form}}
|
||||
|
||||
{{:include file="../_nav.html" current="config" subcurrent="divers"}}
|
||||
{{:admin_header title="Configuration" current="module_equipment"}}
|
||||
{{:include file="../_nav.html" current="config" subcurrent="divers"}}
|
||||
{{:form_errors}}
|
||||
|
||||
{{if $_GET.ok}}
|
||||
<p class="block confirm">Configuration enregistrée.</p>
|
||||
{{/if}}
|
||||
|
||||
{{* lecture config *}}
|
||||
{{:include file="../_get_config.html" keep="loan_duration"}}
|
||||
|
||||
<form method="post" action="" data-focus="1">
|
||||
<fieldset>
|
||||
<legend>Sorties temporaires</legend>
|
||||
<p class="help">Pour chaque sortie temporaire, indiquer si elle est gratuite ou payante</p>
|
||||
<dl>
|
||||
{{#foreach from=$module.config.output_nature}}
|
||||
{{if $type == 'temporaire'}}
|
||||
{{:input type="radio-btn" name=$key value="gratuit" label="Gratuit" required=true prefix_title=$label default=$fee}}
|
||||
{{:input type="radio-btn" name=$key value="payant" label="Payant" required=true default=$fee}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
</dl>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Autres paramètres</legend>
|
||||
<dl>
|
||||
{{:input type="number" name="loan_duration" label="Durée de prêt par défaut" min=1 required=true default=$loan_duration help="Durée en nombre de jours"}}
|
||||
|
||||
</dl>
|
||||
</fieldset>
|
||||
<p class="submit">
|
||||
|
|
|
|||
|
|
@ -5,40 +5,38 @@
|
|||
{{*
|
||||
paramètres :
|
||||
- dir : input ou output
|
||||
- op_key : clé du type de mouvement dont on veut modifier le libellé
|
||||
- op_key : clé du type de mouvement dont on veut modifier le libellé ou le tarif
|
||||
*}}
|
||||
|
||||
{{* lecture config (défaut ou enregistrée) *}}
|
||||
{{:include file="../_get_config.html" keep="config, directions"}}
|
||||
|
||||
{{if ! $directions|has_key:$_GET.dir}}
|
||||
{{:error message="Direction « %s » inconnue !"|args:$_GET.dir}}
|
||||
{{/if}}
|
||||
|
||||
{{* interdire la modification des types de mouvement prédéfinis *}}
|
||||
{{:assign var="nature" from="config_defaut.%ss"|args:$_GET.dir}}
|
||||
{{#foreach from=$nature item="elem"}}
|
||||
{{:assign var="default_keys." value=$key}}
|
||||
{{/foreach}}
|
||||
{{if $default_keys|has:$_GET.op_key}}
|
||||
{{:error message="Ce type de mouvement ne peut être modifié"}}
|
||||
{{/if}}
|
||||
{{:include file="../_get_config.html" keep="config_defaut, config, directions"}}
|
||||
|
||||
{{#form on="save"}}
|
||||
{{if $_POST.tarif == null && $_POST.name == null}}
|
||||
{{:redirect to="./config.html"}}
|
||||
{{/if}}
|
||||
{{#foreach from=$directions key="direction"}}
|
||||
{{:assign var="nature" from="config.%s_nature"|args:$direction}}
|
||||
{{#foreach from=$nature key="key" item="elem"}}
|
||||
{{if $_GET.dir == $direction && $_POST.name|trim|tolower == $elem.label|trim|tolower}}
|
||||
{{:error message="Le libellé « %s » est déjà présent"|args:$_POST.name}}
|
||||
{{/if}}
|
||||
{{if $_GET.dir == $direction && $key == $_GET.op_key}}
|
||||
{{:assign label=$_POST.name|trim}}
|
||||
{{else}}
|
||||
{{if $_POST.name == null}}
|
||||
{{:assign label=$elem.label}}
|
||||
{{else}}
|
||||
{{if $_GET.dir == $direction && $key != $_GET.op_key &&
|
||||
$_POST.name|trim|tolower == $elem.label|trim|tolower}}
|
||||
{{:error message="Le libellé « %s » est déjà présent"|args:$_POST.name}}
|
||||
{{/if}}
|
||||
{{if $_GET.dir == $direction && $key == $_GET.op_key}}
|
||||
{{:assign label=$_POST.name|trim}}
|
||||
{{else}}
|
||||
{{:assign label=$elem.label}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{:assign var="%s_nature"|args:$direction value=$elem}}
|
||||
{{:assign var="%s_nature.label"|args:$direction value=$label}}
|
||||
{{:assign var="%s_nature.key"|args:$direction value=$key}}
|
||||
{{if $_POST.tarif != null && $key == $_GET.op_key}}
|
||||
{{:assign var="%s_nature.fee"|args:$direction value=$_POST.tarif}}
|
||||
{{/if}}
|
||||
{{:assign var="%s_natures."|args:$direction from="%s_nature"|args:$direction}}
|
||||
{{/foreach}}
|
||||
{{/foreach}}
|
||||
|
|
@ -53,18 +51,59 @@
|
|||
{{/form}}
|
||||
|
||||
{{:admin_header title="Gestion des matériels" current="module_equipment"}}
|
||||
{{* barre de navigation *}}
|
||||
{{if ! $dialog}}
|
||||
{{:include file="../_nav.html" current="config" subcurrent="typesES"}}
|
||||
{{/if}}
|
||||
{{:form_errors}}
|
||||
|
||||
{{* vérifier que $_GET.dir est bien une direction connue *}}
|
||||
{{if ! $directions|has_key:$_GET.dir}}
|
||||
{{:error message="Direction « %s » inconnue !"|args:$_GET.dir}}
|
||||
{{/if}}
|
||||
|
||||
{{* vérifier que $_GET.op_key est bien dans la liste des opérations *}}
|
||||
{{:assign var="config_nature" from="config.%s_nature"|args:$_GET.dir}}
|
||||
{{if ! $config_nature|keys|has:$_GET.op_key}}
|
||||
{{:error message="Type de mouvement inconnu !"}}
|
||||
{{/if}}
|
||||
|
||||
{{* sortie temporaire ? *}}
|
||||
{{:assign sortie_temp=false}}
|
||||
{{if $_GET.dir == 'output'}}
|
||||
{{:assign var="elem" from="config_nature.%s"|args:$_GET.op_key}}
|
||||
{{if $elem.type == 'temporaire'}}
|
||||
{{:assign sortie_temp=true}}
|
||||
{{:assign fee=$elem.fee}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{* mouvement prédéfini ? *}}
|
||||
{{:assign var="default_nature" from="config_defaut.%ss"|args:$_GET.dir}}
|
||||
{{#foreach from=$default_nature item="elem"}}
|
||||
{{:assign var="default_keys." value=$key}}
|
||||
{{/foreach}}
|
||||
|
||||
{{:assign label_mod=true}}
|
||||
{{if $default_keys|has:$_GET.op_key}}
|
||||
{{:assign label_mod=false}}
|
||||
{{/if}}
|
||||
|
||||
{{if ! $label_mod && ! $sortie_temp}}
|
||||
{{:error message="Ce type de mouvement ne peut être modifié"}}
|
||||
{{/if}}
|
||||
|
||||
{{:assign var="default_label" from="config.%s_nature.%s.label"|args:$_GET.dir:$_GET.op_key}}
|
||||
<form method="post" action="" data-focus="1">
|
||||
<fieldset>
|
||||
<legend>Modifier le libellé</legend>
|
||||
<legend>Paramètres</legend>
|
||||
<dl>
|
||||
{{:input type="text" name="name" label="Libellé" default=$default_label required=true maxlength="100"}}
|
||||
{{if $label_mod}}
|
||||
{{:input type="text" name="name" label="Libellé" default=$default_label required=true maxlength="100"}}
|
||||
{{/if}}
|
||||
{{if $sortie_temp}}
|
||||
{{:input type="radio-btn" name="tarif" value="gratuit" label="Gratuit" required=true default=$fee prefix_title=Tarif}}
|
||||
{{:input type="radio-btn" name="tarif" value="payant" label="Payant" required=true default=$fee}}
|
||||
{{/if}}
|
||||
</dl>
|
||||
<p class="submit">
|
||||
{{:button type="submit" name="save" label="Enregistrer" shape="right" class="main"}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue