71 global $conf, $user, $langs;
72 $langs->load(
"boxes");
76 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
78 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
81 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLatest".(getDolGlobalString(
'MAIN_LASTBOX_ON_OBJECT_DATE') ?
"" :
"Modified").
"SupplierOrders", $max));
83 if ($user->hasRight(
'fournisseur',
'commande',
'lire')) {
84 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
85 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
86 $sql .=
", s.logo, s.email, s.entity";
87 $sql .=
", c.rowid, c.ref, c.tms, c.date_commande";
88 $sql .=
", c.total_ht";
89 $sql .=
", c.total_tva";
90 $sql .=
", c.total_ttc";
91 $sql .=
", c.fk_statut as status";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
93 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
94 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
95 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
97 $sql .=
" WHERE c.fk_soc = s.rowid";
98 $sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
99 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
100 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
103 $sql .=
" AND s.rowid = ".((int) $user->socid);
106 $sql .=
" ORDER BY c.date_commande DESC, c.ref DESC ";
108 $sql .=
" ORDER BY c.tms DESC, c.ref DESC ";
110 $sql .= $this->db->plimit($max, 0);
112 $result = $this->db->query($sql);
114 $num = $this->db->num_rows($result);
117 while ($line < $num) {
118 $objp = $this->db->fetch_object($result);
119 $date = $this->db->jdate($objp->date_commande);
120 $datem = $this->db->jdate($objp->tms);
122 $supplierorderstatic->id = $objp->rowid;
123 $supplierorderstatic->ref = $objp->ref;
124 $supplierorderstatic->statut = $objp->status;
125 $supplierorderstatic->status = $objp->status;
126 $supplierorderstatic->date = $date;
127 $supplierorderstatic->date_modification = $datem;
129 $thirdpartystatic->id = $objp->socid;
130 $thirdpartystatic->name = $objp->name;
132 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
133 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
134 $thirdpartystatic->fournisseur = $objp->fournisseur;
135 $thirdpartystatic->logo = $objp->logo;
136 $thirdpartystatic->email = $objp->email;
137 $thirdpartystatic->entity = $objp->entity;
139 $this->info_box_contents[$line][] = array(
140 'td' =>
'class="nowraponall"',
141 'text' => $supplierorderstatic->getNomUrl(1),
145 $this->info_box_contents[$line][] = array(
146 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
147 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
151 $this->info_box_contents[$line][] = array(
152 'td' =>
'class="nowraponall right amount"',
153 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
156 $this->info_box_contents[$line][] = array(
161 $this->info_box_contents[$line][] = array(
162 'td' =>
'class="right" width="18"',
163 'text' => $supplierorderstatic->LibStatut($objp->status, 3),
170 $this->info_box_contents[$line][] = array(
171 'td' =>
'class="center"',
172 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoSupplierOrder").
'</span>',
176 $this->db->free($result);
178 $this->info_box_contents[0][] = array(
181 'text' => ($this->db->error().
' sql='.$sql),
185 $this->info_box_contents[0][] = array(
186 'td' =>
'class="nohover left"',
187 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'