Fix missing translation and add a TODO to avoid infinite loop.
This commit is contained in:
parent
7998cefdd2
commit
911e862a8e
@ -130,6 +130,7 @@ AssociatedProductsAbility=Activate the package feature
|
|||||||
AssociatedProducts=Package product
|
AssociatedProducts=Package product
|
||||||
AssociatedProductsNumber=Number of products composing this package product
|
AssociatedProductsNumber=Number of products composing this package product
|
||||||
ParentProductsNumber=Number of parent packaging product
|
ParentProductsNumber=Number of parent packaging product
|
||||||
|
ParentProducts=Parent products
|
||||||
IfZeroItIsNotAVirtualProduct=If 0, this product is not a package product
|
IfZeroItIsNotAVirtualProduct=If 0, this product is not a package product
|
||||||
IfZeroItIsNotUsedByVirtualProduct=If 0, this product is not used by any package product
|
IfZeroItIsNotUsedByVirtualProduct=If 0, this product is not used by any package product
|
||||||
EditAssociate=Associate
|
EditAssociate=Associate
|
||||||
|
|||||||
@ -2982,9 +2982,10 @@ class Product extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param int $id Id of product to search childs of
|
* @param int $id Id of product to search childs of
|
||||||
* @param int $firstlevelonly Return only direct child
|
* @param int $firstlevelonly Return only direct child
|
||||||
|
* @param int $level Level of recursing call (start to 1)
|
||||||
* @return array Prod
|
* @return array Prod
|
||||||
*/
|
*/
|
||||||
function getChildsArbo($id, $firstlevelonly=0)
|
function getChildsArbo($id, $firstlevelonly=0, $level=1)
|
||||||
{
|
{
|
||||||
$sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec";
|
$sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
@ -2993,13 +2994,18 @@ class Product extends CommonObject
|
|||||||
$sql.= " AND pa.fk_product_pere = ".$id;
|
$sql.= " AND pa.fk_product_pere = ".$id;
|
||||||
$sql.= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens
|
$sql.= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens
|
||||||
|
|
||||||
dol_syslog(get_class($this).'::getChildsArbo', LOG_DEBUG);
|
dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG);
|
||||||
|
|
||||||
|
// Protection against infinite loop
|
||||||
|
if ($level > 30) return array();
|
||||||
|
|
||||||
$res = $this->db->query($sql);
|
$res = $this->db->query($sql);
|
||||||
if ($res)
|
if ($res)
|
||||||
{
|
{
|
||||||
$prods = array();
|
$prods = array();
|
||||||
while ($rec = $this->db->fetch_array($res))
|
while ($rec = $this->db->fetch_array($res))
|
||||||
{
|
{
|
||||||
|
// TODO Add check to not add ne record if already added
|
||||||
$prods[$rec['rowid']]= array(
|
$prods[$rec['rowid']]= array(
|
||||||
0=>$rec['id'],
|
0=>$rec['id'],
|
||||||
1=>$rec['qty'],
|
1=>$rec['qty'],
|
||||||
@ -3011,7 +3017,7 @@ class Product extends CommonObject
|
|||||||
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
|
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
|
||||||
if (empty($firstlevelonly))
|
if (empty($firstlevelonly))
|
||||||
{
|
{
|
||||||
$listofchilds=$this->getChildsArbo($rec['id']);
|
$listofchilds=$this->getChildsArbo($rec['id'], 0, $level + 1);
|
||||||
foreach($listofchilds as $keyChild => $valueChild)
|
foreach($listofchilds as $keyChild => $valueChild)
|
||||||
{
|
{
|
||||||
$prods[$rec['rowid']]['childs'][$keyChild] = $valueChild;
|
$prods[$rec['rowid']]['childs'][$keyChild] = $valueChild;
|
||||||
@ -3041,7 +3047,7 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
foreach($parent as $key => $value) // key=label, value[0]=id
|
foreach($parent as $key => $value) // key=label, value[0]=id
|
||||||
{
|
{
|
||||||
foreach($this->getChildsArbo($value[0]) as $keyChild => $valueChild)
|
foreach($this->getChildsArbo($value[0]) as $keyChild => $valueChild) // Warning. getChildsArbo can gell getChildsArbo recursively.
|
||||||
{
|
{
|
||||||
$parent[$key][$keyChild] = $valueChild;
|
$parent[$key][$keyChild] = $valueChild;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -265,7 +265,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print load_fiche_titre($langs->trans("ProductParentList"),'','').'<br>';
|
print load_fiche_titre($langs->trans("ProductParentList"),'','').'<br>';
|
||||||
print '<table class="centpercent noborder">';
|
print '<table class="centpercent noborder">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$langs->trans('ParentProduct').'</td>';
|
print '<td>'.$langs->trans('ParentProducts').'</td>';
|
||||||
print '<td>'.$langs->trans('Label').'</td>';
|
print '<td>'.$langs->trans('Label').'</td>';
|
||||||
print '<td>'.$langs->trans('Qty').'</td>';
|
print '<td>'.$langs->trans('Qty').'</td>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user