FIX Check on duplicate profid was not triggered.

This commit is contained in:
Laurent Destailleur 2019-11-06 00:27:36 +01:00
parent d972fa8bcb
commit e885345ef7
3 changed files with 33 additions and 27 deletions

View File

@ -1125,8 +1125,8 @@ class CMailFile
$strContentAltText = '';
if ($this->msgishtml)
{
// Similar code to forge a text from html is also in CMailFile.class.php
$strContentAltText = preg_replace("/<br\s*[^>]*>/", " ", $strContent);
// Similar code to forge a text from html is also in smtps.class.php
$strContentAltText = preg_replace("/<br\s*[^>]*>/", "\n", $strContent);
$strContentAltText = html_entity_decode(strip_tags($strContentAltText));
$strContentAltText = rtrim(wordwrap($strContentAltText, 75, empty($conf->global->MAIN_FIX_FOR_BUGGED_MTA)?"\r\n":"\n"));

View File

@ -1383,7 +1383,7 @@ class SMTPs
if ($strType == 'html')
{
// Similar code to forge a text from html is also in CMailFile.class.php
$strContentAltText = preg_replace("/<br\s*[^>]*>/", " ", $strContent);
$strContentAltText = preg_replace("/<br\s*[^>]*>/", "\n", $strContent);
$strContentAltText = html_entity_decode(strip_tags($strContentAltText));
$strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n"));
}

View File

@ -785,17 +785,7 @@ class Societe extends CommonObject
{
if ($this->isACompany())
{
// Check for unicity
if ($vallabel && $this->id_prof_verifiable($i))
{
if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0)))
{
$langs->load("errors");
$error++; $this->errors[] = $langs->transcountry('ProfId'.$i, $this->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')';
}
}
// Check for mandatory prof id (but only if country is other than ours)
// Check for mandatory prof id (but only if country is same than ours)
if ($mysoc->country_id > 0 && $this->country_id == $mysoc->country_id)
{
$idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY';
@ -807,6 +797,17 @@ class Societe extends CommonObject
}
}
}
// Check for unicity
if (! $error && $vallabel && $this->id_prof_verifiable($i))
{
if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0)))
{
$langs->load("errors");
$error++;
$this->errors[] = $langs->transcountry('ProfId'.$i, $this->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')';
}
}
}
else
{
@ -814,16 +815,6 @@ class Societe extends CommonObject
//var_dump($conf->global->SOCIETE_EMAIL_MANDATORY);
if ($key == 'EMAIL')
{
// Check for unicity
if ($vallabel && ! empty($conf->global->SOCIETE_EMAIL_UNIQUE))
{
if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0)))
{
$langs->load("errors");
$error++; $this->errors[] = $langs->trans('Email')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')';
}
}
// Check for mandatory
if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY) && ! isValidEMail($this->email))
{
@ -831,6 +822,16 @@ class Societe extends CommonObject
$error++;
$this->errors[] = $langs->trans("ErrorBadEMail", $this->email).' ('.$langs->trans("ForbiddenBySetupRules").')';
}
// Check for unicity
if (! $error && $vallabel && ! empty($conf->global->SOCIETE_EMAIL_UNIQUE))
{
if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0)))
{
$langs->load("errors");
$error++; $this->errors[] = $langs->trans('Email')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')';
}
}
}
}
}
@ -3284,12 +3285,17 @@ class Societe extends CommonObject
// Define if third party is treated as company (or not) when nature is unknown
$isacompany=empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES)?0:1; // 0 by default
if (! empty($this->tva_intra)) $isacompany=1;
if (! empty($this->tva_intra)) {
$isacompany = 1;
}
elseif (! empty($this->idprof1) || ! empty($this->idprof2) || ! empty($this->idprof3) || ! empty($this->idprof4) || ! empty($this->idprof5) || ! empty($this->idprof6)) {
$isacompany = 1;
}
elseif (! empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN')
{
// TODO Add a field is_a_company into dictionary
if (preg_match('/^TE_PRIVATE/', $this->typent_code)) $isacompany=0;
else $isacompany=1;
if (preg_match('/^TE_PRIVATE/', $this->typent_code)) $isacompany = 0;
else $isacompany = 1;
}
return $isacompany;