Skip to content

Commit

Permalink
Fix duplicate tab "contact" on thirdparty
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 17, 2018
1 parent 45a45b0 commit 7fcec5f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
58 changes: 30 additions & 28 deletions htdocs/core/lib/company.lib.php
Expand Up @@ -48,26 +48,38 @@ function societe_prepare_head(Societe $object)
$head[$h][2] = 'card';
$h++;

if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
//$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
$nbContact = 0; // TODO

$sql = "SELECT COUNT(p.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " WHERE p.fk_soc = ".$object->id;
$resql = $db->query($sql);
if ($resql)
if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES))
{
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$obj = $db->fetch_object($resql);
if ($obj) $nbContact = $obj->nb;
}
//$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
$nbContact = 0; // TODO

$sql = "SELECT COUNT(p.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " WHERE p.fk_soc = ".$object->id;
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $nbContact = $obj->nb;
}

$head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
$head[$h][2] = 'contact';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/societe/contact.php?socid='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
$head[$h][2] = 'contact';
$h++;
}
}
else
{
$head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id;
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
$head[$h][1] = $langs->trans("ContactsAddresses");
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
$head[$h][2] = 'contact';
$h++;
}

if ($object->client==1 || $object->client==2 || $object->client==3)
Expand Down Expand Up @@ -98,16 +110,6 @@ function societe_prepare_head(Societe $object)
$h++;
}

if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES))
{
$head[$h][0] = DOL_URL_ROOT.'/societe/societecontact.php?socid='.$object->id;
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
$head[$h][1] = $langs->trans("ContactsAddresses");
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
$head[$h][2] = 'contact';
$h++;
}

if (! empty($conf->projet->enabled) && (!empty($user->rights->projet->lire) ))
{
$head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id;
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -6460,6 +6460,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
foreach($head as $key => $val)
{
$condition = (! empty($values[3]) ? verifCond($values[3]) : 1);
//var_dump($key.' - '.$tabname.' - '.$head[$key][2].' - '.$condition);
if ($head[$key][2]==$tabname && $condition)
{
unset($head[$key]);
Expand Down

0 comments on commit 7fcec5f

Please sign in to comment.