63 global $user, $langs, $hookmanager;
64 $langs->load(
"boxes");
68 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
71 $this->info_box_head = array(
72 '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>'
75 if ($user->hasRight(
'societe',
'lire')) {
76 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
77 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
78 $sql .=
", s.logo, s.email, s.entity";
79 $sql .=
", s.datec, s.tms, s.status";
80 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
81 if (!$user->hasRight(
'societe',
'client',
'voir')) {
82 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
84 $sql .=
" WHERE s.fournisseur = 1";
85 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
86 if (!$user->hasRight(
'societe',
'client',
'voir')) {
87 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
90 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
91 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdpartystatic);
92 if (empty($reshook)) {
93 if ($user->socid > 0) {
94 $sql .=
" AND s.rowid = ".((int) $user->socid);
97 $sql .= $hookmanager->resPrint;
98 $sql .=
" ORDER BY s.tms DESC ";
99 $sql .= $this->db->plimit($max, 0);
101 $result = $this->db->query($sql);
103 $num = $this->db->num_rows($result);
106 while ($line < $num) {
107 $objp = $this->db->fetch_object($result);
108 $datec = $this->db->jdate($objp->datec);
109 $datem = $this->db->jdate($objp->tms);
111 $thirdpartystatic->id = $objp->socid;
112 $thirdpartystatic->name = $objp->name;
113 $thirdpartystatic->name_alias = $objp->name_alias;
114 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
115 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
116 $thirdpartystatic->fournisseur = $objp->fournisseur;
117 $thirdpartystatic->logo = $objp->logo;
118 $thirdpartystatic->email = $objp->email;
119 $thirdpartystatic->entity = $objp->entity;
121 $this->info_box_contents[$line][] = array(
123 'text' => $thirdpartystatic->getNomUrl(1,
'', 40),
127 $this->info_box_contents[$line][] = array(
132 $this->info_box_contents[$line][] = array(
133 'td' =>
'class="right" width="18"',
134 'text' => $thirdpartystatic->LibStatut($objp->status, 3),
141 $langs->load(
"suppliers");
142 $this->info_box_contents[$line][0] = array(
143 'td' =>
'class="center"',
144 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedSuppliers").
'</span>'
148 $this->db->free($result);
150 $this->info_box_contents[0][0] = array(
153 'text' => ($this->db->error().
' sql='.$sql),
157 $this->info_box_contents[0][0] = array(
158 'td' =>
'class="nohover left"',
159 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'