72 global
$conf, $user, $langs;
81 $textHead = $langs->trans(
"OpenedProjects");
82 $this->info_box_head = array(
'text' => $textHead,
'limit' =>
dol_strlen($textHead));
86 if ($user->hasRight(
'projet',
'lire')) {
87 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
88 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
89 $projectstatic =
new Project($this->db);
90 $companystatic =
new Societe($this->db);
97 if (!$user->hasRight(
'projet',
'all',
'lire')) {
98 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
101 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public, p.fk_soc,";
102 $sql .=
" s.nom as name, s.name_alias";
103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
104 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
105 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
106 $sql .=
" AND p.fk_statut = ".((int) $projectstatic::STATUS_VALIDATED);
107 if (!$user->hasRight(
'projet',
'all',
'lire')) {
108 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
111 $sql .=
" ORDER BY p.datec DESC";
114 $result = $this->db->query($sql);
117 $num = $this->db->num_rows($result);
118 while ($i < min($num, $max)) {
119 $objp = $this->db->fetch_object($result);
121 $projectstatic->id = $objp->rowid;
122 $projectstatic->ref = $objp->ref;
123 $projectstatic->title = $objp->title;
124 $projectstatic->public = $objp->public;
125 $projectstatic->statut = $objp->status;
126 $projectstatic->status = $objp->status;
128 $companystatic->id = $objp->fk_soc;
129 $companystatic->name = $objp->name;
130 $companystatic->name_alias = $objp->name_alias;
132 $this->info_box_contents[$i][] = array(
133 'td' =>
'class="nowraponall"',
134 'text' => $projectstatic->getNomUrl(1),
138 $this->info_box_contents[$i][] = array(
139 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
140 'text' => $objp->title,
143 $this->info_box_contents[$i][] = array(
144 'td' =>
'class="tdoverflowmax100"',
145 'text' => ($objp->fk_soc > 0 ? $companystatic->getNomUrl(1) :
''),
149 $sql =
"SELECT count(*) as nb, sum(progress) as totprogress";
150 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as pt on pt.fk_projet = p.rowid";
151 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
')';
152 $sql .=
" AND p.rowid = ".((int) $objp->rowid);
154 $resultTask = $this->db->query($sql);
156 $objTask = $this->db->fetch_object($resultTask);
157 $this->info_box_contents[$i][] = array(
158 'td' =>
'class="right"',
159 'text' => $objTask->nb.
" ".$langs->trans(
"Tasks"),
161 if ($objTask->nb > 0) {
162 $this->info_box_contents[$i][] = array(
163 'td' =>
'class="right"',
164 'text' => round($objTask->totprogress / $objTask->nb, 0).
"%",
167 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
169 $totalnbTask += $objTask->nb;
171 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => round(0));
172 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
174 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
179 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="6"',
'text' =>
'...');
187 $this->info_box_contents[$i][] = array(
188 'tr' =>
'class="liste_total_wrap"',
189 'td' =>
'class="liste_total"',
190 'text' => $langs->trans(
"Total").
" ".$textHead,
192 $this->info_box_contents[$i][] = array(
193 'td' =>
'class="right liste_total" ',
194 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
196 $this->info_box_contents[$i][] = array(
197 'td' =>
'class="right liste_total" ',
198 'text' => (($max < $num) ?
'' : (round($totalnbTask, 0).
" ".$langs->trans(
"Tasks"))),
200 $this->info_box_contents[$i][] = array(
201 'td' =>
'class="liste_total"',
204 $this->info_box_contents[$i][] = array(
205 'td' =>
'class="liste_total"',
208 $this->info_box_contents[$i][] = array(
209 'td' =>
'class="liste_total"',