dolibarr 24.0.0-beta
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-2026 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';
38require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
39require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
40
41// Load translation files required by the page
42$langs->loadLangs(array('orders', 'sendings'));
43
44$socid = GETPOSTINT('socid');
45
46// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
47$hookmanager->initHooks(array('sendingindex'));
48
49
50/*
51 * View
52 */
53
54$orderstatic = new Commande($db);
55$companystatic = new Societe($db);
56$shipment = new Expedition($db);
57
58$helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
59llxHeader('', $langs->trans("Shipment"), $helpurl, '', 0, 0, '', '', '', 'mod-expedition page-index');
60
61print load_fiche_titre($langs->trans("SendingsArea"), '', 'dolly');
62
63
64print '<div class="fichecenter"><div class="fichethirdleft">';
65
66/*
67 * Shipments to validate
68 */
69
70$clause = " WHERE ";
71
72$sql = "SELECT e.rowid, e.ref, e.ref_customer,";
73$sql .= " s.nom as name, s.rowid as socid,";
74$sql .= " c.ref as commande_ref, c.rowid as commande_id";
75$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
76$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping'";
77$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
78$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
79if (!$user->hasRight('societe', 'client', 'voir')) {
80 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
81 $sql .= $clause." sc.fk_user = ".((int) $user->id);
82 $clause = " AND ";
83}
84$sql .= $clause." e.fk_statut = ".Expedition::STATUS_DRAFT;
85$sql .= " AND e.entity IN (".getEntity('expedition').")";
86if ($socid) {
87 $sql .= " AND c.fk_soc = ".((int) $socid);
88}
89
90$resql = $db->query($sql);
91if ($resql) {
92 $num = $db->num_rows($resql);
93
94 print '<div class="div-table-responsive-no-min">';
95 print '<table class="noborder centpercent">';
96 print '<tr class="liste_titre">';
97 print '<th colspan="3">';
98 print $langs->trans("SendingsToValidate").' ';
99 print '<a href="'.DOL_URL_ROOT.'/expedition/list.php?search_status='.Expedition::STATUS_DRAFT.'">';
100 print '<span class="badge">'.$num.'</span>';
101 print '</a>';
102 print '</th>';
103 print '</tr>';
104
105 if ($num) {
106 $i = 0;
107 while ($i < $num) {
108 $obj = $db->fetch_object($resql);
109
110 $shipment->id = $obj->rowid;
111 $shipment->ref = $obj->ref;
112 $shipment->ref_customer = $obj->ref_customer;
113
114 print '<tr class="oddeven"><td class="nowrap">';
115 print $shipment->getNomUrl(1);
116 print "</td>";
117 print '<td>';
118 print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name.'</a>';
119 print '</td>';
120 print '<td>';
121 if ($obj->commande_id) {
122 print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$obj->commande_id.'">'.$obj->commande_ref.'</a>';
123 }
124 print '</td></tr>';
125 $i++;
126 }
127 } else {
128 print '<tr><td>'.$langs->trans("None").'</td><td></td><td></td></tr>';
129 }
130
131 print "</table></div><br>";
132}
133
134
135
136//print '</td><td valign="top" width="70%">';
137print '</div><div class="fichetwothirdright">';
138
139$max = 5;
140
141/*
142 * Latest shipments
143 */
144$sql = "SELECT e.rowid, e.ref, e.ref_customer,";
145$sql .= " s.nom as name, s.rowid as socid,";
146$sql .= " c.ref as commande_ref, c.rowid as commande_id";
147$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
148$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')";
149$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
150$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
151if (!$user->hasRight('societe', 'client', 'voir')) {
152 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
153}
154$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
155if (!$user->hasRight('societe', 'client', 'voir')) {
156 $sql .= " AND sc.fk_user = ".((int) $user->id);
157}
158$sql .= " AND e.fk_statut = ".Expedition::STATUS_VALIDATED;
159if ($socid) {
160 $sql .= " AND c.fk_soc = ".((int) $socid);
161}
162$sql .= " ORDER BY e.date_delivery DESC";
163$sql .= $db->plimit($max, 0);
164
165$resql = $db->query($sql);
166if ($resql) {
167 $num = $db->num_rows($resql);
168
169 print '<div class="div-table-responsive-no-min">';
170 print '<table class="noborder centpercent">';
171 print '<tr class="liste_titre">';
172 print '<th colspan="4">';
173 print $langs->trans("LastSendings").' ';
174 print '<a href="'.DOL_URL_ROOT.'/expedition/list.php?search_status='.Expedition::STATUS_VALIDATED.'">';
175 print '<span class="badge">'.$num.'</span>';
176 print '</a>';
177 print '</th>';
178 print '</tr>';
179
180 if ($num) {
181 $i = 0;
182 while ($i < $num) {
183 $obj = $db->fetch_object($resql);
184
185 $shipment->id = $obj->rowid;
186 $shipment->ref = $obj->ref;
187 $shipment->ref_customer = $obj->ref_customer;
188
189 print '<tr class="oddeven"><td>';
190 print $shipment->getNomUrl(1);
191 print '</td>';
192 print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.'</a></td>';
193 print '<td>';
194 if ($obj->commande_id > 0) {
195 $orderstatic->id = $obj->commande_id;
196 $orderstatic->ref = $obj->commande_ref;
197 print $orderstatic->getNomUrl(1);
198 }
199 print '</td>';
200 print '<td class="">';
201
202 print '</td>';
203 print '</tr>';
204 $i++;
205 }
206 } else {
207 print '<tr><td>'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
208 }
209 print "</table></div><br>";
210 $db->free($resql);
211} else {
213}
214
215/*
216 * Open orders
217 */
218$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";
219$sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
220$sql .= " ".MAIN_DB_PREFIX."societe as s";
221if (!$user->hasRight('societe', 'client', 'voir')) {
222 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
223}
224$sql .= " WHERE c.fk_soc = s.rowid";
225$sql .= " AND c.entity IN (".getEntity('order').")";
226$sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")";
227if ($socid > 0) {
228 $sql .= " AND c.fk_soc = ".((int) $socid);
229}
230if (!$user->hasRight('societe', 'client', 'voir')) {
231 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
232}
233
234$parameters = array();
235$reshook = $hookmanager->executeHooks('printFieldListWhereOpenedOrders', $parameters, $object); // Note that $action and $object may have been modified by hook
236$sql .= $hookmanager->resPrint;
237
238$sql .= " ORDER BY c.rowid ASC";
239
240$resql = $db->query($sql);
241if ($resql) {
242 $langs->load("orders");
243
244 $num = $db->num_rows($resql);
245
246 print '<div class="div-table-responsive-no-min">';
247 print '<table class="noborder centpercent">';
248
249 print '<tr class="liste_titre">';
250 print '<th colspan="3">'.$langs->trans("OrdersToProcess").' ';
251 print '<a href="'.DOL_URL_ROOT.'/commande/list.php?search_status='.Commande::STATUS_VALIDATED.','.Commande::STATUS_SHIPMENTONPROCESS.'">';
252 print '<span class="badge">'.$num.'</span>';
253 print '</a>';
254 print '</th>';
255 print '</tr>';
256
257 if ($num) {
258 $i = 0;
259 while ($i < $num && $i < 10) {
260 $obj = $db->fetch_object($resql);
261
262 $orderstatic->id = $obj->rowid;
263 $orderstatic->ref = $obj->ref;
264 $orderstatic->ref_customer = $obj->ref_customer;
265 $orderstatic->status = $obj->status;
266 $orderstatic->billed = $obj->billed;
267
268 $companystatic->name = $obj->name;
269 $companystatic->id = $obj->socid;
270
271 print '<tr class="oddeven"><td>';
272 print $orderstatic->getNomUrl(1);
273 print '</td>';
274 print '<td>';
275 print $companystatic->getNomUrl(1, 'customer', 32);
276 print '</td>';
277 print '<td class="right">';
278 print $orderstatic->getLibStatut(3);
279 print '</td>';
280 print '</tr>';
281 $i++;
282 }
283
284 if ($i < $num) {
285 print '<tr class="opacitymedium">';
286 print '<td>'.$langs->trans("More").'...</td>';
287 print '<td></td>';
288 print '<td></td>';
289 print '</tr>';
290 }
291 } else {
292 print '<tr><td>'.$langs->trans("None").'</td><td></td><td></td></tr>';
293 }
294
295 print "</table></div><br>";
296} else {
298}
299
300
301print '</div></div>';
302
303$parameters = array('user' => $user);
304$reshook = $hookmanager->executeHooks('dashboardWarehouseSendings', $parameters, $object); // Note that $action and $object may have been modified by hook
305
306// End of page
307llxFooter();
308$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
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 third parties objects (customers, suppliers, prospects...)
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.