Compare commits

...

2 Commits

6 changed files with 22 additions and 25 deletions

View File

@ -1,7 +1,13 @@
{{* -*- brindille -*- *}}
<nav class="tabs">
{{if $current == 'inventaire'}}
<aside>
{{:linkbutton label="Ajouter un nouveau matériel" shape="plus" href="mouvements/ajouter_entree.html" target="_dialog"}}
{{if $cat == null || $cat == 0}}
{{:linkbutton label="Ajouter une catégorie" shape="plus" href="categories/add_category.html" target="_dialog"}}
{{else}}
{{:linkbutton label="Ajouter un nouveau matériel" shape="plus" href="mouvements/ajouter_entree.html" target="_dialog"}}
{{/if}}
</aside>
{{/if}}

View File

@ -9,11 +9,8 @@
{{#form on="save"}}
{{* Vérifier s'il existe déjà une catégorie avec le même nom *}}
{{#load type="category"}}
{{if $name|tolower == $_POST.name|trim|tolower}}
{{:error message="Impossible d'ajouter la catégorie « %s » car elle existe déjà !"|args:$name|trim}}
{{:break}}
{{/if}}
{{#load type="category" where="$$.name = :name COLLATE U_NOCASE" :name=$_POST.name|trim limit=1}}
{{:error message="Impossible d'ajouter la catégorie « %s » car elle existe déjà !"|args:$name|trim}}
{{/load}}
{{:assign key=""|uuid}}

View File

@ -8,11 +8,8 @@
{{* Traiter l'envoi du formulaire *}}
{{#form on="save"}}
{{* Vérifier s'il existe déjà une catégorie avec le même nom *}}
{{#load type="category"}}
{{if $name|tolower == $_POST.name|trim|tolower && $key != $_GET.key}}
{{:error message="Modification impossible car ce nom de catégorie (« %s ») existe déjà !"|args:$name|trim}}
{{:break}}
{{/if}}
{{#load type="category" where="$$.name = :name" :name=$_POST.name|trim|tolower|ucfirst limit=1}}
{{:error message="Modification impossible car ce nom de catégorie (« %s ») existe déjà !"|args:$name|trim}}
{{/load}}
{{:save

View File

@ -8,7 +8,9 @@
{{else}}
{{:assign proprio="nonproprio"}}
{{/if}}
{{:include file="_nav.html" current="inventaire" subcurrent="%s"|args:$proprio}}
{{#load type="category" count=true assign="result"}}{{/load}}
{{:include file="_nav.html" current="inventaire" cat="%d"|args:$result.count subcurrent="%s"|args:$proprio}}
{{if $_GET.ok}}
{{if $_GET.msg == "ajout" }}
@ -22,8 +24,6 @@
<p class="block error">Modification refusée</p>
{{/if}}
{{#load type="category" count=true assign="result"}}{{/load}}
{{if $result.count == 0}}
<p class="block alert">Il n'y a aucune catégorie : vous devez en ajouter.</p>
{{else}}

View File

@ -28,7 +28,7 @@
{{#load key=$equipment_key}}
{{if $designation|trim|tolower != $_POST.designation|trim|tolower}}
{{* le nom change => vérifier l'existence d'un matériel du même nom *}}
{{#load type="equipment" where="lower($$.designation) = :name" :name=$_POST.designation|trim|tolower}}
{{#load type="equipment" where="$$.designation = :name" :name=$_POST.designation|trim|tolower|ucfirst limit=1}}
{{:assign chgt_ok=false}}
{{/load}}
{{else}}
@ -37,8 +37,8 @@
{{/load}}
{{else}}
{{* catégorie ne change pas => vérifier le nom*}}
{{#load type="equipment" where="lower($$.designation) = :name" :name=$_POST.designation|trim|tolower}}
{{* catégorie ne change pas => vérifier le nom *}}
{{#load type="equipment" where="$$.designation = :name" :name=$_POST.designation|trim|tolower|ucfirst limit=1}}
{{:assign chgt_ok=false}}
{{/load}}
{{/if}}
@ -51,7 +51,7 @@
{{:save
key=$equipment_key
category=$category.key
designation=$_POST.designation|trim
designation=$_POST.designation|trim|tolower|ucfirst
}}
{{:redirect force="index.html?ok=1&msg=modification&prop=%s"|args:$_GET.prop}}
{{/form}}

View File

@ -32,13 +32,10 @@
{{:assign post_mat=$_POST.designation|trim|tolower|ucfirst}}
{{* vérifier l'existence d'un matériel de même nom *}}
{{#load type="equipment"}}
{{if $_POST.designation|trim|tolower == $designation|tolower}}
{{:assign equipment_key=$key}}
{{:assign var=nom_cat from="categories.%s"|args:$category}}
{{:assign present=true}}
{{:break}}
{{/if}}
{{#load type="equipment" where="$$.designation = :name COLLATE U_NOCASE" :name=$_POST.designation|trim limit=1}}}}
{{:assign equipment_key=$key}}
{{:assign var=nom_cat from="categories.%s"|args:$category}}
{{:assign present=true}}
{{/load}}
{{:assign var=post_cat from="categories.%s"|args:$_POST.category}}