FIX check mandatory thirdparty fields for mass action
This commit is contained in:
parent
d13ae9f721
commit
397776d4a4
@ -566,45 +566,6 @@ if (empty($reshook))
|
|||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
|
|
||||||
// Check for mandatory fields in thirdparty (defined into setup)
|
|
||||||
$array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL');
|
|
||||||
foreach ($array_to_check as $key)
|
|
||||||
{
|
|
||||||
$keymin = strtolower($key);
|
|
||||||
$i = (int) preg_replace('/[^0-9]/', '', $key);
|
|
||||||
$vallabel = $object->thirdparty->$keymin;
|
|
||||||
|
|
||||||
if ($i > 0)
|
|
||||||
{
|
|
||||||
if ($object->thirdparty->isACompany())
|
|
||||||
{
|
|
||||||
// Check for mandatory prof id (but only if country is other than ours)
|
|
||||||
if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id)
|
|
||||||
{
|
|
||||||
$idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY';
|
|
||||||
if (!$vallabel && !empty($conf->global->$idprof_mandatory))
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
$error++;
|
|
||||||
setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $object->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//var_dump($conf->global->SOCIETE_EMAIL_MANDATORY);
|
|
||||||
if ($key == 'EMAIL')
|
|
||||||
{
|
|
||||||
// Check for mandatory
|
|
||||||
if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($object->thirdparty->email))
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
$error++;
|
|
||||||
setEventMessages($langs->trans("ErrorBadEMail", $object->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for mandatory fields in invoice
|
// Check for mandatory fields in invoice
|
||||||
$array_to_check = array('REF_CUSTOMER'=>'RefCustomer');
|
$array_to_check = array('REF_CUSTOMER'=>'RefCustomer');
|
||||||
foreach ($array_to_check as $key => $val)
|
foreach ($array_to_check as $key => $val)
|
||||||
|
|||||||
@ -2470,7 +2470,7 @@ class Facture extends CommonInvoice
|
|||||||
*/
|
*/
|
||||||
public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 0)
|
public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs, $mysoc;
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
$productStatic = null;
|
$productStatic = null;
|
||||||
@ -2512,6 +2512,46 @@ class Facture extends CommonInvoice
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for mandatory fields in thirdparty (defined into setup)
|
||||||
|
$array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL');
|
||||||
|
foreach ($array_to_check as $key)
|
||||||
|
{
|
||||||
|
$keymin = strtolower($key);
|
||||||
|
$i = (int) preg_replace('/[^0-9]/', '', $key);
|
||||||
|
$vallabel = $this->thirdparty->$keymin;
|
||||||
|
|
||||||
|
if ($i > 0)
|
||||||
|
{
|
||||||
|
if ($this->thirdparty->isACompany())
|
||||||
|
{
|
||||||
|
// Check for mandatory prof id (but only if country is other than ours)
|
||||||
|
if ($mysoc->country_id > 0 && $this->thirdparty->country_id == $mysoc->country_id)
|
||||||
|
{
|
||||||
|
$idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY';
|
||||||
|
if (!$vallabel && !empty($conf->global->$idprof_mandatory))
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
$this->error = $langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $this->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").')'.' ['.$langs->trans('Company').' : '.$this->thirdparty->name.']';
|
||||||
|
dol_syslog(__METHOD__.' '.$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($key == 'EMAIL')
|
||||||
|
{
|
||||||
|
// Check for mandatory
|
||||||
|
if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($this->thirdparty->email))
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
$this->error = $langs->trans("ErrorBadEMail", $this->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").')'.' ['.$langs->trans('Company').' : '.$this->thirdparty->name.']';
|
||||||
|
dol_syslog(__METHOD__.' '.$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user