27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"lastcustomershipments";
36 public $boximg =
"sending";
37 public $boxlabel =
"BoxLastCustomerShipments";
38 public $depends = array(
"expedition");
47 public $info_box_head = array();
48 public $info_box_contents = array();
63 $this->hidden = !($user->rights->expedition->lire);
74 global $user, $langs, $conf;
75 $langs->loadLangs(array(
'orders',
'sendings'));
79 include_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
80 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
81 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
87 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLastCustomerShipments", $max));
89 if ($user->rights->expedition->lire)
91 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
92 $sql .=
", s.code_client, s.code_compta, s.client";
93 $sql .=
", s.logo, s.email, s.entity";
94 $sql .=
", e.ref, e.tms";
96 $sql .=
", e.ref_customer";
97 $sql .=
", e.fk_statut";
98 $sql .=
", e.fk_user_valid";
99 $sql .=
", c.ref as commande_ref";
100 $sql .=
", c.rowid as commande_id";
101 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expedition as e";
102 $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')";
103 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
104 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = e.fk_soc";
105 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
106 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
107 if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .=
" AND e.fk_statut = 1";
108 if ($user->socid > 0) $sql.=
" AND s.rowid = ".$user->socid;
109 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND sc.fk_user = ".$user->id;
110 else $sql .=
" ORDER BY e.date_delivery, e.ref DESC ";
111 $sql .= $this->
db->plimit($max, 0);
113 $result = $this->
db->query($sql);
115 $num = $this->
db->num_rows($result);
119 while ($line < $num) {
120 $objp = $this->
db->fetch_object($result);
122 $shipmentstatic->id = $objp->rowid;
123 $shipmentstatic->ref = $objp->ref;
124 $shipmentstatic->ref_customer = $objp->ref_customer;
126 $orderstatic->id = $objp->commande_id;
127 $orderstatic->ref = $objp->commande_ref;
129 $societestatic->id = $objp->socid;
130 $societestatic->name = $objp->name;
132 $societestatic->code_client = $objp->code_client;
133 $societestatic->code_compta = $objp->code_compta;
134 $societestatic->client = $objp->client;
135 $societestatic->logo = $objp->logo;
136 $societestatic->email = $objp->email;
137 $societestatic->entity = $objp->entity;
139 $this->info_box_contents[$line][] = array(
140 'td' =>
'class="nowraponall"',
141 'text' => $shipmentstatic->getNomUrl(1),
145 $this->info_box_contents[$line][] = array(
146 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
147 'text' => $societestatic->getNomUrl(1),
151 $this->info_box_contents[$line][] = array(
152 'td' =>
'class="nowraponall"',
153 'text' => $orderstatic->getNomUrl(1),
157 $this->info_box_contents[$line][] = array(
158 'td' =>
'class="right" width="18"',
159 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3),
165 if ($num == 0) $this->info_box_contents[$line][0] = array(
166 'td' =>
'class="center opacitymedium"',
167 'text'=>$langs->trans(
"NoRecordedShipments")
170 $this->
db->free($result);
172 $this->info_box_contents[0][0] = array(
175 'text' => ($this->
db->error().
' sql='.$sql),
179 $this->info_box_contents[0][0] = array(
180 'td' =>
'class="nohover opacitymedium left"',
181 'text' => $langs->trans(
"ReadPermissionNotAllowed")
194 public function showBox($head = null, $contents = null, $nooutput = 0)
196 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage the box to show last shipments.
$conf db
API class for accounts.
loadBox($max=5)
Load data for box to show them later.
Class to manage third parties objects (customers, suppliers, prospects...)
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
Class to manage shipments.
Class to manage customers orders.
__construct($db, $param)
Constructor.