From a029dac6ef6257965a85803cd9275752b8afcaf8 Mon Sep 17 00:00:00 2001 From: Anatole Date: Thu, 25 Jun 2020 14:17:29 +0300 Subject: [PATCH] modif multivalidation pour ajouter validation siret --- views/tpls/forms/cplx/multitextvalidation.php | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/views/tpls/forms/cplx/multitextvalidation.php b/views/tpls/forms/cplx/multitextvalidation.php index 782c4c4..6e6bf96 100644 --- a/views/tpls/forms/cplx/multitextvalidation.php +++ b/views/tpls/forms/cplx/multitextvalidation.php @@ -168,7 +168,8 @@ $paramsData = [ "validation" => [ "text" => "texte", "number" => "Nombre", - "email" => "adresse mail" + "email" => "adresse mail", + "unique" => "Siret" ] ]; @@ -296,13 +297,32 @@ if($mode == "r"){ ?> $(this).parent().addClass('true-validate'); } - answer.path = "answers."+$(this).data("form")+"."+$(this).data("id"); - answer.collection = "answers" ; - answer.id = ""; - answer.value = $(this).val(); - dataHelper.path2Value(answer , function(params) { - //toastr.success('saved'); - }); + if($(this).attr('type') == 'unique' ) { + ajaxPost(null, baseUrl+"/co2/search/globalautocomplete", {"searchType" : ["organizations"], "filters": { "siret" : [$(this).val()] }}, + function (data){ + if (data.results.lenght != 0){ + toastr.error('cette organisation existe déjà'); + } else { + answer.path = "answers."+$(this).data("form")+"."+$(this).data("id"); + answer.collection = "answers" ; + answer.id = ""; + answer.value = $(this).val(); + dataHelper.path2Value(answer , function(params) { + //toastr.success('saved'); + }); + } + } + ); + } else { + + answer.path = "answers."+$(this).data("form")+"."+$(this).data("id"); + answer.collection = "answers" ; + answer.id = ""; + answer.value = $(this).val(); + dataHelper.path2Value(answer , function(params) { + //toastr.success('saved'); + }); + } } }) }); @@ -338,8 +358,6 @@ if($mode == "r"){ ?> $(thisAlert).removeClass('alert-validate'); } - - -- GitLab