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 = empty($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));
89 if ($user->rights->projet->lire) {
90 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
98 if (empty($user->rights->projet->all->lire)) {
99 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
102 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public";
103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
104 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
105 $sql .=
" AND p.fk_statut = 1";
106 if (empty($user->rights->projet->all->lire)) {
107 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
110 $sql .=
" ORDER BY p.datec DESC";
113 $result = $this->
db->query($sql);
116 $num = $this->
db->num_rows($result);
117 while ($i < min($num, $max)) {
118 $objp = $this->
db->fetch_object($result);
120 $projectstatic->id = $objp->rowid;
121 $projectstatic->ref = $objp->ref;
122 $projectstatic->title = $objp->title;
123 $projectstatic->public = $objp->public;
124 $projectstatic->statut = $objp->status;
126 $this->info_box_contents[$i][] = array(
127 'td' =>
'class="nowraponall"',
128 'text' => $projectstatic->getNomUrl(1),
132 $this->info_box_contents[$i][] = array(
133 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
134 'text' => $objp->title,
137 $sql =
"SELECT count(*) as nb, sum(progress) as totprogress";
138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as pt on pt.fk_projet = p.rowid";
139 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
')';
140 $sql .=
" AND p.rowid = ".((int) $objp->rowid);
142 $resultTask = $this->
db->query($sql);
144 $objTask = $this->
db->fetch_object($resultTask);
145 $this->info_box_contents[$i][] = array(
146 'td' =>
'class="right"',
147 'text' => $objTask->nb.
" ".$langs->trans(
"Tasks"),
149 if ($objTask->nb > 0) {
150 $this->info_box_contents[$i][] = array(
151 'td' =>
'class="right"',
152 'text' => round($objTask->totprogress / $objTask->nb, 0).
"%",
155 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
157 $totalnbTask += $objTask->nb;
159 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => round(0));
160 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' =>
"N/A ");
162 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
167 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="5"',
'text' =>
'...');
175 $this->info_box_contents[$i][] = array(
176 'td' =>
'class="liste_total"',
177 'text' => $langs->trans(
"Total").
" ".$textHead,
179 $this->info_box_contents[$i][] = array(
180 'td' =>
'class="right liste_total" ',
181 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
183 $this->info_box_contents[$i][] = array(
184 'td' =>
'class="right liste_total" ',
185 'text' => (($max < $num) ?
'' : (round($totalnbTask, 0).
" ".$langs->trans(
"Tasks"))),
187 $this->info_box_contents[$i][] = array(
188 'td' =>
'class="liste_total"',
191 $this->info_box_contents[$i][] = array(
192 'td' =>
'class="liste_total"',
205 public function showBox($head =
null, $contents =
null, $nooutput = 0)
207 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage projects.
Class to manage the box to show last projet.
loadBox($max=5)
Load data for box to show them later.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
__construct($db, $param='')
Constructor.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
$conf db
API class for accounts.