NEW Add function isValidVATID()
This commit is contained in:
parent
742de5c777
commit
684e09fdcd
@ -564,6 +564,28 @@ function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0
|
||||
return $ValidUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
function isValidVATID($company)
|
||||
{
|
||||
if ($company->isInEEC()) // Syntax check rules for EEC countries
|
||||
{
|
||||
$vatprefix = $company->country_code;
|
||||
if ($vatprefix == 'GR') $vatprefix = '(EL|GR)';
|
||||
else $vatprefix = preg_quote($vatprefix, '/');
|
||||
if (! preg_match('/^'.$vatprefix.'[a-zA-Z0-9\-\.]{5,10}$/', $company->tva_intra))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean an url string
|
||||
*
|
||||
|
||||
@ -41,6 +41,13 @@ $product = new Product($db);
|
||||
|
||||
$product->fetch($id);
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (!$product->isProduct()) {
|
||||
header('Location: '.dol_buildpath('/product/card.php?id='.$product->id, 2));
|
||||
exit();
|
||||
@ -59,8 +66,8 @@ $combinations = GETPOST('combinations', 'array');
|
||||
$price_var_percent = (bool) GETPOST('price_var_percent');
|
||||
$donotremove = true;
|
||||
|
||||
if ($_POST) {
|
||||
|
||||
if ($_POST)
|
||||
{
|
||||
$donotremove = (bool) GETPOST('donotremove');
|
||||
|
||||
//We must check if all those given combinations actually exist
|
||||
@ -102,7 +109,8 @@ if ($_POST) {
|
||||
|
||||
$res = 1;
|
||||
|
||||
foreach (cartesianArray($adapted_values) as $currcomb)
|
||||
$cartesianarray = cartesianArray($adapted_values);
|
||||
foreach ($cartesianarray as $currcomb)
|
||||
{
|
||||
$res = $combination->createProductCombination($product, $currcomb, $sanitized_values, $price_var_percent);
|
||||
if ($res < 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user