65 global
$conf, $user, $langs;
66 $langs->load(
"boxes");
70 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
72 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
75 $text = $langs->trans(
"BoxTitleLatest".(
getDolGlobalString(
'MAIN_LASTBOX_ON_OBJECT_DATE') ?
"" :
"Modified").
"SupplierOrders", $max);
76 $this->info_box_head = array(
77 'text' => $text.
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?sortfield=cf.tms&sortorder=DESC"><span class="badge">...</span></a>'
80 if ($user->hasRight(
'fournisseur',
'commande',
'lire')) {
81 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
82 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
83 $sql .=
", s.logo, s.email, s.entity";
84 $sql .=
", c.rowid, c.ref, c.tms, c.date_commande";
85 $sql .=
", c.total_ht";
86 $sql .=
", c.total_tva";
87 $sql .=
", c.total_ttc";
88 $sql .=
", c.fk_statut as status";
89 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
90 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
91 if (!$user->hasRight(
'societe',
'client',
'voir')) {
92 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
94 $sql .=
" WHERE c.fk_soc = s.rowid";
95 $sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
96 if (!$user->hasRight(
'societe',
'client',
'voir')) {
97 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
100 $sql .=
" AND s.rowid = ".((int) $user->socid);
103 $sql .=
" ORDER BY c.date_commande DESC, c.ref DESC ";
105 $sql .=
" ORDER BY c.tms DESC, c.ref DESC ";
107 $sql .= $this->db->plimit($max, 0);
109 $result = $this->db->query($sql);
111 $num = $this->db->num_rows($result);
114 while ($line < $num) {
115 $objp = $this->db->fetch_object($result);
116 $date = $this->db->jdate($objp->date_commande);
117 $datem = $this->db->jdate($objp->tms);
119 $supplierorderstatic->id = $objp->rowid;
120 $supplierorderstatic->ref = $objp->ref;
121 $supplierorderstatic->statut = $objp->status;
122 $supplierorderstatic->status = $objp->status;
123 $supplierorderstatic->date = $date;
124 $supplierorderstatic->date_modification = $datem;
126 $thirdpartystatic->id = $objp->socid;
127 $thirdpartystatic->name = $objp->name;
129 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
130 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
131 $thirdpartystatic->fournisseur = $objp->fournisseur;
132 $thirdpartystatic->logo = $objp->logo;
133 $thirdpartystatic->email = $objp->email;
134 $thirdpartystatic->entity = $objp->entity;
136 $this->info_box_contents[$line][] = array(
137 'td' =>
'class="nowraponall"',
138 'text' => $supplierorderstatic->getNomUrl(1),
142 $this->info_box_contents[$line][] = array(
143 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
144 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
148 $this->info_box_contents[$line][] = array(
149 'td' =>
'class="nowraponall right amount"',
150 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1,
$conf->currency),
153 $this->info_box_contents[$line][] = array(
158 $this->info_box_contents[$line][] = array(
159 'td' =>
'class="right" width="18"',
160 'text' => $supplierorderstatic->LibStatut($objp->status, 3),
166 $this->db->free($result);
168 $this->info_box_contents[0][] = array(
171 'text' => ($this->db->error().
' sql='.$sql),
175 $this->info_box_contents[0][] = array(
176 'td' =>
'class="nohover left"',
177 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'