76 global $user, $langs, $hookmanager;
80 $thirdpartystatic =
new Client($this->db);
82 $this->info_box_head = array(
83 '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>',
86 if ($user->hasRight(
'societe',
'lire')) {
87 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
88 $sql .=
", s.code_client, s.code_compta, s.client";
89 $sql .=
", s.logo, s.email, s.entity";
90 $sql .=
", s.fk_stcomm";
91 $sql .=
", s.datec, s.tms, s.status";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
93 if (!$user->hasRight(
'societe',
'client',
'voir')) {
94 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
96 $sql .=
" WHERE s.client IN (2, 3)";
97 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
98 if (!$user->hasRight(
'societe',
'client',
'voir')) {
99 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
102 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
103 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
104 if (empty($reshook)) {
105 if ($user->socid > 0) {
106 $sql .=
" AND s.rowid = ".((int) $user->socid);
109 $sql .= $hookmanager->resPrint;
110 $sql .=
" ORDER BY s.tms DESC";
111 $sql .= $this->db->plimit($max, 0);
113 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
114 $resql = $this->db->query($sql);
116 $num = $this->db->num_rows($resql);
119 while ($line < $num) {
120 $objp = $this->db->fetch_object($resql);
121 $datec = $this->db->jdate($objp->datec);
122 $datem = $this->db->jdate($objp->tms);
124 $thirdpartystatic->id = $objp->socid;
125 $thirdpartystatic->name = $objp->name;
126 $thirdpartystatic->name_alias = $objp->name_alias;
127 $thirdpartystatic->code_client = $objp->code_client;
128 $thirdpartystatic->code_compta = $objp->code_compta;
129 $thirdpartystatic->code_compta_client = $objp->code_compta;
130 $thirdpartystatic->client = $objp->client;
131 $thirdpartystatic->logo = $objp->logo;
132 $thirdpartystatic->email = $objp->email;
133 $thirdpartystatic->entity = $objp->entity;
135 $this->info_box_contents[$line][] = array(
136 'td' =>
'class="tdoverflowmax150"',
137 'text' => $thirdpartystatic->getNomUrl(1),
141 $this->info_box_contents[$line][] = array(
146 $this->info_box_contents[$line][] = array(
147 'td' =>
'class="right" width="18"',
148 'text' => str_replace(
'img ',
'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3)),
151 $this->info_box_contents[$line][] = array(
152 'td' =>
'class="right" width="18"',
153 'text' => $thirdpartystatic->LibStatut($objp->status, 3),
159 $this->db->free($resql);
161 $this->info_box_contents[0][0] = array(
164 'text' => ($this->db->error().
' sql='.$sql),
168 $this->info_box_contents[0][0] = array(
169 'td' =>
'class="nohover left"',
170 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'