72 global $conf, $user, $langs;
73 $langs->loadLangs(array(
"boxes",
"sendings",
"orders"));
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(
"BoxTitleSupplierOrdersAwaitingReception", $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, c.date_livraison as delivery_date";
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 $sql .=
" AND c.date_livraison IS NOT NULL";
102 if (empty($user->rights->societe->client->voir) && !$user->socid) {
103 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
106 $sql .=
" AND s.rowid = ".((int) $user->socid);
108 if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
109 $sql .=
" ORDER BY c.date_commande DESC, c.ref DESC";
111 $sql .=
" ORDER BY c.date_livraison ASC, c.fk_statut ASC";
113 $sql .= $this->db->plimit($max, 0);
115 $result = $this->db->query($sql);
117 $num = $this->db->num_rows($result);
120 while ($line < $num) {
121 $objp = $this->db->fetch_object($result);
122 $date = $this->db->jdate($objp->date_commande);
123 $delivery_date = $this->db->jdate($objp->delivery_date);
124 $datem = $this->db->jdate($objp->tms);
126 $supplierorderstatic->id = $objp->rowid;
127 $supplierorderstatic->ref = $objp->ref;
128 $supplierorderstatic->delivery_date = $delivery_date;
129 $supplierorderstatic->statut = $objp->status;
131 $thirdpartystatic->id = $objp->socid;
132 $thirdpartystatic->name = $objp->name;
134 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
135 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
136 $thirdpartystatic->fournisseur = $objp->fournisseur;
137 $thirdpartystatic->logo = $objp->logo;
138 $thirdpartystatic->email = $objp->email;
139 $thirdpartystatic->entity = $objp->entity;
141 $this->info_box_contents[$line][] = array(
142 'td' =>
'class="nowraponall"',
143 'text' => $supplierorderstatic->getNomUrl(1),
147 $this->info_box_contents[$line][] = array(
148 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
149 'text' => $thirdpartystatic->getNomUrl(1,
'supplier'),
153 $this->info_box_contents[$line][] = array(
154 'td' =>
'class="nowraponall right amount"',
155 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
159 if ($supplierorderstatic->hasDelay()) {
163 $this->info_box_contents[$line][] = array(
164 'td' =>
'class="right"',
165 '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>',
173 $this->info_box_contents[$line][] = array(
174 'td' =>
'class="center"',
175 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"NoSupplierOrder").
'</span>',
179 $this->db->free($result);
181 $this->info_box_contents[0][] = array(
184 'text' => ($this->db->error().
' sql='.$sql),
188 $this->info_box_contents[0][] = array(
189 'td' =>
'class="nohover opacitymedium left"',
190 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'