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;
 
  127          $companystatic->id = $objp->fk_soc;
 
  128          $companystatic->name = $objp->name;
 
  129          $companystatic->name_alias = $objp->name_alias;
 
  131          $this->info_box_contents[$i][] = array(
 
  132            'td' => 
'class="nowraponall"',
 
  133            'text' => $projectstatic->getNomUrl(1),
 
  137          $this->info_box_contents[$i][] = array(
 
  138            'td' => 
'class="tdoverflowmax150 maxwidth200onsmartphone"',
 
  139            'text' => $objp->title,
 
  142          $this->info_box_contents[$i][] = array(
 
  143            'td' => 
'class="tdoverflowmax100"',
 
  144            'text' => ($objp->fk_soc > 0 ? $companystatic->getNomUrl(1) : 
''),
 
  148          $sql = 
"SELECT count(*) as nb, sum(progress) as totprogress";
 
  149          $sql .= 
" FROM ".MAIN_DB_PREFIX.
"projet as p LEFT JOIN ".MAIN_DB_PREFIX.
"projet_task as pt on pt.fk_projet = p.rowid";
 
  150          $sql .= 
" WHERE p.entity IN (".getEntity(
'project').
')';
 
  151          $sql .= 
" AND p.rowid = ".((int) $objp->rowid);
 
  153          $resultTask = $this->db->query($sql);
 
  155            $objTask = $this->db->fetch_object($resultTask);
 
  156            $this->info_box_contents[$i][] = array(
 
  157              'td' => 
'class="right"',
 
  158              'text' => $objTask->nb.
" ".$langs->trans(
"Tasks"),
 
  160            if ($objTask->nb > 0) {
 
  161              $this->info_box_contents[$i][] = array(
 
  162                'td' => 
'class="right"',
 
  163                'text' => round($objTask->totprogress / $objTask->nb, 0).
"%",
 
  166              $this->info_box_contents[$i][] = array(
'td' => 
'class="right"', 
'text' => 
"N/A ");
 
  168            $totalnbTask += $objTask->nb;
 
  170            $this->info_box_contents[$i][] = array(
'td' => 
'class="right"', 
'text' => round(0));
 
  171            $this->info_box_contents[$i][] = array(
'td' => 
'class="right"', 
'text' => 
"N/A ");
 
  173          $this->info_box_contents[$i][] = array(
'td' => 
'class="right"', 
'text' => $projectstatic->getLibStatut(3));
 
  178          $this->info_box_contents[$i][] = array(
'td' => 
'colspan="6"', 
'text' => 
'...');
 
  186      $this->info_box_contents[$i][] = array(
 
  187        'tr' => 
'class="liste_total_wrap"',
 
  188        'td' => 
'class="liste_total"',
 
  189        'text' => $langs->trans(
"Total").
" ".$textHead,
 
  191      $this->info_box_contents[$i][] = array(
 
  192        'td' => 
'class="right liste_total" ',
 
  193        'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
 
  195      $this->info_box_contents[$i][] = array(
 
  196        'td' => 
'class="right liste_total" ',
 
  197        'text' => (($max < $num) ? 
'' : (round($totalnbTask, 0).
" ".$langs->trans(
"Tasks"))),
 
  199      $this->info_box_contents[$i][] = array(
 
  200        'td' => 
'class="liste_total"',
 
  203      $this->info_box_contents[$i][] = array(
 
  204        'td' => 
'class="liste_total"',
 
  207      $this->info_box_contents[$i][] = array(
 
  208        'td' => 
'class="liste_total"',