74 global $user, $langs, $hookmanager;
75 $langs->load(
"boxes");
79 include_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
80 $thirdpartystatic =
new Client($this->db);
82 $this->info_box_head = array(
83 '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>',
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 as code_compta_client, s.client";
89 $sql .=
", s.logo, s.email, s.entity";
90 $sql .=
", s.datec, s.tms, s.status";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
92 if (!$user->hasRight(
'societe',
'client',
'voir')) {
93 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
95 $sql .=
" WHERE s.client IN (1, 3)";
96 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
97 if (!$user->hasRight(
'societe',
'client',
'voir')) {
98 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
101 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
102 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
103 if (empty($reshook)) {
104 if ($user->socid > 0) {
105 $sql .=
" AND s.rowid = ".((int) $user->socid);
108 $sql .= $hookmanager->resPrint;
109 $sql .=
" ORDER BY s.tms DESC";
110 $sql .= $this->db->plimit($max, 0);
112 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
113 $result = $this->db->query($sql);
115 $num = $this->db->num_rows($result);
118 while ($line < $num) {
119 $objp = $this->db->fetch_object($result);
120 $datec = $this->db->jdate($objp->datec);
121 $datem = $this->db->jdate($objp->tms);
123 $thirdpartystatic->id = $objp->socid;
124 $thirdpartystatic->name = $objp->name;
125 $thirdpartystatic->name_alias = $objp->name_alias;
126 $thirdpartystatic->code_client = $objp->code_client;
127 $thirdpartystatic->code_compta = $objp->code_compta_client;
128 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
129 $thirdpartystatic->client = $objp->client;
130 $thirdpartystatic->logo = $objp->logo;
131 $thirdpartystatic->email = $objp->email;
132 $thirdpartystatic->entity = $objp->entity;
134 $this->info_box_contents[$line][] = array(
135 'td' =>
'class="tdoverflowmax150"',
136 'text' => $thirdpartystatic->getNomUrl(1),
140 $this->info_box_contents[$line][] = array(
145 $this->info_box_contents[$line][] = array(
146 'td' =>
'class="right" width="18"',
147 'text' => $thirdpartystatic->LibStatut($objp->status, 3)
154 $this->db->free($result);
156 $this->info_box_contents[0][0] = array(
159 'text' => ($this->db->error().
' sql='.$sql)
163 $this->info_box_contents[0][0] = array(
164 'td' =>
'class="nohover left"',
165 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'