62 global $conf, $user, $langs;
63 $langs->load(
"boxes");
67 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
69 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
72 $text = $langs->trans(
"BoxTitleLatest".(
getDolGlobalString(
'MAIN_LASTBOX_ON_OBJECT_DATE') ?
"" :
"Modified").
"SupplierOrders", $max);
73 $this->info_box_head = array(
74 'text' => $text.
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?sortfield=cf.tms&sortorder=DESC"><span class="badge">...</span></a>'
77 if ($user->hasRight(
'fournisseur',
'commande',
'lire')) {
78 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
79 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
80 $sql .=
", s.logo, s.email, s.entity";
81 $sql .=
", c.rowid, c.ref, c.tms, c.date_commande";
82 $sql .=
", c.total_ht";
83 $sql .=
", c.total_tva";
84 $sql .=
", c.total_ttc";
85 $sql .=
", c.fk_statut as status";
86 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
87 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
88 if (!$user->hasRight(
'societe',
'client',
'voir')) {
89 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
91 $sql .=
" WHERE c.fk_soc = s.rowid";
92 $sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
93 if (!$user->hasRight(
'societe',
'client',
'voir')) {
94 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
97 $sql .=
" AND s.rowid = ".((int) $user->socid);
100 $sql .=
" ORDER BY c.date_commande DESC, c.ref DESC ";
102 $sql .=
" ORDER BY c.tms DESC, c.ref DESC ";
104 $sql .= $this->db->plimit($max, 0);
106 $result = $this->db->query($sql);
108 $num = $this->db->num_rows($result);
111 while ($line < $num) {
112 $objp = $this->db->fetch_object($result);
113 $date = $this->db->jdate($objp->date_commande);
114 $datem = $this->db->jdate($objp->tms);
116 $supplierorderstatic->id = $objp->rowid;
117 $supplierorderstatic->ref = $objp->ref;
118 $supplierorderstatic->statut = $objp->status;
119 $supplierorderstatic->status = $objp->status;
120 $supplierorderstatic->date = $date;
121 $supplierorderstatic->date_modification = $datem;
123 $thirdpartystatic->id = $objp->socid;
124 $thirdpartystatic->name = $objp->name;
126 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
127 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
128 $thirdpartystatic->fournisseur = $objp->fournisseur;
129 $thirdpartystatic->logo = $objp->logo;
130 $thirdpartystatic->email = $objp->email;
131 $thirdpartystatic->entity = $objp->entity;
133 $this->info_box_contents[$line][] = array(
134 'td' =>
'class="nowraponall"',
135 'text' => $supplierorderstatic->getNomUrl(1),
139 $this->info_box_contents[$line][] = array(
140 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
141 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
145 $this->info_box_contents[$line][] = array(
146 'td' =>
'class="nowraponall right amount"',
147 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
150 $this->info_box_contents[$line][] = array(
155 $this->info_box_contents[$line][] = array(
156 'td' =>
'class="right" width="18"',
157 'text' => $supplierorderstatic->LibStatut($objp->status, 3),
164 $this->info_box_contents[$line][] = array(
165 'td' =>
'class="center"',
166 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoSupplierOrder").
'</span>',
170 $this->db->free($result);
172 $this->info_box_contents[0][] = array(
175 'text' => ($this->db->error().
' sql='.$sql),
179 $this->info_box_contents[0][] = array(
180 'td' =>
'class="nohover left"',
181 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'