27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"lastsuppliers";
36 public $boximg =
"object_company";
37 public $boxlabel =
"BoxLastSuppliers";
38 public $depends = array(
"fournisseur");
47 public $info_box_head = array();
48 public $info_box_contents = array();
63 $this->hidden = !($user->rights->societe->lire && empty($user->socid));
74 global $conf, $user, $langs;
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->rights->societe->lire)
86 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
87 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
88 $sql .=
", s.logo, s.email, s.entity";
89 $sql .=
", s.datec, s.tms, s.status";
90 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
91 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
92 $sql .=
" WHERE s.fournisseur = 1";
93 $sql .=
" AND s.entity IN (".getEntity(
'societe').
")";
94 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
95 if ($user->socid) $sql .=
" AND s.rowid = ".$user->socid;
96 $sql .=
" ORDER BY s.tms DESC ";
97 $sql .= $this->
db->plimit($max, 0);
99 $result = $this->
db->query($sql);
102 $num = $this->
db->num_rows($result);
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(
128 'td' =>
'class="right"',
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 opacitymedium"',
144 'text'=>$langs->trans(
"NoRecordedSuppliers"),
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 opacitymedium left"',
159 'text' => $langs->trans(
"ReadPermissionNotAllowed")
172 public function showBox($head = null, $contents = null, $nooutput = 0)
174 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
loadBox($max=5)
Load data into info_box_contents array to show array later.
Class to manage the box to show last suppliers.
$conf db
API class for accounts.
Class to manage suppliers.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
__construct($db, $param)
Constructor.