27 include_once DOL_DOCUMENT_ROOT.
"/core/boxes/modules_boxes.php";
34 public $boxcode =
"project";
35 public $boximg =
"object_projectpub";
46 public $info_box_head = array();
47 public $info_box_contents = array();
60 $langs->loadLangs(array(
'boxes',
'projects'));
63 $this->boxlabel =
"OpenedProjects";
65 $this->hidden = !($user->rights->projet->lire);
76 global $conf, $user, $langs;
84 $textHead = $langs->trans(
"OpenedProjects");
85 $this->info_box_head = array(
'text' => $textHead,
'limit'=>
dol_strlen($textHead));
88 if ($user->rights->projet->lire) {
89 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
97 if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
99 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
101 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
102 $sql .=
" AND p.fk_statut = 1";
103 if (!$user->rights->projet->all->lire) $sql .=
" AND p.rowid IN (".$projectsListId.
")";
105 $sql .=
" ORDER BY p.datec DESC";
108 $result = $this->
db->query($sql);
111 $num = $this->
db->num_rows($result);
113 while ($i < min($num, $max)) {
114 $objp = $this->
db->fetch_object($result);
116 $projectstatic->id = $objp->rowid;
117 $projectstatic->ref = $objp->ref;
118 $projectstatic->title = $objp->title;
119 $projectstatic->public = $objp->public;
120 $projectstatic->statut = $objp->status;
122 $this->info_box_contents[$i][] = array(
123 'td' =>
'class="nowraponall"',
124 'text' => $projectstatic->getNomUrl(1),
128 $this->info_box_contents[$i][] = array(
129 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
130 'text' => $objp->title,
133 $sql =
"SELECT count(*) as nb, sum(progress) as totprogress";
134 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as pt on pt.fk_projet = p.rowid";
135 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
')';
136 $sql .=
" AND p.rowid = ".$objp->rowid;
137 $resultTask = $this->
db->query($sql);
139 $objTask = $this->
db->fetch_object($resultTask);
140 $this->info_box_contents[$i][] = array(
141 'td' =>
'class="right"',
142 'text' => $objTask->nb.
" ".$langs->trans(
"Tasks"),
144 if ($objTask->nb > 0)
145 $this->info_box_contents[$i][] = array(
146 'td' =>
'class="right"',
147 'text' => round($objTask->totprogress / $objTask->nb, 0).
"%",
149 else $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
150 $totalnbTask += $objTask->nb;
152 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => round(0));
153 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
155 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
161 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="5"',
'text' =>
'...');
169 $this->info_box_contents[$i][] = array(
170 'td' =>
'class="liste_total"',
171 'text' => $langs->trans(
"Total").
" ".$textHead,
174 $this->info_box_contents[$i][] = array(
175 'td' =>
'class="right liste_total" ',
176 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
178 $this->info_box_contents[$i][] = array(
179 'td' =>
'class="right liste_total" ',
180 'text' => (($max < $num) ?
'' : (round($totalnbTask, 0).
" ".$langs->trans(
"Tasks"))),
182 $this->info_box_contents[$i][] = array(
183 'td' =>
'class="liste_total"',
186 $this->info_box_contents[$i][] = array(
187 'td' =>
'class="liste_total"',
200 public function showBox($head = null, $contents = null, $nooutput = 0)
202 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
$conf db
API class for accounts.
loadBox($max=5)
Load data for box to show them later.
Class to manage the box to show last projet.
__construct($db, $param= '')
Constructor.
Class to manage projects.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.