66 global $conf, $user, $langs;
74 $textHead = $langs->trans(
"OpenedProjects");
75 $this->info_box_head = array(
'text' => $textHead,
'limit'=>
dol_strlen($textHead));
79 if ($user->hasRight(
'projet',
'lire')) {
80 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
81 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
82 $projectstatic =
new Project($this->db);
83 $companystatic =
new Societe($this->db);
90 if (!$user->hasRight(
'projet',
'all',
'lire')) {
91 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
94 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public, p.fk_soc,";
95 $sql .=
" s.nom as name, s.name_alias";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
97 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
98 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
99 $sql .=
" AND p.fk_statut = ".((int) $projectstatic::STATUS_VALIDATED);
100 if (!$user->hasRight(
'projet',
'all',
'lire')) {
101 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
104 $sql .=
" ORDER BY p.datec DESC";
107 $result = $this->db->query($sql);
110 $num = $this->db->num_rows($result);
111 while ($i < min($num, $max)) {
112 $objp = $this->db->fetch_object($result);
114 $projectstatic->id = $objp->rowid;
115 $projectstatic->ref = $objp->ref;
116 $projectstatic->title = $objp->title;
117 $projectstatic->public = $objp->public;
118 $projectstatic->statut = $objp->status;
120 $companystatic->id = $objp->fk_soc;
121 $companystatic->name = $objp->name;
122 $companystatic->name_alias = $objp->name_alias;
124 $this->info_box_contents[$i][] = array(
125 'td' =>
'class="nowraponall"',
126 'text' => $projectstatic->getNomUrl(1),
130 $this->info_box_contents[$i][] = array(
131 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
132 'text' => $objp->title,
135 $this->info_box_contents[$i][] = array(
136 'td' =>
'class="tdoverflowmax100"',
137 'text' => ($objp->fk_soc > 0 ? $companystatic->getNomUrl(1) :
''),
141 $sql =
"SELECT count(*) as nb, sum(progress) as totprogress";
142 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as pt on pt.fk_projet = p.rowid";
143 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
')';
144 $sql .=
" AND p.rowid = ".((int) $objp->rowid);
146 $resultTask = $this->db->query($sql);
148 $objTask = $this->db->fetch_object($resultTask);
149 $this->info_box_contents[$i][] = array(
150 'td' =>
'class="right"',
151 'text' => $objTask->nb.
" ".$langs->trans(
"Tasks"),
153 if ($objTask->nb > 0) {
154 $this->info_box_contents[$i][] = array(
155 'td' =>
'class="right"',
156 'text' => round($objTask->totprogress / $objTask->nb, 0).
"%",
159 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
161 $totalnbTask += $objTask->nb;
163 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => round(0));
164 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
166 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
171 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="6"',
'text' =>
'...');
179 $this->info_box_contents[$i][] = array(
180 'tr' =>
'class="liste_total_wrap"',
181 'td' =>
'class="liste_total"',
182 'text' => $langs->trans(
"Total").
" ".$textHead,
184 $this->info_box_contents[$i][] = array(
185 'td' =>
'class="right liste_total" ',
186 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
188 $this->info_box_contents[$i][] = array(
189 'td' =>
'class="right liste_total" ',
190 'text' => (($max < $num) ?
'' : (round($totalnbTask, 0).
" ".$langs->trans(
"Tasks"))),
192 $this->info_box_contents[$i][] = array(
193 'td' =>
'class="liste_total"',
196 $this->info_box_contents[$i][] = array(
197 'td' =>
'class="liste_total"',
200 $this->info_box_contents[$i][] = array(
201 'td' =>
'class="liste_total"',