67 global $conf, $user, $langs;
75 $textHead = $langs->trans(
"OpenedProjects");
76 $this->info_box_head = array(
'text' => $textHead,
'limit' =>
dol_strlen($textHead));
80 if ($user->hasRight(
'projet',
'lire')) {
81 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
82 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
83 $projectstatic =
new Project($this->db);
84 $companystatic =
new Societe($this->db);
91 if (!$user->hasRight(
'projet',
'all',
'lire')) {
92 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
95 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public, p.fk_soc,";
96 $sql .=
" s.nom as name, s.name_alias";
97 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
98 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
99 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
100 $sql .=
" AND p.fk_statut = ".((int) $projectstatic::STATUS_VALIDATED);
101 if (!$user->hasRight(
'projet',
'all',
'lire')) {
102 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
105 $sql .=
" ORDER BY p.datec DESC";
108 $result = $this->db->query($sql);
111 $num = $this->db->num_rows($result);
112 while ($i < min($num, $max)) {
113 $objp = $this->db->fetch_object($result);
115 $projectstatic->id = $objp->rowid;
116 $projectstatic->ref = $objp->ref;
117 $projectstatic->title = $objp->title;
118 $projectstatic->public = $objp->public;
119 $projectstatic->statut = $objp->status;
121 $companystatic->id = $objp->fk_soc;
122 $companystatic->name = $objp->name;
123 $companystatic->name_alias = $objp->name_alias;
125 $this->info_box_contents[$i][] = array(
126 'td' =>
'class="nowraponall"',
127 'text' => $projectstatic->getNomUrl(1),
131 $this->info_box_contents[$i][] = array(
132 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
133 'text' => $objp->title,
136 $this->info_box_contents[$i][] = array(
137 'td' =>
'class="tdoverflowmax100"',
138 'text' => ($objp->fk_soc > 0 ? $companystatic->getNomUrl(1) :
''),
142 $sql =
"SELECT count(*) as nb, sum(progress) as totprogress";
143 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as pt on pt.fk_projet = p.rowid";
144 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
')';
145 $sql .=
" AND p.rowid = ".((int) $objp->rowid);
147 $resultTask = $this->db->query($sql);
149 $objTask = $this->db->fetch_object($resultTask);
150 $this->info_box_contents[$i][] = array(
151 'td' =>
'class="right"',
152 'text' => $objTask->nb.
" ".$langs->trans(
"Tasks"),
154 if ($objTask->nb > 0) {
155 $this->info_box_contents[$i][] = array(
156 'td' =>
'class="right"',
157 'text' => round($objTask->totprogress / $objTask->nb, 0).
"%",
160 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
162 $totalnbTask += $objTask->nb;
164 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => round(0));
165 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
167 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
172 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="6"',
'text' =>
'...');
180 $this->info_box_contents[$i][] = array(
181 'tr' =>
'class="liste_total_wrap"',
182 'td' =>
'class="liste_total"',
183 'text' => $langs->trans(
"Total").
" ".$textHead,
185 $this->info_box_contents[$i][] = array(
186 'td' =>
'class="right liste_total" ',
187 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
189 $this->info_box_contents[$i][] = array(
190 'td' =>
'class="right liste_total" ',
191 'text' => (($max < $num) ?
'' : (round($totalnbTask, 0).
" ".$langs->trans(
"Tasks"))),
193 $this->info_box_contents[$i][] = array(
194 'td' =>
'class="liste_total"',
197 $this->info_box_contents[$i][] = array(
198 'td' =>
'class="liste_total"',
201 $this->info_box_contents[$i][] = array(
202 'td' =>
'class="liste_total"',