72 global $conf, $user, $langs;
73 $langs->load(
"boxes");
77 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
79 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
82 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLatest".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ?
"" :
"Modified").
"SupplierOrders", $max));
84 if ($user->rights->fournisseur->commande->lire) {
85 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
86 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
87 $sql .=
", s.logo, s.email, s.entity";
88 $sql .=
", c.rowid, c.ref, c.tms, c.date_commande";
89 $sql .=
", c.total_ht";
90 $sql .=
", c.total_tva";
91 $sql .=
", c.total_ttc";
92 $sql .=
", c.fk_statut as status";
93 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
94 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
95 if (empty($user->rights->societe->client->voir) && !$user->socid) {
96 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
98 $sql .=
" WHERE c.fk_soc = s.rowid";
99 $sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
100 if (empty($user->rights->societe->client->voir) && !$user->socid) {
101 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
104 $sql .=
" AND s.rowid = ".((int) $user->socid);
106 if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
107 $sql .=
" ORDER BY c.date_commande DESC, c.ref DESC ";
109 $sql .=
" ORDER BY c.tms DESC, c.ref DESC ";
111 $sql .= $this->db->plimit($max, 0);
113 $result = $this->db->query($sql);
115 $num = $this->db->num_rows($result);
118 while ($line < $num) {
119 $objp = $this->db->fetch_object($result);
120 $date = $this->db->jdate($objp->date_commande);
121 $datem = $this->db->jdate($objp->tms);
123 $supplierorderstatic->id = $objp->rowid;
124 $supplierorderstatic->ref = $objp->ref;
125 $supplierorderstatic->statut = $objp->status;
126 $supplierorderstatic->status = $objp->status;
127 $supplierorderstatic->date = $date;
128 $supplierorderstatic->date_modification = $datem;
130 $thirdpartystatic->id = $objp->socid;
131 $thirdpartystatic->name = $objp->name;
133 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
134 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
135 $thirdpartystatic->fournisseur = $objp->fournisseur;
136 $thirdpartystatic->logo = $objp->logo;
137 $thirdpartystatic->email = $objp->email;
138 $thirdpartystatic->entity = $objp->entity;
140 $this->info_box_contents[$line][] = array(
141 'td' =>
'class="nowraponall"',
142 'text' => $supplierorderstatic->getNomUrl(1),
146 $this->info_box_contents[$line][] = array(
147 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
148 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
152 $this->info_box_contents[$line][] = array(
153 'td' =>
'class="nowraponall right amount"',
154 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
157 $this->info_box_contents[$line][] = array(
162 $this->info_box_contents[$line][] = array(
163 'td' =>
'class="right" width="18"',
164 'text' => $supplierorderstatic->LibStatut($objp->status, 3),
171 $this->info_box_contents[$line][] = array(
172 'td' =>
'class="center"',
173 'text' => $langs->trans(
"NoSupplierOrder"),
177 $this->db->free($result);
179 $this->info_box_contents[0][] = array(
182 'text' => ($this->db->error().
' sql='.$sql),
186 $this->info_box_contents[0][] = array(
187 'td' =>
'class="nohover left"',
188 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'