71 global $conf, $user, $langs;
72 $langs->loadLangs(array(
"boxes",
"sendings",
"orders"));
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(
"BoxTitleSupplierOrdersAwaitingReception", $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, c.date_livraison as delivery_date";
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 $sql .=
" AND c.date_livraison IS NOT NULL";
101 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
102 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
105 $sql .=
" AND s.rowid = ".((int) $user->socid);
108 $sql .=
" ORDER BY c.date_commande DESC, c.ref DESC";
110 $sql .=
" ORDER BY c.date_livraison ASC, c.fk_statut ASC";
112 $sql .= $this->db->plimit($max, 0);
114 $result = $this->db->query($sql);
116 $num = $this->db->num_rows($result);
119 while ($line < $num) {
120 $objp = $this->db->fetch_object($result);
121 $date = $this->db->jdate($objp->date_commande);
122 $delivery_date = $this->db->jdate($objp->delivery_date);
123 $datem = $this->db->jdate($objp->tms);
125 $supplierorderstatic->id = $objp->rowid;
126 $supplierorderstatic->ref = $objp->ref;
127 $supplierorderstatic->delivery_date = $delivery_date;
128 $supplierorderstatic->statut = $objp->status;
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),
158 if ($supplierorderstatic->hasDelay()) {
162 $this->info_box_contents[$line][] = array(
163 'td' =>
'class="right"',
164 '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>',
172 $this->info_box_contents[$line][] = array(
173 'td' =>
'class="center"',
174 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoSupplierOrder").
'</span>',
178 $this->db->free($result);
180 $this->info_box_contents[0][] = array(
183 'text' => ($this->db->error().
' sql='.$sql),
187 $this->info_box_contents[0][] = array(
188 'td' =>
'class="nohover left"',
189 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'