Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into develop
Conflicts: htdocs/comm/propal/list.php htdocs/commande/list.php htdocs/compta/facture/list.php htdocs/product/price.php
This commit is contained in:
commit
45bc686f7f
@ -593,8 +593,10 @@ if (!$error && $massaction == 'confirm_presend') {
|
||||
if ($mailfile->error) {
|
||||
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto);
|
||||
$resaction .= '<br><div class="error">'.$mailfile->error.'</div>';
|
||||
} else {
|
||||
} elseif (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
|
||||
$resaction .= '<div class="warning">No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS</div>';
|
||||
} else {
|
||||
$resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto) . '<br><div class="error">(unhandled error)</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -926,7 +926,7 @@ class CMailFile
|
||||
}
|
||||
// send mail
|
||||
try {
|
||||
$result = $this->mailer->send($this->message);
|
||||
$result = $this->mailer->send($this->message, $failedRecipients);
|
||||
} catch (Exception $e) {
|
||||
$this->error = $e->getMessage();
|
||||
}
|
||||
@ -936,6 +936,9 @@ class CMailFile
|
||||
|
||||
$res = true;
|
||||
if (!empty($this->error) || !$result) {
|
||||
if (!empty($failedRecipients)) {
|
||||
$this->error = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
|
||||
}
|
||||
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
|
||||
$res = false;
|
||||
} else {
|
||||
|
||||
@ -1470,7 +1470,6 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul
|
||||
}
|
||||
|
||||
print '<td class="center">'.$langs->trans("PriceBase").'</td>';
|
||||
print $conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL;
|
||||
if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
|
||||
print '<td class="right">'.$langs->trans("DefaultTaxRate").'</td>';
|
||||
}
|
||||
|
||||
@ -3332,17 +3332,58 @@ class Societe extends CommonObject
|
||||
{
|
||||
// phpcs:enable
|
||||
if ($this->id) {
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
|
||||
$sql .= " SET parent = ".($id > 0 ? $id : "null");
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
dol_syslog(get_class($this).'::set_parent', LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$this->parent = $id;
|
||||
// Check if the id we want to add as parent has not already one parent that is the current id we try to update
|
||||
$sameparent = $this->validateFamilyTree($id, $this->id, 0);
|
||||
if ($sameparent < 0) {
|
||||
return -1;
|
||||
} elseif ($sameparent == 1) {
|
||||
setEventMessages('ParentCompanyToAddIsAlreadyAChildOfModifiedCompany', null, 'warnings');
|
||||
return -1;
|
||||
} else {
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe SET parent = '.($id > 0 ? $id : 'null').' WHERE rowid = '.((int) $this->id);
|
||||
dol_syslog(get_class($this).'::set_parent', LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$this->parent = $id;
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a thirdparty $idchild is or not inside the parents (or grand parents) of another thirdparty id $idparent.
|
||||
*
|
||||
* @param int $idparent Id of thirdparty to check
|
||||
* @param int $idchild Id of thirdparty to compare to
|
||||
* @param int $counter Counter to protect against infinite loops
|
||||
* @return int <0 if KO, 0 if OK or 1 if at some level a parent company was the child to compare to
|
||||
*/
|
||||
public function validateFamilyTree($idparent, $idchild, $counter = 0)
|
||||
{
|
||||
if ($counter > 100) {
|
||||
dol_syslog("Too high level of parent - child for company. May be an infinite loop ?", LOG_WARNING);
|
||||
}
|
||||
|
||||
$sql = 'SELECT s.parent';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
|
||||
$sql .= ' WHERE rowid = '.$idparent;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
if ($obj->parent == '') {
|
||||
return 0;
|
||||
} elseif ($obj->parent == $idchild) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
$sameparent = $this->validateFamilyTree($obj->parent, $idchild, ($counter + 1));
|
||||
}
|
||||
return $sameparent;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user