add project
This commit is contained in:
parent
65925e60b9
commit
518826ad3d
@ -129,22 +129,30 @@ function societe_prepare_head(Societe $object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
|
if (!empty($conf->projet->enabled) && (!empty($user->rights->projet->lire))) {
|
||||||
$nbNote = 0;
|
$nbProject = 0;
|
||||||
$sql = "SELECT COUNT(n.rowid) as nb";
|
$cachekey = 'count_projects_thirdparty_'.$object->id;
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet as n";
|
$dataretrieved = dol_getcache($cachekey);
|
||||||
$sql .= " WHERE fk_soc = ".$object->id;
|
|
||||||
$sql .= " AND entity IN (".getEntity('project').")";
|
if (!is_null($dataretrieved)) {
|
||||||
$resql = $db->query($sql);
|
$nbProject = $dataretrieved;
|
||||||
if ($resql) {
|
|
||||||
$obj = $db->fetch_object($resql);
|
|
||||||
$nbNote = $obj->nb;
|
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
$sql = "SELECT COUNT(n.rowid) as nb";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."projet as n";
|
||||||
|
$sql .= " WHERE fk_soc = ".$object->id;
|
||||||
|
$sql .= " AND entity IN (".getEntity('project').")";
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
$nbProject = $obj->nb;
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
dol_setcache($cachekey, $nbProject, 120); // If setting cache fails, this is not a problem, so we do not test result.
|
||||||
}
|
}
|
||||||
$head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id;
|
$head[$h][0] = DOL_URL_ROOT.'/societe/project.php?socid='.$object->id;
|
||||||
$head[$h][1] = $langs->trans("Projects");
|
$head[$h][1] = $langs->trans("Projects");
|
||||||
if ($nbNote > 0) {
|
if ($nbProject > 0) {
|
||||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbProject.'</span>';
|
||||||
}
|
}
|
||||||
$head[$h][2] = 'project';
|
$head[$h][2] = 'project';
|
||||||
$h++;
|
$h++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user