diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 5f8c630e46a..93a1906fac4 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -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("/
]*>/", " ", $strContent);
+ // Similar code to forge a text from html is also in smtps.class.php
+ $strContentAltText = preg_replace("/
]*>/", "\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"));
diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php
index d950f92b3c2..a66fd267d54 100644
--- a/htdocs/core/class/smtps.class.php
+++ b/htdocs/core/class/smtps.class.php
@@ -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("/
]*>/", " ", $strContent);
+ $strContentAltText = preg_replace("/
]*>/", "\n", $strContent);
$strContentAltText = html_entity_decode(strip_tags($strContentAltText));
$strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n"));
}
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 21213272a26..e73a060af40 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -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;