FIX: Add missing event counter on Agenda tab (#36972)
Co-authored-by: Noé <noe@scopen.fr> Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
619fb3a590
commit
4b2ca3bd28
5 changed files with 123 additions and 0 deletions
|
|
@ -136,8 +136,32 @@ function contact_prepare_head(Contact $object)
|
|||
$head[$tab][0] = dolBuildUrl(DOL_URL_ROOT.'/contact/agenda.php', ['id' => $object->id]);
|
||||
$head[$tab][1] = $langs->trans("Events");
|
||||
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
|
||||
$nbEvent = 0;
|
||||
// Enable caching of contact count actioncomm
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
||||
$cachekey = 'count_events_contact_'.$object->id;
|
||||
$dataretrieved = dol_getcache($cachekey);
|
||||
if (!is_null($dataretrieved)) {
|
||||
$nbEvent = $dataretrieved;
|
||||
} else {
|
||||
$sql = "SELECT COUNT(id) as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
|
||||
$sql .= " WHERE fk_contact = ".((int) $object->id);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$nbEvent = $obj->nb;
|
||||
} else {
|
||||
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
|
||||
}
|
||||
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
|
||||
}
|
||||
|
||||
$head[$tab][1] .= '/';
|
||||
$head[$tab][1] .= $langs->trans("Agenda");
|
||||
if ($nbEvent > 0) {
|
||||
$head[$tab][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
|
||||
}
|
||||
}
|
||||
$head[$tab][2] = 'agenda';
|
||||
$tab++;
|
||||
|
|
|
|||
|
|
@ -267,8 +267,33 @@ function ordersupplier_prepare_head(CommandeFournisseur $object)
|
|||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
|
||||
$nbEvent = 0;
|
||||
// Enable caching of order supplier count actioncomm
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
||||
$cachekey = 'count_events_order_'.$object->id;
|
||||
$dataretrieved = dol_getcache($cachekey);
|
||||
if (!is_null($dataretrieved)) {
|
||||
$nbEvent = $dataretrieved;
|
||||
} else {
|
||||
$sql = "SELECT COUNT(id) as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
|
||||
$sql .= " WHERE fk_element = ".((int) $object->id);
|
||||
$sql .= " AND elementtype = 'order_supplier'";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$nbEvent = $obj->nb;
|
||||
} else {
|
||||
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
|
||||
}
|
||||
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
|
||||
}
|
||||
|
||||
$head[$h][1] .= '/';
|
||||
$head[$h][1] .= $langs->trans("Agenda");
|
||||
if ($nbEvent > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
|
||||
}
|
||||
}
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
|
|
|||
|
|
@ -259,8 +259,33 @@ function product_prepare_head($object)
|
|||
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/product/messaging.php', ['id' => $object->id]);
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
|
||||
$nbEvent = 0;
|
||||
// Enable caching of product count actioncomm
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
||||
$cachekey = 'count_events_product_'.$object->id;
|
||||
$dataretrieved = dol_getcache($cachekey);
|
||||
if (!is_null($dataretrieved)) {
|
||||
$nbEvent = $dataretrieved;
|
||||
} else {
|
||||
$sql = "SELECT COUNT(id) as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
|
||||
$sql .= " WHERE fk_element = ".((int) $object->id);
|
||||
$sql .= " AND elementtype = 'product'";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$nbEvent = $obj->nb;
|
||||
} else {
|
||||
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
|
||||
}
|
||||
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
|
||||
}
|
||||
|
||||
$head[$h][1] .= '/';
|
||||
$head[$h][1] .= $langs->trans("Agenda");
|
||||
if ($nbEvent > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
|
||||
}
|
||||
}
|
||||
$head[$h][2] = 'agenda';
|
||||
$h++;
|
||||
|
|
|
|||
|
|
@ -352,8 +352,32 @@ function project_prepare_head(Project $project, $moreparam = '')
|
|||
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/projet/messaging.php', ['id' => $project->id]);
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
|
||||
$nbEvent = 0;
|
||||
// Enable caching of project count actioncomm
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
||||
$cachekey = 'count_events_project_'.$project->id;
|
||||
$dataretrieved = dol_getcache($cachekey);
|
||||
if (!is_null($dataretrieved)) {
|
||||
$nbEvent = $dataretrieved;
|
||||
} else {
|
||||
$sql = "SELECT COUNT(id) as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
|
||||
$sql .= " WHERE fk_project = ".((int) $project->id);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$nbEvent = $obj->nb;
|
||||
} else {
|
||||
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
|
||||
}
|
||||
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
|
||||
}
|
||||
|
||||
$head[$h][1] .= '/';
|
||||
$head[$h][1] .= $langs->trans("Agenda");
|
||||
if ($nbEvent > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
|
||||
}
|
||||
}
|
||||
$head[$h][2] = 'agenda';
|
||||
$h++;
|
||||
|
|
|
|||
|
|
@ -165,8 +165,33 @@ function ticket_prepare_head($object)
|
|||
}
|
||||
$head[$h][1] = $langs->trans('Events');
|
||||
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
|
||||
$nbEvent = 0;
|
||||
// Enable caching of ticket count actioncomm
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
||||
$cachekey = 'count_events_ticket_'.$object->id;
|
||||
$dataretrieved = dol_getcache($cachekey);
|
||||
if (!is_null($dataretrieved)) {
|
||||
$nbEvent = $dataretrieved;
|
||||
} else {
|
||||
$sql = "SELECT COUNT(id) as nb";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
|
||||
$sql .= " WHERE fk_element = ".((int) $object->id);
|
||||
$sql .= " AND elementtype = 'ticket'";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$nbEvent = $obj->nb;
|
||||
} else {
|
||||
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
|
||||
}
|
||||
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
|
||||
}
|
||||
|
||||
$head[$h][1] .= '/';
|
||||
$head[$h][1] .= $langs->trans("Agenda");
|
||||
if ($nbEvent > 0) {
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
|
||||
}
|
||||
}
|
||||
$head[$h][2] = 'tabTicketLogs';
|
||||
$h++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue