Fix missing the badge on virtual product tab
This commit is contained in:
parent
9ed679d19a
commit
4969ae2abb
@ -80,6 +80,9 @@ function product_prepare_head($object)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/composition/card.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans('AssociatedProducts');
|
||||
|
||||
$nbFatherAndChild = $object->hasFatherOrChild();
|
||||
if ($nbFatherAndChild > 0) $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>';
|
||||
$head[$h][2] = 'subproduct';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@ -3314,6 +3314,32 @@ class Product extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return all parent products for current product (first level only)
|
||||
*
|
||||
* @return int Nb of father + child
|
||||
*/
|
||||
function hasFatherOrChild()
|
||||
{
|
||||
$nb = 0;
|
||||
|
||||
$sql = "SELECT COUNT(pa.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa";
|
||||
$sql.= " WHERE pa.fk_product_fils = ".$this->id." OR pa.fk_product_pere = ".$this->id;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) $nb = $obj->nb;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $nb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all parent products for current product (first level only)
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user