70 global $user, $langs, $hookmanager;
71 $langs->load(
"boxes");
75 include_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
76 $thirdpartystatic =
new Client($this->db);
78 $this->info_box_head = array(
79 'text' => $langs->trans(
"BoxTitleLastModifiedCustomers", $max).
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/societe/list.php?type=c&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.datec, s.tms, s.status";
87 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
88 if (!$user->hasRight(
'societe',
'client',
'voir')) {
89 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
91 $sql .=
" WHERE s.client IN (1, 3)";
92 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
93 if (!$user->hasRight(
'societe',
'client',
'voir')) {
94 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
97 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
98 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
99 if (empty($reshook)) {
100 if ($user->socid > 0) {
101 $sql .=
" AND s.rowid = ".((int) $user->socid);
104 $sql .= $hookmanager->resPrint;
105 $sql .=
" ORDER BY s.tms DESC";
106 $sql .= $this->db->plimit($max, 0);
108 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
109 $result = $this->db->query($sql);
111 $num = $this->db->num_rows($result);
114 while ($line < $num) {
115 $objp = $this->db->fetch_object($result);
116 $datec = $this->db->jdate($objp->datec);
117 $datem = $this->db->jdate($objp->tms);
119 $thirdpartystatic->id = $objp->socid;
120 $thirdpartystatic->name = $objp->name;
121 $thirdpartystatic->name_alias = $objp->name_alias;
122 $thirdpartystatic->code_client = $objp->code_client;
123 $thirdpartystatic->code_compta = $objp->code_compta;
124 $thirdpartystatic->client = $objp->client;
125 $thirdpartystatic->logo = $objp->logo;
126 $thirdpartystatic->email = $objp->email;
127 $thirdpartystatic->entity = $objp->entity;
129 $this->info_box_contents[$line][] = array(
130 'td' =>
'class="tdoverflowmax150"',
131 'text' => $thirdpartystatic->getNomUrl(1),
135 $this->info_box_contents[$line][] = array(
140 $this->info_box_contents[$line][] = array(
141 'td' =>
'class="right" width="18"',
142 'text' => $thirdpartystatic->LibStatut($objp->status, 3)
149 $this->info_box_contents[$line][0] = array(
150 'td' =>
'class="center"',
151 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedCustomers").
'</span>'
155 $this->db->free($result);
157 $this->info_box_contents[0][0] = array(
160 'text' => ($this->db->error().
' sql='.$sql)
164 $this->info_box_contents[0][0] = array(
165 'td' =>
'class="nohover left"',
166 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'