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