74 global $conf, $user, $langs, $hookmanager;
75 $langs->load(
"boxes");
79 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
82 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastModifiedSuppliers", $max));
84 if ($user->hasRight(
'societe',
'lire')) {
85 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
86 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
87 $sql .=
", s.logo, s.email, s.entity";
88 $sql .=
", s.datec, s.tms, s.status";
89 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
90 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
91 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
93 $sql .=
" WHERE s.fournisseur = 1";
94 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
95 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
96 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
99 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
100 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
101 if (empty($reshook)) {
102 if ($user->socid > 0) {
103 $sql .=
" AND s.rowid = ".((int) $user->socid);
106 $sql .= $hookmanager->resPrint;
107 $sql .=
" ORDER BY s.tms DESC ";
108 $sql .= $this->db->plimit($max, 0);
110 $result = $this->db->query($sql);
112 $num = $this->db->num_rows($result);
115 while ($line < $num) {
116 $objp = $this->db->fetch_object($result);
117 $datec = $this->db->jdate($objp->datec);
118 $datem = $this->db->jdate($objp->tms);
120 $thirdpartystatic->id = $objp->socid;
121 $thirdpartystatic->name = $objp->name;
122 $thirdpartystatic->name_alias = $objp->name_alias;
123 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
124 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
125 $thirdpartystatic->fournisseur = $objp->fournisseur;
126 $thirdpartystatic->logo = $objp->logo;
127 $thirdpartystatic->email = $objp->email;
128 $thirdpartystatic->entity = $objp->entity;
130 $this->info_box_contents[$line][] = array(
132 'text' => $thirdpartystatic->getNomUrl(1,
'', 40),
136 $this->info_box_contents[$line][] = array(
141 $this->info_box_contents[$line][] = array(
142 'td' =>
'class="right" width="18"',
143 'text' => $thirdpartystatic->LibStatut($objp->status, 3),
150 $langs->load(
"suppliers");
151 $this->info_box_contents[$line][0] = array(
152 'td' =>
'class="center"',
153 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedSuppliers").
'</span>'
157 $this->db->free($result);
159 $this->info_box_contents[0][0] = array(
162 'text' => ($this->db->error().
' sql='.$sql),
166 $this->info_box_contents[0][0] = array(
167 'td' =>
'class="nohover left"',
168 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'