72 global $user, $langs, $hookmanager;
76 $thirdpartystatic =
new Client($this->db);
78 $this->info_box_head = array(
79 'text' => $langs->trans(
"BoxTitleLastModifiedProspects", $max).
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/societe/list.php?type=p&sortfield=s.tms&sortorder=DESC"><span class="badge">...</span></a>',
82 if ($user->hasRight(
'societe',
'lire')) {
83 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
84 $sql .=
", s.code_client, s.code_compta, s.client";
85 $sql .=
", s.logo, s.email, s.entity";
86 $sql .=
", s.fk_stcomm";
87 $sql .=
", s.datec, s.tms, s.status";
88 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
89 if (!$user->hasRight(
'societe',
'client',
'voir')) {
90 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
92 $sql .=
" WHERE s.client IN (2, 3)";
93 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
94 if (!$user->hasRight(
'societe',
'client',
'voir')) {
95 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
98 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
99 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
100 if (empty($reshook)) {
101 if ($user->socid > 0) {
102 $sql .=
" AND s.rowid = ".((int) $user->socid);
105 $sql .= $hookmanager->resPrint;
106 $sql .=
" ORDER BY s.tms DESC";
107 $sql .= $this->db->plimit($max, 0);
109 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
110 $resql = $this->db->query($sql);
112 $num = $this->db->num_rows($resql);
115 while ($line < $num) {
116 $objp = $this->db->fetch_object($resql);
117 $datec = $this->db->jdate($objp->datec);
118 $datem = $this->db->jdate($objp->tms);
120 $thirdpartystatic->id = $objp->socid;
121 $thirdpartystatic->name = $objp->name;
122 $thirdpartystatic->name_alias = $objp->name_alias;
123 $thirdpartystatic->code_client = $objp->code_client;
124 $thirdpartystatic->code_compta = $objp->code_compta;
125 $thirdpartystatic->client = $objp->client;
126 $thirdpartystatic->logo = $objp->logo;
127 $thirdpartystatic->email = $objp->email;
128 $thirdpartystatic->entity = $objp->entity;
130 $this->info_box_contents[$line][] = array(
131 'td' =>
'class="tdoverflowmax150"',
132 'text' => $thirdpartystatic->getNomUrl(1),
136 $this->info_box_contents[$line][] = array(
141 $this->info_box_contents[$line][] = array(
142 'td' =>
'class="right" width="18"',
143 'text' => str_replace(
'img ',
'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)),
146 $this->info_box_contents[$line][] = array(
147 'td' =>
'class="right" width="18"',
148 'text' => $thirdpartystatic->LibStatut($objp->status, 3),
155 $this->info_box_contents[$line][0] = array(
156 'td' =>
'class="center"',
157 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedProspects").
'</span>'
161 $this->db->free($resql);
163 $this->info_box_contents[0][0] = array(
166 'text' => ($this->db->error().
' sql='.$sql),
170 $this->info_box_contents[0][0] = array(
171 'td' =>
'class="nohover left"',
172 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'