2
0
forked from Wavyzz/dolibarr

New: An external module can force the third party code to be required whatever is the rule of third party code module.

This commit is contained in:
Laurent Destailleur
2009-07-06 07:58:26 +00:00
parent 1910f3232c
commit 1b8c9df552
6 changed files with 139 additions and 90 deletions

View File

@@ -38,6 +38,8 @@ For translators:
- Update some language files. - Update some language files.
For developers: For developers:
- An external module can force the third party code to be required whatever is the rule of
third party code module.
- Update fckeditor to 2.6.4. - Update fckeditor to 2.6.4.
- Removed some deprecated files. - Removed some deprecated files.
- Creation of directory in module descriptor is simpler. - Creation of directory in module descriptor is simpler.

View File

@@ -197,12 +197,16 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
/** /**
* \brief Verifie la validite du code * \brief Check validity of code according to its rules
* \param $db Handler acces base * \param $db Database handler
* \param $code Code a verifier/corriger * \param $code Code to check/correct
* \param $soc Objet societe * \param $soc Object third party
* \param $type 0 = client/prospect , 1 = fournisseur * \param $type 0 = customer/prospect , 1 = supplier
* \return int <0 if KO, 0 if OK * \return int 0 if OK
* -1 ErrorBadCustomerCodeSyntax
* -2 ErrorCustomerCodeRequired
* -3 ErrorCustomerCodeAlreadyUsed
* -4 ErrorPrefixRequired
*/ */
function verif($db, &$code, $soc, $type) function verif($db, &$code, $soc, $type)
{ {
@@ -213,10 +217,14 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
$result=0; $result=0;
$code = strtoupper(trim($code)); $code = strtoupper(trim($code));
if (! $code && $this->code_null) if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
{ {
$result=0; $result=0;
} }
else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
{
$result=-2;
}
else else
{ {
// Get Mask value // Get Mask value

View File

@@ -85,17 +85,35 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode
/** /**
* \brief check validity of code * \brief Check validity of code according to its rules
* \param $db Handler acces base * \param $db Database handler
* \param $code Code to check * \param $code Code to check/correct
* \param $soc Objet societe * \param $soc Object third party
* \param $type 0 = customer/prospect , 1 = supplier
* \return int 0 if OK
* -1 ErrorBadCustomerCodeSyntax
* -2 ErrorCustomerCodeRequired
* -3 ErrorCustomerCodeAlreadyUsed
* -4 ErrorPrefixRequired
*/ */
function verif($db, &$code, $soc) function verif($db, &$code, $soc, $type)
{ {
global $conf;
$result=0;
$code = strtoupper(trim($code)); $code = strtoupper(trim($code));
// Renvoie toujours ok if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
return 0; {
$result=0;
}
else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
{
$result=-2;
}
dol_syslog("mod_codeclient_leopard::verif type=".$type." result=".$result);
return $result;
} }
} }

View File

@@ -135,21 +135,32 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
/** /**
* \brief Verifie la validite du code * \brief Check validity of code according to its rules
* \param $db Handler acces base * \param $db Database handler
* \param $code Code a verifier/corriger * \param $code Code to check/correct
* \param $soc Objet societe * \param $soc Object third party
* \return int <0 si KO, 0 si OK * \param $type 0 = customer/prospect , 1 = supplier
* \return int 0 if OK
* -1 ErrorBadCustomerCodeSyntax
* -2 ErrorCustomerCodeRequired
* -3 ErrorCustomerCodeAlreadyUsed
* -4 ErrorPrefixRequired
*/ */
function verif($db, &$code, $soc) function verif($db, &$code, $soc, $type)
{ {
global $conf;
$result=0; $result=0;
$code = strtoupper(trim($code)); $code = strtoupper(trim($code));
if (! $code && $this->code_null) if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
{ {
$result=0; $result=0;
} }
else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
{
$result=-2;
}
else else
{ {
if ($this->verif_syntax($code) >= 0) if ($this->verif_syntax($code) >= 0)
@@ -176,7 +187,8 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
} }
} }
} }
dol_syslog("mod_codeclient_monkey::verif result=".$result);
dol_syslog("mod_codeclient_monkey::verif type=".$type." result=".$result);
return $result; return $result;
} }

View File

@@ -147,10 +147,11 @@ class Societe extends CommonObject
$this->db->begin(); $this->db->begin();
// For automatic creation during create action (not used by Dolibarr) // For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts)
if ($this->code_client == -1) $this->get_codeclient($this->prefix_comm,0); if ($this->code_client == -1) $this->get_codeclient($this->prefix_comm,0);
if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1); if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1);
// Check more parameters
$result = $this->verify(); $result = $this->verify();
if ($result >= 0) if ($result >= 0)
@@ -229,7 +230,7 @@ class Societe extends CommonObject
} }
/** /**
* \brief Check properties of third party are ok * \brief Check properties of third party are ok (like name, third party codes, ...)
* \return int 0 if OK, <0 if KO * \return int 0 if OK, <0 if KO
*/ */
function verify() function verify()
@@ -1553,8 +1554,12 @@ class Societe extends CommonObject
/** /**
* \brief Verifie code client * \brief Check customer code
* \return int <0 si KO, 0 si OK, peut modifier le code client suivant le module utilise * \return int 0 if OK
* -1 ErrorBadCustomerCodeSyntax
* -2 ErrorCustomerCodeRequired
* -3 ErrorCustomerCodeAlreadyUsed
* -4 ErrorPrefixRequired
*/ */
function check_codeclient() function check_codeclient()
{ {
@@ -1578,8 +1583,12 @@ class Societe extends CommonObject
} }
/** /**
* \brief Verifie code fournisseur * \brief Check supplier code
* \return int <0 si KO, 0 si OK, peut modifier le code client suivant le module utilise * \return int 0 if OK
* -1 ErrorBadCustomerCodeSyntax
* -2 ErrorCustomerCodeRequired
* -3 ErrorCustomerCodeAlreadyUsed
* -4 ErrorPrefixRequired
*/ */
function check_codefournisseur() function check_codefournisseur()
{ {