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