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