27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"lastcustomershipments";
36 public $boximg =
"dolly";
37 public $boxlabel =
"BoxLastCustomerShipments";
38 public $depends = array(
"expedition");
52 $this->hidden = !$user->hasRight(
'expedition',
'lire');
63 global $user, $langs, $conf;
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(
'text' => $langs->trans(
"BoxTitleLastCustomerShipments", $max));
78 if ($user->hasRight(
'expedition',
'lire')) {
79 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
80 $sql .=
", s.code_client, s.code_compta, s.client";
81 $sql .=
", s.logo, s.email, s.entity";
82 $sql .=
", e.ref, e.tms";
84 $sql .=
", e.ref_customer";
85 $sql .=
", e.fk_statut";
86 $sql .=
", e.fk_user_valid";
87 $sql .=
", c.ref as commande_ref";
88 $sql .=
", c.rowid as commande_id";
89 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expedition as e";
90 $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')";
91 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
92 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = e.fk_soc";
93 if (!$user->hasRight(
'societe',
'client',
'voir')) {
94 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
96 $sql .=
" WHERE e.entity IN (".getEntity(
'expedition').
")";
98 $sql .=
" AND e.fk_statut = 1";
100 if ($user->socid > 0) {
101 $sql.=
" AND s.rowid = ".((int) $user->socid);
103 if (!$user->hasRight(
'societe',
'client',
'voir')) {
104 $sql .=
" AND sc.fk_user = ".((int) $user->id);
106 $sql .=
" ORDER BY e.date_delivery, e.ref DESC";
108 $sql .= $this->db->plimit($max, 0);
110 $result = $this->db->query(
$sql);
112 $num = $this->db->num_rows($result);
116 while ($line < $num) {
117 $objp = $this->db->fetch_object($result);
119 $shipmentstatic->id = $objp->rowid;
120 $shipmentstatic->ref = $objp->ref;
121 $shipmentstatic->ref_customer = $objp->ref_customer;
123 $orderstatic->id = $objp->commande_id;
124 $orderstatic->ref = $objp->commande_ref;
126 $societestatic->id = $objp->socid;
127 $societestatic->name = $objp->name;
129 $societestatic->code_client = $objp->code_client;
130 $societestatic->code_compta = $objp->code_compta;
131 $societestatic->client = $objp->client;
132 $societestatic->logo = $objp->logo;
133 $societestatic->email = $objp->email;
134 $societestatic->entity = $objp->entity;
136 $this->info_box_contents[$line][] = array(
137 'td' =>
'class="nowraponall"',
138 'text' => $shipmentstatic->getNomUrl(1),
142 $this->info_box_contents[$line][] = array(
143 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
144 'text' => $societestatic->getNomUrl(1),
148 $this->info_box_contents[$line][] = array(
149 'td' =>
'class="nowraponall"',
150 'text' => $orderstatic->getNomUrl(1),
154 $this->info_box_contents[$line][] = array(
155 'td' =>
'class="right" width="18"',
156 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3),
163 $this->info_box_contents[$line][0] = array(
164 'td' =>
'class="center"',
165 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedShipments").
'</span>'
169 $this->db->free($result);
171 $this->info_box_contents[0][0] = array(
174 'text' => ($this->db->error().
' sql='.
$sql),
178 $this->info_box_contents[0][0] = array(
179 'td' =>
'class="nohover left"',
180 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
193 public function showBox($head =
null, $contents =
null, $nooutput = 0)
195 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage customers orders.
Class to manage shipments.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage the box to show last shipments.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox($max=5)
Load data for box to show them later.
__construct($db, $param)
Constructor.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.