From 0396573b91f5d340779eb89b6aab0e805cce1ddf Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 21 Jul 2021 09:46:38 +0200 Subject: [PATCH] fix focusout on mandatoryPeriod only --- htdocs/core/tpl/objectline_create.tpl.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 9a87d89189a..5d3d9de4ea4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -679,8 +679,9 @@ if (!empty($usemargins) && $user->rights->margins->creer) { table_element_line != 'commande_fournisseurdet' || $this->table_element_line == 'facture_fourn_det') { ?> $("#date_start, #date_end").focusout(function() { - type = $(this).attr('type'); - if (type == 1){ + let type = $(this).attr('type'); + let mandatoryP = $(this).attr('mandatoryperiod'); + if (type == 1 && mandatoryP == 1 ){ if ( $(this).val() == '' && !$(this).hasClass("error") ) { $(this).addClass('error'); }else{ @@ -722,6 +723,11 @@ if (!empty($usemargins) && $user->rights->margins->creer) { $('#date_start').attr('type', data.type); $('#date_end').attr('type', data.type); + $( '#date_start').removeAttr( "mandatoryperiod" ); + $( '#date_end' ).removeAttr( "mandatoryperiod" ); + $('#date_start').attr('mandatoryperiod', data.mandatory_period); + $('#date_end').attr('mandatoryperiod', data.mandatory_period); + // service and we setted mandatory_period to true if (data.mandatory_period == 1 && data.type == 1 ) { jQuery("#date_start").addClass("error");