FIX list of projects
Conflicts: htdocs/core/boxes/box_project.php
This commit is contained in:
parent
36630b9404
commit
e2e76b40da
@ -72,27 +72,40 @@ class box_project extends ModeleBoxes
|
||||
$totalnb = 0;
|
||||
$totalnbTask=0;
|
||||
|
||||
$textHead = $langs->trans("Projects");
|
||||
$textHead = $langs->trans("OpenedProjects");
|
||||
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));
|
||||
|
||||
// list the summary of the orders
|
||||
if ($user->rights->projet->lire) {
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public";
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
|
||||
$projectstatic = new Project($this->db);
|
||||
|
||||
$socid=$user->societe_id;
|
||||
|
||||
// Get list of project id allowed to user (in a string list separated by coma)
|
||||
$projectsListId='';
|
||||
if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid);
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
if($user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=p.fk_soc";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
if($user->socid) $sql.= " AND s.rowid = ".$user->socid;
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project',1).')';
|
||||
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
|
||||
if ($user->socid) $sql.= " AND s.rowid = ".$user->socid;
|
||||
$sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts
|
||||
$sql.= " ORDER BY p.datec DESC";
|
||||
$sql.= $db->plimit($max, 0);
|
||||
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
|
||||
|
||||
$sql.= " ORDER BY p.datec DESC";
|
||||
//$sql.= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
while ($i < min($num, $max)) {
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$tooltip = $langs->trans('Project') . ': ' . $objp->ref;
|
||||
@ -117,8 +130,8 @@ class box_project extends ModeleBoxes
|
||||
|
||||
$sql ="SELECT count(*) as nb, sum(progress) as totprogress";
|
||||
$sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid";
|
||||
$sql.=" WHERE p.entity = ".$conf->entity;
|
||||
$sql.=" AND p.rowid = ".$objp->rowid;
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project',1).')';
|
||||
$sql.=" AND p.rowid = ".$objp->rowid;
|
||||
$resultTask = $db->query($sql);
|
||||
if ($resultTask) {
|
||||
$objTask = $db->fetch_object($resultTask);
|
||||
@ -135,12 +148,17 @@ class box_project extends ModeleBoxes
|
||||
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => "N/A ");
|
||||
$totalnbTask += $objTask->nb;
|
||||
} else {
|
||||
$this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => number_format(0, 0, ',', ' '));
|
||||
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => "N/A ");
|
||||
$this->info_box_contents[$i][3] = array('td' => 'class="right"', 'text' => round(0));
|
||||
$this->info_box_contents[$i][4] = array('td' => 'class="right"', 'text' => "N/A ");
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
if ($max < $num)
|
||||
{
|
||||
$this->info_box_contents[$i][0] = array('td' => 'colspan="5"', 'text' => '...');
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,11 +176,11 @@ class box_project extends ModeleBoxes
|
||||
);
|
||||
$this->info_box_contents[$i][2] = array(
|
||||
'td' => 'align="right" ',
|
||||
'text' => number_format($num, 0, ',', ' ')." ".$langs->trans("Projects"),
|
||||
'text' => round($num, 0)." ".$langs->trans("Projects"),
|
||||
);
|
||||
$this->info_box_contents[$i][3] = array(
|
||||
'td' => 'align="right" ',
|
||||
'text' => number_format($totalnbTask, 0, ',', ' ')." ".$langs->trans("Tasks"),
|
||||
'text' => (($max < $num) ? '' : (round($totalnbTask, 0)." ".$langs->trans("Tasks"))),
|
||||
);
|
||||
$this->info_box_contents[$i][4] = array(
|
||||
'td' => '',
|
||||
|
||||
@ -196,6 +196,7 @@ $title=$langs->trans("Projects");
|
||||
if ($search_user == $user->id) $title=$langs->trans("MyProjects");
|
||||
|
||||
// Get list of project id allowed to user (in a string list separated by coma)
|
||||
$projectsListId='';
|
||||
if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid);
|
||||
|
||||
// Get id of types of contacts for projects (This list never contains a lot of elements)
|
||||
@ -245,7 +246,7 @@ if ($search_user > 0)
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project',1).')';
|
||||
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
|
||||
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
|
||||
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
|
||||
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
||||
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user