66 global $user, $langs, $hookmanager;
67 $langs->load(
"boxes");
71 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
74 $this->info_box_head = array(
75 'text' => $langs->trans(
"BoxTitleLastModifiedSuppliers", $max).
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/societe/list.php?type=f&sortfield=s.tms&sortorder=DESC"><span class="badge">...</span></a>'
78 if ($user->hasRight(
'societe',
'lire')) {
79 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
80 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
81 $sql .=
", s.logo, s.email, s.entity";
82 $sql .=
", s.datec, s.tms, s.status";
83 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
84 if (!$user->hasRight(
'societe',
'client',
'voir')) {
85 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
87 $sql .=
" WHERE s.fournisseur = 1";
88 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
89 if (!$user->hasRight(
'societe',
'client',
'voir')) {
90 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
93 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
94 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
95 if (empty($reshook)) {
96 if ($user->socid > 0) {
97 $sql .=
" AND s.rowid = ".((int) $user->socid);
100 $sql .= $hookmanager->resPrint;
101 $sql .=
" ORDER BY s.tms DESC ";
102 $sql .= $this->db->plimit($max, 0);
104 $result = $this->db->query($sql);
106 $num = $this->db->num_rows($result);
109 while ($line < $num) {
110 $objp = $this->db->fetch_object($result);
111 $datec = $this->db->jdate($objp->datec);
112 $datem = $this->db->jdate($objp->tms);
114 $thirdpartystatic->id = $objp->socid;
115 $thirdpartystatic->name = $objp->name;
116 $thirdpartystatic->name_alias = $objp->name_alias;
117 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
118 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
119 $thirdpartystatic->fournisseur = $objp->fournisseur;
120 $thirdpartystatic->logo = $objp->logo;
121 $thirdpartystatic->email = $objp->email;
122 $thirdpartystatic->entity = $objp->entity;
124 $this->info_box_contents[$line][] = array(
126 'text' => $thirdpartystatic->getNomUrl(1,
'', 40),
130 $this->info_box_contents[$line][] = array(
135 $this->info_box_contents[$line][] = array(
136 'td' =>
'class="right" width="18"',
137 'text' => $thirdpartystatic->LibStatut($objp->status, 3),
151 $this->db->free($result);
153 $this->info_box_contents[0][0] = array(
156 'text' => ($this->db->error().
' sql='.$sql),
160 $this->info_box_contents[0][0] = array(
161 'td' =>
'class="nohover left"',
162 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'