dolibarr  x.y.z
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6  * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7  * Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
8  * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
30 // Load Dolibarr environment
31 require '../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
43 if (isModEnabled('ficheinter')) {
44  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
45 }
46 
47 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
48 $hookmanager = new HookManager($db);
49 $hookmanager->initHooks(array('commercialindex'));
50 
51 // Load translation files required by the page
52 $langs->loadLangs(array("boxes", "commercial", "contracts", "orders", "propal", "supplier_proposal"));
53 
54 $action = GETPOST('action', 'aZ09');
55 $bid = GETPOST('bid', 'int');
56 
57 // Securite acces client
58 $socid = GETPOST('socid', 'int');
59 if (isset($user->socid) && $user->socid > 0) {
60  $action = '';
61  $socid = $user->socid;
62 }
63 
64 $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
65 $now = dol_now();
66 
67 // Security check
68 $socid = GETPOST("socid", 'int');
69 if ($user->socid > 0) {
70  $action = '';
71  $id = $user->socid;
72 } else {
73  $id = 0;
74 }
75 
76 //restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
77 if (!$user->hasRight('propal', 'read') && !$user->hasRight('supplier_proposal', 'read') && !$user->hasRight('commande', 'read') && !$user->hasRight('fournisseur', 'commande', 'read')
78  && !$user->hasRight('supplier_order', 'read') && !$user->hasRight('fichinter', 'read')) {
80 }
81 
82 $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
83 
84 
85 /*
86  * Actions
87  */
88 
89 // None
90 
91 
92 /*
93  * View
94  */
95 
96 $form = new Form($db);
97 $formfile = new FormFile($db);
98 $companystatic = new Societe($db);
99 if (isModEnabled("propal")) {
100  $propalstatic = new Propal($db);
101 }
102 if (isModEnabled('supplier_proposal')) {
103  $supplierproposalstatic = new SupplierProposal($db);
104 }
105 if (isModEnabled('commande')) {
106  $orderstatic = new Commande($db);
107 }
108 if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) {
109  $supplierorderstatic = new CommandeFournisseur($db);
110 }
111 
112 if (isModEnabled('ficheinter')) {
113  $fichinterstatic = new Fichinter($db);
114 }
115 
116 llxHeader("", $langs->trans("CommercialArea"));
117 
118 print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial');
119 
120 print '<div class="fichecenter"><div class="fichethirdleft">';
121 
122 $tmp = getCustomerProposalPieChart($socid);
123 if ($tmp) {
124  print $tmp;
125  print '<br>';
126 }
127 $tmp = getCustomerOrderPieChart($socid);
128 if ($tmp) {
129  print $tmp;
130  print '<br>';
131 }
132 
133 /*
134  * Draft customer proposals
135  */
136 
137 if (isModEnabled("propal") && $user->hasRight("propal", "lire")) {
138  $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
139  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
140  $sql .= ", s.code_client, s.code_compta, s.client";
141  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
142  $sql .= ", s.logo, s.email, s.entity";
143  $sql .= ", s.canvas";
144  $sql .= " FROM ".MAIN_DB_PREFIX."propal as p,";
145  $sql .= " ".MAIN_DB_PREFIX."societe as s";
146  if (empty($user->rights->societe->client->voir) && !$socid) {
147  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
148  }
149  $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
150  $sql .= " AND p.fk_soc = s.rowid";
151  $sql .= " AND p.fk_statut = ".Propal::STATUS_DRAFT;
152  if (empty($user->rights->societe->client->voir) && !$socid) {
153  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
154  }
155  if ($socid) {
156  $sql .= " AND s.rowid = ".((int) $socid);
157  }
158 
159  $resql = $db->query($sql);
160  if ($resql) {
161  $total = 0;
162  $num = $db->num_rows($resql);
163  $nbofloop = min($num, $maxofloop);
164  startSimpleTable("ProposalsDraft", "comm/propal/list.php", "search_status=".Propal::STATUS_DRAFT, 2, $num);
165 
166  if ($num > 0) {
167  $i = 0;
168  $othernb = 0;
169 
170  while ($i < $nbofloop) {
171  $obj = $db->fetch_object($resql);
172 
173  if ($i >= $max) {
174  $othernb += 1;
175  $i++;
176  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
177  continue;
178  }
179 
180  $propalstatic->id = $obj->rowid;
181  $propalstatic->ref = $obj->ref;
182  $propalstatic->ref_client = $obj->ref_client;
183  $propalstatic->total_ht = $obj->total_ht;
184  $propalstatic->total_tva = $obj->total_tva;
185  $propalstatic->total_ttc = $obj->total_ttc;
186  $propalstatic->statut = $obj->status;
187 
188  $companystatic->id = $obj->socid;
189  $companystatic->name = $obj->name;
190  $companystatic->name_alias = $obj->name_alias;
191  $companystatic->code_client = $obj->code_client;
192  $companystatic->code_compta = $obj->code_compta;
193  $companystatic->client = $obj->client;
194  $companystatic->code_fournisseur = $obj->code_fournisseur;
195  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
196  $companystatic->fournisseur = $obj->fournisseur;
197  $companystatic->logo = $obj->logo;
198  $companystatic->email = $obj->email;
199  $companystatic->entity = $obj->entity;
200  $companystatic->canvas = $obj->canvas;
201 
202  print '<tr class="oddeven">';
203  print '<td class="nowraponall tdoverflowmax100">'.$propalstatic->getNomUrl(1).'</td>';
204  print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
205  print '<td class="nowrap right tdamount amount">'.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).'</td>';
206  print '</tr>';
207 
208  $i++;
209  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
210  }
211 
212  if ($othernb) {
213  print '<tr class="oddeven">';
214  print '<td class="nowrap" colspan="5">';
215  print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
216  print '</td>';
217  print "</tr>\n";
218  }
219  }
220 
221  addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
222  finishSimpleTable(true);
223 
224  $db->free($resql);
225  } else {
226  dol_print_error($db);
227  }
228 }
229 
230 
231 /*
232  * Draft supplier proposals
233  */
234 
235 if (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "lire")) {
236  $sql = "SELECT p.rowid, p.ref, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
237  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
238  $sql .= ", s.code_client, s.code_compta, s.client";
239  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
240  $sql .= ", s.logo, s.email, s.entity";
241  $sql .= ", s.canvas";
242  $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p,";
243  $sql .= " ".MAIN_DB_PREFIX."societe as s";
244  if (empty($user->rights->societe->client->voir) && !$socid) {
245  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
246  }
247  $sql .= " WHERE p.entity IN (".getEntity($supplierproposalstatic->element).")";
248  $sql .= " AND p.fk_statut = ".SupplierProposal::STATUS_DRAFT;
249  $sql .= " AND p.fk_soc = s.rowid";
250  if (empty($user->rights->societe->client->voir) && !$socid) {
251  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
252  }
253  if ($socid) {
254  $sql .= " AND s.rowid = ".((int) $socid);
255  }
256 
257  $resql = $db->query($sql);
258  if ($resql) {
259  $total = 0;
260  $num = $db->num_rows($resql);
261  $nbofloop = min($num, $maxofloop);
262  startSimpleTable("SupplierProposalsDraft", "supplier_proposal/list.php", "search_status=".SupplierProposal::STATUS_DRAFT, 2, $num);
263 
264  if ($num > 0) {
265  $i = 0;
266  $othernb = 0;
267 
268  while ($i < $nbofloop) {
269  $obj = $db->fetch_object($resql);
270 
271  if ($i >= $max) {
272  $othernb += 1;
273  $i++;
274  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
275  continue;
276  }
277 
278  $supplierproposalstatic->id = $obj->rowid;
279  $supplierproposalstatic->ref = $obj->ref;
280  $supplierproposalstatic->total_ht = $obj->total_ht;
281  $supplierproposalstatic->total_tva = $obj->total_tva;
282  $supplierproposalstatic->total_ttc = $obj->total_ttc;
283  $supplierproposalstatic->statut = $obj->status;
284 
285  $companystatic->id = $obj->socid;
286  $companystatic->name = $obj->name;
287  $companystatic->name_alias = $obj->name_alias;
288  $companystatic->code_client = $obj->code_client;
289  $companystatic->code_compta = $obj->code_compta;
290  $companystatic->client = $obj->client;
291  $companystatic->code_fournisseur = $obj->code_fournisseur;
292  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
293  $companystatic->fournisseur = $obj->fournisseur;
294  $companystatic->logo = $obj->logo;
295  $companystatic->email = $obj->email;
296  $companystatic->entity = $obj->entity;
297  $companystatic->canvas = $obj->canvas;
298 
299  print '<tr class="oddeven">';
300  print '<td class="nowraponall tdoverflowmax100">'.$supplierproposalstatic->getNomUrl(1).'</td>';
301  print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
302  print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
303  print '</tr>';
304 
305  $i++;
306  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
307  }
308 
309  if ($othernb) {
310  print '<tr class="oddeven">';
311  print '<td class="nowrap" colspan="5">';
312  print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
313  print '</td>';
314  print "</tr>\n";
315  }
316  }
317 
318  addSummaryTableLine(3, $num, $nbofloop, $total, "NoProposal");
319  finishSimpleTable(true);
320 
321  $db->free($resql);
322  } else {
323  dol_print_error($db);
324  }
325 }
326 
327 
328 /*
329  * Draft sales orders
330  */
331 
332 if (isModEnabled('commande') && $user->rights->commande->lire) {
333  $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status";
334  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
335  $sql .= ", s.code_client, s.code_compta, s.client";
336  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
337  $sql .= ", s.logo, s.email, s.entity";
338  $sql .= ", s.canvas";
339  $sql .= " FROM ".MAIN_DB_PREFIX."commande as c,";
340  $sql .= " ".MAIN_DB_PREFIX."societe as s";
341  if (empty($user->rights->societe->client->voir) && !$socid) {
342  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
343  }
344  $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
345  $sql .= " AND c.fk_statut = ".Commande::STATUS_DRAFT;
346  $sql .= " AND c.fk_soc = s.rowid";
347  if (empty($user->rights->societe->client->voir) && !$socid) {
348  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
349  }
350  if ($socid) {
351  $sql .= " AND c.fk_soc = ".((int) $socid);
352  }
353 
354  $resql = $db->query($sql);
355  if ($resql) {
356  $total = 0;
357  $num = $db->num_rows($resql);
358  $nbofloop = min($num, $maxofloop);
359  startSimpleTable("DraftOrders", "commande/list.php", "search_status=".Commande::STATUS_DRAFT, 2, $num);
360 
361  if ($num > 0) {
362  $i = 0;
363  $othernb = 0;
364 
365  while ($i < $nbofloop) {
366  $obj = $db->fetch_object($resql);
367 
368  if ($i >= $max) {
369  $othernb += 1;
370  $i++;
371  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
372  continue;
373  }
374 
375  $orderstatic->id = $obj->rowid;
376  $orderstatic->ref = $obj->ref;
377  $orderstatic->ref_client = $obj->ref_client;
378  $orderstatic->total_ht = $obj->total_ht;
379  $orderstatic->total_tva = $obj->total_tva;
380  $orderstatic->total_ttc = $obj->total_ttc;
381  $orderstatic->statut = $obj->status;
382 
383  $companystatic->id = $obj->socid;
384  $companystatic->name = $obj->name;
385  $companystatic->name_alias = $obj->name_alias;
386  $companystatic->code_client = $obj->code_client;
387  $companystatic->code_compta = $obj->code_compta;
388  $companystatic->client = $obj->client;
389  $companystatic->code_fournisseur = $obj->code_fournisseur;
390  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
391  $companystatic->fournisseur = $obj->fournisseur;
392  $companystatic->logo = $obj->logo;
393  $companystatic->email = $obj->email;
394  $companystatic->entity = $obj->entity;
395  $companystatic->canvas = $obj->canvas;
396 
397  print '<tr class="oddeven">';
398  print '<td class="nowraponall tdoverflowmax100">'.$orderstatic->getNomUrl(1).'</td>';
399  print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
400  print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
401  print '</tr>';
402 
403  $i++;
404  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
405  }
406 
407  if ($othernb) {
408  print '<tr class="oddeven">';
409  print '<td class="nowrap" colspan="5">';
410  print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
411  print '</td>';
412  print "</tr>\n";
413  }
414  }
415 
416  addSummaryTableLine(3, $num, $nbofloop, $total, "NoOrder");
417  finishSimpleTable(true);
418 
419  $db->free($resql);
420  } else {
421  dol_print_error($db);
422  }
423 }
424 
425 
426 /*
427  * Draft purchase orders
428  */
429 
430 if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "commande", "lire")) || (isModEnabled("supplier_order") && $user->hasRight("supplier_order", "lire"))) {
431  $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_statut as status";
432  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
433  $sql .= ", s.code_client, s.code_compta, s.client";
434  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
435  $sql .= ", s.logo, s.email, s.entity";
436  $sql .= ", s.canvas";
437  $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,";
438  $sql .= " ".MAIN_DB_PREFIX."societe as s";
439  if (empty($user->rights->societe->client->voir) && !$socid) {
440  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
441  }
442  $sql .= " WHERE cf.entity IN (".getEntity($supplierorderstatic->element).")";
443  $sql .= " AND cf.fk_statut = ".CommandeFournisseur::STATUS_DRAFT;
444  $sql .= " AND cf.fk_soc = s.rowid";
445  if (empty($user->rights->societe->client->voir) && !$socid) {
446  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
447  }
448  if ($socid) {
449  $sql .= " AND cf.fk_soc = ".((int) $socid);
450  }
451 
452  $resql = $db->query($sql);
453  if ($resql) {
454  $total = 0;
455  $num = $db->num_rows($resql);
456  $nbofloop = min($num, $maxofloop);
457  startSimpleTable("DraftSuppliersOrders", "fourn/commande/list.php", "search_status=".CommandeFournisseur::STATUS_DRAFT, 2, $num);
458 
459  if ($num > 0) {
460  $i = 0;
461  $othernb = 0;
462 
463  while ($i < $nbofloop) {
464  $obj = $db->fetch_object($resql);
465 
466  if ($i >= $max) {
467  $othernb += 1;
468  $i++;
469  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
470  continue;
471  }
472 
473  $supplierorderstatic->id = $obj->rowid;
474  $supplierorderstatic->ref = $obj->ref;
475  $supplierorderstatic->ref_supplier = $obj->ref_supplier;
476  $supplierorderstatic->total_ht = $obj->total_ht;
477  $supplierorderstatic->total_tva = $obj->total_tva;
478  $supplierorderstatic->total_ttc = $obj->total_ttc;
479  $supplierorderstatic->statut = $obj->status;
480 
481  $companystatic->id = $obj->socid;
482  $companystatic->name = $obj->name;
483  $companystatic->name_alias = $obj->name_alias;
484  $companystatic->code_client = $obj->code_client;
485  $companystatic->code_compta = $obj->code_compta;
486  $companystatic->client = $obj->client;
487  $companystatic->code_fournisseur = $obj->code_fournisseur;
488  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
489  $companystatic->fournisseur = $obj->fournisseur;
490  $companystatic->logo = $obj->logo;
491  $companystatic->email = $obj->email;
492  $companystatic->entity = $obj->entity;
493  $companystatic->canvas = $obj->canvas;
494 
495  print '<tr class="oddeven">';
496  print '<td class="nowraponall tdoverflowmax100">'.$supplierorderstatic->getNomUrl(1).'</td>';
497  print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
498  print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
499  print '</tr>';
500 
501  $i++;
502  $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
503  }
504 
505  if ($othernb) {
506  print '<tr class="oddeven">';
507  print '<td class="nowrap" colspan="5">';
508  print '<span class="opacitymedium">'.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').'</span>';
509  print '</td>';
510  print "</tr>\n";
511  }
512  }
513 
514  addSummaryTableLine(3, $num, $nbofloop, $total, "NoOrder");
515  finishSimpleTable(true);
516 
517  $db->free($resql);
518  } else {
519  dol_print_error($db);
520  }
521 }
522 
523 
524 /*
525  * Draft interventions
526  */
527 if (isModEnabled('ficheinter')) {
528  $sql = "SELECT f.rowid, f.ref, s.nom as name, f.fk_statut";
529  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
530  $sql .= ", s.code_client, s.code_compta, s.client";
531  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
532  $sql .= ", s.logo, s.email, s.entity";
533  $sql .= ", s.canvas";
534  $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
535  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
536  if (empty($user->rights->societe->client->voir) && !$socid) {
537  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
538  }
539  $sql .= " WHERE f.entity IN (".getEntity('intervention').")";
540  $sql .= " AND f.fk_soc = s.rowid";
541  $sql .= " AND f.fk_statut = 0";
542  if ($socid) {
543  $sql .= " AND f.fk_soc = ".((int) $socid);
544  }
545  if (empty($user->rights->societe->client->voir) && !$socid) {
546  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
547  }
548 
549 
550  $resql = $db->query($sql);
551  if ($resql) {
552  $num = $db->num_rows($resql);
553  $nbofloop = min($num, $maxofloop);
554  startSimpleTable("DraftFichinter", "fichinter/list.php", "search_status=".Fichinter::STATUS_DRAFT, 2, $num);
555 
556  //print '<tr class="liste_titre">';
557  //print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
558 
559  if ($num > 0) {
560  $i = 0;
561  while ($i < $nbofloop) {
562  $obj = $db->fetch_object($resql);
563 
564  $fichinterstatic->id=$obj->rowid;
565  $fichinterstatic->ref=$obj->ref;
566  $fichinterstatic->statut=$obj->fk_statut;
567 
568  $companystatic->id = $obj->socid;
569  $companystatic->name = $obj->name;
570  $companystatic->name_alias = $obj->name_alias;
571  $companystatic->code_client = $obj->code_client;
572  $companystatic->code_compta = $obj->code_compta;
573  $companystatic->client = $obj->client;
574  $companystatic->code_fournisseur = $obj->code_fournisseur;
575  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
576  $companystatic->fournisseur = $obj->fournisseur;
577  $companystatic->logo = $obj->logo;
578  $companystatic->email = $obj->email;
579  $companystatic->entity = $obj->entity;
580  $companystatic->canvas = $obj->canvas;
581 
582  print '<tr class="oddeven">';
583  print '<td class="nowraponall tdoverflowmax100">';
584  print $fichinterstatic->getNomUrl(1);
585  print "</td>";
586  print '<td class="nowrap tdoverflowmax100">';
587  print $companystatic->getNomUrl(1, 'customer');
588  print '</td></tr>';
589  $i++;
590  }
591  }
592 
593  addSummaryTableLine(3, $num, $nbofloop, $total, "NoIntervention");
594  finishSimpleTable(true);
595 
596  print "</table></div>";
597  }
598 }
599 
600 print '</div><div class="fichetwothirdright">';
601 
602 /*
603  * Last modified customers or prospects
604  */
605 if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) {
606  $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
607  $sql .= ", s.code_client, s.code_compta, s.client";
608  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
609  $sql .= ", s.logo, s.email, s.entity";
610  $sql .= ", s.canvas";
611  $sql .= ", s.datec, s.tms";
612  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
613  if (empty($user->rights->societe->client->voir) && !$socid) {
614  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
615  }
616  $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
617  $sql .= " AND s.client IN (".Societe::CUSTOMER.", ".Societe::PROSPECT.", ".Societe::CUSTOMER_AND_PROSPECT.")";
618  if (empty($user->rights->societe->client->voir) && !$socid) {
619  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
620  }
621  // Add where from hooks
622  $parameters = array('socid' => $socid);
623  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
624  if (empty($reshook)) {
625  if ($socid > 0) {
626  $sql .= " AND s.rowid = ".((int) $socid);
627  }
628  }
629  $sql .= $hookmanager->resPrint;
630  $sql .= " ORDER BY s.tms DESC";
631  $sql .= $db->plimit($max, 0);
632 
633  $resql = $db->query($sql);
634  if ($resql) {
635  if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
636  $header = "BoxTitleLastCustomersOrProspects";
637  } elseif (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
638  $header = "BoxTitleLastModifiedProspects";
639  } else {
640  $header = "BoxTitleLastModifiedCustomers";
641  }
642 
643  $num = $db->num_rows($resql);
644  startSimpleTable($langs->trans($header, min($max, $num)), "societe/list.php", "type=p,c", 1);
645 
646  if ($num) {
647  $i = 0;
648 
649  while ($i < $num && $i < $max) {
650  $objp = $db->fetch_object($resql);
651 
652  $companystatic->id = $objp->socid;
653  $companystatic->name = $objp->name;
654  $companystatic->name_alias = $objp->name_alias;
655  $companystatic->code_client = $objp->code_client;
656  $companystatic->code_compta = $objp->code_compta;
657  $companystatic->client = $objp->client;
658  $companystatic->code_fournisseur = $objp->code_fournisseur;
659  $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
660  $companystatic->fournisseur = $objp->fournisseur;
661  $companystatic->logo = $objp->logo;
662  $companystatic->email = $objp->email;
663  $companystatic->entity = $objp->entity;
664  $companystatic->canvas = $objp->canvas;
665 
666  print '<tr class="oddeven">';
667  print '<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
668  print '<td class="nowrap">';
669  //print $companystatic->getLibCustProspStatut();
670 
671  $obj = $companystatic;
672  $s = '';
673  if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
674  $s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
675  }
676  if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
677  $s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
678  }
679  /*
680  if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur)
681  {
682  $s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
683  }*/
684  print $s;
685 
686  print '</td>';
687 
688  $datem = $db->jdate($objp->tms);
689  print '<td class="right nowrap tddate" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
690  print dol_print_date($datem, 'day', 'tzuserrel');
691  print '</td>';
692  print '</tr>';
693 
694  $i++;
695  }
696  }
697 
698  addSummaryTableLine(3, $num);
699  finishSimpleTable(true);
700 
701  $db->free($resql);
702  } else {
703  dol_print_error($db);
704  }
705 }
706 
707 
708 /*
709  * Last suppliers
710  */
711 if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->hasRight('societe', 'lire')) {
712  $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
713  $sql .= ", s.code_client, s.code_compta, s.client";
714  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
715  $sql .= ", s.logo, s.email, s.entity";
716  $sql .= ", s.canvas";
717  $sql .= ", s.datec as dc, s.tms as dm";
718  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
719  if (empty($user->rights->societe->client->voir) && !$user->socid) {
720  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
721  }
722  $sql .= " WHERE s.entity IN (".getEntity($companystatic->element).")";
723  $sql .= " AND s.fournisseur = ".Societe::SUPPLIER;
724  if (empty($user->rights->societe->client->voir) && !$user->socid) {
725  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
726  }
727  // Add where from hooks
728  $parameters = array('socid' => $socid);
729  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
730  if (empty($reshook)) {
731  if ($socid > 0) {
732  $sql .= " AND s.rowid = ".((int) $socid);
733  }
734  }
735  $sql .= $hookmanager->resPrint;
736  $sql .= " ORDER BY s.datec DESC";
737  $sql .= $db->plimit($max, 0);
738 
739  $resql = $db->query($sql);
740  if ($resql) {
741  $num = $db->num_rows($resql);
742  startSimpleTable($langs->trans("BoxTitleLastModifiedSuppliers", min($max, $num)), "societe/list.php", "type=f", 1);
743 
744  if ($num) {
745  $i = 0;
746  while ($i < $num && $i < $max) {
747  $objp = $db->fetch_object($resql);
748 
749  $companystatic->id = $objp->socid;
750  $companystatic->name = $objp->name;
751  $companystatic->name_alias = $objp->name_alias;
752  $companystatic->code_client = $objp->code_client;
753  $companystatic->code_compta = $objp->code_compta;
754  $companystatic->client = $objp->client;
755  $companystatic->code_fournisseur = $objp->code_fournisseur;
756  $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
757  $companystatic->fournisseur = $objp->fournisseur;
758  $companystatic->logo = $objp->logo;
759  $companystatic->email = $objp->email;
760  $companystatic->entity = $objp->entity;
761  $companystatic->canvas = $objp->canvas;
762 
763  print '<tr class="oddeven">';
764  print '<td class="nowraponall tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
765  print '<td>';
766 
767  $obj = $companystatic;
768  $s = '';
769  /*if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
770  $s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
771  }
772  if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
773  {
774  $s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
775  }*/
776  if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) {
777  $s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
778  }
779  print $s;
780 
781  print '</td>';
782 
783  $datem = $db->jdate($objp->dm);
784  print '<td class="right tddate" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'">';
785  print dol_print_date($datem, 'day', 'tzuserrel');
786  print '</td>';
787  print '</tr>';
788 
789  $i++;
790  }
791  }
792 
793  addSummaryTableLine(3, $num);
794  finishSimpleTable(true);
795 
796  $db->free($resql);
797  } else {
798  dol_print_error($db);
799  }
800 }
801 
802 
803 /*
804  * Last actions
805  */
806 /*if ($user->rights->agenda->myactions->read) {
807  show_array_last_actions_done($max);
808 }*/
809 
810 
811 /*
812  * Actions to do
813  */
814 /*if ($user->rights->agenda->myactions->read) {
815  show_array_actions_to_do($max);
816 }*/
817 
818 
819 /*
820  * Latest contracts
821  */
822 if (isModEnabled('contrat') && $user->hasRight("contrat", "lire") && 0) { // TODO A REFAIRE DEPUIS NOUVEAU CONTRAT
823  $staticcontrat = new Contrat($db);
824 
825  $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
826  $sql .= ", s.code_client, s.code_compta, s.client";
827  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
828  $sql .= ", s.logo, s.email, s.entity";
829  $sql .= ", s.canvas";
830  $sql .= ", c.statut, c.rowid as contratid, p.ref, c.fin_validite as datefin, c.date_cloture as dateclo";
831  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
832  $sql .= ", ".MAIN_DB_PREFIX."contrat as c";
833  $sql .= ", ".MAIN_DB_PREFIX."product as p";
834  if (empty($user->rights->societe->client->voir) && !$socid) {
835  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
836  }
837  $sql .= " WHERE c.entity IN (".getEntity($staticcontrat->element).")";
838  $sql .= " AND c.fk_soc = s.rowid";
839  $sql .= " AND c.fk_product = p.rowid";
840  if (empty($user->rights->societe->client->voir) && !$socid) {
841  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
842  }
843  if ($socid) {
844  $sql .= " AND s.rowid = ".((int) $socid);
845  }
846  $sql .= " ORDER BY c.tms DESC";
847  $sql .= $db->plimit($max + 1, 0);
848 
849  $resql = $db->query($sql);
850  if ($resql) {
851  $num = $db->num_rows($resql);
852  startSimpleTable($langs->trans("LastContracts", $max), "", "", 2);
853 
854  if ($num > 0) {
855  $i = 0;
856 
857  while ($i < $num) {
858  $obj = $db->fetch_object($resql);
859 
860  $companystatic->id = $obj->socid;
861  $companystatic->name = $obj->name;
862  $companystatic->name_alias = $obj->name_alias;
863  $companystatic->code_client = $obj->code_client;
864  $companystatic->code_compta = $obj->code_compta;
865  $companystatic->client = $obj->client;
866  $companystatic->code_fournisseur = $obj->code_fournisseur;
867  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
868  $companystatic->fournisseur = $obj->fournisseur;
869  $companystatic->logo = $obj->logo;
870  $companystatic->email = $obj->email;
871  $companystatic->entity = $obj->entity;
872  $companystatic->canvas = $obj->canvas;
873 
874  $staticcontrat->id = $obj->contratid;
875  $staticcontrat->ref = $obj->ref;
876 
877  print '<tr class="oddeven">';
878  print '<td class="nowraponall">'.$staticcontrat->getNomUrl(1).'</td>';
879  print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
880  print '<td class="right">'.$staticcontrat->LibStatut($obj->statut, 3).'</td>';
881  print '</tr>';
882 
883  $i++;
884  }
885  }
886 
887  addSummaryTableLine(2, $num);
888  finishSimpleTable(true);
889 
890  $db->free($resql);
891  } else {
892  dol_print_error($db);
893  }
894 }
895 
896 
897 /*
898  * Opened (validated) proposals
899  */
900 if (isModEnabled("propal") && $user->hasRight("propal", "lire")) {
901  $sql = "SELECT p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
902  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
903  $sql .= ", s.code_client, s.code_compta, s.client";
904  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
905  $sql .= ", s.logo, s.email, s.entity";
906  $sql .= ", s.canvas";
907  $sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
908  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
909  if (empty($user->rights->societe->client->voir) && !$socid) {
910  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
911  }
912  $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")";
913  $sql .= " AND p.fk_soc = s.rowid";
914  $sql .= " AND p.fk_statut = ".Propal::STATUS_VALIDATED;
915  if (empty($user->rights->societe->client->voir) && !$socid) {
916  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
917  }
918  if ($socid) {
919  $sql .= " AND s.rowid = ".((int) $socid);
920  }
921  $sql .= " ORDER BY p.rowid DESC";
922 
923  $resql = $db->query($sql);
924  if ($resql) {
925  $total = $total_ttc = 0;
926  $num = $db->num_rows($resql);
927  $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
928  startSimpleTable("ProposalsOpened", "comm/propal/list.php", "search_status=1", 4, $num);
929 
930  if ($num > 0) {
931  $i = 0;
932  $othernb = 0;
933 
934  while ($i < $nbofloop) {
935  $obj = $db->fetch_object($resql);
936 
937  if ($i >= $max) {
938  $othernb += 1;
939  $i++;
940  $total += $obj->total_ht;
941  $total_ttc += $obj->total_ttc;
942  continue;
943  }
944 
945  $propalstatic->id = $obj->propalid;
946  $propalstatic->ref = $obj->ref;
947  $propalstatic->ref_client = $obj->ref_client;
948  $propalstatic->total_ht = $obj->total_ht;
949  $propalstatic->total_tva = $obj->total_tva;
950  $propalstatic->total_ttc = $obj->total_ttc;
951 
952  $companystatic->id = $obj->socid;
953  $companystatic->name = $obj->name;
954  $companystatic->name_alias = $obj->name_alias;
955  $companystatic->code_client = $obj->code_client;
956  $companystatic->code_compta = $obj->code_compta;
957  $companystatic->client = $obj->client;
958  $companystatic->code_fournisseur = $obj->code_fournisseur;
959  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
960  $companystatic->fournisseur = $obj->fournisseur;
961  $companystatic->logo = $obj->logo;
962  $companystatic->email = $obj->email;
963  $companystatic->entity = $obj->entity;
964  $companystatic->canvas = $obj->canvas;
965 
966  $filename = dol_sanitizeFileName($obj->ref);
967  $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref);
968  //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
969  $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
970 
971  print '<tr class="oddeven">';
972 
973  print '<td class="nowrap" width="140">';
974  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
975  print '<td class="nobordernopadding nowraponall">'.$propalstatic->getNomUrl(1).'</td>';
976  print '<td width="18" class="nobordernopadding nowrap">'.$warning.'</td>';
977  print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).'</td>';
978  print '</tr>';
979  print '</table>';
980  print '</td>';
981 
982  print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
983  $datem = $db->jdate($obj->dp);
984  print '<td class="center tddate" title="'.dol_escape_htmltag($langs->trans("Date").': '.dol_print_date($datem, 'day', 'tzserver')).'">';
985  print dol_print_date($datem, 'day', 'tzserver');
986  print '</td>';
987  print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
988  print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>';
989 
990  print '</tr>';
991 
992  $i++;
993  $total += $obj->total_ht;
994  $total_ttc += $obj->total_ttc;
995  }
996 
997  if ($othernb) {
998  print '<tr class="oddeven">';
999  print '<td class="nowrap" colspan="5">';
1000  print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
1001  print '</td>';
1002  print "</tr>\n";
1003  }
1004  }
1005 
1006  addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "NoProposal", true);
1007  finishSimpleTable(true);
1008 
1009  $db->free($resql);
1010  } else {
1011  dol_print_error($db);
1012  }
1013 }
1014 
1015 
1016 /*
1017  * Opened (validated) order
1018  */
1019 if (isModEnabled('commande') && $user->rights->commande->lire) {
1020  $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed";
1021  $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
1022  $sql .= ", s.code_client, s.code_compta, s.client";
1023  $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
1024  $sql .= ", s.logo, s.email, s.entity";
1025  $sql .= ", s.canvas";
1026  $sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
1027  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
1028  if (empty($user->rights->societe->client->voir) && !$socid) {
1029  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
1030  }
1031  $sql .= " WHERE c.entity IN (".getEntity($orderstatic->element).")";
1032  $sql .= " AND c.fk_soc = s.rowid";
1033  $sql .= " AND c.fk_statut IN (".Commande::STATUS_VALIDATED.", ".Commande::STATUS_SHIPMENTONPROCESS.")";
1034  if (empty($user->rights->societe->client->voir) && !$socid) {
1035  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1036  }
1037  if ($socid) {
1038  $sql .= " AND s.rowid = ".((int) $socid);
1039  }
1040  $sql .= " ORDER BY c.rowid DESC";
1041 
1042  $resql = $db->query($sql);
1043  if ($resql) {
1044  $total = $total_ttc = 0;
1045  $num = $db->num_rows($resql);
1046  $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
1047  startSimpleTable("OrdersOpened", "commande/list.php", "search_status=".Commande::STATUS_VALIDATED, 4, $num);
1048 
1049  if ($num > 0) {
1050  $i = 0;
1051  $othernb = 0;
1052 
1053  while ($i < $nbofloop) {
1054  $obj = $db->fetch_object($resql);
1055 
1056  if ($i >= $max) {
1057  $othernb += 1;
1058  $i++;
1059  $total += $obj->total_ht;
1060  $total_ttc += $obj->total_ttc;
1061  continue;
1062  }
1063 
1064  $orderstatic->id = $obj->commandeid;
1065  $orderstatic->ref = $obj->ref;
1066  $orderstatic->ref_client = $obj->ref_client;
1067  $orderstatic->statut = $obj->fk_statut;
1068  $orderstatic->total_ht = $obj->total_ht;
1069  $orderstatic->total_tva = $obj->total_tva;
1070  $orderstatic->total_ttc = $obj->total_ttc;
1071 
1072  $companystatic->id = $obj->socid;
1073  $companystatic->name = $obj->name;
1074  $companystatic->name_alias = $obj->name_alias;
1075  $companystatic->code_client = $obj->code_client;
1076  $companystatic->code_compta = $obj->code_compta;
1077  $companystatic->client = $obj->client;
1078  $companystatic->code_fournisseur = $obj->code_fournisseur;
1079  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1080  $companystatic->fournisseur = $obj->fournisseur;
1081  $companystatic->logo = $obj->logo;
1082  $companystatic->email = $obj->email;
1083  $companystatic->entity = $obj->entity;
1084  $companystatic->canvas = $obj->canvas;
1085 
1086  $filename = dol_sanitizeFileName($obj->ref);
1087  $filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
1088  //$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->propalid;
1089  //$warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ? img_warning($langs->trans("Late")) : '';
1090 
1091  print '<tr class="oddeven">';
1092 
1093  print '<td class="nowrap" width="140">';
1094  print '<table class="nobordernopadding"><tr class="nocellnopadd">';
1095  print '<td class="nobordernopadding nowraponall">'.$orderstatic->getNomUrl(1).'</td>';
1096  print '<td width="18" class="nobordernopadding nowrap"></td>';
1097  print '<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($orderstatic->element, $filename, $filedir).'</td>';
1098  print '</tr>';
1099  print '</table>';
1100  print '</td>';
1101 
1102  print '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
1103  $datem = $db->jdate($obj->dv);
1104  print '<td class="center tddate" title="'.dol_escape_htmltag($langs->trans("DateValue").': '.dol_print_date($datem, 'day', 'tzserver')).'">';
1105  print dol_print_date($datem, 'day', 'tzserver');
1106  print '</td>';
1107 
1108  print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
1109  print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).'</td>';
1110 
1111  print '</tr>';
1112 
1113  $i++;
1114  $total += $obj->total_ht;
1115  $total_ttc += $obj->total_ttc;
1116  }
1117 
1118  if ($othernb) {
1119  print '<tr class="oddeven">';
1120  print '<td class="nowrap" colspan="5">';
1121  print '<span class="opacitymedium">'.$langs->trans("More").'... ('.$othernb.')</span>';
1122  print '</td>';
1123  print "</tr>\n";
1124  }
1125  }
1126 
1127  addSummaryTableLine(5, $num, $nbofloop, empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $total_ttc : $total, "None", true);
1128  finishSimpleTable(true);
1129 
1130  $db->free($resql);
1131  } else {
1132  dol_print_error($db);
1133  }
1134 }
1135 
1136 print '</div>';
1137 print '</div>';
1138 
1139 $parameters = array('user' => $user);
1140 $reshook = $hookmanager->executeHooks('dashboardCommercials', $parameters, $object); // Note that $action and $object may have been modified by hook
1141 
1142 // End of page
1143 llxFooter();
1144 $db->close();
Class to manage predefined suppliers products.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
Class to manage contracts.
Class to manage interventions.
const STATUS_DRAFT
Draft status.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage hooks.
Class to manage proposals.
const STATUS_DRAFT
Draft status.
Class to manage third parties objects (customers, suppliers, prospects...)
const PROSPECT
Third party type is a prospect.
const CUSTOMER_AND_PROSPECT
Third party type is a customer and a prospect.
Class to manage price ask supplier.
const STATUS_DRAFT
Draft status.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
startSimpleTable($header, $link="", $arguments="", $emptyRows=0, $number=-1)
Start a table with headers and a optinal clickable number (don't forget to use "finishSimpleTable()" ...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
addSummaryTableLine($tableColumnCount, $num, $nbofloop=0, $total=0, $noneWord="None", $extraRightColumn=false)
Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx")
isModEnabled($module)
Is Dolibarr module enabled.
getCustomerOrderPieChart($socid=0)
Return a HTML table that contains a pie chart of sales orders.
Definition: order.lib.php:197
getCustomerProposalPieChart($socid=0)
Return a HTML table that contains a pie chart of customer proposals.
Definition: propal.lib.php:178
llxFooter()
Footer empty.
Definition: index.php:71
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
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.