62 global
$conf, $user, $langs;
63 $langs->loadLangs(array(
"boxes",
"sendings",
"orders"));
67 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
69 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
72 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleSupplierOrdersAwaitingReception", $max));
74 if ($user->hasRight(
'fournisseur',
'commande',
'lire')) {
75 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
76 $sql .=
", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
77 $sql .=
", s.logo, s.email, s.entity";
78 $sql .=
", c.rowid, c.ref, c.tms, c.date_commande, c.date_livraison as delivery_date";
79 $sql .=
", c.total_ht";
80 $sql .=
", c.total_tva";
81 $sql .=
", c.total_ttc";
82 $sql .=
", c.fk_statut as status";
83 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
84 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
85 if (!$user->hasRight(
'societe',
'client',
'voir')) {
86 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
88 $sql .=
" WHERE c.fk_soc = s.rowid";
89 $sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
90 $sql .=
" AND c.date_livraison IS NOT NULL";
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.date_livraison ASC, c.fk_statut ASC";
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 $delivery_date = $this->db->jdate($objp->delivery_date);
114 $datem = $this->db->jdate($objp->tms);
116 $supplierorderstatic->id = $objp->rowid;
117 $supplierorderstatic->ref = $objp->ref;
118 $supplierorderstatic->delivery_date = $delivery_date;
119 $supplierorderstatic->statut = $objp->status;
121 $thirdpartystatic->id = $objp->socid;
122 $thirdpartystatic->name = $objp->name;
124 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
125 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
126 $thirdpartystatic->fournisseur = $objp->fournisseur;
127 $thirdpartystatic->logo = $objp->logo;
128 $thirdpartystatic->email = $objp->email;
129 $thirdpartystatic->entity = $objp->entity;
131 $this->info_box_contents[$line][] = array(
132 'td' =>
'class="nowraponall"',
133 'text' => $supplierorderstatic->getNomUrl(1),
137 $this->info_box_contents[$line][] = array(
138 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
139 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
143 $this->info_box_contents[$line][] = array(
144 'td' =>
'class="nowraponall right amount"',
145 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1,
$conf->currency),
149 if ($supplierorderstatic->hasDelay()) {
153 $this->info_box_contents[$line][] = array(
154 'td' =>
'class="right"',
155 '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>',
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>'