Merge branch '14.0' of git@github.com:Dolibarr/dolibarr.git into 15.0

This commit is contained in:
Laurent Destailleur 2022-08-22 13:02:51 +02:00
commit 4e678c5065
2 changed files with 9 additions and 6 deletions

View File

@ -3080,8 +3080,8 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
$newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
}
} elseif (strtoupper($countrycode) == "MG") {//Madagascar
if (dol_strlen($phone) == 13) {//ex: +261_AB_CD_EF_GHI
$newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3);
if (dol_strlen($phone) == 13) {//ex: +261_AB_CD_EFG_HI
$newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 2);
}
} elseif (strtoupper($countrycode) == "GB") {//Royaume uni
if (dol_strlen($phone) == 13) {//ex: +44_ABCD_EFG_HIJ

View File

@ -4697,9 +4697,10 @@ class Product extends CommonObject
* @param int $id Id of product to search childs of
* @param int $firstlevelonly Return only direct child
* @param int $level Level of recursing call (start to 1)
* @param array $parents Array of all parents of $id
* @return array Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref)
*/
public function getChildsArbo($id, $firstlevelonly = 0, $level = 1)
public function getChildsArbo($id, $firstlevelonly = 0, $level = 1, $parents = array())
{
global $alreadyfound;
@ -4717,7 +4718,7 @@ class Product extends CommonObject
$sql .= " AND pa.fk_product_fils <> ".((int) $id); // This should not happens, it is to avoid infinite loop if it happens
$sql.= " ORDER BY pa.rang";
dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG);
dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level. ' parents='.$parents, LOG_DEBUG);
if ($level == 1) {
$alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly
@ -4733,7 +4734,9 @@ class Product extends CommonObject
while ($rec = $this->db->fetch_array($res)) {
if (!empty($alreadyfound[$rec['rowid']])) {
dol_syslog(get_class($this).'::getChildsArbo the product id='.$rec['rowid'].' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING);
continue;
if (in_array($rec['id'], $parents)) {
continue; // We discard this child if it is already found at a higher level in tree in the same branch.
}
}
$alreadyfound[$rec['rowid']] = 1;
$prods[$rec['rowid']] = array(
@ -4749,7 +4752,7 @@ class Product extends CommonObject
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']);
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
if (empty($firstlevelonly)) {
$listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1);
$listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, array_push($parents, $rec['rowid']));
foreach ($listofchilds as $keyChild => $valueChild) {
$prods[$rec['rowid']]['childs'][$keyChild] = $valueChild;
}