61 global $conf, $user, $langs;
62 $langs->load(
"boxes");
66 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
68 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
71 $text = $langs->trans(
"BoxTitleLatest".(
getDolGlobalString(
'MAIN_LASTBOX_ON_OBJECT_DATE') ?
"" :
"Modified").
"SupplierOrders", $max);
72 $this->info_box_head = array(
73 'text' => $text.
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?sortfield=cf.tms&sortorder=DESC"><span class="badge">...</span></a>'
76 if ($user->hasRight(
'fournisseur',
'commande',
'lire')) {
77 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
78 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
79 $sql .=
", s.logo, s.email, s.entity";
80 $sql .=
", c.rowid, c.ref, c.tms, c.date_commande";
81 $sql .=
", c.total_ht";
82 $sql .=
", c.total_tva";
83 $sql .=
", c.total_ttc";
84 $sql .=
", c.fk_statut as status";
85 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
86 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
87 if (!$user->hasRight(
'societe',
'client',
'voir')) {
88 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
90 $sql .=
" WHERE c.fk_soc = s.rowid";
91 $sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
92 if (!$user->hasRight(
'societe',
'client',
'voir')) {
93 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
96 $sql .=
" AND s.rowid = ".((int) $user->socid);
99 $sql .=
" ORDER BY c.date_commande DESC, c.ref DESC ";
101 $sql .=
" ORDER BY c.tms DESC, c.ref DESC ";
103 $sql .= $this->db->plimit($max, 0);
105 $result = $this->db->query($sql);
107 $num = $this->db->num_rows($result);
110 while ($line < $num) {
111 $objp = $this->db->fetch_object($result);
112 $date = $this->db->jdate($objp->date_commande);
113 $datem = $this->db->jdate($objp->tms);
115 $supplierorderstatic->id = $objp->rowid;
116 $supplierorderstatic->ref = $objp->ref;
117 $supplierorderstatic->statut = $objp->status;
118 $supplierorderstatic->status = $objp->status;
119 $supplierorderstatic->date = $date;
120 $supplierorderstatic->date_modification = $datem;
122 $thirdpartystatic->id = $objp->socid;
123 $thirdpartystatic->name = $objp->name;
125 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
126 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
127 $thirdpartystatic->fournisseur = $objp->fournisseur;
128 $thirdpartystatic->logo = $objp->logo;
129 $thirdpartystatic->email = $objp->email;
130 $thirdpartystatic->entity = $objp->entity;
132 $this->info_box_contents[$line][] = array(
133 'td' =>
'class="nowraponall"',
134 'text' => $supplierorderstatic->getNomUrl(1),
138 $this->info_box_contents[$line][] = array(
139 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
140 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
144 $this->info_box_contents[$line][] = array(
145 'td' =>
'class="nowraponall right amount"',
146 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
149 $this->info_box_contents[$line][] = array(
154 $this->info_box_contents[$line][] = array(
155 'td' =>
'class="right" width="18"',
156 'text' => $supplierorderstatic->LibStatut($objp->status, 3),
163 $this->info_box_contents[$line][] = array(
164 'td' =>
'class="center"',
165 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoSupplierOrder").
'</span>',
169 $this->db->free($result);
171 $this->info_box_contents[0][] = array(
174 'text' => ($this->db->error().
' sql='.$sql),
178 $this->info_box_contents[0][] = array(
179 'td' =>
'class="nohover left"',
180 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'