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, st.libelle as stcomm_label, st.picto as stcomm_picto";
91 $sql .=
", s.datec, s.tms, s.status";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
93 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_stcomm as st ON s.fk_stcomm = st.id";
94 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
95 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
97 $sql .=
" WHERE s.client IN (2, 3)";
98 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
99 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
100 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
103 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
104 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
105 if (empty($reshook)) {
106 if ($user->socid > 0) {
107 $sql .=
" AND s.rowid = ".((int) $user->socid);
110 $sql .= $hookmanager->resPrint;
111 $sql .=
" ORDER BY s.tms DESC";
112 $sql .= $this->db->plimit($max, 0);
114 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
115 $resql = $this->db->query($sql);
117 $num = $this->db->num_rows($resql);
120 while ($line < $num) {
121 $objp = $this->db->fetch_object($resql);
122 $datec = $this->db->jdate($objp->datec);
123 $datem = $this->db->jdate($objp->tms);
125 $thirdpartystatic->id = $objp->socid;
126 $thirdpartystatic->name = $objp->name;
127 $thirdpartystatic->name_alias = $objp->name_alias;
128 $thirdpartystatic->code_client = $objp->code_client;
129 $thirdpartystatic->code_compta = $objp->code_compta;
130 $thirdpartystatic->code_compta_client = $objp->code_compta;
131 $thirdpartystatic->client = $objp->client;
132 $thirdpartystatic->logo = $objp->logo;
133 $thirdpartystatic->email = $objp->email;
134 $thirdpartystatic->entity = $objp->entity;
136 $this->info_box_contents[$line][] = array(
137 'td' =>
'class="tdoverflowmax150"',
138 'text' => $thirdpartystatic->getNomUrl(1),
142 $this->info_box_contents[$line][] = array(
147 $this->info_box_contents[$line][] = array(
148 'td' =>
'class="right" width="18"',
149 'text' => str_replace(
'img ',
'img height="14" ', $thirdpartystatic->LibProspCommStatut($objp->fk_stcomm, 3, $objp->stcomm_label, $objp->stcomm_picto)),
152 $this->info_box_contents[$line][] = array(
153 'td' =>
'class="right" width="18"',
154 'text' => $thirdpartystatic->LibStatut($objp->status, 3),
160 $this->db->free($resql);
162 $this->info_box_contents[0][0] = array(
165 'text' => ($this->db->error().
' sql='.$sql),
169 $this->info_box_contents[0][0] = array(
170 'td' =>
'class="nohover left"',
171 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'