dolibarr  13.0.2
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 
34 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
35 $hookmanager->initHooks(array('sendingindex'));
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array('orders', 'sendings'));
39 
40 /*
41  * View
42  */
43 
44 $orderstatic = new Commande($db);
45 $companystatic = new Societe($db);
46 $shipment = new Expedition($db);
47 
48 $helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
49 llxHeader('', $langs->trans("Shipment"), $helpurl);
50 
51 print load_fiche_titre($langs->trans("SendingsArea"), '', 'dolly');
52 
53 
54 print '<div class="fichecenter"><div class="fichethirdleft">';
55 
56 
57 if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
58 {
59  print '<form method="post" action="list.php">';
60  print '<input type="hidden" name="token" value="'.newToken().'">';
61  print '<div class="div-table-responsive-no-min">';
62  print '<table class="noborder nohover centpercent">';
63  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
64  print '<tr class="oddeven"><td>';
65  print $langs->trans("Shipment").':</td><td><input type="text" class="flat" name="sall" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
66  print "</table></div></form><br>\n";
67 }
68 
69 /*
70  * Shipments to validate
71  */
72 
73 $clause = " WHERE ";
74 
75 $sql = "SELECT e.rowid, e.ref, e.ref_customer,";
76 $sql .= " s.nom as name, s.rowid as socid,";
77 $sql .= " c.ref as commande_ref, c.rowid as commande_id";
78 $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
79 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping'";
80 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
81 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
82 if (!$user->rights->societe->client->voir && !$socid)
83 {
84  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
85  $sql .= $clause." sc.fk_user = ".$user->id;
86  $clause = " AND ";
87 }
88 $sql .= $clause." e.fk_statut = ".Expedition::STATUS_DRAFT;
89 $sql .= " AND e.entity IN (".getEntity('expedition').")";
90 if ($socid) $sql .= " AND c.fk_soc = ".$socid;
91 
92 $resql = $db->query($sql);
93 if ($resql)
94 {
95  $num = $db->num_rows($resql);
96 
97  print '<div class="div-table-responsive-no-min">';
98  print '<table class="noborder centpercent">';
99  print '<tr class="liste_titre">';
100  print '<th colspan="3">';
101  print $langs->trans("SendingsToValidate").' ';
102  print '<a href="'.DOL_URL_ROOT.'/expedition/list.php?search_status='.Expedition::STATUS_DRAFT.'">';
103  print '<span class="badge">'.$num.'</span>';
104  print '</a>';
105  print '</th>';
106  print '</tr>';
107 
108  if ($num)
109  {
110  $i = 0;
111  while ($i < $num)
112  {
113  $obj = $db->fetch_object($resql);
114 
115  $shipment->id = $obj->rowid;
116  $shipment->ref = $obj->ref;
117  $shipment->ref_customer = $obj->ref_customer;
118 
119  print '<tr class="oddeven"><td class="nowrap">';
120  print $shipment->getNomUrl(1);
121  print "</td>";
122  print '<td>';
123  print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name.'</a>';
124  print '</td>';
125  print '<td>';
126  if ($obj->commande_id) print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$obj->commande_id.'">'.$obj->commande_ref.'</a>';
127  print '</td></tr>';
128  $i++;
129  }
130  } else {
131  print '<tr><td>'.$langs->trans("None").'</td><td></td><td></td></tr>';
132  }
133 
134  print "</table></div><br>";
135 }
136 
137 
138 
139 //print '</td><td valign="top" width="70%">';
140 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
141 
142 $max = 5;
143 
144 /*
145  * Latest shipments
146  */
147 $sql = "SELECT e.rowid, e.ref, e.ref_customer,";
148 $sql .= " s.nom as name, s.rowid as socid,";
149 $sql .= " c.ref as commande_ref, c.rowid as commande_id";
150 $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
151 $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')";
152 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
153 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
154 if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
155 $sql .= " WHERE e.entity IN (".getEntity('expedition').")";
156 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
157 $sql .= " AND e.fk_statut = ".Expedition::STATUS_VALIDATED;
158 if ($socid) $sql .= " AND c.fk_soc = ".$socid;
159 $sql .= " ORDER BY e.date_delivery DESC";
160 $sql .= $db->plimit($max, 0);
161 
162 $resql = $db->query($sql);
163 if ($resql)
164 {
165  $num = $db->num_rows($resql);
166 
167  print '<div class="div-table-responsive-no-min">';
168  print '<table class="noborder centpercent">';
169  print '<tr class="liste_titre">';
170  print '<th colspan="4">';
171  print $langs->trans("LastSendings").' ';
172  print '<a href="'.DOL_URL_ROOT.'/expedition/list.php?search_status='.Expedition::STATUS_VALIDATED.'">';
173  print '<span class="badge">'.$num.'</span>';
174  print '</a>';
175  print '</th>';
176  print '</tr>';
177 
178  if ($num)
179  {
180  $i = 0;
181  while ($i < $num)
182  {
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  {
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 dol_print_error($db);
213 
214 /*
215  * Open orders
216  */
217 $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";
218 $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
219 $sql .= " ".MAIN_DB_PREFIX."societe as s";
220 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
221 $sql .= " WHERE c.fk_soc = s.rowid";
222 $sql .= " AND c.entity IN (".getEntity('order').")";
223 $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_ACCEPTED.")";
224 if ($socid > 0) $sql .= " AND c.fk_soc = ".$socid;
225 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
226 $sql .= " ORDER BY c.rowid ASC";
227 
228 $resql = $db->query($sql);
229 if ($resql)
230 {
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_ACCEPTED.'">';
241  print '<span class="badge">'.$num.'</span>';
242  print '</a>';
243  print '</th>';
244  print '</tr>';
245 
246  if ($num)
247  {
248  $i = 0;
249  while ($i < $num && $i < 10)
250  {
251  $obj = $db->fetch_object($resql);
252 
253  $orderstatic->id = $obj->rowid;
254  $orderstatic->ref = $obj->ref;
255  $orderstatic->ref_customer = $obj->ref_customer;
256  $orderstatic->statut = $obj->status;
257  $orderstatic->billed = $obj->billed;
258 
259  $companystatic->name = $obj->name;
260  $companystatic->id = $obj->socid;
261 
262  print '<tr class="oddeven"><td>';
263  print $orderstatic->getNomUrl(1);
264  print '</td>';
265  print '<td>';
266  print $companystatic->getNomUrl(1, 'customer', 32);
267  print '</td>';
268  print '<td class="right">';
269  print $orderstatic->getLibStatut(3);
270  print '</td>';
271  print '</tr>';
272  $i++;
273  }
274 
275  if ($i < $num) {
276  print '<tr class="opacitymedium">';
277  print '<td>'.$langs->trans("More").'...</td>';
278  print '<td></td>';
279  print '<td></td>';
280  print '</tr>';
281  }
282  } else {
283  print '<tr><td>'.$langs->trans("None").'</td><td></td><td></td></tr>';
284  }
285 
286  print "</table></div><br>";
287 } else dol_print_error($db);
288 
289 
290 print '</div></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
296 llxFooter();
297 $db->close();
const STATUS_DRAFT
Draft status.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage hooks.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage shipments.
Class to manage customers orders.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
const STATUS_VALIDATED
Validated status.
const STATUS_VALIDATED
Validated status.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.