dolibarr 20.0.0
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
6 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
31require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
32
33$hookmanager = new HookManager($db);
34
35$socid = GETPOSTINT('socid');
36
37// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
38$hookmanager->initHooks(array('sendingindex'));
39
40// Load translation files required by the page
41$langs->loadLangs(array('orders', 'sendings'));
42
43/*
44 * View
45 */
46
47$orderstatic = new Commande($db);
48$companystatic = new Societe($db);
49$shipment = new Expedition($db);
50
51$helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
52llxHeader('', $langs->trans("Shipment"), $helpurl);
53
54print load_fiche_titre($langs->trans("SendingsArea"), '', 'dolly');
55
56
57print '<div class="fichecenter"><div class="fichethirdleft">';
58
59/*
60 * Shipments to validate
61 */
62
63$clause = " WHERE ";
64
65$sql = "SELECT e.rowid, e.ref, e.ref_customer,";
66$sql .= " s.nom as name, s.rowid as socid,";
67$sql .= " c.ref as commande_ref, c.rowid as commande_id";
68$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
69$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping'";
70$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
71$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
72if (!$user->hasRight('societe', 'client', 'voir')) {
73 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
74 $sql .= $clause." sc.fk_user = ".((int) $user->id);
75 $clause = " AND ";
76}
77$sql .= $clause." e.fk_statut = ".Expedition::STATUS_DRAFT;
78$sql .= " AND e.entity IN (".getEntity('expedition').")";
79if ($socid) {
80 $sql .= " AND c.fk_soc = ".((int) $socid);
81}
82
83$resql = $db->query($sql);
84if ($resql) {
85 $num = $db->num_rows($resql);
86
87 print '<div class="div-table-responsive-no-min">';
88 print '<table class="noborder centpercent">';
89 print '<tr class="liste_titre">';
90 print '<th colspan="3">';
91 print $langs->trans("SendingsToValidate").' ';
92 print '<a href="'.DOL_URL_ROOT.'/expedition/list.php?search_status='.Expedition::STATUS_DRAFT.'">';
93 print '<span class="badge">'.$num.'</span>';
94 print '</a>';
95 print '</th>';
96 print '</tr>';
97
98 if ($num) {
99 $i = 0;
100 while ($i < $num) {
101 $obj = $db->fetch_object($resql);
102
103 $shipment->id = $obj->rowid;
104 $shipment->ref = $obj->ref;
105 $shipment->ref_customer = $obj->ref_customer;
106
107 print '<tr class="oddeven"><td class="nowrap">';
108 print $shipment->getNomUrl(1);
109 print "</td>";
110 print '<td>';
111 print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name.'</a>';
112 print '</td>';
113 print '<td>';
114 if ($obj->commande_id) {
115 print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$obj->commande_id.'">'.$obj->commande_ref.'</a>';
116 }
117 print '</td></tr>';
118 $i++;
119 }
120 } else {
121 print '<tr><td>'.$langs->trans("None").'</td><td></td><td></td></tr>';
122 }
123
124 print "</table></div><br>";
125}
126
127
128
129//print '</td><td valign="top" width="70%">';
130print '</div><div class="fichetwothirdright">';
131
132$max = 5;
133
134/*
135 * Latest shipments
136 */
137$sql = "SELECT e.rowid, e.ref, e.ref_customer,";
138$sql .= " s.nom as name, s.rowid as socid,";
139$sql .= " c.ref as commande_ref, c.rowid as commande_id";
140$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
141$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')";
142$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
143$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
144if (!$user->hasRight('societe', 'client', 'voir')) {
145 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
146}
147$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
148if (!$user->hasRight('societe', 'client', 'voir')) {
149 $sql .= " AND sc.fk_user = ".((int) $user->id);
150}
151$sql .= " AND e.fk_statut = ".Expedition::STATUS_VALIDATED;
152if ($socid) {
153 $sql .= " AND c.fk_soc = ".((int) $socid);
154}
155$sql .= " ORDER BY e.date_delivery DESC";
156$sql .= $db->plimit($max, 0);
157
158$resql = $db->query($sql);
159if ($resql) {
160 $num = $db->num_rows($resql);
161
162 print '<div class="div-table-responsive-no-min">';
163 print '<table class="noborder centpercent">';
164 print '<tr class="liste_titre">';
165 print '<th colspan="4">';
166 print $langs->trans("LastSendings").' ';
167 print '<a href="'.DOL_URL_ROOT.'/expedition/list.php?search_status='.Expedition::STATUS_VALIDATED.'">';
168 print '<span class="badge">'.$num.'</span>';
169 print '</a>';
170 print '</th>';
171 print '</tr>';
172
173 if ($num) {
174 $i = 0;
175 while ($i < $num) {
176 $obj = $db->fetch_object($resql);
177
178 $shipment->id = $obj->rowid;
179 $shipment->ref = $obj->ref;
180 $shipment->ref_customer = $obj->ref_customer;
181
182 print '<tr class="oddeven"><td>';
183 print $shipment->getNomUrl(1);
184 print '</td>';
185 print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.'</a></td>';
186 print '<td>';
187 if ($obj->commande_id > 0) {
188 $orderstatic->id = $obj->commande_id;
189 $orderstatic->ref = $obj->commande_ref;
190 print $orderstatic->getNomUrl(1);
191 }
192 print '</td>';
193 print '<td class="">';
194
195 print '</td>';
196 print '</tr>';
197 $i++;
198 }
199 } else {
200 print '<tr><td>'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
201 }
202 print "</table></div><br>";
203 $db->free($resql);
204} else {
205 dol_print_error($db);
206}
207
208/*
209 * Open orders
210 */
211$sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, c.fk_statut as status, c.facture as billed, s.nom as name, s.rowid as socid";
212$sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
213$sql .= " ".MAIN_DB_PREFIX."societe as s";
214if (!$user->hasRight('societe', 'client', 'voir')) {
215 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
216}
217$sql .= " WHERE c.fk_soc = s.rowid";
218$sql .= " AND c.entity IN (".getEntity('order').")";
219$sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_ACCEPTED.")";
220if ($socid > 0) {
221 $sql .= " AND c.fk_soc = ".((int) $socid);
222}
223if (!$user->hasRight('societe', 'client', 'voir')) {
224 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
225}
226$sql .= " ORDER BY c.rowid ASC";
227
228$resql = $db->query($sql);
229if ($resql) {
230 $langs->load("orders");
231
232 $num = $db->num_rows($resql);
233
234 print '<div class="div-table-responsive-no-min">';
235 print '<table class="noborder centpercent">';
236
237 print '<tr class="liste_titre">';
238 print '<th colspan="3">'.$langs->trans("OrdersToProcess").' ';
239 print '<a href="'.DOL_URL_ROOT.'/commande/list.php?search_status='.Commande::STATUS_VALIDATED.','.Commande::STATUS_ACCEPTED.'">';
240 print '<span class="badge">'.$num.'</span>';
241 print '</a>';
242 print '</th>';
243 print '</tr>';
244
245 if ($num) {
246 $i = 0;
247 while ($i < $num && $i < 10) {
248 $obj = $db->fetch_object($resql);
249
250 $orderstatic->id = $obj->rowid;
251 $orderstatic->ref = $obj->ref;
252 $orderstatic->ref_customer = $obj->ref_customer;
253 $orderstatic->statut = $obj->status;
254 $orderstatic->billed = $obj->billed;
255
256 $companystatic->name = $obj->name;
257 $companystatic->id = $obj->socid;
258
259 print '<tr class="oddeven"><td>';
260 print $orderstatic->getNomUrl(1);
261 print '</td>';
262 print '<td>';
263 print $companystatic->getNomUrl(1, 'customer', 32);
264 print '</td>';
265 print '<td class="right">';
266 print $orderstatic->getLibStatut(3);
267 print '</td>';
268 print '</tr>';
269 $i++;
270 }
271
272 if ($i < $num) {
273 print '<tr class="opacitymedium">';
274 print '<td>'.$langs->trans("More").'...</td>';
275 print '<td></td>';
276 print '<td></td>';
277 print '</tr>';
278 }
279 } else {
280 print '<tr><td>'.$langs->trans("None").'</td><td></td><td></td></tr>';
281 }
282
283 print "</table></div><br>";
284} else {
285 dol_print_error($db);
286}
287
288
289print '</div></div>';
290
291$parameters = array('user' => $user);
292$reshook = $hookmanager->executeHooks('dashboardWarehouseSendings', $parameters, $object); // Note that $action and $object may have been modified by hook
293
294// End of page
295llxFooter();
296$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage customers orders.
const STATUS_VALIDATED
Validated status.
Class to manage shipments.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status -> parcel is ready to be sent prev status : draft next status : closed or shipment_i...
Class to manage hooks.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...