61 global $conf, $user, $langs;
62 $langs->loadLangs(array(
"boxes",
"sendings",
"orders"));
66 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
68 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
71 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleSupplierOrdersAwaitingReception", $max));
73 if ($user->hasRight(
'fournisseur',
'commande',
'lire')) {
74 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
75 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
76 $sql .=
", s.logo, s.email, s.entity";
77 $sql .=
", c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison as delivery_date";
78 $sql .=
", c.total_ht";
79 $sql .=
", c.total_tva";
80 $sql .=
", c.total_ttc";
81 $sql .=
", c.fk_statut as status";
82 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
83 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
84 if (!$user->hasRight(
'societe',
'client',
'voir')) {
85 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
87 $sql .=
" WHERE c.fk_soc = s.rowid";
88 $sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
89 $sql .=
" AND c.date_livraison IS NOT NULL";
91 if (!$user->hasRight(
'societe',
'client',
'voir')) {
92 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
95 $sql .=
" AND s.rowid = ".((int) $user->socid);
98 $sql .=
" ORDER BY c.date_commande DESC, c.ref DESC";
100 $sql .=
" ORDER BY c.date_livraison ASC, c.fk_statut ASC";
102 $sql .= $this->db->plimit($max, 0);
104 $result = $this->db->query($sql);
106 $num = $this->db->num_rows($result);
109 while ($line < $num) {
110 $objp = $this->db->fetch_object($result);
111 $date = $this->db->jdate($objp->date_commande);
112 $delivery_date = $this->db->jdate($objp->delivery_date);
113 $datem = $this->db->jdate($objp->tms);
115 $supplierorderstatic->id = $objp->rowid;
116 $supplierorderstatic->ref = $objp->ref;
117 $supplierorderstatic->delivery_date = $delivery_date;
118 $supplierorderstatic->statut = $objp->status;
120 $thirdpartystatic->id = $objp->socid;
121 $thirdpartystatic->name = $objp->name;
123 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
124 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
125 $thirdpartystatic->fournisseur = $objp->fournisseur;
126 $thirdpartystatic->logo = $objp->logo;
127 $thirdpartystatic->email = $objp->email;
128 $thirdpartystatic->entity = $objp->entity;
130 $this->info_box_contents[$line][] = array(
131 'td' =>
'class="nowraponall"',
132 'text' => $supplierorderstatic->getNomUrl(1),
136 $this->info_box_contents[$line][] = array(
137 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
138 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
142 $this->info_box_contents[$line][] = array(
143 'td' =>
'class="nowraponall right amount"',
144 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
148 if ($supplierorderstatic->hasDelay()) {
152 $this->info_box_contents[$line][] = array(
153 'td' =>
'class="right"',
154 'text' => $delayIcon.
'<span class="classfortooltip" title="'.$langs->trans(
'DateDeliveryPlanned').
'"><i class="fa fa-flip-dolly" ></i> '.($delivery_date ?
dol_print_date($delivery_date,
'day',
'tzuserrel') :
'').
'</span>',
162 $this->info_box_contents[$line][] = array(
163 'td' =>
'class="center"',
164 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoSupplierOrder").
'</span>',
168 $this->db->free($result);
170 $this->info_box_contents[0][] = array(
173 'text' => ($this->db->error().
' sql='.$sql),
177 $this->info_box_contents[0][] = array(
178 'td' =>
'class="nohover left"',
179 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'