69 global
$conf, $user, $langs;
77 $textHead = $langs->trans(
"OpenedProjects");
78 $this->info_box_head = array(
'text' => $textHead,
'limit' =>
dol_strlen($textHead));
82 if ($user->hasRight(
'projet',
'lire')) {
83 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
84 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
85 $projectstatic =
new Project($this->db);
86 $companystatic =
new Societe($this->db);
93 if (!$user->hasRight(
'projet',
'all',
'lire')) {
94 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
97 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public, p.fk_soc,";
98 $sql .=
" s.nom as name, s.name_alias";
99 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
100 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
101 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
102 $sql .=
" AND p.fk_statut = ".((int) $projectstatic::STATUS_VALIDATED);
103 if (!$user->hasRight(
'projet',
'all',
'lire')) {
104 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
107 $sql .=
" ORDER BY p.datec DESC";
110 $result = $this->db->query($sql);
113 $num = $this->db->num_rows($result);
114 while ($i < min($num, $max)) {
115 $objp = $this->db->fetch_object($result);
117 $projectstatic->id = $objp->rowid;
118 $projectstatic->ref = $objp->ref;
119 $projectstatic->title = $objp->title;
120 $projectstatic->public = $objp->public;
121 $projectstatic->statut = $objp->status;
123 $companystatic->id = $objp->fk_soc;
124 $companystatic->name = $objp->name;
125 $companystatic->name_alias = $objp->name_alias;
127 $this->info_box_contents[$i][] = array(
128 'td' =>
'class="nowraponall"',
129 'text' => $projectstatic->getNomUrl(1),
133 $this->info_box_contents[$i][] = array(
134 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
135 'text' => $objp->title,
138 $this->info_box_contents[$i][] = array(
139 'td' =>
'class="tdoverflowmax100"',
140 'text' => ($objp->fk_soc > 0 ? $companystatic->getNomUrl(1) :
''),
144 $sql =
"SELECT count(*) as nb, sum(progress) as totprogress";
145 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as pt on pt.fk_projet = p.rowid";
146 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
')';
147 $sql .=
" AND p.rowid = ".((int) $objp->rowid);
149 $resultTask = $this->db->query($sql);
151 $objTask = $this->db->fetch_object($resultTask);
152 $this->info_box_contents[$i][] = array(
153 'td' =>
'class="right"',
154 'text' => $objTask->nb.
" ".$langs->trans(
"Tasks"),
156 if ($objTask->nb > 0) {
157 $this->info_box_contents[$i][] = array(
158 'td' =>
'class="right"',
159 'text' => round($objTask->totprogress / $objTask->nb, 0).
"%",
162 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
164 $totalnbTask += $objTask->nb;
166 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => round(0));
167 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
169 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
174 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="6"',
'text' =>
'...');
182 $this->info_box_contents[$i][] = array(
183 'tr' =>
'class="liste_total_wrap"',
184 'td' =>
'class="liste_total"',
185 'text' => $langs->trans(
"Total").
" ".$textHead,
187 $this->info_box_contents[$i][] = array(
188 'td' =>
'class="right liste_total" ',
189 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
191 $this->info_box_contents[$i][] = array(
192 'td' =>
'class="right liste_total" ',
193 'text' => (($max < $num) ?
'' : (round($totalnbTask, 0).
" ".$langs->trans(
"Tasks"))),
195 $this->info_box_contents[$i][] = array(
196 'td' =>
'class="liste_total"',
199 $this->info_box_contents[$i][] = array(
200 'td' =>
'class="liste_total"',
203 $this->info_box_contents[$i][] = array(
204 'td' =>
'class="liste_total"',