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