79 global $user, $langs, $hookmanager;
80 $langs->load(
"boxes");
84 include_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
85 $thirdpartystatic =
new Client($this->db);
87 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedCustomers", $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.datec, s.tms, s.status";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
95 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
96 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
98 $sql .=
" WHERE s.client IN (1, 3)";
99 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
100 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
101 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
104 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
105 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
106 if (empty($reshook)) {
107 if ($user->socid > 0) {
108 $sql .=
" AND s.rowid = ".((int) $user->socid);
111 $sql .= $hookmanager->resPrint;
112 $sql .=
" ORDER BY s.tms DESC";
113 $sql .= $this->db->plimit($max, 0);
115 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
116 $result = $this->db->query($sql);
118 $num = $this->db->num_rows($result);
121 while ($line < $num) {
122 $objp = $this->db->fetch_object($result);
123 $datec = $this->db->jdate($objp->datec);
124 $datem = $this->db->jdate($objp->tms);
126 $thirdpartystatic->id = $objp->socid;
127 $thirdpartystatic->name = $objp->name;
128 $thirdpartystatic->name_alias = $objp->name_alias;
129 $thirdpartystatic->code_client = $objp->code_client;
130 $thirdpartystatic->code_compta = $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' => $thirdpartystatic->LibStatut($objp->status, 3)
156 $this->info_box_contents[$line][0] = array(
157 'td' =>
'class="center"',
158 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedCustomers").
'</span>'
162 $this->db->free($result);
164 $this->info_box_contents[0][0] = array(
167 'text' => ($this->db->error().
' sql='.$sql)
171 $this->info_box_contents[0][0] = array(
172 'td' =>
'class="nohover left"',
173 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'