64 $langs->loadLangs(array(
'orders',
'sendings'));
68 include_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
69 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
70 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
73 $orderstatic =
new Commande($this->db);
74 $societestatic =
new Societe($this->db);
76 $this->info_box_head = array(
77 'text' => $langs->trans(
"BoxTitleLastCustomerShipments", $max).
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/expedition/list.php?sortfield=e.tms&sortorder=DESC"><span class="badge">...</span></a>'
80 if ($user->hasRight(
'expedition',
'lire')) {
81 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
82 $sql .=
", s.code_client, s.code_compta, s.client";
83 $sql .=
", s.logo, s.email, s.entity";
84 $sql .=
", e.ref, e.tms";
86 $sql .=
", e.ref_customer";
87 $sql .=
", e.fk_statut";
88 $sql .=
", e.fk_user_valid";
89 $sql .=
", c.ref as commande_ref";
90 $sql .=
", c.rowid as commande_id";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expedition as e";
92 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
93 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
94 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = e.fk_soc";
95 if (!$user->hasRight(
'societe',
'client',
'voir')) {
96 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
98 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
100 $sql .=
" AND e.fk_statut = 1";
102 if ($user->socid > 0) {
103 $sql.=
" AND s.rowid = ".((int) $user->socid);
105 if (!$user->hasRight(
'societe',
'client',
'voir')) {
106 $sql .=
" AND sc.fk_user = ".((int) $user->id);
108 $sql .=
" ORDER BY e.tms DESC, e.date_delivery DESC, e.ref DESC";
110 $sql .= $this->db->plimit($max, 0);
112 $result = $this->db->query($sql);
114 $num = $this->db->num_rows($result);
118 while ($line < $num) {
119 $objp = $this->db->fetch_object($result);
121 $shipmentstatic->id = $objp->rowid;
122 $shipmentstatic->ref = $objp->ref;
123 $shipmentstatic->ref_customer = $objp->ref_customer;
125 $orderstatic->id = $objp->commande_id;
126 $orderstatic->ref = $objp->commande_ref;
128 $societestatic->id = $objp->socid;
129 $societestatic->name = $objp->name;
131 $societestatic->code_client = $objp->code_client;
132 $societestatic->code_compta = $objp->code_compta;
133 $societestatic->client = $objp->client;
134 $societestatic->logo = $objp->logo;
135 $societestatic->email = $objp->email;
136 $societestatic->entity = $objp->entity;
138 $this->info_box_contents[$line][] = array(
139 'td' =>
'class="nowraponall"',
140 'text' => $shipmentstatic->getNomUrl(1),
144 $this->info_box_contents[$line][] = array(
145 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
146 'text' => $societestatic->getNomUrl(1),
150 $this->info_box_contents[$line][] = array(
151 'td' =>
'class="nowraponall"',
152 'text' => ($orderstatic->id > 0 ? $orderstatic->getNomUrl(1) :
''),
156 $this->info_box_contents[$line][] = array(
157 'td' =>
'class="right" width="18"',
158 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3),
165 $this->info_box_contents[$line][0] = array(
166 'td' =>
'class="center"',
167 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedShipments").
'</span>'
171 $this->db->free($result);
173 $this->info_box_contents[0][0] = array(
176 'text' => ($this->db->error().
' sql='.$sql),
180 $this->info_box_contents[0][0] = array(
181 'td' =>
'class="nohover left"',
182 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'