76 global $conf, $user, $langs;
84 $textHead = $langs->trans(
"OpenedProjects");
85 $this->info_box_head = array(
'text' => $textHead,
'limit'=>
dol_strlen($textHead));
89 if ($user->hasRight(
'projet',
'lire')) {
90 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
91 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
92 $projectstatic =
new Project($this->db);
93 $companystatic =
new Societe($this->db);
100 if (!$user->hasRight(
'projet',
'all',
'lire')) {
101 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
104 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public, p.fk_soc,";
105 $sql .=
" s.nom as name, s.name_alias";
106 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
107 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
108 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
109 $sql .=
" AND p.fk_statut = ".((int) $projectstatic::STATUS_VALIDATED);
110 if (!$user->hasRight(
'projet',
'all',
'lire')) {
111 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
114 $sql .=
" ORDER BY p.datec DESC";
117 $result = $this->db->query($sql);
120 $num = $this->db->num_rows($result);
121 while ($i < min($num, $max)) {
122 $objp = $this->db->fetch_object($result);
124 $projectstatic->id = $objp->rowid;
125 $projectstatic->ref = $objp->ref;
126 $projectstatic->title = $objp->title;
127 $projectstatic->public = $objp->public;
128 $projectstatic->statut = $objp->status;
130 $companystatic->id = $objp->fk_soc;
131 $companystatic->name = $objp->name;
132 $companystatic->name_alias = $objp->name_alias;
134 $this->info_box_contents[$i][] = array(
135 'td' =>
'class="nowraponall"',
136 'text' => $projectstatic->getNomUrl(1),
140 $this->info_box_contents[$i][] = array(
141 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
142 'text' => $objp->title,
145 $this->info_box_contents[$i][] = array(
146 'td' =>
'class="tdoverflowmax100"',
147 'text' => ($objp->fk_soc > 0 ? $companystatic->getNomUrl(1) :
''),
151 $sql =
"SELECT count(*) as nb, sum(progress) as totprogress";
152 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as pt on pt.fk_projet = p.rowid";
153 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
')';
154 $sql .=
" AND p.rowid = ".((int) $objp->rowid);
156 $resultTask = $this->db->query($sql);
158 $objTask = $this->db->fetch_object($resultTask);
159 $this->info_box_contents[$i][] = array(
160 'td' =>
'class="right"',
161 'text' => $objTask->nb.
" ".$langs->trans(
"Tasks"),
163 if ($objTask->nb > 0) {
164 $this->info_box_contents[$i][] = array(
165 'td' =>
'class="right"',
166 'text' => round($objTask->totprogress / $objTask->nb, 0).
"%",
169 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
171 $totalnbTask += $objTask->nb;
173 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => round(0));
174 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
176 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
181 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="6"',
'text' =>
'...');
189 $this->info_box_contents[$i][] = array(
190 'tr' =>
'class="liste_total_wrap"',
191 'td' =>
'class="liste_total"',
192 'text' => $langs->trans(
"Total").
" ".$textHead,
194 $this->info_box_contents[$i][] = array(
195 'td' =>
'class="right liste_total" ',
196 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
198 $this->info_box_contents[$i][] = array(
199 'td' =>
'class="right liste_total" ',
200 'text' => (($max < $num) ?
'' : (round($totalnbTask, 0).
" ".$langs->trans(
"Tasks"))),
202 $this->info_box_contents[$i][] = array(
203 'td' =>
'class="liste_total"',
206 $this->info_box_contents[$i][] = array(
207 'td' =>
'class="liste_total"',
210 $this->info_box_contents[$i][] = array(
211 'td' =>
'class="liste_total"',