81    global $user, $langs, $hookmanager;
 
   85    $thirdpartystatic = 
new Client($this->db);
 
   87    $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedProspects", $max));
 
   89    if ($user->hasRight(
'societe', 
'lire')) {
 
   90      $sql = 
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
 
   91      $sql .= 
", s.code_client, s.code_compta, s.client";
 
   92      $sql .= 
", s.logo, s.email, s.entity";
 
   93      $sql .= 
", s.fk_stcomm";
 
   94      $sql .= 
", s.datec, s.tms, s.status";
 
   95      $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s";
 
   96      if (!$user->hasRight(
'societe', 
'client', 
'voir') && !$user->socid) {
 
   97        $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
   99      $sql .= 
" WHERE s.client IN (2, 3)";
 
  100      $sql .= 
" AND s.entity IN (".getEntity(
'societe').
")";
 
  101      if (!$user->hasRight(
'societe', 
'client', 
'voir') && !$user->socid) {
 
  102        $sql .= 
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
 
  105      $parameters = array(
'socid' => $user->socid, 
'boxcode' => $this->boxcode);
 
  106      $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic); 
 
  107      if (empty($reshook)) {
 
  108        if ($user->socid > 0) {
 
  109          $sql .= 
" AND s.rowid = ".((int) $user->socid);
 
  112      $sql .= $hookmanager->resPrint;
 
  113      $sql .= 
" ORDER BY s.tms DESC";
 
  114      $sql .= $this->db->plimit($max, 0);
 
  116      dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
 
  117      $resql = $this->db->query($sql);
 
  119        $num = $this->db->num_rows($resql);
 
  122        while ($line < $num) {
 
  123          $objp = $this->db->fetch_object($resql);
 
  124          $datec = $this->db->jdate($objp->datec);
 
  125          $datem = $this->db->jdate($objp->tms);
 
  127          $thirdpartystatic->id = $objp->socid;
 
  128          $thirdpartystatic->name = $objp->name;
 
  129          $thirdpartystatic->name_alias = $objp->name_alias;
 
  130          $thirdpartystatic->code_client = $objp->code_client;
 
  131          $thirdpartystatic->code_compta = $objp->code_compta;
 
  132          $thirdpartystatic->client = $objp->client;
 
  133          $thirdpartystatic->logo = $objp->logo;
 
  134          $thirdpartystatic->email = $objp->email;
 
  135          $thirdpartystatic->entity = $objp->entity;
 
  137          $this->info_box_contents[$line][] = array(
 
  138            'td' => 
'class="tdoverflowmax150"',
 
  139            'text' => $thirdpartystatic->getNomUrl(1),
 
  143          $this->info_box_contents[$line][] = array(
 
  148          $this->info_box_contents[$line][] = array(
 
  149            'td' => 
'class="right" width="18"',
 
  150            'text' => str_replace(
'img ', 
'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)),
 
  153          $this->info_box_contents[$line][] = array(
 
  154            'td' => 
'class="right" width="18"',
 
  155            'text' => $thirdpartystatic->LibStatut($objp->status, 3),
 
  162          $this->info_box_contents[$line][0] = array(
 
  163            'td' => 
'class="center"',
 
  164            'text'=> 
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedProspects").
'</span>' 
  168        $this->db->free($resql);
 
  170        $this->info_box_contents[0][0] = array(
 
  173          'text' => ($this->db->error().
' sql='.$sql),
 
  177      $this->info_box_contents[0][0] = array(
 
  178        'td' => 
'class="nohover left"',
 
  179        'text' => 
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'