count actioncomm for thirdparty tab agenda

This commit is contained in:
Frédéric FRANCE 2021-02-17 22:16:07 +01:00
parent 933a944603
commit 45e947ee2b
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1

View File

@ -304,21 +304,21 @@ function societe_prepare_head(Societe $object)
$head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Events"); $head[$h][1] = $langs->trans("Events");
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$nbNote = 0; $nbEvent = 0;
$sql = "SELECT COUNT(id) as nb"; $sql = "SELECT COUNT(id) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
$sql .= " WHERE fk_soc = ".$object->id; $sql .= " WHERE fk_soc = ".$object->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$nbNote = $obj->nb; $nbEvent = $obj->nb;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
$head[$h][1] .= '/'; $head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda"); $head[$h][1] .= $langs->trans("Agenda");
if ($nbNote > 0) { if ($nbEvent > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>'; $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
} }
} }
$head[$h][2] = 'agenda'; $head[$h][2] = 'agenda';