diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bcd1b555906..bce137d1e11 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3441,16 +3441,17 @@ function img_info($titlealt = 'default') * * @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title. * @param string $moreatt Add more attribute on img tag (For example 'style="float: right"'). If 1, add float: right. Can't be "class" attribute. + * @param string $morecss Add more CSS * @return string Return img tag */ -function img_warning($titlealt = 'default', $moreatt = '') +function img_warning($titlealt = 'default', $moreatt = '', $morecss = 'pictowarning') { global $conf, $langs; if ($titlealt == 'default') $titlealt = $langs->trans('Warning'); //return '
'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'
'; - return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')); + return img_picto($titlealt, 'warning.png', 'class="valignmiddle'.($morecss?' '.$morecss:'').'"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')); } /** diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index fac25451ece..83e3d87f919 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -568,7 +568,7 @@ function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0 * Check if VAT numero is valid (check done on syntax only, no database or remote access) * * @param Societe $company VAT number - * @return int 1=Check is OK, 0=Check is KO + * @return int 1=Check is OK, 0=Check is KO */ function isValidVATID($company) { @@ -577,7 +577,7 @@ function isValidVATID($company) $vatprefix = $company->country_code; if ($vatprefix == 'GR') $vatprefix = '(EL|GR)'; else $vatprefix = preg_quote($vatprefix, '/'); - if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,12}$/', $company->tva_intra)) + if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.\s]{5,12}$/', $company->tva_intra)) { return 0; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 13f179b99cc..68d61e627e1 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -35,6 +35,7 @@ require_once '../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; @@ -989,6 +990,8 @@ while ($i < min($num, $limit)) $companystatic->fournisseur=$obj->fournisseur; $companystatic->code_client=$obj->code_client; $companystatic->code_fournisseur=$obj->code_fournisseur; + $companystatic->tva_intra=$obj->tva_intra; + $companystatic->country_code=$obj->country_code; $companystatic->code_compta_client=$obj->code_compta; $companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur; @@ -1166,7 +1169,13 @@ while ($i < min($num, $limit)) } if (! empty($arrayfields['s.tva_intra']['checked'])) { - print "".$obj->tva_intra."\n"; + print ""; + print $obj->tva_intra; + if ($obj->tva_intra && ! isValidVATID($companystatic)) + { + print img_warning("BadVATNumber", '', ''); + } + print "\n"; if (! $i) $totalarray['nbfield']++; } // Type